include/oox/ppt/presentationfragmenthandler.hxx |    8 -
 oox/source/ppt/presentationfragmenthandler.cxx  |   43 ++++----
 sd/qa/unit/data/pptx/master-slides.pptx         |binary
 sd/qa/unit/export-tests-ooxml2.cxx              |    6 -
 sd/qa/unit/export-tests-ooxml3.cxx              |    4 
 sd/qa/unit/import-tests2.cxx                    |   12 ++
 sd/source/filter/eppt/epptooxml.hxx             |    4 
 sd/source/filter/eppt/pptx-epptooxml.cxx        |  128 ++++++++++++++++++++++--
 sd/source/ui/inc/unopage.hxx                    |    1 
 sd/source/ui/unoidl/unopage.cxx                 |   13 ++
 10 files changed, 183 insertions(+), 36 deletions(-)

New commits:
commit 3ef576f21213c6c5c63e84b04853a1a8a85fe74f
Author:     Henry Castro <hcas...@collabora.com>
AuthorDate: Mon Oct 9 10:29:40 2023 -0400
Commit:     Caolán McNamara <caolan.mcnam...@collabora.com>
CommitDate: Sun Oct 29 21:47:25 2023 +0100

    tdf#155512: sd: qa: unit: add unit test "testMasterSlides"
    
    Signed-off-by: Henry Castro <hcas...@collabora.com>
    Change-Id: I6117b384fdad215e6c04b6e74df22fe9daa6a526
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157705
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>

diff --git a/sd/qa/unit/data/pptx/master-slides.pptx 
b/sd/qa/unit/data/pptx/master-slides.pptx
new file mode 100644
index 000000000000..3494d33254ab
Binary files /dev/null and b/sd/qa/unit/data/pptx/master-slides.pptx differ
diff --git a/sd/qa/unit/import-tests2.cxx b/sd/qa/unit/import-tests2.cxx
index 102d7e2dfa99..c72bd133fb7b 100644
--- a/sd/qa/unit/import-tests2.cxx
+++ b/sd/qa/unit/import-tests2.cxx
@@ -149,6 +149,7 @@ public:
     void testOverflowBehaviorClip();
     void testShapeMasterText();
     void testIndentDuplication();
+    void testMasterSlides();
 
     CPPUNIT_TEST_SUITE(SdImportTest2);
 
@@ -231,6 +232,7 @@ public:
     CPPUNIT_TEST(testOverflowBehaviorClip);
     CPPUNIT_TEST(testShapeMasterText);
     CPPUNIT_TEST(testIndentDuplication);
+    CPPUNIT_TEST(testMasterSlides);
 
     CPPUNIT_TEST_SUITE_END();
 };
@@ -2084,6 +2086,16 @@ void SdImportTest2::testIndentDuplication()
     CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nIndent2);
 }
 
+void SdImportTest2::testMasterSlides()
+{
+    createSdImpressDoc("pptx/master-slides.pptx");
+    uno::Reference<drawing::XMasterPagesSupplier> 
xMasterPagesSupplier(mxComponent,
+                                                                       
uno::UNO_QUERY_THROW);
+    uno::Reference<drawing::XDrawPages> 
xMasterPages(xMasterPagesSupplier->getMasterPages());
+    CPPUNIT_ASSERT(xMasterPages.is());
+    CPPUNIT_ASSERT_EQUAL(7, xMasterPages->getCount());
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SdImportTest2);
 CPPUNIT_PLUGIN_IMPLEMENT();
 
commit d23176dc22ab3ef7291757aca779f80f0cf0576b
Author:     Henry Castro <hcas...@collabora.com>
AuthorDate: Mon Oct 9 07:34:02 2023 -0400
Commit:     Caolán McNamara <caolan.mcnam...@collabora.com>
CommitDate: Sun Oct 29 21:47:19 2023 +0100

    tdf#155512: oox: ppt: fix import master slides, follow up
    
    Import all master slides.
    
    Signed-off-by: Henry Castro <hcas...@collabora.com>
    Change-Id: Ieac68bacf15c75e4c23ec692aadcb16033cdd092
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157701
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>

