sd/source/core/drawdoc2.cxx | 2 ++ sd/source/filter/eppt/eppt.cxx | 2 ++ sd/source/filter/eppt/epptbase.hxx | 1 + sd/source/filter/eppt/epptso.cxx | 4 +++- sd/source/filter/eppt/pptx-epptbase.cxx | 22 +++++++++++++++++++++- sd/source/filter/eppt/pptx-epptooxml.cxx | 30 +++++++++++++++++++++++++----- 6 files changed, 54 insertions(+), 7 deletions(-)
New commits: commit 3da1b9f81d2abbd12ef42fcd46de774db2066dd4 Author: Mohit Marathe <[email protected]> AuthorDate: Wed Nov 26 16:56:03 2025 +0530 Commit: Mohit Marathe <[email protected]> CommitDate: Wed Dec 3 12:33:12 2025 +0100 sd: do not export canvas master page to pptx Signed-off-by: Mohit Marathe <[email protected]> Change-Id: I827c2325788552cdfd424fd69d0384fa6d2b88bc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/194699 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Michael Stahl <[email protected]> diff --git a/sd/source/core/drawdoc2.cxx b/sd/source/core/drawdoc2.cxx index 792055d12091..c5ac123fb6f1 100644 --- a/sd/source/core/drawdoc2.cxx +++ b/sd/source/core/drawdoc2.cxx @@ -1508,6 +1508,8 @@ void SdDrawDocument::ImportCanvasPage() pPage->SetCanvasPage(); pPage->SetExcluded(true); mpCanvasPage = pPage; + SdPage* pMPage = static_cast<SdPage*>(&pPage->TRG_GetMasterPage()); + pMPage->SetCanvasMasterPage(); // re-populate the previews grid if not valid if (!bIsCanvasPageValid) { diff --git a/sd/source/filter/eppt/eppt.cxx b/sd/source/filter/eppt/eppt.cxx index be5a99cd02a7..d928dad8ded6 100644 --- a/sd/source/filter/eppt/eppt.cxx +++ b/sd/source/filter/eppt/eppt.cxx @@ -1310,6 +1310,8 @@ void PPTWriter::ImplWriteAtomEnding() // write MasterPages persists for ( i = 0; i < mnMasterPages; i++ ) { + if (i == mnCanvasMasterIndex) + continue; nOfs = mpPptEscherEx->PtGetOffsetByID( EPP_Persist_MainMaster | i ); if ( nOfs ) { diff --git a/sd/source/filter/eppt/epptbase.hxx b/sd/source/filter/eppt/epptbase.hxx index 0c06e55c275c..8d587742f40c 100644 --- a/sd/source/filter/eppt/epptbase.hxx +++ b/sd/source/filter/eppt/epptbase.hxx @@ -346,6 +346,7 @@ protected: sal_uInt32 mnPages; ///< number of Slides ( w/o master pages & notes & handout ) sal_uInt32 mnMasterPages; + sal_uInt32 mnCanvasMasterIndex; Fraction maFraction; MapMode maMapModeSrc; diff --git a/sd/source/filter/eppt/epptso.cxx b/sd/source/filter/eppt/epptso.cxx index ffec0145717c..7442f2bc918e 100644 --- a/sd/source/filter/eppt/epptso.cxx +++ b/sd/source/filter/eppt/epptso.cxx @@ -317,13 +317,15 @@ sal_uInt32 PPTWriter::ImplDocumentListContainer( SvStream* pStrm ) sal_uInt32 PPTWriter::ImplMasterSlideListContainer( SvStream* pStrm ) { - sal_uInt32 i, nSize = 28 * mnMasterPages + 8; + sal_uInt32 i, nSize = 28 * (mnMasterPages - static_cast<int>(mbHasCanvasPage)) + 8; if ( pStrm ) { pStrm->WriteUInt32( 0x1f | ( EPP_SlideListWithText << 16 ) ).WriteUInt32( nSize - 8 ); for ( i = 0; i < mnMasterPages; i++ ) { + if (i == mnCanvasMasterIndex) + continue; pStrm->WriteUInt32( EPP_SlidePersistAtom << 16 ).WriteUInt32( 20 ); mpPptEscherEx->InsertPersistOffset( EPP_MAINMASTER_PERSIST_KEY | i, pStrm->Tell() ); pStrm->WriteUInt32( 0 ) // psrReference - logical reference to the slide persist object ( EPP_MAINMASTER_PERSIST_KEY ) diff --git a/sd/source/filter/eppt/pptx-epptbase.cxx b/sd/source/filter/eppt/pptx-epptbase.cxx index 8bea54bd1124..8f940e2d2267 100644 --- a/sd/source/filter/eppt/pptx-epptbase.cxx +++ b/sd/source/filter/eppt/pptx-epptbase.cxx @@ -22,6 +22,7 @@ #include "epptbase.hxx" #include "epptdef.hxx" #include "../ppt/pptanimations.hxx" +#include <sdpage.hxx> #include <unomodel.hxx> #include <o3tl/any.hxx> @@ -110,6 +111,7 @@ PPTWriterBase::PPTWriterBase() , mnAngle(0) , mnPages(0) , mnMasterPages(0) + , mnCanvasMasterIndex(SAL_MAX_UINT32) , maFraction(1, 576) , maMapModeSrc(MapUnit::Map100thMM) , maMapModeDest(MapUnit::MapInch, Point(), maFraction, maFraction) @@ -130,6 +132,7 @@ PPTWriterBase::PPTWriterBase( const Reference< XModel > & rXModel, , mnAngle(0) , mnPages(0) , mnMasterPages(0) + , mnCanvasMasterIndex(SAL_MAX_UINT32) , maFraction(1, 576) , maMapModeSrc(MapUnit::Map100thMM) , maMapModeDest(MapUnit::MapInch, Point(), maFraction, maFraction) @@ -196,6 +199,8 @@ void PPTWriterBase::exportPPT( const std::vector< css::beans::PropertyValue >& r for ( i = 0; i < mnMasterPages; i++ ) { + if (i == mnCanvasMasterIndex) + continue; if ( !CreateSlideMaster( i ) ) return; } @@ -253,6 +258,19 @@ bool PPTWriterBase::InitSOIface() mbHasCanvasPage = true; else mbHasCanvasPage = false; + + for (sal_uInt32 i = 0; i < mnMasterPages; i++) + { + if (GetPageByIndex(i, MASTER)) + { + SdPage* pPage = SdPage::getImplementation(mXDrawPage); + if (pPage && pPage->IsCanvasMasterPage()) + { + mnCanvasMasterIndex = i; + break; + } + } + } } return true; } @@ -476,7 +494,7 @@ sal_uInt32 PPTWriterBase::GetMasterIndex( PageType ePageType ) } } if ( ePageType == NOTICE ) - nRetValue += mnMasterPages; + nRetValue += mnMasterPages - static_cast<int>(mbHasCanvasPage); return nRetValue; } @@ -495,6 +513,8 @@ bool PPTWriterBase::GetStyleSheets() for ( nPageNum = 0; nPageNum < mnMasterPages; nPageNum++ ) { + if (nPageNum == mnCanvasMasterIndex) + continue; Reference< XNamed > aXNamed; diff --git a/sd/source/filter/eppt/pptx-epptooxml.cxx b/sd/source/filter/eppt/pptx-epptooxml.cxx index 2b8f81d12b22..c7f329472d1e 100644 --- a/sd/source/filter/eppt/pptx-epptooxml.cxx +++ b/sd/source/filter/eppt/pptx-epptooxml.cxx @@ -1924,6 +1924,8 @@ void PowerPointExport::FindEquivalentMasterPages() maEquivalentMasters.resize(mnMasterPages, SAL_MAX_UINT32); for (sal_uInt32 i = 0; i < mnMasterPages; i++) { + if (i == mnCanvasMasterIndex) + continue; css::uno::Reference<css::drawing::XDrawPage> xDrawPage; uno::Any aAny(xDrawPages->getByIndex(i)); aAny >>= xDrawPage; @@ -1944,11 +1946,13 @@ void PowerPointExport::FindEquivalentMasterPages() for (sal_uInt32 i = 0; i < mnMasterPages; i++) { - if (!maMastersLayouts[i].first || maEquivalentMasters[i] != SAL_MAX_UINT32) + if (!maMastersLayouts[i].first || maEquivalentMasters[i] != SAL_MAX_UINT32 + || i == mnCanvasMasterIndex) continue; for (sal_uInt32 j = i + 1; j < mnMasterPages; j++) { - if (!maMastersLayouts[j].first || maEquivalentMasters[j] != SAL_MAX_UINT32) + if (!maMastersLayouts[j].first || maEquivalentMasters[j] != SAL_MAX_UINT32 + || j == mnCanvasMasterIndex) continue; if (lcl_ComparePageProperties(maMastersLayouts[i].first, maMastersLayouts[j].first) @@ -1974,6 +1978,8 @@ void PowerPointExport::ImplWriteSlideMaster(sal_uInt32 nPageNum, Reference< XPro { SAL_INFO("sd.eppt", "write master slide: " << nPageNum << " --------------"); + assert(mnCanvasMasterIndex != nPageNum); + if (nPageNum != GetEquivalentMasterPage(nPageNum) && GetEquivalentMasterPage(nPageNum) != SAL_MAX_UINT32) { @@ -1994,6 +2000,8 @@ void PowerPointExport::ImplWriteSlideMaster(sal_uInt32 nPageNum, Reference< XPro // Close the list tag if it was the last one if (nPageNum == mnMasterPages - 1) mPresentationFS->endElementNS(XML_p, XML_sldMasterIdLst); + if (mnCanvasMasterIndex == mnMasterPages - 1 && nPageNum == mnMasterPages - 2) + mPresentationFS->endElementNS(XML_p, XML_sldMasterIdLst); return; } @@ -2001,6 +2009,8 @@ void PowerPointExport::ImplWriteSlideMaster(sal_uInt32 nPageNum, Reference< XPro // slides list if (nPageNum == 0) mPresentationFS->startElementNS(XML_p, XML_sldMasterIdLst); + if (mnCanvasMasterIndex == 0 && nPageNum == 1) + mPresentationFS->startElementNS(XML_p, XML_sldMasterIdLst); OUString sRelId = addRelation(mPresentationFS->getOutputStream(), oox::getRelationship(Relationship::SLIDEMASTER), @@ -2010,6 +2020,12 @@ void PowerPointExport::ImplWriteSlideMaster(sal_uInt32 nPageNum, Reference< XPro XML_id, OString::number(GetNewSlideMasterId()), FSNS(XML_r, XML_id), sRelId); + // if canvas master page is the last one, close the list tag before that + if (mnCanvasMasterIndex == mnMasterPages - 1) + { + if (nPageNum == mnMasterPages - 2) + mPresentationFS->endElementNS(XML_p, XML_sldMasterIdLst); + } if (nPageNum == mnMasterPages - 1) mPresentationFS->endElementNS(XML_p, XML_sldMasterIdLst); @@ -2175,6 +2191,8 @@ void PowerPointExport::ImplWriteSlideMaster(sal_uInt32 nPageNum, Reference< XPro // Add layouts of other Impress masters that came from a single pptx master with multiple layouts for (sal_uInt32 i = 0; i < mnMasterPages; i++) { + if (i == mnCanvasMasterIndex) + continue; if (i != nPageNum && maEquivalentMasters[i] == nPageNum) { aLayouts = getLayoutsUsedForMaster(maMastersLayouts[i].first); @@ -2763,12 +2781,12 @@ void PowerPointExport::WriteNotesMaster() auto pTheme = std::make_shared<model::Theme>("Office Theme"); pTheme->setColorSet(std::make_shared<model::ColorSet>(*pDefaultColorSet)); - WriteTheme(mnMasterPages, pTheme.get()); + WriteTheme(mnMasterPages - static_cast<int>(mbHasCanvasPage), pTheme.get()); // add implicit relation to the presentation theme addRelation(pFS->getOutputStream(), oox::getRelationship(Relationship::THEME), - Concat2View("../theme/theme" + OUString::number(mnMasterPages + 1) + ".xml")); + Concat2View("../theme/theme" + OUString::number(mnMasterPages + 1 - static_cast<int>(mbHasCanvasPage)) + ".xml")); } pFS->startElementNS(XML_p, XML_notesMaster, presentationNamespaces(*this)); @@ -3020,9 +3038,11 @@ Reference<XShape> PowerPointExport::GetReferencedPlaceholderXShape(const Placeho } for (sal_uInt32 i = 0; i < mnMasterPages; i++) { + if (i == mnCanvasMasterIndex) + continue; if (maMastersLayouts[i].first == pPage) { - if (maEquivalentMasters[i] < mnMasterPages) + if (maEquivalentMasters[i] < mnMasterPages - static_cast<int>(mbHasCanvasPage)) pPage = maMastersLayouts[maEquivalentMasters[i]].first; break; }
