Compare commits

...

3 Commits

3 changed files with 180 additions and 30 deletions

View File

@ -346,8 +346,11 @@ namespace NSBinPptxRW
{
oPathOutput = m_strDstMedia + FILE_SEPARATOR_STR + strImage + strExts;
if (oPathOutput.GetPath() != strInput)
CDirectory::CopyFile(strInput, oPathOutput.GetPath());
if (oPathOutput.GetPath() != strInput && NSFile::CFileBinary::Exists(strInput))
{
NSFile::CFileBinary::Copy(strInput, oPathOutput.GetPath());
oImageManagerInfo.sFilepathImage = oPathOutput.GetPath();
}
}
else
{
@ -355,8 +358,8 @@ namespace NSBinPptxRW
strExts = _T(".png");
oPathOutput = m_strDstMedia + FILE_SEPARATOR_STR + strImage + strExts;
SaveImageAsPng(strInput, oPathOutput.GetPath());
oImageManagerInfo.sFilepathImage = oPathOutput.GetPath();
}
oImageManagerInfo.sFilepathImage = oPathOutput.GetPath();
if ((!strAdditionalImage.empty() || !oleData.empty() ) && (nAdditionalType == 1))
{
@ -374,13 +377,14 @@ namespace NSBinPptxRW
if(!oleData.empty())
{
WriteOleData(strAdditionalImageOut, oleData);
oImageManagerInfo.sFilepathAdditional = strAdditionalImageOut;
}
else
else if (NSFile::CFileBinary::Exists(strAdditionalImage))
{
CDirectory::CopyFile(strAdditionalImage, strAdditionalImageOut);
NSFile::CFileBinary::Copy(strAdditionalImage, strAdditionalImageOut);
oImageManagerInfo.sFilepathAdditional = strAdditionalImageOut;
}
oImageManagerInfo.sFilepathAdditional = strAdditionalImageOut;
}
else if (!strAdditionalImage.empty() && nAdditionalType == 2)
{
@ -395,8 +399,11 @@ namespace NSBinPptxRW
std::wstring strAdditionalImageOut = pathOutput.GetPath();
CDirectory::CopyFile(strAdditionalImage, strAdditionalImageOut);
oImageManagerInfo.sFilepathAdditional = strAdditionalImageOut;
if (NSFile::CFileBinary::Exists(strAdditionalImage))
{
NSFile::CFileBinary::Copy(strAdditionalImage, strAdditionalImageOut);
oImageManagerInfo.sFilepathAdditional = strAdditionalImageOut;
}
}
return oImageManagerInfo;
@ -1236,24 +1243,28 @@ namespace NSBinPptxRW
if (m_pManager->m_nDocumentType == XMLWRITER_DOC_TYPE_DOCX) strImageRelsPath = L"media/";
else strImageRelsPath = L"../media/";
strImageRelsPath += OOX::CPath(oImageManagerInfo.sFilepathImage).GetFilename();
std::map<std::wstring, _relsGeneratorInfo>::iterator pPair = m_mapImages.find(strImageRelsPath);
if (m_mapImages.end() != pPair)
{
return pPair->second;
}
_relsGeneratorInfo oRelsGeneratorInfo;
oRelsGeneratorInfo.nImageRId = m_lNextRelsID++;
oRelsGeneratorInfo.sFilepathImage = oImageManagerInfo.sFilepathImage;
std::wstring strRid = L"rId" + std::to_wstring(oRelsGeneratorInfo.nImageRId);
if (!oImageManagerInfo.sFilepathImage.empty())
{
strImageRelsPath += OOX::CPath(oImageManagerInfo.sFilepathImage).GetFilename();
m_pWriter->WriteString( L"<Relationship Id=\"" + strRid +
L"\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image\" Target=\"" + strImageRelsPath +
L"\"/>");
std::map<std::wstring, _relsGeneratorInfo>::iterator pPair = m_mapImages.find(strImageRelsPath);
if (m_mapImages.end() != pPair)
{
return pPair->second;
}
oRelsGeneratorInfo.nImageRId = m_lNextRelsID++;
oRelsGeneratorInfo.sFilepathImage = oImageManagerInfo.sFilepathImage;
std::wstring strRid = L"rId" + std::to_wstring(oRelsGeneratorInfo.nImageRId);
m_pWriter->WriteString( L"<Relationship Id=\"" + strRid +
L"\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image\" Target=\"" + strImageRelsPath +
L"\"/>");
}
if(additionalFile.is<OOX::OleObject>())
{
@ -1285,7 +1296,7 @@ namespace NSBinPptxRW
}
}
}
if(additionalFile.is<OOX::Media>())
else if(additionalFile.is<OOX::Media>())
{
smart_ptr<OOX::Media> mediaFile = additionalFile.smart_dynamic_cast<OOX::Media>();

View File

@ -447,7 +447,10 @@ namespace PPTX
if (!blip.is_init())
blip = new PPTX::Logic::Blip();
blip->embed = new OOX::RId((size_t)oRelsGeneratorInfo.nImageRId);
if (oRelsGeneratorInfo.nImageRId >= 0)
{
blip->embed = new OOX::RId((size_t)oRelsGeneratorInfo.nImageRId);
}
if(oRelsGeneratorInfo.nOleRId > 0)
{

View File

@ -138,22 +138,158 @@ namespace ParseAllCultureInfo
{
var index = aTemp[i];
if(nIndexD == index)
sShortDatePattern += "0";
else if (nIndexM == index)
sShortDatePattern += "1";
{
if (nIndexD + 1 < ShortDatePatternLower.Length && 'd' == ShortDatePatternLower[nIndexD + 1])
{
sShortDatePattern += "1";
}
else
{
sShortDatePattern += "0";
}
} else if (nIndexM == index)
{
if (nIndexM + 1 < ShortDatePatternLower.Length && 'm' == ShortDatePatternLower[nIndexM + 1])
{
sShortDatePattern += "3";
}
else
{
sShortDatePattern += "2";
}
}
else if (nIndexY == index)
sShortDatePattern += "2";
{
if (nIndexY + 2 < ShortDatePatternLower.Length && 'y' == ShortDatePatternLower[nIndexY + 2])
{
sShortDatePattern += "5";
}
else
{
sShortDatePattern += "4";
}
}
}
ShortDatePattern = sShortDatePattern;
}
}
static Dictionary<int, int> g_mapUsedValues = new Dictionary<int, int>() {
{4, 1},
{5, 1},
{7, 1},
{8, 1},
{9, 1},
{10, 1},
{11, 1},
{12, 1},
{16, 1},
{17, 1},
{18, 1},
{21, 1},
{22, 1},
{25, 1},
{31, 1},
{34, 1},
{36, 1},
{38, 1},
{42, 1},
{44, 1},
{1028, 1},
{1029, 1},
{1031, 1},
{1032, 1},
{1033, 1},
{1035, 1},
{1036, 1},
{1040, 1},
{1041, 1},
{1042, 1},
{1045, 1},
{1046, 1},
{1049, 1},
{1055, 1},
{1058, 1},
{1060, 1},
{1062, 1},
{1066, 1},
{1068, 1},
{2052, 1},
{2055, 1},
{2057, 1},
{2058, 1},
{2060, 1},
{2064, 1},
{2070, 1},
{2073, 1},
{2092, 1},
{3076, 1},
{3079, 1},
{3081, 1},
{3082, 1},
{3084, 1},
{4100, 1},
{4103, 1},
{4105, 1},
{4106, 1},
{4108, 1},
{5124, 1},
{5127, 1},
{5129, 1},
{5130, 1},
{5132, 1},
{6153, 1},
{6154, 1},
{6156, 1},
{7177, 1},
{7178, 1},
{7180, 1},
{8201, 1},
{8202, 1},
{8204, 1},
{9225, 1},
{9226, 1},
{9228, 1},
{10249, 1},
{10250, 1},
{10252, 1},
{11273, 1},
{11274, 1},
{11276, 1},
{12297, 1},
{12298, 1},
{12300, 1},
{13321, 1},
{13322, 1},
{13324, 1},
{14345, 1},
{14346, 1},
{14348, 1},
{15369, 1},
{15370, 1},
{15372, 1},
{16393, 1},
{16394, 1},
{17417, 1},
{17418, 1},
{18441, 1},
{18442, 1},
{19466, 1},
{20490, 1},
{21514, 1},
{22538, 1},
{23562, 1},
{29740, 1},
{30724, 1},
{30764, 1},
{31748, 1}
};
public static void parse()
{
List<int> aLcid = new List<int>();
Dictionary<int, CultureInfo> aInfos = new Dictionary<int, CultureInfo>();
foreach (CultureInfo ci in CultureInfo.GetCultures(CultureTypes.AllCultures))
{
if (!aInfos.ContainsKey(ci.LCID))
if (!aInfos.ContainsKey(ci.LCID) && g_mapUsedValues.ContainsKey(ci.LCID))
{
aLcid.Add(ci.LCID);
aInfos[ci.LCID] = ci;