diff --git a/include/oox/ppt/presentationfragmenthandler.hxx 
b/include/oox/ppt/presentationfragmenthandler.hxx
index 4685ea2d8316..20fc521ae8c5 100644
--- a/include/oox/ppt/presentationfragmenthandler.hxx
+++ b/include/oox/ppt/presentationfragmenthandler.hxx
@@ -52,10 +52,10 @@ private:
     void importSlide( const ::oox::core::FragmentHandlerRef& 
rSlideFragmentHandler,
                         const oox::ppt::SlidePersistPtr& rPersist );
     void importSlide(sal_uInt32 nSlide, bool bFirstSlide, bool bImportNotes);
-    oox::ppt::SlidePersistPtr importMasterSlide(const 
::com::sun::star::uno::Reference<::com::sun::star::frame::XModel>& xModel,
-                                                ::oox::ppt::PowerPointImport& 
rFilter,
-                                                const OUString& 
rLayoutFragmentPath,
-                                                const OUString& 
rMasterFragmentPath);
+    void importMasterSlides();
+    void importMasterSlide(const 
::com::sun::star::uno::Reference<::com::sun::star::frame::XModel>& xModel,
+                           ::oox::ppt::PowerPointImport& rFilter,
+                           const OUString& rMasterFragmentPath);
     void saveThemeToGrabBag(const oox::drawingml::ThemePtr& pThemePtr, 
sal_Int32 nThemeIdx);
     void importCustomSlideShow(std::vector<CustomShow>& rCustomShowList);
     static void importSlideNames(::oox::core::XmlFilterBase& rFilter, const 
std::vector<SlidePersistPtr>& rSlidePersist);
diff --git a/oox/source/ppt/presentationfragmenthandler.cxx 
b/oox/source/ppt/presentationfragmenthandler.cxx
index 80fb6c6689a7..91824210e239 100644
--- a/oox/source/ppt/presentationfragmenthandler.cxx
+++ b/oox/source/ppt/presentationfragmenthandler.cxx
@@ -199,13 +199,12 @@ void 
PresentationFragmentHandler::importCustomSlideShow(std::vector<CustomShow>&
     }
 }
 
-SlidePersistPtr PresentationFragmentHandler::importMasterSlide(const 
Reference<frame::XModel>& xModel,
-                                                               
PowerPointImport& rFilter,
-                                                               const OUString& 
rLayoutFragmentPath,
-                                                               const OUString& 
rMasterFragmentPath)
+void PresentationFragmentHandler::importMasterSlide(const 
Reference<frame::XModel>& xModel,
+                                                    PowerPointImport& rFilter,
+                                                    const OUString& 
rMasterFragmentPath)
 {
     OUString aLayoutFragmentPath;
-    SlidePersistPtr pMasterPersistPtr, pMasterPtr;
+    SlidePersistPtr pMasterPersistPtr;
     Reference< drawing::XDrawPage > xMasterPage;
     Reference< drawing::XMasterPagesSupplier > xMPS( xModel, 
uno::UNO_QUERY_THROW );
     Reference< drawing::XDrawPages > xMasterPages( xMPS->getMasterPages(), 
uno::UNO_SET_THROW );
@@ -280,14 +279,7 @@ SlidePersistPtr 
PresentationFragmentHandler::importMasterSlide(const Reference<f
         {
             pTheme->addTheme(pMasterPersistPtr->getPage());
         }
-
-        if (pMasterPersistPtr->getLayoutPath() == rLayoutFragmentPath)
-        {
-            pMasterPtr = pMasterPersistPtr;
-        }
     }
-
-    return pMasterPtr;
 }
 
 void PresentationFragmentHandler::saveThemeToGrabBag(const 
oox::drawingml::ThemePtr& pThemePtr,
@@ -356,6 +348,19 @@ void PresentationFragmentHandler::saveThemeToGrabBag(const 
oox::drawingml::Theme
     }
 }
 
