oox/source/ppt/presentationfragmenthandler.cxx |    7 -
 oox/source/ppt/slidepersist.cxx                |    6 
 sd/qa/unit/data/pptx/tdf157740.pptx            |binary
 sd/qa/unit/export-tests-ooxml1.cxx             |   16 +-
 sd/qa/unit/export-tests-ooxml2.cxx             |   12 -
 sd/source/core/drawdoc3.cxx                    |   38 ++++-
 sd/source/filter/eppt/epptbase.hxx             |    2 
 sd/source/filter/eppt/epptooxml.hxx            |    2 
 sd/source/filter/eppt/pptx-epptooxml.cxx       |  160 ++++++++++---------------
 sd/source/ui/inc/unopage.hxx                   |    1 
 sd/source/ui/unoidl/unopage.cxx                |   13 +-
 xmloff/source/draw/ximpbody.cxx                |   19 ++
 12 files changed, 149 insertions(+), 127 deletions(-)

New commits:
commit 397da200a5250bc23df7692354ccb4910783f61e
Author:     Balazs Varga <balazs.varga.ext...@allotropia.de>
AuthorDate: Sun Dec 3 23:41:01 2023 +0100
Commit:     Henry Castro <hcas...@collabora.com>
CommitDate: Tue Dec 19 22:47:04 2023 +0100

    tdf#157740 FILESAVE PPTX: fix explosion of the number of master slides
    
    - Export correctly the "supported" master slides with the actual slides 
names.
    - Set SlideLayout property at ODF import as well for MasterSlides layout 
type.
    - When we copy a slide with the master slide also copy the SlideLayout 
property
    value as well.
    
    Change-Id: Idb6b88ebe87a83818d8eb27a1fa087652a002c0c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160290
    Tested-by: Jenkins
    Reviewed-by: Henry Castro <hcas...@collabora.com>
    Reviewed-by: Balazs Varga <balazs.varga.ext...@allotropia.de>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160985
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>

