include/oox/export/drawingml.hxx         |    1 +
 oox/source/export/drawingml.cxx          |    2 ++
 oox/source/export/shapes.cxx             |    3 +--
 sd/source/filter/eppt/pptx-epptooxml.cxx |    1 +
 4 files changed, 5 insertions(+), 2 deletions(-)

New commits:
commit 269585d6b461b565fe75f77b6dbf219749edc5ab
Author:     Miklos Vajna <vmik...@collabora.com>
AuthorDate: Wed Mar 8 08:04:09 2023 +0100
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Wed Mar 8 08:06:59 2023 +0000

    oox, sd: fix ever-increasing chart IDs when exporting to PPTX
    
    Bring the static counter under the control of
    DrawingML::ResetMlCounters(), so the first chart is always chart1.xml,
    even if the same process already exported a chart previously.
    
    XLSX is a separate codepath, this fix doesn't help with that yet.
    
    Change-Id: Idf6e576ba94e254ae9782ef86e85542efd80127f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148457
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>

diff --git a/include/oox/export/drawingml.hxx b/include/oox/export/drawingml.hxx
index 21914fbf57d1..5dc243e8536c 100644
--- a/include/oox/export/drawingml.hxx
+++ b/include/oox/export/drawingml.hxx
@@ -163,6 +163,7 @@ protected:
     /// If set, this is the parent of the currently handled shape.
     css::uno::Reference<css::drawing::XShape> m_xParent;
     bool                                      mbIsBackgroundDark;
+    static sal_Int32 mnChartCount;
 
     /// True when exporting presentation placeholder shape.
     bool mbPlaceholder;
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 26858cac40cf..5f2e1a7b4558 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -243,6 +243,7 @@ std::stack<sal_Int32> DrawingML::mnWdpImageCounter;
 std::stack<std::map<OUString, OUString>> DrawingML::maWdpCache;
 sal_Int32 DrawingML::mnDrawingMLCount = 0;
 sal_Int32 DrawingML::mnVmlCount = 0;
+sal_Int32 DrawingML::mnChartCount = 0;
 std::stack<std::unordered_map<BitmapChecksum, OUString>> 
DrawingML::maExportGraphics;
 
 sal_Int16 DrawingML::GetScriptType(const OUString& rStr)
@@ -273,6 +274,7 @@ void DrawingML::ResetMlCounters()
 {
     mnDrawingMLCount = 0;
     mnVmlCount = 0;
+    mnChartCount = 0;
 }
 
 void DrawingML::PushExportGraphics()
diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index 676d3f75c201..6993a7c9c304 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -2520,8 +2520,7 @@ ShapeExport& ShapeExport::WriteOLE2Shape( const 
Reference< XShape >& xShape )
         // TODO: With Chart extracted this cannot really happen since
         // no Chart could've been added at all
         ChartExport aChartExport( mnXmlNamespace, GetFS(), xChartDoc, GetFB(), 
GetDocumentType() );
-        static sal_Int32 nChartCount = 0;
-        aChartExport.WriteChartObj( xShape, GetNewShapeID( xShape ), 
++nChartCount );
+        aChartExport.WriteChartObj( xShape, GetNewShapeID( xShape ), 
++mnChartCount );
 #endif
         return *this;
     }
diff --git a/sd/source/filter/eppt/pptx-epptooxml.cxx 
b/sd/source/filter/eppt/pptx-epptooxml.cxx
index 1ae7da9cc786..f857f10bec7f 100644
--- a/sd/source/filter/eppt/pptx-epptooxml.cxx
+++ b/sd/source/filter/eppt/pptx-epptooxml.cxx
@@ -428,6 +428,7 @@ bool PowerPointExport::importDocument() noexcept
 
 bool PowerPointExport::exportDocument()
 {
+    drawingml::DrawingML::ResetMlCounters();
     DrawingML::PushExportGraphics();
     maShapeMap.clear();
 

Reply via email to