+void PresentationFragmentHandler::importMasterSlides()
+{
+    OUString aMasterFragmentPath;
+    PowerPointImport& rFilter = dynamic_cast<PowerPointImport&>(getFilter());
+    Reference<frame::XModel> xModel(rFilter.getModel());
+
+    for (sal_uInt32 nMaster = 0; nMaster < maSlideMasterVector.size(); 
++nMaster)
+    {
+        aMasterFragmentPath = 
getFragmentPathFromRelId(maSlideMasterVector[nMaster]);
+        importMasterSlide(xModel, rFilter, aMasterFragmentPath);
+    }
+}
+
 void PresentationFragmentHandler::importSlide(sal_uInt32 nSlide, bool 
bFirstPage, bool bImportNotesPage)
 {
     PowerPointImport& rFilter = dynamic_cast< PowerPointImport& >( getFilter() 
);
@@ -370,7 +375,10 @@ void PresentationFragmentHandler::importSlide(sal_uInt32 
nSlide, bool bFirstPage
     try {
 
         if( bFirstPage )
+        {
             xDrawPages->getByIndex( 0 ) >>= xSlide;
+            importMasterSlides();
+        }
         else
             xSlide = xDrawPages->insertNewByIndex( xDrawPages->getCount() );
 
@@ -403,11 +411,6 @@ void PresentationFragmentHandler::importSlide(sal_uInt32 
nSlide, bool bFirstPage
                             break;
                         }
                     }
-
-                    if ( !pMasterPersistPtr )
-                    {   // masterpersist not found, we have to load it
-                        pMasterPersistPtr = importMasterSlide(xModel, rFilter, 
aLayoutFragmentPath, aMasterFragmentPath);
-                    }
                 }
             }
 
commit c8d8d3bffec73e965ca3b9b30c4d74515e2d0d4e
Author:     Henry Castro <hcas...@collabora.com>
AuthorDate: Tue Oct 17 07:42:52 2023 -0400
Commit:     Caolán McNamara <caolan.mcnam...@collabora.com>
CommitDate: Sun Oct 29 21:47:13 2023 +0100

    tdf#155512: sd: filter: eppt: add "SlideLayout" property to Slide Master
    
    If it is importing all Slide Master from pptx file, unfortunately
    it breaks the exporting to pptx due to save and reload unit test failures
    
    According to the documentation
    http://officeopenxml.com/prSlideLayout.php, so the file pptx has a
    relationship Slide -> Slide Layout -> Slide Master
    
    The Slide Layout is a template an unique to be reused
    with Slide Master, so exporting requires to compare
    the templates due to LibreOffice relation Slide -> Slide Master
    
    Adjust unit test values:
    
    SdOOXMLExportTest2::testTdf106867
    revert adcde78935fb8ca2b93322aa3a558d0b3ccdbfad
    
    SdOOXMLExportTest2::testTdf112280
    revert adcde78935fb8ca2b93322aa3a558d0b3ccdbfad
    
    SdOOXMLExportTest2::testThemeColors and
    SdOOXMLExportTest3::testTdf114848
    The file tdf84205.pptx does not contain theme2.xml,
    and save and reload it does not caintain theme2.xml too
    fix "An uncaught exception of type 
com.sun.star.container.NoSuchElementException"
    
    Signed-off-by: Henry Castro <hcas...@collabora.com>
    Change-Id: I622e9d5d68c406ff520387f3903808613d1cd3d9
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158084
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>

diff --git a/oox/source/ppt/presentationfragmenthandler.cxx 
b/oox/source/ppt/presentationfragmenthandler.cxx
index 0ab32be82a21..80fb6c6689a7 100644
--- a/oox/source/ppt/presentationfragmenthandler.cxx
+++ b/oox/source/ppt/presentationfragmenthandler.cxx
@@ -213,6 +213,9 @@ SlidePersistPtr 
PresentationFragmentHandler::importMasterSlide(const Reference<f
 
     for (const auto& rEntry : *xMasterRelations)
     {
+        if (!rEntry.second.maType.endsWith("relationships/slideLayout"))
+            continue;
+
         aLayoutFragmentPath = 
xMasterRelations->getFragmentPathFromRelation(rEntry.second);
 
         sal_Int32 nIndex;
@@ -269,6 +272,9 @@ SlidePersistPtr 
PresentationFragmentHandler::importMasterSlide(const Reference<f
         pMasterPersistPtr->createBackground( rFilter );
         pMasterPersistPtr->createXShapes( rFilter );
 
+        uno::Reference< beans::XPropertySet > 
xSet(pMasterPersistPtr->getPage(), uno::UNO_QUERY_THROW);
+        xSet->setPropertyValue("SlideLayout", 
Any(pMasterPersistPtr->getLayoutFromValueToken()));
+
         oox::drawingml::ThemePtr pTheme = pMasterPersistPtr->getTheme();
         if (pTheme)
         {
diff --git a/sd/qa/unit/export-tests-ooxml2.cxx 
b/sd/qa/unit/export-tests-ooxml2.cxx
index 1996210bc6c2..47efaea2fe55 100644
--- a/sd/qa/unit/export-tests-ooxml2.cxx
+++ b/sd/qa/unit/export-tests-ooxml2.cxx
@@ -1462,7 +1462,7 @@ void SdOOXMLExportTest2::testTdf106867()
                 
"/p:sld/p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:cTn/p:childTnLst/p:par/"
                 
"p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:cmd/"
                 "p:cBhvr/p:tgtEl/p:spTgt",
-                "spid", "491");
+                "spid", "42");
 }
 
 void SdOOXMLExportTest2::testTdf112280()
@@ -1843,7 +1843,7 @@ void SdOOXMLExportTest2::testAccentColor()
                 "70ad47");
     xmlDocUniquePtr pXmlDocTheme2 = parseExport("ppt/theme/theme2.xml");
     assertXPath(pXmlDocTheme2, 
"/a:theme/a:themeElements/a:clrScheme/a:accent6/a:srgbClr", "val",
-                "70ad47");
+                "deb340");
 
     // Without the accompanying fix in place, this test would have failed with:
     // - Expected: Motyw pakietu Office
