diff --git a/ASCOfficeDocFile/DocDocxConverter/DocumentMapping.cpp b/ASCOfficeDocFile/DocDocxConverter/DocumentMapping.cpp index f65faacf89..376c12744c 100755 --- a/ASCOfficeDocFile/DocDocxConverter/DocumentMapping.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/DocumentMapping.cpp @@ -823,8 +823,10 @@ namespace DocFileFormat } else if (TextMark::PageBreakOrSectionMark == code) { - if (_isSectionPageBreak == 0) + if (_isSectionPageBreak == 0 || _isSectionPageBreak == 2) { + _isSectionPageBreak = -1; + writeTextElement(text, textType); text.clear(); @@ -1029,7 +1031,7 @@ namespace DocFileFormat } else { - VMLShapeMapping oVmlMapper(m_context, &pictWriter, NULL, &oPicture, _caller, isInline); + VMLShapeMapping oVmlMapper(m_context, &pictWriter, NULL, &oPicture, _caller, isInline, false); oPicture.shapeContainer->Convert(&oVmlMapper); } diff --git a/ASCOfficeDocFile/DocDocxConverter/DocumentMapping.h b/ASCOfficeDocFile/DocDocxConverter/DocumentMapping.h index af6fde4ebb..58d93f2001 100644 --- a/ASCOfficeDocFile/DocDocxConverter/DocumentMapping.h +++ b/ASCOfficeDocFile/DocDocxConverter/DocumentMapping.h @@ -154,7 +154,7 @@ namespace DocFileFormat int _endnoteNr; int _commentNr; bool _isTextBoxContent; - int _isSectionPageBreak; //0 - not set, 1 -page break, 2 - continues + int _isSectionPageBreak; //0 - not set, 1 -page break, 2 - continues, -1 - already bool _writeWebHidden; std::wstring _writeAfterRun; std::wstring _lastOLEObject; diff --git a/ASCOfficeDocFile/DocDocxConverter/ParagraphPropertiesMapping.cpp b/ASCOfficeDocFile/DocDocxConverter/ParagraphPropertiesMapping.cpp index 9f80aa8aad..88b6035384 100644 --- a/ASCOfficeDocFile/DocDocxConverter/ParagraphPropertiesMapping.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/ParagraphPropertiesMapping.cpp @@ -661,7 +661,8 @@ namespace DocFileFormat //Vinci_Customer_Case_Study.doc _isSectionPageBreak = 1; } - else _isSectionPageBreak = 2; + else + _isSectionPageBreak = 2; RELEASEOBJECT( sectionPropertiesMapping ); _pPr->AppendChild( sectPr ); diff --git a/ASCOfficeDocFile/DocDocxConverter/VMLPictureMapping.cpp b/ASCOfficeDocFile/DocDocxConverter/VMLPictureMapping.cpp index aa4b972cbd..399c1a1a90 100644 --- a/ASCOfficeDocFile/DocDocxConverter/VMLPictureMapping.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/VMLPictureMapping.cpp @@ -228,7 +228,7 @@ namespace DocFileFormat style +=( L";" ); } - VMLPictureMapping::VMLPictureMapping(ConversionContext* ctx, XMLTools::CStringXmlWriter* writer, bool olePreview, IMapping* caller, bool isInlinePicture) : PropertiesMapping(writer) + VMLPictureMapping::VMLPictureMapping(ConversionContext* ctx, XMLTools::CStringXmlWriter* writer, bool olePreview, IMapping* caller, bool isInlinePicture, bool inGroup) : PropertiesMapping(writer) { m_context = ctx; m_isOlePreview = olePreview; @@ -236,6 +236,7 @@ namespace DocFileFormat m_nImageId = 0; m_caller = caller; m_isInlinePicture = isInlinePicture; + m_inGroup = inGroup; m_isBullete = false; m_isEquation = false; diff --git a/ASCOfficeDocFile/DocDocxConverter/VMLPictureMapping.h b/ASCOfficeDocFile/DocDocxConverter/VMLPictureMapping.h index 4f7dca84d1..846176a15d 100644 --- a/ASCOfficeDocFile/DocDocxConverter/VMLPictureMapping.h +++ b/ASCOfficeDocFile/DocDocxConverter/VMLPictureMapping.h @@ -50,7 +50,7 @@ namespace DocFileFormat class VMLPictureMapping: public PropertiesMapping, public IMapping { public: - VMLPictureMapping( ConversionContext* ctx, XMLTools::CStringXmlWriter* writer, bool olePreview, IMapping* caller, bool isInlinePicture = false ); + VMLPictureMapping( ConversionContext* ctx, XMLTools::CStringXmlWriter* writer, bool olePreview, IMapping* caller, bool isInlinePicture = false, bool inGroup = false); virtual ~VMLPictureMapping(); virtual void Apply( IVisitable* visited ); private: @@ -88,6 +88,7 @@ namespace DocFileFormat bool m_isOlePreview; bool m_isInlinePicture; + bool m_inGroup; XMLTools::XMLElement* m_imageData; diff --git a/ASCOfficeDocFile/DocDocxConverter/VMLShapeMapping.cpp b/ASCOfficeDocFile/DocDocxConverter/VMLShapeMapping.cpp index b9e4da8f19..f41c449aab 100644 --- a/ASCOfficeDocFile/DocDocxConverter/VMLShapeMapping.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/VMLShapeMapping.cpp @@ -48,8 +48,9 @@ namespace DocFileFormat { - VMLShapeMapping::VMLShapeMapping (ConversionContext* pConv, XMLTools::CStringXmlWriter* pWriter, Spa* pSpa, PictureDescriptor* pPicture, IMapping* pCaller, bool isInlineShape) : PropertiesMapping(pWriter) + VMLShapeMapping::VMLShapeMapping (ConversionContext* pConv, XMLTools::CStringXmlWriter* pWriter, Spa* pSpa, PictureDescriptor* pPicture, IMapping* pCaller, bool isInlineShape, bool inGroup) : PropertiesMapping(pWriter) { + m_inGroup = inGroup; m_isInlineShape = isInlineShape; m_isBullete = false; m_isPictureBroken = false; @@ -191,7 +192,7 @@ namespace DocFileFormat ShapeContainer* pChildShape = static_cast(container->Children[i]); if (pChildShape) { - VMLShapeMapping vmlShapeMapping(m_context, m_pXmlWriter, m_pSpa, NULL, m_pCaller); + VMLShapeMapping vmlShapeMapping(m_context, m_pXmlWriter, m_pSpa, NULL, m_pCaller, false, true); pChildShape->Convert(&vmlShapeMapping); } } @@ -1731,7 +1732,8 @@ namespace DocFileFormat case ODRAW::posrelh: { nRelH = iter->op; - appendStyleProperty(oStyle, L"mso-position-horizontal-relative", mapHorizontalPositionRelative((PositionHorizontalRelative)iter->op)); + if (false == m_inGroup) + appendStyleProperty(oStyle, L"mso-position-horizontal-relative", mapHorizontalPositionRelative((PositionHorizontalRelative)iter->op)); }break; case ODRAW::posv: { @@ -1740,7 +1742,8 @@ namespace DocFileFormat case ODRAW::posrelv: { nRelV = iter->op; - appendStyleProperty(oStyle, L"mso-position-vertical-relative", mapVerticalPositionRelative((PositionVerticalRelative)iter->op)); + if (false == m_inGroup) + appendStyleProperty(oStyle, L"mso-position-vertical-relative", mapVerticalPositionRelative((PositionVerticalRelative)iter->op)); }break; // BOOLEANS case ODRAW::groupShapeBooleanProperties: @@ -1752,7 +1755,7 @@ namespace DocFileFormat //за текстом (The shape is behind the text, so the z-index must be negative.) m_isInlineShape = false; - if (!bZIndex) + if (false == bZIndex && false == m_inGroup) { appendStyleProperty(oStyle, L"z-index", FormatUtils::IntToWideString(-zIndex - 0x7ffff)); bZIndex = true; @@ -1837,12 +1840,12 @@ namespace DocFileFormat { m_isInlineShape = true; } - if (!m_isInlineShape && !bZIndex) + if (false == m_isInlineShape && false == bZIndex && false == m_inGroup) { appendStyleProperty( oStyle, L"z-index", FormatUtils::IntToWideString(zIndex + 0x7ffff)); bZIndex = true; } - if (false == m_isInlineShape) + if (false == m_isInlineShape && false == m_inGroup) { if (nPosH >= 0) { @@ -2306,16 +2309,19 @@ namespace DocFileFormat strStyle += L"margin-left:" + FormatUtils::IntToWideString( (int)x.ToPoints()) + L"pt;"; strStyle += L"margin-top:" + FormatUtils::IntToWideString( (int)y.ToPoints()) + L"pt;"; - std::wstring xMargin; - std::wstring yMargin; - if (m_pSpa->bx == PAGE) xMargin = L"page;"; - if (m_pSpa->by == PAGE) yMargin = L"page;"; - - if (m_pSpa->bx == MARGIN) xMargin = L"margin;"; - if (m_pSpa->by == MARGIN) yMargin = L"margin;"; + if (false == m_inGroup) + { + std::wstring xMargin; + std::wstring yMargin; + if (m_pSpa->bx == PAGE) xMargin = L"page;"; + if (m_pSpa->by == PAGE) yMargin = L"page;"; - if (!xMargin.empty()) strStyle += L"mso-position-horizontal-relative:" + xMargin; - if (!yMargin.empty()) strStyle += L"mso-position-vertical-relative:" + yMargin; + if (m_pSpa->bx == MARGIN) xMargin = L"margin;"; + if (m_pSpa->by == MARGIN) yMargin = L"margin;"; + + if (!xMargin.empty()) strStyle += L"mso-position-horizontal-relative:" + xMargin; + if (!yMargin.empty()) strStyle += L"mso-position-vertical-relative:" + yMargin; + } std::wstring strSize = FormatUtils::IntToWideString(primitive->dxa) + L"," + FormatUtils::IntToWideString(primitive->dya); std::wstring strOrigin = FormatUtils::IntToWideString(primitive->xa) + L"," + FormatUtils::IntToWideString(primitive->ya); diff --git a/ASCOfficeDocFile/DocDocxConverter/VMLShapeMapping.h b/ASCOfficeDocFile/DocDocxConverter/VMLShapeMapping.h index a6efeaf2cc..837bf866dc 100644 --- a/ASCOfficeDocFile/DocDocxConverter/VMLShapeMapping.h +++ b/ASCOfficeDocFile/DocDocxConverter/VMLShapeMapping.h @@ -57,7 +57,7 @@ namespace DocFileFormat { public: - VMLShapeMapping (ConversionContext* ctx ,XMLTools::CStringXmlWriter* writer, Spa* pSpa, PictureDescriptor* pict, IMapping* caller, bool bullet = false); + VMLShapeMapping (ConversionContext* ctx, XMLTools::CStringXmlWriter* writer, Spa* pSpa, PictureDescriptor* pict, IMapping* caller, bool bullet = false, bool in_group = false); virtual ~VMLShapeMapping(); virtual void Apply(IVisitable* visited); @@ -67,6 +67,7 @@ namespace DocFileFormat static std::wstring mapHorizontalPositionRelative (int hRel ); static std::wstring mapWrapText (int val_); + bool m_inGroup; bool m_isBullete; bool m_isPictureBroken; std::wstring m_shapeId; diff --git a/ASCOfficeDocxFile2/BinReader/MediaWriter.h b/ASCOfficeDocxFile2/BinReader/MediaWriter.h index e81482c8da..26ad1e00e2 100644 --- a/ASCOfficeDocxFile2/BinReader/MediaWriter.h +++ b/ASCOfficeDocxFile2/BinReader/MediaWriter.h @@ -54,7 +54,7 @@ namespace Writers } std::wstring AddImageGetNewPath() { - OOX::CSystemUtility::CreateDirectories(m_sMediaDir); + NSDirectory::CreateDirectories(m_sMediaDir); std::wstring sNewImgName = L"image" + std::to_wstring(nImageCount + 1) + L".jpg"; std::wstring sNewImg = m_sMediaDir + FILE_SEPARATOR_STR + sNewImgName; diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Animation.cpp b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Animation.cpp index 2c3ad93e2d..642914c69c 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Animation.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Animation.cpp @@ -403,6 +403,30 @@ void Animation::FillAnimScale( oAnim.zoomContents = oAtom.m_fZoomContents; } +// TODO refactoring +void Animation::FillAudio(CRecordExtTimeNodeContainer *pETNC, + PPTX::Logic::Audio &oAudio) +{ + auto* pCVEC = pETNC->m_pClientVisualElement; + if (pCVEC->m_bVisualShapeAtom && m_pRels) + { + CExFilesInfo* pInfo1 = m_pExMedia->LockAudioFromCollection(pCVEC->m_oVisualShapeAtom.m_nObjectIdRef); + if (pInfo1) + { + bool bExternal(false); + oAudio.cMediaNode.tgtEl.embed = + new OOX::RId(m_pRels->WriteAudio(pInfo1->m_strFilePath, bExternal)); + oAudio.cMediaNode.tgtEl.name = XmlUtils::EncodeXmlString(pInfo1->m_name); + } else if (pCVEC->m_oVisualShapeAtom.m_RefType == TL_ET_ShapeType) + { + oAudio.cMediaNode.tgtEl.spTgt = new PPTX::Logic::SpTgt; + oAudio.cMediaNode.tgtEl.spTgt->spid = std::to_wstring(pCVEC->m_oVisualShapeAtom.m_nObjectIdRef); + } else + return; + FillCTn(pETNC, oAudio.cMediaNode.cTn); + } +} + void Animation::FillAudio(CRecordClientVisualElementContainer *pCVEC, PPTX::Logic::Audio &oAudio) { @@ -639,7 +663,7 @@ void Animation::FillCBhvr( pBhvr->m_oClientVisualElement.m_oVisualShapeAtom.m_nData1 != 0xFFFFFFFF) { oBhvr.tgtEl.spTgt->txEl = new PPTX::Logic::TxEl; - oBhvr.tgtEl.spTgt->txEl->charRg = true; + oBhvr.tgtEl.spTgt->txEl->charRg = false; oBhvr.tgtEl.spTgt->txEl->st = pBhvr->m_oClientVisualElement.m_oVisualShapeAtom.m_nData1; oBhvr.tgtEl.spTgt->txEl->end = pBhvr->m_oClientVisualElement.m_oVisualShapeAtom.m_nData2; } @@ -1104,6 +1128,13 @@ void Animation::FillTnChild( FillVideo(pETNC, *video); oChild.m_node = video; } + + if (pETNC->m_pClientVisualElement->m_oVisualShapeAtom.m_Type == TL_TVET_Audio) + { + auto audio = new PPTX::Logic::Audio; + FillAudio(pETNC, *audio); + oChild.m_node = audio; + } } } } diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Animation.h b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Animation.h index 7ea1c2e706..a0cd8deeb3 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Animation.h +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Animation.h @@ -133,8 +133,9 @@ private: void FillAnimScale( CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::AnimScale &oAnim); - void FillAudio( - PPT_FORMAT::CRecordClientVisualElementContainer *pCVEC, + void FillAudio(CRecordExtTimeNodeContainer *pETNC, + PPTX::Logic::Audio &oAudio); + void FillAudio(CRecordClientVisualElementContainer *pCVEC, PPTX::Logic::Audio &oAudio); void FillCmd( CRecordExtTimeNodeContainer *pETNC, diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.cpp b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.cpp index aae42edeb8..33e4caacdf 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.cpp @@ -36,10 +36,7 @@ #include "../../../ASCOfficePPTXFile/Editor/DefaultNotesMaster.h" #include "../../../ASCOfficePPTXFile/Editor/DefaultNotesTheme.h" -#include "../../../Common/DocxFormat/Source/SystemUtility/SystemUtility.h" -#include "../../../ASCOfficeXlsFile2/source/Common/simple_xml_writer.h" -#include "../../../DesktopEditor/common/Directory.h" -#include "../../../DesktopEditor/common/SystemUtils.h" +#include "TableWriter.h" #include "../Reader/PPTDocumentInfo.h" #include "ShapeWriter.h" @@ -48,7 +45,6 @@ #include "Converter.h" #include "Animation.h" - #include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Transitions/Transition.h" #include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Transitions/TransitionBase.h" #include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Transitions/EmptyTransition.h" @@ -61,6 +57,16 @@ #include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Transitions/SplitTransition.h" #include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Transitions/ZoomTransition.h" +#include "../../../ASCOfficeXlsFile2/source/Common/simple_xml_writer.h" + +#include "../../../DesktopEditor/common/Directory.h" +#include "../../../DesktopEditor/common/SystemUtils.h" + +#include +#include + +typedef boost::uuids::detail::md5 MD5; + namespace PPT_FORMAT { namespace NSPPTXWriterConst @@ -109,13 +115,13 @@ void PPT_FORMAT::CPPTXWriter::CreateFile(CPPTUserInfo* pUserInfo ) m_pShapeWriter->InitNextId(); NSDirectory::CreateDirectory(m_strTempDirectory); - CFile oFile; + NSFile::CFileBinary oFile; std::wstring strMemory = _T(""); // _rels NSDirectory::CreateDirectory(m_strTempDirectory + FILE_SEPARATOR_STR + _T("_rels")); - oFile.CreateFile(m_strTempDirectory + FILE_SEPARATOR_STR + _T("_rels") + FILE_SEPARATOR_STR + _T(".rels")); + oFile.CreateFileW(m_strTempDirectory + FILE_SEPARATOR_STR + _T("_rels") + FILE_SEPARATOR_STR + _T(".rels")); strMemory = NSPPTXWriterConst::g_string_rels_presentation; oFile.WriteStringUTF8(strMemory); oFile.CloseFile(); @@ -124,13 +130,13 @@ void PPT_FORMAT::CPPTXWriter::CreateFile(CPPTUserInfo* pUserInfo ) NSDirectory::CreateDirectory(m_strTempDirectory + FILE_SEPARATOR_STR + _T("docProps")); // core - oFile.CreateFile(m_strTempDirectory + FILE_SEPARATOR_STR + _T("docProps") + FILE_SEPARATOR_STR + _T("core.xml")); + oFile.CreateFileW(m_strTempDirectory + FILE_SEPARATOR_STR + _T("docProps") + FILE_SEPARATOR_STR + _T("core.xml")); strMemory = NSPPTXWriterConst::g_string_core; oFile.WriteStringUTF8(strMemory); oFile.CloseFile(); // app - oFile.CreateFile(m_strTempDirectory + FILE_SEPARATOR_STR + _T("docProps") + FILE_SEPARATOR_STR + _T("app.xml")); + oFile.CreateFileW(m_strTempDirectory + FILE_SEPARATOR_STR + _T("docProps") + FILE_SEPARATOR_STR + _T("app.xml")); WriteApp(oFile); oFile.CloseFile(); @@ -153,13 +159,13 @@ void PPT_FORMAT::CPPTXWriter::CreateFile(CDocument* pDocument) m_pShapeWriter->InitNextId(); NSDirectory::CreateDirectory(m_strTempDirectory); - CFile oFile; + NSFile::CFileBinary oFile; std::wstring strMemory = _T(""); // _rels NSDirectory::CreateDirectory(m_strTempDirectory + FILE_SEPARATOR_STR + _T("_rels")); - oFile.CreateFile(m_strTempDirectory + FILE_SEPARATOR_STR + _T("_rels") + FILE_SEPARATOR_STR + _T(".rels")); + oFile.CreateFileW(m_strTempDirectory + FILE_SEPARATOR_STR + _T("_rels") + FILE_SEPARATOR_STR + _T(".rels")); strMemory = NSPPTXWriterConst::g_string_rels_presentation; oFile.WriteStringUTF8(strMemory); oFile.CloseFile(); @@ -168,13 +174,13 @@ void PPT_FORMAT::CPPTXWriter::CreateFile(CDocument* pDocument) NSDirectory::CreateDirectory(m_strTempDirectory + FILE_SEPARATOR_STR + _T("docProps")); // core - oFile.CreateFile(m_strTempDirectory + FILE_SEPARATOR_STR + _T("docProps") + FILE_SEPARATOR_STR + _T("core.xml")); + oFile.CreateFileW(m_strTempDirectory + FILE_SEPARATOR_STR + _T("docProps") + FILE_SEPARATOR_STR + _T("core.xml")); strMemory = NSPPTXWriterConst::g_string_core; oFile.WriteStringUTF8(strMemory); oFile.CloseFile(); // app - oFile.CreateFile(m_strTempDirectory + FILE_SEPARATOR_STR + _T("docProps") + FILE_SEPARATOR_STR + _T("app.xml")); + oFile.CreateFileW(m_strTempDirectory + FILE_SEPARATOR_STR + _T("docProps") + FILE_SEPARATOR_STR + _T("app.xml")); WriteApp(oFile); oFile.CloseFile(); @@ -279,14 +285,14 @@ void PPT_FORMAT::CPPTXWriter::WriteContentTypes() } strContentTypes += _T(""); - CFile oFile; - oFile.CreateFile(m_strTempDirectory + FILE_SEPARATOR_STR + _T("[Content_Types].xml")); + NSFile::CFileBinary oFile; + oFile.CreateFileW(m_strTempDirectory + FILE_SEPARATOR_STR + _T("[Content_Types].xml")); oFile.WriteStringUTF8(strContentTypes); oFile.CloseFile(); } -void PPT_FORMAT::CPPTXWriter::WriteApp(CFile& oFile) +void PPT_FORMAT::CPPTXWriter::WriteApp(NSFile::CFileBinary& oFile) { std::wstringstream strm; @@ -428,17 +434,17 @@ void PPT_FORMAT::CPPTXWriter::WriteApp(CFile& oFile) void PPT_FORMAT::CPPTXWriter::WritePresInfo() { - CFile oFile; + NSFile::CFileBinary oFile; // tableStyles.xml - oFile.CreateFile(m_strTempDirectory + FILE_SEPARATOR_STR + _T("ppt") + FILE_SEPARATOR_STR + _T("tableStyles.xml")); + oFile.CreateFileW(m_strTempDirectory + FILE_SEPARATOR_STR + _T("ppt") + FILE_SEPARATOR_STR + _T("tableStyles.xml")); oFile.WriteStringUTF8(L"\ "); oFile.CloseFile(); // presProps.xml - oFile.CreateFile(m_strTempDirectory + FILE_SEPARATOR_STR + _T("ppt") + FILE_SEPARATOR_STR + _T("presProps.xml")); + oFile.CreateFileW(m_strTempDirectory + FILE_SEPARATOR_STR + _T("ppt") + FILE_SEPARATOR_STR + _T("presProps.xml")); oFile.WriteStringUTF8(L"\ \ \ @@ -449,7 +455,7 @@ void PPT_FORMAT::CPPTXWriter::WritePresInfo() oFile.CloseFile(); // viewProps.xml - oFile.CreateFile(m_strTempDirectory + FILE_SEPARATOR_STR + _T("ppt") + FILE_SEPARATOR_STR + _T("viewProps.xml")); + oFile.CreateFileW(m_strTempDirectory + FILE_SEPARATOR_STR + _T("ppt") + FILE_SEPARATOR_STR + _T("viewProps.xml")); oFile.WriteStringUTF8(L"\ \ \ @@ -526,7 +532,7 @@ void PPT_FORMAT::CPPTXWriter::WritePresInfo() std::wstring strPptRels = m_strTempDirectory + FILE_SEPARATOR_STR + _T("ppt") + FILE_SEPARATOR_STR + _T("_rels"); NSDirectory::CreateDirectory(strPptRels); - oFile.CreateFile(strPptRels + FILE_SEPARATOR_STR + _T("presentation.xml.rels")); + oFile.CreateFileW(strPptRels + FILE_SEPARATOR_STR + _T("presentation.xml.rels")); oFile.WriteStringUTF8(strPresRels); oFile.CloseFile(); @@ -559,7 +565,7 @@ void PPT_FORMAT::CPPTXWriter::WritePresInfo() strPres += strDefaultTextStyle; strPres +=_T(""); - oFile.CreateFile(m_strTempDirectory+ FILE_SEPARATOR_STR + _T("ppt") + FILE_SEPARATOR_STR + _T("presentation.xml")); + oFile.CreateFileW(m_strTempDirectory+ FILE_SEPARATOR_STR + _T("ppt") + FILE_SEPARATOR_STR + _T("presentation.xml")); oFile.WriteStringUTF8(strPres); oFile.CloseFile(); } @@ -601,18 +607,127 @@ void PPT_FORMAT::CPPTXWriter::WriteAll() void PPT_FORMAT::CPPTXWriter::WriteThemes() { int nStartLayout = 0, nIndexTheme = 0; + auto arrRT = m_pDocument->getArrRoundTripTheme(); - for (size_t i = 0; i < m_pDocument->m_arThemes.size(); i++) + //if (arrRT.empty()) - см баг 52046 { - m_pShapeWriter->m_pTheme = m_pDocument->m_arThemes[i].get(); - WriteTheme(m_pDocument->m_arThemes[i], nIndexTheme, nStartLayout); - m_pShapeWriter->m_pTheme = NULL; + for (size_t i = 0; i < m_pDocument->m_arThemes.size(); i++) + { + m_pShapeWriter->m_pTheme = m_pDocument->m_arThemes[i].get(); + WriteTheme(m_pDocument->m_arThemes[i], nIndexTheme, nStartLayout); + m_pShapeWriter->m_pTheme = NULL; + } } + //else + //{ + // WriteRoundTripThemes(arrRT, nIndexTheme, nStartLayout); + //} WriteTheme(m_pDocument->m_pNotesMaster, nIndexTheme, nStartLayout); WriteTheme(m_pDocument->m_pHandoutMaster, nIndexTheme, nStartLayout); } +void CPPTXWriter::WriteRoundTripThemes(const std::vector& arrRTThemes, int& nIndexTheme, int & nStartLayout) +{ + PPT_FORMAT::CRelsGenerator themeRels(&m_oManager); + std::unordered_set writedFilesHash; + for (const auto* pRTT : arrRTThemes) + { + if (pRTT == nullptr) + continue; + + std::wstring strPptDirectory = m_strTempDirectory + FILE_SEPARATOR_STR + _T("ppt") + FILE_SEPARATOR_STR ; + std::wstring tempPath = NSDirectory::GetTempPath(); + + auto& zipAtom = *pRTT; + BYTE* zipData = zipAtom.data.first.get(); + ULONG zipDataLen = zipAtom.data.second; + + + NSFile::CFileBinary binFile; + std::wstring tempZipPath = tempPath + FILE_SEPARATOR_STR + L"tempTheme.zip"; + if (!binFile.CreateFileW(tempZipPath)) + continue; + + binFile.WriteFile(zipData, zipDataLen); + binFile.CloseFile(); + + COfficeUtils officeUtils(NULL); + std::wstring tempUnZipPath = tempPath + FILE_SEPARATOR_STR + L"tempTheme"; + NSDirectory::CreateDirectory(tempUnZipPath); + officeUtils.ExtractToDirectory(tempZipPath, tempUnZipPath, NULL, 0); + NSFile::CFileBinary::Remove(tempZipPath); + + auto arrPaths = NSDirectory::GetFiles(tempUnZipPath + FILE_SEPARATOR_STR + L"theme" + FILE_SEPARATOR_STR + L"theme"); + auto arrThemesPaths = NSDirectory::GrepPaths(arrPaths, L".*theme[0-9]+.xml"); + + arrPaths = NSDirectory::GetFiles(tempUnZipPath + FILE_SEPARATOR_STR + L"theme" + FILE_SEPARATOR_STR + L"media"); + auto arrImagesPaths = NSDirectory::GrepPaths(arrPaths, L".*image[0-9]+.*"); + + arrPaths = NSDirectory::GetFiles(tempUnZipPath + FILE_SEPARATOR_STR + L"theme" + FILE_SEPARATOR_STR + L"theme" + FILE_SEPARATOR_STR + L"_rels"); + auto arrRelsPaths = NSDirectory::GrepPaths(arrPaths, L".*theme[0-9]+.xml.rels"); + + BYTE *utf8Data = NULL; + ULONG utf8DataSize = 0; + bool wasThemeWrite = false; + + // write themes + for (auto& strThemePath : arrThemesPaths) + { + // read file bytes + NSFile::CFileBinary::ReadAllBytes(strThemePath, &utf8Data, utf8DataSize); + // compare hash + char* pointerToThemeElems = strstr((char*)utf8Data, ""); + UINT hashShift = pointerToThemeElems ? pointerToThemeElems - (char*)utf8Data : 0; + auto strHash = CFile::md5(utf8Data+hashShift, utf8DataSize-hashShift); + + // cp file with new name or write bytes + if (writedFilesHash.find(strHash) == writedFilesHash.end()) + { + std::wstring strThemeFile = L"theme" + std::to_wstring(++nIndexTheme) + L".xml"; + strThemeFile = strPptDirectory + _T("theme") + FILE_SEPARATOR_STR + strThemeFile; + NSFile::CFileBinary oFile; + oFile.CreateFileW(strThemeFile); + oFile.WriteFile(utf8Data, utf8DataSize); + wasThemeWrite = true; + + // clear bytes + writedFilesHash.insert(strHash); + RELEASEOBJECT(utf8Data); + utf8DataSize = 0; + oFile.CloseFile(); + } + } + if (wasThemeWrite == false) + continue; + + for (auto& strImagePath : arrImagesPaths) + { + themeRels.WriteImage(strImagePath); + } + // write _rels + if (!arrRelsPaths.empty()) + { + std::wstring relsFolder = strPptDirectory + L"theme" + FILE_SEPARATOR_STR + L"_rels" + FILE_SEPARATOR_STR; + std::wstring relsName = L"theme" + std::to_wstring(nIndexTheme) + L".xml.rels"; + std::wstring themeRelsPath = arrRelsPaths[0]; + NSDirectory::CreateDirectory(relsFolder); + + NSFile::CFileBinary::ReadAllBytes(arrRelsPaths[0], &utf8Data, utf8DataSize); + NSFile::CFileBinary oFile; + oFile.CreateFileW(relsFolder + relsName); + oFile.WriteFile(utf8Data, utf8DataSize); + + oFile.CloseFile(); + RELEASEOBJECT(utf8Data); +// utf8DataSize = 0; + } + } + + if (!m_pDocument->m_arThemes.empty()) + WriteLayoutAfterTheme(m_pDocument->m_arThemes[0], nIndexTheme, nStartLayout); +} + void PPT_FORMAT::CPPTXWriter::WriteTheme(CThemePtr pTheme, int & nIndexTheme, int & nStartLayout) { if (!pTheme) return; @@ -622,8 +737,8 @@ void PPT_FORMAT::CPPTXWriter::WriteTheme(CThemePtr pTheme, int & nIndexTheme, in std::wstring strThemeFile = L"theme" + std::to_wstring(nIndexTheme + 1) + L".xml"; strThemeFile = strPptDirectory + _T("theme") + FILE_SEPARATOR_STR + strThemeFile; - CFile oFile; - oFile.CreateFile(strThemeFile); + NSFile::CFileBinary oFile; + oFile.CreateFileW(strThemeFile); PPT_FORMAT::CStringWriter oStringWriter; @@ -713,7 +828,7 @@ void PPT_FORMAT::CPPTXWriter::WriteTheme(CThemePtr pTheme, int & nIndexTheme, in WriteBackground(oWriter, oRels, pTheme->m_oBackground); } oWriter.WriteString(L"\ - "); +"); CGroupElement *pGroupElement = !pTheme->m_arElements.empty() ? dynamic_cast(pTheme->m_arElements[0].get()) : NULL; @@ -855,7 +970,7 @@ void PPT_FORMAT::CPPTXWriter::WriteTheme(CThemePtr pTheme, int & nIndexTheme, in strSlideMasterRelsFile = L"handoutMaster1.xml.rels"; strSlideMasterRelsFile = strPptDirectory + _T("handoutMasters") + FILE_SEPARATOR_STR + _T("_rels") + FILE_SEPARATOR_STR + strSlideMasterRelsFile; } - oFile.CreateFile(strSlideMasterFile); + oFile.CreateFileW(strSlideMasterFile); std::wstring strMaster = oWriter.GetData(); oFile.WriteStringUTF8(strMaster); oFile.CloseFile(); @@ -946,26 +1061,33 @@ void PPT_FORMAT::CPPTXWriter::WriteGroup(CStringWriter& oWriter, CRelsGenerator& } void PPT_FORMAT::CPPTXWriter::WriteTable(CStringWriter& oWriter, CRelsGenerator& oRels, CElementPtr pElement, CLayout* pLayout) { - CGroupElement *pGroupElement = dynamic_cast(pElement.get()); + CTableElement *pTableElement = dynamic_cast(pElement.get()); - m_pShapeWriter->SetElement(pElement); - oWriter.WriteString(m_pShapeWriter->ConvertTable()); - oWriter.WriteString(m_pShapeWriter->ConvertTableCells()); - // for (size_t i = 0; i < pGroupElement->m_pChildElements.size(); i++) - // { - // WriteElement(oWriter, oRels, pGroupElement->m_pChildElements[i], pLayout); - // } - oWriter.WriteString(L""); + PPTX::Logic::GraphicFrame gf; + TableWriter table(pTableElement, &oRels); + if (pTableElement->m_xmlRawData.empty()) + { + table.Convert(gf); + oWriter.WriteString(gf.toXML()); + } else + { + oWriter.WriteString(table.getXmlForGraphicFrame(pElement->m_lID, pElement->m_lPlaceholderID)); + } } + void PPT_FORMAT::CPPTXWriter::WriteElement(CStringWriter& oWriter, CRelsGenerator& oRels, CElementPtr pElement, CLayout* pLayout) { if (!pElement) return; - CGroupElement *pGroupElement = dynamic_cast(pElement.get()); - if (pGroupElement && pGroupElement->m_sName.find(L"Table") != -1) + CTableElement *pTableElement = dynamic_cast(pElement.get()); + if (pTableElement) + { return WriteTable(oWriter, oRels, pElement, pLayout); + } + + CGroupElement *pGroupElement = dynamic_cast(pElement.get()); if (pGroupElement) { return WriteGroup(oWriter, oRels, pElement, pLayout); @@ -1041,7 +1163,7 @@ void PPT_FORMAT::CPPTXWriter::WriteLayout(CLayoutPtr pLayout, int nIndexLayout, } std::wstring strElems = _T("\ - "); +"); oWriter.WriteString(strElems); size_t start_index = 0; @@ -1075,9 +1197,9 @@ void PPT_FORMAT::CPPTXWriter::WriteLayout(CLayoutPtr pLayout, int nIndexLayout, std::wstring strXml = oWriter.GetData(); std::wstring strFile = L"slideLayout" + std::to_wstring(nIndexLayout + nStartLayout + 1) + L".xml"; - CFile oFile; + NSFile::CFileBinary oFile; std::wstring strFileLayoutPath= m_strTempDirectory + FILE_SEPARATOR_STR + _T("ppt") + FILE_SEPARATOR_STR + _T("slideLayouts") + FILE_SEPARATOR_STR; - oFile.CreateFile(strFileLayoutPath + strFile); + oFile.CreateFileW(strFileLayoutPath + strFile); oFile.WriteStringUTF8(strXml); oFile.CloseFile(); @@ -1123,7 +1245,7 @@ void PPT_FORMAT::CPPTXWriter::WriteSlide(int nIndexSlide) } oWriter.WriteString(std::wstring(L"\ - ")); +")); CGroupElement *pGroupElement = !pSlide->m_arElements.empty() ? dynamic_cast(pSlide->m_arElements[0].get()) : NULL; @@ -1165,8 +1287,8 @@ void PPT_FORMAT::CPPTXWriter::WriteSlide(int nIndexSlide) std::wstring strFile = L"slide" + std::to_wstring(nIndexSlide + 1) + L".xml"; std::wstring strFileSlidePath= m_strTempDirectory + FILE_SEPARATOR_STR + _T("ppt") + FILE_SEPARATOR_STR + _T("slides") + FILE_SEPARATOR_STR; - CFile oFile; - oFile.CreateFile(strFileSlidePath + strFile); + NSFile::CFileBinary oFile; + oFile.CreateFileW(strFileSlidePath + strFile); oFile.WriteStringUTF8(strXml); oFile.CloseFile(); @@ -1226,11 +1348,15 @@ void PPT_FORMAT::CPPTXWriter::WriteTransition(CStringWriter& oWriter, CSlideShow case 5: case 6: { + // case was not documented + if ((UINT)transition.m_nEffectDirection > 1) + break; + auto pTrBase = new PPTX::Logic::OptionalBlackTransition; if (transition.m_nEffectType == 0) pTrBase->name = L"cut"; else if (transition.m_nEffectType == 5) pTrBase->name = L"dissolve"; else if (transition.m_nEffectType == 6) pTrBase->name = L"fade"; - pTrBase->thruBlk = transition.m_nEffectDirection; + pTrBase->thruBlk = (bool)transition.m_nEffectDirection; Tr.base.base.reset(pTrBase); }break; case 4: @@ -1342,8 +1468,10 @@ void PPT_FORMAT::CPPTXWriter::WriteTransition(CStringWriter& oWriter, CSlideShow std::wstring rId = m_pShapeWriter->m_pRels->WriteAudio(transition.m_oAudio.m_strAudioFileName, bExternal); Tr.sndAc = new PPTX::Logic::SndAc; Tr.sndAc->stSnd = new PPTX::Logic::StSnd; - Tr.sndAc->stSnd->name = XmlUtils::EncodeXmlString(transition.m_oAudio.m_sImageName); Tr.sndAc->stSnd->embed = rId; + + if (!transition.m_oAudio.m_sImageName.empty()) + Tr.sndAc->stSnd->name = XmlUtils::EncodeXmlString(transition.m_oAudio.m_sImageName); } oWriter.WriteString(Tr.toXML()); } @@ -1371,7 +1499,7 @@ void PPT_FORMAT::CPPTXWriter::WriteNotes(int nIndexNotes) } oWriter.WriteString(std::wstring(L"\ - ")); +")); CGroupElement *pGroupElement = !pNotes->m_arElements.empty() ? dynamic_cast(pNotes->m_arElements[0].get()) : NULL; @@ -1403,8 +1531,8 @@ void PPT_FORMAT::CPPTXWriter::WriteNotes(int nIndexNotes) std::wstring strFile = L"notesSlide" + std::to_wstring(nIndexNotes + 1) + L".xml"; std::wstring strFileSlidePath = m_strTempDirectory + FILE_SEPARATOR_STR + _T("ppt") + FILE_SEPARATOR_STR + _T("notesSlides") + FILE_SEPARATOR_STR; - CFile oFile; - oFile.CreateFile(strFileSlidePath + strFile); + NSFile::CFileBinary oFile; + oFile.CreateFileW(strFileSlidePath + strFile); oFile.WriteStringUTF8(strXml); oFile.CloseFile(); @@ -1428,6 +1556,191 @@ void PPT_FORMAT::CPPTXWriter::WriteNotes() } } +void CPPTXWriter::WriteLayoutAfterTheme(CThemePtr pTheme, const int nIndexTheme, int &nStartLayout) +{//nIndexTheme тут уже +1 + CRelsGenerator oRels(&m_oManager); + int nCountLayouts = (int)pTheme->m_arLayouts.size(); + oRels.StartMaster(nIndexTheme - 1, nStartLayout, nCountLayouts); + + CStringWriter oWriter; + oWriter.WriteString(L""); + + if (pTheme->m_eType == typeMaster) + { + oWriter.WriteString(L""); + } + else if (pTheme->m_eType == typeNotesMaster) + { + oWriter.WriteString(L""); + } + else if (pTheme->m_eType == typeHandoutMaster) + { + oWriter.WriteString(L""); + } + oWriter.WriteString(L""); + + if (pTheme->m_bIsBackground) + { + WriteBackground(oWriter, oRels, pTheme->m_oBackground); + } + oWriter.WriteString(L"\ +"); + + CGroupElement *pGroupElement = !pTheme->m_arElements.empty() ? dynamic_cast(pTheme->m_arElements[0].get()) : NULL; + + size_t start_index = 0; + if (pGroupElement) + { + for (size_t i = 0; i < pGroupElement->m_pChildElements.size(); ++i) + { + if (isBodyPlaceholder(pGroupElement->m_pChildElements[i]->m_lPlaceholderType)) + pGroupElement->m_pChildElements[i]->m_lPlaceholderType = 100; //body тип прописывать !! + + //if (pGroupElement->m_pChildElements[i]->m_bAnchorEnabled == false && + // pGroupElement->m_pChildElements[i]->m_bChildAnchorEnabled == false) + // continue; + + //if (pTheme->m_eType == typeNotesMaster) + //{ + // pGroupElement->m_pChildElements[i]->m_lPlaceholderID = -1; + //} + //else if (pTheme->m_eType == typeHandoutMaster) + //{ + // pGroupElement->m_pChildElements[i]->m_lPlaceholderID = -1; + // pGroupElement->m_pChildElements[i]->m_lPlaceholderSizePreset = -1; + //} + WriteElement(oWriter, oRels, pGroupElement->m_pChildElements[i]); + } + + start_index = 1; + } + + for (size_t i = start_index; i < pTheme->m_arElements.size(); ++i) + { + if (isBodyPlaceholder(pTheme->m_arElements[i]->m_lPlaceholderType)) + pTheme->m_arElements[i]->m_lPlaceholderType = 100; //body тип прописывать !! + + //if (pTheme->m_arElements[i]->m_bAnchorEnabled == false && + // pTheme->m_arElements[i]->m_bChildAnchorEnabled == false) + // continue; + + //if (pTheme->m_eType == typeNotesMaster) + //{ + // pTheme->m_arElements[i]->m_lPlaceholderID = -1; + //} + //else if (pTheme->m_eType == typeHandoutMaster) + //{ + // pTheme->m_arElements[i]->m_lPlaceholderID = -1; + // pTheme->m_arElements[i]->m_lPlaceholderSizePreset = -1; + //} + + WriteElement(oWriter, oRels, pTheme->m_arElements[i]); + } + + oWriter.WriteString(std::wstring(L"")); + + std::wstring strOverrideColorScheme = _T(""); + oWriter.WriteString(strOverrideColorScheme); + + if (pTheme->m_eType == typeMaster) + { + oWriter.WriteString(std::wstring(L"")); + + size_t __nCountLayouts = 0; + for (int nIndexLayout = 0; nIndexLayout < nCountLayouts; ++nIndexLayout) + { + oWriter.WriteString(L""); + + WriteLayout(pTheme->m_arLayouts[nIndexLayout], nIndexLayout, nStartLayout, nIndexTheme - 1); + } + + oWriter.WriteString(std::wstring(L"")); + } + + if (pTheme->m_bHasDate || pTheme->m_bHasFooter || pTheme->m_bHasSlideNumber) + { + oWriter.WriteString(std::wstring(L"m_bHasDate) oWriter.WriteString(std::wstring(L" dt=\"0\"")); + if (!pTheme->m_bHasSlideNumber) oWriter.WriteString(std::wstring(L" sldNum=\"0\"")); + oWriter.WriteString(std::wstring(L" hdr=\"0\"")); + if (!pTheme->m_bHasFooter) oWriter.WriteString(std::wstring(L" ftr=\"0\"")); + oWriter.WriteString(std::wstring(L"/>")); + } + CStylesWriter styleWriter; + styleWriter.m_pTheme = pTheme.get(); + + if (pTheme->m_eType == typeMaster) + { + oWriter.WriteString(std::wstring(L"")); + + oWriter.WriteString(std::wstring(L"")); + styleWriter.ConvertStyles(pTheme->m_pStyles[1], oWriter, 9); + oWriter.WriteString(std::wstring(L"")); + + oWriter.WriteString(std::wstring(L"")); + styleWriter.ConvertStyles(pTheme->m_pStyles[2], oWriter, 9); + oWriter.WriteString(std::wstring(L"")); + + oWriter.WriteString(std::wstring(L"")); + styleWriter.ConvertStyles(pTheme->m_pStyles[3], oWriter, 9); + oWriter.WriteString(std::wstring(L"")); + + oWriter.WriteString(std::wstring(L"")); + } + else if (pTheme->m_eType == typeNotesMaster) + { + oWriter.WriteString(std::wstring(L"")); + styleWriter.ConvertStyles(pTheme->m_pStyles[1], oWriter, 9); + oWriter.WriteString(std::wstring(L"")); + } + + std::wstring strPptDirectory = m_strTempDirectory + FILE_SEPARATOR_STR + _T("ppt") + FILE_SEPARATOR_STR ; + + std::wstring strSlideMasterFile; + std::wstring strSlideMasterRelsFile; + if (pTheme->m_eType == typeMaster) + { + oWriter.WriteString(std::wstring(L"")); + + strSlideMasterFile = L"slideMaster" + std::to_wstring(nIndexTheme) + L".xml"; + strSlideMasterFile = strPptDirectory + _T("slideMasters") + FILE_SEPARATOR_STR + strSlideMasterFile; + + strSlideMasterRelsFile = L"slideMaster" + std::to_wstring(nIndexTheme) + L".xml.rels"; + strSlideMasterRelsFile = strPptDirectory + _T("slideMasters") + FILE_SEPARATOR_STR + _T("_rels") + FILE_SEPARATOR_STR + strSlideMasterRelsFile; + } + else if (pTheme->m_eType == typeNotesMaster) + { + oWriter.WriteString(std::wstring(L"")); + + strSlideMasterFile = L"notesMaster1.xml"; + strSlideMasterFile = strPptDirectory + _T("notesMasters") + FILE_SEPARATOR_STR + strSlideMasterFile; + + strSlideMasterRelsFile = L"notesMaster1.xml.rels"; + strSlideMasterRelsFile = strPptDirectory + _T("notesMasters") + FILE_SEPARATOR_STR + _T("_rels") + FILE_SEPARATOR_STR + strSlideMasterRelsFile; + } + else if (pTheme->m_eType == typeHandoutMaster) + { + oWriter.WriteString(std::wstring(L"")); + + strSlideMasterFile = L"handoutMaster1.xml"; + strSlideMasterFile = strPptDirectory + _T("handoutMasters") + FILE_SEPARATOR_STR + strSlideMasterFile; + + strSlideMasterRelsFile = L"handoutMaster1.xml.rels"; + strSlideMasterRelsFile = strPptDirectory + _T("handoutMasters") + FILE_SEPARATOR_STR + _T("_rels") + FILE_SEPARATOR_STR + strSlideMasterRelsFile; + } + + NSFile::CFileBinary oFile; + oFile.CreateFileW(strSlideMasterFile); + std::wstring strMaster = oWriter.GetData(); + oFile.WriteStringUTF8(strMaster); + oFile.CloseFile(); + + oRels.CloseRels(); + oRels.SaveRels(strSlideMasterRelsFile); + + nStartLayout += nCountLayouts; +} + void PPT_FORMAT::CPPTXWriter::WriteTiming(CStringWriter& oWriter, CRelsGenerator &oRels, int nIndexSlide) { diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.h b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.h index a908185bbb..30481e6159 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.h +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.h @@ -70,16 +70,18 @@ namespace PPT_FORMAT } protected: - void WriteApp (CFile& oFile); + void WriteApp (NSFile::CFileBinary& oFile); void WriteContentTypes (); void WritePresInfo (); void WriteAll (); void WriteThemes (); + void WriteRoundTripThemes(const std::vector &arrRTThemes, int& nIndexTheme, int &nStartLayout); void WriteTheme (CThemePtr pTheme, int & nIndexTheme, int & nStartLayout); void WriteTheme (CRecordRoundTripThemeAtom *pTheme, int &nIndexTheme); void WriteSlides (); void WriteNotes (); - void WriteLayout (CLayoutPtr pLayout, int nIndexLayout, int nStartLayout, int nIndexTheme); + void WriteLayoutAfterTheme (CThemePtr pTheme, const int nIndexTheme, int &nStartLayout); + void WriteLayout (CLayoutPtr pLayout, int nIndexLayout, int nStartLayout, int nIndexTheme); void WriteSlide (int nIndexSlide); void WriteNotes (int nIndexNotes); void WriteTiming (CStringWriter& oWriter, CRelsGenerator &oRels, int nIndexSlide); // TODO write spec class for timing diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/ImageManager.h b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/ImageManager.h index d16b609857..a8eb5ce750 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/ImageManager.h +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/ImageManager.h @@ -85,11 +85,15 @@ namespace PPT_FORMAT inline std::wstring GenerateAudio(const std::wstring& strInput) { return GenerateMedia(strInput, L"audio", m_lIndexNextAudio, L".wav"); - } - inline std::wstring GenerateImage(const std::wstring& strInput) - { - return GenerateMedia(strInput, L"image", m_lIndexNextImage, L".png"); - } + } + inline std::wstring GenerateImage(const std::wstring& strInput) + { + return GenerateMedia(strInput, L"image", m_lIndexNextImage, L".png"); + } + inline std::wstring GenerateImageJPEG(const std::wstring& strInput) + { + return GenerateMedia(strInput, L"image", m_lIndexNextImage, L".jpeg"); + } inline std::wstring GenerateMedia(const std::wstring& strInput, const std::wstring& Template, long & Indexer, const std::wstring& strDefaultExt) { std::map::iterator pPair = m_mapMedia.find(strInput); @@ -123,7 +127,7 @@ namespace PPT_FORMAT nIndexExt = strInput1.rfind(wchar_t('.')); strExts = nIndexExt < 0 ? L"" : strInput1.substr(nIndexExt); } - if (strExts == _T(".tmp")) strExts = strDefaultExt; + if (strExts == _T(".tmp") || strExts.empty()) strExts = strDefaultExt; std::wstring strMediaName = Template + std::to_wstring(++Indexer); @@ -298,7 +302,7 @@ namespace PPT_FORMAT std::wstring strRels = L"" : L"\"/>"); m_oWriter.WriteString(strRels); diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/ShapeWriter.cpp b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/ShapeWriter.cpp index b5e791349f..aa2cdff02f 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/ShapeWriter.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/ShapeWriter.cpp @@ -59,17 +59,6 @@ void CStylesWriter::ConvertStyleLevel(PPT_FORMAT::CTextStyleLevel& oLevel, PPT_F PPT_FORMAT::CTextPFRun* pPF = &oLevel.m_oPFRun; - if (pPF->textDirection.is_init()) - { - if (pPF->textDirection.get() == 1) oWriter.WriteString(L" rtl=\"1\""); - else oWriter.WriteString(L" rtl=\"0\""); - } - if (pPF->fontAlign.is_init()) - { - std::wstring strProp = GetFontAlign(pPF->fontAlign.get()); - oWriter.WriteString(L" fontAlgn=\"" + strProp + L"\""); - } - int leftMargin = 0; if (pPF->leftMargin.is_init()) { @@ -92,7 +81,17 @@ void CStylesWriter::ConvertStyleLevel(PPT_FORMAT::CTextStyleLevel& oLevel, PPT_F std::wstring strProp = std::to_wstring(pPF->defaultTabSize.get()); oWriter.WriteString(L" defTabSz=\"" + strProp + L"\""); } - oWriter.WriteString(L">"); + if (pPF->textDirection.is_init()) + { + if (pPF->textDirection.get() == 1) oWriter.WriteString(L" rtl=\"1\""); + else oWriter.WriteString(L" rtl=\"0\""); + } + if (pPF->fontAlign.is_init()) + { + std::wstring strProp = GetFontAlign(pPF->fontAlign.get()); + oWriter.WriteString(L" fontAlgn=\"" + strProp + L"\""); + } + oWriter.WriteString(L">"); if (pPF->tabStops.size() > 0) { @@ -217,7 +216,14 @@ void CStylesWriter::ConvertStyleLevel(PPT_FORMAT::CTextStyleLevel& oLevel, PPT_F PPT_FORMAT::CTextCFRun* pCF = &oLevel.m_oCFRun; - if (pCF->Size.is_init()) + if (pCF->Language.is_init()) + { + std::wstring str_lang = msLCID2wstring(pCF->Language.get()); + + if (str_lang.length() > 0) + oWriter.WriteString(std::wstring(L" lang=\"") + str_lang + _T("\"")); + } + if (pCF->Size.is_init()) { std::wstring str = std::to_wstring((int)(100 * pCF->Size.get())); oWriter.WriteString(L" sz=\"" + str + L"\""); @@ -236,13 +242,7 @@ void CStylesWriter::ConvertStyleLevel(PPT_FORMAT::CTextStyleLevel& oLevel, PPT_F else oWriter.WriteString(std::wstring(L" i=\"0\"")); } - if (pCF->Language.is_init()) - { - std::wstring str_lang = msLCID2wstring(pCF->Language.get()); - if (str_lang.length() > 0) - oWriter.WriteString(std::wstring(L" lang=\"") + str_lang + _T("\"")); - } oWriter.WriteString(std::wstring(L">")); if (pCF->Color.is_init()) @@ -738,14 +738,18 @@ void PPT_FORMAT::CShapeWriter::WriteImageInfo() bool bExternal = false; std::wstring strRid = m_pRels->WriteAudio(pAudioElement->m_strAudioFileName, bExternal); - m_oWriter.WriteString(L""); + if ((int)pAudioElement->m_strAudioFileName.find(L".WAV") == -1 && + (int)pAudioElement->m_strAudioFileName.find(L".wav") == -1) + m_oWriter.WriteString(L""); + else + m_oWriter.WriteString(L""); sMediaFile = bExternal ? L"" : pAudioElement->m_strAudioFileName; } if (sMediaFile.empty() == false) { - std::wstring strRid = m_pRels->WriteMedia(sMediaFile); - if (!strRid.empty()) + std::wstring strRid = m_pRels->WriteImage(pImageElement->m_strImageFileName); + if (!strRid.empty() && false) { m_oWriter.WriteString(L"\ "); @@ -1270,29 +1274,21 @@ void PPT_FORMAT::CShapeWriter::WriteTextInfo() // if (pParagraph->m_arSpans.size() == 1 && pParagraph->m_arSpans[0].m_strText.empty()) break; //} - std::wstring _str1 = std::to_wstring(pParagraph->m_lTextLevel); - m_oWriter.WriteString(L"m_oPFRun; - - if (pPF->textDirection.is_init()) - { - if (pPF->textDirection.get() == 1) m_oWriter.WriteString(std::wstring(L" rtl=\"1\"")); - else m_oWriter.WriteString(std::wstring(L" rtl=\"0\"")); - } - if (pPF->fontAlign.is_init()) - { - std::wstring strProp = CStylesWriter::GetFontAlign(pPF->fontAlign.get()); - m_oWriter.WriteString(std::wstring(L" fontAlgn=\"") + strProp + L"\""); - } - int leftMargin = 0; + + int leftMargin = 0; if (pPF->leftMargin.is_init()) { leftMargin = pPF->leftMargin.get(); std::wstring strProp = std::to_wstring( leftMargin ); m_oWriter.WriteString(L" marL=\"" + strProp + L"\""); } - if (pPF->indent.is_init()) + std::wstring _strLevel = std::to_wstring(pParagraph->m_lTextLevel); + m_oWriter.WriteString(L" lvl=\"" + _strLevel + L"\""); + + if (pPF->indent.is_init()) { std::wstring strProp = std::to_wstring(pPF->indent.get() - leftMargin); m_oWriter.WriteString(L" indent=\"" + strProp + L"\""); @@ -1307,7 +1303,17 @@ void PPT_FORMAT::CShapeWriter::WriteTextInfo() std::wstring strProp= std::to_wstring( pPF->defaultTabSize.get()); m_oWriter.WriteString(L" defTabSz=\"" + strProp + L"\""); } - m_oWriter.WriteString(L">"); + if (pPF->textDirection.is_init()) + { + if (pPF->textDirection.get() == 1) m_oWriter.WriteString(std::wstring(L" rtl=\"1\"")); + else m_oWriter.WriteString(std::wstring(L" rtl=\"0\"")); + } + if (pPF->fontAlign.is_init()) + { + std::wstring strProp = CStylesWriter::GetFontAlign(pPF->fontAlign.get()); + m_oWriter.WriteString(std::wstring(L" fontAlgn=\"") + strProp + L"\""); + } + m_oWriter.WriteString(L">"); double dKoef1 = 3.52777778; // :-) чё это не понятно ... if (pPF->lineSpacing.is_init()) @@ -1392,10 +1398,15 @@ void PPT_FORMAT::CShapeWriter::WriteTextInfo() } m_oWriter.WriteString(std::wstring(L"/>")); } - if (pPF->bulletAutoNum.is_init()) // TODO Numbering + if (pPF->bulletAutoNum.is_init() && !pPF->bulletChar.is_init()) // TODO Numbering { m_oWriter.WriteString(L"bulletAutoNum->type.get()); + if (pPF->bulletAutoNum->startAt.get2() != 1) + { + m_oWriter.WriteString(L" startAt=\""); + m_oWriter.WriteString(std::to_wstring(pPF->bulletAutoNum->startAt.get2())); + } m_oWriter.WriteString(L"\"/>"); } @@ -1484,7 +1495,13 @@ void PPT_FORMAT::CShapeWriter::WriteTextInfo() m_oWriter.WriteString(std::wstring(L"Language.is_init()) + { + std::wstring str_lang = msLCID2wstring(pCF->Language.get()); + if (str_lang.length() > 0) + m_oWriter.WriteString(std::wstring(L" lang=\"") + str_lang + _T("\"")); + } if ((pCF->Size.is_init()) && (pCF->Size.get() > 0) && (pCF->Size.get() < 4001)) { m_oWriter.WriteString(L" sz=\"" + std::to_wstring((int)(100 * pCF->Size.get())) + L"\""); @@ -1515,13 +1532,7 @@ void PPT_FORMAT::CShapeWriter::WriteTextInfo() else m_oWriter.WriteString(std::wstring(L" u=\"none\"")); } - if (pCF->Language.is_init()) - { - std::wstring str_lang = msLCID2wstring(pCF->Language.get()); - if (str_lang.length() > 0) - m_oWriter.WriteString(std::wstring(L" lang=\"") + str_lang + _T("\"")); - } m_oWriter.WriteString(std::wstring(L">")); WriteHyperlink(pParagraph->m_arSpans[nSpan].m_arrInteractive); @@ -1716,6 +1727,7 @@ void PPT_FORMAT::CShapeWriter::WriteHyperlink(const std::vectorembed = m_pRels->WriteAudio(actions[i].m_strAudioFileName, bExternal); hlink.snd->m_name = L"snd"; hlink.snd->name = actions[i].m_strAudioName; + hlink.id = std::wstring(L""); } if (actions[i].m_eActivation == CInteractiveInfo::over) @@ -1793,7 +1805,8 @@ void PPT_FORMAT::CShapeWriter::WriteHyperlink(const std::vector @@ -13,7 +13,7 @@ void TableWriter::Convert(PPTX::Logic::GraphicFrame &oGraphicFrame) if (!m_pTableElement) return; - if (m_pTableElement->m_xmlRawData.empty()/* || true*/) + if (/*m_pTableElement->m_xmlRawData.empty() || */true) { oGraphicFrame.nvGraphicFramePr = new PPTX::Logic::NvGraphicFramePr; FillNvGraphicFramePr(oGraphicFrame.nvGraphicFramePr.get2()); @@ -24,11 +24,6 @@ void TableWriter::Convert(PPTX::Logic::GraphicFrame &oGraphicFrame) oGraphicFrame.table = new PPTX::Logic::Table; FillTable(oGraphicFrame.table.get2()); } - else - { - oGraphicFrame.fromXMLString(getXmlForGraphicFrame()); -// CorrectGraphicFrame(oGraphicFrame); - } } void TableWriter::FillNvGraphicFramePr(PPTX::Logic::NvGraphicFramePr& oNvGFPr) @@ -392,7 +387,7 @@ void TableWriter::FillRow(PPTX::Logic::TableRow &oRow, ProtoTableRow& arrCells) } } -std::wstring TableWriter::getXmlForGraphicFrame() const +std::wstring TableWriter::getXmlForGraphicFrame(int ID, int idx) const { auto& rXml = m_pTableElement->m_xmlRawData; @@ -402,7 +397,20 @@ std::wstring TableWriter::getXmlForGraphicFrame() const xml += std::wstring(rXml.begin() + startIter, rXml.begin() + endIter); xml += L""; - return xml; + PPTX::Logic::GraphicFrame graphic_frame; + + graphic_frame.fromXMLString(xml); + + if (graphic_frame.nvGraphicFramePr.IsInit()) + { + graphic_frame.nvGraphicFramePr->cNvPr.id = ID; // или менять в карте связей для анимаций + + if (graphic_frame.nvGraphicFramePr->nvPr.ph.IsInit() && idx >= 0) + {//проверить + graphic_frame.nvGraphicFramePr->nvPr.ph->idx = std::to_wstring(idx); + } + } + return graphic_frame.toXML(); } void TableWriter::CorrectGraphicFrame(PPTX::Logic::GraphicFrame &oGraphicFrame) diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.h b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.h index 78239491f7..e52c855b47 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.h +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.h @@ -159,8 +159,9 @@ private: void FillRow(PPTX::Logic::TableRow& oRow, ProtoTableRow &arrCells); +public: + std::wstring getXmlForGraphicFrame(int ID, int idx)const; private: - std::wstring getXmlForGraphicFrame()const; void CorrectGraphicFrame(PPTX::Logic::GraphicFrame& oGraphicFrame); void FillnvPr(PPTX::Logic::NvPr& oNvPr); diff --git a/ASCOfficePPTFile/PPTFormatLib/Reader/PPTDocumentInfoOneUser.cpp b/ASCOfficePPTFile/PPTFormatLib/Reader/PPTDocumentInfoOneUser.cpp index b2f038d0ad..810df439d8 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Reader/PPTDocumentInfoOneUser.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/Reader/PPTDocumentInfoOneUser.cpp @@ -1635,10 +1635,14 @@ void CPPTUserInfo::LoadMainMaster(_UINT32 dwMasterID) for (auto& oMaster : m_mapMasters) - oMaster.second->GetRecordsByType(&pTheme->m_arrZipXml, false); + if (oMaster.second != nullptr) + oMaster.second->GetRecordsByType(&pTheme->m_arrZipXml, false); // for (auto& oNoteMaster : m_mapNotesMasters) -// oNoteMaster.second->GetRecordsByType(&pTheme->m_arrZipXml, false); +// if (oNoteMaster.second != nullptr) +// oNoteMaster.second->GetRecordsByType(&pTheme->m_arrZipXml, false); + // for (auto& oHandoutMaster : m_mapHandoutMasters) +// if (oHandoutMaster.second != nullptr) // oHandoutMaster.second->GetRecordsByType(&pTheme->m_arrZipXml, false); if (lLayoutID >= 0 && false == pTheme->m_arLayouts.empty()) diff --git a/ASCOfficePPTFile/PPTFormatLib/Reader/ReadStructures.cpp b/ASCOfficePPTFile/PPTFormatLib/Reader/ReadStructures.cpp index 75cd2e568b..684c811579 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Reader/ReadStructures.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/Reader/ReadStructures.cpp @@ -523,6 +523,8 @@ namespace PPT_FORMAT int nCountCFs = (int)oArrayCF.size(); oAttributes.m_arParagraphs.clear(); + oAttributes.m_originalText = strText; + int nCurrentPF = 0; int nCurrentCF = 0; int nOffsetCF = 0; diff --git a/ASCOfficePPTFile/PPTFormatLib/Reader/ReadStructures.h b/ASCOfficePPTFile/PPTFormatLib/Reader/ReadStructures.h index 5b61b55547..1fd293ca3e 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Reader/ReadStructures.h +++ b/ASCOfficePPTFile/PPTFormatLib/Reader/ReadStructures.h @@ -248,15 +248,15 @@ public: } } - void ToFile(CFile* pFile) + void ToFile(NSFile::CFileBinary* pFile) { if (NULL != m_pMetaHeader) { - pFile->WriteFile((void*)m_pMetaHeader, m_lMetaHeaderSize); + pFile->WriteFile(m_pMetaHeader, m_lMetaHeaderSize); } if (NULL != m_pMetaFile) { - pFile->WriteFile((void*)m_pMetaFile, m_lMetaFileSize); + pFile->WriteFile(m_pMetaFile, m_lMetaFileSize); } } }; diff --git a/ASCOfficePPTFile/PPTFormatLib/Reader/Records.h b/ASCOfficePPTFile/PPTFormatLib/Reader/Records.h index 728d75dc86..01283d1b10 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Reader/Records.h +++ b/ASCOfficePPTFile/PPTFormatLib/Reader/Records.h @@ -57,6 +57,8 @@ public: unsigned short RecInstance; PPT_FORMAT::RecordType RecType; _UINT32 RecLen; + + bool bBadHeader; void Clear() { @@ -64,6 +66,8 @@ public: RecInstance = 0; RecType = RT_NONE; RecLen = 0; + + bBadHeader = false; } SRecordHeader() { @@ -86,9 +90,10 @@ public: unsigned long sz = pStream->getStreamSize() - pStream->getStreamPointer(); - if (RecLen > sz ) + if (RecLen > sz) { - RecLen = sz; + RecLen = (UINT)sz; + bBadHeader = true; // GZoabli_PhD.ppt ... RecLen & 0xffff ???? } return true; @@ -115,9 +120,10 @@ public: POLE::uint64 sz = pStream->size() - pStream->tell(); - if (RecLen > sz ) + if (RecLen > sz) { RecLen = (UINT)sz; + bBadHeader = true; // GZoabli_PhD.ppt ... RecLen & 0xffff ???? } return true; diff --git a/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ArtBlip.cpp b/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ArtBlip.cpp index 7e3e712189..11cf71737b 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ArtBlip.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ArtBlip.cpp @@ -193,10 +193,9 @@ void CRecordOfficeArtBlip::ReadFromStream(SRecordHeader & oHeader, POLE::Stream* { std::wstring strFile = L"Image " +std::to_wstring(nImagesCount + 1) + oMetaFile.m_sExtension; - CFile fileMeta; - HRESULT hr = fileMeta.CreateFile(m_strTmpDirectory + FILE_SEPARATOR_STR + strFile); + NSFile::CFileBinary fileMeta; - if (hr == S_OK) + if (fileMeta.CreateFileW(m_strTmpDirectory + FILE_SEPARATOR_STR + strFile)) { oMetaFile.ToFile(&fileMeta); fileMeta.CloseFile(); @@ -214,22 +213,22 @@ void CRecordOfficeArtBlip::ReadFromStream(SRecordHeader & oHeader, POLE::Stream* } std::wstring strFile = L"Image " + std::to_wstring(nImagesCount + 1) + sExt; - CFile fileImage; - HRESULT hr = fileImage.CreateFile(m_strTmpDirectory + FILE_SEPARATOR_STR + strFile); - if (hr == S_OK) + NSFile::CFileBinary fileImage; + + if (fileImage.CreateFileW(m_strTmpDirectory + FILE_SEPARATOR_STR + strFile)) { if (RECORD_TYPE_ESCHER_BLIP_DIB == oHeader.RecType) { WORD vtType = 0x4D42; - fileImage.WriteFile((void*)&vtType, 2); + fileImage.WriteFile((BYTE*)&vtType, 2); _UINT32 dwLen = oHeader.RecLen - lOffset; - fileImage.WriteFile((void*)&dwLen, 4); + fileImage.WriteFile((BYTE*)&dwLen, 4); _UINT32 dwRes = 0; - fileImage.WriteFile((void*)&dwRes, 4); + fileImage.WriteFile((BYTE*)&dwRes, 4); _UINT32 dwOffset = 2; - fileImage.WriteFile((void*)&dwOffset, 4); + fileImage.WriteFile((BYTE*)&dwOffset, 4); } - fileImage.WriteFile((void*)pImage, oHeader.RecLen - lOffset); + fileImage.WriteFile(pImage, oHeader.RecLen - lOffset); fileImage.CloseFile(); } if (pImage)delete[] pImage; diff --git a/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp b/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp index cd8251c88c..131b4be6c5 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp @@ -1880,7 +1880,6 @@ CElementPtr CRecordShapeContainer::GetElement (bool inGroup, CExMedia* pMapIDs, if (0 < oArrayTextBytes.size() && strShapeText.empty()) { strShapeText = oArrayTextBytes[0]->m_strText; - pShapeElem->m_pShape->m_oText.m_originalText = strShapeText; } std::vector oArrayTextChars; @@ -1935,9 +1934,9 @@ CElementPtr CRecordShapeContainer::GetElement (bool inGroup, CExMedia* pMapIDs, if (oArrayTextBox.size()) { + // It's differance records oArrayTextBox[0]->GetRecordsByType(&oArrayTextInteractive, false); - -// oArrayTextBox[0]->GetRecordsByType(&oArrayInteractiveCont, false); + oArrayTextBox[0]->GetRecordsByType(&oArrayInteractiveCont, false); } for (const auto* pInerAtom : oArrayInteractiveCont) @@ -2559,12 +2558,13 @@ void CRecordShapeContainer::ApplyHyperlink(CShapeElement* pShape, CColor& oColor auto& oTextAttributes = pShape->m_pShape->m_oText; const auto& originalText = oTextAttributes.m_originalText; + // lenght these ones shoud be equal const auto& arrRanges = pShape->m_oTextActions.m_arRanges; const auto arrSplitedInteractive = splitInteractive(pShape->m_textHyperlinks); // It cannot be changed - if (arrRanges.empty() || arrSplitedInteractive.empty()) + if (arrRanges.empty() || arrSplitedInteractive.empty() || originalText.empty()) return; size_t posOrigText(0); @@ -2586,12 +2586,16 @@ 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; + // Skiping span with '\r' + if (iterSpan->m_strText.size() && (int)iterSpan->m_strText.find(L"\r") != -1) + continue; + posOrigText += blockLen; // Skipping span if (iterRange->m_lStart > posBlockEnd) @@ -2615,10 +2619,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--; } - addHyperlinkToSpan(*iterSpan, *iterInteractive, oColor); + if (iterSpan != arrSpans.end() && iterInteractive != arrSplitedInteractive.end()) + addHyperlinkToSpan(*iterSpan, *iterInteractive, oColor); + else + break; //GZoabli_PhD.ppt if (posBlockEnd == iterRange->m_lEnd) { diff --git a/ASCOfficePPTFile/PPTFormatLib/Records/OutlineTextProps9Container.h b/ASCOfficePPTFile/PPTFormatLib/Records/OutlineTextProps9Container.h index 2301246413..130c1fd9e7 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Records/OutlineTextProps9Container.h +++ b/ASCOfficePPTFile/PPTFormatLib/Records/OutlineTextProps9Container.h @@ -45,8 +45,16 @@ public: void ReadFromStream(SRecordHeader &oHeader, POLE::Stream *pStream) override { CRecordOutlineTextPropsHeaderExAtom::ReadFromStream(oHeader, pStream); - SRecordHeader ReadHeader; + + SRecordHeader ReadHeader; ReadHeader.ReadFromStream(pStream); + + if (ReadHeader.bBadHeader) + { + oHeader.bBadHeader = true; // GZoabli_PhD.ppt + return; + } + m_styleTextProp9Atom.ReadFromStream(ReadHeader, pStream); } }; @@ -66,25 +74,29 @@ public: } } - virtual void ReadFromStream(SRecordHeader &oHeader, POLE::Stream *pStream) - { - m_oHeader = oHeader; - LONG lPos = 0; - StreamUtils::StreamPosition ( lPos, pStream ); + virtual void ReadFromStream(SRecordHeader &oHeader, POLE::Stream *pStream) + { + m_oHeader = oHeader; + LONG lPos = 0; + StreamUtils::StreamPosition(lPos, pStream); - UINT lCurLen = 0; + UINT lCurLen = 0; - SRecordHeader ReadHeader; + SRecordHeader ReadHeader; - while ( lCurLen < m_oHeader.RecLen ) - { - if ( ReadHeader.ReadFromStream(pStream) == false) + while (lCurLen < m_oHeader.RecLen) + { + if (ReadHeader.ReadFromStream(pStream) == false || ReadHeader.bBadHeader) break; lCurLen += 8 + ReadHeader.RecLen; auto pRec = new CRecordOutlineTextProps9Entry; pRec->ReadFromStream(ReadHeader, pStream); + + if (ReadHeader.bBadHeader) + break; + m_rgOutlineTextProps9Entry.push_back(pRec); } StreamUtils::StreamSeek(lPos + m_oHeader.RecLen, pStream); diff --git a/ASCOfficePPTFile/PPTFormatLib/Records/RoundTripThemeAtom.h b/ASCOfficePPTFile/PPTFormatLib/Records/RoundTripThemeAtom.h index 9134d872a0..b80ad34eb3 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Records/RoundTripThemeAtom.h +++ b/ASCOfficePPTFile/PPTFormatLib/Records/RoundTripThemeAtom.h @@ -50,5 +50,10 @@ public: data = std::make_pair(boost::shared_array(new unsigned char[m_oHeader.RecLen]), m_oHeader.RecLen); pStream->read(data.first.get(), data.second); + +// std::string filename = "roundtrip/" + std::to_string(data.second) + ".zip"; +// std::ofstream file(filename, std::ios::binary | std::ios::out); +// file.write((char*)data.first.get(), data.second); +// file.close(); } }; diff --git a/ASCOfficePPTFile/PPTFormatLib/Structures/IStruct.h b/ASCOfficePPTFile/PPTFormatLib/Structures/IStruct.h index 9085c37f7c..8f74f97fc0 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Structures/IStruct.h +++ b/ASCOfficePPTFile/PPTFormatLib/Structures/IStruct.h @@ -32,7 +32,7 @@ #pragma once #include "../../../Common/DocxFormat/Source/Base/Types_32.h" -#include "../../../Common/DocxFormat/Source/SystemUtility/File.h" +#include "../../../DesktopEditor/common/File.h" namespace PPT_FORMAT { struct IStruct { diff --git a/ASCOfficePPTFile/PPTFormatLib/Win32/PPTFormatLib.vcxproj b/ASCOfficePPTFile/PPTFormatLib/Win32/PPTFormatLib.vcxproj index a5c7d0ab65..8dc7db0c39 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Win32/PPTFormatLib.vcxproj +++ b/ASCOfficePPTFile/PPTFormatLib/Win32/PPTFormatLib.vcxproj @@ -377,6 +377,8 @@ + + @@ -392,6 +394,8 @@ + + @@ -422,35 +426,29 @@ + + + + + + + + + + - - - - - - - - - - - - - - - - diff --git a/ASCOfficePPTFile/PPTFormatLib/Win32/PPTFormatLib.vcxproj.filters b/ASCOfficePPTFile/PPTFormatLib/Win32/PPTFormatLib.vcxproj.filters index 9f86d6f544..c2728bf15f 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Win32/PPTFormatLib.vcxproj.filters +++ b/ASCOfficePPTFile/PPTFormatLib/Win32/PPTFormatLib.vcxproj.filters @@ -652,54 +652,6 @@ Records\Slide - - Records\Text - - - Records\Text - - - Records\Text - - - Records\Text - - - Records\Text - - - Records\Text - - - Records\Text - - - Records\Text - - - Records\Text - - - Records\Text - - - Records\Text - - - Records\Text - - - Records\Text - - - Records\Text - - - Records\Text - - - Records\Text - Reader @@ -745,6 +697,48 @@ OOXElements + + Records\Text + + + Records\Text + + + Records\Text + + + Records\Text + + + Records\Text + + + Records\Text + + + Records\Text + + + Records\Text + + + Records\Text + + + Records\Text + + + Records\Text + + + Records\Text + + + Records\Text + + + Records\Text + diff --git a/ASCOfficePPTXFile/Editor/Drawing/Attributes.h b/ASCOfficePPTXFile/Editor/Drawing/Attributes.h index e1462c2e06..ed3a8ceed3 100644 --- a/ASCOfficePPTXFile/Editor/Drawing/Attributes.h +++ b/ASCOfficePPTXFile/Editor/Drawing/Attributes.h @@ -42,6 +42,7 @@ #include "../../../DesktopEditor/graphics/IRenderer.h" #include "../../../DesktopEditor/graphics/structures.h" #include "../../../Common/DocxFormat/Source/XML/Utils.h" +#include static void ReplaceAll(std::wstring & str, const std::wstring& from, const std::wstring& to) { @@ -130,6 +131,19 @@ public: } } + // Second chance + std::vector splited; + boost::split(splited, str, boost::is_any_of(L",")); + if (splited.size() == 3) + { + try { + int num = std::stoi(splited[1]); + if (num > 0 && num < 256) + return num; + } catch (...) { + + } + } return -1; } static bool isHTTPLink(const std::wstring &str) diff --git a/ASCOfficePPTXFile/Editor/Drawing/Document.h b/ASCOfficePPTXFile/Editor/Drawing/Document.h index af7038c5f0..21e606e528 100644 --- a/ASCOfficePPTXFile/Editor/Drawing/Document.h +++ b/ASCOfficePPTXFile/Editor/Drawing/Document.h @@ -36,268 +36,279 @@ namespace PPT_FORMAT { - class CDocument - { - public: - long m_lSlideWidth; - long m_lSlideHeight; +class CDocument +{ +public: + long m_lSlideWidth; + long m_lSlideHeight; - long m_lNotesWidth; - long m_lNotesHeight; + long m_lNotesWidth; + long m_lNotesHeight; - std::vector m_arThemes; - std::vector m_arSlides; - std::vector m_arNotes; + std::vector m_arThemes; + std::vector m_arSlides; + std::vector m_arNotes; - CThemePtr m_pNotesMaster; - CThemePtr m_pHandoutMaster; + CThemePtr m_pNotesMaster; + CThemePtr m_pHandoutMaster; - bool m_bMacros; - std::wstring m_sVbaProjectFile; + bool m_bMacros; + std::wstring m_sVbaProjectFile; - CDocument() : m_bMacros (true) - { - m_lSlideWidth = 0; - m_lSlideHeight = 0; + CDocument() : m_bMacros (true) + { + m_lSlideWidth = 0; + m_lSlideHeight = 0; - m_lNotesWidth = 0; - m_lNotesHeight = 0; - } + m_lNotesWidth = 0; + m_lNotesHeight = 0; + } - virtual ~CDocument() - { - Clear(); - } + virtual ~CDocument() + { + Clear(); + } - void Clear() - { - m_arThemes.clear(); - try - { - ClearSlides(); - ClearNotes(); - }catch(...) - { - } - } - inline void ClearSlides() - { - for (size_t i = 0 ; i < m_arSlides.size(); i++) - { - RELEASEOBJECT(m_arSlides[i]); - } - m_arSlides.clear(); - } - inline void ClearNotes() - { - for (size_t i = 0 ; i < m_arNotes.size(); i++) - { - RELEASEOBJECT(m_arNotes[i]); - } - m_arNotes.clear(); - } - void CalculateSlideElements(int nIndex, CAudioOverlay& oAudioOverlay) - { - double dStartTime = m_arSlides[nIndex]->m_dStartTime; - double dEndTime = m_arSlides[nIndex]->m_dEndTime; - double dDuration = m_arSlides[nIndex]->m_dDuration; - - CSlide* pSlide = m_arSlides[nIndex]; - - size_t nCountElems = pSlide->m_arElements.size(); - for (size_t i = 0; i < nCountElems; ++i) - { - CElementPtr pElement = pSlide->m_arElements[i]; + void Clear() + { + m_arThemes.clear(); + try + { + ClearSlides(); + ClearNotes(); + }catch(...) + { + } + } + inline void ClearSlides() + { + for (size_t i = 0 ; i < m_arSlides.size(); i++) + { + RELEASEOBJECT(m_arSlides[i]); + } + m_arSlides.clear(); + } + inline void ClearNotes() + { + for (size_t i = 0 ; i < m_arNotes.size(); i++) + { + RELEASEOBJECT(m_arNotes[i]); + } + m_arNotes.clear(); + } + void CalculateSlideElements(int nIndex, CAudioOverlay& oAudioOverlay) + { + double dStartTime = m_arSlides[nIndex]->m_dStartTime; + double dEndTime = m_arSlides[nIndex]->m_dEndTime; + double dDuration = m_arSlides[nIndex]->m_dDuration; - switch (pElement->m_etType) - { - case etAudio: - { - CAudioElement* pAudioElem = dynamic_cast(pElement.get()); + CSlide* pSlide = m_arSlides[nIndex]; - if (NULL != pAudioElem) - { - // а другого и быть не может - if (pAudioElem->m_bWithVideo) - { - pElement->m_dStartTime = dStartTime; - pElement->m_dEndTime = dEndTime; - } - else if (pAudioElem->m_bLoop) - { - pElement->m_dStartTime = dStartTime; - pElement->m_dEndTime = oAudioOverlay.m_dAllDuration/* - dStartTime*/; - } - else - { - pElement->m_dStartTime = dStartTime; - pElement->m_dEndTime = (std::min)(dStartTime + pAudioElem->m_dAudioDuration, oAudioOverlay.m_dAllDuration/* - dStartTime*/); - } + size_t nCountElems = pSlide->m_arElements.size(); + for (size_t i = 0; i < nCountElems; ++i) + { + CElementPtr pElement = pSlide->m_arElements[i]; - CAudioPart oPart(pAudioElem); - oAudioOverlay.m_arParts.push_back(oPart); - } + switch (pElement->m_etType) + { + case etAudio: + { + CAudioElement* pAudioElem = dynamic_cast(pElement.get()); - break; - } - default: - //{ - //pElement->m_dStartTime = 0; - //pElement->m_dEndTime = dDuration; + if (NULL != pAudioElem) + { + // а другого и быть не может + if (pAudioElem->m_bWithVideo) + { + pElement->m_dStartTime = dStartTime; + pElement->m_dEndTime = dEndTime; + } + else if (pAudioElem->m_bLoop) + { + pElement->m_dStartTime = dStartTime; + pElement->m_dEndTime = oAudioOverlay.m_dAllDuration/* - dStartTime*/; + } + else + { + pElement->m_dStartTime = dStartTime; + pElement->m_dEndTime = (std::min)(dStartTime + pAudioElem->m_dAudioDuration, oAudioOverlay.m_dAllDuration/* - dStartTime*/); + } - break; - //} - }; - } - } + CAudioPart oPart(pAudioElem); + oAudioOverlay.m_arParts.push_back(oPart); + } - void ResetAutoText(CElementPtr pElement, vector_string const (&placeholdersReplaceString)[3]) - { - CShapeElement* pShape = dynamic_cast(pElement.get()); - - if (NULL == pShape) return; - - if (pElement->m_lPlaceholderType == PT_MasterSlideNumber) pShape->SetUpTextPlaceholder(L"<#>"); - - int ind = -1; - if (pElement->m_lPlaceholderType == PT_MasterDate) ind = 0; - if (pElement->m_lPlaceholderType == PT_MasterFooter) ind = 2; + break; + } + default: + //{ + //pElement->m_dStartTime = 0; + //pElement->m_dEndTime = dDuration; - if (pElement->m_lPlaceholderUserStr >= 0 && ind >= 0) - { - if (pElement->m_lPlaceholderUserStr < (int)placeholdersReplaceString[ind].size()) - pShape->SetUpTextPlaceholder( placeholdersReplaceString[ind][pElement->m_lPlaceholderUserStr] ); - else pShape->SetUpTextPlaceholder(L""); - } - else - { - if (pElement->m_lPlaceholderType == PT_MasterDate && pElement->m_nFormatDate == 1) - { - std::wstring current_date = L"11.11.2015"; - pShape->SetUpTextPlaceholder(current_date); - } - } - } + break; + //} + }; + } + } + std::vector getArrRoundTripTheme()const + { + std::vector arrRoundTripThemes; + for (const auto& theme : m_arThemes) + { + for (auto* pRoundTripAtom : theme->m_arrZipXml) + arrRoundTripThemes.push_back(pRoundTripAtom); + } - void CalculateEditor(bool bIsPlaceholderSetUp = false) - { - // автозамены и поля настраиваем тут во избежания путаницы + return arrRoundTripThemes; + } - size_t nCountThemes = m_arThemes.size(); - for (size_t i = 0; i < nCountThemes; ++i) - { - CTheme* pTheme = m_arThemes[i].get(); - pTheme->CalculateStyles(); + void ResetAutoText(CElementPtr pElement, vector_string const (&placeholdersReplaceString)[3]) + { + CShapeElement* pShape = dynamic_cast(pElement.get()); - size_t nCountElems = pTheme->m_arElements.size(); - for (size_t nIndexEl = 0; nIndexEl < nCountElems; ++nIndexEl) - { - CElementPtr pElement = pTheme->m_arElements[nIndexEl]; + if (NULL == pShape) return; - if (pElement->m_lPlaceholderType > 0) - { - ResetAutoText(pElement, pTheme->m_PlaceholdersReplaceString); - } - pElement->m_pTheme = pTheme; - pElement->m_pLayout = NULL; - } + if (pElement->m_lPlaceholderType == PT_MasterSlideNumber) pShape->SetUpTextPlaceholder(L"<#>"); - size_t nCountLayouts = pTheme->m_arLayouts.size(); - for (size_t nIndexL = 0; nIndexL < nCountLayouts; ++nIndexL) - { - CLayout* pLayout = pTheme->m_arLayouts[nIndexL].get(); + int ind = -1; + if (pElement->m_lPlaceholderType == PT_MasterDate) ind = 0; + if (pElement->m_lPlaceholderType == PT_MasterFooter) ind = 2; - size_t nCountLayoutElements = pLayout->m_arElements.size(); - for (size_t nIndexLayoutEl = 0; nIndexLayoutEl < nCountLayoutElements; ++nIndexLayoutEl) - { - CElementPtr pElement = pLayout->m_arElements[nIndexLayoutEl]; - - if (pElement->m_lPlaceholderType > 0) - { - ResetAutoText(pElement, pLayout->m_PlaceholdersReplaceString); - } + if (pElement->m_lPlaceholderUserStr >= 0 && ind >= 0) + { + if (pElement->m_lPlaceholderUserStr < (int)placeholdersReplaceString[ind].size()) + pShape->SetUpTextPlaceholder( placeholdersReplaceString[ind][pElement->m_lPlaceholderUserStr] ); + else pShape->SetUpTextPlaceholder(L""); + } + else + { + if (pElement->m_lPlaceholderType == PT_MasterDate && pElement->m_nFormatDate == 1) + { + std::wstring current_date = L"11.11.2015"; + pShape->SetUpTextPlaceholder(current_date); + } + } + } - pElement->m_pTheme = pTheme; - pElement->m_pLayout = NULL; + void CalculateEditor(bool bIsPlaceholderSetUp = false) + { + // автозамены и поля настраиваем тут во избежания путаницы - CShapeElement* pShape = dynamic_cast(pElement.get()); - if (!pLayout->m_bUseThemeColorScheme && NULL != pShape) - { - int lPhType = pElement->m_lPlaceholderType; - - int lIndex = 0; - - if (isTitlePlaceholder(lPhType)) lIndex = 1; - else if (isBodyPlaceholder(lPhType)) lIndex = 2; - else if (-1 != lPhType) lIndex = 3; + size_t nCountThemes = m_arThemes.size(); + for (size_t i = 0; i < nCountThemes; ++i) + { + CTheme* pTheme = m_arThemes[i].get(); + pTheme->CalculateStyles(); - CTextStyles* pThemeStyles = &pTheme->m_pStyles[lIndex]; - for (int nIndexLevel = 0; nIndexLevel < 10; ++nIndexLevel) - { - if (!pThemeStyles->m_pLevels[nIndexLevel].is_init()) - continue; - if (!pThemeStyles->m_pLevels[nIndexLevel]->m_oCFRun.Color.is_init()) - continue; - if (pThemeStyles->m_pLevels[nIndexLevel]->m_oCFRun.Color->m_lSchemeIndex == -1) - continue; + size_t nCountElems = pTheme->m_arElements.size(); + for (size_t nIndexEl = 0; nIndexEl < nCountElems; ++nIndexEl) + { + CElementPtr pElement = pTheme->m_arElements[nIndexEl]; - if (pShape->m_pShape->m_oText.m_oStyles.m_pLevels[0].is_init()) - { - if (pShape->m_pShape->m_oText.m_oStyles.m_pLevels[0]->m_oCFRun.Color.is_init()) - { + if (pElement->m_lPlaceholderType > 0) + { + ResetAutoText(pElement, pTheme->m_PlaceholdersReplaceString); + } + pElement->m_pTheme = pTheme; + pElement->m_pLayout = NULL; + } - if (pShape->m_pShape->m_oText.m_oStyles.m_pLevels[0]->m_oCFRun.Color->m_lSchemeIndex != -1) - continue; - - LONG lIndexSchemeT = pThemeStyles->m_pLevels[nIndexLevel]->m_oCFRun.Color->m_lSchemeIndex; + size_t nCountLayouts = pTheme->m_arLayouts.size(); + for (size_t nIndexL = 0; nIndexL < nCountLayouts; ++nIndexL) + { + CLayout* pLayout = pTheme->m_arLayouts[nIndexL].get(); - pShape->m_pShape->m_oText.m_oStyles.m_pLevels[0]->m_oCFRun.Color->m_lSchemeIndex = -1; - pShape->m_pShape->m_oText.m_oStyles.m_pLevels[0]->m_oCFRun.Color->R = pLayout->m_arColorScheme[lIndexSchemeT].R; - pShape->m_pShape->m_oText.m_oStyles.m_pLevels[0]->m_oCFRun.Color->G = pLayout->m_arColorScheme[lIndexSchemeT].G; - pShape->m_pShape->m_oText.m_oStyles.m_pLevels[0]->m_oCFRun.Color->B = pLayout->m_arColorScheme[lIndexSchemeT].B; - - bIsPlaceholderSetUp = true; - } - } - } - } - } - } - } + size_t nCountLayoutElements = pLayout->m_arElements.size(); + for (size_t nIndexLayoutEl = 0; nIndexLayoutEl < nCountLayoutElements; ++nIndexLayoutEl) + { + CElementPtr pElement = pLayout->m_arElements[nIndexLayoutEl]; - size_t nCountSlides = m_arSlides.size(); - for (size_t i = 0; i < nCountSlides; ++i) - { - CSlide* pSlide = m_arSlides[i]; + if (pElement->m_lPlaceholderType > 0) + { + ResetAutoText(pElement, pLayout->m_PlaceholdersReplaceString); + } - CTheme* pTheme = NULL; - if ((0 <= pSlide->m_lThemeID) && (pSlide->m_lThemeID < (LONG)nCountThemes)) - pTheme = m_arThemes[pSlide->m_lThemeID].get(); + pElement->m_pTheme = pTheme; + pElement->m_pLayout = NULL; - CLayout* pLayout = NULL; - if (NULL != pTheme) - { - if ((0 <= pSlide->m_lLayoutID) && (pSlide->m_lLayoutID < (LONG)pTheme->m_arLayouts.size())) - pLayout = pTheme->m_arLayouts[pSlide->m_lLayoutID].get(); - } + CShapeElement* pShape = dynamic_cast(pElement.get()); + if (!pLayout->m_bUseThemeColorScheme && NULL != pShape) + { + int lPhType = pElement->m_lPlaceholderType; - size_t nCountElems = pSlide->m_arElements.size(); - for (size_t nIndexEl = 0; nIndexEl < nCountElems; ++nIndexEl) - { - CElementPtr pElement = pSlide->m_arElements[nIndexEl]; + int lIndex = 0; - if (pElement->m_lPlaceholderType > 0) - { - ResetAutoText(pElement, pSlide->m_PlaceholdersReplaceString); - } - pElement->m_pTheme = pTheme; - pElement->m_pLayout = pLayout; + if (isTitlePlaceholder(lPhType)) lIndex = 1; + else if (isBodyPlaceholder(lPhType)) lIndex = 2; + else if (-1 != lPhType) lIndex = 3; - } + CTextStyles* pThemeStyles = &pTheme->m_pStyles[lIndex]; + for (int nIndexLevel = 0; nIndexLevel < 10; ++nIndexLevel) + { + if (!pThemeStyles->m_pLevels[nIndexLevel].is_init()) + continue; + if (!pThemeStyles->m_pLevels[nIndexLevel]->m_oCFRun.Color.is_init()) + continue; + if (pThemeStyles->m_pLevels[nIndexLevel]->m_oCFRun.Color->m_lSchemeIndex == -1) + continue; - if (NULL != pLayout && bIsPlaceholderSetUp) - pSlide->SetUpPlaceholderStyles(pLayout); - } - } - }; + if (pShape->m_pShape->m_oText.m_oStyles.m_pLevels[0].is_init()) + { + if (pShape->m_pShape->m_oText.m_oStyles.m_pLevels[0]->m_oCFRun.Color.is_init()) + { + + if (pShape->m_pShape->m_oText.m_oStyles.m_pLevels[0]->m_oCFRun.Color->m_lSchemeIndex != -1) + continue; + + LONG lIndexSchemeT = pThemeStyles->m_pLevels[nIndexLevel]->m_oCFRun.Color->m_lSchemeIndex; + + pShape->m_pShape->m_oText.m_oStyles.m_pLevels[0]->m_oCFRun.Color->m_lSchemeIndex = -1; + pShape->m_pShape->m_oText.m_oStyles.m_pLevels[0]->m_oCFRun.Color->R = pLayout->m_arColorScheme[lIndexSchemeT].R; + pShape->m_pShape->m_oText.m_oStyles.m_pLevels[0]->m_oCFRun.Color->G = pLayout->m_arColorScheme[lIndexSchemeT].G; + pShape->m_pShape->m_oText.m_oStyles.m_pLevels[0]->m_oCFRun.Color->B = pLayout->m_arColorScheme[lIndexSchemeT].B; + + bIsPlaceholderSetUp = true; + } + } + } + } + } + } + } + + size_t nCountSlides = m_arSlides.size(); + for (size_t i = 0; i < nCountSlides; ++i) + { + CSlide* pSlide = m_arSlides[i]; + + CTheme* pTheme = NULL; + if ((0 <= pSlide->m_lThemeID) && (pSlide->m_lThemeID < (LONG)nCountThemes)) + pTheme = m_arThemes[pSlide->m_lThemeID].get(); + + CLayout* pLayout = NULL; + if (NULL != pTheme) + { + if ((0 <= pSlide->m_lLayoutID) && (pSlide->m_lLayoutID < (LONG)pTheme->m_arLayouts.size())) + pLayout = pTheme->m_arLayouts[pSlide->m_lLayoutID].get(); + } + + size_t nCountElems = pSlide->m_arElements.size(); + for (size_t nIndexEl = 0; nIndexEl < nCountElems; ++nIndexEl) + { + CElementPtr pElement = pSlide->m_arElements[nIndexEl]; + + if (pElement->m_lPlaceholderType > 0) + { + ResetAutoText(pElement, pSlide->m_PlaceholdersReplaceString); + } + pElement->m_pTheme = pTheme; + pElement->m_pLayout = pLayout; + + } + + if (NULL != pLayout && bIsPlaceholderSetUp) + pSlide->SetUpPlaceholderStyles(pLayout); + } + } +}; } diff --git a/ASCOfficePPTXFile/Editor/Drawing/Shapes/BaseShape/PPTShape/ElementSettings.h b/ASCOfficePPTXFile/Editor/Drawing/Shapes/BaseShape/PPTShape/ElementSettings.h index 378491c569..6dbe792c21 100644 --- a/ASCOfficePPTXFile/Editor/Drawing/Shapes/BaseShape/PPTShape/ElementSettings.h +++ b/ASCOfficePPTXFile/Editor/Drawing/Shapes/BaseShape/PPTShape/ElementSettings.h @@ -33,7 +33,6 @@ #include "../../../../../../ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ArtBlip.h" -#include "../../../../../../Common/DocxFormat/Source/SystemUtility/File.h" #include "Enums.h" // это класс, использующийся для передачи свойств объектов, diff --git a/ASCOfficePPTXFile/PPTXFormat/Logic/Transitions/Transition.h b/ASCOfficePPTXFile/PPTXFormat/Logic/Transitions/Transition.h index 38dedee2d1..c5b1b03b7b 100644 --- a/ASCOfficePPTXFile/PPTXFormat/Logic/Transitions/Transition.h +++ b/ASCOfficePPTXFile/PPTXFormat/Logic/Transitions/Transition.h @@ -84,9 +84,9 @@ namespace PPTX virtual std::wstring toXML() const { XmlUtils::CAttribute oAttr; + oAttr.WriteLimitNullable(_T("spd"), spd); oAttr.Write(_T("advClick"), advClick); oAttr.Write(_T("advTm"), advTm); - oAttr.WriteLimitNullable(_T("spd"), spd); oAttr.Write(_T("dur"), dur); XmlUtils::CNodeValue oValue; diff --git a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/Dv.cpp b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/Dv.cpp index 047b17f23c..f0f6ebaf6a 100644 --- a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/Dv.cpp +++ b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/Dv.cpp @@ -47,13 +47,17 @@ static std::wstring replace_zero (const std::wstring &str, const std::wstring &d { if (pos >= str.size()) break; - if (str[pos] == '\0') + if (str[pos] == 0) { out += delimetr; } else if (str[pos] >= 0x20) { out += str[pos]; + } + else + { + } pos++; } diff --git a/Common/DocxFormat/Source/SystemUtility/File.h b/Common/DocxFormat/Source/SystemUtility/File.h index c4038866b0..fa4283843c 100644 --- a/Common/DocxFormat/Source/SystemUtility/File.h +++ b/Common/DocxFormat/Source/SystemUtility/File.h @@ -31,6 +31,8 @@ */ #pragma once #include +#include +#include #include "../../../3dParty/pole/pole.h" #include "../Base/unicode_util.h" @@ -39,7 +41,7 @@ #include "../../../../DesktopEditor/xml/include/xmlutils.h" #include "../../../../DesktopEditor/common/File.h" -class CFile +class CFile { private: HRESULT _Open(const std::wstring& strFileName, bool bOpen = false, bool bCreate = false, bool bReadWrite = false) @@ -312,6 +314,23 @@ public: RELEASEARRAYOBJECTS(pData); } + + static std::string md5(const BYTE* pData, const ULONG dataLen) + { + std::string strHash; + boost::uuids::detail::md5 hash; + boost::uuids::detail::md5::digest_type digest; + + hash.process_bytes(pData, dataLen); + hash.get_digest(digest); + + const auto charDigest = reinterpret_cast(&digest); + boost::algorithm::hex(charDigest, charDigest + sizeof(boost::uuids::detail::md5::digest_type), + std::back_inserter(strHash)); + + return strHash; + } + protected: FILE* m_pFile; @@ -321,252 +340,252 @@ protected: namespace StreamUtils { - static BYTE ReadBYTE(POLE::Stream* pStream) +static BYTE ReadBYTE(POLE::Stream* pStream) +{ + if (pStream == NULL) return 0; + + BYTE lMem = 0; + ULONG lReadByte = 0; + + lReadByte = (ULONG)pStream->read(&lMem, 1); + if (lReadByte < 1) { - if (pStream == NULL) return 0; + lMem = 0; + } + return lMem; +} +static WORD ReadWORD(POLE::Stream* pStream) +{ + if (pStream == NULL) return 0; - BYTE lMem = 0; - ULONG lReadByte = 0; + WORD lWord = 0; + BYTE pMem[2]; + ULONG lReadByte = 0; - lReadByte = (ULONG)pStream->read(&lMem, 1); - if (lReadByte < 1) + lReadByte = (ULONG)pStream->read(pMem, 2); + if (lReadByte == 2) + { + lWord = ((pMem[1] << 8) | pMem[0]); + } + return lWord; +} +static DWORD ReadDWORD(POLE::Stream* pStream) +{ + if (pStream == NULL) return 0; + + DWORD lDWord = 0; + BYTE pMem[4]; + ULONG lReadByte = 0; + lReadByte = (ULONG)pStream->read(pMem, 4); + + //#if defined(_DEBUG) && (defined(_WIN32) || defined(_WIN64)) + // ATLASSERT(4 == lReadByte); + //#endif + + if (lReadByte == 4) + { + lDWord = ((pMem[3] << 24) | (pMem[2] << 16) | (pMem[1] << 8) | pMem[0]); + } + return 0xFFFFFFFF & lDWord; +} +static SHORT ReadSHORT(POLE::Stream* pStream) +{ + return (short)ReadWORD(pStream); +} +static LONG ReadLONG(POLE::Stream* pStream) +{ + return (_INT32)ReadDWORD(pStream); +} + +static FLOAT ReadFLOAT( POLE::Stream* pStream) +{ + if (pStream == NULL) return 0; + + FLOAT Value = 0.0f; + pStream->read ((unsigned char*) &Value, sizeof (FLOAT)); + return Value; +} + +static std::string ReadStringA(POLE::Stream* pStream, LONG lLen) +{ + if (pStream == NULL) return (""); + + char* pData = new char[lLen + 1]; + ULONG lReadByte = 0; + + lReadByte = (ULONG)pStream->read((unsigned char*)pData, lLen); + + pData[lLen] = 0; + + std::string str(pData, lLen); + + delete[] pData; + return str; +} +static std::wstring ReadStringW(POLE::Stream* pStream, LONG lLen) +{ + if (pStream == NULL) return (L""); + + unsigned char* pData = new unsigned char[2 * (lLen + 1)]; + memset (pData, 0, 2 * (lLen + 1)); + + ULONG lReadByte = 0; + lReadByte = (ULONG)pStream->read(pData, 2 * lLen); + + if (sizeof(wchar_t) == 4) + { + ConversionResult eUnicodeConversionResult; + UTF32 *pStrUtf32 = new UTF32 [lLen + 1]; + pStrUtf32[lLen] = 0 ; + + const UTF16 *pStrUtf16_Conv = (const UTF16 *) pData; + UTF32 *pStrUtf32_Conv = pStrUtf32; + + eUnicodeConversionResult = ConvertUTF16toUTF32 ( &pStrUtf16_Conv + , &pStrUtf16_Conv[lLen] + , &pStrUtf32_Conv + , &pStrUtf32 [lLen] + , strictConversion); + + if (conversionOK != eUnicodeConversionResult) { - lMem = 0; + delete [] pStrUtf32; + return (L""); } - return lMem; + std::wstring res((wchar_t*)pStrUtf32, lLen); + if (pStrUtf32) delete [] pStrUtf32; + return res; } - static WORD ReadWORD(POLE::Stream* pStream) + else { - if (pStream == NULL) return 0; - - WORD lWord = 0; - BYTE pMem[2]; - ULONG lReadByte = 0; - - lReadByte = (ULONG)pStream->read(pMem, 2); - if (lReadByte == 2) - { - lWord = ((pMem[1] << 8) | pMem[0]); - } - return lWord; - } - static DWORD ReadDWORD(POLE::Stream* pStream) - { - if (pStream == NULL) return 0; - - DWORD lDWord = 0; - BYTE pMem[4]; - ULONG lReadByte = 0; - lReadByte = (ULONG)pStream->read(pMem, 4); - - //#if defined(_DEBUG) && (defined(_WIN32) || defined(_WIN64)) - // ATLASSERT(4 == lReadByte); - //#endif - - if (lReadByte == 4) - { - lDWord = ((pMem[3] << 24) | (pMem[2] << 16) | (pMem[1] << 8) | pMem[0]); - } - return 0xFFFFFFFF & lDWord; - } - static SHORT ReadSHORT(POLE::Stream* pStream) - { - return (short)ReadWORD(pStream); - } - static LONG ReadLONG(POLE::Stream* pStream) - { - return (_INT32)ReadDWORD(pStream); - } - - static FLOAT ReadFLOAT( POLE::Stream* pStream) - { - if (pStream == NULL) return 0; - - FLOAT Value = 0.0f; - pStream->read ((unsigned char*) &Value, sizeof (FLOAT)); - return Value; - } - - static std::string ReadStringA(POLE::Stream* pStream, LONG lLen) - { - if (pStream == NULL) return (""); - - char* pData = new char[lLen + 1]; - ULONG lReadByte = 0; - - lReadByte = (ULONG)pStream->read((unsigned char*)pData, lLen); - - pData[lLen] = 0; - - std::string str(pData, lLen); - + std::wstring str((wchar_t*)pData); delete[] pData; return str; } - static std::wstring ReadStringW(POLE::Stream* pStream, LONG lLen) - { - if (pStream == NULL) return (L""); - unsigned char* pData = new unsigned char[2 * (lLen + 1)]; - memset (pData, 0, 2 * (lLen + 1)); +} +static std::string ConvertCStringWToCStringA(std::wstring& strW) +{ + std::string str_a(strW.begin(), strW.end()); - ULONG lReadByte = 0; - lReadByte = (ULONG)pStream->read(pData, 2 * lLen); + return str_a; +} +static void StreamSeek(long lOffset, POLE::Stream* pStream) +{ + if (pStream == NULL) return; - if (sizeof(wchar_t) == 4) - { - ConversionResult eUnicodeConversionResult; - UTF32 *pStrUtf32 = new UTF32 [lLen + 1]; - pStrUtf32[lLen] = 0 ; + pStream->seek(lOffset); +} +static void StreamPosition(long& lPosition, POLE::Stream* pStream) +{ + if (pStream == NULL) return ; - const UTF16 *pStrUtf16_Conv = (const UTF16 *) pData; - UTF32 *pStrUtf32_Conv = pStrUtf32; + lPosition = (LONG)pStream->tell(); +} +static void StreamSkip(long lCount, POLE::Stream* pStream) +{ + if (pStream == NULL) return; - eUnicodeConversionResult = ConvertUTF16toUTF32 ( &pStrUtf16_Conv - , &pStrUtf16_Conv[lLen] - , &pStrUtf32_Conv - , &pStrUtf32 [lLen] - , strictConversion); + pStream->seek(pStream->tell() + lCount); +} +static void StreamSkipBack(long lCount, POLE::Stream* pStream) +{ + if (pStream == NULL) return; - if (conversionOK != eUnicodeConversionResult) - { - delete [] pStrUtf32; - return (L""); - } - std::wstring res((wchar_t*)pStrUtf32, lLen); - if (pStrUtf32) delete [] pStrUtf32; - return res; - } - else - { - std::wstring str((wchar_t*)pData); - delete[] pData; - return str; - } - - } - static std::string ConvertCStringWToCStringA(std::wstring& strW) - { - std::string str_a(strW.begin(), strW.end()); - - return str_a; - } - static void StreamSeek(long lOffset, POLE::Stream* pStream) - { - if (pStream == NULL) return; - - pStream->seek(lOffset); - } - static void StreamPosition(long& lPosition, POLE::Stream* pStream) - { - if (pStream == NULL) return ; - - lPosition = (LONG)pStream->tell(); - } - static void StreamSkip(long lCount, POLE::Stream* pStream) - { - if (pStream == NULL) return; - - pStream->seek(pStream->tell() + lCount); - } - static void StreamSkipBack(long lCount, POLE::Stream* pStream) - { - if (pStream == NULL) return; - - pStream->seek(pStream->tell()-lCount); - } + pStream->seek(pStream->tell()-lCount); +} } namespace CDirectory { - static void SaveToFile(std::wstring strFileName, std::wstring strXml) - { - NSFile::CFileBinary file; - file.CreateFileW(strFileName); - file.WriteStringUTF8(strXml); - file.CloseFile(); - } - - static bool DeleteFile (std::wstring strFileName) - { - return NSFile::CFileBinary::Remove(strFileName); - } - static bool CopyFile (const std::wstring& strExists, const std::wstring& strNew) - { - return NSFile::CFileBinary::Copy(strExists, strNew); - } - static void WriteValueToNode(std::wstring strName, DWORD value, XmlUtils::CXmlWriter* pWriter) - { - pWriter->WriteNodeBegin(strName); - pWriter->WriteString(boost::lexical_cast(value)); - pWriter->WriteNodeEnd(strName); - } - - static void WriteValueToNode(std::wstring strName, LONG value, XmlUtils::CXmlWriter* pWriter) - { - pWriter->WriteNodeBegin(strName); - pWriter->WriteString(boost::lexical_cast(value)); - pWriter->WriteNodeEnd(strName); - } - static void WriteValueToNode(std::wstring strName, std::wstring value, XmlUtils::CXmlWriter* pWriter) - { - pWriter->WriteNodeBegin(strName); - pWriter->WriteString(value); - pWriter->WriteNodeEnd(strName); - } - static void WriteValueToNode(std::wstring strName, WCHAR value, XmlUtils::CXmlWriter* pWriter) - { - wchar_t str_arr[2]={}; - str_arr[0] = value; - std::wstring str(str_arr); - - pWriter->WriteNodeBegin(strName); - pWriter->WriteString(str); - pWriter->WriteNodeEnd(strName); - } - static void WriteValueToNode(std::wstring strName, bool value, XmlUtils::CXmlWriter* pWriter) - { - pWriter->WriteNodeBegin(strName); - std::wstring str = (true == value) ? (L"1") : (L"0"); - pWriter->WriteString(str); - pWriter->WriteNodeEnd(strName); - } - - static double FixedPointToDouble(DWORD point) - { - double dVal = (double)(point % 65536) / 65536; - dVal += (point / 65536); - return dVal; - } - static LONG NormFixedPoint(DWORD point, LONG base) - { - return (LONG)(FixedPointToDouble(point) * base); - } - - static std::wstring BYTEArrayToString(BYTE* arr, size_t nCount) - { - std::wstring str; - for (size_t index = 0; index < nCount; ++index) - { - if ('\0' != (char)(arr[index])) - str += (char)(arr[index]); - } - if (str.length() == 0) - str = (L"0"); - return str; - } - - static std::wstring BYTEArrayToStringW(BYTE* arr, size_t nCount) - { - std::wstring str; - wchar_t* pArr = (wchar_t*)arr; - size_t nCountNew = nCount / 2; - for (size_t index = 0; index < nCountNew; ++index) - { - str += pArr[index]; - } - if (str.length() == 0) - str = (L"0"); - return str; - } +static void SaveToFile(std::wstring strFileName, std::wstring strXml) +{ + NSFile::CFileBinary file; + file.CreateFileW(strFileName); + file.WriteStringUTF8(strXml); + file.CloseFile(); +} + +static bool DeleteFile (std::wstring strFileName) +{ + return NSFile::CFileBinary::Remove(strFileName); +} +static bool CopyFile (const std::wstring& strExists, const std::wstring& strNew) +{ + return NSFile::CFileBinary::Copy(strExists, strNew); +} +static void WriteValueToNode(std::wstring strName, DWORD value, XmlUtils::CXmlWriter* pWriter) +{ + pWriter->WriteNodeBegin(strName); + pWriter->WriteString(boost::lexical_cast(value)); + pWriter->WriteNodeEnd(strName); +} + +static void WriteValueToNode(std::wstring strName, LONG value, XmlUtils::CXmlWriter* pWriter) +{ + pWriter->WriteNodeBegin(strName); + pWriter->WriteString(boost::lexical_cast(value)); + pWriter->WriteNodeEnd(strName); +} +static void WriteValueToNode(std::wstring strName, std::wstring value, XmlUtils::CXmlWriter* pWriter) +{ + pWriter->WriteNodeBegin(strName); + pWriter->WriteString(value); + pWriter->WriteNodeEnd(strName); +} +static void WriteValueToNode(std::wstring strName, WCHAR value, XmlUtils::CXmlWriter* pWriter) +{ + wchar_t str_arr[2]={}; + str_arr[0] = value; + std::wstring str(str_arr); + + pWriter->WriteNodeBegin(strName); + pWriter->WriteString(str); + pWriter->WriteNodeEnd(strName); +} +static void WriteValueToNode(std::wstring strName, bool value, XmlUtils::CXmlWriter* pWriter) +{ + pWriter->WriteNodeBegin(strName); + std::wstring str = (true == value) ? (L"1") : (L"0"); + pWriter->WriteString(str); + pWriter->WriteNodeEnd(strName); +} + +static double FixedPointToDouble(DWORD point) +{ + double dVal = (double)(point % 65536) / 65536; + dVal += (point / 65536); + return dVal; +} +static LONG NormFixedPoint(DWORD point, LONG base) +{ + return (LONG)(FixedPointToDouble(point) * base); +} + +static std::wstring BYTEArrayToString(BYTE* arr, size_t nCount) +{ + std::wstring str; + for (size_t index = 0; index < nCount; ++index) + { + if ('\0' != (char)(arr[index])) + str += (char)(arr[index]); + } + if (str.length() == 0) + str = (L"0"); + return str; +} + +static std::wstring BYTEArrayToStringW(BYTE* arr, size_t nCount) +{ + std::wstring str; + wchar_t* pArr = (wchar_t*)arr; + size_t nCountNew = nCount / 2; + for (size_t index = 0; index < nCountNew; ++index) + { + str += pArr[index]; + } + if (str.length() == 0) + str = (L"0"); + return str; +} } diff --git a/DesktopEditor/common/Directory.cpp b/DesktopEditor/common/Directory.cpp index 0f9d33fd70..b698ea9c29 100644 --- a/DesktopEditor/common/Directory.cpp +++ b/DesktopEditor/common/Directory.cpp @@ -53,6 +53,7 @@ #endif #include +#include #include "Directory.h" namespace NSDirectory @@ -583,4 +584,19 @@ namespace NSDirectory { return Exists(pathName); } + + std::vector GrepPaths(const std::vector &paths, const std::wstring &strRegEx) + { + std::vector filtredPaths; + std::wregex regEx(strRegEx); + std::wsmatch wSmath; + for (const auto& path : paths) + { + if (std::regex_match(path, wSmath, regEx)) + filtredPaths.push_back(path); + } + + return filtredPaths; + } + } diff --git a/DesktopEditor/common/Directory.h b/DesktopEditor/common/Directory.h index 7248bff7e6..f20f2a07ba 100644 --- a/DesktopEditor/common/Directory.h +++ b/DesktopEditor/common/Directory.h @@ -68,6 +68,7 @@ namespace NSDirectory KERNEL_DECL void GetFiles2(std::wstring strDirectory, std::vector& oArray, bool bIsRecursion = false); KERNEL_DECL std::vector GetFiles(std::wstring strDirectory, bool bIsRecursion = false); + KERNEL_DECL std::vector GrepPaths(const std::vector& paths, const std::wstring& strRegEx); KERNEL_DECL std::vector GetDirectories(std::wstring strDirectory); KERNEL_DECL bool Exists(const std::wstring& strDirectory); KERNEL_DECL bool CreateDirectory(const std::wstring& strDirectory); diff --git a/DesktopEditor/raster/Metafile/svg/SVGFramework.h b/DesktopEditor/raster/Metafile/svg/SVGFramework.h index e5d74aa278..06d78bc8ba 100644 --- a/DesktopEditor/raster/Metafile/svg/SVGFramework.h +++ b/DesktopEditor/raster/Metafile/svg/SVGFramework.h @@ -5691,6 +5691,22 @@ public: m_oUs.SetViewBox(m_nWidth, m_nHeight, m_oViewBox, m_Metrics); SetDefaultSizes (); + + m_oStyle.SetDefault(); + m_oStyle.ClearFillColor(); + std::wstring css = oXml.GetAttribute(L"style"); + if (!css.empty()) + { + m_oFontStyle.SetStyle (css, true); + m_oStyle.SetStyle (css, true, m_oUs, m_model, m_oColTable); + } + else + { + m_oFontStyle.UpdateStyle (oXml); + m_oStyle.UpdateStyle (oXml, m_oUs, m_model, m_oColTable); + } + + m_oStyles.Push(m_oStyle); } else if (L"g" == strXmlNode) { diff --git a/DesktopEditor/xml/src/xmldom.cpp b/DesktopEditor/xml/src/xmldom.cpp index 6f63dd50e1..98227a09cc 100644 --- a/DesktopEditor/xml/src/xmldom.cpp +++ b/DesktopEditor/xml/src/xmldom.cpp @@ -706,8 +706,11 @@ namespace XmlUtils std::wstring sRes; if (!GetAttributeIfExist(strAttributeName, sRes)) { - if (!GetTextIfExist(sRes)) - sRes = strDefaultValue; + CXmlNode oTemp; + if (GetNode(strAttributeName, oTemp)) + sRes = oTemp.GetText(); + else + sRes = strDefaultValue; } return sRes; } diff --git a/Fb2File/Fb2File.cpp b/Fb2File/Fb2File.cpp index f915bd736a..38eae2a5f5 100644 --- a/Fb2File/Fb2File.cpp +++ b/Fb2File/Fb2File.cpp @@ -1744,17 +1744,18 @@ void readStream(NSStringUtils::CStringBuilder& oXml, XmlUtils::CXmlLiteReader& o } else if (sName == L"a") { + oXml.WriteString(L""); + oXml.WriteString(L"\" "); } oIndexHtml.MoveToElement(); + oXml.WriteString(L">"); readStream(oXml, oIndexHtml, arrBinary, bWasP, bWasTable); oXml.WriteString(L""); @@ -1771,7 +1772,7 @@ void readStream(NSStringUtils::CStringBuilder& oXml, XmlUtils::CXmlLiteReader& o if (oIndexHtml.GetName() == L"src") { sBinary = oIndexHtml.GetText(); - sBinary.erase(0, sBinary.find(L',') + 2); + sBinary.erase(0, sBinary.find(L',') + 1); arrBinary.push_back(sBinary); } } diff --git a/PdfReader/Src/SecurityHandler.cpp b/PdfReader/Src/SecurityHandler.cpp index d5020bef92..8842cb65d9 100644 --- a/PdfReader/Src/SecurityHandler.cpp +++ b/PdfReader/Src/SecurityHandler.cpp @@ -151,7 +151,12 @@ namespace PdfReader if (oCryptCurFilter.DictLookup("Length", &oCFLength)->IsInt()) { // Согласно спецификации, должно быть oCFLength / 8 - m_nFileKeyLength = oCFLength.GetInt() / 8; + m_nFileKeyLength = oCFLength.GetInt(); + + // для AES256 приходят 32 и 256. Т.е. иногда нажо делить на 8, а иногда нет. + // мы все равно кинем exception, если длина не 32 + if (cryptAES256 == m_eCryptType) + m_nFileKeyLength = 32; } oCFLength.Free(); diff --git a/X2tConverter/src/ASCConverters.cpp b/X2tConverter/src/ASCConverters.cpp index bca279acb5..179c7e7296 100644 --- a/X2tConverter/src/ASCConverters.cpp +++ b/X2tConverter/src/ASCConverters.cpp @@ -4218,7 +4218,7 @@ namespace NExtractTools initApplicationFonts(pApplicationFonts, params); if(AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_PDF == nFormatTo) { - if(nFormatFrom == nFormatTo && !params.getIsPDFA()) + if(nFormatFrom == nFormatTo && !params.getIsPDFA() && params.getPassword() == params.getSavePassword()) { NSFile::CFileBinary::Copy(sFrom, sTo); }