Commit 746c2282 authored by ElenaSubbotina's avatar ElenaSubbotina

PptFormat - support vba macros

parent d8c7d414
...@@ -52,7 +52,7 @@ COfficePPTFile::~COfficePPTFile() ...@@ -52,7 +52,7 @@ COfficePPTFile::~COfficePPTFile()
CloseFile(); CloseFile();
} }
long COfficePPTFile::OpenFile(const std::wstring & sFileName, const std::wstring & password) long COfficePPTFile::OpenFile(const std::wstring & sFileName, const std::wstring & password, bool &bMacros)
{ {
CloseFile(); CloseFile();
...@@ -66,6 +66,7 @@ long COfficePPTFile::OpenFile(const std::wstring & sFileName, const std::wstring ...@@ -66,6 +66,7 @@ long COfficePPTFile::OpenFile(const std::wstring & sFileName, const std::wstring
pptReader->m_oDocumentInfo.m_strTmpDirectory = m_strTempDirectory; pptReader->m_oDocumentInfo.m_strTmpDirectory = m_strTempDirectory;
pptReader->m_oDocumentInfo.m_strPassword = password; pptReader->m_oDocumentInfo.m_strPassword = password;
pptReader->m_oDocumentInfo.m_bMacros = bMacros;
if (pptReader->IsPowerPoint() == false) if (pptReader->IsPowerPoint() == false)
{ {
...@@ -88,6 +89,7 @@ long COfficePPTFile::OpenFile(const std::wstring & sFileName, const std::wstring ...@@ -88,6 +89,7 @@ long COfficePPTFile::OpenFile(const std::wstring & sFileName, const std::wstring
//pptReader->ReadDocumentSummary(); //pptReader->ReadDocumentSummary();
pptReader->ReadDocument(); pptReader->ReadDocument();
bMacros = pptReader->m_oDocumentInfo.m_bMacros;
m_Status = READMODE; m_Status = READMODE;
return S_OK; return S_OK;
...@@ -101,14 +103,14 @@ bool COfficePPTFile::CloseFile() ...@@ -101,14 +103,14 @@ bool COfficePPTFile::CloseFile()
return S_OK; return S_OK;
} }
HRESULT COfficePPTFile::LoadFromFile(std::wstring sSrcFileName, std::wstring sDstPath, std::wstring password) HRESULT COfficePPTFile::LoadFromFile(std::wstring sSrcFileName, std::wstring sDstPath, std::wstring password, bool &bMacros)
{ {
if (m_strTempDirectory.empty()) if (m_strTempDirectory.empty())
{ {
m_strTempDirectory = NSDirectory::GetTempPath(); m_strTempDirectory = NSDirectory::GetTempPath();
} }
long nResult = OpenFile(sSrcFileName, password); long nResult = OpenFile(sSrcFileName, password, bMacros);
if (nResult != S_OK) if (nResult != S_OK)
{ {
CloseFile(); CloseFile();
......
...@@ -66,7 +66,7 @@ public: ...@@ -66,7 +66,7 @@ public:
return m_strTempDirectory; return m_strTempDirectory;
} }
HRESULT LoadFromFile(std::wstring sSrcFileName, std::wstring sDstPath, std::wstring password); HRESULT LoadFromFile(std::wstring sSrcFileName, std::wstring sDstPath, std::wstring password, bool &bMacros);
private: private:
...@@ -76,7 +76,7 @@ private: ...@@ -76,7 +76,7 @@ private:
std::wstring m_strTempDirectory; std::wstring m_strTempDirectory;
std::wstring m_sTempDecryptFileName; std::wstring m_sTempDecryptFileName;
long OpenFile(const std::wstring & fileName, const std::wstring & password); long OpenFile(const std::wstring & fileName, const std::wstring & password, bool &bMacros);
bool CloseFile(); bool CloseFile();
std::wstring GetDirectory(std::wstring strFileName); std::wstring GetDirectory(std::wstring strFileName);
......
...@@ -186,7 +186,7 @@ void NSPresentationEditor::CPPTXWriter::CloseFile() ...@@ -186,7 +186,7 @@ void NSPresentationEditor::CPPTXWriter::CloseFile()
void NSPresentationEditor::CPPTXWriter::WriteContentTypes() void NSPresentationEditor::CPPTXWriter::WriteContentTypes()
{ {
std::wstring strContentTypes = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>\ std::wstring strContentTypes = L"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>\
<Types xmlns=\"http://schemas.openxmlformats.org/package/2006/content-types\">\ <Types xmlns=\"http://schemas.openxmlformats.org/package/2006/content-types\">\
<Default Extension=\"bmp\" ContentType=\"image/bmp\" />\ <Default Extension=\"bmp\" ContentType=\"image/bmp\" />\
<Default Extension=\"png\" ContentType=\"image/png\" />\ <Default Extension=\"png\" ContentType=\"image/png\" />\
...@@ -208,14 +208,22 @@ void NSPresentationEditor::CPPTXWriter::WriteContentTypes() ...@@ -208,14 +208,22 @@ void NSPresentationEditor::CPPTXWriter::WriteContentTypes()
<Default Extension=\"xls\" ContentType=\"application/vnd.ms-excel\"/>\ <Default Extension=\"xls\" ContentType=\"application/vnd.ms-excel\"/>\
<Default Extension=\"xlsx\" ContentType=\"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\"/>\ <Default Extension=\"xlsx\" ContentType=\"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\"/>\
<Default Extension=\"bin\" ContentType=\"application/vnd.openxmlformats-officedocument.oleObject\" />\ <Default Extension=\"bin\" ContentType=\"application/vnd.openxmlformats-officedocument.oleObject\" />\
<Default Extension=\"jpg\" ContentType=\"application/octet-stream\"/>"); <Default Extension=\"jpg\" ContentType=\"application/octet-stream\"/>";
strContentTypes += _T("<Override PartName=\"/ppt/presentation.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml\" />\ if (m_pDocument->m_bMacros)
<Override PartName=\"/ppt/presProps.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.presentationml.presProps+xml\" />\ {
strContentTypes += L"<Override PartName=\"/ppt/presentation.xml\" ContentType=\"application/vnd.ms-powerpoint.presentation.macroEnabled.main+xml\" />\
<Override PartName=\"/ppt/vbaProject.bin\" ContentType=\"application/vnd.ms-office.vbaProject\" />";
}
else
{
strContentTypes += L"<Override PartName=\"/ppt/presentation.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml\" />";
}
strContentTypes += L"<Override PartName=\"/ppt/presProps.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.presentationml.presProps+xml\" />\
<Override PartName=\"/ppt/viewProps.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.presentationml.viewProps+xml\" />\ <Override PartName=\"/ppt/viewProps.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.presentationml.viewProps+xml\" />\
<Override PartName=\"/ppt/tableStyles.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.presentationml.tableStyles+xml\"/>\ <Override PartName=\"/ppt/tableStyles.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.presentationml.tableStyles+xml\"/>\
<Override PartName=\"/docProps/core.xml\" ContentType=\"application/vnd.openxmlformats-package.core-properties+xml\" />\ <Override PartName=\"/docProps/core.xml\" ContentType=\"application/vnd.openxmlformats-package.core-properties+xml\" />\
<Override PartName=\"/docProps/app.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.extended-properties+xml\" />"); <Override PartName=\"/docProps/app.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.extended-properties+xml\" />";
int nIndexLayout = 1, nIndexTheme = 1; int nIndexLayout = 1, nIndexTheme = 1;
...@@ -411,6 +419,15 @@ void NSPresentationEditor::CPPTXWriter::WritePresInfo() ...@@ -411,6 +419,15 @@ void NSPresentationEditor::CPPTXWriter::WritePresInfo()
strPresRels += L"<Relationship Id=\"rId" + std::to_wstring(nCurrentRels++) + L"\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/tableStyles\" Target=\"tableStyles.xml\"/>"; strPresRels += L"<Relationship Id=\"rId" + std::to_wstring(nCurrentRels++) + L"\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/tableStyles\" Target=\"tableStyles.xml\"/>";
strPresRels += L"<Relationship Id=\"rId" + std::to_wstring(nCurrentRels++) + L"\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/viewProps\" Target=\"viewProps.xml\"/>"; strPresRels += L"<Relationship Id=\"rId" + std::to_wstring(nCurrentRels++) + L"\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/viewProps\" Target=\"viewProps.xml\"/>";
if (m_pDocument->m_bMacros)
{
std::wstring strVbaProject = m_strTempDirectory + FILE_SEPARATOR_STR + _T("ppt") + FILE_SEPARATOR_STR + _T("vbaProject.bin");
if (CDirectory::CopyFile(m_pDocument->m_sVbaProjectFile, strVbaProject))
{
strPresRels += L"<Relationship Id=\"rId" + std::to_wstring(nCurrentRels++) + L"\" Type=\"http://schemas.microsoft.com/office/2006/relationships/vbaProject\" Target=\"vbaProject.bin\"/>";
}
}
strPresRels = L"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?><Relationships xmlns=\"http://schemas.openxmlformats.org/package/2006/relationships\">" strPresRels = L"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?><Relationships xmlns=\"http://schemas.openxmlformats.org/package/2006/relationships\">"
+ strPresRels + L"</Relationships>"; + strPresRels + L"</Relationships>";
......
...@@ -41,8 +41,9 @@ public: ...@@ -41,8 +41,9 @@ public:
std::wstring m_strTmpDirectory; std::wstring m_strTmpDirectory;
std::map<int, std::wstring> m_mapStoreImageFile; std::map<int, std::wstring> m_mapStoreImageFile;
std::wstring m_strPassword; std::wstring m_strPassword;
bool m_bMacros;
CPPTDocumentInfo() : m_oCurrentUser(), m_arUsers() CPPTDocumentInfo() : m_oCurrentUser(), m_bMacros(true)
{ {
} }
...@@ -88,6 +89,7 @@ public: ...@@ -88,6 +89,7 @@ public:
pInfo->m_strTmpDirectory = m_strTmpDirectory; pInfo->m_strTmpDirectory = m_strTmpDirectory;
pInfo->m_bEncrypt = m_oCurrentUser.m_bIsEncrypt; pInfo->m_bEncrypt = m_oCurrentUser.m_bIsEncrypt;
pInfo->m_strPassword = m_strPassword; pInfo->m_strPassword = m_strPassword;
pInfo->m_bMacros = m_bMacros;
bool bResult = pInfo->ReadFromStream(&oUserAtom, pStream); bool bResult = pInfo->ReadFromStream(&oUserAtom, pStream);
......
...@@ -52,6 +52,7 @@ CPPTUserInfo::CPPTUserInfo() : CDocument(), ...@@ -52,6 +52,7 @@ CPPTUserInfo::CPPTUserInfo() : CDocument(),
m_pDecryptor(NULL), m_pDecryptor(NULL),
m_arOffsetPictures() m_arOffsetPictures()
{ {
m_VbaProjectStg = NULL;
m_pDocumentInfo = NULL; m_pDocumentInfo = NULL;
m_lIndexThisUser = -1; m_lIndexThisUser = -1;
...@@ -83,6 +84,7 @@ void CPPTUserInfo::Clear() ...@@ -83,6 +84,7 @@ void CPPTUserInfo::Clear()
RELEASEOBJECT(m_pDecryptor); RELEASEOBJECT(m_pDecryptor);
RELEASEOBJECT(m_pStorageDecrypt); RELEASEOBJECT(m_pStorageDecrypt);
RELEASEOBJECT(m_VbaProjectStg);
for (std::map<DWORD, CRecordSlide*>::iterator pPair = m_mapSlides.begin(); pPair != m_mapSlides.end(); ++pPair) for (std::map<DWORD, CRecordSlide*>::iterator pPair = m_mapSlides.begin(); pPair != m_mapSlides.end(); ++pPair)
{ {
...@@ -390,6 +392,47 @@ bool CPPTUserInfo::ReadDocumentPersists(POLE::Stream* pStream) ...@@ -390,6 +392,47 @@ bool CPPTUserInfo::ReadDocumentPersists(POLE::Stream* pStream)
m_mapHandoutMasters.insert( std::pair<DWORD, CRecordSlide*>(0, pSlide )); m_mapHandoutMasters.insert( std::pair<DWORD, CRecordSlide*>(0, pSlide ));
} }
} }
if (m_bMacros)
{
m_bMacros = false;
std::vector<CRecordVBAInfoAtom*> oArrayVba;
m_oDocument.GetRecordsByType(&oArrayVba, true, true);
if (!oArrayVba.empty())
{
if (oArrayVba[0]->m_nHasMacros)
{
nIndexPsrRef = m_mapOffsetInPIDs.find(oArrayVba[0]->m_nObjStgDataRef);
if (m_mapOffsetInPIDs.end() != nIndexPsrRef)
{
offset_stream = nIndexPsrRef->second;
StreamUtils::StreamSeek(offset_stream, pStream);
POLE::Stream *pStreamTmp = pStream;
if (m_pDecryptor)
{
DecryptStream(pStream, oArrayVba[0]->m_nObjStgDataRef);
pStreamTmp = m_arStreamDecrypt.back()->stream_;
}
oHeader.ReadFromStream(pStreamTmp);
m_VbaProjectStg = new CRecordVbaProjectStg(m_strTmpDirectory);
m_VbaProjectStg->ReadFromStream(oHeader, pStreamTmp);
if (m_VbaProjectStg->m_sFileName.empty())
{
RELEASEOBJECT(m_VbaProjectStg);
}
else
{
m_sVbaProjectFile = m_VbaProjectStg->m_sFileName;
m_bMacros = true;
}
}
}
}
}
return true; return true;
} }
//-------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------
......
...@@ -95,6 +95,7 @@ public: ...@@ -95,6 +95,7 @@ public:
// чтобы загружать неизмененные элементы от других юзеров (предыдущих) // чтобы загружать неизмененные элементы от других юзеров (предыдущих)
CPPTDocumentInfo* m_pDocumentInfo; CPPTDocumentInfo* m_pDocumentInfo;
CRecordVbaProjectStg* m_VbaProjectStg;
int m_lIndexThisUser; int m_lIndexThisUser;
// Animations structures // Animations structures
......
...@@ -181,7 +181,7 @@ IRecord* CreateByType(SRecordHeader oHeader) ...@@ -181,7 +181,7 @@ IRecord* CreateByType(SRecordHeader oHeader)
//CREATE_BY_TYPE(RECORD_TYPE_VIEWINFO_ATOM , CRecordNoZoomViewInfoAtom) //CREATE_BY_TYPE(RECORD_TYPE_VIEWINFO_ATOM , CRecordNoZoomViewInfoAtom)
CREATE_BY_TYPE(RECORD_TYPE_VIEWINFO_ATOM , CRecordViewInfoAtom) CREATE_BY_TYPE(RECORD_TYPE_VIEWINFO_ATOM , CRecordViewInfoAtom)
CREATE_BY_TYPE(RECORD_TYPE_SLIDE_VIEWINFO_ATOM , CRecordSlideViewInfoAtom) CREATE_BY_TYPE(RECORD_TYPE_SLIDE_VIEWINFO_ATOM , CRecordSlideViewInfoAtom)
//CREATE_BY_TYPE(RECORD_TYPE_VBAINFO_ATOM , CRecordVBAInfoAtom) CREATE_BY_TYPE(RECORD_TYPE_VBAINFO_ATOM , CRecordVBAInfoAtom)
//CREATE_BY_TYPE(RECORD_TYPE_SSDOCINFO_ATOM , CRecordSSDocInfoAtom) //CREATE_BY_TYPE(RECORD_TYPE_SSDOCINFO_ATOM , CRecordSSDocInfoAtom)
//CREATE_BY_TYPE(RECORD_TYPE_DOC_ROUTING_SLIP , CRecordDocRoutingSlipAtom) //CREATE_BY_TYPE(RECORD_TYPE_DOC_ROUTING_SLIP , CRecordDocRoutingSlipAtom)
CREATE_BY_TYPE(RECORD_TYPE_EXOBJLIST_ATOM , CRecordExObjListAtom) CREATE_BY_TYPE(RECORD_TYPE_EXOBJLIST_ATOM , CRecordExObjListAtom)
...@@ -263,11 +263,10 @@ IRecord* CreateByType(SRecordHeader oHeader) ...@@ -263,11 +263,10 @@ IRecord* CreateByType(SRecordHeader oHeader)
//CREATE_BY_TYPE(RECORD_TYPE_UNKNOWN , CRecordRecolorInfoAtom) //CREATE_BY_TYPE(RECORD_TYPE_UNKNOWN , CRecordRecolorInfoAtom)
//CREATE_BY_TYPE(RECORD_TYPE_UNKNOWN , CRecordAnimationInfoAtom) //CREATE_BY_TYPE(RECORD_TYPE_UNKNOWN , CRecordAnimationInfoAtom)
CREATE_BY_TYPE(RECORD_TYPE_EX_VIDEOCONTAINER , CRecordExVideoContainer) CREATE_BY_TYPE(RECORD_TYPE_EX_VIDEOCONTAINER , CRecordExVideoContainer)
CREATE_BY_TYPE(RECORD_TYPE_EX_OBJREF_ATOM , CRecordExObjRefAtom) CREATE_BY_TYPE(RECORD_TYPE_EX_OBJREF_ATOM , CRecordExObjRefAtom)
CREATE_BY_TYPE(RECORD_TYPE_EX_MEDIA_ATOM , CRecordExMediaAtom) CREATE_BY_TYPE(RECORD_TYPE_EX_MEDIA_ATOM , CRecordExMediaAtom)
//CREATE_BY_TYPE(RECORD_TYPE_EXCONTROL_ATOM , CRecordExControlAtom) CREATE_BY_TYPE(RECORD_TYPE_EXCONTROL_ATOM , CRecordExControlAtom)
CREATE_BY_TYPE(RECORD_TYPE_ESCHER_BSTORE_CONTAINER , CRecordBlipStoreContainer) CREATE_BY_TYPE(RECORD_TYPE_ESCHER_BSTORE_CONTAINER , CRecordBlipStoreContainer)
CREATE_BY_TYPE(RECORD_TYPE_ESCHER_BSE , CRecordBlipStoreEntry) CREATE_BY_TYPE(RECORD_TYPE_ESCHER_BSE , CRecordBlipStoreEntry)
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
class CRecordExControlAtom : public CUnknownRecord class CRecordExControlAtom : public CUnknownRecord
{ {
UINT m_nSlideID; UINT m_nSlideIdRef;
public: public:
...@@ -49,6 +49,7 @@ public: ...@@ -49,6 +49,7 @@ public:
virtual void ReadFromStream(SRecordHeader & oHeader, POLE::Stream* pStream) virtual void ReadFromStream(SRecordHeader & oHeader, POLE::Stream* pStream)
{ {
m_oHeader = oHeader; m_oHeader = oHeader;
m_nSlideID = StreamUtils::ReadDWORD(pStream);
m_nSlideIdRef = StreamUtils::ReadDWORD(pStream);
} }
}; };
\ No newline at end of file
...@@ -52,6 +52,78 @@ public: ...@@ -52,6 +52,78 @@ public:
virtual void ReadFromStream(SRecordHeader & oHeader, POLE::Stream* pStream) virtual void ReadFromStream(SRecordHeader & oHeader, POLE::Stream* pStream)
{ {
return CUnknownRecord::ReadFromStream(oHeader, pStream); m_oHeader = oHeader;
m_nDrawAspect = StreamUtils::ReadDWORD(pStream);
m_nType = StreamUtils::ReadDWORD(pStream);
m_nExObjID = StreamUtils::ReadDWORD(pStream);
m_nSubType = StreamUtils::ReadDWORD(pStream);
m_nPersistID = StreamUtils::ReadDWORD(pStream);
StreamUtils::StreamSkip ( 4, pStream ); //unused
}
};
class CRecordExOleObjStg : public CUnknownRecord
{
public:
std::wstring m_sFileName;
std::wstring m_strTmpDirectory;
CRecordExOleObjStg(std::wstring strTemp) : m_strTmpDirectory(strTemp)
{
}
~CRecordExOleObjStg()
{
} }
virtual void ReadFromStream(SRecordHeader & oHeader, POLE::Stream* pStream)
{
m_oHeader = oHeader;
ULONG decompressedSize = m_oHeader.RecLen, compressedSize = m_oHeader.RecLen;
BYTE* pData = new BYTE[m_oHeader.RecLen];
if (!pData) return;
if (m_oHeader.RecInstance == 0x01)
{
decompressedSize = StreamUtils::ReadDWORD(pStream);
compressedSize = m_oHeader.RecLen - 4;
}
pStream->read(pData, compressedSize);
if (m_oHeader.RecInstance == 0x01)
{
BYTE* pDataUncompress = new BYTE[decompressedSize + 64];
if (NSZLib::Decompress(pData, compressedSize, pDataUncompress, decompressedSize))
{
RELEASEOBJECT(pData);
pData = pDataUncompress;
}
else
{
RELEASEOBJECT(pData);
}
}
//if (pDecryptor)
//{
// pDecryptor->Decrypt((char*)pData, oHeader.RecLen - lOffset, 0);
//}
if (pData)
{
m_sFileName = m_strTmpDirectory + FILE_SEPARATOR_STR + L"oleObject_xxx.bin";
NSFile::CFileBinary file;
if (file.CreateFile(m_sFileName))
{
file.WriteFile(pData, decompressedSize);
file.CloseFile();
}
delete[] pData;
pData = NULL;
}
}
}; };
\ No newline at end of file
...@@ -34,11 +34,11 @@ ...@@ -34,11 +34,11 @@
class CRecordVBAInfoAtom : public CUnknownRecord class CRecordVBAInfoAtom : public CUnknownRecord
{ {
public:
UINT m_nObjStgDataRef; UINT m_nObjStgDataRef;
UINT m_nHasMacros; UINT m_nHasMacros;
UINT m_nVersion; UINT m_nVersion;
public:
CRecordVBAInfoAtom() CRecordVBAInfoAtom()
{ {
...@@ -50,7 +50,69 @@ public: ...@@ -50,7 +50,69 @@ public:
virtual void ReadFromStream(SRecordHeader & oHeader, POLE::Stream* pStream) virtual void ReadFromStream(SRecordHeader & oHeader, POLE::Stream* pStream)
{ {
return CUnknownRecord::ReadFromStream(oHeader, pStream); m_oHeader = oHeader;
m_nObjStgDataRef = StreamUtils::ReadDWORD(pStream);
m_nHasMacros = StreamUtils::ReadDWORD(pStream);
m_nVersion = StreamUtils::ReadDWORD(pStream);
}
};
class CRecordVbaProjectStg : public CUnknownRecord
{
public:
std::wstring m_sFileName;
std::wstring m_strTmpDirectory;
CRecordVbaProjectStg(std::wstring strTemp) : m_strTmpDirectory(strTemp)
{
}
~CRecordVbaProjectStg()
{
}
virtual void ReadFromStream(SRecordHeader & oHeader, POLE::Stream* pStream)
{
m_oHeader = oHeader;
ULONG decompressedSize = m_oHeader.RecLen, compressedSize = m_oHeader.RecLen;
BYTE* pData = new BYTE[compressedSize];
if (!pData) return;
if (m_oHeader.RecInstance == 0x01)
{
decompressedSize = StreamUtils::ReadDWORD(pStream) + 64;
compressedSize -= 4;
}
pStream->read(pData, compressedSize);
//if (pDecryptor)
//{
// pDecryptor->Decrypt((char*)pData, compressedSize, 0);
//}
if (m_oHeader.RecInstance == 0x01)
{
BYTE* pDataUncompress = new BYTE[decompressedSize];
NSZLib::Decompress(pData, compressedSize, pDataUncompress, decompressedSize);
RELEASEOBJECT(pData);
pData = pDataUncompress;
}
m_sFileName = m_strTmpDirectory + FILE_SEPARATOR_STR + L"vbaProject.bin";
NSFile::CFileBinary file;
if (file.CreateFile(m_sFileName))
{
file.WriteFile(pData, decompressedSize);
file.CloseFile();
}
delete[] pData;
pData = NULL;
} }
}; };
\ No newline at end of file
...@@ -49,9 +49,9 @@ int _tmain(int argc, _TCHAR* argv[]) ...@@ -49,9 +49,9 @@ int _tmain(int argc, _TCHAR* argv[])
if (argc < 2) return 1; if (argc < 2) return 1;
std::wstring sSrcPpt = argv[1]; std::wstring sSrcPpt = argv[1];
std::wstring sDstPptx = argc > 2 ? argv[2] : sSrcPpt + L"-my.pptx"; std::wstring sDstPptx;
std::wstring outputDir = NSDirectory::GetFolderPath(sDstPptx); std::wstring outputDir = NSDirectory::GetFolderPath(sSrcPpt);
std::wstring dstTempPath = NSDirectory::CreateDirectoryWithUniqueName(outputDir); std::wstring dstTempPath = NSDirectory::CreateDirectoryWithUniqueName(outputDir);
std::wstring tempPath = NSDirectory::CreateDirectoryWithUniqueName(outputDir); std::wstring tempPath = NSDirectory::CreateDirectoryWithUniqueName(outputDir);
...@@ -60,8 +60,19 @@ int _tmain(int argc, _TCHAR* argv[]) ...@@ -60,8 +60,19 @@ int _tmain(int argc, _TCHAR* argv[])
pptFile.put_TempDirectory(tempPath); pptFile.put_TempDirectory(tempPath);
HRESULT hRes = pptFile.LoadFromFile(sSrcPpt, dstTempPath, L"password"); bool bMacros = true;
HRESULT hRes = pptFile.LoadFromFile(sSrcPpt, dstTempPath, L"password", bMacros);
if (bMacros)
{
sDstPptx = sSrcPpt + L"-my.pptm";
}
else
{
sDstPptx = sSrcPpt + L"-my.pptx";
}
if (hRes == S_OK) if (hRes == S_OK)
{ {
COfficeUtils oCOfficeUtils(NULL); COfficeUtils oCOfficeUtils(NULL);
......
...@@ -48,7 +48,10 @@ namespace NSPresentationEditor ...@@ -48,7 +48,10 @@ namespace NSPresentationEditor
CMetricInfo m_oInfo; CMetricInfo m_oInfo;
CDocument() : m_arThemes(), m_arSlides() bool m_bMacros;
std::wstring m_sVbaProjectFile;
CDocument() : m_bMacros (false)
{ {
m_pHandoutMaster = NULL; m_pHandoutMaster = NULL;
m_pNotesMaster = NULL; m_pNotesMaster = NULL;
......
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