@@ -1858,7 +1858,7 @@ void SdOOXMLExportTest2::testThemeColors()
     createSdImpressDoc("pptx/tdf84205.pptx");
     save("Impress Office Open XML");
 
-    xmlDocUniquePtr pXmlDocTheme2 = parseExport("ppt/theme/theme2.xml");
+    xmlDocUniquePtr pXmlDocTheme2 = parseExport("ppt/theme/theme1.xml");
     assertXPath(pXmlDocTheme2, 
"/a:theme/a:themeElements/a:clrScheme/a:dk2/a:srgbClr", "val",
                 "44546a");
     assertXPath(pXmlDocTheme2, 
"/a:theme/a:themeElements/a:clrScheme/a:accent3/a:srgbClr", "val",
diff --git a/sd/qa/unit/export-tests-ooxml3.cxx 
b/sd/qa/unit/export-tests-ooxml3.cxx
index fa80e6c6b46c..e827e4d96805 100644
--- a/sd/qa/unit/export-tests-ooxml3.cxx
+++ b/sd/qa/unit/export-tests-ooxml3.cxx
@@ -288,10 +288,6 @@ void SdOOXMLExportTest3::testTdf114848()
     xmlDocUniquePtr pXmlDocTheme1 = parseExport("ppt/theme/theme1.xml");
     assertXPath(pXmlDocTheme1, 
"/a:theme/a:themeElements/a:clrScheme/a:dk2/a:srgbClr", "val",
                 "1f497d");
-    xmlDocUniquePtr pXmlDocTheme2 = parseExport("ppt/theme/theme2.xml");
-
-    assertXPath(pXmlDocTheme2, 
"/a:theme/a:themeElements/a:clrScheme/a:dk2/a:srgbClr", "val",
-                "1f497d");
 }
 
 void SdOOXMLExportTest3::testTdf147586()
diff --git a/sd/source/filter/eppt/epptooxml.hxx 
b/sd/source/filter/eppt/epptooxml.hxx
index 0c7644c72b3d..6d804c80cf1f 100644
--- a/sd/source/filter/eppt/epptooxml.hxx
+++ b/sd/source/filter/eppt/epptooxml.hxx
@@ -131,6 +131,8 @@ private:
     css::uno::Reference<css::drawing::XShape> 
GetReferencedPlaceholderXShape(const PlaceholderType eType, PageType ePageType) 
const;
     void WritePlaceholderReferenceShapes(PowerPointShapeExport& rDML, PageType 
ePageType);
 
+    long FindEquivalentMasterPage(SdrPage* pMasterPage) const;
+
     /// Should we export as .pptm, ie. do we contain macros?
     bool mbPptm;
 
@@ -140,12 +142,14 @@ private:
     ::sax_fastparser::FSHelperPtr mPresentationFS;
 
     LayoutInfo mLayoutInfo[EPP_LAYOUT_SIZE];
+    std::vector<std::pair<SdrPage*, size_t>> mpSlidesMaster;
     std::vector< ::sax_fastparser::FSHelperPtr > mpSlidesFSArray;
     sal_Int32 mnLayoutFileIdMax;
 
     sal_uInt32 mnSlideIdMax;
     sal_uInt32 mnSlideMasterIdMax;
     sal_uInt32 mnAnimationNodeIdMax;
+    sal_uInt32 mnThemeIdMax;
 
     sal_uInt32 mnDiagramId;
 
