sd/qa/unit/data/pptx/multiplelayoutfooter.pptx |binary
 sd/qa/unit/export-tests-ooxml4.cxx             |   24 ++++++++++++++++++++++++
 sd/source/filter/eppt/pptx-epptooxml.cxx       |   11 -----------
 3 files changed, 24 insertions(+), 11 deletions(-)

New commits:
commit 0f21756af8e74b0dd3f25fe4234feb067430838b
Author:     Jaume Pujantell <[email protected]>
AuthorDate: Wed Nov 19 09:15:38 2025 +0100
Commit:     Miklos Vajna <[email protected]>
CommitDate: Fri Dec 5 09:03:02 2025 +0100

    sd: pptx: fix footer moving places for MSO
    
    In a pptx file with a slide master that has multiple slide layouts, the
    footer would loose properties when saved in LO and opened in MSO.
    This is due to the master de-duplicating logic that in trying to emulate
    pptx's natural way of dealing with master and layout slide it treats
    multiple Impress masters as equivalent. This is needed for most export
    functions, but when exporting an element from an Impress slide that
    references an Impress master (like a footer), we need to differentiate
    exactly which one of the equivalent masters it comes from to make the
    indices match.
    
    Change-Id: I815c3db54256d934b69108c7268f6d7642c33cbb
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/194190
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-by: Miklos Vajna <[email protected]>

diff --git a/sd/qa/unit/data/pptx/multiplelayoutfooter.pptx 
b/sd/qa/unit/data/pptx/multiplelayoutfooter.pptx
new file mode 100644
index 000000000000..9536e13a6e07
Binary files /dev/null and b/sd/qa/unit/data/pptx/multiplelayoutfooter.pptx 
differ
diff --git a/sd/qa/unit/export-tests-ooxml4.cxx 
b/sd/qa/unit/export-tests-ooxml4.cxx
index 7edcb3fca05c..18015db6ac16 100644
--- a/sd/qa/unit/export-tests-ooxml4.cxx
+++ b/sd/qa/unit/export-tests-ooxml4.cxx
@@ -1647,6 +1647,30 @@ CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest4, 
testtdf169496_hidden_graphic)
         CPPUNIT_FAIL("Names of graphics is incorrect");
 }
 
+CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest4, testFooterIdxConsistency)
+{
+    createSdImpressDoc("pptx/multiplelayoutfooter.pptx");
+    save(u"Impress Office Open XML"_ustr);
+
+    // slide1 points to slideLayout2
+    xmlDocUniquePtr pRelsDoc = 
parseExport(u"ppt/slides/_rels/slide1.xml.rels"_ustr);
+    assertXPath(pRelsDoc,
+                "/rels:Relationships/rels:Relationship[@Type='http://";
+                "schemas.openxmlformats.org/officeDocument/2006/"
+                "relationships/slideLayout']",
+                "Target", u"../slideLayouts/slideLayout2.xml");
+
+    // And they agree on the idx of the footer:
+    xmlDocUniquePtr pSlide = parseExport(u"ppt/slides/slide1.xml"_ustr);
+    OUString aFtrIdx = getXPath(pSlide, "//p:sp/p:nvSpPr/p:nvPr/p:ph", "idx");
+    xmlDocUniquePtr pLayout = 
parseExport(u"ppt/slideLayouts/slideLayout2.xml"_ustr);
+    assertXPath(pLayout, "//p:sp/p:nvSpPr/p:nvPr/p:ph", "idx", aFtrIdx);
+    // Without the fix it fails with:
+    // - Expected: 1
+    // - Actual  : 2
+    // - In <>, attribute 'idx' of '//p:sp/p:nvSpPr/p:nvPr/p:ph' incorrect 
value.
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sd/source/filter/eppt/pptx-epptooxml.cxx 
b/sd/source/filter/eppt/pptx-epptooxml.cxx
index 194a6906e07a..7982f0af77c8 100644
--- a/sd/source/filter/eppt/pptx-epptooxml.cxx
+++ b/sd/source/filter/eppt/pptx-epptooxml.cxx
@@ -3039,17 +3039,6 @@ Reference<XShape> 
PowerPointExport::GetReferencedPlaceholderXShape(const Placeho
         {
             pPage = 
&SdPage::getImplementation(mXDrawPage)->TRG_GetMasterPage();
         }
-        for (sal_uInt32 i = 0; i < mnMasterPages; i++)
-        {
-            if (i == mnCanvasMasterIndex)
-                continue;
-            if (maMastersLayouts[i].first == pPage)
-            {
-                if (maEquivalentMasters[i] < mnMasterPages - 
static_cast<int>(mbHasCanvasPage))
-                    pPage = maMastersLayouts[maEquivalentMasters[i]].first;
-                break;
-            }
-        }
         SdPage* pMasterPage = dynamic_cast<SdPage*>(pPage);
         if (SdrObject* pMasterFooter
             = (pMasterPage ? pMasterPage->GetPresObj(ePresObjKind) : nullptr))

Reply via email to