Commit ce19969b authored by ElenaSubbotina's avatar ElenaSubbotina

PptxFormat - fix objects without replacement image

parent e9805cef
...@@ -346,8 +346,11 @@ namespace NSBinPptxRW ...@@ -346,8 +346,11 @@ namespace NSBinPptxRW
{ {
oPathOutput = m_strDstMedia + FILE_SEPARATOR_STR + strImage + strExts; oPathOutput = m_strDstMedia + FILE_SEPARATOR_STR + strImage + strExts;
if (oPathOutput.GetPath() != strInput) if (oPathOutput.GetPath() != strInput && NSFile::CFileBinary::Exists(strInput))
CDirectory::CopyFile(strInput, oPathOutput.GetPath()); {
NSFile::CFileBinary::Copy(strInput, oPathOutput.GetPath());
oImageManagerInfo.sFilepathImage = oPathOutput.GetPath();
}
} }
else else
{ {
...@@ -355,8 +358,8 @@ namespace NSBinPptxRW ...@@ -355,8 +358,8 @@ namespace NSBinPptxRW
strExts = _T(".png"); strExts = _T(".png");
oPathOutput = m_strDstMedia + FILE_SEPARATOR_STR + strImage + strExts; oPathOutput = m_strDstMedia + FILE_SEPARATOR_STR + strImage + strExts;
SaveImageAsPng(strInput, oPathOutput.GetPath()); SaveImageAsPng(strInput, oPathOutput.GetPath());
oImageManagerInfo.sFilepathImage = oPathOutput.GetPath();
} }
oImageManagerInfo.sFilepathImage = oPathOutput.GetPath();
if ((!strAdditionalImage.empty() || !oleData.empty() ) && (nAdditionalType == 1)) if ((!strAdditionalImage.empty() || !oleData.empty() ) && (nAdditionalType == 1))
{ {
...@@ -374,13 +377,14 @@ namespace NSBinPptxRW ...@@ -374,13 +377,14 @@ namespace NSBinPptxRW
if(!oleData.empty()) if(!oleData.empty())
{ {
WriteOleData(strAdditionalImageOut, oleData); 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) else if (!strAdditionalImage.empty() && nAdditionalType == 2)
{ {
...@@ -395,8 +399,11 @@ namespace NSBinPptxRW ...@@ -395,8 +399,11 @@ namespace NSBinPptxRW
std::wstring strAdditionalImageOut = pathOutput.GetPath(); std::wstring strAdditionalImageOut = pathOutput.GetPath();
CDirectory::CopyFile(strAdditionalImage, strAdditionalImageOut); if (NSFile::CFileBinary::Exists(strAdditionalImage))
oImageManagerInfo.sFilepathAdditional = strAdditionalImageOut; {
NSFile::CFileBinary::Copy(strAdditionalImage, strAdditionalImageOut);
oImageManagerInfo.sFilepathAdditional = strAdditionalImageOut;
}
} }
return oImageManagerInfo; return oImageManagerInfo;
...@@ -1236,24 +1243,28 @@ namespace NSBinPptxRW ...@@ -1236,24 +1243,28 @@ namespace NSBinPptxRW
if (m_pManager->m_nDocumentType == XMLWRITER_DOC_TYPE_DOCX) strImageRelsPath = L"media/"; if (m_pManager->m_nDocumentType == XMLWRITER_DOC_TYPE_DOCX) strImageRelsPath = L"media/";
else 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; _relsGeneratorInfo oRelsGeneratorInfo;
oRelsGeneratorInfo.nImageRId = m_lNextRelsID++; if (!oImageManagerInfo.sFilepathImage.empty())
oRelsGeneratorInfo.sFilepathImage = oImageManagerInfo.sFilepathImage; {
strImageRelsPath += OOX::CPath(oImageManagerInfo.sFilepathImage).GetFilename();
std::wstring strRid = L"rId" + std::to_wstring(oRelsGeneratorInfo.nImageRId);
std::map<std::wstring, _relsGeneratorInfo>::iterator pPair = m_mapImages.find(strImageRelsPath);
m_pWriter->WriteString( L"<Relationship Id=\"" + strRid + if (m_mapImages.end() != pPair)
L"\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image\" Target=\"" + strImageRelsPath + {
L"\"/>"); 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>()) if(additionalFile.is<OOX::OleObject>())
{ {
...@@ -1285,7 +1296,7 @@ namespace NSBinPptxRW ...@@ -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>(); smart_ptr<OOX::Media> mediaFile = additionalFile.smart_dynamic_cast<OOX::Media>();
......
...@@ -447,7 +447,10 @@ namespace PPTX ...@@ -447,7 +447,10 @@ namespace PPTX
if (!blip.is_init()) if (!blip.is_init())
blip = new PPTX::Logic::Blip(); 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) if(oRelsGeneratorInfo.nOleRId > 0)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment