Compare commits

..

5 Commits

12 changed files with 194 additions and 165 deletions

View File

@ -36,10 +36,26 @@ namespace BinDocxRW {
int Binary_VbaProjectTableReader::Read()
{
m_oFileWriter.m_pVbaProject = new OOX::VbaProject();
m_oFileWriter.m_pVbaProject->fromPPTY(&m_oBufferedStream);
return ReadTable(&Binary_VbaProjectTableReader::ReadContent, this);
}
int Binary_VbaProjectTableReader::ReadContent(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
if ( c_oSerVbaProjectTypes::Name == type )
{
std::wstring file_name = m_oBufferedStream.GetString4(length);
return c_oSerConstants::ReadOk;
OOX::CPath inputPath = m_oBufferedStream.m_strFolder + FILE_SEPARATOR_STR + L"media" + FILE_SEPARATOR_STR + file_name;
OOX::CPath outputPath = m_oFileWriter.m_oDocumentWriter.m_sDir + FILE_SEPARATOR_STR + L"word" + FILE_SEPARATOR_STR + L"vbaProject.bin";
NSFile::CFileBinary::Copy(inputPath.GetPath(), outputPath.GetPath());
m_oFileWriter.m_pVbaProject = new OOX::VbaProject();
m_oFileWriter.m_pVbaProject->set_filename(outputPath.GetPath());
}
else
res = c_oSerConstants::ReadUnknown;
return res;
}
//-------------------------------------------------------------------------------------
Binary_HdrFtrTableReader::Binary_HdrFtrTableReader(NSBinPptxRW::CBinaryFileReader& poBufferedStream, Writers::FileWriter& oFileWriter, CComments* pComments):Binary_CommonReader(poBufferedStream),m_oFileWriter(oFileWriter),m_oHeaderFooterWriter(oFileWriter.m_oHeaderFooterWriter),m_pComments(pComments)
@ -118,4 +134,4 @@ int Binary_HdrFtrTableReader::ReadHdrFtrItemContent(BYTE type, long length, void
return pBinary_DocumentTableReader->ReadDocumentContent(type, length, NULL);
}
}
}

View File

