diff options
author | Balazs Varga <balazs.varga.extern@allotropia.de> | 2023-12-03 23:41:01 +0100 |
---|---|---|
committer | Balazs Varga <balazs.varga.extern@allotropia.de> | 2023-12-18 15:10:54 +0100 |
commit | bff76421e234df7246a7f49c71a11432f86e09d1 (patch) | |
tree | 3eae1dc2ea775e03759c2e54a6d0784559c6147f | |
parent | 5aba83e7c1bc177270b585253ef27e6995f41f23 (diff) |
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 <hcastro@collabora.com>
Reviewed-by: Balazs Varga <balazs.varga.extern@allotropia.de>
-rw-r--r-- | oox/source/ppt/slidepersist.cxx | 6 | ||||
-rw-r--r-- | sd/qa/unit/data/pptx/tdf157740.pptx | bin | 0 -> 16941 bytes | |||
-rw-r--r-- | sd/qa/unit/export-tests-ooxml1.cxx | 4 | ||||
-rw-r--r-- | sd/qa/unit/export-tests-ooxml2.cxx | 4 | ||||
-rw-r--r-- | sd/qa/unit/export-tests-ooxml4.cxx | 16 | ||||
-rw-r--r-- | sd/source/core/drawdoc3.cxx | 38 | ||||
-rw-r--r-- | sd/source/filter/eppt/epptbase.hxx | 2 | ||||
-rw-r--r-- | sd/source/filter/eppt/epptooxml.hxx | 6 | ||||
-rw-r--r-- | sd/source/filter/eppt/pptx-epptooxml.cxx | 284 | ||||
-rw-r--r-- | xmloff/source/draw/ximpbody.cxx | 19 |
10 files changed, 142 insertions, 237 deletions
diff --git a/oox/source/ppt/slidepersist.cxx b/oox/source/ppt/slidepersist.cxx index cd42ef6bcdb6..a4225f95cd43 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 Binary files differnew file mode 100644 index 000000000000..009e9eeb1da0 --- /dev/null +++ b/sd/qa/unit/data/pptx/tdf157740.pptx diff --git a/sd/qa/unit/export-tests-ooxml1.cxx b/sd/qa/unit/export-tests-ooxml1.cxx index deab0ea2de24..9f87fd5d92c4 100644 --- a/sd/qa/unit/export-tests-ooxml1.cxx +++ b/sd/qa/unit/export-tests-ooxml1.cxx @@ -111,11 +111,11 @@ CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest1, testTdf149128) xmlDocUniquePtr pXmlDoc = parseExport("ppt/slides/slide1.xml"); assertXPath(pXmlDoc, "/p:sld/p:cSld/p:spTree/p:cxnSp/p:nvCxnSpPr/p:cNvCxnSpPr/a:stCxn"_ostr, - "id"_ostr, "42"); + "id"_ostr, "8"); assertXPath(pXmlDoc, "/p:sld/p:cSld/p:spTree/p:cxnSp/p:nvCxnSpPr/p:cNvCxnSpPr/a:stCxn"_ostr, "idx"_ostr, "0"); assertXPath(pXmlDoc, "/p:sld/p:cSld/p:spTree/p:cxnSp/p:nvCxnSpPr/p:cNvCxnSpPr/a:endCxn"_ostr, - "id"_ostr, "43"); + "id"_ostr, "9"); assertXPath(pXmlDoc, "/p:sld/p:cSld/p:spTree/p:cxnSp/p:nvCxnSpPr/p:cNvCxnSpPr/a:endCxn"_ostr, "idx"_ostr, "2"); } diff --git a/sd/qa/unit/export-tests-ooxml2.cxx b/sd/qa/unit/export-tests-ooxml2.cxx index 0583233c9f06..4498f66bf03a 100644 --- a/sd/qa/unit/export-tests-ooxml2.cxx +++ b/sd/qa/unit/export-tests-ooxml2.cxx @@ -1343,7 +1343,7 @@ CPPUNIT_TEST_FIXTURE(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"_ostr, - "spid"_ostr, "42"); + "spid"_ostr, "67"); } CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest2, testTdf112280) @@ -1740,7 +1740,7 @@ CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest2, testAccentColor) xmlDocUniquePtr pXmlDocTheme1 = parseExport("ppt/theme/theme1.xml"); assertXPath(pXmlDocTheme1, "/a:theme/a:themeElements/a:clrScheme/a:accent6/a:srgbClr"_ostr, "val"_ostr, "70ad47"); - xmlDocUniquePtr pXmlDocTheme2 = parseExport("ppt/theme/theme2.xml"); + xmlDocUniquePtr pXmlDocTheme2 = parseExport("ppt/theme/theme12.xml"); assertXPath(pXmlDocTheme2, "/a:theme/a:themeElements/a:clrScheme/a:accent6/a:srgbClr"_ostr, "val"_ostr, "deb340"); diff --git a/sd/qa/unit/export-tests-ooxml4.cxx b/sd/qa/unit/export-tests-ooxml4.cxx index 4a60941fa49f..b09614454df9 100644 --- a/sd/qa/unit/export-tests-ooxml4.cxx +++ b/sd/qa/unit/export-tests-ooxml4.cxx @@ -1083,6 +1083,22 @@ CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest4, testTableCellVerticalPropertyRoundtrip) assertXPath(pXml, "(//a:tcPr)[3]"_ostr, "vert"_ostr, "wordArtVert"); } +CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest4, testTdf157740_slideMasters) +{ + createSdImpressDoc("pptx/tdf157740.pptx"); + saveAndReload("Impress Office Open XML"); + + // Test how many slidemaster we have + xmlDocUniquePtr pXmlDocContent = parseExport("ppt/presentation.xml"); + assertXPath(pXmlDocContent, "/p:presentation/p:sldMasterIdLst/p:sldMasterId"_ostr, 7); + + pXmlDocContent = parseExport("ppt/slideMasters/slideMaster1.xml"); + assertXPath(pXmlDocContent, "/p:sldMaster/p:sldLayoutIdLst/p:sldLayoutId"_ostr, 1); + + pXmlDocContent = parseExport("ppt/slideMasters/slideMaster7.xml"); + assertXPath(pXmlDocContent, "/p:sldMaster/p:sldLayoutIdLst/p:sldLayoutId"_ostr, 1); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/core/drawdoc3.cxx b/sd/source/core/drawdoc3.cxx index b3c6e0595c8a..5062630edb88 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()) { @@ -899,6 +908,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 6d804c80cf1f..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 ); @@ -131,8 +131,6 @@ 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; @@ -142,14 +140,12 @@ 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 d9ae8b1a64c2..41ef744c1799 100644 --- a/sd/source/filter/eppt/pptx-epptooxml.cxx +++ b/sd/source/filter/eppt/pptx-epptooxml.cxx @@ -25,8 +25,6 @@ #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> @@ -42,8 +40,6 @@ #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> @@ -191,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; @@ -217,72 +196,46 @@ struct PPTXLayoutInfo } -const PPTXLayoutInfo aLayoutInfo[LAYOUT_SIZE] = -{ - { 20, "Blank Slide", "blank" }, - { 0, "Title Slide", "tx" }, - { 1, "Title, Content", "obj" }, - { 3, "Title, 2 Content", "twoObj" }, +const PPTXLayoutInfo aLayoutInfo[EPP_LAYOUT_SIZE] = +{ + { 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) @@ -392,7 +345,6 @@ PowerPointExport::PowerPointExport(const Reference< XComponentContext >& rContex , mnSlideIdMax(1 << 8) , mnSlideMasterIdMax(1U << 31) , mnAnimationNodeIdMax(1) - , mnThemeIdMax(0) , mnDiagramId(1) , mbCreateNotes(false) , mnPlaceholderIndexMax(1) @@ -1428,7 +1380,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)) @@ -1496,111 +1448,8 @@ 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 = 0; - 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 @@ -1623,7 +1472,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) { @@ -1631,12 +1480,12 @@ void PowerPointExport::ImplWriteSlideMaster(sal_uInt32 nPageNum, Reference< XPro } // write theme per master - WriteTheme(mnThemeIdMax, pTheme); + WriteTheme(nPageNum, pTheme); // add implicit relation to the presentation theme addRelation(pFS->getOutputStream(), oox::getRelationship(Relationship::THEME), - Concat2View("../theme/theme" + OUString::number(++mnThemeIdMax) + ".xml")); + Concat2View("../theme/theme" + OUString::number(nPageNum + 1) + ".xml")); pFS->startElementNS(XML_p, XML_sldMaster, PNMSS); @@ -1666,26 +1515,23 @@ 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; } - if (aLayout.hasValue()) - { - aLayout >>= nLayout; - mpSlidesMaster.push_back(std::make_pair(pMasterPage, - GetLayoutFileId(GetPPTXLayoutId(nLayout), nPageNum))); - } + 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); @@ -1705,7 +1551,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); @@ -1749,8 +1595,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); @@ -2397,11 +2251,9 @@ Reference<XShape> PowerPointExport::GetReferencedPlaceholderXShape(const Placeho } else { - SdrPage* pPage = &SdPage::getImplementation(mXDrawPage)->TRG_GetMasterPage(); - long nFound = FindEquivalentMasterPage(pPage); - pMasterPage = dynamic_cast<SdPage*>(nFound != -1 ? mpSlidesMaster[nFound].first : pPage); + pMasterPage = &static_cast<SdPage&>(SdPage::getImplementation(mXDrawPage)->TRG_GetMasterPage()); } - if (SdrObject* pMasterFooter = (pMasterPage ? pMasterPage->GetPresObj(ePresObjKind) : nullptr)) + if (SdrObject* pMasterFooter = pMasterPage->GetPresObj(ePresObjKind)) return GetXShapeForSdrObject(pMasterFooter); } return nullptr; 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()) { |