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 06d42a9b828ad6aa711dd054490fb53624392bb6 Author: Karthik Godha <[email protected]> AuthorDate: Mon Jan 12 14:22:33 2026 +0530 Commit: Michael Stahl <[email protected]> CommitDate: Thu Jan 15 16:47:07 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/+/197328 Tested-by: Michael Stahl <[email protected]> diff --git a/include/oox/core/xmlfilterbase.hxx b/include/oox/core/xmlfilterbase.hxx index 5fdd7a410d70..6892de77dcc2 100644 --- a/include/oox/core/xmlfilterbase.hxx +++ b/include/oox/core/xmlfilterbase.hxx @@ -263,6 +263,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( utl::MediaDescriptor& rMediaDesc ) const override; @@ -286,6 +291,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 d398f836b95f..a41e11607b80 100644 --- a/include/oox/export/drawingml.hxx +++ b/include/oox/export/drawingml.hxx @@ -295,9 +295,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; @@ -522,12 +518,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 bf37a0f8f857..87d5f707dbdd 100644 --- a/include/oox/export/shapes.hxx +++ b/include/oox/export/shapes.hxx @@ -80,9 +80,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 4f72421f14e1..80dfe19995c7 100644 --- a/oox/source/export/chartexport.cxx +++ b/oox/source/export/chartexport.cxx @@ -1678,7 +1678,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 8130d773aaa3..adfcd8f3711a 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -249,11 +249,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) @@ -299,13 +294,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 2ecd9a3b5fc3..800427baa911 100644 --- a/oox/source/export/shapes.cxx +++ b/oox/source/export/shapes.cxx @@ -329,7 +329,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 ) @@ -2849,7 +2848,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; } @@ -2960,7 +2959,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 ccc6cde8174a..d247e9fe6319 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 c860d6c6d6ae..e31827875722 100644 --- a/sc/source/filter/excel/xestream.cxx +++ b/sc/source/filter/excel/xestream.cxx @@ -1037,7 +1037,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 e07e84c5e39d..8e6fcb633898 100644 --- a/sc/source/filter/xcl97/xcl97rec.cxx +++ b/sc/source/filter/xcl97/xcl97rec.cxx @@ -258,7 +258,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( @@ -345,7 +345,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 9aff2d587ac5..cd1bcd1fdb75 100644 --- a/sd/qa/unit/export-tests-ooxml3.cxx +++ b/sd/qa/unit/export-tests-ooxml3.cxx @@ -1124,6 +1124,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(u"Impress Office Open XML"_ustr); + + 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 552ce3aedf86..b8733f1954bf 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();