diff --git a/sd/source/filter/eppt/pptx-epptooxml.cxx 
b/sd/source/filter/eppt/pptx-epptooxml.cxx
index 437434c201fe..1e7b70501870 100644
--- a/sd/source/filter/eppt/pptx-epptooxml.cxx
+++ b/sd/source/filter/eppt/pptx-epptooxml.cxx
@@ -25,6 +25,8 @@
 #include <oox/ole/vbaproject.hxx>
 #include "epptooxml.hxx"
 #include <oox/export/shapes.hxx>
+#include <svx/svdlayer.hxx>
+#include <unokywds.hxx>
 
 #include <comphelper/sequenceashashmap.hxx>
 #include <comphelper/storagehelper.hxx>
@@ -40,6 +42,8 @@
 #include <com/sun/star/drawing/FillStyle.hpp>
 #include <com/sun/star/drawing/XDrawPages.hpp>
 #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
+#include <com/sun/star/drawing/XMasterPageTarget.hpp>
+#include <com/sun/star/drawing/XMasterPagesSupplier.hpp>
 #include <com/sun/star/embed/ElementModes.hpp>
 #include <com/sun/star/geometry/RealPoint2D.hpp>
 #include <com/sun/star/office/XAnnotationEnumeration.hpp>
@@ -388,6 +392,7 @@ PowerPointExport::PowerPointExport(const Reference< 
XComponentContext >& rContex
     , mnSlideIdMax(1 << 8)
     , mnSlideMasterIdMax(1U << 31)
     , mnAnimationNodeIdMax(1)
+    , mnThemeIdMax(0)
     , mnDiagramId(1)
     , mbCreateNotes(false)
     , mnPlaceholderIndexMax(1)
@@ -1489,8 +1494,111 @@ void PowerPointExport::AddLayoutIdAndRelation(const 
FSHelperPtr& pFS, sal_Int32
                          FSNS(XML_r, XML_id), sRelId);
 }
 
