diff --git a/ASCOfficePPTXFile/Editor/BinaryFileReaderWriter.cpp b/ASCOfficePPTXFile/Editor/BinaryFileReaderWriter.cpp index 60eb79e58e..0f03117c43 100644 --- a/ASCOfficePPTXFile/Editor/BinaryFileReaderWriter.cpp +++ b/ASCOfficePPTXFile/Editor/BinaryFileReaderWriter.cpp @@ -39,6 +39,7 @@ #include "../../Common/DocxFormat/Source/DocxFormat/Media/ActiveX.h" #include "../../Common/DocxFormat/Source/DocxFormat/Media/Video.h" #include "../../Common/DocxFormat/Source/DocxFormat/Media/Audio.h" +#include "../../Common/DocxFormat/Source/DocxFormat/Media/VbaProject.h" #include "../../Common/Base64.h" diff --git a/ASCOfficePPTXFile/PPTXFormat/FileFactory.cpp b/ASCOfficePPTXFile/PPTXFormat/FileFactory.cpp index 2da0ca8e97..0f072b49ae 100644 --- a/ASCOfficePPTXFile/PPTXFormat/FileFactory.cpp +++ b/ASCOfficePPTXFile/PPTXFormat/FileFactory.cpp @@ -63,6 +63,7 @@ #include "../../Common/DocxFormat/Source/DocxFormat/Media/Video.h" #include "../../Common/DocxFormat/Source/DocxFormat/Media/OleObject.h" #include "../../Common/DocxFormat/Source/DocxFormat/Media/ActiveX.h" +#include "../../Common/DocxFormat/Source/DocxFormat/Media/VbaProject.h" #include "../../Common/DocxFormat/Source/DocxFormat/External/HyperLink.h" #include "../../Common/DocxFormat/Source/DocxFormat/External/ExternalImage.h" #include "../../Common/DocxFormat/Source/DocxFormat/External/ExternalAudio.h" diff --git a/ASCOfficePPTXFile/PPTXFormat/Logic/SpTreeElem.cpp b/ASCOfficePPTXFile/PPTXFormat/Logic/SpTreeElem.cpp index 64b71765bb..c3cf8557e0 100644 --- a/ASCOfficePPTXFile/PPTXFormat/Logic/SpTreeElem.cpp +++ b/ASCOfficePPTXFile/PPTXFormat/Logic/SpTreeElem.cpp @@ -42,6 +42,8 @@ #include "../../../Common/DocxFormat/Source/DocxFormat/Media/Audio.h" #include "../../../Common/DocxFormat/Source/DocxFormat/Media/Video.h" +#include "../../../Common/DocxFormat/Source/DocxFormat/Media/ActiveX.h" + namespace PPTX { namespace Logic diff --git a/Common/DocxFormat/Source/DocxFormat/Media/Media.h b/Common/DocxFormat/Source/DocxFormat/Media/Media.h index 39bc0d703e..a220455ba5 100644 --- a/Common/DocxFormat/Source/DocxFormat/Media/Media.h +++ b/Common/DocxFormat/Source/DocxFormat/Media/Media.h @@ -78,8 +78,11 @@ namespace OOX { return m_filename; } - void copy_to(const CPath& path) const + virtual void copy_to(const CPath& path) const { + OOX::CPath pathSaveItem = path + FILE_SEPARATOR_STR + m_filename.GetFilename(); + + NSFile::CFileBinary::Copy(m_filename.GetPath(), pathSaveItem.GetPath()); } virtual const CPath DefaultDirectory() const { diff --git a/Common/DocxFormat/Source/XlsxFormat/FileFactory_Spreadsheet.cpp b/Common/DocxFormat/Source/XlsxFormat/FileFactory_Spreadsheet.cpp index 49ba46d2db..969a956172 100644 --- a/Common/DocxFormat/Source/XlsxFormat/FileFactory_Spreadsheet.cpp +++ b/Common/DocxFormat/Source/XlsxFormat/FileFactory_Spreadsheet.cpp @@ -182,8 +182,6 @@ namespace OOX return smart_ptr(new OOX::ActiveX_xml( oRootPath, oFileName )); else if ( pRelation->Type() == OOX::FileTypes::ActiveX_bin) return smart_ptr(new OOX::ActiveX_bin( oFileName )); - else if ( pRelation->Type() == OOX::FileTypes::VbaProject) - return smart_ptr(new OOX::VbaProject( oRootPath, oFileName )); return smart_ptr( new UnknowTypeFile() ); } diff --git a/XlsxSerializerCom/Common/BinReaderWriterDefines.h b/XlsxSerializerCom/Common/BinReaderWriterDefines.h index 3bbe83618e..32f1176db0 100755 --- a/XlsxSerializerCom/Common/BinReaderWriterDefines.h +++ b/XlsxSerializerCom/Common/BinReaderWriterDefines.h @@ -191,7 +191,8 @@ namespace BinXlsxRW PivotCache = 8, ExternalBook = 9, OleLink = 10, - DdeLink = 11 + DdeLink = 11, + VbaProject = 12 };} namespace c_oSerWorkbookPrTypes{enum c_oSerWorkbookPrTypes { diff --git a/XlsxSerializerCom/Reader/BinaryWriter.h b/XlsxSerializerCom/Reader/BinaryWriter.h index a56359a6c1..25d1c63db7 100644 --- a/XlsxSerializerCom/Reader/BinaryWriter.h +++ b/XlsxSerializerCom/Reader/BinaryWriter.h @@ -38,6 +38,7 @@ #include "../../Common/DocxFormat/Source/SystemUtility/SystemUtility.h" #include "../../Common/DocxFormat/Source/DocxFormat/Media/OleObject.h" #include "../../Common/DocxFormat/Source/DocxFormat/Media/ActiveX.h" +#include "../../Common/DocxFormat/Source/DocxFormat/Media/VbaProject.h" #include "../../Common/OfficeFileFormats.h" #include "../../Common/Base64.h" @@ -1521,6 +1522,14 @@ namespace BinXlsxRW WriteExternalReferences(workbook.m_oExternalReferences.get(), workbook); m_oBcw.WriteItemWithLengthEnd(nCurPos); } + + smart_ptr vbaProject = workbook.Get(OOX::FileTypes::VbaProject); + if (vbaProject.IsInit()) + { + nCurPos = m_oBcw.WriteItemStart(c_oSerWorkbookTypes::VbaProject); + WriteVbaProject (vbaProject.smart_dynamic_cast()); + m_oBcw.WriteItemWithLengthEnd(nCurPos); + } }; void WriteWorkbookPr(const OOX::Spreadsheet::CWorkbookPr& workbookPr) { @@ -1925,7 +1934,6 @@ namespace BinXlsxRW m_oBcw.WriteItemWithLengthEnd(nCurPos); } } - void WriteDefinedName(const OOX::Spreadsheet::CDefinedName& definedName) { int nCurPos = 0; @@ -1961,7 +1969,19 @@ namespace BinXlsxRW m_oBcw.m_oStream.WriteBYTE(c_oSerDefinedNameTypes::Comment); m_oBcw.m_oStream.WriteStringW(definedName.m_oComment.get2()); } - }; + } + void WriteVbaProject(smart_ptr & fileVbaProject) + { + std::wstring file_name = fileVbaProject->filename().GetFilename(); + + m_oBcw.m_oStream.WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); + m_oBcw.m_oStream.WriteString1(0, file_name); + m_oBcw.m_oStream.WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); + //... todooo write parsing vba project + + //copy file bin + fileVbaProject->copy_to(m_oBcw.m_oStream.m_pCommon->m_pImageManager->m_strDstMedia); + } }; class BinaryWorksheetTableWriter { diff --git a/XlsxSerializerCom/Writer/BinaryReader.h b/XlsxSerializerCom/Writer/BinaryReader.h index 1469fd4899..eedd31c9d9 100644 --- a/XlsxSerializerCom/Writer/BinaryReader.h +++ b/XlsxSerializerCom/Writer/BinaryReader.h @@ -36,6 +36,8 @@ #include "../../Common/ATLDefine.h" #include "../../Common/DocxFormat/Source/XlsxFormat/Worksheets/Sparkline.h" +#include "../../Common/DocxFormat/Source/DocxFormat/Media/VbaProject.h" + #include "../../DesktopEditor/common/Path.h" #include "../../DesktopEditor/common/Directory.h" @@ -1504,8 +1506,10 @@ namespace BinXlsxRW { { OOX::Spreadsheet::CWorkbook& m_oWorkbook; std::map>& m_mapPivotCacheDefinitions; + const std::wstring& m_sDestinationDir; public: - BinaryWorkbookTableReader(NSBinPptxRW::CBinaryFileReader& oBufferedStream, OOX::Spreadsheet::CWorkbook& oWorkbook, std::map>& mapPivotCacheDefinitions):Binary_CommonReader(oBufferedStream), m_oWorkbook(oWorkbook), m_mapPivotCacheDefinitions(mapPivotCacheDefinitions) + BinaryWorkbookTableReader(NSBinPptxRW::CBinaryFileReader& oBufferedStream, OOX::Spreadsheet::CWorkbook& oWorkbook, std::map>& mapPivotCacheDefinitions, const std::wstring& sDestinationDir) + : Binary_CommonReader(oBufferedStream), m_oWorkbook(oWorkbook), m_mapPivotCacheDefinitions(mapPivotCacheDefinitions), m_sDestinationDir(sDestinationDir) { } int Read() @@ -1542,6 +1546,10 @@ namespace BinXlsxRW { res = Read1(length, &BinaryWorkbookTableReader::ReadPivotCaches, this, poResult); m_oWorkbook.m_oPivotCachesXml->append(L""); } + else if(c_oSerWorkbookTypes::VbaProject == type) + { + res = Read1(length, &BinaryWorkbookTableReader::ReadVbaProject, this, poResult); + } else res = c_oSerConstants::ReadUnknown; return res; @@ -2068,7 +2076,7 @@ namespace BinXlsxRW { else res = c_oSerConstants::ReadUnknown; return res; - }; + } int ReadPivotCache(BYTE type, long length, void* poResult) { PivotCachesTemp* pPivotCachesTemp = static_cast(poResult); @@ -2090,13 +2098,36 @@ namespace BinXlsxRW { else res = c_oSerConstants::ReadUnknown; return res; - }; + } + int ReadVbaProject(BYTE type, long length, void* poResult) + { + int res = c_oSerConstants::ReadOk; + if(c_oSerWorkbookTypes::VbaProject == type) + { + std::wstring file_name = m_oBufferedStream.GetString3(length); + + OOX::CPath inputPath = m_oBufferedStream.m_strFolder + FILE_SEPARATOR_STR + _T("media") + FILE_SEPARATOR_STR + file_name; + OOX::CPath outputPath = m_sDestinationDir + FILE_SEPARATOR_STR + _T("xl") + FILE_SEPARATOR_STR + _T("vbaProject.bin"); + + NSFile::CFileBinary::Copy(inputPath.GetPath(), outputPath.GetPath()); + + smart_ptr oFile; + oFile->set_filename(outputPath); + const OOX::RId oRId = m_oWorkbook.Add(oFile.smart_dynamic_cast()); + + return res; + + } + else + res = c_oSerConstants::ReadUnknown; + } }; class BinaryCommentReader : public Binary_CommonReader { OOX::Spreadsheet::CWorksheet* m_pCurWorksheet; public: - BinaryCommentReader(NSBinPptxRW::CBinaryFileReader& oBufferedStream, OOX::Spreadsheet::CWorksheet* pCurWorksheet):Binary_CommonReader(oBufferedStream),m_pCurWorksheet(pCurWorksheet) + BinaryCommentReader(NSBinPptxRW::CBinaryFileReader& oBufferedStream, OOX::Spreadsheet::CWorksheet* pCurWorksheet) + : Binary_CommonReader(oBufferedStream), m_pCurWorksheet(pCurWorksheet) { } int Read(long length, void* poResult) @@ -4414,7 +4445,7 @@ namespace BinXlsxRW { if(-1 != nWorkbookOffBits) { oBufferedStream.Seek(nWorkbookOffBits); - res = BinaryWorkbookTableReader(oBufferedStream, *pWorkbook, m_mapPivotCacheDefinitions).Read(); + res = BinaryWorkbookTableReader(oBufferedStream, *pWorkbook, m_mapPivotCacheDefinitions, sOutDir).Read(); if(c_oSerConstants::ReadOk != res) return res; }