[Libreoffice-commits] core.git: Branch 'distro/collabora/co-2021' - sd/source

Sarper Akdemir (via logerrit) logerrit at kemper.freedesktop.org
Wed Jun 23 09:51:21 UTC 2021


 sd/source/filter/eppt/epptooxml.hxx      |   10 +++
 sd/source/filter/eppt/pptx-epptooxml.cxx |   83 ++++++++++++++++++-------------
 2 files changed, 59 insertions(+), 34 deletions(-)

New commits:
commit 2654253ebc8f19f6107d00342aa1bc065ec9430b
Author:     Sarper Akdemir <sarper.akdemir at collabora.com>
AuthorDate: Wed Jun 9 07:54:04 2021 +0300
Commit:     Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Wed Jun 23 11:50:45 2021 +0200

    tdf#59323: pptx export: add placeholder index to master footer placeholders
    
    OOXML uses placeholder index to determine from which layout placeholder it
    should be inheriting styles, position etc.
    
    Added maPlaceholderShapeToIndexMap that stores corresponding Placeholder index
    for a Placeholder XShape on the master slide.
    
    Right now only used for placeholder types Footer, DateAndTime and SlideNumber.
    
    Change-Id: If788f235d00b6d1cde7194d9e4a0789e019432c3
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117010
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117628
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>

diff --git a/sd/source/filter/eppt/epptooxml.hxx b/sd/source/filter/eppt/epptooxml.hxx
index 56b70a0d9d58..c745c432203b 100644
--- a/sd/source/filter/eppt/epptooxml.hxx
+++ b/sd/source/filter/eppt/epptooxml.hxx
@@ -117,6 +117,12 @@ private:
 
     static void WriteDiagram(const FSHelperPtr& pFS, PowerPointShapeExport& rDML, const css::uno::Reference<css::drawing::XShape>& rXShape, int nDiagramId);
 
+    /** Create a new placeholder index for a master placeholder shape
+
+        @param rXShape Master placeholder shape
+        @returns Placeholder index
+    */
+    unsigned CreateNewPlaceholderIndex(const css::uno::Reference<css::drawing::XShape>& rXShape);
     /// Should we export as .pptm, ie. do we contain macros?
     bool mbPptm;
 
@@ -139,6 +145,10 @@ private:
 
     ::oox::drawingml::ShapeExport::ShapeHashMap maShapeMap;
 
+    unsigned mnPlaceholderIndexMax; ///< Last used placeholder index
+    /// Map of placeholder indexes for Master placeholders
+    std::unordered_map< css::uno::Reference<css::drawing::XShape>, unsigned > maPlaceholderShapeToIndexMap;
+
     struct AuthorComments {
         sal_Int32 nId;
         sal_Int32 nLastIndex;
diff --git a/sd/source/filter/eppt/pptx-epptooxml.cxx b/sd/source/filter/eppt/pptx-epptooxml.cxx
index c734bf10f0f5..b3d68353f8e9 100644
--- a/sd/source/filter/eppt/pptx-epptooxml.cxx
+++ b/sd/source/filter/eppt/pptx-epptooxml.cxx
@@ -125,8 +125,35 @@ void WriteSndAc(const FSHelperPtr& pFS, const OUString& sSoundRelId, const OUStr
         pFS->endElement(FSNS(XML_p, XML_stSnd));
         pFS->endElement(FSNS(XML_p, XML_sndAc));
 }
-}
 
+const char* getPlaceholderTypeName(PlaceholderType ePlaceholder)
+{
+    switch (ePlaceholder)
+    {
+        case SlideImage:
+            return "sldImg";
+        case Notes:
+            return "body";
+        case Header:
+            return "hdr";
+        case Footer:
+            return "ftr";
+        case SlideNumber:
+            return "sldNum";
+        case DateAndTime:
+            return "dt";
+        case Outliner:
+            return "body";
+        case Title:
+            return "title";
+        case Subtitle:
+            return "subTitle";
+        default:
+            SAL_INFO("sd.eppt", "warning: unhandled placeholder type: " << ePlaceholder);
+            return "";
+    }
+}
+}
 }
 
 namespace {
@@ -335,6 +362,7 @@ PowerPointExport::PowerPointExport(const Reference< XComponentContext >& rContex
     , mnAnimationNodeIdMax(1)
     , mnDiagramId(1)
     , mbCreateNotes(false)
+    , mnPlaceholderIndexMax(1)
 {
     comphelper::SequenceAsHashMap aArgumentsMap(rArguments);
     mbPptm = aArgumentsMap.getUnpackedValueOrDefault("IsPPTM", false);
@@ -1461,41 +1489,22 @@ ShapeExport& PowerPointShapeExport::WritePlaceholderShape(const Reference< XShap
     mpFS->endElementNS(XML_p, XML_cNvSpPr);
     mpFS->startElementNS(XML_p, XML_nvPr);
 
-    const char* pType = nullptr;
-    switch (ePlaceholder)
+    bool bUsePlaceholderIndex
+        = ePlaceholder == Footer || ePlaceholder == DateAndTime || ePlaceholder == SlideNumber;
+    const char* pType = getPlaceholderTypeName(ePlaceholder);
+
+    SAL_INFO("sd.eppt", "write placeholder " << pType);
+    if (bUsePlaceholderIndex)
     {
-    case SlideImage:
-        pType = "sldImg";
-        break;
-    case Notes:
-        pType = "body";
-        break;
-    case Header:
-        pType = "hdr";
-        break;
-    case Footer:
-        pType = "ftr";
-        break;
-    case SlideNumber:
-        pType = "sldNum";
-        break;
-    case DateAndTime:
-        pType = "dt";
-        break;
-    case Outliner:
-        pType = "body";
-        break;
-    case Title:
-        pType = "title";
-        break;
-    case Subtitle:
-        pType = "subTitle";
-        break;
-    default:
-        SAL_INFO("sd.eppt", "warning: unhandled placeholder type: " << ePlaceholder);
+        mpFS->singleElementNS(
+            XML_p, XML_ph, XML_type, pType, XML_idx,
+            OString::number(
+                static_cast<PowerPointExport*>(GetFB())->CreateNewPlaceholderIndex(xShape)));
+    }
+    else
+    {
+        mpFS->singleElementNS(XML_p, XML_ph, XML_type, pType);
     }
-    SAL_INFO("sd.eppt", "write placeholder " << pType);
-    mpFS->singleElementNS(XML_p, XML_ph, XML_type, pType);
     mpFS->endElementNS(XML_p, XML_nvPr);
     mpFS->endElementNS(XML_p, XML_nvSpPr);
 
@@ -2023,6 +2032,12 @@ void PowerPointExport::WriteDiagram(const FSHelperPtr& pFS, PowerPointShapeExpor
     pFS->endElementNS(XML_p, XML_graphicFrame);
 }
 
+unsigned PowerPointExport::CreateNewPlaceholderIndex(const css::uno::Reference<XShape> &rXShape)
+{
+    maPlaceholderShapeToIndexMap.insert({rXShape, mnPlaceholderIndexMax});
+    return mnPlaceholderIndexMax++;
+}
+
 // UNO component
 extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
 css_comp_Impress_oox_PowerPointExport(uno::XComponentContext* rxCtxt,


More information about the Libreoffice-commits mailing list