diff --git a/oox/source/ppt/presentationfragmenthandler.cxx 
b/oox/source/ppt/presentationfragmenthandler.cxx
index 1586a8a26174..91824210e239 100644
--- a/oox/source/ppt/presentationfragmenthandler.cxx
+++ b/oox/source/ppt/presentationfragmenthandler.cxx
@@ -212,11 +212,11 @@ void PresentationFragmentHandler::importMasterSlide(const 
Reference<frame::XMode
 
     for (const auto& rEntry : *xMasterRelations)
     {
-        aLayoutFragmentPath = 
xMasterRelations->getFragmentPathFromRelation(rEntry.second);
-
         if (!rEntry.second.maType.endsWith("relationships/slideLayout"))
             continue;
 
+        aLayoutFragmentPath = 
xMasterRelations->getFragmentPathFromRelation(rEntry.second);
+
         sal_Int32 nIndex;
         if( rFilter.getMasterPages().empty() )
         {
@@ -271,6 +271,9 @@ void PresentationFragmentHandler::importMasterSlide(const 
Reference<frame::XMode
         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/oox/source/ppt/slidepersist.cxx b/oox/source/ppt/slidepersist.cxx
index 0f7479e8ede9..d31416e43f5b 100644
--- a/oox/source/ppt/slidepersist.cxx
+++ b/oox/source/ppt/slidepersist.cxx
@@ -105,6 +105,7 @@ sal_Int16 SlidePersist::getLayoutFromValueToken() const
         case XML_titleOnly:         nLayout = 19; break;
         case XML_twoObj:
         case XML_twoColTx:          nLayout =  3; break;
+        case XML_twoObjAndObj:
         case XML_twoObjAndTx:       nLayout = 15; break;
         case XML_twoObjOverTx:      nLayout = 16; break;
         case XML_tx:                nLayout =  1; break;
@@ -112,19 +113,18 @@ sal_Int16 SlidePersist::getLayoutFromValueToken() const
         case XML_txAndClipArt:      nLayout =  6; break;
         case XML_txAndMedia:        nLayout =  6; break;
         case XML_txAndObj:          nLayout = 10; break;
+        case XML_objAndTwoObj:
         case XML_txAndTwoObj:       nLayout = 12; break;
         case XML_txOverObj:         nLayout = 17; break;
         case XML_vertTitleAndTx:    nLayout = 22; break;
         case XML_vertTitleAndTxOverChart: nLayout = 21; break;
         case XML_vertTx:            nLayout = 23; break;
+        case XML_objOnly:           nLayout = 32; break;
 
         case XML_twoTxTwoObj:
-        case XML_twoObjAndObj:
         case XML_objTx:
         case XML_picTx:
         case XML_secHead:
-        case XML_objOnly:
-        case XML_objAndTwoObj:
         case XML_mediaAndTx:
         case XML_dgm:
         case XML_cust:
diff --git a/sd/qa/unit/data/pptx/tdf157740.pptx 
b/sd/qa/unit/data/pptx/tdf157740.pptx
new file mode 100644
index 000000000000..009e9eeb1da0
Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf157740.pptx differ
diff --git a/sd/qa/unit/export-tests-ooxml1.cxx 
b/sd/qa/unit/export-tests-ooxml1.cxx
index 30df5ba06789..e7726d27e29e 100644
--- a/sd/qa/unit/export-tests-ooxml1.cxx
+++ b/sd/qa/unit/export-tests-ooxml1.cxx
@@ -263,14 +263,14 @@ void SdOOXMLExportTest1::testTdf149128()
     save("Impress Office Open XML");
 
     xmlDocUniquePtr pXmlDoc = parseExport("ppt/slides/slide1.xml");
-    assertXPath(pXmlDoc, 
"/p:sld/p:cSld/p:spTree/p:cxnSp/p:nvCxnSpPr/p:cNvCxnSpPr/a:stCxn", "id",
-                "42");
-    assertXPath(pXmlDoc, 
"/p:sld/p:cSld/p:spTree/p:cxnSp/p:nvCxnSpPr/p:cNvCxnSpPr/a:stCxn", "idx",
-                "0");
-    assertXPath(pXmlDoc, 
"/p:sld/p:cSld/p:spTree/p:cxnSp/p:nvCxnSpPr/p:cNvCxnSpPr/a:endCxn", "id",
-                "43");
-    assertXPath(pXmlDoc, 
"/p:sld/p:cSld/p:spTree/p:cxnSp/p:nvCxnSpPr/p:cNvCxnSpPr/a:endCxn", "idx",
-                "2");
+    assertXPath(pXmlDoc, 
"/p:sld/p:cSld/p:spTree/p:cxnSp/p:nvCxnSpPr/p:cNvCxnSpPr/a:stCxn",
+                "id", "8");
+    assertXPath(pXmlDoc, 
"/p:sld/p:cSld/p:spTree/p:cxnSp/p:nvCxnSpPr/p:cNvCxnSpPr/a:stCxn",
+                "idx", "0");
+    assertXPath(pXmlDoc, 
"/p:sld/p:cSld/p:spTree/p:cxnSp/p:nvCxnSpPr/p:cNvCxnSpPr/a:endCxn",
+                "id", "9");
+    assertXPath(pXmlDoc, 
"/p:sld/p:cSld/p:spTree/p:cxnSp/p:nvCxnSpPr/p:cNvCxnSpPr/a:endCxn",
+                "idx", "2");
 }
 
 void SdOOXMLExportTest1::testTdf66228()
diff --git a/sd/qa/unit/export-tests-ooxml2.cxx 
b/sd/qa/unit/export-tests-ooxml2.cxx
index 9d572a8ee10c..cd3aed7d51dc 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", "455");
+                "spid", "67");
 }
 
 void SdOOXMLExportTest2::testTdf112280()
@@ -1839,11 +1839,11 @@ void SdOOXMLExportTest2::testAccentColor()
     assertXPath(pXmlDocContent2, 
"/p:sld/p:cSld/p:spTree/p:sp/p:style/a:fillRef/a:schemeClr", "val",
                 "accent6");
     xmlDocUniquePtr pXmlDocTheme1 = parseExport("ppt/theme/theme1.xml");
-    assertXPath(pXmlDocTheme1, 
"/a:theme/a:themeElements/a:clrScheme/a:accent6/a:srgbClr", "val",
-                "70ad47");
-    xmlDocUniquePtr pXmlDocTheme2 = parseExport("ppt/theme/theme24.xml");
-    assertXPath(pXmlDocTheme2, 
"/a:theme/a:themeElements/a:clrScheme/a:accent6/a:srgbClr", "val",
-                "deb340");
+    assertXPath(pXmlDocTheme1, 
"/a:theme/a:themeElements/a:clrScheme/a:accent6/a:srgbClr",
+                "val", "70ad47");
+    xmlDocUniquePtr pXmlDocTheme2 = parseExport("ppt/theme/theme12.xml");
+    assertXPath(pXmlDocTheme2, 
"/a:theme/a:themeElements/a:clrScheme/a:accent6/a:srgbClr",
+                "val", "deb340");
 
     // Without the accompanying fix in place, this test would have failed with:
     // - Expected: Motyw pakietu Office
diff --git a/sd/source/core/drawdoc3.cxx b/sd/source/core/drawdoc3.cxx
index aaaabf7d304e..410141980d1d 100644
--- a/sd/source/core/drawdoc3.cxx
+++ b/sd/source/core/drawdoc3.cxx
@@ -67,11 +67,11 @@ namespace {
 class InsertBookmarkAsPage_FindDuplicateLayouts
 {
 public:
-    explicit InsertBookmarkAsPage_FindDuplicateLayouts( std::vector<OUString> 
&rLayoutsToTransfer )
+    explicit InsertBookmarkAsPage_FindDuplicateLayouts( std::map<OUString, 
sal_Int32> &rLayoutsToTransfer )
         : mrLayoutsToTransfer(rLayoutsToTransfer) {}
     void operator()( SdDrawDocument&, SdPage const *, bool, SdDrawDocument* );
 private:
-    std::vector<OUString> &mrLayoutsToTransfer;
+    std::map<OUString, sal_Int32> &mrLayoutsToTransfer;
 };
 
 }
@@ -85,11 +85,11 @@ void InsertBookmarkAsPage_FindDuplicateLayouts::operator()( 
SdDrawDocument& rDoc
     if( nIndex != -1 )
         aLayout = aLayout.copy(0, nIndex);
 
-    std::vector<OUString>::const_iterator pIter =
-            
find(mrLayoutsToTransfer.begin(),mrLayoutsToTransfer.end(),aLayout);
+    std::map<OUString, sal_Int32>::const_iterator pIter = 
mrLayoutsToTransfer.find(aLayout);
 
     bool bFound = pIter != mrLayoutsToTransfer.end();
 
+    sal_Int32 nLayout = 20; // blank page - master slide layout ID
     const sal_uInt16 nMPageCount = rDoc.GetMasterPageCount();
     for (sal_uInt16 nMPage = 0; nMPage < nMPageCount && !bFound; nMPage++)
     {
@@ -110,6 +110,15 @@ void 
InsertBookmarkAsPage_FindDuplicateLayouts::operator()( SdDrawDocument& rDoc
                     pBMMPage->GetLayoutName(), pBMMPage->GetName() + "_");
                 aLayout = pBMMPage->GetName();
 
+                uno::Reference< drawing::XDrawPage > 
xOldPage(rDoc.GetMasterPage(nMPage)->getUnoPage(), uno::UNO_QUERY_THROW);
+                uno::Reference<beans::XPropertySet> xPropSet(xOldPage, 
uno::UNO_QUERY_THROW);
+                if (xPropSet.is())
+                {
+                    uno::Any aLayoutID = 
xPropSet->getPropertyValue("SlideLayout");
+                    if (aLayoutID.hasValue()) {
+                        aLayoutID >>= nLayout;
+                    }
+                }
                 break;
             }
             else
@@ -118,7 +127,7 @@ void InsertBookmarkAsPage_FindDuplicateLayouts::operator()( 
SdDrawDocument& rDoc
     }
 
     if (!bFound)
-        mrLayoutsToTransfer.push_back(aLayout);
+        mrLayoutsToTransfer.insert({ aLayout, nLayout });
 }
 
 // Inserts a bookmark as a page
@@ -499,7 +508,7 @@ bool SdDrawDocument::InsertBookmarkAsPage(
 
     // Refactored copy'n'pasted layout name collection into 
IterateBookmarkPages
 
-    std::vector<OUString> aLayoutsToTransfer;
+    std::map<OUString, sal_Int32> aLayoutsToTransfer;
     InsertBookmarkAsPage_FindDuplicateLayouts aSearchFunctor( 
aLayoutsToTransfer );
     lcl_IterateBookmarkPages( *this, pBookmarkDoc, rBookmarkList, 
nBMSdPageCount, aSearchFunctor, ( rBookmarkList.empty() && pBookmarkDoc != this 
) );
 
@@ -511,11 +520,11 @@ bool SdDrawDocument::InsertBookmarkAsPage(
     if( !aLayoutsToTransfer.empty() )
         bMergeMasterPages = true;
 
-    for ( const OUString& layoutName : aLayoutsToTransfer )
+    for ( const auto& layout : aLayoutsToTransfer )
     {
         StyleSheetCopyResultVector aCreatedStyles;
 
-        rStyleSheetPool.CopyLayoutSheets(layoutName, 
rBookmarkStyleSheetPool,aCreatedStyles);
+        rStyleSheetPool.CopyLayoutSheets(layout.first, 
rBookmarkStyleSheetPool, aCreatedStyles);
 
         if(!aCreatedStyles.empty())
         {
@@ -897,6 +906,19 @@ bool SdDrawDocument::InsertBookmarkAsPage(
                 pRefPage->SetSize(aSize);
                 pRefPage->SetBorder(nLeft, nUpper, nRight, nLower);
                 pRefPage->SetOrientation( eOrient );
+
+                uno::Reference< drawing::XDrawPage > 
xNewPage(GetMasterPage(nPage)->getUnoPage(), uno::UNO_QUERY_THROW);
+                uno::Reference<beans::XPropertySet> xNewPropSet(xNewPage, 
uno::UNO_QUERY_THROW);
+                if (xNewPropSet.is())
+                {
+                    OUString aLayout(pRefPage->GetName());
+                    sal_Int32 nLayout = 20; // blank page - master slide 
layout ID
+                    if (auto it{ aLayoutsToTransfer.find(aLayout) }; it != 
std::end(aLayoutsToTransfer))
+                    {
+                        nLayout = it->second;
+                    }
+                    xNewPropSet->setPropertyValue("SlideLayout", 
uno::Any(nLayout));
+                }
             }
             else        // Can only be notes
             {
diff --git a/sd/source/filter/eppt/epptbase.hxx 
b/sd/source/filter/eppt/epptbase.hxx
index c56866b248fe..64709fa14f39 100644
--- a/sd/source/filter/eppt/epptbase.hxx
+++ b/sd/source/filter/eppt/epptbase.hxx
@@ -73,7 +73,7 @@ enum class EppLayout
     TITLERIGHT2BODIESLEFT = 18  /* Vertical title on the right, body on the 
left split into 2 rows                        */
 };
 
-#define EPP_LAYOUT_SIZE 25
+#define EPP_LAYOUT_SIZE 36
 
 struct PHLayout
 {
diff --git a/sd/source/filter/eppt/epptooxml.hxx 
b/sd/source/filter/eppt/epptooxml.hxx
index 0c7644c72b3d..2d67ebce2c77 100644
--- a/sd/source/filter/eppt/epptooxml.hxx
+++ b/sd/source/filter/eppt/epptooxml.hxx
@@ -89,7 +89,7 @@ private:
                                  bool bHasBackground, css::uno::Reference< 
css::beans::XPropertySet > const & aXBackgroundPropSet ) override;
     virtual void ImplWriteNotes( sal_uInt32 nPageNum ) override;
     virtual void ImplWriteSlideMaster( sal_uInt32 nPageNum, 
css::uno::Reference< css::beans::XPropertySet > const & aXBackgroundPropSet ) 
override;
-    void ImplWritePPTXLayout( sal_Int32 nOffset, sal_uInt32 nMasterNum );
+    void ImplWritePPTXLayout( sal_Int32 nOffset, sal_uInt32 nMasterNum, const 
OUString& aSlideName );
     static void WriteDefaultColorSchemes(const FSHelperPtr& pFS);
     void WriteTheme( sal_Int32 nThemeNum, model::Theme* pTheme );
 
diff --git a/sd/source/filter/eppt/pptx-epptooxml.cxx 
b/sd/source/filter/eppt/pptx-epptooxml.cxx
index 437434c201fe..8759a78ef88e 100644
--- a/sd/source/filter/eppt/pptx-epptooxml.cxx
+++ b/sd/source/filter/eppt/pptx-epptooxml.cxx
@@ -187,23 +187,6 @@ const char* getPlaceholderTypeName(PlaceholderType 
ePlaceholder)
 
 namespace {
 
-enum PPTXLayout
-{
-    LAYOUT_BLANK,
-    LAYOUT_TITLE_SLIDE,
-    LAYOUT_TITLE_CONTENT,
-    LAYOUT_TITLE_2CONTENT,
-    LAYOUT_TITLE,
-    LAYOUT_CENTERED_TEXT,
-    LAYOUT_TITLE_2CONTENT_CONTENT,
-    LAYOUT_TITLE_CONTENT_2CONTENT,
-    LAYOUT_TITLE_2CONTENT_OVER_CONTENT,
-    LAYOUT_TITLE_CONTENT_OVER_CONTENT,
-    LAYOUT_TITLE_4CONTENT,
-    LAYOUT_TITLE_6CONTENT,
-    LAYOUT_SIZE
-};
-
 struct PPTXLayoutInfo
 {
     int nType;
@@ -213,72 +196,46 @@ struct PPTXLayoutInfo
 
 }
 
-const PPTXLayoutInfo aLayoutInfo[LAYOUT_SIZE] =
+const PPTXLayoutInfo aLayoutInfo[EPP_LAYOUT_SIZE] =
 {
-    { 20, "Blank Slide", "blank" },
-    { 0, "Title Slide", "tx" },
-    { 1, "Title, Content", "obj" },
-    { 3, "Title, 2 Content", "twoObj" },
+    { 0, "Title Slide", "title" },
+    { 1, "Title and text", "tx" },
+    { 2, "Title and chart", "chart" },
+    { 3, "Title, text on left, text on right", "twoObj" },
+    { 4, "Title, text on left and chart on right", "txAndChart" },
+    { 6, "Title, text on left, clip art on right", "txAndClipArt" },
+    { 6, "Title, text on left, media on right", "txAndMedia" },
+    { 7, "Title, chart on left and text on right", "chartAndTx" },
+    { 8, "Title and table", "tbl" },
+    { 9, "Title, clipart on left, text on right", "clipArtAndTx" },
+    { 10, "Title, text on left, object on right", "txAndObj" },
+    { 1, "Title and object", "obj" },
+    { 12, "Title, text on left, two objects on right", "txAndTwoObj" },
+    { 13, "Title, object on left, text on right", "objAndTx" },
+    { 14, "Title, object on top, text on bottom", "objOverTx" },
+    { 15, "Title, two objects on left, text on right", "twoObjAndTx" },
+    { 16, "Title, two objects on top, text on bottom", "twoObjOverTx" },
+    { 17, "Title, text on top, object on bottom", "txOverObj" },
+    { 18, "Title and four objects", "fourObj" },
     { 19, "Title Only", "titleOnly" },
-    { 32, "Centered Text", "objOnly" },                       // not exactly, 
but close
-    { 15, "Title, 2 Content and Content", "twoObjAndObj" },
-    { 12, "Title Content and 2 Content", "objAndTwoObj" },
-    { 16, "Title, 2 Content over Content", "twoObjOverTx" },      // not 
exactly, but close
-    { 14, "Title, Content over Content", "objOverTx" },           // not 
exactly, but close
-    { 18, "Title, 4 Content", "fourObj" },
-    { 34, "Title, 6 Content", "blank" }                           // not 
defined => blank
+    { 20, "Blank Slide", "blank" },
+    { 21, "Vertical title on right, vertical text on top, chart on bottom", 
"vertTitleAndTxOverChart" },
+    { 22, "Vertical title on right, vertical text on left", "vertTitleAndTx" },
+    { 23, "Title and vertical text body", "vertTx" },
+    { 24, "Title, clip art on left, vertical text on right", 
"clipArtAndVertTx" },
+    { 20, "Title, two objects each with text", "twoTxTwoObj" },
+    { 15, "Title, two objects on left, one object on right", "twoObjAndObj" },
+    { 20, "Title, object and caption text", "objTx" },
+    { 20, "Title, picture, and caption text", "picTx" },
+    { 20, "Section header title and subtitle text", "secHead" },
+    { 32, "Object only", "objOnly" },
+    { 12, "Title, one object on left, two objects on right", "objAndTwoObj" },
+    { 20, "Title, media on left, text on right", "mediaAndTx" },
+    { 34, "Title, 6 Content", "blank" }, // not defined in OOXML => blank
+    { 2, "Title and diagram", "dgm" },
+    { 0, "Custom layout defined by user", "cust" },
 };
 
-int PowerPointExport::GetPPTXLayoutId(int nOffset)
-{
-    int nId = LAYOUT_BLANK;
-
-    SAL_INFO("sd.eppt", "GetPPTXLayoutId " << nOffset);
-
-    switch (nOffset)
-    {
-    case 0:
-        nId = LAYOUT_TITLE_SLIDE;
-        break;
-    case 1:
-        nId = LAYOUT_TITLE_CONTENT;
-        break;
-    case 3:
-        nId = LAYOUT_TITLE_2CONTENT;
-        break;
-    case 19:
-        nId = LAYOUT_TITLE;
-        break;
-    case 15:
-        nId = LAYOUT_TITLE_2CONTENT_CONTENT;
-        break;
-    case 12:
-        nId = LAYOUT_TITLE_CONTENT_2CONTENT;
-        break;
-    case 16:
-        nId = LAYOUT_TITLE_2CONTENT_OVER_CONTENT;
-        break;
-    case 14:
-        nId = LAYOUT_TITLE_CONTENT_OVER_CONTENT;
-        break;
-    case 18:
-        nId = LAYOUT_TITLE_4CONTENT;
-        break;
-    case 32:
-        nId = LAYOUT_CENTERED_TEXT;
-        break;
-    case 34:
-        nId = LAYOUT_TITLE_6CONTENT;
-        break;
-    case 20:
-    default:
-        nId = LAYOUT_BLANK;
-        break;
-    }
-
-    return nId;
-}
-
 PowerPointShapeExport::PowerPointShapeExport(FSHelperPtr pFS, ShapeHashMap* 
pShapeMap,
         PowerPointExport* pFB)
     : ShapeExport(XML_p, std::move(pFS), pShapeMap, pFB)
@@ -1421,7 +1378,7 @@ void PowerPointExport::ImplWriteSlide(sal_uInt32 
nPageNum, sal_uInt32 nMasterNum
     addRelation(pFS->getOutputStream(),
                 oox::getRelationship(Relationship::SLIDELAYOUT),
                 Concat2View("../slideLayouts/slideLayout" +
-                    
OUString::number(GetLayoutFileId(GetPPTXLayoutId(GetLayoutOffset(mXPagePropSet)),
 nMasterNum)) +
+                    
OUString::number(GetLayoutFileId(GetLayoutOffset(mXPagePropSet), nMasterNum)) +
                     ".xml"));
 
     if (WriteComments(nPageNum))
@@ -1556,20 +1513,24 @@ void PowerPointExport::ImplWriteSlideMaster(sal_uInt32 
nPageNum, Reference< XPro
     // use master's id type as they have same range, mso does that as well
     pFS->startElementNS(XML_p, XML_sldLayoutIdLst);
 
-    for (int i = 0; i < LAYOUT_SIZE; i++)
+    sal_Int32 nLayout = 0;
+    OUString aSlideName;
+    css::uno::Reference< css::beans::XPropertySet >xPagePropSet;
+    xPagePropSet.set(mXDrawPage, UNO_QUERY);
+    if (xPagePropSet.is())
     {
-        sal_Int32 nLayoutFileId = GetLayoutFileId(i, nPageNum);
-        if (nLayoutFileId > 0)
-        {
-            AddLayoutIdAndRelation(pFS, nLayoutFileId);
-        }
-        else
-        {
-            ImplWritePPTXLayout(i, nPageNum);
-            AddLayoutIdAndRelation(pFS, GetLayoutFileId(i, nPageNum));
-        }
+        uno::Any aAny;
+        if (GetPropertyValue(aAny, xPagePropSet, "SlideLayout"))
+            aAny >>= nLayout;
     }
 
+    Reference< XNamed > xNamed(mXDrawPage, UNO_QUERY);
+    if (xNamed.is())
+        aSlideName = xNamed->getName();
+
+    ImplWritePPTXLayout(nLayout, nPageNum, aSlideName);
+    AddLayoutIdAndRelation(pFS, GetLayoutFileId(nLayout, nPageNum));
+
     pFS->endElementNS(XML_p, XML_sldLayoutIdLst);
 
     pFS->endElementNS(XML_p, XML_sldMaster);
@@ -1588,7 +1549,7 @@ sal_Int32 PowerPointExport::GetLayoutFileId(sal_Int32 
nOffset, sal_uInt32 nMaste
     return mLayoutInfo[ nOffset ].mnFileIdArray[ nMasterNum ];
 }
 
-void PowerPointExport::ImplWritePPTXLayout(sal_Int32 nOffset, sal_uInt32 
nMasterNum)
+void PowerPointExport::ImplWritePPTXLayout(sal_Int32 nOffset, sal_uInt32 
nMasterNum, const OUString& aSlideName)
 {
     SAL_INFO("sd.eppt", "write layout: " << nOffset);
 
@@ -1632,8 +1593,16 @@ void PowerPointExport::ImplWritePPTXLayout(sal_Int32 
nOffset, sal_uInt32 nMaster
                         XML_type, aLayoutInfo[ nOffset ].sType,
                         XML_preserve, "1");
 
-    pFS->startElementNS(XML_p, XML_cSld,
-                        XML_name, aLayoutInfo[ nOffset ].sName);
+    if (!aSlideName.isEmpty())
+    {
+        pFS->startElementNS(XML_p, XML_cSld,
+            XML_name, aSlideName);
+    }
+    else
+    {
+        pFS->startElementNS(XML_p, XML_cSld,
+            XML_name, aLayoutInfo[nOffset].sName);
+    }
     //pFS->write( MINIMAL_SPTREE ); // TODO: write actual shape tree
     WriteShapeTree(pFS, LAYOUT, true);
 
@@ -2268,8 +2237,7 @@ Reference<XShape> 
PowerPointExport::GetReferencedPlaceholderXShape(const Placeho
         }
         else
         {
-            pMasterPage
-                = 
&static_cast<SdPage&>(SdPage::getImplementation(mXDrawPage)->TRG_GetMasterPage());
+            pMasterPage = 
&static_cast<SdPage&>(SdPage::getImplementation(mXDrawPage)->TRG_GetMasterPage());
         }
         if (SdrObject* pMasterFooter = pMasterPage->GetPresObj(ePresObjKind))
             return GetXShapeForSdrObject(pMasterFooter);
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());
diff --git a/xmloff/source/draw/ximpbody.cxx b/xmloff/source/draw/ximpbody.cxx
index 198503eab2cd..764c011eec27 100644
--- a/xmloff/source/draw/ximpbody.cxx
+++ b/xmloff/source/draw/ximpbody.cxx
@@ -161,6 +161,25 @@ SdXMLDrawPageContext::SdXMLDrawPageContext( SdXMLImport& 
rImport,
 
                 if(xMasterPage.is())
                 {
+                    uno::Reference< beans::XPropertySet > 
xPropSet(xMasterPage, uno::UNO_QUERY_THROW);
+                    if (xPropSet.is())
+                    {
+                        OUString aPropName("SlideLayout");
+                        uno::Reference< beans::XPropertySetInfo > 
xInfo(xPropSet->getPropertySetInfo());
+                        if (xInfo.is() && xInfo->hasPropertyByName(aPropName))
+                        {
+                            sal_Int32 nType = -1;
+                            uno::Reference< container::XNameAccess > 
xPageLayouts(GetSdImport().getPageLayouts());
+                            if (xPageLayouts.is())
+                            {
+                                if (xPageLayouts->hasByName(maPageLayoutName))
+                                    xPageLayouts->getByName(maPageLayoutName) 
>>= nType;
+                            }
+                            if (-1 != nType)
+                                xPropSet->setPropertyValue(aPropName, 
uno::Any(static_cast<sal_Int16>(nType)));
+                        }
+                    }
+
                     uno::Reference < container::XNamed > 
xMasterNamed(xMasterPage, uno::UNO_QUERY);
                     if(xMasterNamed.is())
                     {

Reply via email to