From aad0ec464f528c6407ee6c51564be608172d38d2 Mon Sep 17 00:00:00 2001 From: Ivan Date: Wed, 17 Nov 2021 22:54:07 +0300 Subject: [PATCH 01/12] trying to add blip bullet to fix numbering --- .../PPTFormatLib/Linux/PPTFormatLib.pro | 4 +- .../PPTFormatLib/PPTXWriter/ShapeWriter.cpp | 18 +++-- .../Reader/PPTDocumentInfoOneUser.cpp | 19 ++++- .../Reader/PPTDocumentInfoOneUser.h | 2 +- .../Records/BlipCollection9Container.h | 77 +++++++++++++++++++ .../PPTFormatLib/Records/BlipEntityAtom.cpp | 57 ++++++++++++++ .../PPTFormatLib/Records/BlipEntityAtom.h | 28 +++---- .../Records/DocProgTagsContainer.h | 8 ++ .../Records/Drawing/ShapeContainer.cpp | 13 +++- .../Editor/Drawing/TextStructures.h | 17 +++- 10 files changed, 215 insertions(+), 28 deletions(-) create mode 100644 ASCOfficePPTFile/PPTFormatLib/Records/BlipCollection9Container.h create mode 100644 ASCOfficePPTFile/PPTFormatLib/Records/BlipEntityAtom.cpp diff --git a/ASCOfficePPTFile/PPTFormatLib/Linux/PPTFormatLib.pro b/ASCOfficePPTFile/PPTFormatLib/Linux/PPTFormatLib.pro index c325eca8cf..20ff7c9ded 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Linux/PPTFormatLib.pro +++ b/ASCOfficePPTFile/PPTFormatLib/Linux/PPTFormatLib.pro @@ -109,6 +109,7 @@ HEADERS += \ ../Records/Animations/VisualShapeGeneralAtom.h \ ../Records/Animations/VisualSoundAtom.h \ ../Records/Animations/_includer.h \ + ../Records/BlipCollection9Container.h \ ../Records/BlipEntityAtom.h \ ../Records/BookmarkEntityAtom.h \ ../Records/BookmarkSeedAtom.h \ @@ -293,4 +294,5 @@ SOURCES += \ ../PPTXWriter/TableWriter.cpp \ ../PPTXWriter/TxBodyConverter.cpp \ ../Reader/RoundTripExtractor.cpp \ - ../Records/Animations/TimeVariant.cpp + ../Records/Animations/TimeVariant.cpp \ + ../Records/BlipEntityAtom.cpp diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/ShapeWriter.cpp b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/ShapeWriter.cpp index c284cc1ee0..3723b89575 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/ShapeWriter.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/ShapeWriter.cpp @@ -1402,6 +1402,7 @@ void PPT_FORMAT::CShapeWriter::WriteTextInfo() } m_oWriter.WriteString(std::wstring(L"/>")); } + bool donotNeedBullet = true; if (pPF->bulletAutoNum.is_init() && !pPF->bulletChar.is_init()) { m_oWriter.WriteString(L""); + donotNeedBullet = true; + } + if (pPF->bulletBlip.is_init() && pPF->bulletBlip->tmpImagePath.size()) + { + auto strRID = m_pRels->WriteImage(pPF->bulletBlip->tmpImagePath); + if (strRID.empty()) + break; + m_oWriter.WriteString(L""); + donotNeedBullet = true; } bool set = true; @@ -1434,7 +1446,7 @@ void PPT_FORMAT::CShapeWriter::WriteTextInfo() set = true; } - if (!set) + if (!set && !donotNeedBullet) { if (pPF->hasBullet.is_init() && *(pPF->hasBullet) && !pPF->bulletChar.is_init()) { @@ -1626,10 +1638,6 @@ void PPT_FORMAT::CShapeWriter::WriteTextInfo() std::wstring strT = pParagraph->m_arSpans[nSpan].m_strText; CorrectXmlString(strT); - if (strT == L"Мой Офис® Защищенный") - { - int a = 2; - } m_oWriter.WriteString(strT); diff --git a/ASCOfficePPTFile/PPTFormatLib/Reader/PPTDocumentInfoOneUser.cpp b/ASCOfficePPTFile/PPTFormatLib/Reader/PPTDocumentInfoOneUser.cpp index 2770de70c9..7b8b678f2e 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Reader/PPTDocumentInfoOneUser.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/Reader/PPTDocumentInfoOneUser.cpp @@ -1094,7 +1094,7 @@ void CPPTUserInfo::LoadGroupShapeContainer(CRecordGroupShapeContainer* pGroupCon CElementPtr pElement = pShapeGroup->GetElement(m_current_level > 1, &m_oExMedia, pTheme, pLayout, pThemeWrapper, pSlideWrapper, pSlide); CShapeElement* pShape = dynamic_cast(pElement.get()); - + LoadBulletBlip(pShape); if (NULL != pElement) { pElement->m_pParentElements = pParentElements; @@ -2600,3 +2600,20 @@ void CPPTUserInfo::LoadAutoNumbering(CRecordGroupShapeContainer *pGroupContainer } } } + +void CPPTUserInfo::LoadBulletBlip(CShapeElement *pShape) +{ + if (pShape == nullptr || pShape->m_pShape == nullptr) return; + std::vector arrDocInfoCont; + m_oDocument.GetRecordsByType(&arrDocInfoCont, false); + // TODO need to find BlipEntity; + + for (auto& par : pShape->m_pShape->m_oText.m_arParagraphs) + { + if (par.m_oPFRun.bulletBlip.IsInit()) + { + // TODO need to write path of image here + par.m_oPFRun.bulletBlip->bulletBlipRef; + } + } +} diff --git a/ASCOfficePPTFile/PPTFormatLib/Reader/PPTDocumentInfoOneUser.h b/ASCOfficePPTFile/PPTFormatLib/Reader/PPTDocumentInfoOneUser.h index b7c30a1b9f..58526f1c62 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Reader/PPTDocumentInfoOneUser.h +++ b/ASCOfficePPTFile/PPTFormatLib/Reader/PPTDocumentInfoOneUser.h @@ -158,7 +158,7 @@ public: void LoadExAudio(CRecordsContainer* pExObject); void LoadAutoNumbering(CRecordGroupShapeContainer* pGroupContainer, PPT_FORMAT::CTheme* pTheme); - + void LoadBulletBlip(CShapeElement* pShape); void CreateDefaultStyle(PPT_FORMAT::CTextStyles& pStyle, PPT_FORMAT::CTheme* pTheme); void CorrectColorScheme(std::vector& oScheme) { diff --git a/ASCOfficePPTFile/PPTFormatLib/Records/BlipCollection9Container.h b/ASCOfficePPTFile/PPTFormatLib/Records/BlipCollection9Container.h new file mode 100644 index 0000000000..28f18444e4 --- /dev/null +++ b/ASCOfficePPTFile/PPTFormatLib/Records/BlipCollection9Container.h @@ -0,0 +1,77 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * 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 +#include "BlipEntityAtom.h" +#include + +namespace PPT_FORMAT +{ + +class CRecordBlipCollection9Container : public CUnknownRecord +{ +public: + std::vector > m_rgBlipEntityAtom; + + CRecordBlipCollection9Container() + { + } + + ~CRecordBlipCollection9Container() + { + } + + virtual void ReadFromStream(SRecordHeader & oHeader, POLE::Stream* pStream) + { + m_oHeader = oHeader; + LONG lPos = 0; + StreamUtils::StreamPosition ( lPos, pStream ); + + _UINT32 lCurLen = 0; + + SRecordHeader ReadHeader; + + while ( lCurLen < m_oHeader.RecLen ) + { + if ( ReadHeader.ReadFromStream(pStream) == false) + break; + + lCurLen += 8 + ReadHeader.RecLen; + + std::shared_ptr pRec(new CRecordBlipEntityAtom); + pRec->ReadFromStream(ReadHeader, pStream); + m_rgBlipEntityAtom.push_back(pRec); + } + StreamUtils::StreamSeek(lPos + m_oHeader.RecLen, pStream); + } + +}; +} diff --git a/ASCOfficePPTFile/PPTFormatLib/Records/BlipEntityAtom.cpp b/ASCOfficePPTFile/PPTFormatLib/Records/BlipEntityAtom.cpp new file mode 100644 index 0000000000..02e9a576e6 --- /dev/null +++ b/ASCOfficePPTFile/PPTFormatLib/Records/BlipEntityAtom.cpp @@ -0,0 +1,57 @@ +#include "BlipEntityAtom.h" +#include "../../../DesktopEditor/common/Directory.h" + +CRecordBlipEntityAtom::CRecordBlipEntityAtom() +{ + +} + +CRecordBlipEntityAtom::~CRecordBlipEntityAtom() +{ + NSDirectory::DeleteDirectory(m_tmpFolder); +} + +void CRecordBlipEntityAtom::ReadFromStream(SRecordHeader &oHeader, POLE::Stream *pStream) +{ + m_oHeader = oHeader; + + m_nWinBlipType = StreamUtils::ReadBYTE(pStream); + StreamUtils::StreamSkip(1, pStream); + SRecordHeader ReadHeader; + ReadHeader.ReadFromStream(pStream); + + m_tmpFolder = getTempFolder(); + m_oBlip.m_strTmpDirectory = m_tmpFolder; + m_oBlip.ReadFromStream(ReadHeader, pStream); +} + + +std::wstring CRecordBlipEntityAtom::getTempFolder() const +{ + std::wstring tempRootPath = NSDirectory::GetTempPath(); + if (false == NSDirectory::Exists(tempRootPath)) + return L""; + std::wstring tempFolder = NSDirectory::CreateDirectoryWithUniqueName(tempRootPath) + FILE_SEPARATOR_STR; + if (false == NSDirectory::Exists(tempFolder)) + return L""; + + + return tempFolder; +} + +const std::wstring CRecordBlipEntityAtom::getTmpImgPath() const +{ + return m_tmpFolder + m_oBlip.m_sFileName; +} + +const std::wstring CRecordBlipEntityAtom::getImgExtention() const +{ + switch (m_nWinBlipType) + { + case 2: return L".emf"; + case 3: return L".wmf"; + case 5: return L".jpeg"; + case 6: return L".png"; + default: return L""; + } +} diff --git a/ASCOfficePPTFile/PPTFormatLib/Records/BlipEntityAtom.h b/ASCOfficePPTFile/PPTFormatLib/Records/BlipEntityAtom.h index b2411c28b0..738451b806 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Records/BlipEntityAtom.h +++ b/ASCOfficePPTFile/PPTFormatLib/Records/BlipEntityAtom.h @@ -31,24 +31,26 @@ */ #pragma once #include "../Reader/Records.h" +#include "Drawing/ArtBlip.h" class CRecordBlipEntityAtom : public CUnknownRecord { public: - BYTE m_nWinBlipType; - std::pair, _INT32> data; - CRecordBlipEntityAtom() - { - } + CRecordBlipEntityAtom(); + const std::wstring getTmpImgPath() const; + const std::wstring getImgExtention() const; + ~CRecordBlipEntityAtom(); - ~CRecordBlipEntityAtom() - { - } + void ReadFromStream(SRecordHeader & oHeader, POLE::Stream* pStream) override; - virtual void ReadFromStream(SRecordHeader & oHeader, POLE::Stream* pStream) - { - return CUnknownRecord::ReadFromStream(oHeader, pStream); - } -}; \ No newline at end of file +private: + bool writeImage(); + std::wstring getTempFolder()const; + +private: + BYTE m_nWinBlipType; + CRecordOfficeArtBlip m_oBlip; + std::wstring m_tmpFolder; +}; diff --git a/ASCOfficePPTFile/PPTFormatLib/Records/DocProgTagsContainer.h b/ASCOfficePPTFile/PPTFormatLib/Records/DocProgTagsContainer.h index a2bd016a3b..ee88ad470d 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Records/DocProgTagsContainer.h +++ b/ASCOfficePPTFile/PPTFormatLib/Records/DocProgTagsContainer.h @@ -36,6 +36,7 @@ #include "ProgStringTagContainer.h" #include "TextDefaults9Atom.h" #include "OutlineTextProps9Container.h" +#include "BlipCollection9Container.h" #define ___PPT9 L"___PPT9" @@ -53,6 +54,7 @@ public: std::vector m_rgTextMasterStyleAtom; nullable m_textDefaultsAtom; nullable m_outlineTextPropsContainer; + nullable m_blipCollectionContainer; // TODO CRecordPP9DocBinaryTagExtension() { @@ -104,6 +106,12 @@ public: m_outlineTextPropsContainer->ReadFromStream(ReadHeader, pStream); break; } + case RT_BlipCollection9: + { + m_blipCollectionContainer = new CRecordBlipCollection9Container; + m_blipCollectionContainer->ReadFromStream(ReadHeader, pStream); + break; + } default: StreamUtils::StreamSkip(ReadHeader.RecLen, pStream); break; diff --git a/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp b/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp index 0e4234515b..436c5baf5a 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp @@ -2748,11 +2748,11 @@ void CRecordShapeContainer::ApplyAutoNumbering(CTextAttributesEx *pText) if (!par.m_arSpans[0].m_oRun.pp9rt.is_init()) continue; - WORD pp9st = par.m_arSpans[0].m_oRun.pp9rt.get(); - if (pp9st >= arrProps9.size()) + WORD pp9rt = par.m_arSpans[0].m_oRun.pp9rt.get(); + if (pp9rt >= arrProps9.size()) continue; - auto& prop9 = arrProps9[pp9st]; + auto& prop9 = arrProps9[pp9rt]; if (prop9.m_pf9.m_optBulletAutoNumberScheme.is_init()) { auto* pBuAutoNum = new CBulletAutoNum; @@ -2761,6 +2761,13 @@ void CRecordShapeContainer::ApplyAutoNumbering(CTextAttributesEx *pText) par.m_oPFRun.bulletAutoNum.reset(pBuAutoNum); } + // TODO not connected with pp9rt? To connect m_optBulletBlipRef with CBulletBlip if (prop9.m_pf9.m_optBulletBlipRef.is_init()) + { +// auto* pBuBlip = new CBulletBlip; +// pBuBlip->bulletBlipRef = prop9.m_pf9.m_optBulletBlipRef.get(); + +// par.m_oPFRun.bulletBlip.reset(pBuBlip); + } } } diff --git a/ASCOfficePPTXFile/Editor/Drawing/TextStructures.h b/ASCOfficePPTXFile/Editor/Drawing/TextStructures.h index c3c4e365bf..403752ee80 100644 --- a/ASCOfficePPTXFile/Editor/Drawing/TextStructures.h +++ b/ASCOfficePPTXFile/Editor/Drawing/TextStructures.h @@ -118,6 +118,13 @@ namespace PPT_FORMAT }; + class CBulletBlip + { + public: + std::wstring tmpImagePath; + WORD bulletBlipRef; + }; + class CFontProperties { public: @@ -278,8 +285,9 @@ namespace PPT_FORMAT NSCommon::nullable_base bulletSize; NSCommon::nullable_base bulletChar; NSCommon::nullable_base bulletColor; - NSCommon::nullable_base bulletFontProperties; - NSCommon::nullable_base bulletAutoNum; + NSCommon::nullable_base bulletFontProperties; + NSCommon::nullable_base bulletAutoNum; + NSCommon::nullable_base bulletBlip; NSCommon::nullable_base textAlignment; NSCommon::nullable_base lineSpacing; @@ -946,6 +954,7 @@ namespace PPT_FORMAT return false; } return true; - } - }; + } + }; + } From 0ffc7ef04cea5b1a78a252c86de3099a1a045eb2 Mon Sep 17 00:00:00 2001 From: Ivan Date: Tue, 23 Nov 2021 23:25:13 +0300 Subject: [PATCH 02/12] add ConvertExtention9() for buBlip --- .../Reader/PPTDocumentInfoOneUser.cpp | 16 +++++----- .../PPTFormatLib/Reader/Records.cpp | 2 +- .../Records/DocProgTagsContainer.h | 13 +++++--- .../Records/Drawing/ShapeContainer.cpp | 32 +++++++++++++++++++ .../Records/Drawing/ShapeContainer.h | 1 + .../Records/OfficeArtClientData.h | 11 +++++++ ASCOfficePPTXFile/Editor/Drawing/Element.h | 2 ++ .../Editor/Drawing/TextStructures.h | 13 +++++--- 8 files changed, 71 insertions(+), 19 deletions(-) diff --git a/ASCOfficePPTFile/PPTFormatLib/Reader/PPTDocumentInfoOneUser.cpp b/ASCOfficePPTFile/PPTFormatLib/Reader/PPTDocumentInfoOneUser.cpp index 7b8b678f2e..d5d291d284 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Reader/PPTDocumentInfoOneUser.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/Reader/PPTDocumentInfoOneUser.cpp @@ -2608,12 +2608,12 @@ void CPPTUserInfo::LoadBulletBlip(CShapeElement *pShape) m_oDocument.GetRecordsByType(&arrDocInfoCont, false); // TODO need to find BlipEntity; - for (auto& par : pShape->m_pShape->m_oText.m_arParagraphs) - { - if (par.m_oPFRun.bulletBlip.IsInit()) - { - // TODO need to write path of image here - par.m_oPFRun.bulletBlip->bulletBlipRef; - } - } +// for (auto& par : pShape->m_pShape->m_oText.m_arParagraphs) +// { +// if (par.m_oPFRun.bulletBlip.IsInit()) +// { +// // TODO need to write path of image here +// par.m_oPFRun.bulletBlip->bulletBlipRef; +// } +// } } diff --git a/ASCOfficePPTFile/PPTFormatLib/Reader/Records.cpp b/ASCOfficePPTFile/PPTFormatLib/Reader/Records.cpp index 4cad68104d..8c5dcbb4c8 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Reader/Records.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/Reader/Records.cpp @@ -566,7 +566,7 @@ IRecord* CreateByType(SRecordHeader oHeader) CREATE_BY_TYPE(RT_TextRulerAtom , CRecordTextRulerAtom) //CREATE_BY_TYPE(RECORD_TYPE_TEXTBOOKMARK_ATOM , CRecordTextBookmarkAtom) CREATE_BY_TYPE(RT_TextBytesAtom , CRecordTextBytesAtom) - //CREATE_BY_TYPE(RECORD_TYPE_UNKNOWN , CRecordOutlineTextPropsHeaderExAtom) + CREATE_BY_TYPE(RT_OutlineTextPropsHeader9Atom , CRecordOutlineTextPropsHeaderExAtom) CREATE_BY_TYPE(RT_GuideAtom , CRecordGuideAtom) diff --git a/ASCOfficePPTFile/PPTFormatLib/Records/DocProgTagsContainer.h b/ASCOfficePPTFile/PPTFormatLib/Records/DocProgTagsContainer.h index ee88ad470d..ef87ea9d8d 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Records/DocProgTagsContainer.h +++ b/ASCOfficePPTFile/PPTFormatLib/Records/DocProgTagsContainer.h @@ -48,13 +48,13 @@ namespace PPT_FORMAT { -class CRecordPP9DocBinaryTagExtension : public CUnknownRecord +class CRecordPP9DocBinaryTagExtension : public CRecordsContainer { public: std::vector m_rgTextMasterStyleAtom; - nullable m_textDefaultsAtom; - nullable m_outlineTextPropsContainer; - nullable m_blipCollectionContainer; + nullable m_textDefaultsAtom; + nullable m_outlineTextPropsContainer; + nullable m_blipCollectionContainer; // TODO CRecordPP9DocBinaryTagExtension() { @@ -113,7 +113,10 @@ public: break; } default: - StreamUtils::StreamSkip(ReadHeader.RecLen, pStream); + IRecord* pRecord = CreateByType(ReadHeader); + pRecord->ReadFromStream(ReadHeader, pStream); + + m_arRecords.push_back(pRecord); break; } diff --git a/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp b/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp index 436c5baf5a..4521c267bb 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp @@ -1965,6 +1965,8 @@ CElementPtr CRecordShapeContainer::GetElement (bool inGroup, CExMedia* pMapIDs, pShapeElem->m_oTextActions.m_arRanges.push_back(oRange); } } + + ConvertExtention9(pShapeElem); double dAngle = pShapeElem->m_dRotate; if (0 <= dAngle) { @@ -2775,6 +2777,36 @@ void CRecordShapeContainer::ApplyAutoNumbering(CTextAttributesEx *pText) } } +void CRecordShapeContainer::ConvertExtention9(CElement* pElement) +{ + if (pElement == nullptr) + return; + + std::vector arrOfficeData; + GetRecordsByType(&arrOfficeData, false, true); + + if (arrOfficeData.empty()) + return; + + auto pUnknownBinaryTag =arrOfficeData[0]->getProgTag(___PPT9); + if (pUnknownBinaryTag == nullptr) + return; + auto progTag9 = dynamic_cast(pUnknownBinaryTag); + if (progTag9 == nullptr) + return; + + for (const auto& textProp9 : progTag9->m_styleTextPropAtom.m_rgStyleTextProp9) + { + if (textProp9.m_pf9.m_optBulletBlipRef.IsInit()) + { + CBulletBlip buBlip; + buBlip.bulletBlipRef = textProp9.m_pf9.m_optBulletBlipRef.get(); + pElement->m_arrBlip.push_back(buBlip); + } + } + +} + void CRecordGroupShapeContainer::ReadFromStream(SRecordHeader & oHeader, POLE::Stream* pStream) { CRecordsContainer::ReadFromStream(oHeader, pStream); diff --git a/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.h b/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.h index a37a74c221..641a16c345 100755 --- a/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.h +++ b/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.h @@ -150,5 +150,6 @@ protected: static std::vector > splitInteractive(const std::vector& arrInteractive); static void ConvertInteractiveInfo(CInteractiveInfo& interactiveInfo, const CRecordMouseInteractiveInfoContainer* interactiveCont, CExMedia* pMapIDs); void ApplyAutoNumbering(CTextAttributesEx *pText); + void ConvertExtention9(CElement *pElement); }; diff --git a/ASCOfficePPTFile/PPTFormatLib/Records/OfficeArtClientData.h b/ASCOfficePPTFile/PPTFormatLib/Records/OfficeArtClientData.h index 62efbc2752..972ddc51c4 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Records/OfficeArtClientData.h +++ b/ASCOfficePPTFile/PPTFormatLib/Records/OfficeArtClientData.h @@ -70,6 +70,17 @@ public: RELEASEOBJECT ( m_rgShapeClientRoundtripData[i] ); } + CRecordShapeProgBinaryTagSubContainerOrAtom* getProgTag(const std::wstring& tagname) + { + for (auto* progtag : m_rgShapeClientRoundtripData) + { + if (progtag->m_pTagName->m_strText == tagname) + return progtag; + } + + return nullptr; + } + virtual void ReadFromStream(SRecordHeader & oHeader, POLE::Stream* pStream) { m_oHeader = oHeader; diff --git a/ASCOfficePPTXFile/Editor/Drawing/Element.h b/ASCOfficePPTXFile/Editor/Drawing/Element.h index 52009a2fbc..e2f24e0493 100644 --- a/ASCOfficePPTXFile/Editor/Drawing/Element.h +++ b/ASCOfficePPTXFile/Editor/Drawing/Element.h @@ -77,6 +77,8 @@ public: std::vector m_arrActions; std::vector m_textHyperlinks; + std::vector m_arrBlip; + CAnimationInfo m_oAnimations; CEffects m_oEffects; diff --git a/ASCOfficePPTXFile/Editor/Drawing/TextStructures.h b/ASCOfficePPTXFile/Editor/Drawing/TextStructures.h index 403752ee80..f61ecc63d3 100644 --- a/ASCOfficePPTXFile/Editor/Drawing/TextStructures.h +++ b/ASCOfficePPTXFile/Editor/Drawing/TextStructures.h @@ -225,7 +225,7 @@ namespace PPT_FORMAT if (!eaFontRef.is_init()) eaFontRef = oSrc.eaFontRef; if (!ansiFontRef.is_init()) ansiFontRef = oSrc.ansiFontRef; if (!symbolFontRef.is_init()) symbolFontRef = oSrc.symbolFontRef; - + if (!pp9rt.is_init()) pp9rt = oSrc.pp9rt; if (!BaseLineOffset.is_init()) BaseLineOffset = oSrc.BaseLineOffset; if (!Color.is_init()) Color = oSrc.Color; if (!Size.is_init()) Size = oSrc.Size; @@ -244,8 +244,9 @@ namespace PPT_FORMAT if (oSrc.FontItalic.is_init()) FontItalic = oSrc.FontItalic; if (oSrc.FontUnderline.is_init()) FontUnderline = oSrc.FontUnderline; if (oSrc.FontStrikeout.is_init()) FontStrikeout = oSrc.FontStrikeout; - if (oSrc.FontShadow.is_init()) FontShadow = oSrc.FontShadow; - + if (oSrc.FontShadow.is_init()) FontShadow = oSrc.FontShadow; + if (oSrc.pp9rt.is_init()) pp9rt = oSrc.pp9rt; + bool bFontRefSetUp = false; if (oSrc.fontRef.is_init()) { @@ -255,8 +256,10 @@ namespace PPT_FORMAT if (oSrc.eaFontRef.is_init()) eaFontRef = oSrc.eaFontRef; if (oSrc.ansiFontRef.is_init()) ansiFontRef = oSrc.ansiFontRef; if (oSrc.symbolFontRef.is_init()) symbolFontRef = oSrc.symbolFontRef; - if (oSrc.BaseLineOffset.is_init()) BaseLineOffset = oSrc.BaseLineOffset; - if (oSrc.Color.is_init()) Color = oSrc.Color; + if (oSrc.BaseLineOffset.is_init()) BaseLineOffset = oSrc.BaseLineOffset; + if (oSrc.pp9rt.is_init()) pp9rt = oSrc.pp9rt; + + if (oSrc.Color.is_init()) Color = oSrc.Color; if (oSrc.Size.is_init()) Size = oSrc.Size; if (oSrc.Cap.is_init()) Cap = oSrc.Cap; if (oSrc.Language.is_init()) Language = oSrc.Language; From f76bf0cee1a3ffedd012812abad2190301dacbf5 Mon Sep 17 00:00:00 2001 From: Ivan Morozov Date: Wed, 24 Nov 2021 18:41:17 +0300 Subject: [PATCH 03/12] add buBlip. bullet as image --- .../Reader/PPTDocumentInfoOneUser.cpp | 36 +++- .../Records/DocInfoListContainer.h | 16 ++ .../Records/DocProgTagsContainer.h | 11 +- .../Records/Drawing/ShapeContainer.cpp | 193 +++++++++--------- .../Records/Drawing/ShapeContainer.h | 3 +- .../Editor/Drawing/TextStructures.h | 5 +- 6 files changed, 159 insertions(+), 105 deletions(-) diff --git a/ASCOfficePPTFile/PPTFormatLib/Reader/PPTDocumentInfoOneUser.cpp b/ASCOfficePPTFile/PPTFormatLib/Reader/PPTDocumentInfoOneUser.cpp index d5d291d284..b11339010e 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Reader/PPTDocumentInfoOneUser.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/Reader/PPTDocumentInfoOneUser.cpp @@ -2605,15 +2605,31 @@ void CPPTUserInfo::LoadBulletBlip(CShapeElement *pShape) { if (pShape == nullptr || pShape->m_pShape == nullptr) return; std::vector arrDocInfoCont; - m_oDocument.GetRecordsByType(&arrDocInfoCont, false); - // TODO need to find BlipEntity; + m_oDocument.GetRecordsByType(&arrDocInfoCont, false, true); -// for (auto& par : pShape->m_pShape->m_oText.m_arParagraphs) -// { -// if (par.m_oPFRun.bulletBlip.IsInit()) -// { -// // TODO need to write path of image here -// par.m_oPFRun.bulletBlip->bulletBlipRef; -// } -// } + if (arrDocInfoCont.empty()) + return; + auto& arrPars = pShape->m_pShape->m_oText.m_arParagraphs; + + // TODO need to find BlipEntity; + IRecord* pRecPPT9 = arrDocInfoCont[0]->getDocBinaryTagExtension(___PPT9); + auto* pProgBinaryTag = dynamic_cast(pRecPPT9); + if (pProgBinaryTag == nullptr || !pProgBinaryTag->m_blipCollectionContainer.is_init()) + return; + + const auto& arrBlipEntity = pProgBinaryTag->m_blipCollectionContainer.get().m_rgBlipEntityAtom; + if(arrBlipEntity.empty()) + return; + + for (auto& par : arrPars) + { + if (par.m_oPFRun.bulletBlip.IsInit()) + { + auto& buBlip = par.m_oPFRun.bulletBlip.get(); + if (buBlip.bulletBlipRef >= 0 && (UINT)buBlip.bulletBlipRef < arrBlipEntity.size()) + { + buBlip.tmpImagePath = arrBlipEntity[buBlip.bulletBlipRef]->getTmpImgPath(); + } + } + } } diff --git a/ASCOfficePPTFile/PPTFormatLib/Records/DocInfoListContainer.h b/ASCOfficePPTFile/PPTFormatLib/Records/DocInfoListContainer.h index 5a886db91c..d4047d1d77 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Records/DocInfoListContainer.h +++ b/ASCOfficePPTFile/PPTFormatLib/Records/DocInfoListContainer.h @@ -113,6 +113,22 @@ public: StreamUtils::StreamSeek(lPos + m_oHeader.RecLen, pStream); } + IRecord* getDocBinaryTagExtension(const std::wstring& extVersion) + { + for (auto* pChild : m_rgChildRec) + { + if(pChild == nullptr || pChild->m_record.IsInit() == false) + continue; + + auto* pDocProgTagsCont = dynamic_cast(pChild->m_record.GetPointer()); + if (pDocProgTagsCont == nullptr) + continue; + + return pDocProgTagsCont->getDocBinaryTagExtension(extVersion); + } + return nullptr; + } + CRecordVBAInfoAtom* getVBAInfoAtom()const { for (const auto* pChild : m_rgChildRec) diff --git a/ASCOfficePPTFile/PPTFormatLib/Records/DocProgTagsContainer.h b/ASCOfficePPTFile/PPTFormatLib/Records/DocProgTagsContainer.h index ef87ea9d8d..1f6f8de31b 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Records/DocProgTagsContainer.h +++ b/ASCOfficePPTFile/PPTFormatLib/Records/DocProgTagsContainer.h @@ -306,7 +306,7 @@ public: StreamUtils::StreamSeek(lPos + m_oHeader.RecLen, pStream); } - CRecordPP9DocBinaryTagExtension* getPP19DocBinaryTagExtension() + CRecordPP9DocBinaryTagExtension* getPP9DocBinaryTagExtension() { for (auto* rec : m_arrRgChildRec) if (rec->m_pTagName->m_strText == ___PPT9) @@ -315,6 +315,15 @@ public: return nullptr; } + IRecord* getDocBinaryTagExtension(const std::wstring& extVersion) + { + for (auto* rec : m_arrRgChildRec) + if (rec->m_pTagName->m_strText == extVersion) + return rec->m_pTagContainer; + + return nullptr; + } + public: std::vector m_arrRgChildRec; }; diff --git a/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp b/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp index 4521c267bb..2458a1a0a9 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp @@ -927,10 +927,10 @@ void CPPTElement::SetUpPropertyShape(CElementPtr pElement, CTheme* pTheme, CSlid if (utf8Data && utf8DataSize > 0) { pParentShape->m_strXmlString = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8(utf8Data, utf8DataSize); -// std::string filename = std::to_string(nRTCounter++) + "_shape.xml"; -// std::ofstream file("data/" + filename, std::ios::out); -// file.write((char*)utf8Data, utf8DataSize); -// file.close(); + // std::string filename = std::to_string(nRTCounter++) + "_shape.xml"; + // std::ofstream file("data/" + filename, std::ios::out); + // file.write((char*)utf8Data, utf8DataSize); + // file.close(); delete []utf8Data; } @@ -1840,9 +1840,9 @@ CElementPtr CRecordShapeContainer::GetElement (bool inGroup, CExMedia* pMapIDs, } - //--------- наличие текста -------------------------------------------------------------------------- CShapeElement* pShapeElem = dynamic_cast(pElement.get()); + if (NULL != pShapeElem) { CElementInfo oElementInfo; @@ -1966,7 +1966,6 @@ CElementPtr CRecordShapeContainer::GetElement (bool inGroup, CExMedia* pMapIDs, } } - ConvertExtention9(pShapeElem); double dAngle = pShapeElem->m_dRotate; if (0 <= dAngle) { @@ -2057,7 +2056,7 @@ bool CRecordShapeContainer::isTable() const { if ((prop.m_ePID == tableProperties || prop.m_ePID == tableRowProperties) && - bGroupShape) + bGroupShape) { return true; } @@ -2080,26 +2079,26 @@ std::wstring CRecordShapeContainer::getTableXmlStr() const ULONG utf8DataSize = 0; auto& xmlProp = oArrayOptions[1]->m_oProperties.m_arProperties[2]; //id == 0x2065 ? - if (xmlProp.m_pOptions && xmlProp.m_lValue > 0) // file513.ppt - { - std::wstring temp = NSDirectory::GetTempPath(); - std::wstring tempFileName = temp + FILE_SEPARATOR_STR + L"tempMetroBlob.zip"; + if (xmlProp.m_pOptions && xmlProp.m_lValue > 0) // file513.ppt + { + std::wstring temp = NSDirectory::GetTempPath(); + std::wstring tempFileName = temp + FILE_SEPARATOR_STR + L"tempMetroBlob.zip"; - NSFile::CFileBinary file; - if (file.CreateFileW(tempFileName)) - { - file.WriteFile(xmlProp.m_pOptions, xmlProp.m_lValue); - file.CloseFile(); - } + NSFile::CFileBinary file; + if (file.CreateFileW(tempFileName)) + { + file.WriteFile(xmlProp.m_pOptions, xmlProp.m_lValue); + file.CloseFile(); + } - if (S_OK == officeUtils.LoadFileFromArchive(tempFileName, L"drs/e2oDoc.xml", &utf8Data, utf8DataSize)) - { - xmlStr = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8(utf8Data, utf8DataSize); - } + if (S_OK == officeUtils.LoadFileFromArchive(tempFileName, L"drs/e2oDoc.xml", &utf8Data, utf8DataSize)) + { + xmlStr = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8(utf8Data, utf8DataSize); + } - delete[] utf8Data; - NSFile::CFileBinary::Remove(tempFileName); - } + delete[] utf8Data; + NSFile::CFileBinary::Remove(tempFileName); + } } return xmlStr; @@ -2127,7 +2126,8 @@ void CRecordShapeContainer::ApplyThemeStyle(CElementPtr pElem, CTheme* pTheme, C } pText->ApplyThemeStyle(pTheme); - ApplyAutoNumbering(pText); + // AutoNumbering and BulletBlip + ConvertStyleTextProp9(pText); } void CRecordShapeContainer::SetUpTextStyle(std::wstring& strText, CTheme* pTheme, CLayout* pLayout, CElementPtr pElem, CSlideInfo* pThemeWrapper, CSlideInfo* pSlideWrapper, CSlide* pSlide, CRecordMasterTextPropAtom* master_levels) { @@ -2594,8 +2594,8 @@ void CRecordShapeContainer::ApplyHyperlink(CShapeElement* pShape, CColor& oColor const int posBlockStart = posOrigText; const int posOrigSpanEnd = posBlockStart + iterSpan->m_strText.length(); const int posBlockEnd = isHyperlink ? - (std::min)(posOrigSpanEnd, iterRange->m_lEnd) : - (std::min)(posOrigSpanEnd, iterRange->m_lStart); + (std::min)(posOrigSpanEnd, iterRange->m_lEnd) : + (std::min)(posOrigSpanEnd, iterRange->m_lStart); const size_t blockLen = posBlockEnd - posBlockStart; const bool isNeedToSplit = posBlockEnd < posOrigSpanEnd && isHyperlink; @@ -2627,13 +2627,13 @@ void CRecordShapeContainer::ApplyHyperlink(CShapeElement* pShape, CColor& oColor iterSpan->m_strText = originalText.substr(posBlockEnd, nextBlockLen); iterSpan->m_arrInteractive.clear(); // Return to current span - iterSpan--; + iterSpan--; } - if (iterSpan != arrSpans.end() && iterInteractive != arrSplitedInteractive.end()) - addHyperlinkToSpan(*iterSpan, *iterInteractive, oColor); - else - break; //GZoabli_PhD.ppt + if (iterSpan != arrSpans.end() && iterInteractive != arrSplitedInteractive.end()) + addHyperlinkToSpan(*iterSpan, *iterInteractive, oColor); + else + break; //GZoabli_PhD.ppt if (posBlockEnd == iterRange->m_lEnd) { @@ -2654,7 +2654,7 @@ void CRecordShapeContainer::ApplyHyperlink(CShapeElement* pShape, CColor& oColor const size_t nextBlockLen = posOrigSpanEnd - posBlockEnd; iterSpan->m_strText = originalText.substr(posBlockEnd, nextBlockLen); iterSpan->m_arrInteractive.clear(); - // Return to current span + // Return to current span iterSpan--; } } @@ -2728,60 +2728,9 @@ void CRecordShapeContainer::ConvertInteractiveInfo(CInteractiveInfo &interactive } -void CRecordShapeContainer::ApplyAutoNumbering(CTextAttributesEx *pText) +void CRecordShapeContainer::ConvertStyleTextProp9(CTextAttributesEx *pText) { - std::vector arrOfficeArtClientData; - GetRecordsByType(&arrOfficeArtClientData, true); - - for (auto childOfficeArtClientData : arrOfficeArtClientData) - { - for (auto prog : childOfficeArtClientData->m_rgShapeClientRoundtripData) - { - if (prog->m_pTagName && prog->m_pTagContainer && prog->m_pTagName->m_strText == ___PPT9) - { - auto styleTextPropAtom = dynamic_cast(prog->m_pTagContainer)->m_styleTextPropAtom; - auto& arrProps9 = styleTextPropAtom.m_rgStyleTextProp9; - auto& arrPars = pText->m_arParagraphs; - for (auto& par : arrPars) - { - if (par.m_arSpans.empty()) - continue; - if (!par.m_arSpans[0].m_oRun.pp9rt.is_init()) - continue; - - WORD pp9rt = par.m_arSpans[0].m_oRun.pp9rt.get(); - if (pp9rt >= arrProps9.size()) - continue; - - auto& prop9 = arrProps9[pp9rt]; - if (prop9.m_pf9.m_optBulletAutoNumberScheme.is_init()) - { - auto* pBuAutoNum = new CBulletAutoNum; - pBuAutoNum->type = prop9.m_pf9.m_optBulletAutoNumberScheme->SchemeToStr(); - pBuAutoNum->startAt = prop9.m_pf9.m_optBulletAutoNumberScheme->m_nStartNum; - - par.m_oPFRun.bulletAutoNum.reset(pBuAutoNum); - } - // TODO not connected with pp9rt? To connect m_optBulletBlipRef with CBulletBlip if (prop9.m_pf9.m_optBulletBlipRef.is_init()) - { -// auto* pBuBlip = new CBulletBlip; -// pBuBlip->bulletBlipRef = prop9.m_pf9.m_optBulletBlipRef.get(); - -// par.m_oPFRun.bulletBlip.reset(pBuBlip); - } - } - } - - } - } -} - -void CRecordShapeContainer::ConvertExtention9(CElement* pElement) -{ - if (pElement == nullptr) - return; - std::vector arrOfficeData; GetRecordsByType(&arrOfficeData, false, true); @@ -2791,22 +2740,84 @@ void CRecordShapeContainer::ConvertExtention9(CElement* pElement) auto pUnknownBinaryTag =arrOfficeData[0]->getProgTag(___PPT9); if (pUnknownBinaryTag == nullptr) return; - auto progTag9 = dynamic_cast(pUnknownBinaryTag); + auto progTag9 = dynamic_cast(pUnknownBinaryTag->m_pTagContainer); if (progTag9 == nullptr) return; - for (const auto& textProp9 : progTag9->m_styleTextPropAtom.m_rgStyleTextProp9) + const auto& arrStyleTextProp9 = progTag9->m_styleTextPropAtom.m_rgStyleTextProp9; + if (arrStyleTextProp9.empty()) + return; + + WORD pp9rt = 0; + auto& arrPars = pText->m_arParagraphs; + for (auto& par : arrPars) { - if (textProp9.m_pf9.m_optBulletBlipRef.IsInit()) + if (par.m_arSpans.empty()) + continue; + + if (par.m_arSpans[0].m_oRun.pp9rt.is_init()) + pp9rt = par.m_arSpans[0].m_oRun.pp9rt.get(); + + if (pp9rt >= arrStyleTextProp9.size()) + continue; + + auto& prop9 = arrStyleTextProp9[pp9rt]; + + if (prop9.m_pf9.m_optBulletAutoNumberScheme.is_init()) { - CBulletBlip buBlip; - buBlip.bulletBlipRef = textProp9.m_pf9.m_optBulletBlipRef.get(); - pElement->m_arrBlip.push_back(buBlip); + auto* pBuAutoNum = new CBulletAutoNum; + pBuAutoNum->type = prop9.m_pf9.m_optBulletAutoNumberScheme->SchemeToStr(); + pBuAutoNum->startAt = prop9.m_pf9.m_optBulletAutoNumberScheme->m_nStartNum; + + par.m_oPFRun.bulletAutoNum.reset(pBuAutoNum); + } + if (prop9.m_pf9.m_optBulletBlipRef.is_init()) + { + auto* pBuBlip = new CBulletBlip; + if (prop9.m_pf9.m_optBulletBlipRef.IsInit()) + pBuBlip->bulletBlipRef = prop9.m_pf9.m_optBulletBlipRef.get(); + else + pBuBlip->bulletBlipRef = -1; + + par.m_oPFRun.bulletBlip.reset(pBuBlip); } } } +//void CRecordShapeContainer::ConvertExtention9(CElement* pElement) +//{ +// if (pElement == nullptr) +// return; + +// std::vector arrOfficeData; +// GetRecordsByType(&arrOfficeData, false, true); + +// if (arrOfficeData.empty()) +// return; + +// auto pUnknownBinaryTag =arrOfficeData[0]->getProgTag(___PPT9); +// if (pUnknownBinaryTag == nullptr) +// return; +// auto progTag9 = dynamic_cast(pUnknownBinaryTag->m_pTagContainer); +// if (progTag9 == nullptr) +// return; + +// const auto& arrStyleTextProp9 = progTag9->m_styleTextPropAtom.m_rgStyleTextProp9; + +// for (const auto& textProp9 : arrStyleTextProp9) +// { +// CBulletBlip buBlip; +// if (textProp9.m_pf9.m_optBulletBlipRef.IsInit()) +// buBlip.bulletBlipRef = textProp9.m_pf9.m_optBulletBlipRef.get(); +// else +// buBlip.bulletBlipRef = -1; + +// pElement->m_arrBlip.push_back(buBlip); +// } + +//} + void CRecordGroupShapeContainer::ReadFromStream(SRecordHeader & oHeader, POLE::Stream* pStream) { CRecordsContainer::ReadFromStream(oHeader, pStream); diff --git a/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.h b/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.h index 641a16c345..2a5a4cf1e4 100755 --- a/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.h +++ b/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.h @@ -149,7 +149,6 @@ protected: static void addHyperlinkToSpan(CSpan& oSpan, const std::vector &arrInteractive, const CColor& oColor); static std::vector > splitInteractive(const std::vector& arrInteractive); static void ConvertInteractiveInfo(CInteractiveInfo& interactiveInfo, const CRecordMouseInteractiveInfoContainer* interactiveCont, CExMedia* pMapIDs); - void ApplyAutoNumbering(CTextAttributesEx *pText); - void ConvertExtention9(CElement *pElement); + void ConvertStyleTextProp9(CTextAttributesEx *pText); }; diff --git a/ASCOfficePPTXFile/Editor/Drawing/TextStructures.h b/ASCOfficePPTXFile/Editor/Drawing/TextStructures.h index f61ecc63d3..cfeb14e2bf 100644 --- a/ASCOfficePPTXFile/Editor/Drawing/TextStructures.h +++ b/ASCOfficePPTXFile/Editor/Drawing/TextStructures.h @@ -122,7 +122,10 @@ namespace PPT_FORMAT { public: std::wstring tmpImagePath; - WORD bulletBlipRef; + SHORT bulletBlipRef; + + bool hasRef()const + {return bulletBlipRef != -1;} }; class CFontProperties From 9cd8cb0662f51c99cfc755329678a58df08c163d Mon Sep 17 00:00:00 2001 From: "Elena.Subbotina" Date: Thu, 25 Nov 2021 13:21:57 +0300 Subject: [PATCH 04/12] fix bug #53305 --- ASCOfficeDocxFile2/BinReader/Readers.cpp | 2 ++ ASCOfficeDocxFile2/BinWriter/BinWriters.cpp | 2 +- X2tConverter/src/ASCConverters.cpp | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/ASCOfficeDocxFile2/BinReader/Readers.cpp b/ASCOfficeDocxFile2/BinReader/Readers.cpp index 2174a4a9ec..b68dfc304f 100644 --- a/ASCOfficeDocxFile2/BinReader/Readers.cpp +++ b/ASCOfficeDocxFile2/BinReader/Readers.cpp @@ -9159,6 +9159,8 @@ int Binary_DocumentTableReader::ReadSdt(BYTE type, long length, void* poResult) } int Binary_DocumentTableReader::ReadSdtPr(BYTE type, long length, void* poResult) { + if (length < 1) return 0; + int res = 0; SdtWraper* pSdtWraper = static_cast(poResult); OOX::Logic::CSdtPr* pSdtPr = pSdtWraper->m_oSdt.m_oSdtPr.GetPointer(); diff --git a/ASCOfficeDocxFile2/BinWriter/BinWriters.cpp b/ASCOfficeDocxFile2/BinWriter/BinWriters.cpp index 210e1bdc44..967c9a9b63 100644 --- a/ASCOfficeDocxFile2/BinWriter/BinWriters.cpp +++ b/ASCOfficeDocxFile2/BinWriter/BinWriters.cpp @@ -8567,7 +8567,7 @@ void BinarySettingsTableWriter::WriteMathPr(const OOX::Logic::CMathPr &pMathPr) } void BinarySettingsTableWriter::WriteColorSchemeMapping(const PPTX::Logic::ClrMap& oColorSchemeMapping) { - int re_index[] = {0, 1, 2, 3, 4, 5, 10, 11, 6, 7, 8, 9, 10, 11, 10, 6, 7}; + int re_index[] = {0, 1, 2, 3, 4, 5, 10, 11, 6, 7, 9, 8, 10, 11, 10, 6, 7}; int nCurPos = 0; diff --git a/X2tConverter/src/ASCConverters.cpp b/X2tConverter/src/ASCConverters.cpp index 88226e7dd0..f4cdd3cccd 100644 --- a/X2tConverter/src/ASCConverters.cpp +++ b/X2tConverter/src/ASCConverters.cpp @@ -380,7 +380,7 @@ namespace NExtractTools } else if (AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCXF == *params.m_nFormatTo) { - std::wstring sCT = L""; + std::wstring sCT = L""; nRes = addContentType(sResultDocxDir, sCT); } } @@ -3598,7 +3598,7 @@ namespace NExtractTools } else if (AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCXF == nFormatTo) { - std::wstring sCT = L""; + std::wstring sCT = L""; nRes = addContentType(sFrom, sCT); } if(SUCCEEDED_X2T(nRes)) From 06052da3080c74099adc525baf7c8616f8b2518d Mon Sep 17 00:00:00 2001 From: Michael Efremov Date: Thu, 25 Nov 2021 16:37:57 +0300 Subject: [PATCH 05/12] [android] Fix bug 54053 --- X2tConverter/build/Android/libx2t/src/main/java/lib/x2t/X2t.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/X2tConverter/build/Android/libx2t/src/main/java/lib/x2t/X2t.kt b/X2tConverter/build/Android/libx2t/src/main/java/lib/x2t/X2t.kt index c947ee1a1a..26a674aaa8 100644 --- a/X2tConverter/build/Android/libx2t/src/main/java/lib/x2t/X2t.kt +++ b/X2tConverter/build/Android/libx2t/src/main/java/lib/x2t/X2t.kt @@ -266,7 +266,7 @@ class X2t private constructor() { { setIcuDataPath(icu) setFonts(arrayOf(fontsJs), fontsDir) - createXmlFileTransform(xml, key, mConvertType, from, to, temp, fontsJs, themes, password, + createXmlFileTransform(xml, key, mConvertType, from, to, temp, fontsDir, themes, password, delimiterCode.equals( InputParams.DELIMITER_CODE_NONE ).let { From cac9293d87099c7245339031e70a019575fabe03 Mon Sep 17 00:00:00 2001 From: "Elena.Subbotina" Date: Thu, 25 Nov 2021 22:20:08 +0300 Subject: [PATCH 06/12] fix bug #54116 --- .../src/docx/docx_conversion_context.cpp | 41 ++++++++++--------- .../src/docx/docx_conversion_context.h | 12 +++--- .../odf/style_paragraph_properties_docx.cpp | 13 +++--- .../src/odf/style_table_properties.cpp | 5 +-- ASCOfficeOdfFile/src/odf/text_elements.cpp | 23 ++++++++--- ASCOfficeOdfFile/win32/cpcommon.vcxproj | 8 ++-- ASCOfficeOdfFile/win32/cpodf.vcxproj | 16 +++++--- ASCOfficeOdfFile/win32/cpxml.vcxproj | 5 ++- .../win32/formulasconvert.vcxproj | 5 ++- .../source/win32/OdfFormat.vcxproj | 14 ++++--- .../source/win32/Oox2OdfConverter.vcxproj | 14 ++++--- 11 files changed, 91 insertions(+), 65 deletions(-) diff --git a/ASCOfficeOdfFile/src/docx/docx_conversion_context.cpp b/ASCOfficeOdfFile/src/docx/docx_conversion_context.cpp index 67c4d6413c..6103693e28 100644 --- a/ASCOfficeOdfFile/src/docx/docx_conversion_context.cpp +++ b/ASCOfficeOdfFile/src/docx/docx_conversion_context.cpp @@ -1210,7 +1210,7 @@ void docx_conversion_context::start_process_style_content() styles_context_.start(); } -void docx_conversion_context::process_section(std::wostream & strm, odf_reader::style_columns * columns)//from page layout +void docx_conversion_context::process_section(std::wostream & strm, odf_reader::style_columns *columns_page)//from page layout { if (root()->odf_context().pageLayoutContainer().linenumbering()) { @@ -1222,7 +1222,8 @@ void docx_conversion_context::process_section(std::wostream & strm, odf_reader:: oox::section_context::_section & section = get_section_context().get_last(); - if (!columns) + odf_reader::style_columns *columns = columns_page; + //if (!columns) { if (const odf_reader::style_instance * secStyle = root()->odf_context().styleContainer().style_by_name(section.style_, odf_types::style_family::Section, process_headers_footers_)) { @@ -1279,20 +1280,27 @@ void docx_conversion_context::process_section(std::wostream & strm, odf_reader:: } for (size_t i = 0; page_width > 0, i < columns->style_columns_.size(); i++) { - odf_reader::style_column * col = dynamic_cast( columns->style_columns_[i].get()); + odf_reader::style_column *col = dynamic_cast( columns->style_columns_[i].get()); if (!col) continue; - double width = page_width * (col->style_rel_width_ ? col->style_rel_width_->get_value() / 65535. : 0); + double percent = col->style_rel_width_ ? col->style_rel_width_->get_value() : 0; + if (percent > 1000.) percent /= 100.; - double space = col->fo_end_indent_ ? col->fo_end_indent_->get_value_unit(odf_types::length::pt) : 0; + double width = page_width * percent / 100.; + + double space_end = col->fo_end_indent_ ? col->fo_end_indent_->get_value_unit(odf_types::length::pt) : 0; + double space_start = col->fo_start_indent_ ? col->fo_start_indent_->get_value_unit(odf_types::length::pt) : 0; + + width -= space_end; + width -= space_start; if (i < columns->style_columns_.size() - 1) { col = dynamic_cast( columns->style_columns_[i + 1].get()); - space += col->fo_start_indent_ ? col->fo_start_indent_->get_value_unit(odf_types::length::pt) : 0; + space_start = col->fo_start_indent_ ? col->fo_start_indent_->get_value_unit(odf_types::length::pt) : 0; } - width_space.push_back(std::make_pair(width, space)); + width_space.push_back(std::make_pair(width, space_start + space_end)); } } } @@ -1467,12 +1475,12 @@ odf_reader::style_text_properties_ptr docx_conversion_context::current_text_prop return cur; } -void docx_conversion_context::set_page_break_after(bool val) +void docx_conversion_context::set_page_break_after(int val) { page_break_after_ = val; } -bool docx_conversion_context::get_page_break_after() +int docx_conversion_context::get_page_break_after() { return page_break_after_ ; } @@ -1484,12 +1492,12 @@ bool docx_conversion_context::get_page_break() { return page_break_; } -void docx_conversion_context::set_page_break_before(bool val) +void docx_conversion_context::set_page_break_before(int val) { page_break_before_ = val; } -bool docx_conversion_context::get_page_break_before() +int docx_conversion_context::get_page_break_before() { return page_break_before_; } @@ -1937,15 +1945,8 @@ void docx_conversion_context::process_page_break_after(const odf_reader::style_i _CP_OPT(odf_types::fo_break) fo_break_val = inst->content()->get_style_paragraph_properties()->content_.fo_break_after_; if (fo_break_val) { - if (fo_break_val->get_type() == odf_types::fo_break::Page) - { - set_page_break_after(true); - break; - } - else if (fo_break_val->get_type() == odf_types::fo_break::Auto) - { - break; - } + set_page_break_after(fo_break_val->get_type()); + break; } } inst = inst->parent(); diff --git a/ASCOfficeOdfFile/src/docx/docx_conversion_context.h b/ASCOfficeOdfFile/src/docx/docx_conversion_context.h index 34ad385c69..ea245d7f1c 100644 --- a/ASCOfficeOdfFile/src/docx/docx_conversion_context.h +++ b/ASCOfficeOdfFile/src/docx/docx_conversion_context.h @@ -853,11 +853,11 @@ public: odf_reader::style_text_properties_ptr current_text_properties(); - void set_page_break_after(bool val); - bool get_page_break_after(); + void set_page_break_after(int val); + int get_page_break_after(); - void set_page_break_before(bool val); - bool get_page_break_before(); + void set_page_break_before(int val); + int get_page_break_before(); void set_page_break (bool val); bool get_page_break (); @@ -1044,8 +1044,8 @@ private: bool first_element_list_item_; - bool page_break_after_; - bool page_break_before_; + int page_break_after_; // 0 = false, 1 - column, 2 -page + int page_break_before_; bool page_break_; bool in_automatic_style_; diff --git a/ASCOfficeOdfFile/src/odf/style_paragraph_properties_docx.cpp b/ASCOfficeOdfFile/src/odf/style_paragraph_properties_docx.cpp index e353ba5520..e23021ac4f 100644 --- a/ASCOfficeOdfFile/src/odf/style_paragraph_properties_docx.cpp +++ b/ASCOfficeOdfFile/src/odf/style_paragraph_properties_docx.cpp @@ -284,9 +284,9 @@ void paragraph_format_properties::docx_convert(oox::docx_conversion_context & Co CP_XML_NODE(L"w:textAlignment"){CP_XML_ATTR(L"w:val", L"baseline");} } - if (Context.get_page_break_before()) + if (Context.get_page_break_before() == 2) { - Context.set_page_break_before(false); + Context.set_page_break_before(0); CP_XML_NODE(L"w:pageBreakBefore"){CP_XML_ATTR(L"w:val", L"true"); } } else if (fo_break_before_) @@ -296,6 +296,8 @@ void paragraph_format_properties::docx_convert(oox::docx_conversion_context & Co val = L"false"; else if (fo_break_before_->get_type() == fo_break::Page) val = L"true"; + else + Context.set_page_break_before(fo_break_before_->get_type()); if (!val.empty()) CP_XML_NODE(L"w:pageBreakBefore"){CP_XML_ATTR(L"w:val", val);} @@ -466,12 +468,9 @@ void paragraph_format_properties::docx_convert(oox::docx_conversion_context & Co } } } - if (fo_break_after_ && fo_break_after_->get_type() == fo_break::Page) + if (fo_break_after_ && Context.in_automatic_style()) { - if (Context.in_automatic_style()) - { - Context.set_page_break_after(true); - } + Context.set_page_break_after(fo_break_after_->get_type()); } Context.get_tabs_context().docx_convert(Context); diff --git a/ASCOfficeOdfFile/src/odf/style_table_properties.cpp b/ASCOfficeOdfFile/src/odf/style_table_properties.cpp index 6ff8473f42..8f36f97ebf 100644 --- a/ASCOfficeOdfFile/src/odf/style_table_properties.cpp +++ b/ASCOfficeOdfFile/src/odf/style_table_properties.cpp @@ -115,9 +115,8 @@ void table_format_properties::docx_convert(oox::docx_conversion_context & Contex if (common_break_attlist_.fo_break_before_) { - if (common_break_attlist_.fo_break_before_->get_type() == fo_break::Page) - Context.set_page_break_before(true); - } + Context.set_page_break_before(common_break_attlist_.fo_break_before_->get_type()); + } if (table_align_) { diff --git a/ASCOfficeOdfFile/src/odf/text_elements.cpp b/ASCOfficeOdfFile/src/odf/text_elements.cpp index 7e8c88003c..d00f840322 100644 --- a/ASCOfficeOdfFile/src/odf/text_elements.cpp +++ b/ASCOfficeOdfFile/src/odf/text_elements.cpp @@ -349,7 +349,18 @@ void paragraph::docx_convert(oox::docx_conversion_context & Context, _CP_OPT(std int textStyle = Context.process_paragraph_attr(&attrs_); Context.add_note_reference(); + + int break_ = Context.get_page_break_before(); + if (break_ > 0) + { + Context.set_page_break_before(0); + is_empty = false; + Context.add_new_run(_T("")); + if (break_ == 1) Context.output_stream() << L""; + else if (break_ == 2) Context.output_stream() << L""; + Context.finish_run(); + } for (size_t i = index; i < content_.size(); i++) { if (Context.get_page_break()) @@ -396,14 +407,16 @@ void paragraph::docx_convert(oox::docx_conversion_context & Context, _CP_OPT(std Context.docx_convert_delayed(); } - if (Context.get_page_break_after()) + break_ = Context.get_page_break_after(); + if (break_ > 0) { - Context.set_page_break_after(false); + Context.set_page_break_after(0); is_empty = false; Context.add_new_run(_T("")); - Context.output_stream() << L""; - Context.finish_run(); + if (break_ == 1) Context.output_stream() << L""; + else if (break_ == 2) Context.output_stream() << L""; + Context.finish_run(); } if (is_empty) @@ -439,7 +452,7 @@ void soft_page_break::docx_convert(oox::docx_conversion_context & Context) if (Context.process_headers_footers_) return; - if (!Context.get_page_break_after() && !Context.get_page_break_before()) + if (0 == Context.get_page_break_after() && 0 == Context.get_page_break_before()) { Context.output_stream() << L""; } diff --git a/ASCOfficeOdfFile/win32/cpcommon.vcxproj b/ASCOfficeOdfFile/win32/cpcommon.vcxproj index 3922d4b125..45e8590ac8 100644 --- a/ASCOfficeOdfFile/win32/cpcommon.vcxproj +++ b/ASCOfficeOdfFile/win32/cpcommon.vcxproj @@ -75,8 +75,8 @@ $(Platform)\$(Configuration)\ $(Platform)\$(Configuration)\ - $(VC_IncludePath);$(WindowsSDK_IncludePath);D:\_Work\core\Common\3dParty\boost\build\win_64\include; - $(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64);$(NETFXKitsDir)Lib\um\x64;D:\_Work\core\Common\3dParty\boost\build\win_64\lib; + D:\_Work\core\Common\3dParty\boost\build\win_64\include;$(IncludePath) + D:\_Work\core\Common\3dParty\boost\build\win_64\lib;$(LibraryPath) $(Configuration)\ @@ -89,7 +89,7 @@ Disabled - ..\include;..\src\odf\datatypes;..\..\DesktopEditor\freetype-2.5.2\include;%(AdditionalIncludeDirectories) + ..\include;..\src\odf\datatypes;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) true EnableFastChecks @@ -110,7 +110,7 @@ Disabled - ../include;../src/odf/datatypes;%(AdditionalIncludeDirectories) + ..\include;..\src\odf\datatypes;%(AdditionalIncludeDirectories) _DEBUG;_CONSOLE;%(PreprocessorDefinitions) true EnableFastChecks diff --git a/ASCOfficeOdfFile/win32/cpodf.vcxproj b/ASCOfficeOdfFile/win32/cpodf.vcxproj index 4b7c0ecd85..9412062bbd 100644 --- a/ASCOfficeOdfFile/win32/cpodf.vcxproj +++ b/ASCOfficeOdfFile/win32/cpodf.vcxproj @@ -75,6 +75,8 @@ $(Platform)\$(Configuration)\ $(Platform)\$(Configuration)\ + D:\_Work\core\Common\3dParty\boost\build\win_64\include;$(IncludePath) + D:\_Work\core\Common\3dParty\boost\build\win_64\lib;$(LibraryPath) $(Configuration)\ @@ -87,7 +89,7 @@ Disabled - ..\include;..\..\DesktopEditor\freetype-2.5.2\include;..\..\DesktopEditor\xml\libxml2\include;%(AdditionalIncludeDirectories) + ..\include;..\..\DesktopEditor\xml\libxml2\include;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_CONSOLE;USE_LITE_READER;_USE_XMLLITE_READER_;_USE_LIBXML2_READER_;LIBXML_READER_ENABLED;%(PreprocessorDefinitions) true EnableFastChecks @@ -108,8 +110,8 @@ Disabled - ../include;../../../DesktopEditor/freetype-2.5.2/include;%(AdditionalIncludeDirectories) - _DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + ..\include;..\..\DesktopEditor\xml\libxml2\include;%(AdditionalIncludeDirectories) + _DEBUG;_CONSOLE;USE_LITE_READER;_USE_XMLLITE_READER_;_USE_LIBXML2_READER_;LIBXML_READER_ENABLED;%(PreprocessorDefinitions) true EnableFastChecks MultiThreadedDebugDLL @@ -358,7 +360,9 @@ - + + /bigobj %(AdditionalOptions) + @@ -368,7 +372,9 @@ - + + /bigobj %(AdditionalOptions) + diff --git a/ASCOfficeOdfFile/win32/cpxml.vcxproj b/ASCOfficeOdfFile/win32/cpxml.vcxproj index 4a5089d9b4..68d625d44d 100644 --- a/ASCOfficeOdfFile/win32/cpxml.vcxproj +++ b/ASCOfficeOdfFile/win32/cpxml.vcxproj @@ -75,6 +75,8 @@ $(Platform)\$(Configuration)\ $(Platform)\$(Configuration)\ + D:\_Work\core\Common\3dParty\boost\build\win_64\include;$(IncludePath) + D:\_Work\core\Common\3dParty\boost\build\win_64\lib;$(LibraryPath) $(Configuration)\ @@ -108,7 +110,7 @@ Disabled - _DEBUG;_CONSOLE;USE_LITE_READER;_USE_XMLLITE_READER_;_USE_LIBXML2_READER_;LIBXML_READER_ENABLED;%(PreprocessorDefinitions) + WIN32;_DEBUG;_CONSOLE;USE_LITE_READER;_USE_XMLLITE_READER_;_USE_LIBXML2_READER_;LIBXML_READER_ENABLED;%(PreprocessorDefinitions) true EnableFastChecks MultiThreadedDebugDLL @@ -117,6 +119,7 @@ Level3 ProgramDatabase 4311;4267;4996;4172;%(DisableSpecificWarnings) + ../../DesktopEditor/xml/libxml2/include;../../DesktopEditor/xml/build/vs2005;%(AdditionalIncludeDirectories) $(OutDir)$(ProjectName).lib diff --git a/ASCOfficeOdfFile/win32/formulasconvert.vcxproj b/ASCOfficeOdfFile/win32/formulasconvert.vcxproj index b79cbb3340..8cec430429 100644 --- a/ASCOfficeOdfFile/win32/formulasconvert.vcxproj +++ b/ASCOfficeOdfFile/win32/formulasconvert.vcxproj @@ -74,8 +74,8 @@ $(Platform)\$(Configuration)\ $(Platform)\$(Configuration)\ - $(VC_IncludePath);$(WindowsSDK_IncludePath);D:\_Work\core\Common\3dParty\boost\build\win_64\include; - $(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64);$(NETFXKitsDir)Lib\um\x64;D:\_Work\core\Common\3dParty\boost\build\win_64\lib; + D:\_Work\core\Common\3dParty\boost\build\win_64\include;$(IncludePath) + D:\_Work\core\Common\3dParty\boost\build\win_64\lib;$(LibraryPath) $(Configuration)\ @@ -112,6 +112,7 @@ Level3 ProgramDatabase 4311;4267;4996;4172;%(DisableSpecificWarnings) + ..\include;%(AdditionalIncludeDirectories) $(OutDir)$(ProjectName).lib diff --git a/ASCOfficeOdfFileW/source/win32/OdfFormat.vcxproj b/ASCOfficeOdfFileW/source/win32/OdfFormat.vcxproj index ec5a149170..05cf4239e8 100644 --- a/ASCOfficeOdfFileW/source/win32/OdfFormat.vcxproj +++ b/ASCOfficeOdfFileW/source/win32/OdfFormat.vcxproj @@ -75,8 +75,8 @@ $(Platform)\$(Configuration)\ $(Platform)\$(Configuration)\ - $(VC_IncludePath);$(WindowsSDK_IncludePath);D:\_Work\core\Common\3dParty\boost\build\win_64\include; - $(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64);$(NETFXKitsDir)Lib\um\x64;D:\_Work\core\Common\3dParty\boost\build\win_64\lib; + D:\_Work\core\Common\3dParty\boost\build\win_64\include;$(IncludePath) + D:\_Work\core\Common\3dParty\boost\build\win_64\lib;$(LibraryPath) $(Configuration)\ @@ -89,7 +89,7 @@ Disabled - ..\..\..\ASCOfficeOdfFile\include;..\..\..\ASCOfficeOdfFile\src\odf\datatypes;..\..\..\DesktopEditor\freetype-2.5.2\include;%(AdditionalIncludeDirectories) + ..\..\..\ASCOfficeOdfFile\include;..\..\..\ASCOfficeOdfFile\src\odf\datatypes;%(AdditionalIncludeDirectories) _DEBUG;_LIB;DONT_WRITE_EMBEDDED_FONTS;%(PreprocessorDefinitions) true EnableFastChecks @@ -107,8 +107,8 @@ Disabled - ../../../ASCOfficeOdfFile/include;../../../ASCOfficeOdfFile/src/odf/datatypes;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + ..\..\..\ASCOfficeOdfFile\include;..\..\..\ASCOfficeOdfFile\src\odf\datatypes;%(AdditionalIncludeDirectories) + _DEBUG;_LIB;DONT_WRITE_EMBEDDED_FONTS;%(PreprocessorDefinitions) true EnableFastChecks MultiThreadedDebugDLL @@ -188,7 +188,9 @@ - + + /bigobj %(AdditionalOptions) + diff --git a/ASCOfficeOdfFileW/source/win32/Oox2OdfConverter.vcxproj b/ASCOfficeOdfFileW/source/win32/Oox2OdfConverter.vcxproj index b2cf8a1027..933f6aaeff 100644 --- a/ASCOfficeOdfFileW/source/win32/Oox2OdfConverter.vcxproj +++ b/ASCOfficeOdfFileW/source/win32/Oox2OdfConverter.vcxproj @@ -74,8 +74,8 @@ $(Platform)\$(Configuration)\ $(Platform)\$(Configuration)\ - $(VC_IncludePath);$(WindowsSDK_IncludePath);D:\_Work\core\Common\3dParty\boost\build\win_64\include; - $(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64);$(NETFXKitsDir)Lib\um\x64;D:\_Work\core\Common\3dParty\boost\build\win_64\lib; + D:\_Work\core\Common\3dParty\boost\build\win_64\include;$(IncludePath) + D:\_Work\core\Common\3dParty\boost\build\win_64\lib;$(LibraryPath) $(Configuration)\ @@ -88,7 +88,7 @@ Disabled - ..\..\..\ASCOfficeOdfFile\include;..\..\..\ASCOfficeOdfFile\src\odf\datatypes;..\..\..\DesktopEditor\freetype-2.5.2\include;%(AdditionalIncludeDirectories) + ..\..\..\ASCOfficeOdfFile\include;..\..\..\ASCOfficeOdfFile\src\odf\datatypes;%(AdditionalIncludeDirectories) NDEBUG;_LIB;_USE_XMLLITE_READER_;USE_LITE_READER;_USE_LIBXML2_READER_;LIBXML_READER_ENABLED;DONT_WRITE_EMBEDDED_FONTS;%(PreprocessorDefinitions) true EnableFastChecks @@ -106,8 +106,8 @@ Disabled - ../../../ASCOfficeOdfFile/include;../../../ASCOfficeOdfFile/src/odf/datatypes;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_LIB;_USE_LIBXML2_READER_;LIBXML_READER_ENABLED;DONT_WRITE_EMBEDDED_FONTS;%(PreprocessorDefinitions) + ..\..\..\ASCOfficeOdfFile\include;..\..\..\ASCOfficeOdfFile\src\odf\datatypes;%(AdditionalIncludeDirectories) + NDEBUG;_LIB;_USE_XMLLITE_READER_;USE_LITE_READER;_USE_LIBXML2_READER_;LIBXML_READER_ENABLED;DONT_WRITE_EMBEDDED_FONTS;%(PreprocessorDefinitions) true EnableFastChecks MultiThreadedDebugDLL @@ -144,7 +144,9 @@ - + + /bigobj %(AdditionalOptions) + From 978d80e19843c89a8bcf7c36c54adac3b1be3385 Mon Sep 17 00:00:00 2001 From: KirillovIlya Date: Fri, 26 Nov 2021 11:00:10 +0300 Subject: [PATCH 07/12] Fix reading strings in pdf to xml conversion --- PdfReader/Src/Object.cpp | 22 ++++++++++++++++++++-- PdfReader/Src/Object.h | 1 + PdfReader/Src/PDFDoc.cpp | 2 +- PdfReader/Src/XRef.cpp | 7 +++++-- 4 files changed, 27 insertions(+), 5 deletions(-) diff --git a/PdfReader/Src/Object.cpp b/PdfReader/Src/Object.cpp index 137d24ec48..115a22cfda 100644 --- a/PdfReader/Src/Object.cpp +++ b/PdfReader/Src/Object.cpp @@ -249,10 +249,17 @@ namespace PdfReader wsXml += std::to_wstring(m_uReal); break; case objString: - wsXml += L"("; - wsXml += m_uStringExt->GetWString(); + { + wsXml += L"("; + std::wstring wsValue = m_uStringExt->GetWString(); + ReplaceAll(wsValue, L"\"", L"""); + ReplaceAll(wsValue, L"&", L"&"); + ReplaceAll(wsValue, L"<", L"<"); + ReplaceAll(wsValue, L">", L">"); + wsXml += wsValue; wsXml += L")"; break; + } case objName: wsXml += L"/"; AppendStringToXml(wsXml, m_uName); @@ -318,6 +325,17 @@ namespace PdfReader wsXml += wsTmp; } + void Object::ReplaceAll(std::wstring& wsString, const std::wstring& wsFrom, const std::wstring& wsTo) + { + size_t nStartPos = 0; + while((nStartPos = wsString.find(wsFrom, nStartPos)) != std::wstring::npos) + { + wsString.replace(nStartPos, wsFrom.length(), wsTo); + nStartPos += wsTo.length(); + } + } + + //------------------------------------------------------------------------ // Array accessors. //------------------------------------------------------------------------ diff --git a/PdfReader/Src/Object.h b/PdfReader/Src/Object.h index 44e18485fc..7ede7327ed 100644 --- a/PdfReader/Src/Object.h +++ b/PdfReader/Src/Object.h @@ -382,6 +382,7 @@ namespace PdfReader void Print(FILE *pFile = stdout); void ToXml(std::wstring& wsXml); static void AppendStringToXml(std::wstring& wsXml, const std::string& sString); + static void ReplaceAll(std::wstring& wsString, const std::wstring& wsFrom, const std::wstring& wsTo); private: diff --git a/PdfReader/Src/PDFDoc.cpp b/PdfReader/Src/PDFDoc.cpp index 50577277bb..d8bf9e4c3f 100644 --- a/PdfReader/Src/PDFDoc.cpp +++ b/PdfReader/Src/PDFDoc.cpp @@ -353,7 +353,7 @@ namespace PdfReader std::wstring wsXml; wsXml = L""; - m_pXref->AllObjectsToXml(wsXml, false); + m_pXref->AllObjectsToXml(wsXml, true); wsXml += L""; return wsXml; diff --git a/PdfReader/Src/XRef.cpp b/PdfReader/Src/XRef.cpp index 3459d19103..4b3da4dd1d 100644 --- a/PdfReader/Src/XRef.cpp +++ b/PdfReader/Src/XRef.cpp @@ -1125,9 +1125,12 @@ namespace PdfReader Stream* pStream = oTemp.GetStream(); pStream->Reset(); - Object oFilter; + Object oFilter, oTempArray; + Array* pArray = NULL; pStreamDict->Search("Filter", &oFilter); - if (oFilter.IsNull() || oFilter.IsName("FlateDecode")) + if (oFilter.IsNull() + || oFilter.IsName("FlateDecode") + || (oFilter.IsArray() && (pArray = oFilter.GetArray()) && 1 == pArray->GetCount() && pArray->Get(0, &oTempArray) && oTempArray.IsName("FlateDecode"))) { int nChar; while (EOF != (nChar = pStream->GetChar())) From c051240cd4af2e9e793990cf5ec8c1281736d476 Mon Sep 17 00:00:00 2001 From: Ivan Date: Fri, 26 Nov 2021 13:39:08 +0300 Subject: [PATCH 08/12] fix bug #54032 --- ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.cpp b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.cpp index aa13d37874..a46c248737 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.cpp @@ -328,7 +328,7 @@ void TxBodyConverter::ConvertPFRun(PPTX::Logic::TextParagraphPr &oPPr, CTextPFRu if (val > 0) pSpcBef->spcPts = round(12.5 * pPF->spaceBefore.get()); else if (val < 0 && val > -13200) - pSpcBef->spcPts = val * -1000; + pSpcBef->spcPct = val * -1000; oPPr.spcBef = pSpcBef; } From 92d8d9ad057607eb6732f4d7c74b57935af4466a Mon Sep 17 00:00:00 2001 From: Ivan Date: Fri, 26 Nov 2021 15:04:41 +0300 Subject: [PATCH 09/12] fix bug #54031 --- .../PPTFormatLib/PPTXWriter/ShapeWriter.cpp | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/ShapeWriter.cpp b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/ShapeWriter.cpp index 3723b89575..92d0694c1c 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/ShapeWriter.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/ShapeWriter.cpp @@ -1402,7 +1402,6 @@ void PPT_FORMAT::CShapeWriter::WriteTextInfo() } m_oWriter.WriteString(std::wstring(L"/>")); } - bool donotNeedBullet = true; if (pPF->bulletAutoNum.is_init() && !pPF->bulletChar.is_init()) { m_oWriter.WriteString(L""); - donotNeedBullet = true; } if (pPF->bulletBlip.is_init() && pPF->bulletBlip->tmpImagePath.size()) { @@ -1426,7 +1424,6 @@ void PPT_FORMAT::CShapeWriter::WriteTextInfo() m_oWriter.WriteString(L""); - donotNeedBullet = true; } bool set = true; @@ -1446,14 +1443,9 @@ void PPT_FORMAT::CShapeWriter::WriteTextInfo() set = true; } - if (!set && !donotNeedBullet) + if (!set) { - if (pPF->hasBullet.is_init() && *(pPF->hasBullet) && !pPF->bulletChar.is_init()) - { - m_oWriter.WriteString(L""); - } else + if (pPF->hasBullet.is_init() && *(pPF->hasBullet)) { wchar_t bu = 0x2022; m_oWriter.WriteString(std::wstring(L" Date: Sat, 27 Nov 2021 11:38:55 +0300 Subject: [PATCH 10/12] fix bug #54148 fix ppt project --- .../PPTFormatLib/Linux/PPTFormatLib.pro | 25 +++++---- .../PPTFormatLib/Linux/pptformatlib_logic.cpp | 15 +++-- .../PPTFormatLib/Win32/PPTFormatLib.vcxproj | 1 + .../Win32/PPTFormatLib.vcxproj.filters | 3 + Common/OfficeFileFormatChecker.h | 5 +- Common/OfficeFileFormatChecker2.cpp | 56 +++++++++++++------ Common/OfficeFileFormats.h | 1 + OfficeCryptReader/source/ECMACryptFile.cpp | 7 +++ 8 files changed, 79 insertions(+), 34 deletions(-) diff --git a/ASCOfficePPTFile/PPTFormatLib/Linux/PPTFormatLib.pro b/ASCOfficePPTFile/PPTFormatLib/Linux/PPTFormatLib.pro index 20ff7c9ded..22adc1de2b 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Linux/PPTFormatLib.pro +++ b/ASCOfficePPTFile/PPTFormatLib/Linux/PPTFormatLib.pro @@ -273,26 +273,27 @@ SOURCES += \ core_debug { SOURCES += \ + ../Enums/RecordType.cpp \ + ../PPTFormatLib.cpp \ ../Reader/ReadStructures.cpp \ + ../Reader/RoundTripExtractor.cpp \ ../Reader/PPTDocumentInfoOneUser.cpp \ ../Reader/Records.cpp \ ../Reader/PPTFileReader.cpp \ ../Reader/SlidePersist.cpp \ - ../Records/Drawing/ArtBlip.cpp \ - ../Records/Drawing/ShapeContainer.cpp \ ../PPTXWriter/Converter.cpp \ - ../PPTXWriter/ShapeWriter.cpp -} - -SOURCES += \ - ../Enums/RecordType.cpp \ - ../PPTFormatLib.cpp \ - ../../../ASCOfficePPTXFile/Editor/Drawing/Elements.cpp \ - ../../../ASCOfficePPTXFile/Editor/Drawing/TextAttributesEx.cpp \ - ../../../Common/3dParty/pole/pole.cpp \ + ../PPTXWriter/ShapeWriter.cpp \ ../PPTXWriter/Animation.cpp \ ../PPTXWriter/TableWriter.cpp \ ../PPTXWriter/TxBodyConverter.cpp \ - ../Reader/RoundTripExtractor.cpp \ + ../Records/Drawing/ArtBlip.cpp \ + ../Records/Drawing/ShapeContainer.cpp \ ../Records/Animations/TimeVariant.cpp \ ../Records/BlipEntityAtom.cpp +} + +SOURCES += \ + ../../../ASCOfficePPTXFile/Editor/Drawing/Elements.cpp \ + ../../../ASCOfficePPTXFile/Editor/Drawing/TextAttributesEx.cpp \ + ../../../Common/3dParty/pole/pole.cpp + diff --git a/ASCOfficePPTFile/PPTFormatLib/Linux/pptformatlib_logic.cpp b/ASCOfficePPTFile/PPTFormatLib/Linux/pptformatlib_logic.cpp index 370f6c0814..745c7fbae9 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Linux/pptformatlib_logic.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/Linux/pptformatlib_logic.cpp @@ -30,13 +30,20 @@ * */ +#include "../Enums/RecordType.cpp" +#include "../PPTFormatLib.cpp" #include "../Reader/ReadStructures.cpp" +#include "../Reader/RoundTripExtractor.cpp" #include "../Reader/PPTDocumentInfoOneUser.cpp" -#include "../Reader/PPTFileReader.cpp" #include "../Reader/Records.cpp" +#include "../Reader/PPTFileReader.cpp" #include "../Reader/SlidePersist.cpp" -//#include "../Records/Animations/AnimationTypes.cpp" -#include "../Records/Drawing/ArtBlip.cpp" -#include "../Records/Drawing/ShapeContainer.cpp" #include "../PPTXWriter/Converter.cpp" #include "../PPTXWriter/ShapeWriter.cpp" +#include "../PPTXWriter/Animation.cpp" +#include "../PPTXWriter/TableWriter.cpp" +#include "../PPTXWriter/TxBodyConverter.cpp" +#include "../Records/Drawing/ArtBlip.cpp" +#include "../Records/Drawing/ShapeContainer.cpp" +#include "../Records/Animations/TimeVariant.cpp" +#include "../Records/BlipEntityAtom.cpp" diff --git a/ASCOfficePPTFile/PPTFormatLib/Win32/PPTFormatLib.vcxproj b/ASCOfficePPTFile/PPTFormatLib/Win32/PPTFormatLib.vcxproj index cca4b0e3d1..85beed3274 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Win32/PPTFormatLib.vcxproj +++ b/ASCOfficePPTFile/PPTFormatLib/Win32/PPTFormatLib.vcxproj @@ -507,6 +507,7 @@ + diff --git a/ASCOfficePPTFile/PPTFormatLib/Win32/PPTFormatLib.vcxproj.filters b/ASCOfficePPTFile/PPTFormatLib/Win32/PPTFormatLib.vcxproj.filters index 91f870a858..9d33fa2602 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Win32/PPTFormatLib.vcxproj.filters +++ b/ASCOfficePPTFile/PPTFormatLib/Win32/PPTFormatLib.vcxproj.filters @@ -856,5 +856,8 @@ Reader + + Records + \ No newline at end of file diff --git a/Common/OfficeFileFormatChecker.h b/Common/OfficeFileFormatChecker.h index 766f619d05..328fcd7543 100644 --- a/Common/OfficeFileFormatChecker.h +++ b/Common/OfficeFileFormatChecker.h @@ -71,8 +71,9 @@ public: bool isDocFormatFile (POLE::Storage *storage); bool isXlsFormatFile (POLE::Storage *storage); bool isPptFormatFile (POLE::Storage *storage); - bool isMS_OFFCRYPTOFormatFile (POLE::Storage * storage, std::wstring & documentID); - bool isMS_OFFCRYPTOFormatFile (const std::wstring & fileName, std::wstring & documentID); + bool isMS_OFFICECRYPTOFormatFile(POLE::Storage * storage, std::wstring & documentID); + bool isMS_MITCRYPTOFormatFile(POLE::Storage * storage, std::wstring & documentID); + bool isMS_OFFCRYPTOFormatFile (const std::wstring & fileName, std::wstring & documentID); std::wstring getDocumentID (const std::wstring & fileName); diff --git a/Common/OfficeFileFormatChecker2.cpp b/Common/OfficeFileFormatChecker2.cpp index 6b21ea7025..96090dfd53 100644 --- a/Common/OfficeFileFormatChecker2.cpp +++ b/Common/OfficeFileFormatChecker2.cpp @@ -274,10 +274,14 @@ std::wstring COfficeFileFormatChecker::getDocumentID (const std::wstring & _file POLE::Storage storage(fileName.c_str()); if (storage.open()) { - if ( isMS_OFFCRYPTOFormatFile(&storage, documentID) ) + if ( isMS_OFFICECRYPTOFormatFile(&storage, documentID) ) { nFileType = AVS_OFFICESTUDIO_FILE_OTHER_MS_OFFCRYPTO; } + else if (isMS_MITCRYPTOFormatFile(&storage, documentID)) + { + nFileType = AVS_OFFICESTUDIO_FILE_OTHER_MS_MITCRYPTO; + } } else { @@ -316,37 +320,36 @@ bool COfficeFileFormatChecker::isMS_OFFCRYPTOFormatFile (const std::wstring & _f POLE::Storage storage(fileName.c_str()); if (storage.open()) { - if ( isMS_OFFCRYPTOFormatFile(&storage, documentID) ) + if (isMS_OFFICECRYPTOFormatFile(&storage, documentID) ) { nFileType = AVS_OFFICESTUDIO_FILE_OTHER_MS_OFFCRYPTO; return true; } + if (isMS_MITCRYPTOFormatFile(&storage, documentID)) + { + nFileType = AVS_OFFICESTUDIO_FILE_OTHER_MS_MITCRYPTO; + return true; + } } return false; } - -bool COfficeFileFormatChecker::isMS_OFFCRYPTOFormatFile (POLE::Storage * storage, std::wstring & documentID) +bool COfficeFileFormatChecker::isMS_OFFICECRYPTOFormatFile(POLE::Storage * storage, std::wstring & documentID) { - if (storage == NULL) return false; + if (storage == NULL) return false; documentID.clear(); bool result = false; - std::list entries = storage->entries(L"DataSpaces"); - if (entries.size() > 0) + std::list entries = storage->entries(L"DataSpaces"); + if (/*false == entries.empty() && */storage->exists(L"EncryptionInfo")) { - result = true; + result = true; } - if ( storage->exists(L"EncryptionInfo") && - storage->exists(L"EncryptedPackage")) - { - result = true; - } if (result) { - POLE::Stream stream(storage, L"DocumentID"); - + POLE::Stream stream(storage, L"DocumentID"); + std::string sData; sData.resize(stream.size()); if (stream.read((BYTE*)sData.c_str(), stream.size()) > 0) @@ -357,6 +360,22 @@ bool COfficeFileFormatChecker::isMS_OFFCRYPTOFormatFile (POLE::Storage * storage } return result; } + +bool COfficeFileFormatChecker::isMS_MITCRYPTOFormatFile (POLE::Storage * storage, std::wstring & documentID) +{ + if (storage == NULL) return false; + + documentID.clear(); + + bool result = false; + std::list entries = storage->entries(L"DataSpaces"); + if (false == entries.empty() && false == storage->exists(L"EncryptionInfo") && storage->exists(L"EncryptedPackage")) + { + result = true; + } + + return result; +} bool COfficeFileFormatChecker::isOfficeFile(const std::wstring & _fileName) { #if defined(_WIN32) || defined(_WIN32_WCE) || defined(_WIN64) @@ -396,11 +415,16 @@ bool COfficeFileFormatChecker::isOfficeFile(const std::wstring & _fileName) nFileType = AVS_OFFICESTUDIO_FILE_PRESENTATION_PPT; return true; } - else if ( isMS_OFFCRYPTOFormatFile(&storage, sDocumentID) ) + else if ( isMS_OFFICECRYPTOFormatFile(&storage, sDocumentID) ) { nFileType = AVS_OFFICESTUDIO_FILE_OTHER_MS_OFFCRYPTO; return true; } + else if (isMS_MITCRYPTOFormatFile(&storage, sDocumentID)) + { + nFileType = AVS_OFFICESTUDIO_FILE_OTHER_MS_MITCRYPTO; + return true; + } } COfficeUtils OfficeUtils(NULL); diff --git a/Common/OfficeFileFormats.h b/Common/OfficeFileFormats.h index 1d402787ec..be7faab306 100644 --- a/Common/OfficeFileFormats.h +++ b/Common/OfficeFileFormats.h @@ -119,6 +119,7 @@ #define AVS_OFFICESTUDIO_FILE_OTHER_JSON AVS_OFFICESTUDIO_FILE_OTHER + 0x0008 // Для mail-merge #define AVS_OFFICESTUDIO_FILE_OTHER_ZIP AVS_OFFICESTUDIO_FILE_OTHER + 0x0009 #define AVS_OFFICESTUDIO_FILE_OTHER_ODF AVS_OFFICESTUDIO_FILE_OTHER + 0x000a +#define AVS_OFFICESTUDIO_FILE_OTHER_MS_MITCRYPTO AVS_OFFICESTUDIO_FILE_OTHER + 0x000b #define AVS_OFFICESTUDIO_FILE_TEAMLAB 0x1000 #define AVS_OFFICESTUDIO_FILE_TEAMLAB_DOCY AVS_OFFICESTUDIO_FILE_TEAMLAB + 0x0001 diff --git a/OfficeCryptReader/source/ECMACryptFile.cpp b/OfficeCryptReader/source/ECMACryptFile.cpp index 0e1fdd792a..89e2301f8f 100644 --- a/OfficeCryptReader/source/ECMACryptFile.cpp +++ b/OfficeCryptReader/source/ECMACryptFile.cpp @@ -946,6 +946,12 @@ bool ECMACryptFile::DecryptOfficeFile(const std::wstring &file_name_inp, const s if (pStream) { + if (pStream->fail()) + { + delete pStream; + delete pStorage; + return false; + } _UINT16 VersionInfoMajor = 0, VersionInfoMinor = 0; pStream->read((unsigned char*)&VersionInfoMajor, 2); @@ -963,6 +969,7 @@ bool ECMACryptFile::DecryptOfficeFile(const std::wstring &file_name_inp, const s return false; } nEncryptionInfoSize = pStream->read(byteEncryptionInfo, nEncryptionInfoSize); + delete pStream; if (VersionInfoMajor == 0x0004 && VersionInfoMinor == 0x0004) From 046e0f77107097d8e19917d29cc924c963346cc3 Mon Sep 17 00:00:00 2001 From: Sergey Konovalov Date: Sun, 28 Nov 2021 18:48:07 +0300 Subject: [PATCH 11/12] [x2t] Fix saving to docxf --- X2tConverter/src/ASCConverters.cpp | 8 ++++++-- X2tConverter/src/cextracttools.h | 4 ---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/X2tConverter/src/ASCConverters.cpp b/X2tConverter/src/ASCConverters.cpp index f4cdd3cccd..2c9872c42c 100644 --- a/X2tConverter/src/ASCConverters.cpp +++ b/X2tConverter/src/ASCConverters.cpp @@ -3024,6 +3024,8 @@ namespace NExtractTools case AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCM: case AVS_OFFICESTUDIO_FILE_DOCUMENT_DOTX: case AVS_OFFICESTUDIO_FILE_DOCUMENT_DOTM: + case AVS_OFFICESTUDIO_FILE_DOCUMENT_OFORM: + case AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCXF: { return docx2doct_bin(sResultDecryptFile, sTo, sTemp, params); }break; @@ -3767,7 +3769,8 @@ namespace NExtractTools } else if(AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCM == nFormatFrom) { - if(AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX == nFormatTo || AVS_OFFICESTUDIO_FILE_DOCUMENT_DOTX == nFormatTo) + if (AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX == nFormatTo || AVS_OFFICESTUDIO_FILE_DOCUMENT_DOTX == nFormatTo + || AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCXF == nFormatTo || AVS_OFFICESTUDIO_FILE_DOCUMENT_OFORM == nFormatTo) { nRes = docm2docx_dir(sFrom, sDocxDir, params); } @@ -3782,7 +3785,8 @@ namespace NExtractTools } else if(AVS_OFFICESTUDIO_FILE_DOCUMENT_DOTM == nFormatFrom) { - if(AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX == nFormatTo || AVS_OFFICESTUDIO_FILE_DOCUMENT_DOTX == nFormatTo) + if (AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX == nFormatTo || AVS_OFFICESTUDIO_FILE_DOCUMENT_DOTX == nFormatTo + || AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCXF == nFormatTo || AVS_OFFICESTUDIO_FILE_DOCUMENT_OFORM == nFormatTo) { nRes = dotm2docx_dir(sFrom, sDocxDir, params); } diff --git a/X2tConverter/src/cextracttools.h b/X2tConverter/src/cextracttools.h index b1bf0ec578..91da987362 100644 --- a/X2tConverter/src/cextracttools.h +++ b/X2tConverter/src/cextracttools.h @@ -1086,10 +1086,6 @@ namespace NExtractTools else m_sFileTo->append(FileFormatChecker.GetExtensionByType(toFormat)); } - else if (AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCXF == toFormat) - { - toFormat = AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX; - } *m_nFormatTo = toFormat; } bool getDontSaveAdditional() const From 57e5fea9cc1ea7c80bca96ba482367a9cfdb1512 Mon Sep 17 00:00:00 2001 From: Sergey Konovalov Date: Sun, 28 Nov 2021 19:33:44 +0300 Subject: [PATCH 12/12] [x2t] Add AVS_FILEUTILS_ERROR_CONVERT_DRM_UNSUPPORTED type for bug 54148 --- Common/OfficeFileErrorDescription.h | 2 +- X2tConverter/src/ASCConverters.cpp | 31 ++++++++++++++++++++++++++++- X2tConverter/src/ASCConverters.h | 3 +++ X2tConverter/src/cextracttools.h | 4 ++++ 4 files changed, 38 insertions(+), 2 deletions(-) diff --git a/Common/OfficeFileErrorDescription.h b/Common/OfficeFileErrorDescription.h index d19d5a4e1e..c8fe67f86d 100644 --- a/Common/OfficeFileErrorDescription.h +++ b/Common/OfficeFileErrorDescription.h @@ -233,7 +233,7 @@ #define AVS_FILEUTILS_ERROR_CONVERT_UNKNOWN_FORMAT (AVS_ERROR_FIRST + AVS_FILEUTILS_ERROR_FIRST + 0x0052) #define AVS_FILEUTILS_ERROR_CONVERT_TIMEOUT (AVS_ERROR_FIRST + AVS_FILEUTILS_ERROR_FIRST + 0x0053) #define AVS_FILEUTILS_ERROR_CONVERT_READ_FILE (AVS_ERROR_FIRST + AVS_FILEUTILS_ERROR_FIRST + 0x0054) -//#define AVS_FILEUTILS_ERROR_CONVERT_MS_OFFCRYPTO (AVS_ERROR_FIRST + AVS_FILEUTILS_ERROR_FIRST + 0x0055) +#define AVS_FILEUTILS_ERROR_CONVERT_DRM_UNSUPPORTED (AVS_ERROR_FIRST + AVS_FILEUTILS_ERROR_FIRST + 0x0055) #define AVS_FILEUTILS_ERROR_CONVERT_CORRUPTED (AVS_ERROR_FIRST + AVS_FILEUTILS_ERROR_FIRST + 0x0056) #define AVS_FILEUTILS_ERROR_CONVERT_LIBREOFFICE (AVS_ERROR_FIRST + AVS_FILEUTILS_ERROR_FIRST + 0x0057) #define AVS_FILEUTILS_ERROR_CONVERT_PARAMS (AVS_ERROR_FIRST + AVS_FILEUTILS_ERROR_FIRST + 0x0058) diff --git a/X2tConverter/src/ASCConverters.cpp b/X2tConverter/src/ASCConverters.cpp index 2c9872c42c..5882263411 100644 --- a/X2tConverter/src/ASCConverters.cpp +++ b/X2tConverter/src/ASCConverters.cpp @@ -287,6 +287,8 @@ namespace NExtractTools { if (OfficeFileFormatChecker.nFileType == AVS_OFFICESTUDIO_FILE_OTHER_MS_OFFCRYPTO) return mscrypt2oot_bin(sFrom, sTo, sTemp, params); + else if (OfficeFileFormatChecker.nFileType == AVS_OFFICESTUDIO_FILE_OTHER_MS_MITCRYPTO) + return mitcrypt2oot_bin(sFrom, sTo, sTemp, params); else { if (create_if_empty(sFrom, sTo, L"DOCY;v10;0;")) @@ -715,6 +717,8 @@ namespace NExtractTools return mscrypt2oot_bin(sFrom, sTo, sTemp, params); } } + else if (OfficeFileFormatChecker.nFileType == AVS_OFFICESTUDIO_FILE_OTHER_MS_MITCRYPTO) + return mitcrypt2oot_bin(sFrom, sTo, sTemp, params); else { if (create_if_empty(sFrom, sTo, L"XLSY;v10;0;")) @@ -1146,6 +1150,8 @@ namespace NExtractTools { if (OfficeFileFormatChecker.nFileType == AVS_OFFICESTUDIO_FILE_OTHER_MS_OFFCRYPTO) return mscrypt2oot_bin(sFrom, sTo, sTemp, params); + else if (OfficeFileFormatChecker.nFileType == AVS_OFFICESTUDIO_FILE_OTHER_MS_MITCRYPTO) + return mitcrypt2oot_bin(sFrom, sTo, sTemp, params); else { if (create_if_empty(sFrom, sTo, L"PPTY;v10;0;")) @@ -2994,6 +3000,11 @@ namespace NExtractTools return 0; } + _UINT32 mitcrypt2oox (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, InputParams& params) + { + //todo + return AVS_FILEUTILS_ERROR_CONVERT_DRM_UNSUPPORTED; + } _UINT32 mscrypt2oot_bin (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, InputParams& params) { //decrypt to temp file @@ -3065,6 +3076,12 @@ namespace NExtractTools } return AVS_FILEUTILS_ERROR_CONVERT; } + _UINT32 mitcrypt2oot_bin (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, InputParams& params) + { + //todo + return AVS_FILEUTILS_ERROR_CONVERT_DRM_UNSUPPORTED; + } + _UINT32 oox2mscrypt (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, InputParams& params) { std::wstring password = params.getSavePassword(); @@ -3135,6 +3152,12 @@ namespace NExtractTools } return nRes; } + _UINT32 fromMitcrypt (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, InputParams& params) + { + //todo + return AVS_FILEUTILS_ERROR_CONVERT_DRM_UNSUPPORTED; + } + //html _UINT32 html_array2docx_dir (const std::vector &arFiles, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params) { @@ -4030,6 +4053,8 @@ namespace NExtractTools params.m_sPassword = new std::wstring(sOldPassword); } } + else if (OfficeFileFormatChecker.nFileType == AVS_OFFICESTUDIO_FILE_OTHER_MS_MITCRYPTO) + nRes = mitcrypt2oox(sFrom, sTo, sTemp, params); } } } @@ -5088,8 +5113,12 @@ namespace NExtractTools result = mscrypt2oot (sFileFrom, sFileTo, sTempDir, oInputParams); }break; case TCD_MSCRYPT2BIN: - result = mscrypt2oot_bin (sFileFrom, sFileTo, sTempDir, oInputParams); { + result = mscrypt2oot_bin (sFileFrom, sFileTo, sTempDir, oInputParams); + }break; + case TCD_MITCRYPT2: + { + result = fromMitcrypt (sFileFrom, sFileTo, sTempDir, oInputParams); }break; case TCD_HTML2DOCX: { diff --git a/X2tConverter/src/ASCConverters.h b/X2tConverter/src/ASCConverters.h index 3abb8793d8..339e947242 100644 --- a/X2tConverter/src/ASCConverters.h +++ b/X2tConverter/src/ASCConverters.h @@ -180,9 +180,12 @@ namespace NExtractTools _UINT32 pptx_dir2odp (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, InputParams& params, bool bTemplate); _UINT32 fromMscrypt (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, InputParams& params); + _UINT32 fromMitcrypt (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, InputParams& params); _UINT32 mscrypt2oox (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, InputParams& params); + _UINT32 mitcrypt2oox (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, InputParams& params); _UINT32 mscrypt2oot (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, InputParams& params); _UINT32 mscrypt2oot_bin (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, InputParams& params); + _UINT32 mitcrypt2oot_bin(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, InputParams& params); _UINT32 oox2mscrypt (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, InputParams& params); diff --git a/X2tConverter/src/cextracttools.h b/X2tConverter/src/cextracttools.h index 91da987362..8d86469aeb 100644 --- a/X2tConverter/src/cextracttools.h +++ b/X2tConverter/src/cextracttools.h @@ -193,6 +193,8 @@ namespace NExtractTools TCD_MSCRYPT2_RAW, TCD_2MSCRYPT_RAW, + TCD_MITCRYPT2, + // TCD_HTML2DOCX, TCD_HTML2DOCT, @@ -839,6 +841,8 @@ namespace NExtractTools eRes = TCD_CANVAS_PDF2; else if(AVS_OFFICESTUDIO_FILE_OTHER_MS_OFFCRYPTO == nFormatFrom) eRes = TCD_MSCRYPT2; + else if(AVS_OFFICESTUDIO_FILE_OTHER_MS_MITCRYPTO == nFormatFrom) + eRes = TCD_MITCRYPT2; else if(AVS_OFFICESTUDIO_FILE_OTHER_ZIP == nFormatFrom && AVS_OFFICESTUDIO_FILE_UNKNOWN == nFormatTo) eRes = TCD_UNZIPDIR; else if(AVS_OFFICESTUDIO_FILE_UNKNOWN == nFormatFrom && AVS_OFFICESTUDIO_FILE_OTHER_ZIP == nFormatTo)