emfio/qa/cppunit/wmf/wmfimporttest.cxx | 32 ++++++++++---------------------- include/test/xmltesttools.hxx | 3 ++- include/vcl/mtfxmldump.hxx | 4 ++-- test/source/xmltesttools.cxx | 7 ++++++- vcl/source/gdi/mtfxmldump.cxx | 4 ++-- 5 files changed, 22 insertions(+), 28 deletions(-)
New commits: commit 44ab8a915c81fa88973c81c782acb51de2662f6a Author: Mike Kaganski <[email protected]> AuthorDate: Thu Dec 11 08:32:37 2025 +0100 Commit: Mike Kaganski <[email protected]> CommitDate: Thu Dec 11 15:56:00 2025 +0100 Simplify XmlTestTools::dumpAndParse for default dumper case ... which is the majority of cases. Make dumper's methods const, where it makes sense. Change-Id: I4368a15d18bd0843a3c7b125b03bbbf623cd10c2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195424 Tested-by: Jenkins Reviewed-by: Mike Kaganski <[email protected]> diff --git a/emfio/qa/cppunit/wmf/wmfimporttest.cxx b/emfio/qa/cppunit/wmf/wmfimporttest.cxx index c7da2ed4ff90..06cfbfd58ff6 100644 --- a/emfio/qa/cppunit/wmf/wmfimporttest.cxx +++ b/emfio/qa/cppunit/wmf/wmfimporttest.cxx @@ -92,8 +92,7 @@ void WmfTest::testEOFWmf() GDIMetaFile aGDIMetaFile; ReadWindowMetafile(aFileStream, aGDIMetaFile); - MetafileXmlDump dumper; - xmlDocUniquePtr pDoc = dumpAndParse(dumper, aGDIMetaFile); + xmlDocUniquePtr pDoc = dumpAndParse(aGDIMetaFile); CPPUNIT_ASSERT(pDoc); assertXPath(pDoc, "/metafile/push", 2); @@ -147,8 +146,7 @@ void WmfTest::testTdf88163NonPlaceableWmf() GDIMetaFile aGDIMetaFile; ReadWindowMetafile(aFileStream, aGDIMetaFile); - MetafileXmlDump dumper; - xmlDocUniquePtr pDoc = dumpAndParse(dumper, aGDIMetaFile); + xmlDocUniquePtr pDoc = dumpAndParse(aGDIMetaFile); CPPUNIT_ASSERT(pDoc); @@ -182,9 +180,7 @@ void WmfTest::testTdf88163PlaceableWmf() GDIMetaFile aGDIMetaFile; ReadWindowMetafile(aFileStream, aGDIMetaFile); - MetafileXmlDump dumper; - - xmlDocUniquePtr pDoc = dumpAndParse(dumper, aGDIMetaFile); + xmlDocUniquePtr pDoc = dumpAndParse(aGDIMetaFile); CPPUNIT_ASSERT(pDoc); @@ -220,9 +216,7 @@ void WmfTest::testSetTextAlignWmf() GDIMetaFile aGDIMetaFile; ReadWindowMetafile(aFileStream, aGDIMetaFile); - MetafileXmlDump dumper; - - xmlDocUniquePtr pDoc = dumpAndParse(dumper, aGDIMetaFile); + xmlDocUniquePtr pDoc = dumpAndParse(aGDIMetaFile); CPPUNIT_ASSERT(pDoc); @@ -461,8 +455,7 @@ void WmfTest::testTdf93750() GDIMetaFile aGDIMetaFile; ReadWindowMetafile(aFileStream, aGDIMetaFile); - MetafileXmlDump dumper; - xmlDocUniquePtr pDoc = dumpAndParse(dumper, aGDIMetaFile); + xmlDocUniquePtr pDoc = dumpAndParse(aGDIMetaFile); CPPUNIT_ASSERT(pDoc); @@ -497,8 +490,7 @@ void WmfTest::testTdf39894Wmf() GDIMetaFile aGDIMetaFile; ReadWindowMetafile(aFileStream, aGDIMetaFile); - MetafileXmlDump dumper; - xmlDocUniquePtr pDoc = dumpAndParse(dumper, aGDIMetaFile); + xmlDocUniquePtr pDoc = dumpAndParse(aGDIMetaFile); CPPUNIT_ASSERT(pDoc); @@ -514,8 +506,7 @@ void WmfTest::testTdf39894Emf() GDIMetaFile aGDIMetaFile; ReadWindowMetafile(aFileStream, aGDIMetaFile); - MetafileXmlDump dumper; - xmlDocUniquePtr pDoc = dumpAndParse(dumper, aGDIMetaFile); + xmlDocUniquePtr pDoc = dumpAndParse(aGDIMetaFile); CPPUNIT_ASSERT(pDoc); @@ -531,8 +522,7 @@ void WmfTest::testETO_PDYWmf() GDIMetaFile aGDIMetaFile; ReadWindowMetafile(aFileStream, aGDIMetaFile); - MetafileXmlDump dumper; - xmlDocUniquePtr pDoc = dumpAndParse(dumper, aGDIMetaFile); + xmlDocUniquePtr pDoc = dumpAndParse(aGDIMetaFile); CPPUNIT_ASSERT(pDoc); @@ -551,8 +541,7 @@ void WmfTest::testETO_PDYEmf() GDIMetaFile aGDIMetaFile; ReadWindowMetafile(aFileStream, aGDIMetaFile); - MetafileXmlDump dumper; - xmlDocUniquePtr pDoc = dumpAndParse(dumper, aGDIMetaFile); + xmlDocUniquePtr pDoc = dumpAndParse(aGDIMetaFile); CPPUNIT_ASSERT(pDoc); @@ -571,8 +560,7 @@ void WmfTest::testStockObject() GDIMetaFile aGDIMetaFile; ReadWindowMetafile(aFileStream, aGDIMetaFile); - MetafileXmlDump dumper; - xmlDocUniquePtr pDoc = dumpAndParse(dumper, aGDIMetaFile); + xmlDocUniquePtr pDoc = dumpAndParse(aGDIMetaFile); CPPUNIT_ASSERT(pDoc); diff --git a/include/test/xmltesttools.hxx b/include/test/xmltesttools.hxx index 94f4cf18a816..e755a088e437 100644 --- a/include/test/xmltesttools.hxx +++ b/include/test/xmltesttools.hxx @@ -30,7 +30,8 @@ public: /// Return xmlDocPtr representation of the XML stream read from pStream. static xmlDocUniquePtr parseXmlStream(SvStream* pStream); - static xmlDocUniquePtr dumpAndParse(MetafileXmlDump& rDumper, const GDIMetaFile& rGDIMetaFile); + static xmlDocUniquePtr dumpAndParse(const MetafileXmlDump& rDumper, const GDIMetaFile& rGDIMetaFile); + static xmlDocUniquePtr dumpAndParse(const GDIMetaFile& rGDIMetaFile); // using default dumper protected: XmlTestTools(); diff --git a/include/vcl/mtfxmldump.hxx b/include/vcl/mtfxmldump.hxx index 6c0723bdcf71..1d3401589232 100644 --- a/include/vcl/mtfxmldump.hxx +++ b/include/vcl/mtfxmldump.hxx @@ -43,7 +43,7 @@ class VCL_DLLPUBLIC MetafileXmlDump final { o3tl::enumarray<MetaActionType, bool> maFilter; - void writeXml(const GDIMetaFile& rMetaFile, tools::XmlWriter& rWriter); + void writeXml(const GDIMetaFile& rMetaFile, tools::XmlWriter& rWriter) const; public: MetafileXmlDump(); @@ -53,7 +53,7 @@ public: /** The actual result that will be used for testing. */ - void dump(const GDIMetaFile& rMetaFile, SvStream& rStream); + void dump(const GDIMetaFile& rMetaFile, SvStream& rStream) const; }; #endif diff --git a/test/source/xmltesttools.cxx b/test/source/xmltesttools.cxx index aac5425cff55..ffc473fb0a40 100644 --- a/test/source/xmltesttools.cxx +++ b/test/source/xmltesttools.cxx @@ -66,7 +66,7 @@ xmlDocUniquePtr XmlTestTools::parseXmlStream(SvStream* pStream) return xmlDocUniquePtr(xmlReadDoc(pCharBuffer, nullptr, nullptr, options)); } -xmlDocUniquePtr XmlTestTools::dumpAndParse(MetafileXmlDump& rDumper, const GDIMetaFile& rGDIMetaFile) +xmlDocUniquePtr XmlTestTools::dumpAndParse(const MetafileXmlDump& rDumper, const GDIMetaFile& rGDIMetaFile) { SvMemoryStream aStream; rDumper.dump(rGDIMetaFile, aStream); @@ -74,6 +74,11 @@ xmlDocUniquePtr XmlTestTools::dumpAndParse(MetafileXmlDump& rDumper, const GDIMe return XmlTestTools::parseXmlStream(&aStream); } +xmlDocUniquePtr XmlTestTools::dumpAndParse(const GDIMetaFile& rGDIMetaFile) +{ + return dumpAndParse(MetafileXmlDump(), rGDIMetaFile); +} + xmlXPathObjectPtr XmlTestTools::getXPathNode(const xmlDocUniquePtr& pXmlDoc, const char* pXPath) { xmlXPathContextPtr pXmlXpathCtx = xmlXPathNewContext(pXmlDoc.get()); diff --git a/vcl/source/gdi/mtfxmldump.cxx b/vcl/source/gdi/mtfxmldump.cxx index 6f8cdc1e7d5c..fb19ae2ab976 100644 --- a/vcl/source/gdi/mtfxmldump.cxx +++ b/vcl/source/gdi/mtfxmldump.cxx @@ -658,7 +658,7 @@ void MetafileXmlDump::filterAllActionTypes() maFilter.fill(true); } -void MetafileXmlDump::dump(const GDIMetaFile& rMetaFile, SvStream& rStream) +void MetafileXmlDump::dump(const GDIMetaFile& rMetaFile, SvStream& rStream) const { tools::XmlWriter aWriter(&rStream); aWriter.startDocument(); @@ -670,7 +670,7 @@ void MetafileXmlDump::dump(const GDIMetaFile& rMetaFile, SvStream& rStream) aWriter.endDocument(); } -void MetafileXmlDump::writeXml(const GDIMetaFile& rMetaFile, tools::XmlWriter& rWriter) +void MetafileXmlDump::writeXml(const GDIMetaFile& rMetaFile, tools::XmlWriter& rWriter) const { const MapMode& aMtfMapMode = rMetaFile.GetPrefMapMode(); rWriter.attribute("mapunit", convertMapUnitToString(aMtfMapMode.GetMapUnit()));
