include/oox/core/xmlfilterbase.hxx | 11 +++++++++++ include/oox/export/drawingml.hxx | 10 ---------- include/oox/export/shapes.hxx | 3 --- oox/source/export/chartexport.cxx | 2 +- oox/source/export/drawingml.cxx | 12 ------------ oox/source/export/shapes.cxx | 5 ++--- sc/source/filter/excel/xeescher.cxx | 6 +++--- sc/source/filter/excel/xestream.cxx | 1 - sc/source/filter/xcl97/xcl97rec.cxx | 4 ++-- sd/qa/unit/data/odp/tdf169952.odp |binary sd/qa/unit/export-tests-ooxml3.cxx | 10 ++++++++++ sd/source/filter/eppt/pptx-epptooxml.cxx | 1 - 12 files changed, 29 insertions(+), 36 deletions(-)
New commits: commit 1c1120076a103f694e8430d4c85a2863e02ce959 Author: Karthik Godha <[email protected]> AuthorDate: Mon Jan 12 14:22:33 2026 +0530 Commit: Michael Stahl <[email protected]> CommitDate: Wed Feb 4 18:44:11 2026 +0100 tdf#169952: Convert static counters to member variables Move static counters of `DrawingML` and `ShapeExport` to `XmlFilterBase` and make them member variables. Change-Id: I5ede57f04324630107ee179e58b9183fc62ee5ff Reviewed-on: https://gerrit.libreoffice.org/c/core/+/197079 Reviewed-by: Michael Stahl <[email protected]> Tested-by: Jenkins CollaboraOffice <[email protected]> (cherry picked from commit 54efa07c05956bdcde0443cb8c130f693dd6d40e) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/198413 Tested-by: Jenkins diff --git a/include/oox/core/xmlfilterbase.hxx b/include/oox/core/xmlfilterbase.hxx index a89a4ad9818d..0a3525ba536e 100644 --- a/include/oox/core/xmlfilterbase.hxx +++ b/include/oox/core/xmlfilterbase.hxx @@ -257,6 +257,11 @@ public: OUString getNamespaceURL(sal_Int32 nNSID) const; + sal_Int32 getNewDrawingUniqueId() { return ++mnDrawingMLCount; } + sal_Int32 getNewVMLUniqueId() { return ++mnVmlCount; } + sal_Int32 getNewChartUniqueId() { return ++mnChartCount; } + sal_Int32 getNewOLEUniqueId() { return ++mnOLECount; } + protected: virtual css::uno::Reference< css::io::XInputStream > implGetInputStream( comphelper::SequenceAsHashMap& rMediaDesc ) const override; @@ -280,6 +285,12 @@ private: sal_Int32 mnMaxDocId; bool mbMSO2007; bool mbMSO; + + sal_Int32 mnDrawingMLCount = 0; + sal_Int32 mnVmlCount = 0; + sal_Int32 mnChartCount = 0; + sal_Int32 mnOLECount = 0; + protected: bool mbMissingExtDrawing; }; diff --git a/include/oox/export/drawingml.hxx b/include/oox/export/drawingml.hxx index 75a14e6fe8cd..e0c2d47dc920 100644 --- a/include/oox/export/drawingml.hxx +++ b/include/oox/export/drawingml.hxx @@ -293,9 +293,6 @@ class DrawingML { private: - OOX_DLLPUBLIC static sal_Int32 mnDrawingMLCount; - OOX_DLLPUBLIC static sal_Int32 mnVmlCount; - /// To specify where write eg. the images to (like 'ppt', or 'word' - according to the OPC). DocumentType meDocumentType; /// Parent exporter, used for text callback. @@ -311,7 +308,6 @@ protected: /// If set, this is the parent of the currently handled shape. css::uno::Reference<css::drawing::XShape> m_xParent; bool mbIsBackgroundDark; - OOX_DLLPUBLIC static sal_Int32 mnChartCount; /// True when exporting presentation placeholder shape. bool mbPlaceholder; @@ -539,12 +535,6 @@ public: static bool IsGroupShape( const css::uno::Reference< css::drawing::XShape >& rXShape ); sal_Int32 getBulletMarginIndentation (const css::uno::Reference< css::beans::XPropertySet >& rXPropSet,sal_Int16 nLevel, std::u16string_view propName); - OOX_DLLPUBLIC static void ResetMlCounters(); - - static sal_Int32 getNewDrawingUniqueId() { return ++mnDrawingMLCount; } - static sal_Int32 getNewVMLUniqueId() { return ++mnVmlCount; } - static sal_Int32 getNewChartUniqueId() { return ++mnChartCount; } - // A Helper to decide the script type for given text in order to call WriteRunProperties. static sal_Int16 GetScriptType(const OUString& rStr); diff --git a/include/oox/export/shapes.hxx b/include/oox/export/shapes.hxx index 8956d587749f..a75334c4f94f 100644 --- a/include/oox/export/shapes.hxx +++ b/include/oox/export/shapes.hxx @@ -76,9 +76,6 @@ namespace oox::drawingml { class OOX_DLLPUBLIC ShapeExport : public DrawingML { -private: - int m_nEmbeddedObjects; - public: typedef std::unordered_map< css::uno::Reference< css::drawing::XShape>, sal_Int32> ShapeHashMap; diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx index bda05a4b68c9..7fb109ccdd7a 100644 --- a/oox/source/export/chartexport.cxx +++ b/oox/source/export/chartexport.cxx @@ -1882,7 +1882,7 @@ void ChartExport::exportAdditionalShapes( const Reference< css::chart::XChartDoc OUString sId; const char* sFullPath = nullptr; const char* sRelativePath = nullptr; - sal_Int32 nDrawing = getNewDrawingUniqueId(); + sal_Int32 nDrawing = GetFB()->getNewDrawingUniqueId(); switch (GetDocumentType()) { diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index ffa00ec9fef7..7a9205fe41d7 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -253,11 +253,6 @@ void WriteGradientPath(const basegfx::BGradient& rBGradient, const FSHelperPtr& } } -// not thread safe -sal_Int32 DrawingML::mnDrawingMLCount = 0; -sal_Int32 DrawingML::mnVmlCount = 0; -sal_Int32 DrawingML::mnChartCount = 0; - DrawingML::DrawingML(::sax_fastparser::FSHelperPtr pFS, ::oox::core::XmlFilterBase* pFB, DocumentType eDocumentType, DMLTextExport* pTextExport) : meDocumentType(eDocumentType) , mpTextExport(pTextExport) @@ -304,13 +299,6 @@ sal_Int16 DrawingML::GetScriptType(const OUString& rStr) return css::i18n::ScriptType::LATIN; } -void DrawingML::ResetMlCounters() -{ - mnDrawingMLCount = 0; - mnVmlCount = 0; - mnChartCount = 0; -} - bool DrawingML::GetProperty( const Reference< XPropertySet >& rXPropertySet, const OUString& aName ) { try diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx index 27947ec75e61..9a56b6001a3f 100644 --- a/oox/source/export/shapes.cxx +++ b/oox/source/export/shapes.cxx @@ -326,7 +326,6 @@ namespace oox::drawingml { ShapeExport::ShapeExport( sal_Int32 nXmlNamespace, FSHelperPtr pFS, ShapeHashMap* pShapeMap, XmlFilterBase* pFB, DocumentType eDocumentType, DMLTextExport* pTextExport, bool bUserShapes ) : DrawingML( std::move(pFS), pFB, eDocumentType, pTextExport ) - , m_nEmbeddedObjects(0) , mnShapeIdMax( 1 ) , mbUserShapes( bUserShapes ) , mnXmlNamespace( nXmlNamespace ) @@ -2893,7 +2892,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() ); - aChartExport.WriteChartObj( xShape, GetNewShapeID( xShape ), ++mnChartCount ); + aChartExport.WriteChartObj(xShape, GetNewShapeID(xShape), mpFB->getNewChartUniqueId()); #endif return *this; } @@ -3011,7 +3010,7 @@ ShapeExport& ShapeExport::WriteOLE2Shape( const Reference< XShape >& xShape ) assert(!sRelationType.isEmpty()); assert(!sSuffix.isEmpty()); - OUString sNumber = OUString::number(++m_nEmbeddedObjects); + OUString sNumber = OUString::number(mpFB->getNewOLEUniqueId()); OUString sFileName = u"embeddings/oleObject"_ustr + sNumber + u"."_ustr + sSuffix; OUString sFilePath = GetComponentDir() + u"/"_ustr + sFileName; uno::Reference<io::XOutputStream> const xOutStream(mpFB->openFragmentStream(sFilePath, sMediaType)); diff --git a/sc/source/filter/excel/xeescher.cxx b/sc/source/filter/excel/xeescher.cxx index 5daf880b1a5a..b2ce7ac4f7e7 100644 --- a/sc/source/filter/excel/xeescher.cxx +++ b/sc/source/filter/excel/xeescher.cxx @@ -1413,7 +1413,7 @@ OUString XclExpTbxControlObj::SaveControlPropertiesXml(XclExpXmlStream& rStrm) c { case EXC_OBJTYPE_CHECKBOX: { - const sal_Int32 nDrawing = DrawingML::getNewDrawingUniqueId(); + const sal_Int32 nDrawing = rStrm.getNewDrawingUniqueId(); sax_fastparser::FSHelperPtr pFormControl = rStrm.CreateOutputStream( XclXmlUtils::GetStreamName( "xl/", "ctrlProps/ctrlProps", nDrawing ), XclXmlUtils::GetStreamName( "../", "ctrlProps/ctrlProps", nDrawing ), @@ -1463,7 +1463,7 @@ OUString XclExpTbxControlObj::SaveControlPropertiesXml(XclExpXmlStream& rStrm) c } case EXC_OBJTYPE_BUTTON: { - sal_Int32 nDrawing = DrawingML::getNewDrawingUniqueId(); + sal_Int32 nDrawing = rStrm.getNewDrawingUniqueId(); sax_fastparser::FSHelperPtr pFormControl = rStrm.CreateOutputStream( XclXmlUtils::GetStreamName("xl/", "ctrlProps/ctrlProps", nDrawing), XclXmlUtils::GetStreamName("../", "ctrlProps/ctrlProps", nDrawing), @@ -1641,7 +1641,7 @@ void XclExpChartObj::SaveXml( XclExpXmlStream& rStrm ) ChartExport aChartExport(XML_xdr, pDrawing, GetChartDoc(), &rStrm, drawingml::DOCUMENT_XLSX); auto pURLTransformer = std::make_shared<ScURLTransformer>(*mpDoc); aChartExport.SetURLTranslator(pURLTransformer); - sal_Int32 nChartCount = oox::drawingml::DrawingML::getNewChartUniqueId(); + sal_Int32 nChartCount = rStrm.getNewChartUniqueId(); sal_Int32 nID = rStrm.GetUniqueId(); aChartExport.WriteChartObj( mxShape, nID, nChartCount ); // TODO: get the correcto chart number diff --git a/sc/source/filter/excel/xestream.cxx b/sc/source/filter/excel/xestream.cxx index 1b8e32ee50d1..2121a29132ed 100644 --- a/sc/source/filter/excel/xestream.cxx +++ b/sc/source/filter/excel/xestream.cxx @@ -1054,7 +1054,6 @@ bool XclExpXmlStream::exportDocument() // SfxMedium::GetOutStream() anywhere in the xlsx export filter code! // Instead, write via XOutputStream instance. rtl::Reference<SotStorage> rStorage; - drawingml::DrawingML::ResetMlCounters(); auto& rGraphicExportCache = drawingml::GraphicExportCache::get(); diff --git a/sc/source/filter/xcl97/xcl97rec.cxx b/sc/source/filter/xcl97/xcl97rec.cxx index f5d980b6470b..8d78df5fe0e8 100644 --- a/sc/source/filter/xcl97/xcl97rec.cxx +++ b/sc/source/filter/xcl97/xcl97rec.cxx @@ -261,7 +261,7 @@ void SaveDrawingMLObjects( XclExpObjList& rList, XclExpXmlStream& rStrm ) if (aList.empty()) return; - sal_Int32 nDrawing = drawingml::DrawingML::getNewDrawingUniqueId(); + sal_Int32 nDrawing = rStrm.getNewDrawingUniqueId(); OUString sId; // export in [Content_Types].xml sax_fastparser::FSHelperPtr pDrawing = rStrm.CreateOutputStream( @@ -348,7 +348,7 @@ void SaveVmlObjects( XclExpObjList& rList, XclExpXmlStream& rStrm ) if( GetVmlObjectCount( rList ) == 0 ) return; - sal_Int32 nDrawing = drawingml::DrawingML::getNewVMLUniqueId(); + sal_Int32 nDrawing = rStrm.getNewVMLUniqueId(); OUString sId; sax_fastparser::FSHelperPtr pVmlDrawing = rStrm.CreateOutputStream( XclXmlUtils::GetStreamName( "xl/", "drawings/vmlDrawing", nDrawing ), diff --git a/sd/qa/unit/data/odp/tdf169952.odp b/sd/qa/unit/data/odp/tdf169952.odp new file mode 100644 index 000000000000..0888486ab21c Binary files /dev/null and b/sd/qa/unit/data/odp/tdf169952.odp differ diff --git a/sd/qa/unit/export-tests-ooxml3.cxx b/sd/qa/unit/export-tests-ooxml3.cxx index b7188bfaf8ca..90c56b98a4a0 100644 --- a/sd/qa/unit/export-tests-ooxml3.cxx +++ b/sd/qa/unit/export-tests-ooxml3.cxx @@ -1173,6 +1173,16 @@ CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest3, testTdf169524) pXmlDoc, "/p:sldMaster/p:cSld/p:spTree/p:sp[2]/p:txBody/a:lstStyle/a:lvl1pPr", "marL"); } +CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest3, testTdf169952) +{ + createSdImpressDoc("odp/tdf169952.odp"); + save(TestFilter::PPTX); + + xmlDocUniquePtr pXmlDoc = parseExport(u"ppt/charts/chart2.xml"_ustr); + + CPPUNIT_ASSERT_MESSAGE("Without the fix chart2.xml is not exported", pXmlDoc); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/filter/eppt/pptx-epptooxml.cxx b/sd/source/filter/eppt/pptx-epptooxml.cxx index 65d6d24fabd7..286c2c6e67b9 100644 --- a/sd/source/filter/eppt/pptx-epptooxml.cxx +++ b/sd/source/filter/eppt/pptx-epptooxml.cxx @@ -443,7 +443,6 @@ bool PowerPointExport::importDocument() noexcept bool PowerPointExport::exportDocument() { - drawingml::DrawingML::ResetMlCounters(); auto& rGraphicExportCache = drawingml::GraphicExportCache::get(); rGraphicExportCache.push();
