From e577a275856b22e1768831c2935973bc281ffc2d Mon Sep 17 00:00:00 2001 From: Aron Budea Date: Thu, 24 Sep 2026 01:16:44 +0930 Subject: [PATCH] sd: adjust theme ids when exporting notes to PPTX Previous numbering was from before the deduplication in commit 9205b4eb09dcb4c91539e092db521154fc4e9523. Deduplication collapses themes for the same master to a single XML, and the theme for notes master didn't follow in numbering, causing a big gap, eg. theme1.xml being followed by theme13.xml. Use mnThemeIdMax introduced there. Change-Id: I5e9ddb11716543bc816d47f5aac03bb2f182dc62 Signed-off-by: Aron Budea Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/13448 Reviewed-by: Mike Kaganski Tested-by: Jenkins CPCI (cherry picked from commit a1f3059174fa5ff51d258b5a2125884cb1b4e23b) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/211513 Tested-by: Jenkins Reviewed-by: Xisco Fauli --- sd/qa/unit/export-tests-ooxml4.cxx | 32 ++++++++++++++++++++++++ sd/source/filter/eppt/pptx-epptooxml.cxx | 4 +-- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/sd/qa/unit/export-tests-ooxml4.cxx b/sd/qa/unit/export-tests-ooxml4.cxx index 97116c2dd5f8..99ec6d476e11 100644 --- a/sd/qa/unit/export-tests-ooxml4.cxx +++ b/sd/qa/unit/export-tests-ooxml4.cxx @@ -1456,6 +1456,38 @@ CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest4, testTdf157740_slideMasters) assertXPath(pXmlDocContent, "/p:sldMaster/p:sldLayoutIdLst/p:sldLayoutId", 7); } +CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest4, testNotesMasterThemeNoAfterDeduplicatedMasters) +{ + createSdImpressDoc("n759180.pptx"); + save(TestFilter::PPTX); + + xmlDocUniquePtr pXmlDocContent = parseExport(u"ppt/presentation.xml"_ustr); + assertXPath(pXmlDocContent, "/p:presentation/p:sldMasterIdLst/p:sldMasterId", 1); + + xmlDocUniquePtr pXmlDocRels = parseExport(u"ppt/slideMasters/_rels/slideMaster1.xml.rels"_ustr); + assertXPath(pXmlDocRels, + "/rels:Relationships/rels:Relationship[@Type='http://schemas.openxmlformats.org/" + "officeDocument/2006/relationships/theme']", + "Target", u"../theme/theme1.xml"); + + // The one slide master of this document has 12 layouts, which are imported as 12 master pages + // and written back as one slide master. The notes master theme takes the number after the slide + // master theme, as in the original file, without a gap for the master pages that were merged. + // Without the change in place, this test would have failed with: + // - Expected: ../theme/theme2.xml + // - Actual : ../theme/theme13.xml + pXmlDocRels = parseExport(u"ppt/notesMasters/_rels/notesMaster1.xml.rels"_ustr); + assertXPath(pXmlDocRels, + "/rels:Relationships/rels:Relationship[@Type='http://schemas.openxmlformats.org/" + "officeDocument/2006/relationships/theme']", + "Target", u"../theme/theme2.xml"); + + uno::Reference xNameAccess + = packages::zip::ZipFileAccess::createWithURL(comphelper::getComponentContext(m_xSFactory), + maTempFile.GetURL()); + CPPUNIT_ASSERT_EQUAL(true, bool(xNameAccess->hasByName(u"ppt/theme/theme2.xml"_ustr))); +} + CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest4, testTdf159931_slideLayouts) { createSdImpressDoc("odp/repeatBitmapMode.odp"); diff --git a/sd/source/filter/eppt/pptx-epptooxml.cxx b/sd/source/filter/eppt/pptx-epptooxml.cxx index 9843f5ed8785..4a7152993130 100644 --- a/sd/source/filter/eppt/pptx-epptooxml.cxx +++ b/sd/source/filter/eppt/pptx-epptooxml.cxx @@ -3330,12 +3330,12 @@ void PowerPointExport::WriteNotesMaster() auto pTheme = std::make_shared("Office Theme"); pTheme->setColorSet(std::make_shared(*pDefaultColorSet)); - WriteTheme(mnMasterPages - static_cast(mbHasCanvasPage), pTheme.get()); + WriteTheme(mnThemeIdMax, pTheme.get()); // add implicit relation to the presentation theme addRelation(pFS->getOutputStream(), oox::getRelationship(Relationship::THEME), - Concat2View("../theme/theme" + OUString::number(mnMasterPages + 1 - static_cast(mbHasCanvasPage)) + ".xml")); + Concat2View("../theme/theme" + OUString::number(++mnThemeIdMax) + ".xml")); } pFS->startElementNS(XML_p, XML_notesMaster, presentationNamespaces(*this));