+static bool lcl_ContainsEquivalentObject(SdrPage* pPage, SdrObject* pObj)
+{
+    bool bFound = false;
+    SdrObject* pObjNext;
+
+    if (!pPage || !pObj)
+        return bFound;
+
+    for (size_t nObj = 0; nObj < pPage->GetObjCount(); ++nObj)
+    {
+        pObjNext = pPage->GetObj(nObj);
+        if (pObjNext && pObjNext->GetMergedItemSet().Equals(
+                pObj->GetMergedItemSet(), false))
+        {
+            bFound = true;
+            break;
+        }
+    }
+
+    return bFound;
+}
+
+static bool lcl_ComparePageObjects(SdrPage* pMasterPage, SdrPage* pMasterNext)
+{
+    if (!pMasterPage || !pMasterNext)
+        return false;
+
+    bool bFound = true;
+    SdrObject* pObjNext;
+    SdrLayerID aLayer =
+        
pMasterNext->GetLayerAdmin().GetLayerID(sUNO_LayerName_background_objects);
+
+    for (size_t nObj = 0; nObj < pMasterPage->GetObjCount(); ++nObj)
+    {
+        pObjNext = pMasterPage->GetObj(nObj);
+        if (!pObjNext || pObjNext->GetLayer() == aLayer)
+            continue;
+
+        if (!lcl_ContainsEquivalentObject(pMasterNext, pObjNext))
+        {
+            bFound = false;
+            break;
+        }
+    }
+
+    return bFound;
+}
+
+long PowerPointExport::FindEquivalentMasterPage(SdrPage* pMasterPage) const
+{
+    SdrPage* pMasterNext;
+    long nFound = -1;
+
+    if (!pMasterPage)
+        return nFound;
+
+    for (size_t nMaster = 0; nMaster < mpSlidesMaster.size(); ++nMaster)
+    {
+        pMasterNext = mpSlidesMaster[nMaster].first;
+        if (!pMasterNext)
+            continue;
+
+        if (pMasterNext->getSdrPageProperties().GetItemSet().Equals(
+                pMasterPage->getSdrPageProperties().GetItemSet(), false) &&
+            lcl_ComparePageObjects(pMasterPage, pMasterNext))
+        {
+            nFound = nMaster;
+            break;
+        }
+    }
+
+    return nFound;
+}
+
 void PowerPointExport::ImplWriteSlideMaster(sal_uInt32 nPageNum, Reference< 
XPropertySet > const& aXBackgroundPropSet)
 {
+    SdrPage* pMasterPage = SdPage::getImplementation(mXDrawPage);
+    if (!pMasterPage)
+        return;
+
+    uno::Reference<beans::XPropertySet> xPropSet(mXDrawPage, 
uno::UNO_QUERY_THROW);
+    if (!xPropSet.is())
+        return;
+
+    sal_Int32 nLayout;
+    Any aLayout = xPropSet->getPropertyValue("SlideLayout");
+    long nFound = FindEquivalentMasterPage(pMasterPage);
+    if (aLayout.hasValue() && nFound != -1)
+    {
+        aLayout >>= nLayout;
+        size_t nOffset = GetPPTXLayoutId(nLayout);
+
+        if (mLayoutInfo[nOffset].mnFileIdArray.size() < mnMasterPages)
+        {
+            mLayoutInfo[nOffset].mnFileIdArray.resize(mnMasterPages);
+        }
+
+        mLayoutInfo[nOffset].mnFileIdArray[nPageNum] = 
mpSlidesMaster[nFound].second;
+
+        if (nPageNum == mnMasterPages - 1)
+            mPresentationFS->endElementNS(XML_p, XML_sldMasterIdLst);
+
+        return;
+    }
+
     SAL_INFO("sd.eppt", "write master slide: " << nPageNum << 
"\n--------------");
 
     // slides list
@@ -1513,7 +1621,7 @@ void PowerPointExport::ImplWriteSlideMaster(sal_uInt32 
nPageNum, Reference< XPro
                                           OUString::number(nPageNum + 1) + 
".xml",
                                          
"application/vnd.openxmlformats-officedocument.presentationml.slideMaster+xml");
 
-    SdrPage* pMasterPage = SdPage::getImplementation(mXDrawPage);
+
     model::Theme* pTheme = nullptr;
     if (pMasterPage)
     {
@@ -1521,12 +1629,12 @@ void PowerPointExport::ImplWriteSlideMaster(sal_uInt32 
nPageNum, Reference< XPro
     }
 
     // write theme per master
-    WriteTheme(nPageNum, pTheme);
+    WriteTheme(mnThemeIdMax, pTheme);
 
     // add implicit relation to the presentation theme
     addRelation(pFS->getOutputStream(),
                 oox::getRelationship(Relationship::THEME),
-                Concat2View("../theme/theme" + OUString::number(nPageNum + 1) 
+ ".xml"));
+                Concat2View("../theme/theme" + 
OUString::number(++mnThemeIdMax) + ".xml"));
 
     pFS->startElementNS(XML_p, XML_sldMaster, PNMSS);
 
@@ -1570,6 +1678,13 @@ void PowerPointExport::ImplWriteSlideMaster(sal_uInt32 
nPageNum, Reference< XPro
         }
     }
 
+    if (aLayout.hasValue())
+    {
+        aLayout >>= nLayout;
+        mpSlidesMaster.push_back(std::make_pair(pMasterPage,
+                                                
GetLayoutFileId(GetPPTXLayoutId(nLayout), nPageNum)));
+    }
+
     pFS->endElementNS(XML_p, XML_sldLayoutIdLst);
 
     pFS->endElementNS(XML_p, XML_sldMaster);
@@ -2268,10 +2383,11 @@ Reference<XShape> 
PowerPointExport::GetReferencedPlaceholderXShape(const Placeho
         }
         else
         {
-            pMasterPage
-                = 
&static_cast<SdPage&>(SdPage::getImplementation(mXDrawPage)->TRG_GetMasterPage());
+            SdrPage* pPage = 
&SdPage::getImplementation(mXDrawPage)->TRG_GetMasterPage();
+            long nFound = FindEquivalentMasterPage(pPage);
+            pMasterPage = dynamic_cast<SdPage*>(nFound != -1 ? 
mpSlidesMaster[nFound].first : pPage);
         }
-        if (SdrObject* pMasterFooter = pMasterPage->GetPresObj(ePresObjKind))
+        if (SdrObject* pMasterFooter = (pMasterPage ? 
pMasterPage->GetPresObj(ePresObjKind) : nullptr))
             return GetXShapeForSdrObject(pMasterFooter);
     }
     return nullptr;
diff --git a/sd/source/ui/inc/unopage.hxx b/sd/source/ui/inc/unopage.hxx
index 1eb3cb6d83b1..f2d646817536 100644
--- a/sd/source/ui/inc/unopage.hxx
+++ b/sd/source/ui/inc/unopage.hxx
@@ -56,6 +56,7 @@ private:
     SdrModel* mpSdrModel;
     bool      mbIsImpressDocument;
     sal_Int16 mnTempPageNumber; // for printing handouts