@ -285,7 +285,8 @@ public:
}
int Read ();
};
int ReadContent (BYTE type, long length, void* poResult);
};
class Binary_HdrFtrTableReader : public Binary_CommonReader<Binary_HdrFtrTableReader>
{

View File

@ -3027,12 +3027,25 @@ namespace BinDocxRW
}
pOfficeDrawingConverter->SetRels(oldRels);
}
void WriteVbaProjectContent(OOX::VbaProject& oVbaProject)
{
std::wstring file_name = oVbaProject.filename().GetFilename();
m_oBcw.m_oStream.WriteBYTE(c_oSerVbaProjectTypes::Name);
m_oBcw.m_oStream.WriteStringW(file_name);
//... todooo write parsing vba project
//write vbaData.... todooo
//copy file bin
oVbaProject.copy_to(m_oBcw.m_oStream.m_pCommon->m_pImageManager->m_strDstMedia);
}
void WriteVbaProject(OOX::VbaProject& oVbaProject)
{
m_oBcw.m_oStream.StartRecord(0);
oVbaProject.toPPTY(&m_oBcw.m_oStream);
m_oBcw.m_oStream.EndRecord();
int nStart = m_oBcw.WriteItemWithLengthStart();
WriteVbaProjectContent(oVbaProject);
m_oBcw.WriteItemWithLengthEnd(nStart);
}
void Write(std::vector<OOX::WritingElement*>& aElems)
{

View File

@ -93,9 +93,7 @@ bool BinDocxRW::CDocxSerializer::saveToFile(const std::wstring& sSrcFileName, co
oDrawingConverter.SetFontDir(m_sFontDir);
oDrawingConverter.SetFontPicker(pFontPicker);
oDrawingConverter.SetMainDocument(this);
oDrawingConverter.SetDstPath(pathMain.GetDirectory() + FILE_SEPARATOR_STR + L"word");
oDrawingConverter.SetMediaDstPath(pathMedia.GetPath());
oDrawingConverter.SetMediaDstPath(pathMedia.GetPath());
m_pParamsWriter = new ParamsWriter(&oBufferedStream, &fp, &oDrawingConverter, pEmbeddedFontsManager);
@ -265,10 +263,8 @@ bool BinDocxRW::CDocxSerializer::loadFromFile(const std::wstring& sSrcFileName,
if (NULL != pData)
{
oDrawingConverter.SetMainDocument(this);
oDrawingConverter.SetDstPath(sDstPath + FILE_SEPARATOR_STR + L"word");
oDrawingConverter.SetMediaDstPath(sMediaPath);
oDrawingConverter.SetMainDocument(this);
oDrawingConverter.SetMediaDstPath(sMediaPath);
oDrawingConverter.SetEmbedDstPath(sEmbedPath);
m_pCurFileWriter = new Writers::FileWriter(sDstPath, m_sFontDir, false, nVersion, m_bSaveChartAsImg, &oDrawingConverter, sThemePath);
@ -277,7 +273,7 @@ bool BinDocxRW::CDocxSerializer::loadFromFile(const std::wstring& sSrcFileName,
std::wstring strFileInDir = NSSystemPath::GetDirectoryName(sSrcFileName);
std::wstring sFileInDir = strFileInDir.c_str();
oDrawingConverter.SetSrcPath(sFileInDir);
oDrawingConverter.SetSourceFileDir(sFileInDir);
BinaryFileReader oBinaryFileReader(sFileInDir, oBufferedStream, *m_pCurFileWriter);
oBinaryFileReader.ReadFile();

View File

@ -86,16 +86,15 @@ namespace BinXlsxRW{
}
bool CXlsxSerializer::loadFromFile(const std::wstring& sSrcFileName, const std::wstring& sDstPath, const std::wstring& sXMLOptions, const std::wstring& sMediaDir, const std::wstring& sEmbedDir)
{
std::wstring strFileInDir = NSSystemPath::GetDirectoryName(sSrcFileName);
NSBinPptxRW::CDrawingConverter oDrawingConverter;
NSBinPptxRW::CDrawingConverter oDrawingConverter;
oDrawingConverter.SetDstPath(sDstPath + FILE_SEPARATOR_STR + L"xl");
oDrawingConverter.SetSrcPath(strFileInDir, 2);
oDrawingConverter.SetMediaDstPath(sMediaDir);
oDrawingConverter.SetMediaDstPath(sMediaDir);
oDrawingConverter.SetEmbedDstPath(sEmbedDir);
std::wstring strFileInDir = NSSystemPath::GetDirectoryName(sSrcFileName);
oDrawingConverter.SetSourceFileDir(strFileInDir, 2);
BinXlsxRW::BinaryFileReader oBinaryFileReader;
oBinaryFileReader.ReadFile(sSrcFileName, sDstPath, &oDrawingConverter, sXMLOptions);
return true;

View File

@ -913,29 +913,20 @@ HRESULT CDrawingConverter::SetMainDocument(BinDocxRW::CDocxSerializer* pDocument
return S_OK;
}
void CDrawingConverter::SetSrcPath(const std::wstring& sPath, int nDocType)
HRESULT CDrawingConverter::SetMediaDstPath(const std::wstring& bsMediaPath)
{
m_pReader->m_pRels->m_pManager = m_pImageManager;
m_pReader->m_strFolder = sPath;
m_pBinaryWriter->m_pCommon->m_pImageManager->m_strDstMedia = (std::wstring)bsMediaPath;
m_pImageManager->SetDstMedia(m_pBinaryWriter->m_pCommon->m_pImageManager->m_strDstMedia);
m_pImageManager->m_nDocumentType = nDocType;
NSDirectory::CreateDirectory(bsMediaPath);
return S_OK;
}
void CDrawingConverter::SetDstPath(const std::wstring& sPath)
HRESULT CDrawingConverter::SetEmbedDstPath(const std::wstring& bsEmbedPath)
{
m_pImageManager->SetDstFolder(sPath);
}
void CDrawingConverter::SetMediaDstPath(const std::wstring& sPath)
{
m_pBinaryWriter->m_pCommon->m_pImageManager->m_strDstMedia = sPath;
m_pImageManager->SetDstMedia(sPath);
m_pImageManager->SetDstEmbed(bsEmbedPath);
NSDirectory::CreateDirectory(sPath);
}
void CDrawingConverter::SetEmbedDstPath(const std::wstring& sPath)
{
m_pImageManager->SetDstEmbed(sPath);
NSDirectory::CreateDirectory(sPath);
NSDirectory::CreateDirectory(bsEmbedPath);
return S_OK;
}
HRESULT CDrawingConverter::AddShapeType(const std::wstring& bsXml)
{
@ -5283,6 +5274,14 @@ OOX::CContentTypes* CDrawingConverter::GetContentTypes()
//return m_pReader->mm_strContentTypes;
}
void CDrawingConverter::SetSourceFileDir(std::wstring path, int nDocType)
{
m_pReader->m_pRels->m_pManager = m_pImageManager;
m_pReader->m_strFolder = path;
m_pImageManager->m_nDocumentType = nDocType;
}
void CDrawingConverter::Clear()
{
for (std::map<std::wstring, CShape*>::iterator pPair = m_mapShapeTypes.begin(); pPair != m_mapShapeTypes.end(); ++pPair)

View File

@ -215,12 +215,8 @@ namespace NSBinPptxRW
smart_ptr<OOX::IFileContainer> GetRels();
HRESULT SetMainDocument (BinDocxRW::CDocxSerializer* pDocument);
void SetSrcPath (const std::wstring& sPath, int nDocType = 1/*XMLWRITER_DOC_TYPE_DOCX*/);
void SetDstPath (const std::wstring& sPath);
void SetMediaDstPath (const std::wstring& sMediaPath);
void SetEmbedDstPath (const std::wstring& sEmbedPath);
HRESULT SetMediaDstPath (const std::wstring& sMediaPath);
HRESULT SetEmbedDstPath (const std::wstring& sEmbedPath);
HRESULT AddShapeType (const std::wstring& sXml);
HRESULT AddObject (const std::wstring& sXml, std::wstring** pMainProps);
@ -259,6 +255,8 @@ namespace NSBinPptxRW
void SetDocumentChartsCount (int val);
int GetDocumentChartsCount ();
void SetSourceFileDir (std::wstring path, int nDocType = 1/*XMLWRITER_DOC_TYPE_DOCX*/);
OOX::CContentTypes* GetContentTypes();
protected:
nullable<PPTX::Logic::Xfrm> m_oxfrm_override;

View File

@ -346,11 +346,8 @@ namespace PPTX
pReader->m_pRels = new NSBinPptxRW::CRelsGenerator();
oDrawingConverter.SetMainDocument(&oDocxSerializer);
oDrawingConverter.SetDstPath(sDstEmbeddedTemp + FILE_SEPARATOR_STR + L"word");
oDrawingConverter.SetSrcPath(pReader->m_strFolder, 1);
oDrawingConverter.SetMediaDstPath(sMediaPath);
oDrawingConverter.SetSourceFileDir(pReader->m_strFolder, 1);
oDrawingConverter.SetMediaDstPath(sMediaPath);
oDrawingConverter.SetEmbedDstPath(sEmbedPath);
std::wstring sDocxFilename = L"Microsoft_Word_Document" + std::to_wstring( id ) + L".docx";
@ -437,10 +434,8 @@ namespace PPTX
oDrawingConverter.m_pReader = pReader;
pReader->m_pRels = new NSBinPptxRW::CRelsGenerator();
oDrawingConverter.SetDstPath(sDstEmbeddedTemp + FILE_SEPARATOR_STR + L"xl");
oDrawingConverter.SetSrcPath(pReader->m_strFolder, 2);
oDrawingConverter.SetMediaDstPath(sMediaPath);
oDrawingConverter.SetSourceFileDir(pReader->m_strFolder, 2);
oDrawingConverter.SetMediaDstPath(sMediaPath);
oDrawingConverter.SetEmbedDstPath(sEmbedPath);
std::wstring sXlsxFilename = L"Microsoft_Excel_Worksheet" + std::to_wstring( id ) + L".xlsx";

View File

@ -469,8 +469,8 @@ namespace PPTX
bool m_bMacroEnabled;
smart_ptr<OOX::VbaProject> m_pVbaProject;
void SetClrMap(Logic::ClrMap map) {m_clrMap = map;}
void SetClrScheme(nsTheme::ClrScheme scheme) {m_clrScheme = scheme;}
void SetClrMap(Logic::ClrMap map) {m_clrMap = map;};
void SetClrScheme(nsTheme::ClrScheme scheme) {m_clrScheme = scheme;};
DWORD GetRGBAFromMap(const std::wstring& str)const
{

View File

@ -66,6 +66,7 @@ core_mac {
core_windows {
CONFIG -= debug_and_release debug_and_release_target
QMAKE_CXXFLAGS_RELEASE -= -Zc:strictStrings
QMAKE_CXXFLAGS += /MP
}
core_win_32 {

View File

@ -67,7 +67,7 @@ namespace BinXlsxRW
int nCurPos = 0;
for(size_t i = 0, length = oTableParts.m_arrItems.size(); i < length; ++i)
WriteTablePart(oWorksheet, *oTableParts.m_arrItems[i]);
}
};
void WriteTablePart(const OOX::Spreadsheet::CWorksheet& oWorksheet, const OOX::Spreadsheet::CTablePart& oTablePart)
{
int nCurPos = 0;
@ -578,13 +578,13 @@ namespace BinXlsxRW
public:
BinaryStyleTableWriter(NSBinPptxRW::CBinaryFileWriter &oCBufferedStream, NSFontCutter::CEmbeddedFontsManager* pEmbeddedFontsManager):m_oBcw(oCBufferedStream),m_pEmbeddedFontsManager(pEmbeddedFontsManager)
{
}
};
void Write(OOX::Spreadsheet::CStyles& styles, PPTX::Theme* pTheme, DocWrapper::FontProcessor& oFontProcessor)
{
int nStart = m_oBcw.WriteItemWithLengthStart();
WriteStylesContent(styles, pTheme, oFontProcessor);
m_oBcw.WriteItemWithLengthEnd(nStart);
}
};
void WriteStylesContent(OOX::Spreadsheet::CStyles& styles, PPTX::Theme* pTheme, DocWrapper::FontProcessor& oFontProcessor)
{
int nCurPos;
@ -656,7 +656,7 @@ namespace BinXlsxRW
WriteTableStyles(styles.m_oTableStyles.get());
m_oBcw.WriteItemEnd(nCurPos);
}
}
};
void WriteBorders(const OOX::Spreadsheet::CBorders& borders, OOX::Spreadsheet::CIndexedColors* pIndexedColors, PPTX::Theme* pTheme)
{
int nCurPos = 0;
@ -667,7 +667,7 @@ namespace BinXlsxRW
WriteBorder(*pBorder, pIndexedColors, pTheme);
m_oBcw.WriteItemEnd(nCurPos);
}
}
};
void WriteBorder(const OOX::Spreadsheet::CBorder& border, OOX::Spreadsheet::CIndexedColors* pIndexedColors, PPTX::Theme* pTheme)
{
int nCurPos = 0;
@ -741,7 +741,7 @@ namespace BinXlsxRW
m_oBcw.m_oStream.WriteBOOL(border.m_oOutline->ToBool());
m_oBcw.WriteItemEnd(nCurPos);
}
}
};
void WriteBorderProp(const OOX::Spreadsheet::CBorderProp& borderProp, OOX::Spreadsheet::CIndexedColors* pIndexedColors, PPTX::Theme* pTheme)
{
int nCurPos = 0;
@ -761,7 +761,7 @@ namespace BinXlsxRW
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Byte);
m_oBcw.m_oStream.WriteBYTE((BYTE)borderProp.m_oStyle->GetValue());
}
}
};
void WriteCellStyleXfs(const OOX::Spreadsheet::CCellStyleXfs& cellStyleXfs)
{
int nCurPos = 0;
@ -791,7 +791,7 @@ namespace BinXlsxRW
m_oBcw.WriteItemEnd(nCurPos);
}
}
}
};
void WriteXfs(const OOX::Spreadsheet::CXfs& xfs)
{
int nCurPos = 0;
@ -888,7 +888,7 @@ namespace BinXlsxRW
WriteAligment(xfs.m_oAligment.get());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
}
};
void WriteAligment(const OOX::Spreadsheet::CAligment& aligment)
{
int nCurPos = 0;
@ -952,7 +952,7 @@ namespace BinXlsxRW
WriteFill(*pFill, pIndexedColors, pTheme, false);
m_oBcw.WriteItemEnd(nCurPos);
}
}
};
void WriteFill(const OOX::Spreadsheet::CFill& fill, OOX::Spreadsheet::CIndexedColors* pIndexedColors, PPTX::Theme* pTheme, bool bPriorityBg = false)
{
int nCurPos = 0;
@ -1002,7 +1002,7 @@ namespace BinXlsxRW
m_oBcw.WriteItemEnd(nCurPos2);
m_oBcw.WriteItemEnd(nCurPos);
}
}
};
void WriteFonts(const OOX::Spreadsheet::CFonts& fonts, OOX::Spreadsheet::CIndexedColors* pIndexedColors, PPTX::Theme* pTheme, DocWrapper::FontProcessor& oFontProcessor)
{
int nCurPos = 0;
@ -1013,7 +1013,7 @@ namespace BinXlsxRW
WriteFont(*pFont, pIndexedColors, pTheme, oFontProcessor);
m_oBcw.WriteItemEnd(nCurPos);
}
}
};
void WriteFont(const OOX::Spreadsheet::CFont& font, OOX::Spreadsheet::CIndexedColors* pIndexedColors, PPTX::Theme* theme, DocWrapper::FontProcessor& oFontProcessor)
{
int nCurPos = 0;
@ -1092,7 +1092,7 @@ namespace BinXlsxRW
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Byte);
m_oBcw.m_oStream.WriteBYTE(font.m_oVertAlign->m_oVerticalAlign->GetValue());
}
}
};
void WriteNumFmts(const OOX::Spreadsheet::CNumFmts& numFmts)
{
int nCurPos = 0;
@ -1103,7 +1103,7 @@ namespace BinXlsxRW
WriteNumFmt(*pNumFmt);
m_oBcw.WriteItemEnd(nCurPos);
}
}
};
void WriteNumFmt(const OOX::Spreadsheet::CNumFmt& numFmt)
{
int nCurPos = 0;
@ -1125,7 +1125,7 @@ namespace BinXlsxRW
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG(numFmt.m_oNumFmtId->GetValue());
}
}
};
void WriteCellStyles(const OOX::Spreadsheet::CCellStyles& oCellStyles)
{
int nCurPos = 0;
@ -1190,7 +1190,7 @@ namespace BinXlsxRW
WriteDxf(*pDxf, pIndexedColors, pTheme, oFontProcessor);
m_oBcw.WriteItemEnd(nCurPos);
}
}
};
void WriteDxf(const OOX::Spreadsheet::CDxf& oDxf, OOX::Spreadsheet::CIndexedColors* pIndexedColors, PPTX::Theme* pTheme, DocWrapper::FontProcessor& oFontProcessor)
{
int nCurPos = 0;
@ -1328,13 +1328,13 @@ namespace BinXlsxRW
public:
BinarySharedStringTableWriter(NSBinPptxRW::CBinaryFileWriter &oCBufferedStream, NSFontCutter::CEmbeddedFontsManager* pEmbeddedFontsManager):m_oBcw(oCBufferedStream),m_pEmbeddedFontsManager(pEmbeddedFontsManager)
{
}
};
void Write(OOX::Spreadsheet::CSharedStrings& sharedString, OOX::Spreadsheet::CIndexedColors* pIndexedColors, PPTX::Theme* pTheme, DocWrapper::FontProcessor& oFontProcessor)
{
int nStart = m_oBcw.WriteItemWithLengthStart();
WriteSharedStrings(sharedString, pIndexedColors, pTheme, oFontProcessor);
m_oBcw.WriteItemWithLengthEnd(nStart);
}
};
void WriteSharedStrings(OOX::Spreadsheet::CSharedStrings& sharedString, OOX::Spreadsheet::CIndexedColors* pIndexedColors, PPTX::Theme* pTheme, DocWrapper::FontProcessor& oFontProcessor)
{
int nCurPos;
@ -1349,7 +1349,7 @@ namespace BinXlsxRW
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
}
}
};
void WriteSharedString(OOX::Spreadsheet::CSi& si, OOX::Spreadsheet::CIndexedColors* pIndexedColors, PPTX::Theme* pTheme, DocWrapper::FontProcessor& oFontProcessor)
{
int nCurPos;
@ -1373,7 +1373,7 @@ namespace BinXlsxRW
m_pEmbeddedFontsManager->CheckString(pText->m_sText);
}
}
}
};
void WriteRun(OOX::Spreadsheet::CRun& run, OOX::Spreadsheet::CIndexedColors* pIndexedColors, PPTX::Theme* pTheme, DocWrapper::FontProcessor& oFontProcessor)
{
int nCurPos;
@ -1397,7 +1397,7 @@ namespace BinXlsxRW
m_pEmbeddedFontsManager->CheckString(pText->m_sText);
}
}
}
};
void WriteRPr(const OOX::Spreadsheet::CRPr& rPr, OOX::Spreadsheet::CIndexedColors* pIndexedColors, PPTX::Theme* pTheme, DocWrapper::FontProcessor& oFontProcessor)
{
int nCurPos = 0;
@ -1475,7 +1475,7 @@ namespace BinXlsxRW
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Byte);
m_oBcw.m_oStream.WriteBYTE(rPr.m_oVertAlign->m_oVerticalAlign->GetValue());
}
}
};
};
class BinaryWorkbookTableWriter
@ -1528,15 +1528,11 @@ namespace BinXlsxRW
{
nCurPos = m_oBcw.WriteItemStart(c_oSerWorkbookTypes::VbaProject);
smart_ptr<OOX::VbaProject> vbaProject = fileVbaProject.smart_dynamic_cast<OOX::VbaProject>();
m_oBcw.m_oStream.StartRecord(0);
vbaProject->toPPTY(&m_oBcw.m_oStream);
m_oBcw.m_oStream.EndRecord();
m_oBcw.WriteItemWithLengthEnd(nCurPos);
smart_ptr<OOX::VbaProject> vbaProject = fileVbaProject.smart_dynamic_cast<OOX::VbaProject>();
WriteVbaProject (vbaProject);
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
}
};
void WriteWorkbookPr(const OOX::Spreadsheet::CWorkbookPr& workbookPr)
{
//Date1904
@ -1553,7 +1549,7 @@ namespace BinXlsxRW
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Byte);
m_oBcw.m_oStream.WriteBOOL(workbookPr.m_oDateCompatibility->ToBool());
}
}
};
void WriteBookViews(const OOX::Spreadsheet::CBookViews& bookViews)
{
int nCurPos;
@ -1565,7 +1561,7 @@ namespace BinXlsxRW
WriteWorkbookView(*pWorkbookView);
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
}
};
void WriteWorkbookView(const OOX::Spreadsheet::CWorkbookView& workbookView)
{
//ActiveTab
@ -1575,7 +1571,7 @@ namespace BinXlsxRW
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG(workbookView.m_oActiveTab->GetValue());
}
}
};
void WriteDefinedNames(const OOX::Spreadsheet::CDefinedNames& definedNames)
{
int nCurPos;
@ -1587,7 +1583,7 @@ namespace BinXlsxRW
WriteDefinedName(*pDefinedName);
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
}
};
void WriteExternalReferences(const OOX::Spreadsheet::CExternalReferences& externalReferences, OOX::Spreadsheet::CWorkbook& workbook)
{
int nCurPos;
@ -1653,7 +1649,7 @@ namespace BinXlsxRW
}
}
}
}
};
void WriteExternalBook(const OOX::Spreadsheet::CExternalBook& externalBook, const std::wstring& sLink)
{
int nCurPos = 0;
@ -1976,6 +1972,18 @@ namespace BinXlsxRW
m_oBcw.m_oStream.WriteStringW(definedName.m_oComment.get2());
}
}
void WriteVbaProject(smart_ptr<OOX::VbaProject> & fileVbaProject)
{
std::wstring file_name = fileVbaProject->filename().GetFilename();
m_oBcw.m_oStream.WriteBYTE(c_oSerWorkbookVbaProjectTypes::Name);
m_oBcw.m_oStream.WriteStringW(file_name);
//... todooo write parsing vba project
//copy file bin
fileVbaProject->copy_to(m_oBcw.m_oStream.m_pCommon->m_pImageManager->m_strDstMedia);
}
};
class BinaryWorksheetTableWriter
{
@ -4121,13 +4129,13 @@ namespace BinXlsxRW
public:
BinaryCalcChainTableWriter(NSBinPptxRW::CBinaryFileWriter &oCBufferedStream) : m_oBcw(oCBufferedStream)
{
}
};
void Write(OOX::Spreadsheet::CCalcChain& pCalcChain)
{
int nStart = m_oBcw.WriteItemWithLengthStart();
WriteCalcChainTableContent(pCalcChain);
m_oBcw.WriteItemWithLengthEnd(nStart);
}
};
void WriteCalcChainTableContent(OOX::Spreadsheet::CCalcChain& pCalcChain)
{
int nCurPos;
@ -4138,7 +4146,7 @@ namespace BinXlsxRW
WriteCalcChain(*pCalcChain.m_arrItems[i]);
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
}
};
void WriteCalcChain(OOX::Spreadsheet::CCalcCell& oCalcCell)
{
//Array
@ -4183,7 +4191,7 @@ namespace BinXlsxRW
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Byte);
m_oBcw.m_oStream.WriteBOOL(oCalcCell.m_oNewThread->ToBool());
}
}
};
};
class BinaryOtherTableWriter
{
@ -4217,13 +4225,13 @@ namespace BinXlsxRW
m_pTheme (pTheme),
m_pOfficeDrawingConverter(pOfficeDrawingConverter)
{
}
};
void Write()
{
int nStart = m_oBcw.WriteItemWithLengthStart();
WriteOtherTableContent();
m_oBcw.WriteItemWithLengthEnd(nStart);
}
};
void WriteOtherTableContent()
{
int nCurPos;
@ -4244,7 +4252,7 @@ namespace BinXlsxRW
m_pTheme->toPPTY(&m_oBcw.m_oStream);
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
}
};
};
class BinaryFileWriter {
private:
@ -4271,8 +4279,7 @@ namespace BinXlsxRW
std::wstring mediaDir = path.GetDirectory() + L"media";
NSDirectory::CreateDirectory(mediaDir);
pOfficeDrawingConverter->SetDstPath(path.GetDirectory() + FILE_SEPARATOR_STR + L"word");
pOfficeDrawingConverter->SetMediaDstPath(mediaDir);
pOfficeDrawingConverter->SetMediaDstPath(mediaDir);
long nGrowSize = 1 * 1024 * 1024;//1мб
NSBinPptxRW::CBinaryFileWriter& oBufferedStream = *pOfficeDrawingConverter->m_pBinaryWriter;

View File

@ -56,8 +56,8 @@ namespace BinXlsxRW {
std::wstring sPath;
int nIndex;
std::map<OOX::Spreadsheet::CDrawing*, std::wstring> mapDrawings;
ImageObject()
public:
ImageObject()
{
}
ImageObject(std::wstring& _sPath, int _nIndex)
@ -75,8 +75,8 @@ namespace BinXlsxRW {
OOX::Spreadsheet::CPivotCacheRecords* pRecords;
long nCacheId;
OOX::Spreadsheet::CPivotTable* pTable;
PivotCachesTemp()
public:
PivotCachesTemp()
{
nId = -1;
pDefinitionData = NULL;
@ -1515,7 +1515,7 @@ namespace BinXlsxRW {
int Read()
{
return ReadTable(&BinaryWorkbookTableReader::ReadWorkbookTableContent, this);
}
};
int ReadWorkbookTableContent(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
@ -1548,19 +1548,12 @@ namespace BinXlsxRW {
}
else if(c_oSerWorkbookTypes::VbaProject == type)
{
smart_ptr<OOX::VbaProject> oFileVbaProject(new OOX::VbaProject());
oFileVbaProject->fromPPTY(&m_oBufferedStream);
smart_ptr<OOX::File> oFile = oFileVbaProject.smart_dynamic_cast<OOX::File>();
const OOX::RId oRId = m_oWorkbook.Add(oFile);
m_oWorkbook.m_bMacroEnabled = true;
}
res = Read1(length, &BinaryWorkbookTableReader::ReadVbaProject, this, poResult);
}
else
res = c_oSerConstants::ReadUnknown;
return res;
}
};
int ReadWorkbookPr(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
@ -1577,7 +1570,7 @@ namespace BinXlsxRW {
else
res = c_oSerConstants::ReadUnknown;
return res;
}
};
int ReadBookViews(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
@ -1667,7 +1660,7 @@ namespace BinXlsxRW {
else
res = c_oSerConstants::ReadUnknown;
return res;
}
};
int ReadDefinedNames(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
@ -1680,7 +1673,7 @@ namespace BinXlsxRW {
else
res = c_oSerConstants::ReadUnknown;
return res;
}
};
int ReadDefinedName(BYTE type, long length, void* poResult)
{
OOX::Spreadsheet::CDefinedName* pDefinedName = static_cast<OOX::Spreadsheet::CDefinedName*>(poResult);
@ -1713,7 +1706,7 @@ namespace BinXlsxRW {
else
res = c_oSerConstants::ReadUnknown;
return res;
}
};
int ReadExternalBook(BYTE type, long length, void* poResult)
{
OOX::Spreadsheet::CExternalLink* extLink = static_cast<OOX::Spreadsheet::CExternalLink*>(poResult);
@ -1748,7 +1741,7 @@ namespace BinXlsxRW {
else
res = c_oSerConstants::ReadUnknown;
return res;
}
};
int ReadExternalSheetNames(BYTE type, long length, void* poResult)
{
OOX::Spreadsheet::CExternalSheetNames* pSheetNames = static_cast<OOX::Spreadsheet::CExternalSheetNames*>(poResult);
@ -1763,7 +1756,7 @@ namespace BinXlsxRW {
else
res = c_oSerConstants::ReadUnknown;
return res;
}
};
int ReadExternalDefinedNames(BYTE type, long length, void* poResult)
{
OOX::Spreadsheet::CExternalDefinedNames* pDefinedNames = static_cast<OOX::Spreadsheet::CExternalDefinedNames*>(poResult);
@ -1777,7 +1770,7 @@ namespace BinXlsxRW {
else
res = c_oSerConstants::ReadUnknown;
return res;
}
};
int ReadExternalDefinedName(BYTE type, long length, void* poResult)
{
OOX::Spreadsheet::CExternalDefinedName* pDefinedName = static_cast<OOX::Spreadsheet::CExternalDefinedName*>(poResult);
@ -1800,7 +1793,7 @@ namespace BinXlsxRW {
else
res = c_oSerConstants::ReadUnknown;
return res;
}
};
int ReadExternalSheetDataSet(BYTE type, long length, void* poResult)
{
OOX::Spreadsheet::CExternalSheetDataSet* pSheetDataSet = static_cast<OOX::Spreadsheet::CExternalSheetDataSet*>(poResult);
@ -1814,7 +1807,7 @@ namespace BinXlsxRW {
else
res = c_oSerConstants::ReadUnknown;
return res;
}
};
int ReadExternalSheetData(BYTE type, long length, void* poResult)
{
OOX::Spreadsheet::CExternalSheetData* pSheetData = static_cast<OOX::Spreadsheet::CExternalSheetData*>(poResult);
@ -1838,7 +1831,7 @@ namespace BinXlsxRW {
else
res = c_oSerConstants::ReadUnknown;
return res;
}
};
int ReadExternalRow(BYTE type, long length, void* poResult)
{
OOX::Spreadsheet::CExternalRow* pRow = static_cast<OOX::Spreadsheet::CExternalRow*>(poResult);
@ -1857,7 +1850,7 @@ namespace BinXlsxRW {
else
res = c_oSerConstants::ReadUnknown;
return res;
}
};
int ReadExternalCell(BYTE type, long length, void* poResult)
{
OOX::Spreadsheet::CExternalCell* pCell = static_cast<OOX::Spreadsheet::CExternalCell*>(poResult);
@ -1880,7 +1873,7 @@ namespace BinXlsxRW {
else
res = c_oSerConstants::ReadUnknown;
return res;
}
};
int ReadOleLink(BYTE type, long length, void* poResult)
{
OOX::Spreadsheet::CExternalLink* extLink = static_cast<OOX::Spreadsheet::CExternalLink*>(poResult);
@ -1915,7 +1908,7 @@ namespace BinXlsxRW {
else
res = c_oSerConstants::ReadUnknown;
return res;
}
};
int ReadOleItem(BYTE type, long length, void* poResult)
{
OOX::Spreadsheet::COleItem* pOleItem = static_cast<OOX::Spreadsheet::COleItem*>(poResult);
@ -1943,7 +1936,7 @@ namespace BinXlsxRW {
else
res = c_oSerConstants::ReadUnknown;
return res;
}
};
int ReadDdeLink(BYTE type, long length, void* poResult)
{
OOX::Spreadsheet::CDdeLink* ddeLink = static_cast<OOX::Spreadsheet::CDdeLink*>(poResult);
@ -1971,7 +1964,7 @@ namespace BinXlsxRW {
else
res = c_oSerConstants::ReadUnknown;
return res;
}
};
int ReadDdeItem(BYTE type, long length, void* poResult)
{
OOX::Spreadsheet::CDdeItem* pDdeItem = static_cast<OOX::Spreadsheet::CDdeItem*>(poResult);
@ -2004,7 +1997,7 @@ namespace BinXlsxRW {
else
res = c_oSerConstants::ReadUnknown;
return res;
}
};
int ReadDdeValues(BYTE type, long length, void* poResult)
{
OOX::Spreadsheet::CDdeValues* pDdeValues = static_cast<OOX::Spreadsheet::CDdeValues*>(poResult);
@ -2028,7 +2021,7 @@ namespace BinXlsxRW {
else
res = c_oSerConstants::ReadUnknown;
return res;
}
};
int ReadDdeValue(BYTE type, long length, void* poResult)
{
OOX::Spreadsheet::CDdeValue* pDdeValue = static_cast<OOX::Spreadsheet::CDdeValue*>(poResult);
@ -2047,7 +2040,7 @@ namespace BinXlsxRW {
else
res = c_oSerConstants::ReadUnknown;
return res;
}
};
int ReadPivotCaches(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
@ -2109,18 +2102,29 @@ namespace BinXlsxRW {
int ReadVbaProject(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
if(c_oSerWorkbookVbaProjectTypes::Name == type)
{
std::wstring file_name = m_oBufferedStream.GetString4(length);
smart_ptr<OOX::VbaProject> oFileVbaProject(new OOX::VbaProject());
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");
oFileVbaProject->fromPPTY(&m_oBufferedStream);
NSFile::CFileBinary::Copy(inputPath.GetPath(), outputPath.GetPath());
smart_ptr<OOX::File> oFile = oFileVbaProject.smart_dynamic_cast<OOX::File>();
const OOX::RId oRId = m_oWorkbook.Add(oFile);
smart_ptr<OOX::VbaProject> oFileVbaProject(new OOX::VbaProject());
oFileVbaProject->set_filename(outputPath.GetPath());
smart_ptr<OOX::File> oFile = oFileVbaProject.smart_dynamic_cast<OOX::File>();
const OOX::RId oRId = m_oWorkbook.Add(oFile);
m_oWorkbook.m_bMacroEnabled = true;
m_oWorkbook.m_bMacroEnabled = true;
return res;
}
else
res = c_oSerConstants::ReadUnknown;
return res;
}
}
};
class BinaryCommentReader : public Binary_CommonReader<BinaryCommentReader>
{
@ -2171,7 +2175,7 @@ namespace BinXlsxRW {
else
res = c_oSerConstants::ReadUnknown;
return res;
}
};
int ReadComment(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
@ -2255,7 +2259,7 @@ namespace BinXlsxRW {
else
res = c_oSerConstants::ReadUnknown;
return res;
}
};
int ReadCommentDatas(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
@ -2385,7 +2389,7 @@ namespace BinXlsxRW {
{
m_oWorkbook.m_oSheets.Init();
return ReadTable(&BinaryWorksheetsTableReader::ReadWorksheetsTableContent, this);
}
};
int ReadWorksheetsTableContent(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
@ -2423,7 +2427,7 @@ namespace BinXlsxRW {
else
res = c_oSerConstants::ReadUnknown;
return res;
}
};
int ReadWorksheet(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
@ -3009,7 +3013,7 @@ namespace BinXlsxRW {
else
res = c_oSerConstants::ReadUnknown;
return res;
}
};
int ReadPageMargins(BYTE type, long length, void* poResult)
{
OOX::Spreadsheet::CPageMargins* pPageMargins = static_cast<OOX::Spreadsheet::CPageMargins*>(poResult);
@ -3047,7 +3051,7 @@ namespace BinXlsxRW {
else
res = c_oSerConstants::ReadUnknown;
return res;
}
};
int ReadPageSetup(BYTE type, long length, void* poResult)
{
OOX::Spreadsheet::CPageSetup* pPageSetup = static_cast<OOX::Spreadsheet::CPageSetup*>(poResult);
@ -3065,7 +3069,7 @@ namespace BinXlsxRW {
else
res = c_oSerConstants::ReadUnknown;
return res;
}
};
int ReadPrintOptions(BYTE type, long length, void* poResult)
{
OOX::Spreadsheet::CPrintOptions* pPrintOptions = static_cast<OOX::Spreadsheet::CPrintOptions*>(poResult);
@ -3086,7 +3090,7 @@ namespace BinXlsxRW {
else
res = c_oSerConstants::ReadUnknown;
return res;
}
};
int ReadHyperlinks(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
@ -3099,7 +3103,7 @@ namespace BinXlsxRW {
else
res = c_oSerConstants::ReadUnknown;
return res;
}
};
int ReadHyperlink(BYTE type, long length, void* poResult)
{
OOX::Spreadsheet::CHyperlink* pHyperlink = static_cast<OOX::Spreadsheet::CHyperlink*>(poResult);
@ -3134,7 +3138,7 @@ namespace BinXlsxRW {
else
res = c_oSerConstants::ReadUnknown;
return res;
}
};
int ReadMergeCells(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
@ -3296,7 +3300,7 @@ namespace BinXlsxRW {
else
res = c_oSerConstants::ReadUnknown;
return res;
}
};
int ReadDrawing(BYTE type, long length, void* poResult)
{
OOX::Spreadsheet::CCellAnchor* pCellAnchor = static_cast<OOX::Spreadsheet::CCellAnchor*>(poResult);
@ -3344,7 +3348,7 @@ namespace BinXlsxRW {
else
res = c_oSerConstants::ReadUnknown;
return res;
}
};
int ReadFromTo(BYTE type, long length, void* poResult)
{
OOX::Spreadsheet::CFromTo* pFromTo = static_cast<OOX::Spreadsheet::CFromTo*>(poResult);
@ -3374,7 +3378,7 @@ namespace BinXlsxRW {
else
res = c_oSerConstants::ReadUnknown;
return res;
}
};
int ReadExt(BYTE type, long length, void* poResult)
{
OOX::Spreadsheet::CExt* pExt = static_cast<OOX::Spreadsheet::CExt*>(poResult);
@ -3394,7 +3398,7 @@ namespace BinXlsxRW {
else
res = c_oSerConstants::ReadUnknown;
return res;
}
};
int ReadPos(BYTE type, long length, void* poResult)
{
OOX::Spreadsheet::CPos* pPos = static_cast<OOX::Spreadsheet::CPos*>(poResult);
@ -3414,7 +3418,7 @@ namespace BinXlsxRW {
else
res = c_oSerConstants::ReadUnknown;
return res;
}
};
int ReadSheetData(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
@ -3427,7 +3431,7 @@ namespace BinXlsxRW {
else
res = c_oSerConstants::ReadUnknown;
return res;
}
};
int ReadRow(BYTE type, long length, void* poResult)
{
OOX::Spreadsheet::CRow* pRow = static_cast<OOX::Spreadsheet::CRow*>(poResult);
@ -3635,7 +3639,7 @@ namespace BinXlsxRW {
else
res = c_oSerConstants::ReadUnknown;
return res;
}
};
int ReadConditionalFormatting(BYTE type, long length, void* poResult)
{
OOX::Spreadsheet::CConditionalFormatting* pConditionalFormatting = static_cast<OOX::Spreadsheet::CConditionalFormatting*>(poResult);
@ -3659,7 +3663,7 @@ namespace BinXlsxRW {
else
res = c_oSerConstants::ReadUnknown;
return res;
}
};
int ReadConditionalFormattingRule(BYTE type, long length, void* poResult)
{
OOX::Spreadsheet::CConditionalFormattingRule* pConditionalFormattingRule = static_cast<OOX::Spreadsheet::CConditionalFormattingRule*>(poResult);
@ -3776,7 +3780,7 @@ namespace BinXlsxRW {
else
res = c_oSerConstants::ReadUnknown;
return res;
}
};
int ReadDataBar(BYTE type, long length, void* poResult)
{
OOX::Spreadsheet::CDataBar* pDataBar = static_cast<OOX::Spreadsheet::CDataBar*>(poResult);
@ -4024,7 +4028,7 @@ namespace BinXlsxRW {
else
res = c_oSerConstants::ReadUnknown;
return res;
}
};
int ReadSparklines(BYTE type, long length, void* poResult)
{
OOX::Spreadsheet::CSparklines* pSparklines = static_cast<OOX::Spreadsheet::CSparklines*>(poResult);
@ -4038,7 +4042,7 @@ namespace BinXlsxRW {
else
res = c_oSerConstants::ReadUnknown;
return res;
}
};
int ReadSparkline(BYTE type, long length, void* poResult)
{
OOX::Spreadsheet::CSparkline* pSparkline = static_cast<OOX::Spreadsheet::CSparkline*>(poResult);
@ -4102,7 +4106,7 @@ namespace BinXlsxRW {
int Read()
{
return ReadTable(&BinaryOtherTableReader::ReadOtherTableContent, this);
}
};
int ReadOtherTableContent(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
@ -4136,7 +4140,7 @@ namespace BinXlsxRW {
else
res = c_oSerConstants::ReadUnknown;
return res;
}
};
int ReadMediaItem(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;