From e3f331c19db0bed89a2b162ec5120dbbc82c4034 Mon Sep 17 00:00:00 2001 From: konovalovsergey Date: Wed, 28 Sep 2016 16:27:24 +0300 Subject: [PATCH] open/save math spreadsheet and presentation --- ASCOfficeDocxFile2/BinReader/FileWriter.h | 4 +- ASCOfficeDocxFile2/BinReader/Readers.h | 11 + .../BinReader/fontTableWriter.h | 24 ++- .../BinWriter/BinReaderWriterDefines.h | 5 +- ASCOfficeDocxFile2/BinWriter/BinWriters.cpp | 94 +++++++++ ASCOfficeDocxFile2/BinWriter/BinWriters.h | 63 +----- .../DocWrapper/DocxSerializer.cpp | 74 ++++++- .../DocWrapper/DocxSerializer.h | 10 +- .../Linux/ASCOfficeDocxFile2Lib.pro | 1 + .../Editor/BinReaderWriterDefines.h | 2 + ASCOfficePPTXFile/PPTXFormat/Comments.h | 4 +- ASCOfficePPTXFile/PPTXFormat/HandoutMaster.h | 4 +- .../PPTXFormat/Logic/Paragraph.h | 24 ++- ASCOfficePPTXFile/PPTXFormat/Logic/RunElem.h | 5 +- .../PPTXFormat/Logic/Runs/MathParaWrapper.cpp | 194 ++++++++++++++++++ .../PPTXFormat/Logic/Runs/MathParaWrapper.h | 77 +++++++ .../PPTXFormat/Logic/SpTreeElem.cpp | 36 ++-- ASCOfficePPTXFile/PPTXFormat/NotesMaster.h | 4 + ASCOfficePPTXFile/PPTXFormat/NotesSlide.h | 6 +- ASCOfficePPTXFile/PPTXFormat/Presentation.h | 6 +- ASCOfficePPTXFile/PPTXFormat/Slide.h | 4 + ASCOfficePPTXFile/PPTXFormat/SlideLayout.h | 4 + ASCOfficePPTXFile/PPTXFormat/SlideMaster.h | 4 + .../Linux/PPTXFormatLib/PPTXFormatLib.pro | 2 + .../DocxFormatLib/DocxFormatLib.pro | 4 +- .../DocxFormat/Source/DocxFormat/Math/OMath.h | 21 +- .../Source/DocxFormat/Math/oMathContent.cpp | 5 +- .../Source/DocxFormat/Math/oMathContent.h | 45 +++- Common/DocxFormat/Source/XML/Utils.h | 27 ++- .../Source/XlsxFormat/Drawing/CellAnchor.h | 19 +- .../Source/XlsxFormat/Drawing/Drawing.h | 2 +- 31 files changed, 644 insertions(+), 141 deletions(-) create mode 100644 ASCOfficeDocxFile2/BinWriter/BinWriters.cpp create mode 100644 ASCOfficePPTXFile/PPTXFormat/Logic/Runs/MathParaWrapper.cpp create mode 100644 ASCOfficePPTXFile/PPTXFormat/Logic/Runs/MathParaWrapper.h diff --git a/ASCOfficeDocxFile2/BinReader/FileWriter.h b/ASCOfficeDocxFile2/BinReader/FileWriter.h index e5ead3db05..12f8800b92 100644 --- a/ASCOfficeDocxFile2/BinReader/FileWriter.h +++ b/ASCOfficeDocxFile2/BinReader/FileWriter.h @@ -76,9 +76,9 @@ namespace Writers int m_nDocPrIndex; BinDocxRW::CComments* m_pComments; public: - FileWriter(CString sDirOutput,CString sFontDir, int nVersion, bool bSaveChartAsImg, NSBinPptxRW::CDrawingConverter* pDrawingConverter, CString sThemePath): + FileWriter(CString sDirOutput,CString sFontDir, bool bNoFontDir, int nVersion, bool bSaveChartAsImg, NSBinPptxRW::CDrawingConverter* pDrawingConverter, CString sThemePath): m_pDrawingConverter(pDrawingConverter),m_sThemePath(sThemePath),m_bSaveChartAsImg(bSaveChartAsImg), - m_oContentTypesWriter(sDirOutput), m_oFontTableWriter(sDirOutput, sFontDir), + m_oContentTypesWriter(sDirOutput), m_oFontTableWriter(sDirOutput, sFontDir, bNoFontDir), m_oHeaderFooterWriter(sDirOutput, m_oContentTypesWriter), m_oFootnotesWriter(sDirOutput, m_oContentTypesWriter), m_oEndnotesWriter(sDirOutput, m_oContentTypesWriter), diff --git a/ASCOfficeDocxFile2/BinReader/Readers.h b/ASCOfficeDocxFile2/BinReader/Readers.h index 0a0c4909ba..14fb43ae4b 100644 --- a/ASCOfficeDocxFile2/BinReader/Readers.h +++ b/ASCOfficeDocxFile2/BinReader/Readers.h @@ -5402,6 +5402,17 @@ public: res = Read1(length, &Binary_DocumentTableReader::ReadMathMRPr, this, poResult); GetRunStringWriter().WriteString(CString(_T(""))); } + else if ( c_oSer_OMathContentType::ARPr == type ) + { + PPTX::Logic::RunProperties rPr; + m_oBufferedStream.Skip(1);//skip type + rPr.fromPPTY(&m_oBufferedStream); + rPr.m_name = L"a:rPr"; + //todo use one writer + NSBinPptxRW::CXmlWriter oWriter; + rPr.toXmlWriter(&oWriter); + GetRunStringWriter().WriteString(oWriter.GetXmlString()); + } else if (c_oSer_OMathContentType::pagebreak == type) { GetRunStringWriter().WriteString(CString(_T(""))); diff --git a/ASCOfficeDocxFile2/BinReader/fontTableWriter.h b/ASCOfficeDocxFile2/BinReader/fontTableWriter.h index 76f992ee00..5f7c45db18 100644 --- a/ASCOfficeDocxFile2/BinReader/fontTableWriter.h +++ b/ASCOfficeDocxFile2/BinReader/fontTableWriter.h @@ -49,19 +49,23 @@ namespace Writers public: std::map m_mapFonts; public: - FontTableWriter(CString sDir, CString sFontDir):m_sDir(sDir) + FontTableWriter(CString sDir, CString sFontDir, bool bNoFontDir):m_sDir(sDir) { - if(sFontDir.IsEmpty()) - m_oApplicationFonts.Initialize(); - else - m_oApplicationFonts.InitializeFromFolder(string2std_string(sFontDir)); - CFontList* pFontList = m_oApplicationFonts.GetList(); - if(NULL != pFontList) + m_pFontManager = NULL; + if(!bNoFontDir) { - std::wstring sDefaultFont(_T("Arial")); - pFontList->SetDefaultFont(sDefaultFont); + if(sFontDir.IsEmpty()) + m_oApplicationFonts.Initialize(); + else + m_oApplicationFonts.InitializeFromFolder(string2std_string(sFontDir)); + CFontList* pFontList = m_oApplicationFonts.GetList(); + if(NULL != pFontList) + { + std::wstring sDefaultFont(_T("Arial")); + pFontList->SetDefaultFont(sDefaultFont); + } + m_pFontManager = m_oApplicationFonts.GenerateFontManager(); } - m_pFontManager = m_oApplicationFonts.GenerateFontManager(); } ~FontTableWriter() { diff --git a/ASCOfficeDocxFile2/BinWriter/BinReaderWriterDefines.h b/ASCOfficeDocxFile2/BinWriter/BinReaderWriterDefines.h index a6828999b7..49d51fe493 100644 --- a/ASCOfficeDocxFile2/BinWriter/BinReaderWriterDefines.h +++ b/ASCOfficeDocxFile2/BinWriter/BinReaderWriterDefines.h @@ -123,7 +123,7 @@ const double g_dKoef_mm_to_emu = 36000; const double g_dKoef_mm_to_eightpoint = 8 * g_dKoef_mm_to_pt; const double g_dKoef_mm_to_hps = 2 * g_dKoef_mm_to_pt; -const static TCHAR* g_sFormatSignature = _T("DOCY"); +const static wchar_t* g_sFormatSignature = L"DOCY"; const int g_nFormatVersion = 5; extern int g_nCurFormatVersion; namespace c_oAscWrapStyle{enum c_oSerFormat @@ -865,7 +865,8 @@ extern int g_nCurFormatVersion; Run = 61, Ins = 62, Del = 63, - columnbreak = 64 + columnbreak = 64, + ARPr = 65 };} namespace c_oSer_FramePrType{ enum c_oSer_FramePrType { diff --git a/ASCOfficeDocxFile2/BinWriter/BinWriters.cpp b/ASCOfficeDocxFile2/BinWriter/BinWriters.cpp new file mode 100644 index 0000000000..2942d3cee3 --- /dev/null +++ b/ASCOfficeDocxFile2/BinWriter/BinWriters.cpp @@ -0,0 +1,94 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2016 + * + * This program is a free software product. You can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License (AGPL) + * version 3 as published by the Free Software Foundation. In accordance with + * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect + * that Ascensio System SIA expressly excludes the warranty of non-infringement + * of any third-party rights. + * + * This program is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For + * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html + * + * You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia, + * EU, LV-1021. + * + * The interactive user interfaces in modified source and object code versions + * of the Program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU AGPL version 3. + * + * Pursuant to Section 7(b) of the License you must retain the original Product + * logo when distributing the program. Pursuant to Section 7(e) we decline to + * grant you any rights under trademark law for use of our trademarks. + * + * All the Product's GUI elements, including illustrations and icon sets, as + * well as technical writing content are licensed under the terms of the + * Creative Commons Attribution-ShareAlike 4.0 International. See the License + * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode + * + */ + +#include "BinWriters.h" + +namespace BinDocxRW +{ + BinaryHeaderFooterTableWriter::BinaryHeaderFooterTableWriter(ParamsWriter& oParamsWriter, OOX::IFileContainer* oDocumentRels, std::map* mapIgnoreComments): + m_oBcw(oParamsWriter), m_oParamsWriter(oParamsWriter), m_poTheme(oParamsWriter.m_poTheme), m_oFontProcessor(*oParamsWriter.m_pFontProcessor), m_oSettings(oParamsWriter.m_oSettings),m_pOfficeDrawingConverter(oParamsWriter.m_pOfficeDrawingConverter), m_oDocumentRels(oDocumentRels),m_mapIgnoreComments(mapIgnoreComments) + { + }; + void BinaryHeaderFooterTableWriter::Write() + { + int nStart = m_oBcw.WriteItemWithLengthStart(); + int nCurPos = 0; + //Header + if(m_aHeaders.size() > 0) + { + nCurPos = m_oBcw.WriteItemStart(c_oSerHdrFtrTypes::Header); + WriteHdrFtrContent(m_aHeaders, m_aHeaderTypes, m_aHeaderSectPrs, true); + m_oBcw.WriteItemEnd(nCurPos); + } + //Footer + if(m_aFooters.size() > 0) + { + nCurPos = m_oBcw.WriteItemStart(c_oSerHdrFtrTypes::Footer); + WriteHdrFtrContent(m_aFooters, m_aFooterTypes, m_aFooterSectPrs, false); + m_oBcw.WriteItemEnd(nCurPos); + } + m_oBcw.WriteItemWithLengthEnd(nStart); + }; + void BinaryHeaderFooterTableWriter::WriteHdrFtrContent(std::vector& aHdrFtrs, std::vector& aHdrFtrTypes, std::vector& aHdrSectPrs, bool bHdr) + { + int nCurPos = 0; + for(int i = 0, length = aHdrFtrs.size(); i < length; ++i) + { + OOX::CHdrFtr* pHdrFtr = aHdrFtrs[i]; + SimpleTypes::EHdrFtr eType = aHdrFtrTypes[i]; + OOX::Logic::CSectionProperty* pSectPr = aHdrSectPrs[i]; + BYTE byteHdrFtrType = c_oSerHdrFtrTypes::HdrFtr_Odd; + switch(eType) + { + case SimpleTypes::hdrftrFirst: byteHdrFtrType = c_oSerHdrFtrTypes::HdrFtr_First;break; + case SimpleTypes::hdrftrEven: byteHdrFtrType = c_oSerHdrFtrTypes::HdrFtr_Even;break; + default: byteHdrFtrType = c_oSerHdrFtrTypes::HdrFtr_Odd;break; + } + nCurPos = m_oBcw.WriteItemStart(byteHdrFtrType); + WriteHdrFtrItem(pSectPr, pHdrFtr, bHdr); + m_oBcw.WriteItemEnd(nCurPos); + } + }; + void BinaryHeaderFooterTableWriter::WriteHdrFtrItem(OOX::Logic::CSectionProperty* pSectPr, OOX::CHdrFtr* pHdrFtr, bool bHdr) + { + int nCurPos = 0; + //Content + ParamsDocumentWriter oParamsDocumentWriter(pHdrFtr, pHdrFtr->m_oReadPath.GetPath()); + m_oParamsWriter.m_pCurRels = oParamsDocumentWriter.m_pRels; + m_oParamsWriter.m_sCurDocumentPath = oParamsDocumentWriter.m_sDocumentPath; + BinaryDocumentTableWriter oBinaryDocumentTableWriter(m_oParamsWriter, oParamsDocumentWriter, m_mapIgnoreComments, NULL); + oBinaryDocumentTableWriter.prepareOfficeDrawingConverter(m_pOfficeDrawingConverter, oParamsDocumentWriter.m_sDocumentPath, pHdrFtr->m_arrShapeTypes); + nCurPos = m_oBcw.WriteItemStart(c_oSerHdrFtrTypes::HdrFtr_Content); + oBinaryDocumentTableWriter.WriteDocumentContent(pHdrFtr->m_arrItems); + m_oBcw.WriteItemEnd(nCurPos); + }; +} diff --git a/ASCOfficeDocxFile2/BinWriter/BinWriters.h b/ASCOfficeDocxFile2/BinWriter/BinWriters.h index a8d3b22bdd..b91b30d901 100644 --- a/ASCOfficeDocxFile2/BinWriter/BinWriters.h +++ b/ASCOfficeDocxFile2/BinWriter/BinWriters.h @@ -3713,6 +3713,12 @@ namespace BinDocxRW brPrs.Write_rPr(pMRun->m_oRPr.get()); m_oBcw.WriteItemEnd(nCurPos2); } + if ( pMRun->m_oARPr.IsInit() ) + { + int nCurPos2 = m_oBcw.WriteItemStart(c_oSer_OMathContentType::ARPr); + m_oBcw.m_oStream.WriteRecord2(0, pMRun->m_oARPr); + m_oBcw.WriteItemEnd(nCurPos2); + } if ( pMRun->m_oMText.IsInit() ) WriteMathText(pMRun->m_oMText.get()); @@ -6383,63 +6389,6 @@ namespace BinDocxRW RELEASEOBJECT(pTcPr); }; }; - BinaryHeaderFooterTableWriter::BinaryHeaderFooterTableWriter(ParamsWriter& oParamsWriter, OOX::IFileContainer* oDocumentRels, std::map* mapIgnoreComments): - m_oBcw(oParamsWriter), m_oParamsWriter(oParamsWriter), m_poTheme(oParamsWriter.m_poTheme), m_oFontProcessor(*oParamsWriter.m_pFontProcessor), m_oSettings(oParamsWriter.m_oSettings),m_pOfficeDrawingConverter(oParamsWriter.m_pOfficeDrawingConverter), m_oDocumentRels(oDocumentRels),m_mapIgnoreComments(mapIgnoreComments) - { - }; - void BinaryHeaderFooterTableWriter::Write() - { - int nStart = m_oBcw.WriteItemWithLengthStart(); - int nCurPos = 0; - //Header - if(m_aHeaders.size() > 0) - { - nCurPos = m_oBcw.WriteItemStart(c_oSerHdrFtrTypes::Header); - WriteHdrFtrContent(m_aHeaders, m_aHeaderTypes, m_aHeaderSectPrs, true); - m_oBcw.WriteItemEnd(nCurPos); - } - //Footer - if(m_aFooters.size() > 0) - { - nCurPos = m_oBcw.WriteItemStart(c_oSerHdrFtrTypes::Footer); - WriteHdrFtrContent(m_aFooters, m_aFooterTypes, m_aFooterSectPrs, false); - m_oBcw.WriteItemEnd(nCurPos); - } - m_oBcw.WriteItemWithLengthEnd(nStart); - }; - void BinaryHeaderFooterTableWriter::WriteHdrFtrContent(std::vector& aHdrFtrs, std::vector& aHdrFtrTypes, std::vector& aHdrSectPrs, bool bHdr) - { - int nCurPos = 0; - for(int i = 0, length = aHdrFtrs.size(); i < length; ++i) - { - OOX::CHdrFtr* pHdrFtr = aHdrFtrs[i]; - SimpleTypes::EHdrFtr eType = aHdrFtrTypes[i]; - OOX::Logic::CSectionProperty* pSectPr = aHdrSectPrs[i]; - BYTE byteHdrFtrType = c_oSerHdrFtrTypes::HdrFtr_Odd; - switch(eType) - { - case SimpleTypes::hdrftrFirst: byteHdrFtrType = c_oSerHdrFtrTypes::HdrFtr_First;break; - case SimpleTypes::hdrftrEven: byteHdrFtrType = c_oSerHdrFtrTypes::HdrFtr_Even;break; - default: byteHdrFtrType = c_oSerHdrFtrTypes::HdrFtr_Odd;break; - } - nCurPos = m_oBcw.WriteItemStart(byteHdrFtrType); - WriteHdrFtrItem(pSectPr, pHdrFtr, bHdr); - m_oBcw.WriteItemEnd(nCurPos); - } - }; - void BinaryHeaderFooterTableWriter::WriteHdrFtrItem(OOX::Logic::CSectionProperty* pSectPr, OOX::CHdrFtr* pHdrFtr, bool bHdr) - { - int nCurPos = 0; - //Content - ParamsDocumentWriter oParamsDocumentWriter(pHdrFtr, pHdrFtr->m_oReadPath.GetPath()); - m_oParamsWriter.m_pCurRels = oParamsDocumentWriter.m_pRels; - m_oParamsWriter.m_sCurDocumentPath = oParamsDocumentWriter.m_sDocumentPath; - BinaryDocumentTableWriter oBinaryDocumentTableWriter(m_oParamsWriter, oParamsDocumentWriter, m_mapIgnoreComments, NULL); - oBinaryDocumentTableWriter.prepareOfficeDrawingConverter(m_pOfficeDrawingConverter, oParamsDocumentWriter.m_sDocumentPath, pHdrFtr->m_arrShapeTypes); - nCurPos = m_oBcw.WriteItemStart(c_oSerHdrFtrTypes::HdrFtr_Content); - oBinaryDocumentTableWriter.WriteDocumentContent(pHdrFtr->m_arrItems); - m_oBcw.WriteItemEnd(nCurPos); - }; class BinaryCommentsTableWriter { class CCommentWriteTemp diff --git a/ASCOfficeDocxFile2/DocWrapper/DocxSerializer.cpp b/ASCOfficeDocxFile2/DocWrapper/DocxSerializer.cpp index a3a3c2e296..eefecb0e4f 100644 --- a/ASCOfficeDocxFile2/DocWrapper/DocxSerializer.cpp +++ b/ASCOfficeDocxFile2/DocWrapper/DocxSerializer.cpp @@ -43,7 +43,7 @@ int BinDocxRW::g_nCurFormatVersion = 0; BinDocxRW::CDocxSerializer::CDocxSerializer() { - m_oBinaryFileWriter = NULL; + m_pParamsWriter = NULL; m_pCurFileWriter = NULL; m_bIsNoBase64Save = false; m_bSaveChartAsImg = false; @@ -136,10 +136,10 @@ bool BinDocxRW::CDocxSerializer::saveToFile(const CString& sSrcFileName, const C oDrawingConverter.SetMainDocument(this); oDrawingConverter.SetMediaDstPath(pathMedia.GetPath()); - ParamsWriter oParamsWriter(&oBufferedStream, &fp, &oDrawingConverter, pEmbeddedFontsManager); + m_pParamsWriter = new ParamsWriter(&oBufferedStream, &fp, &oDrawingConverter, pEmbeddedFontsManager); - m_oBinaryFileWriter = new BinaryFileWriter(oParamsWriter); - m_oBinaryFileWriter->intoBindoc(sDstPath); + BinaryFileWriter oBinaryFileWriter(*m_pParamsWriter); + oBinaryFileWriter.intoBindoc(sDstPath); BYTE* pbBinBuffer = oBufferedStream.GetBuffer(); int nBinBufferLen = oBufferedStream.GetPosition(); @@ -159,13 +159,13 @@ bool BinDocxRW::CDocxSerializer::saveToFile(const CString& sSrcFileName, const C { NSFile::CFileBinary oFile; oFile.CreateFileW(string2std_string(sSrcFileName)); - oFile.WriteStringUTF8(string2std_string(m_oBinaryFileWriter->WriteFileHeader(nBinBufferLen))); + oFile.WriteStringUTF8(string2std_string(oBinaryFileWriter.WriteFileHeader(nBinBufferLen))); oFile.WriteFile(pbBase64Buffer, nBase64BufferLen); oFile.CloseFile(); } RELEASEARRAYOBJECTS(pbBase64Buffer); } - RELEASEOBJECT(m_oBinaryFileWriter); + RELEASEOBJECT(m_pParamsWriter); RELEASEOBJECT(pFontPicker); return true; } @@ -283,7 +283,7 @@ bool BinDocxRW::CDocxSerializer::loadFromFile(const CString& sSrcFileName, const oDrawingConverter.SetMainDocument(this); oDrawingConverter.SetMediaDstPath(sMediaPath); oDrawingConverter.SetEmbedDstPath(sEmbedPath); - m_pCurFileWriter = new Writers::FileWriter(sDstPath, m_sFontDir, nVersion, m_bSaveChartAsImg, &oDrawingConverter, sThemePath); + m_pCurFileWriter = new Writers::FileWriter(sDstPath, m_sFontDir, false, nVersion, m_bSaveChartAsImg, &oDrawingConverter, sThemePath); //папка с картинками std::wstring strFileInDir = NSSystemPath::GetDirectoryName(string2std_string(sSrcFileName)); @@ -380,7 +380,7 @@ bool BinDocxRW::CDocxSerializer::getXmlContent(NSBinPptxRW::CBinaryFileReader& o } bool BinDocxRW::CDocxSerializer::getBinaryContent(const CString& bsTxContent, NSBinPptxRW::CBinaryFileWriter& oBufferedStream, long& lDataSize) { - if(NULL == m_oBinaryFileWriter) + if(NULL == m_pParamsWriter) return false; long nStartPos = oBufferedStream.GetPosition(); @@ -406,7 +406,7 @@ bool BinDocxRW::CDocxSerializer::getBinaryContent(const CString& bsTxContent, NS oReader.ReadNextNode();//w:txbxContent oSdtContent.fromXML(oReader); } - BinDocxRW::ParamsWriter& oParamsWriter = m_oBinaryFileWriter->m_oParamsWriter; + BinDocxRW::ParamsWriter& oParamsWriter = *m_pParamsWriter; NSBinPptxRW::CBinaryFileWriter* pBufferedStreamOld = oParamsWriter.m_pCBufferedStream; oParamsWriter.m_pCBufferedStream = &oBufferedStream; @@ -422,6 +422,62 @@ bool BinDocxRW::CDocxSerializer::getBinaryContent(const CString& bsTxContent, NS lDataSize = nEndPos - nStartPos; return true; } +bool BinDocxRW::CDocxSerializer::getBinaryContentElem(OOX::EElementType eElemType, void* pElem, NSBinPptxRW::CBinaryFileWriter& oBufferedStream, long& lDataSize) +{ + if(NULL == m_pParamsWriter) + return false; + long nStartPos = oBufferedStream.GetPosition(); + + BinDocxRW::ParamsWriter& oParamsWriter = *m_pParamsWriter; + NSBinPptxRW::CBinaryFileWriter* pBufferedStreamOld = oParamsWriter.m_pCBufferedStream; + oParamsWriter.m_pCBufferedStream = &oBufferedStream; + + BinDocxRW::BinaryCommonWriter oBinaryCommonWriter(oParamsWriter); + int nCurPos = oBinaryCommonWriter.WriteItemWithLengthStart(); + BinDocxRW::ParamsDocumentWriter oParams(oParamsWriter.m_pCurRels, oParamsWriter.m_sCurDocumentPath); + BinDocxRW::BinaryDocumentTableWriter oBinaryDocumentTableWriter(oParamsWriter, oParams, &oParamsWriter.m_mapIgnoreComments, NULL); + if(OOX::et_m_oMathPara == eElemType) + { + OOX::Logic::COMathPara* pMathPara = static_cast(pElem); + oBinaryDocumentTableWriter.WriteMathOMathPara(pMathPara->m_arrItems); + } + else if(OOX::et_m_oMath == eElemType) + { + OOX::Logic::COMath* pMath = static_cast(pElem); + oBinaryDocumentTableWriter.WriteMathArgNodes(pMath->m_arrItems); + } + oBinaryCommonWriter.WriteItemWithLengthEnd(nCurPos); + + oParamsWriter.m_pCBufferedStream = pBufferedStreamOld; + long nEndPos = oBufferedStream.GetPosition(); + lDataSize = nEndPos - nStartPos; + return true; +} + +bool BinDocxRW::CDocxSerializer::getXmlContentElem(OOX::EElementType eType, NSBinPptxRW::CBinaryFileReader& oBufferedStream, CString& sOutputXml) +{ + long nLength = oBufferedStream.GetLong(); + Writers::ContentWriter oTempContentWriter; + BinDocxRW::Binary_DocumentTableReader oBinary_DocumentTableReader(oBufferedStream, *m_pCurFileWriter, oTempContentWriter, m_pCurFileWriter->m_pComments); + + if(OOX::et_m_oMathPara == eType) + { + oTempContentWriter.m_oContent.WriteString(CString(_T(""))); + oBinary_DocumentTableReader.Read1(nLength, &BinDocxRW::Binary_DocumentTableReader::ReadMathOMathPara, &oBinary_DocumentTableReader, NULL); + oTempContentWriter.m_oContent.WriteString(CString(_T(""))); + } + else if(OOX::et_m_oMath == eType) + { + oTempContentWriter.m_oContent.WriteString(CString(_T(""))); + oBinary_DocumentTableReader.Read1(nLength, &BinDocxRW::Binary_DocumentTableReader::ReadMathArg, &oBinary_DocumentTableReader, NULL); + oTempContentWriter.m_oContent.WriteString(CString(_T(""))); + } + + + sOutputXml = oTempContentWriter.m_oContent.GetData(); + return true; +} + void BinDocxRW::CDocxSerializer::setFontDir(const CString& sFontDir) { m_sFontDir = sFontDir; diff --git a/ASCOfficeDocxFile2/DocWrapper/DocxSerializer.h b/ASCOfficeDocxFile2/DocWrapper/DocxSerializer.h index 1658e64e19..dc75ea19fe 100644 --- a/ASCOfficeDocxFile2/DocWrapper/DocxSerializer.h +++ b/ASCOfficeDocxFile2/DocWrapper/DocxSerializer.h @@ -38,6 +38,7 @@ #else #include "../../Common/DocxFormat/Source/Base/ASCString.h" #endif +#include "../../Common/DocxFormat/Source/DocxFormat/WritingElement.h" namespace Writers { @@ -51,14 +52,16 @@ namespace NSBinPptxRW namespace BinDocxRW { class BinaryFileWriter; + class ParamsWriter; + class CDocxSerializer { - private: + public: CString m_sFontDir; CString m_sEmbeddedFontsDir; bool m_bIsNoBase64Save; bool m_bSaveChartAsImg; - BinaryFileWriter* m_oBinaryFileWriter; + ParamsWriter* m_pParamsWriter; Writers::FileWriter* m_pCurFileWriter; public: CDocxSerializer(); @@ -73,6 +76,9 @@ namespace BinDocxRW bool getXmlContent(NSBinPptxRW::CBinaryFileReader& oBufferedStream, long lLength, CString& sOutputXml); bool getBinaryContent(const CString& bsTxContent, NSBinPptxRW::CBinaryFileWriter& oBufferedStream, long& lDataSize); + bool getBinaryContentElem(OOX::EElementType eElemType, void* pElem, NSBinPptxRW::CBinaryFileWriter& oBufferedStream, long& lDataSize); + bool getXmlContentElem(OOX::EElementType eType, NSBinPptxRW::CBinaryFileReader& oBufferedStream, CString& sOutputXml); + void setFontDir(const CString& sFontDir); void setEmbeddedFontsDir(const CString& sEmbeddedFontsDir); void setIsNoBase64Save(bool bIsNoBase64Save); diff --git a/ASCOfficeDocxFile2/Linux/ASCOfficeDocxFile2Lib.pro b/ASCOfficeDocxFile2/Linux/ASCOfficeDocxFile2Lib.pro index 453c19693d..c7425aa0cc 100644 --- a/ASCOfficeDocxFile2/Linux/ASCOfficeDocxFile2Lib.pro +++ b/ASCOfficeDocxFile2/Linux/ASCOfficeDocxFile2Lib.pro @@ -34,6 +34,7 @@ INCLUDEPATH += \ SOURCES += ../DocWrapper/DocxSerializer.cpp \ ../DocWrapper/FontProcessor.cpp \ ../DocWrapper/XlsxSerializer.cpp \ + ../BinWriter/BinWriters.cpp \ ../../XlsxSerializerCom/Common/Common.cpp \ ../../XlsxSerializerCom/Reader/ChartFromToBinary.cpp \ ../../XlsxSerializerCom/Reader/CommonWriter.cpp \ diff --git a/ASCOfficePPTXFile/Editor/BinReaderWriterDefines.h b/ASCOfficePPTXFile/Editor/BinReaderWriterDefines.h index 4bfe228406..c303163b46 100644 --- a/ASCOfficePPTXFile/Editor/BinReaderWriterDefines.h +++ b/ASCOfficePPTXFile/Editor/BinReaderWriterDefines.h @@ -173,6 +173,8 @@ namespace NSBinPptxRW #define PARRUN_TYPE_RUN 1 #define PARRUN_TYPE_FLD 2 #define PARRUN_TYPE_BR 3 +#define PARRUN_TYPE_MATH 4 +#define PARRUN_TYPE_MATHPARA 5 #define SPTREE_TYPE_NONE 0 #define SPTREE_TYPE_SHAPE 1 diff --git a/ASCOfficePPTXFile/PPTXFormat/Comments.h b/ASCOfficePPTXFile/PPTXFormat/Comments.h index e048f1f41a..f5fe8cdf82 100644 --- a/ASCOfficePPTXFile/PPTXFormat/Comments.h +++ b/ASCOfficePPTXFile/PPTXFormat/Comments.h @@ -356,6 +356,8 @@ namespace PPTX pWriter->WriteAttribute(_T("xmlns:a"), PPTX::g_Namespaces.a.m_strLink); pWriter->WriteAttribute(_T("xmlns:r"), PPTX::g_Namespaces.r.m_strLink); pWriter->WriteAttribute(_T("xmlns:p"), PPTX::g_Namespaces.p.m_strLink); + pWriter->WriteAttribute(_T("xmlns:m"), PPTX::g_Namespaces.m.m_strLink); + pWriter->WriteAttribute(_T("xmlns:w"), PPTX::g_Namespaces.w.m_strLink); pWriter->EndAttributes(); pWriter->WriteArray2(m_arComments); @@ -402,4 +404,4 @@ namespace PPTX }; } // namespace PPTX -#endif // PPTX_COMMENTS_COMMENTS_H_ \ No newline at end of file +#endif // PPTX_COMMENTS_COMMENTS_H_ diff --git a/ASCOfficePPTXFile/PPTXFormat/HandoutMaster.h b/ASCOfficePPTXFile/PPTXFormat/HandoutMaster.h index 503ad5c401..188f1e8aaf 100644 --- a/ASCOfficePPTXFile/PPTXFormat/HandoutMaster.h +++ b/ASCOfficePPTXFile/PPTXFormat/HandoutMaster.h @@ -81,6 +81,8 @@ namespace PPTX XmlUtils::CAttribute oAttr; oAttr.Write(_T("xmlns:a"), PPTX::g_Namespaces.a.m_strLink); oAttr.Write(_T("xmlns:r"), PPTX::g_Namespaces.r.m_strLink); + oAttr.Write(_T("xmlns:m"), PPTX::g_Namespaces.m.m_strLink); + oAttr.Write(_T("xmlns:w"), PPTX::g_Namespaces.w.m_strLink); XmlUtils::CNodeValue oValue; oValue.Write(cSld); @@ -116,4 +118,4 @@ namespace PPTX }; } // namespace PPTX -#endif // PPTX_SLIDES_HANDOUTMASTER_INCLUDE_H_ \ No newline at end of file +#endif // PPTX_SLIDES_HANDOUTMASTER_INCLUDE_H_ diff --git a/ASCOfficePPTXFile/PPTXFormat/Logic/Paragraph.h b/ASCOfficePPTXFile/PPTXFormat/Logic/Paragraph.h index c7f34388ec..0cbba05944 100644 --- a/ASCOfficePPTXFile/PPTXFormat/Logic/Paragraph.h +++ b/ASCOfficePPTXFile/PPTXFormat/Logic/Paragraph.h @@ -81,7 +81,7 @@ namespace PPTX pPr = oNode; else if (_T("endParaRPr") == strName) endParaRPr = oNode; - else if ((_T("r") == strName) || (_T("fld") == strName) || (_T("br") == strName)) + else if ((_T("r") == strName) || (_T("fld") == strName) || (_T("br") == strName) || (_T("m") == strName)) RunElems.push_back(RunElem(oNode)); } } @@ -273,6 +273,26 @@ namespace PPTX pReader->Seek(_end); break; } + case PARRUN_TYPE_MATH: + { + Logic::MathParaWrapper* pRun = new Logic::MathParaWrapper(); + pRun->fromPPTY(_type, pReader); + + RunElem elm; + RunElems.push_back(elm); + RunElems.back().InitRun(pRun); + break; + } + case PARRUN_TYPE_MATHPARA: + { + Logic::MathParaWrapper* pRun = new Logic::MathParaWrapper(); + pRun->fromPPTY(_type, pReader); + + RunElem elm; + RunElems.push_back(elm); + RunElems.back().InitRun(pRun); + break; + } default: break; } @@ -320,4 +340,4 @@ namespace PPTX } // namespace Logic } // namespace PPTX -#endif // PPTX_LOGIC_PARAGRAPH_INCLUDE_H \ No newline at end of file +#endif // PPTX_LOGIC_PARAGRAPH_INCLUDE_H diff --git a/ASCOfficePPTXFile/PPTXFormat/Logic/RunElem.h b/ASCOfficePPTXFile/PPTXFormat/Logic/RunElem.h index e91d6b91cd..2350b2027c 100644 --- a/ASCOfficePPTXFile/PPTXFormat/Logic/RunElem.h +++ b/ASCOfficePPTXFile/PPTXFormat/Logic/RunElem.h @@ -38,6 +38,7 @@ #include "Runs/Run.h" #include "Runs/Fld.h" #include "Runs/Br.h" +#include "Runs/MathParaWrapper.h" namespace PPTX { @@ -59,6 +60,8 @@ namespace PPTX Elem.reset(new Logic::Fld(node)); else if(name == _T("br")) Elem.reset(new Logic::Br(node)); + else if(name == _T("m")) + Elem.reset(new Logic::MathParaWrapper(node)); else Elem.reset(); } virtual CString toXML() const @@ -103,4 +106,4 @@ namespace PPTX } // namespace Logic } // namespace PPTX -#endif // PPTX_LOGIC_RUNELEM_INCLUDE_H \ No newline at end of file +#endif // PPTX_LOGIC_RUNELEM_INCLUDE_H diff --git a/ASCOfficePPTXFile/PPTXFormat/Logic/Runs/MathParaWrapper.cpp b/ASCOfficePPTXFile/PPTXFormat/Logic/Runs/MathParaWrapper.cpp new file mode 100644 index 0000000000..2ddda9986c --- /dev/null +++ b/ASCOfficePPTXFile/PPTXFormat/Logic/Runs/MathParaWrapper.cpp @@ -0,0 +1,194 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2016 + * + * This program is a free software product. You can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License (AGPL) + * version 3 as published by the Free Software Foundation. In accordance with + * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect + * that Ascensio System SIA expressly excludes the warranty of non-infringement + * of any third-party rights. + * + * This program is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For + * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html + * + * You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia, + * EU, LV-1021. + * + * The interactive user interfaces in modified source and object code versions + * of the Program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU AGPL version 3. + * + * Pursuant to Section 7(b) of the License you must retain the original Product + * logo when distributing the program. Pursuant to Section 7(e) we decline to + * grant you any rights under trademark law for use of our trademarks. + * + * All the Product's GUI elements, including illustrations and icon sets, as + * well as technical writing content are licensed under the terms of the + * Creative Commons Attribution-ShareAlike 4.0 International. See the License + * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode + * + */ +#include "MathParaWrapper.h" +#include "../../../Common/DocxFormat/Source/DocxFormat/Math/oMathPara.h" +#include "../../../ASCOfficeDocxFile2/BinWriter/BinWriters.h" +#include "../../../ASCOfficeDocxFile2/BinReader/FileWriter.h" + +namespace PPTX +{ + namespace Logic + { + MathParaWrapper& MathParaWrapper::operator=(const MathParaWrapper& oSrc) + { + //todo + parentFile = oSrc.parentFile; + parentElement = oSrc.parentElement; + + m_oMathPara = oSrc.m_oMathPara; + m_oMath = oSrc.m_oMath; + return *this; + } + void MathParaWrapper::fromXML(XmlUtils::CXmlNode& node) + { + CString sBegin(_T("")); + CString sEnd(_T("")); + CString sXml = sBegin + node.GetXml() + sEnd; + XmlUtils::CXmlLiteReader oReader; + oReader.FromString(sXml.GetBuffer()); + sXml.ReleaseBuffer(); + oReader.ReadNextNode();//root + oReader.ReadNextNode();//a14:m + oReader.ReadNextNode();//oMath oMathPara + CString strNameP = XmlUtils::GetNameNoNS(oReader.GetName()); + if(L"oMathPara" == strNameP) + { + m_oMathPara = oReader; + } + else if(L"oMath" == strNameP) + { + m_oMath = oReader; + } + + FillParentPointersForChilds(); + } + + CString MathParaWrapper::toXML() const + { + if(m_oMathPara.IsInit() || m_oMath.IsInit() || m_oXml.IsInit()) + { + CString sXml = L""; + if(m_oMathPara.IsInit()) + { + sXml += m_oMathPara->toXML(); + } + else if(m_oMath.IsInit()) + { + sXml += m_oMath->toXML(); + } + else + { + sXml += m_oXml.get(); + } + sXml += L""; + return sXml; + } + else + { + return L""; + } + } + + void MathParaWrapper::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + pWriter->WriteString(toXML()); + } + + void MathParaWrapper::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + int nRecordType; + void* pElem = NULL; + OOX::EElementType eElemType; + if(m_oMathPara.IsInit()) + { + nRecordType = PARRUN_TYPE_MATHPARA; + pElem = m_oMathPara.GetPointer(); + eElemType = m_oMathPara->getType(); + } + else if(m_oMath.IsInit()) + { + nRecordType = PARRUN_TYPE_MATH; + pElem = m_oMath.GetPointer(); + eElemType = m_oMath->getType(); + } + if(NULL != pElem) + { + pWriter->StartRecord(nRecordType); + long lDataSize = 0; + if(NULL != pWriter->m_pMainDocument) + { + pWriter->m_pMainDocument->getBinaryContentElem(eElemType, pElem, *pWriter, lDataSize); + } + else + { + BinDocxRW::CDocxSerializer oDocxSerializer; + NSBinPptxRW::CDrawingConverter oDrawingConverter; + NSBinPptxRW::CBinaryFileWriter* pOldWriter = oDrawingConverter.m_pBinaryWriter; + NSCommon::smart_ptr pOldRels = *oDrawingConverter.m_pBinaryWriter->m_pCommonRels; + oDrawingConverter.m_pBinaryWriter = pWriter; + + DocWrapper::FontProcessor fp; + BinDocxRW::ParamsWriter oParamsWriter(pWriter, &fp, &oDrawingConverter, NULL); + oDocxSerializer.m_pParamsWriter = &oParamsWriter; + oDocxSerializer.getBinaryContentElem(eElemType, pElem, *pWriter, lDataSize); + *oDrawingConverter.m_pBinaryWriter->m_pCommonRels = pOldRels; + oDrawingConverter.m_pBinaryWriter = pOldWriter; + } + + pWriter->EndRecord(); + } + } + + void MathParaWrapper::fromPPTY(BYTE type, NSBinPptxRW::CBinaryFileReader* pReader) + { + OOX::EElementType eType; + if(PARRUN_TYPE_MATHPARA == type) + { + eType = OOX::et_m_oMathPara; + } + else + { + eType = OOX::et_m_oMath; + } + LONG _end = pReader->GetPos() + pReader->GetLong() + 4; + CString sXml; + if(NULL != pReader->m_pMainDocument) + { + pReader->m_pMainDocument->getXmlContentElem(eType, *pReader, m_oXml.get()); + } + else + { + BinDocxRW::CDocxSerializer oDocxSerializer; + NSBinPptxRW::CDrawingConverter oDrawingConverter; + NSBinPptxRW::CImageManager2* pOldImageManager = oDrawingConverter.m_pImageManager; + NSBinPptxRW::CBinaryFileReader* pOldReader = oDrawingConverter.m_pReader; + oDrawingConverter.m_pImageManager = pReader->m_pRels->m_pManager; + oDrawingConverter.m_pReader = pReader; + + oDocxSerializer.m_pCurFileWriter = new Writers::FileWriter(L"", L"", true, BinDocxRW::g_nFormatVersion, false, &oDrawingConverter, L""); + oDocxSerializer.getXmlContentElem(eType, *pReader, sXml); + + oDrawingConverter.m_pReader = pOldReader; + oDrawingConverter.m_pImageManager = pOldImageManager; + RELEASEOBJECT(oDocxSerializer.m_pCurFileWriter); + } + m_oXml = sXml; + pReader->Seek(_end); + } + + CString MathParaWrapper::GetText() const + { + //todo + return _T(""); + } + } // namespace Logic +} // namespace PPTX diff --git a/ASCOfficePPTXFile/PPTXFormat/Logic/Runs/MathParaWrapper.h b/ASCOfficePPTXFile/PPTXFormat/Logic/Runs/MathParaWrapper.h new file mode 100644 index 0000000000..04c8b7b2a1 --- /dev/null +++ b/ASCOfficePPTXFile/PPTXFormat/Logic/Runs/MathParaWrapper.h @@ -0,0 +1,77 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2016 + * + * This program is a free software product. You can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License (AGPL) + * version 3 as published by the Free Software Foundation. In accordance with + * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect + * that Ascensio System SIA expressly excludes the warranty of non-infringement + * of any third-party rights. + * + * This program is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For + * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html + * + * You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia, + * EU, LV-1021. + * + * The interactive user interfaces in modified source and object code versions + * of the Program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU AGPL version 3. + * + * Pursuant to Section 7(b) of the License you must retain the original Product + * logo when distributing the program. Pursuant to Section 7(e) we decline to + * grant you any rights under trademark law for use of our trademarks. + * + * All the Product's GUI elements, including illustrations and icon sets, as + * well as technical writing content are licensed under the terms of the + * Creative Commons Attribution-ShareAlike 4.0 International. See the License + * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode + * + */ +#pragma once +#ifndef PPTX_LOGIC_MATHPARAWRAPPER_INCLUDE_H_ +#define PPTX_LOGIC_MATHPARAWRAPPER_INCLUDE_H_ + +#include "RunBase.h" + +namespace OOX +{ + namespace Logic + { + class COMathPara; + class COMath; + } +} +namespace PPTX +{ + namespace Logic + { + class MathParaWrapper : public RunBase + { + public: + PPTX_LOGIC_BASE(MathParaWrapper) + + MathParaWrapper& operator=(const MathParaWrapper& oSrc); + + public: + virtual void fromXML(XmlUtils::CXmlNode& node); + + virtual CString toXML() const; + + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; + + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; + virtual void fromPPTY(BYTE type, NSBinPptxRW::CBinaryFileReader* pReader); + virtual CString GetText() const; + public: + nullable m_oMathPara; + nullable m_oMath; + nullable_string m_oXml; + protected: + virtual void FillParentPointersForChilds(){} + }; + } // namespace Logic +} // namespace PPTX + +#endif // PPTX_LOGIC_MATHPARAWRAPPER_INCLUDE_H_ diff --git a/ASCOfficePPTXFile/PPTXFormat/Logic/SpTreeElem.cpp b/ASCOfficePPTXFile/PPTXFormat/Logic/SpTreeElem.cpp index 117ddae67f..531d4ed1fe 100644 --- a/ASCOfficePPTXFile/PPTXFormat/Logic/SpTreeElem.cpp +++ b/ASCOfficePPTXFile/PPTXFormat/Logic/SpTreeElem.cpp @@ -252,30 +252,32 @@ namespace PPTX m_elem.reset(new Logic::GraphicFrame(node)); else if (name == _T("AlternateContent")) { - XmlUtils::CXmlNode oNodeFall; - if (node.GetNode(_T("mc:Fallback"), oNodeFall)) + bool isEmpty = true; + XmlUtils::CXmlNode oNodeChoice; + if (node.GetNode(_T("mc:Choice"), oNodeChoice)) { + XmlUtils::CXmlNode oNodeFall; XmlUtils::CXmlNodes oNodesC; - if (oNodeFall.GetNodes(_T("*"), oNodesC)) + CString sRequires; + //todo better check (a14 can be math, slicer) + if(oNodeChoice.GetAttributeIfExist(L"Requires", sRequires) && L"a14" == sRequires) { - if (1 == oNodesC.GetCount()) - { - XmlUtils::CXmlNode oNodeC; - oNodesC.GetAt(0, oNodeC); - - fromXML(oNodeC); - } - else - { - m_elem.reset(); - } + oNodeChoice.GetNodes(_T("*"), oNodesC); } - else + else if (node.GetNode(_T("mc:Fallback"), oNodeFall)) { - m_elem.reset(); + oNodeFall.GetNodes(_T("*"), oNodesC); + } + if (1 == oNodesC.GetCount()) + { + XmlUtils::CXmlNode oNodeC; + oNodesC.GetAt(0, oNodeC); + + fromXML(oNodeC); + isEmpty = false; } } - else + if(isEmpty) { m_elem.reset(); } diff --git a/ASCOfficePPTXFile/PPTXFormat/NotesMaster.h b/ASCOfficePPTXFile/PPTXFormat/NotesMaster.h index 1db2798001..7d4c351973 100644 --- a/ASCOfficePPTXFile/PPTXFormat/NotesMaster.h +++ b/ASCOfficePPTXFile/PPTXFormat/NotesMaster.h @@ -84,6 +84,8 @@ namespace PPTX XmlUtils::CAttribute oAttr; oAttr.Write(_T("xmlns:a"), PPTX::g_Namespaces.a.m_strLink); oAttr.Write(_T("xmlns:r"), PPTX::g_Namespaces.r.m_strLink); + oAttr.Write(_T("xmlns:m"), PPTX::g_Namespaces.m.m_strLink); + oAttr.Write(_T("xmlns:w"), PPTX::g_Namespaces.w.m_strLink); XmlUtils::CNodeValue oValue; oValue.Write(cSld); @@ -142,6 +144,8 @@ namespace PPTX pWriter->StartAttributes(); pWriter->WriteAttribute(_T("xmlns:a"), PPTX::g_Namespaces.a.m_strLink); pWriter->WriteAttribute(_T("xmlns:r"), PPTX::g_Namespaces.r.m_strLink); + pWriter->WriteAttribute(_T("xmlns:m"), PPTX::g_Namespaces.m.m_strLink); + pWriter->WriteAttribute(_T("xmlns:w"), PPTX::g_Namespaces.w.m_strLink); pWriter->EndAttributes(); cSld.toXmlWriter(pWriter); diff --git a/ASCOfficePPTXFile/PPTXFormat/NotesSlide.h b/ASCOfficePPTXFile/PPTXFormat/NotesSlide.h index 7aeb118a94..b8cbc99105 100644 --- a/ASCOfficePPTXFile/PPTXFormat/NotesSlide.h +++ b/ASCOfficePPTXFile/PPTXFormat/NotesSlide.h @@ -79,6 +79,8 @@ namespace PPTX oAttr.Write(_T("xmlns:a"), PPTX::g_Namespaces.a.m_strLink); oAttr.Write(_T("xmlns:r"), PPTX::g_Namespaces.r.m_strLink); oAttr.Write(_T("xmlns:p"), PPTX::g_Namespaces.p.m_strLink); + oAttr.Write(_T("xmlns:m"), PPTX::g_Namespaces.m.m_strLink); + oAttr.Write(_T("xmlns:w"), PPTX::g_Namespaces.w.m_strLink); oAttr.Write(_T("showMasterPhAnim"), showMasterPhAnim); oAttr.Write(_T("showMasterSp"), showMasterSp); @@ -131,6 +133,8 @@ namespace PPTX pWriter->WriteAttribute(_T("xmlns:a"), PPTX::g_Namespaces.a.m_strLink); pWriter->WriteAttribute(_T("xmlns:r"), PPTX::g_Namespaces.r.m_strLink); pWriter->WriteAttribute(_T("xmlns:p"), PPTX::g_Namespaces.p.m_strLink); + pWriter->WriteAttribute(_T("xmlns:m"), PPTX::g_Namespaces.m.m_strLink); + pWriter->WriteAttribute(_T("xmlns:w"), PPTX::g_Namespaces.w.m_strLink); pWriter->WriteAttribute(_T("showMasterPhAnim"), showMasterPhAnim); pWriter->WriteAttribute(_T("showMasterSp"), showMasterSp); pWriter->EndAttributes(); @@ -196,4 +200,4 @@ namespace PPTX }; } // namespace PPTX -#endif // PPTX_SLIDES_NOTESSLIDE_INCLUDE_H_ \ No newline at end of file +#endif // PPTX_SLIDES_NOTESSLIDE_INCLUDE_H_ diff --git a/ASCOfficePPTXFile/PPTXFormat/Presentation.h b/ASCOfficePPTXFile/PPTXFormat/Presentation.h index 6f7ba15d3e..1202214318 100644 --- a/ASCOfficePPTXFile/PPTXFormat/Presentation.h +++ b/ASCOfficePPTXFile/PPTXFormat/Presentation.h @@ -176,6 +176,8 @@ namespace PPTX oAttr.Write(_T("xmlns:a"), PPTX::g_Namespaces.a.m_strLink); oAttr.Write(_T("xmlns:r"), PPTX::g_Namespaces.r.m_strLink); oAttr.Write(_T("xmlns:p"), PPTX::g_Namespaces.p.m_strLink); + oAttr.Write(_T("xmlns:m"), PPTX::g_Namespaces.m.m_strLink); + oAttr.Write(_T("xmlns:w"), PPTX::g_Namespaces.w.m_strLink); oAttr.Write(_T("autoCompressPictures"), attrAutoCompressPictures); oAttr.Write(_T("bookmarkIdSeed"), attrBookmarkIdSeed); @@ -372,6 +374,8 @@ namespace PPTX pWriter->WriteAttribute(_T("xmlns:a"), PPTX::g_Namespaces.a.m_strLink); pWriter->WriteAttribute(_T("xmlns:r"), PPTX::g_Namespaces.r.m_strLink); pWriter->WriteAttribute(_T("xmlns:p"), PPTX::g_Namespaces.p.m_strLink); + pWriter->WriteAttribute(_T("xmlns:m"), PPTX::g_Namespaces.m.m_strLink); + pWriter->WriteAttribute(_T("xmlns:w"), PPTX::g_Namespaces.w.m_strLink); pWriter->WriteAttribute(_T("autoCompressPictures"), attrAutoCompressPictures); pWriter->WriteAttribute(_T("bookmarkIdSeed"), attrBookmarkIdSeed); @@ -483,4 +487,4 @@ namespace PPTX }; } // namespace PPTX -#endif // PPTX_PRESENTATION_FILE_INCLUDE_H_ \ No newline at end of file +#endif // PPTX_PRESENTATION_FILE_INCLUDE_H_ diff --git a/ASCOfficePPTXFile/PPTXFormat/Slide.h b/ASCOfficePPTXFile/PPTXFormat/Slide.h index ed8e4e1aba..bc2f146227 100644 --- a/ASCOfficePPTXFile/PPTXFormat/Slide.h +++ b/ASCOfficePPTXFile/PPTXFormat/Slide.h @@ -135,6 +135,8 @@ namespace PPTX oAttr.Write(_T("xmlns:a"), PPTX::g_Namespaces.a.m_strLink); oAttr.Write(_T("xmlns:r"), PPTX::g_Namespaces.r.m_strLink); oAttr.Write(_T("xmlns:p"), PPTX::g_Namespaces.p.m_strLink); + oAttr.Write(_T("xmlns:m"), PPTX::g_Namespaces.m.m_strLink); + oAttr.Write(_T("xmlns:w"), PPTX::g_Namespaces.w.m_strLink); oAttr.Write(_T("show"), show); oAttr.Write(_T("showMasterPhAnim"), showMasterPhAnim); oAttr.Write(_T("showMasterSp"), showMasterSp); @@ -295,6 +297,8 @@ namespace PPTX pWriter->WriteAttribute(_T("xmlns:a"), PPTX::g_Namespaces.a.m_strLink); pWriter->WriteAttribute(_T("xmlns:r"), PPTX::g_Namespaces.r.m_strLink); pWriter->WriteAttribute(_T("xmlns:p"), PPTX::g_Namespaces.p.m_strLink); + pWriter->WriteAttribute(_T("xmlns:m"), PPTX::g_Namespaces.m.m_strLink); + pWriter->WriteAttribute(_T("xmlns:w"), PPTX::g_Namespaces.w.m_strLink); pWriter->WriteAttribute(_T("showMasterPhAnim"), showMasterPhAnim); pWriter->WriteAttribute(_T("showMasterSp"), showMasterSp); diff --git a/ASCOfficePPTXFile/PPTXFormat/SlideLayout.h b/ASCOfficePPTXFile/PPTXFormat/SlideLayout.h index 172155f490..df30a18f63 100644 --- a/ASCOfficePPTXFile/PPTXFormat/SlideLayout.h +++ b/ASCOfficePPTXFile/PPTXFormat/SlideLayout.h @@ -115,6 +115,8 @@ namespace PPTX oAttr.Write(_T("xmlns:a"), PPTX::g_Namespaces.a.m_strLink); oAttr.Write(_T("xmlns:r"), PPTX::g_Namespaces.r.m_strLink); oAttr.Write(_T("xmlns:p"), PPTX::g_Namespaces.p.m_strLink); + oAttr.Write(_T("xmlns:m"), PPTX::g_Namespaces.m.m_strLink); + oAttr.Write(_T("xmlns:w"), PPTX::g_Namespaces.w.m_strLink); oAttr.Write(_T("matchingName"), matchingName); oAttr.Write(_T("preserve"), preserve); @@ -424,6 +426,8 @@ namespace PPTX pWriter->WriteAttribute(_T("xmlns:a"), PPTX::g_Namespaces.a.m_strLink); pWriter->WriteAttribute(_T("xmlns:r"), PPTX::g_Namespaces.r.m_strLink); pWriter->WriteAttribute(_T("xmlns:p"), PPTX::g_Namespaces.p.m_strLink); + pWriter->WriteAttribute(_T("xmlns:m"), PPTX::g_Namespaces.m.m_strLink); + pWriter->WriteAttribute(_T("xmlns:w"), PPTX::g_Namespaces.w.m_strLink); pWriter->WriteAttribute(_T("matchingName"), matchingName); pWriter->WriteAttribute(_T("preserve"), preserve); diff --git a/ASCOfficePPTXFile/PPTXFormat/SlideMaster.h b/ASCOfficePPTXFile/PPTXFormat/SlideMaster.h index 321bcbe577..afa76d2e8b 100644 --- a/ASCOfficePPTXFile/PPTXFormat/SlideMaster.h +++ b/ASCOfficePPTXFile/PPTXFormat/SlideMaster.h @@ -121,6 +121,8 @@ namespace PPTX oAttr.Write(_T("xmlns:p"), PPTX::g_Namespaces.p.m_strLink); oAttr.Write(_T("xmlns:a"), PPTX::g_Namespaces.a.m_strLink); oAttr.Write(_T("xmlns:r"), PPTX::g_Namespaces.r.m_strLink); + oAttr.Write(_T("xmlns:m"), PPTX::g_Namespaces.m.m_strLink); + oAttr.Write(_T("xmlns:w"), PPTX::g_Namespaces.w.m_strLink); oAttr.Write(_T("preserve"), preserve); XmlUtils::CNodeValue oValue; @@ -412,6 +414,8 @@ namespace PPTX pWriter->WriteAttribute(_T("xmlns:a"), PPTX::g_Namespaces.a.m_strLink); pWriter->WriteAttribute(_T("xmlns:r"), PPTX::g_Namespaces.r.m_strLink); pWriter->WriteAttribute(_T("xmlns:p"), PPTX::g_Namespaces.p.m_strLink); + pWriter->WriteAttribute(_T("xmlns:m"), PPTX::g_Namespaces.m.m_strLink); + pWriter->WriteAttribute(_T("xmlns:w"), PPTX::g_Namespaces.w.m_strLink); pWriter->WriteAttribute(_T("preserve"), preserve); pWriter->EndAttributes(); diff --git a/ASCOfficePPTXFile/PPTXLib/Linux/PPTXFormatLib/PPTXFormatLib.pro b/ASCOfficePPTXFile/PPTXLib/Linux/PPTXFormatLib/PPTXFormatLib.pro index f8ac53a115..79e449fe6c 100644 --- a/ASCOfficePPTXFile/PPTXLib/Linux/PPTXFormatLib/PPTXFormatLib.pro +++ b/ASCOfficePPTXFile/PPTXLib/Linux/PPTXFormatLib/PPTXFormatLib.pro @@ -95,6 +95,7 @@ SOURCES += \ ../../../PPTXFormat/Logic/TxBody.cpp \ ../../../PPTXFormat/Logic/UniColor.cpp \ ../../../PPTXFormat/Logic/UniEffect.cpp \ + ../../../PPTXFormat/Logic/Runs/MathParaWrapper.cpp \ ../../../PPTXFormat/FileContainer.cpp \ ../../../PPTXFormat/FileFactory.cpp \ ../../../PPTXFormat/FileMap.cpp \ @@ -300,6 +301,7 @@ HEADERS += pptxformatlib.h \ ../../../PPTXFormat/Logic/Path2D/QuadBezTo.h \ ../../../PPTXFormat/Logic/Runs/Br.h \ ../../../PPTXFormat/Logic/Runs/Fld.h \ + ../../../PPTXFormat/Logic/Runs/MathParaWrapper.h \ ../../../PPTXFormat/Logic/Runs/Run.h \ ../../../PPTXFormat/Logic/Runs/RunBase.h \ ../../../PPTXFormat/Logic/Table/Table.h \ diff --git a/Common/DocxFormat/DocxFormatLib/DocxFormatLib.pro b/Common/DocxFormat/DocxFormatLib/DocxFormatLib.pro index 9d1a06423e..8adaa05da9 100644 --- a/Common/DocxFormat/DocxFormatLib/DocxFormatLib.pro +++ b/Common/DocxFormat/DocxFormatLib/DocxFormatLib.pro @@ -18,7 +18,9 @@ include(../../../Common/base.pri) DEFINES += UNICODE _UNICODE _USE_LIBXML2_READER_ _USE_XMLLITE_READER_ USE_LITE_READER LIBXML_READER_ENABLED -INCLUDEPATH += ../../../DesktopEditor/xml/libxml2/include +INCLUDEPATH += \ + ../../../DesktopEditor/freetype-2.5.2/include \ + ../../../DesktopEditor/xml/libxml2/include build_fast { SOURCES += \ diff --git a/Common/DocxFormat/Source/DocxFormat/Math/OMath.h b/Common/DocxFormat/Source/DocxFormat/Math/OMath.h index c599f15759..db66661e16 100644 --- a/Common/DocxFormat/Source/DocxFormat/Math/OMath.h +++ b/Common/DocxFormat/Source/DocxFormat/Math/OMath.h @@ -127,25 +127,6 @@ namespace OOX return L""; } // Childs - }; - - template - class CMathArgNodesEx : public CMathArgNodes - { - public: - CMathArgNodesEx(XmlUtils::CXmlNode& oNode) - { - fromXML( oNode ); - } - CMathArgNodesEx(XmlUtils::CXmlLiteReader& oReader) - { - fromXML( oReader ); - } - virtual EElementType getType() const - { - return EnumType; - } }; - }//namespace Logic -}//namespace OOX \ No newline at end of file +}//namespace OOX diff --git a/Common/DocxFormat/Source/DocxFormat/Math/oMathContent.cpp b/Common/DocxFormat/Source/DocxFormat/Math/oMathContent.cpp index 869a9d8436..6290039647 100644 --- a/Common/DocxFormat/Source/DocxFormat/Math/oMathContent.cpp +++ b/Common/DocxFormat/Source/DocxFormat/Math/oMathContent.cpp @@ -411,6 +411,9 @@ namespace OOX if ( m_oMRPr.IsInit() ) sResult += m_oMRPr->toXML(); + if ( m_oARPr.IsInit() ) + sResult += m_oARPr->toXML(); + if ( m_oRPr.IsInit() ) sResult += m_oRPr->toXML(); @@ -444,4 +447,4 @@ namespace OOX return sResult; } } -} \ No newline at end of file +} diff --git a/Common/DocxFormat/Source/DocxFormat/Math/oMathContent.h b/Common/DocxFormat/Source/DocxFormat/Math/oMathContent.h index d1b8a44b5b..9a2b810760 100644 --- a/Common/DocxFormat/Source/DocxFormat/Math/oMathContent.h +++ b/Common/DocxFormat/Source/DocxFormat/Math/oMathContent.h @@ -42,6 +42,7 @@ #include "../Logic/Annotations.h" #include "../Logic/Pict.h" #include "../Drawing/Drawing.h" +#include "../../../../../ASCOfficePPTXFile/PPTXFormat/Logic/RunProperties.h" namespace OOX @@ -49,15 +50,32 @@ namespace OOX // Elements 22.1.2 namespace Logic { - typedef CMathArgNodesEx CDeg; - typedef CMathArgNodesEx CDen; - typedef CMathArgNodesEx CElement; - typedef CMathArgNodesEx CFName; - typedef CMathArgNodesEx CLim; - typedef CMathArgNodesEx CNum; - typedef CMathArgNodesEx COMath; - typedef CMathArgNodesEx CSub; - typedef CMathArgNodesEx CSup; + #define CMathArgNodesEx(name, type)\ + class name : public CMathArgNodes\ + {\ + public:\ + name(XmlUtils::CXmlNode& oNode)\ + {\ + fromXML( oNode );\ + }\ + name(XmlUtils::CXmlLiteReader& oReader)\ + {\ + fromXML( oReader );\ + }\ + virtual EElementType getType() const\ + {\ + return type;\ + }\ + }; + CMathArgNodesEx(CDeg, OOX::et_m_deg) + CMathArgNodesEx(CDen, OOX::et_m_den) + CMathArgNodesEx(CElement, OOX::et_m_e) + CMathArgNodesEx(CFName, OOX::et_m_fName) + CMathArgNodesEx(CLim, OOX::et_m_lim) + CMathArgNodesEx(CNum, OOX::et_m_num) + CMathArgNodesEx(COMath, OOX::et_m_oMath) + CMathArgNodesEx(CSub, OOX::et_m_sub) + CMathArgNodesEx(CSup, OOX::et_m_sup) //-------------------------------------------------------------------------------- // CAcc 22.1.2.1 (Accent) //-------------------------------------------------------------------------------- @@ -2354,6 +2372,14 @@ namespace OOX m_oMRPr = oReader ; else if ( _T("w:rPr") == sName ) m_oRPr = oReader; + else if ( _T("a:rPr") == sName ) + { + CString sXml = oReader.GetOuterXml(); + XmlUtils::CXmlNode node; + node.FromXmlString(sXml.GetBuffer()); + sXml.ReleaseBuffer(); + m_oARPr = node; + } else if ( _T("w:ruby") == sName ) m_oRuby = oReader; else if ( _T("w:separator") == sName ) @@ -2411,6 +2437,7 @@ namespace OOX nullable m_oPtab; nullable m_oRPr; nullable m_oMRPr; + nullable m_oARPr; nullable m_oRuby; nullable m_oSeparator; nullable m_oSoftHyphen; diff --git a/Common/DocxFormat/Source/XML/Utils.h b/Common/DocxFormat/Source/XML/Utils.h index bb2ae9bcaa..df9b180ec5 100644 --- a/Common/DocxFormat/Source/XML/Utils.h +++ b/Common/DocxFormat/Source/XML/Utils.h @@ -438,9 +438,34 @@ namespace XmlUtils inline void WriteEncodeXmlString(const wchar_t* pString) { const wchar_t* pData = pString; + bool isUtf16 = sizeof(wchar_t) == 2; + bool skipNext = false; while (*pData != 0) { - BYTE _code = CheckCode(*pData); + wchar_t code = *pData; + BYTE _code; + //todo replace CString with std::wstring and choose one writer + if (isUtf16) + { + if (skipNext) + { + skipNext = false; + _code = 1; + } + else if (code >= 0xD800 && code <= 0xDFFF && *(pData + 1) != 0) + { + skipNext = true; + _code = 1; + } + else + { + _code = CheckCode(code); + } + } + else + { + _code = CheckCode(code); + } switch (_code) { diff --git a/Common/DocxFormat/Source/XlsxFormat/Drawing/CellAnchor.h b/Common/DocxFormat/Source/XlsxFormat/Drawing/CellAnchor.h index ef43e8b0b9..52f1732ec7 100644 --- a/Common/DocxFormat/Source/XlsxFormat/Drawing/CellAnchor.h +++ b/Common/DocxFormat/Source/XlsxFormat/Drawing/CellAnchor.h @@ -207,8 +207,10 @@ namespace OOX while( oReader.ReadNextSiblingNode( nCurDepth ) ) { CString sName = XmlUtils::GetNameNoNS(oReader.GetName()); - if ( _T("Fallback") == sName ) + if ( _T("Fallback") == sName || _T("Choice") == sName ) { + CString sRequires; + ReadAttributesRequire(oReader, sRequires); CString xmlString;// = L""; //encoding=\"UTF-8\" xmlString += L""; xmlString += oReader.GetOuterXml(); - xmlString += L""; + xmlString += L""; + + //todo better check (a14 can be math, slicer) + if(_T("Choice") == sName && !(L"a14" == sRequires && -1 != xmlString.Find(L"a14:m"))) + { + continue; + } XmlUtils::CXmlLiteReader oSubReader; if (oSubReader.FromString(xmlString)) @@ -263,6 +271,13 @@ namespace OOX void ReadAttributes(XmlUtils::CXmlLiteReader& oReader) { } + void ReadAttributesRequire(XmlUtils::CXmlLiteReader& oReader, CString& sRequire) + { + // Читаем атрибуты + WritingElement_ReadAttributes_Start( oReader ) + WritingElement_ReadAttributes_ReadSingle( oReader, _T("Requires"), sRequire ) + WritingElement_ReadAttributes_End( oReader ) + } public: SimpleTypes::Spreadsheet::CCellAnchorType<> m_oAnchorType; nullable m_oFrom; diff --git a/Common/DocxFormat/Source/XlsxFormat/Drawing/Drawing.h b/Common/DocxFormat/Source/XlsxFormat/Drawing/Drawing.h index b060277fb9..af83a66af0 100644 --- a/Common/DocxFormat/Source/XlsxFormat/Drawing/Drawing.h +++ b/Common/DocxFormat/Source/XlsxFormat/Drawing/Drawing.h @@ -208,7 +208,7 @@ namespace OOX virtual void write(const CPath& oPath, const CPath& oDirectory, CContentTypes& oContent) const { XmlUtils::CStringWriter sXml; - sXml.WriteString(_T("")); + sXml.WriteString(_T("")); for(unsigned int i = 0, length = m_arrItems.size(); i < length; ++i) m_arrItems[i]->toXML(sXml); sXml.WriteString(_T(""));