+    css::uno::Any  mSlideLayout;  // import slide layout pptx
     const SvxItemPropertySet*   mpPropSet;
 
     void UpdateModel();
diff --git a/sd/source/ui/unoidl/unopage.cxx b/sd/source/ui/unoidl/unopage.cxx
index d23ba1ad2e0e..cc52acf448a3 100644
--- a/sd/source/ui/unoidl/unopage.cxx
+++ b/sd/source/ui/unoidl/unopage.cxx
@@ -103,7 +103,8 @@ enum WID_PAGE
     WID_PAGE_PAGENUMBERVISIBLE, WID_PAGE_DATETIMEVISIBLE, 
WID_PAGE_DATETIMEFIXED,
     WID_PAGE_DATETIMETEXT, WID_PAGE_DATETIMEFORMAT, WID_TRANSITION_TYPE, 
WID_TRANSITION_SUBTYPE,
     WID_TRANSITION_DIRECTION, WID_TRANSITION_FADE_COLOR, 
WID_TRANSITION_DURATION, WID_LOOP_SOUND,
-    WID_NAVORDER, WID_PAGE_PREVIEWMETAFILE, WID_PAGE_THEME, 
WID_PAGE_THEME_UNO_REPRESENTATION
+    WID_NAVORDER, WID_PAGE_PREVIEWMETAFILE, WID_PAGE_THEME, 
WID_PAGE_THEME_UNO_REPRESENTATION,
+    WID_PAGE_SLIDE_LAYOUT
 };
 
 }
@@ -284,7 +285,8 @@ static const SvxItemPropertySet* 
ImplGetMasterPagePropertySet( PageKind ePageKin
         { u"IsBackgroundDark",             WID_PAGE_ISDARK,    
cppu::UnoType<bool>::get(),                        
beans::PropertyAttribute::READONLY, 0},
         { u"Theme", WID_PAGE_THEME, cppu::UnoType<util::XTheme>::get(), 0,  0},
         // backwards compatible view of the theme for use in tests
-        { u"ThemeUnoRepresentation", WID_PAGE_THEME_UNO_REPRESENTATION, 
cppu::UnoType<uno::Sequence<beans::PropertyValue>>::get(), 0,  0}
+        { u"ThemeUnoRepresentation", WID_PAGE_THEME_UNO_REPRESENTATION, 
cppu::UnoType<uno::Sequence<beans::PropertyValue>>::get(), 0,  0},
+        { u"SlideLayout",            WID_PAGE_SLIDE_LAYOUT,    
::cppu::UnoType<sal_Int16>::get(),            0,  0}
     };
 
     static const SfxItemPropertyMapEntry aHandoutMasterPagePropertyMap_Impl[] =
@@ -591,6 +593,7 @@ void SAL_CALL SdGenericDrawPage::setPropertyValue( const 
OUString& aPropertyName
         case WID_PAGE_TOP:
         case WID_PAGE_BOTTOM:
         case WID_PAGE_LAYOUT:
+        case WID_PAGE_SLIDE_LAYOUT:
         case WID_PAGE_DURATION:
         case WID_PAGE_CHANGE:
         {
@@ -618,6 +621,9 @@ void SAL_CALL SdGenericDrawPage::setPropertyValue( const 
OUString& aPropertyName
             case WID_PAGE_LAYOUT:
                 GetPage()->SetAutoLayout( static_cast<AutoLayout>(nValue), 
true );
                 break;
+            case WID_PAGE_SLIDE_LAYOUT:
+                mSlideLayout <<= nValue;
+                break;
             case WID_PAGE_DURATION:
                 GetPage()->SetTime(nValue);
                 break;
@@ -1057,6 +1063,9 @@ Any SAL_CALL SdGenericDrawPage::getPropertyValue( const 
OUString& PropertyName )
     case WID_PAGE_LAYOUT:
         aAny <<= static_cast<sal_Int16>( GetPage()->GetAutoLayout() );
         break;
+    case WID_PAGE_SLIDE_LAYOUT:
+        aAny = mSlideLayout;
+        break;
     case WID_PAGE_NUMBER:
         {
             const sal_uInt16 nPageNumber(GetPage()->GetPageNum());

Reply via email to