diff --git a/OOXML/Binary/Document/BinReader/Readers.cpp b/OOXML/Binary/Document/BinReader/Readers.cpp index 5b687a9cad..4e1d303eee 100644 --- a/OOXML/Binary/Document/BinReader/Readers.cpp +++ b/OOXML/Binary/Document/BinReader/Readers.cpp @@ -4820,6 +4820,12 @@ int Binary_DocumentTableReader::ReadDocumentContent(BYTE type, long length, void READ1_DEF(length, res, this->ReadDocParts, &oDocParts); m_oDocumentWriter.m_oContent.WriteString(L""); } + else if (c_oSerParType::JsaProjectExternal == type) + { + std::wstring filePath = m_oBufferedStream.GetString3(length); + unsigned int lId = 0; + m_oFileWriter.m_pDrawingConverter->WriteRels(OOX::FileTypes::JsaProject.RelationType(), filePath, L"External", &lId); + } else if(c_oSerParType::JsaProject == type) { BYTE* pData = m_oBufferedStream.GetPointer(length); @@ -5670,7 +5676,7 @@ int Binary_DocumentTableReader::ReadHyperlink(BYTE type, long length, void* poRe { unsigned int rId; std::wstring sHref = XmlUtils::EncodeXmlString(pHyperlink->sLink); - m_oFileWriter.m_pDrawingConverter->WriteRels(std::wstring(_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink")), sHref, std::wstring(_T("External")), &rId); + m_oFileWriter.m_pDrawingConverter->WriteRels(std::wstring(_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink")), sHref, std::wstring(L"External"), &rId); pHyperlink->rId = L"rId" + std::to_wstring(rId); } m_pCurWriter = pPrevWriter; diff --git a/OOXML/Binary/Document/BinWriter/BinReaderWriterDefines.h b/OOXML/Binary/Document/BinWriter/BinReaderWriterDefines.h index 3159a0683a..71089ec93f 100644 --- a/OOXML/Binary/Document/BinWriter/BinReaderWriterDefines.h +++ b/OOXML/Binary/Document/BinWriter/BinReaderWriterDefines.h @@ -535,7 +535,8 @@ extern int g_nCurFormatVersion; AltChunk = 26, DocParts = 27, PermStart = 28, - PermEnd = 29 + PermEnd = 29, + JsaProjectExternal = 30 };} namespace c_oSerGlossary { enum c_oSerGlossary diff --git a/OOXML/Binary/Document/BinWriter/BinWriters.cpp b/OOXML/Binary/Document/BinWriter/BinWriters.cpp index 71ef38188e..6f890a0503 100644 --- a/OOXML/Binary/Document/BinWriter/BinWriters.cpp +++ b/OOXML/Binary/Document/BinWriter/BinWriters.cpp @@ -3450,14 +3450,23 @@ void BinaryDocumentTableWriter::WriteDocumentContent(const std::vectorfilename().GetPath(), &pData, nBytesCount)) + if (pJsaProject->IsExist() && !pJsaProject->IsExternal()) { - nCurPos = m_oBcw.WriteItemStart(c_oSerParType::JsaProject); - m_oBcw.m_oStream.WriteBYTEArray(pData, nBytesCount); + BYTE* pData = NULL; + DWORD nBytesCount; + if (NSFile::CFileBinary::ReadAllBytes(pJsaProject->filename().GetPath(), &pData, nBytesCount)) + { + nCurPos = m_oBcw.WriteItemStart(c_oSerParType::JsaProject); + m_oBcw.m_oStream.WriteBYTEArray(pData, nBytesCount); + m_oBcw.WriteItemEnd(nCurPos); + RELEASEARRAYOBJECTS(pData); + } + } + if (pJsaProject->IsExternal()) + { + nCurPos = m_oBcw.WriteItemStart(c_oSerParType::JsaProjectExternal); + m_oBcw.m_oStream.WriteStringW3(pJsaProject->filename().GetPath()); m_oBcw.WriteItemEnd(nCurPos); - RELEASEARRAYOBJECTS(pData); } } } diff --git a/OOXML/DocxFormat/FileFactory.cpp b/OOXML/DocxFormat/FileFactory.cpp index 8a95534b13..d1aa47ea42 100644 --- a/OOXML/DocxFormat/FileFactory.cpp +++ b/OOXML/DocxFormat/FileFactory.cpp @@ -192,7 +192,7 @@ namespace OOX else if ( oRelation.Type() == OOX::FileTypes::VbaData) return smart_ptr(new OOX::VbaData( pMain, oRootPath, oFileName)); else if ( oRelation.Type() == FileTypes::JsaProject) - return smart_ptr(new JsaProject( pMain, oFileName )); + return smart_ptr(new OOX::JsaProject( pMain, oFileName, oRelation.IsExternal())); else if ( oRelation.Type() == FileTypes::CustomXml) return smart_ptr(new OOX::CCustomXML(pMain, oRootPath, oFileName)); else if ( oRelation.Type() == FileTypes::CustomXmlProps) @@ -343,7 +343,7 @@ namespace OOX else if ( pRelation->Type() == FileTypes::VbaData) return smart_ptr(new OOX::VbaData( pMain, oRootPath, oFileName)); else if ( pRelation->Type() == FileTypes::JsaProject) - return smart_ptr(new JsaProject( pMain, oFileName )); + return smart_ptr(new OOX::JsaProject( pMain, oFileName, pRelation->IsExternal())); else if ( pRelation->Type() == FileTypes::CustomXml) return smart_ptr(new OOX::CCustomXML(pMain, oRootPath, oFileName)); else if ( pRelation->Type() == FileTypes::CustomXmlProps) diff --git a/OOXML/DocxFormat/Media/JsaProject.cpp b/OOXML/DocxFormat/Media/JsaProject.cpp index d4d6a02f53..29441ca1c9 100644 --- a/OOXML/DocxFormat/Media/JsaProject.cpp +++ b/OOXML/DocxFormat/Media/JsaProject.cpp @@ -60,8 +60,9 @@ namespace OOX } } } - JsaProject::JsaProject(OOX::Document *pMain, const CPath& filename) : Media(pMain) + JsaProject::JsaProject(OOX::Document *pMain, const CPath& filename, bool bExternal) : Media(pMain) { + m_bExternal = bExternal; OOX::CDocx* docx = dynamic_cast(pMain); if (docx) { diff --git a/OOXML/DocxFormat/Media/JsaProject.h b/OOXML/DocxFormat/Media/JsaProject.h index 3c536837a0..954e273198 100644 --- a/OOXML/DocxFormat/Media/JsaProject.h +++ b/OOXML/DocxFormat/Media/JsaProject.h @@ -43,7 +43,7 @@ namespace OOX { public: JsaProject( OOX::Document *pMain ); - JsaProject(OOX::Document *pMain, const CPath& filename); + JsaProject(OOX::Document *pMain, const CPath& filename, bool bExternal = false); virtual ~JsaProject(); virtual const FileType type() const; diff --git a/OOXML/PPTXFormat/FileFactory.cpp b/OOXML/PPTXFormat/FileFactory.cpp index 8a00cea929..ae8c756d92 100644 --- a/OOXML/PPTXFormat/FileFactory.cpp +++ b/OOXML/PPTXFormat/FileFactory.cpp @@ -158,7 +158,7 @@ namespace PPTX else if (relation.Type() == OOX::FileTypes::VbaProject) return smart_ptr(new OOX::VbaProject( pMain, filename, filename )); else if (relation.Type() == OOX::FileTypes::JsaProject) - return smart_ptr(new OOX::JsaProject( pMain, filename )); + return smart_ptr(new OOX::JsaProject( pMain, filename, relation.IsExternal())); else if (relation.Type() == OOX::FileTypes::CustomXml) return smart_ptr(new OOX::CCustomXML(pMain, filename, filename)); else if (relation.Type() == OOX::FileTypes::ActiveX_xml)