[Libreoffice-commits] core.git: chart2/qa drawinglayer/source emfio/qa filter/qa include/drawinglayer include/test sc/qa sd/qa sfx2/qa starmath/qa svgio/qa svx/qa sw/qa test/qa test/source vcl/qa writerperfect/qa xmlsecurity/qa

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Thu May 7 07:53:03 UTC 2020


 chart2/qa/extras/chart2export.cxx                  |  228 ++++++++++-----------
 chart2/qa/extras/xshape/chart2xshape.cxx           |   10 
 drawinglayer/source/tools/primitive2dxmldump.cxx   |    5 
 emfio/qa/cppunit/emf/EmfImportTest.cxx             |   10 
 emfio/qa/cppunit/wmf/wmfimporttest.cxx             |   16 -
 filter/qa/cppunit/filters-pict-test.cxx            |    2 
 filter/qa/unit/svg.cxx                             |    4 
 include/drawinglayer/tools/primitive2dxmldump.hxx  |    3 
 include/test/htmltesttools.hxx                     |    7 
 include/test/xmldocptr.hxx                         |   19 +
 include/test/xmltesttools.hxx                      |   31 +-
 sc/qa/extras/htmlexporttest.cxx                    |    2 
 sc/qa/unit/helper/xpath.cxx                        |    4 
 sc/qa/unit/helper/xpath.hxx                        |    5 
 sc/qa/unit/pivottable_filters_test.cxx             |   40 +--
 sc/qa/unit/subsequent_export-test.cxx              |  162 +++++++-------
 sd/qa/unit/HtmlExportTest.cxx                      |    4 
 sd/qa/unit/SVGExportTests.cxx                      |    4 
 sd/qa/unit/export-tests-ooxml1.cxx                 |   16 -
 sd/qa/unit/export-tests-ooxml2.cxx                 |  170 +++++++--------
 sd/qa/unit/export-tests.cxx                        |   20 -
 sd/qa/unit/misc-tests.cxx                          |   20 -
 sd/qa/unit/sdmodeltestbase.hxx                     |    4 
 sd/qa/unit/tiledrendering/tiledrendering.cxx       |   18 -
 sfx2/qa/cppunit/test_misc.cxx                      |    2 
 starmath/qa/extras/mmlexport-test.cxx              |   12 -
 svgio/qa/cppunit/SvgImportTest.cxx                 |   58 ++---
 svx/qa/unit/svdraw.cxx                             |    2 
 sw/qa/core/frmedt/frmedt.cxx                       |    2 
 sw/qa/core/layout/layout.cxx                       |    6 
 sw/qa/core/objectpositioning/objectpositioning.cxx |    2 
 sw/qa/core/text/text.cxx                           |    2 
 sw/qa/core/txtnode/txtnode.cxx                     |    2 
 sw/qa/extras/docbookexport/docbookexport.cxx       |    4 
 sw/qa/extras/fodfexport/fodfexport.cxx             |    4 
 sw/qa/extras/htmlexport/htmlexport.cxx             |   56 ++---
 sw/qa/extras/htmlexport/xhtmlexport.cxx            |    2 
 sw/qa/extras/layout/layout.cxx                     |  172 +++++++--------
 sw/qa/extras/mailmerge/mailmerge.cxx               |    4 
 sw/qa/extras/odfexport/odfexport.cxx               |   32 +-
 sw/qa/extras/ooxmlexport/ooxmlexport.cxx           |   64 ++---
 sw/qa/extras/ooxmlexport/ooxmlexport10.cxx         |   16 -
 sw/qa/extras/ooxmlexport/ooxmlexport11.cxx         |   68 +++---
 sw/qa/extras/ooxmlexport/ooxmlexport12.cxx         |   12 -
 sw/qa/extras/ooxmlexport/ooxmlexport13.cxx         |   54 ++--
 sw/qa/extras/ooxmlexport/ooxmlexport14.cxx         |   54 ++--
 sw/qa/extras/ooxmlexport/ooxmlexport2.cxx          |   20 -
 sw/qa/extras/ooxmlexport/ooxmlexport3.cxx          |   78 +++----
 sw/qa/extras/ooxmlexport/ooxmlexport4.cxx          |  144 ++++++-------
 sw/qa/extras/ooxmlexport/ooxmlexport5.cxx          |  192 ++++++++---------
 sw/qa/extras/ooxmlexport/ooxmlexport6.cxx          |   68 +++---
 sw/qa/extras/ooxmlexport/ooxmlexport7.cxx          |   94 ++++----
 sw/qa/extras/ooxmlexport/ooxmlexport9.cxx          |   42 +--
 sw/qa/extras/ooxmlexport/ooxmlexport_template.cxx  |    2 
 sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx      |  110 +++++-----
 sw/qa/extras/ooxmlexport/ooxmllinks.cxx            |   16 -
 sw/qa/extras/ooxmlexport/ooxmlw14export.cxx        |   22 +-
 sw/qa/extras/ooxmlimport/ooxmlimport.cxx           |    4 
 sw/qa/extras/uiwriter/uiwriter.cxx                 |   74 +++---
 sw/qa/extras/uiwriter/uiwriter2.cxx                |    8 
 sw/qa/extras/ww8export/ww8export2.cxx              |    4 
 sw/qa/inc/swmodeltestbase.hxx                      |   17 -
 test/qa/cppunit/test_xpath.cxx                     |    2 
 test/source/htmltesttools.cxx                      |    8 
 test/source/xmltesttools.cxx                       |   34 +--
 vcl/qa/cppunit/svm/svmtest.cxx                     |   82 +++----
 writerperfect/qa/unit/EPUBExportTest.cxx           |   17 -
 xmlsecurity/qa/unit/signing/signing.cxx            |    4 
 68 files changed, 1242 insertions(+), 1234 deletions(-)

New commits:
commit ec6eaa58addf0d8823f8c56d4ec168ff389da8c5
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Tue May 5 19:10:16 2020 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Thu May 7 09:52:27 2020 +0200

    fix memory leak of xmlDoc objects
    
    in unit tests
    
    Change-Id: Id16731bbbe2f1b0e3642722d77aba04fc98db4cc
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93508
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/chart2/qa/extras/chart2export.cxx b/chart2/qa/extras/chart2export.cxx
index 91fad970586e..571a0da80132 100644
--- a/chart2/qa/extras/chart2export.cxx
+++ b/chart2/qa/extras/chart2export.cxx
@@ -305,7 +305,7 @@ protected:
      * xml stream, and asserting an XPath expression. This method returns the
      * xml stream, so that you can do the asserting.
      */
-    xmlDocPtr parseExport(const OUString& rDir, const OUString& rFilterFormat);
+    xmlDocUniquePtr parseExport(const OUString& rDir, const OUString& rFilterFormat);
 
 };
 
@@ -343,7 +343,7 @@ OUString findChartFile(const OUString& rDir, uno::Reference< container::XNameAcc
 
 }
 
-xmlDocPtr Chart2ExportTest::parseExport(const OUString& rDir, const OUString& rFilterFormat)
+xmlDocUniquePtr Chart2ExportTest::parseExport(const OUString& rDir, const OUString& rFilterFormat)
 {
     std::shared_ptr<utl::TempFile> pTempFile = save(rFilterFormat);
 
@@ -578,7 +578,7 @@ void Chart2ExportTest::testErrorBarXLSX()
 void Chart2ExportTest::testErrorBarPropXLSX()
 {
     load("/chart2/qa/extras/data/xlsx/", "testErrorBarProp.xlsx");
-    xmlDocPtr pXmlDoc = parseExport("xl/charts/chart","Calc Office Open XML");
+    xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart","Calc Office Open XML");
     CPPUNIT_ASSERT(pXmlDoc);
 
     // test y error bars property
@@ -631,7 +631,7 @@ void Chart2ExportTest::testStockChart()
      */
     load("/chart2/qa/extras/data/docx/", "testStockChart.docx");
 
-    xmlDocPtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
+    xmlDocUniquePtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
     if (!pXmlDoc)
        return;
 
@@ -646,7 +646,7 @@ void Chart2ExportTest::testStockChart()
 void Chart2ExportTest::testBarChart()
 {
     load("/chart2/qa/extras/data/docx/", "testBarChart.docx");
-    xmlDocPtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
+    xmlDocUniquePtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
     if (!pXmlDoc)
        return;
 
@@ -656,7 +656,7 @@ void Chart2ExportTest::testBarChart()
 void Chart2ExportTest::testCrosses()
 {
     load("/chart2/qa/extras/data/docx/", "Bar_horizontal_cone.docx");
-    xmlDocPtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
+    xmlDocUniquePtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
 
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:catAx/c:crosses", "val", "autoZero");
 }
@@ -703,7 +703,7 @@ void Chart2ExportTest::testScatterChartTextXValues()
     CPPUNIT_ASSERT_EQUAL(5.0, aYValues[2][3]);
 
     // Test the export.
-    xmlDocPtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
+    xmlDocUniquePtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
     if (!pXmlDoc)
        return;
 
@@ -714,7 +714,7 @@ void Chart2ExportTest::testScatterXAxisValues()
 {
     load("/chart2/qa/extras/data/odt/", "tdf114657.odt");
 
-    xmlDocPtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
+    xmlDocUniquePtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
     CPPUNIT_ASSERT(pXmlDoc);
 
     assertXPath(pXmlDoc, "//c:scatterChart/c:ser/c:xVal/c:numRef/c:numCache/c:ptCount", "val", "5");
@@ -728,7 +728,7 @@ void Chart2ExportTest::testScatterXAxisCategories()
 {
     load("/chart2/qa/extras/data/odt/", "tdf131143.odt");
 
-    xmlDocPtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
+    xmlDocUniquePtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
     CPPUNIT_ASSERT(pXmlDoc);
     assertXPath(pXmlDoc, "//c:scatterChart/c:ser[1]/c:xVal/c:strRef/c:strCache/c:ptCount", "val", "4");
     assertXPathContent(pXmlDoc, "//c:scatterChart/c:ser[1]/c:xVal/c:strRef/c:strCache/c:pt[1]/c:v", "Row 1");
@@ -739,7 +739,7 @@ void Chart2ExportTest::testChartDataTable()
 {
     load("/chart2/qa/extras/data/docx/", "testChartDataTable.docx");
 
-    xmlDocPtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
+    xmlDocUniquePtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
     CPPUNIT_ASSERT(pXmlDoc);
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:dTable/c:showHorzBorder", "val", "1");
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:dTable/c:showVertBorder", "val", "1");
@@ -750,7 +750,7 @@ void Chart2ExportTest::testChartExternalData()
 {
     load("/chart2/qa/extras/data/docx/", "testMultipleChart.docx");
 
-    xmlDocPtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
+    xmlDocUniquePtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
     CPPUNIT_ASSERT(pXmlDoc);
     xmlXPathObjectPtr pXmlPathObj = getXPathNode(pXmlDoc, "/c:chartSpace/c:externalData");
     xmlNodeSetPtr pXmlNodes = pXmlPathObj->nodesetval;
@@ -799,7 +799,7 @@ void Chart2ExportTest::testEmbeddingsGrabBag()
 void Chart2ExportTest::testAreaChartLoad()
 {
     load ("/chart2/qa/extras/data/docx/", "testAreaChartLoad.docx");
-    xmlDocPtr pXmlDoc = parseExport("word/charts/chart","Office Open XML Text");
+    xmlDocUniquePtr pXmlDoc = parseExport("word/charts/chart","Office Open XML Text");
     CPPUNIT_ASSERT(pXmlDoc);
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:areaChart/c:ser/c:dLbls/c:showVal", "val", "1");
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:areaChart/c:ser/c:dLbls/c:dLbl", 0);
@@ -809,7 +809,7 @@ void Chart2ExportTest::testUpDownBars()
 {
     /*
     load("/chart2/qa/extras/data/docx/", "UpDownBars.docx");
-    xmlDocPtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
+    xmlDocUniquePtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
     CPPUNIT_ASSERT(pXmlDoc);
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:upDownBars");
     */
@@ -818,7 +818,7 @@ void Chart2ExportTest::testUpDownBars()
 void Chart2ExportTest::testDoughnutChart()
 {
     load("/chart2/qa/extras/data/docx/", "doughnutChart.docx");
-    xmlDocPtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
+    xmlDocUniquePtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
     CPPUNIT_ASSERT(pXmlDoc);
 
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:doughnutChart");
@@ -827,7 +827,7 @@ void Chart2ExportTest::testDoughnutChart()
 void Chart2ExportTest::testDisplayUnits()
 {
     load("/chart2/qa/extras/data/docx/", "DisplayUnits.docx");
-    xmlDocPtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
+    xmlDocUniquePtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
     CPPUNIT_ASSERT(pXmlDoc);
 
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:valAx/c:dispUnits/c:builtInUnit", "val", "billions");
@@ -836,7 +836,7 @@ void Chart2ExportTest::testDisplayUnits()
 // void Chart2ExportTest::testFdo74115WallGradientFill()
 // {
 //     load("/chart2/qa/extras/data/docx/", "fdo74115_WallGradientFill.docx");
-//     xmlDocPtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
+//     xmlDocUniquePtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
 //     CPPUNIT_ASSERT(pXmlDoc);
 //
 //     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:spPr/a:gradFill");
@@ -845,7 +845,7 @@ void Chart2ExportTest::testDisplayUnits()
 void Chart2ExportTest::testFdo74115WallBitmapFill()
 {
     load("/chart2/qa/extras/data/docx/", "fdo74115_WallBitmapFill.docx");
-    xmlDocPtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
+    xmlDocUniquePtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
     CPPUNIT_ASSERT(pXmlDoc);
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:spPr/a:blipFill");
 }
@@ -853,7 +853,7 @@ void Chart2ExportTest::testFdo74115WallBitmapFill()
 void Chart2ExportTest::testPieChartWallLineStyle()
 {
     load("/chart2/qa/extras/data/odt/", "testPieChartWallLineStyle.odt");
-    xmlDocPtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
+    xmlDocUniquePtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
     CPPUNIT_ASSERT(pXmlDoc);
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:spPr/a:ln/a:noFill");
 }
@@ -863,7 +863,7 @@ void Chart2ExportTest::testPieChartWallLineStyle()
 void Chart2ExportTest::testFdo78290LineChartMarkerX()
 {
     load("/chart2/qa/extras/data/docx/", "fdo78290_Line_Chart_Marker_x.docx");
-    xmlDocPtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
+    xmlDocUniquePtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
     CPPUNIT_ASSERT(pXmlDoc);
     assertXPath(pXmlDoc, "/c:chartSpace[1]/c:chart[1]/c:plotArea[1]/c:lineChart[1]/c:ser[1]/c:marker[1]/c:symbol[1]","val","x");
     assertXPath(pXmlDoc, "/c:chartSpace[1]/c:chart[1]/c:plotArea[1]/c:lineChart[1]/c:ser[1]/c:marker[1]/c:size[1]","val","7");
@@ -874,7 +874,7 @@ void Chart2ExportTest::testFdo78290LineChartMarkerX()
 void Chart2ExportTest::testFdo78290ScatterChartMarkerX()
 {
     load("/chart2/qa/extras/data/docx/", "fdo78290_Scatter_Chart_Marker_x.docx");
-    xmlDocPtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
+    xmlDocUniquePtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
     CPPUNIT_ASSERT(pXmlDoc);
     assertXPath(pXmlDoc, "/c:chartSpace[1]/c:chart[1]/c:plotArea[1]/c:scatterChart[1]/c:ser[1]/c:marker[1]/c:symbol[1]","val","x");
     assertXPath(pXmlDoc, "/c:chartSpace[1]/c:chart[1]/c:plotArea[1]/c:scatterChart[1]/c:ser[1]/c:marker[1]/c:size[1]","val","7");
@@ -886,7 +886,7 @@ void Chart2ExportTest::testFdo78290ScatterChartMarkerX()
 void Chart2ExportTest::testFdo78290CombinationChartMarkerX()
 {
     load("/chart2/qa/extras/data/docx/", "fdo78290_Combination_Chart_Marker_x.docx");
-    xmlDocPtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
+    xmlDocUniquePtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
     CPPUNIT_ASSERT(pXmlDoc);
     assertXPath(pXmlDoc, "/c:chartSpace[1]/c:chart[1]/c:plotArea[1]/c:lineChart[1]/c:ser[1]/c:marker[1]/c:symbol[1]","val","x");
     assertXPath(pXmlDoc, "/c:chartSpace[1]/c:chart[1]/c:plotArea[1]/c:lineChart[1]/c:ser[1]/c:marker[1]/c:size[1]","val","7");
@@ -896,7 +896,7 @@ void Chart2ExportTest::testTdf126115IndividualMarker()
 {
     // Check individual marker properties.
     load("/chart2/qa/extras/data/xlsx/", "tdf126115.xlsx");
-    xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
+    xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
     CPPUNIT_ASSERT(pXmlDoc);
     // 1. series
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:scatterChart/c:ser[1]/c:dPt/c:marker/c:symbol", "val", "square");
@@ -1133,7 +1133,7 @@ void Chart2ExportTest::testDataLabel3DChartDOCX()
     Reference<chart2::XChartDocument> xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY);
     CPPUNIT_ASSERT(xChartDoc.is());
 
-    xmlDocPtr pXmlDoc = parseExport("word/charts/chart","Office Open XML Text");
+    xmlDocUniquePtr pXmlDoc = parseExport("word/charts/chart","Office Open XML Text");
     CPPUNIT_ASSERT(pXmlDoc);
 
     // We must not export label position attributes for 3D bar charts. The
@@ -1149,7 +1149,7 @@ void Chart2ExportTest::testDataLabelBarChartDOCX()
     Reference<chart2::XChartDocument> xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY);
     CPPUNIT_ASSERT(xChartDoc.is());
 
-    xmlDocPtr pXmlDoc = parseExport("word/charts/chart","Office Open XML Text");
+    xmlDocUniquePtr pXmlDoc = parseExport("word/charts/chart","Office Open XML Text");
     CPPUNIT_ASSERT(pXmlDoc);
 
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[1]/c:dLbls/c:dLblPos", "val", "ctr");
@@ -1164,7 +1164,7 @@ void Chart2ExportTest::testDataLabelClusteredBarChartDOCX()
     Reference<chart2::XChartDocument> xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY);
     CPPUNIT_ASSERT(xChartDoc.is());
 
-    xmlDocPtr pXmlDoc = parseExport("word/charts/chart","Office Open XML Text");
+    xmlDocUniquePtr pXmlDoc = parseExport("word/charts/chart","Office Open XML Text");
     CPPUNIT_ASSERT(pXmlDoc);
 
     // This was "t", should be one of the allowed values.
@@ -1178,7 +1178,7 @@ void Chart2ExportTest::testDataLabelRadarChartDOCX()
     Reference<chart2::XChartDocument> xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY);
     CPPUNIT_ASSERT(xChartDoc.is());
 
-    xmlDocPtr pXmlDoc = parseExport("word/charts/chart","Office Open XML Text");
+    xmlDocUniquePtr pXmlDoc = parseExport("word/charts/chart","Office Open XML Text");
     CPPUNIT_ASSERT(pXmlDoc);
 
     // We must not export label position attributes for radar charts.
@@ -1193,7 +1193,7 @@ void Chart2ExportTest::testDataLabelDoughnutChartDOCX()
     Reference<chart2::XChartDocument> xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY);
     CPPUNIT_ASSERT(xChartDoc.is());
 
-    xmlDocPtr pXmlDoc = parseExport("word/charts/chart","Office Open XML Text");
+    xmlDocUniquePtr pXmlDoc = parseExport("word/charts/chart","Office Open XML Text");
     CPPUNIT_ASSERT(pXmlDoc);
 
     // We must not export label position attributes for doughnut charts.
@@ -1208,7 +1208,7 @@ void Chart2ExportTest::testDataLabelAreaChartDOCX()
     Reference<chart2::XChartDocument> xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY);
     CPPUNIT_ASSERT(xChartDoc.is());
 
-    xmlDocPtr pXmlDoc = parseExport("word/charts/chart","Office Open XML Text");
+    xmlDocUniquePtr pXmlDoc = parseExport("word/charts/chart","Office Open XML Text");
     CPPUNIT_ASSERT(pXmlDoc);
 
     // We must not export label position attributes for area charts.
@@ -1242,7 +1242,7 @@ void Chart2ExportTest::testDataLabelDefaultLineChartDOCX()
 void Chart2ExportTest::testIndividualDataLabelProps()
 {
     load("/chart2/qa/extras/data/xlsx/", "tdf122915.xlsx");
-    xmlDocPtr pXmlDoc = parseExport("xl/charts/chart","Calc Office Open XML");
+    xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart","Calc Office Open XML");
     CPPUNIT_ASSERT(pXmlDoc);
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:scatterChart/c:ser[3]/c:dLbls/c:dLbl/c:txPr/a:p/a:pPr/a:defRPr", "b", "1");
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:scatterChart/c:ser[3]/c:dLbls/c:dLbl/c:txPr/a:p/a:pPr/a:defRPr", "sz", "1600");
@@ -1253,7 +1253,7 @@ void Chart2ExportTest::testIndividualDataLabelProps()
 void Chart2ExportTest::testTdf108107()
 {
     load("/chart2/qa/extras/data/xlsx/", "tdf108107.xlsx");
-    xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
+    xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
     CPPUNIT_ASSERT(pXmlDoc);
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser/c:dLbls/c:dLbl[1]/c:idx", "val", "1");
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser/c:dLbls/c:dLbl[1]/c:txPr/a:p/a:pPr/a:defRPr", "b", "1");
@@ -1263,7 +1263,7 @@ void Chart2ExportTest::testTdf108107()
 void Chart2ExportTest::testTdf114139()
 {
     load("/chart2/qa/extras/data/xlsx/", "tdf114139.xlsx");
-    xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
+    xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
     CPPUNIT_ASSERT(pXmlDoc);
 
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:pie3DChart", 1);
@@ -1275,7 +1275,7 @@ void Chart2ExportTest::testTdf114139()
 void Chart2ExportTest::testTdf64224()
 {
     load("/chart2/qa/extras/data/ods/", "tdf64224.ods");
-    xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
+    xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
     CPPUNIT_ASSERT(pXmlDoc);
 
     //no fill
@@ -1286,7 +1286,7 @@ void Chart2ExportTest::testTdf64224()
 void Chart2ExportTest::testChartTitlePropertiesColorFillDOCX()
 {
     load("/chart2/qa/extras/data/docx/", "testChartTitlePropertiesColorFill.docx");
-    xmlDocPtr pXmlDoc = parseExport("word/charts/chart","Office Open XML Text");
+    xmlDocUniquePtr pXmlDoc = parseExport("word/charts/chart","Office Open XML Text");
     CPPUNIT_ASSERT(pXmlDoc);
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:spPr/a:solidFill/a:srgbClr", "val", "ff0000");
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:spPr/a:ln/a:noFill", 1);
@@ -1295,7 +1295,7 @@ void Chart2ExportTest::testChartTitlePropertiesColorFillDOCX()
 void Chart2ExportTest::testChartTitlePropertiesGradientFillDOCX()
 {
     load("/chart2/qa/extras/data/docx/", "testChartTitlePropertiesGradientFill.docx");
-    xmlDocPtr pXmlDoc = parseExport("word/charts/chart","Office Open XML Text");
+    xmlDocUniquePtr pXmlDoc = parseExport("word/charts/chart","Office Open XML Text");
     CPPUNIT_ASSERT(pXmlDoc);
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:spPr/a:gradFill/a:gsLst/a:gs[1]/a:srgbClr", "val", "cccccc");
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:spPr/a:gradFill/a:gsLst/a:gs[2]/a:srgbClr", "val", "666666");
@@ -1305,7 +1305,7 @@ void Chart2ExportTest::testChartTitlePropertiesGradientFillDOCX()
 void Chart2ExportTest::testChartTitlePropertiesBitmapFillDOCX()
 {
     load("/chart2/qa/extras/data/docx/", "testChartTitlePropertiesBitmapFill.docx");
-    xmlDocPtr pXmlDoc = parseExport("word/charts/chart","Office Open XML Text");
+    xmlDocUniquePtr pXmlDoc = parseExport("word/charts/chart","Office Open XML Text");
     CPPUNIT_ASSERT(pXmlDoc);
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:spPr/a:blipFill/a:blip", "embed", "rId1");
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:spPr/a:ln/a:noFill", 1);
@@ -1315,7 +1315,7 @@ void Chart2ExportTest::testColorGradientWithTransparancyDOCX()
 {
     // Test color gradient (two color) with gradient transparency
     load("/chart2/qa/extras/data/docx/", "testColorGradientWithTransparancy.docx");
-    xmlDocPtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
+    xmlDocUniquePtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
     CPPUNIT_ASSERT(pXmlDoc);
     // Test the transparency of the first color
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:spPr/a:gradFill/a:gsLst/a:gs[1]/a:srgbClr/a:alpha", "val", "60000");
@@ -1327,7 +1327,7 @@ void Chart2ExportTest::testColorGradientWithTransparancyODS()
 {
     // Test color gradient (two color) with simple transparency
     load("/chart2/qa/extras/data/ods/", "testColorGradientWithTransparancy.ods");
-    xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
+    xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
     CPPUNIT_ASSERT(pXmlDoc);
     // Test the transparency of the first color
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:spPr/a:gradFill/a:gsLst/a:gs[1]/a:srgbClr/a:alpha", "val", "60000");
@@ -1339,7 +1339,7 @@ void Chart2ExportTest::testColorGradientStopXLSX()
 {
     // Test color gradient (two color) stop of the first color
     load("/chart2/qa/extras/data/xlsx/", "tdf128619.xlsx");
-    xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
+    xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
     CPPUNIT_ASSERT(pXmlDoc);
     // Test the position of the first color
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:spPr/a:gradFill/a:gsLst/a:gs[1]", "pos", "45000");
@@ -1350,7 +1350,7 @@ void Chart2ExportTest::testColorGradientStopXLSX()
 void Chart2ExportTest::testBarChartDataPointPropDOCX()
 {
     load("/chart2/qa/extras/data/docx/", "testBarChartDataPointPropDOCX.docx");
-    xmlDocPtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
+    xmlDocUniquePtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
     CPPUNIT_ASSERT(pXmlDoc);
 
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:varyColors", "val", "0");
@@ -1368,7 +1368,7 @@ void Chart2ExportTest::testBarChartDataPointPropDOCX()
 void Chart2ExportTest::testBarChartRotation()
 {
     load ("/chart2/qa/extras/data/docx/", "barChartRotation.docx");
-    xmlDocPtr pXmlDoc = parseExport("word/charts/chart","Office Open XML Text");
+    xmlDocUniquePtr pXmlDoc = parseExport("word/charts/chart","Office Open XML Text");
     CPPUNIT_ASSERT(pXmlDoc);
 
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:view3D/c:rotX", "val", "30");
@@ -1383,7 +1383,7 @@ void Chart2ExportTest::testShapeFollowedByChart()
        docPr Id should be unique, ensuring the same here.
     */
     load("/chart2/qa/extras/data/docx/", "FDO74430.docx");
-    xmlDocPtr pXmlDoc = parseExport("word/document", "Office Open XML Text" );
+    xmlDocUniquePtr pXmlDoc = parseExport("word/document", "Office Open XML Text" );
     CPPUNIT_ASSERT(pXmlDoc);
 
     OUString aValueOfFirstDocPR = getXPath(pXmlDoc, "/w:document/w:body/w:p[3]/w:r[1]/w:drawing[1]/wp:inline[1]/wp:docPr[1]", "id");
@@ -1395,7 +1395,7 @@ void Chart2ExportTest::testShapeFollowedByChart()
 void Chart2ExportTest::testPieChartDataLabels()
 {
     load("/chart2/qa/extras/data/docx/", "PieChartDataLabels.docx");
-    xmlDocPtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
+    xmlDocUniquePtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
     CPPUNIT_ASSERT(pXmlDoc);
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:pie3DChart/c:ser[1]/c:dLbls/c:dLbl[1]/c:dLblPos", "val", "bestFit");
 }
@@ -1403,7 +1403,7 @@ void Chart2ExportTest::testPieChartDataLabels()
 void Chart2ExportTest::testSeriesIdxOrder()
 {
     load("/chart2/qa/extras/data/docx/", "testSeriesIdxOrder.docx");
-    xmlDocPtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
+    xmlDocUniquePtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
     CPPUNIT_ASSERT(pXmlDoc);
     assertXPath(pXmlDoc, "/c:chartSpace[1]/c:chart[1]/c:plotArea[1]/c:lineChart[1]/c:ser[1]/c:idx[1]", "val", "1");
     assertXPath(pXmlDoc, "/c:chartSpace[1]/c:chart[1]/c:plotArea[1]/c:lineChart[1]/c:ser[1]/c:order[1]", "val", "1");
@@ -1473,14 +1473,14 @@ void Chart2ExportTest::testErrorBarDataRangeODS()
 void Chart2ExportTest::testChartCrash()
 {
     load("/chart2/qa/extras/data/docx/", "FDO75975.docx");
-    xmlDocPtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
+    xmlDocUniquePtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
     CPPUNIT_ASSERT(pXmlDoc);
 }
 
 void Chart2ExportTest::testPieChartRotation()
 {
     load ("/chart2/qa/extras/data/docx/", "pieChartRotation.docx");
-    xmlDocPtr pXmlDoc = parseExport("word/charts/chart","Office Open XML Text");
+    xmlDocUniquePtr pXmlDoc = parseExport("word/charts/chart","Office Open XML Text");
     CPPUNIT_ASSERT(pXmlDoc);
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:view3D/c:rotX", "val", "40");
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:view3D/c:rotY", "val", "30");
@@ -1583,7 +1583,7 @@ void Chart2ExportTest::testGapWidthXLSX()
 void Chart2ExportTest::testSmoothedLines()
 {
     load("/chart2/qa/extras/data/ods/", "smoothedLines.ods");
-    xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
+    xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
     CPPUNIT_ASSERT(pXmlDoc);
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser[1]/c:smooth", "val", "0");
 }
@@ -1613,7 +1613,7 @@ void Chart2ExportTest::testLabelStringODS()
 void Chart2ExportTest::testFdo83058dlblPos()
 {
     load ("/chart2/qa/extras/data/docx/", "fdo83058_dlblPos.docx");
-    xmlDocPtr pXmlDoc = parseExport("word/charts/chart","Office Open XML Text");
+    xmlDocUniquePtr pXmlDoc = parseExport("word/charts/chart","Office Open XML Text");
     CPPUNIT_ASSERT(pXmlDoc);
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[1]/c:dLbls[1]/c:dLbl[2]/c:dLblPos", "val", "outEnd");
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[1]/c:dLbls[1]/c:dLbl[3]/c:dLblPos", "val", "outEnd");
@@ -1624,7 +1624,7 @@ void Chart2ExportTest::testFdo83058dlblPos()
 void Chart2ExportTest::testAutoTitleDelXLSX()
 {
     load("/chart2/qa/extras/data/xlsx/", "autotitledel_2007.xlsx");
-    xmlDocPtr pXmlDoc = parseExport("xl/charts/chart","Calc Office Open XML");
+    xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart","Calc Office Open XML");
     CPPUNIT_ASSERT(pXmlDoc);
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:autoTitleDeleted", "val", "0");
 }
@@ -1632,7 +1632,7 @@ void Chart2ExportTest::testAutoTitleDelXLSX()
 void Chart2ExportTest::testDispBlanksAsXLSX()
 {
     load("/chart2/qa/extras/data/xlsx/", "dispBlanksAs_2007.xlsx");
-    xmlDocPtr pXmlDoc = parseExport("xl/charts/chart","Calc Office Open XML");
+    xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart","Calc Office Open XML");
     CPPUNIT_ASSERT(pXmlDoc);
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:dispBlanksAs", "val", "gap");
 }
@@ -1640,7 +1640,7 @@ void Chart2ExportTest::testDispBlanksAsXLSX()
 void Chart2ExportTest::testMarkerColorXLSX()
 {
     load("/chart2/qa/extras/data/xlsx/", "markerColor.xlsx");
-    xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
+    xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
     CPPUNIT_ASSERT(pXmlDoc);
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:scatterChart/c:ser/c:marker/c:spPr/a:solidFill/a:srgbClr", "val", "92d050");
 }
@@ -1648,7 +1648,7 @@ void Chart2ExportTest::testMarkerColorXLSX()
 void Chart2ExportTest::testRoundedCornersXLSX()
 {
     load("/chart2/qa/extras/data/xlsx/", "markerColor.xlsx");
-    xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
+    xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
     CPPUNIT_ASSERT(pXmlDoc);
     assertXPath(pXmlDoc, "/c:chartSpace/c:roundedCorners", "val", "0");
 }
@@ -1656,7 +1656,7 @@ void Chart2ExportTest::testRoundedCornersXLSX()
 void Chart2ExportTest::testAxisNumberFormatXLSX()
 {
     load("/chart2/qa/extras/data/ods/", "axis_number_format.ods");
-    xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
+    xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
     CPPUNIT_ASSERT(pXmlDoc);
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:valAx", 2);
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:valAx[1]/c:numFmt", "formatCode", "0.00E+000");
@@ -1670,7 +1670,7 @@ void Chart2ExportTest::testDataPointLabelNumberFormatXLSX()
 {
     load("/chart2/qa/extras/data/ods/", "tdf123774.ods");
     {
-        xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
+        xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
         CPPUNIT_ASSERT(pXmlDoc);
         assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:pieChart/c:ser/c:dLbls/c:numFmt", "formatCode", "[$-40E]0.00%");
         assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:pieChart/c:ser/c:dLbls/c:numFmt", "sourceLinked", "0");
@@ -1681,7 +1681,7 @@ void Chart2ExportTest::testDataPointLabelNumberFormatXLSX()
 
     load("/chart2/qa/extras/data/xlsx/", "tdf130986.xlsx");
     {
-        xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
+        xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
         CPPUNIT_ASSERT(pXmlDoc);
         assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dLbls/c:dLbl/c:idx", "val", "1");
         assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dLbls/c:dLbl/c:numFmt", "formatCode", "0.00E+00");
@@ -1700,7 +1700,7 @@ void Chart2ExportTest::testDataLabelDefaultValuesXLSX()
     CPPUNIT_ASSERT(aAny >>= aLabel);
     CPPUNIT_ASSERT(aLabel.ShowNumber);
 
-    xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
+    xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
     CPPUNIT_ASSERT(pXmlDoc);
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dLbls/c:showVal", "val", "1");
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dLbls/c:dLblPos", "val", "outEnd");
@@ -1709,7 +1709,7 @@ void Chart2ExportTest::testDataLabelDefaultValuesXLSX()
 void Chart2ExportTest::testTitleOverlayXLSX()
 {
     load("/chart2/qa/extras/data/xlsx/", "chart_title.xlsx");
-    xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
+    xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
     CPPUNIT_ASSERT(pXmlDoc);
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:overlay", "val", "0");
 }
@@ -1717,7 +1717,7 @@ void Chart2ExportTest::testTitleOverlayXLSX()
 void Chart2ExportTest::testInvertIfNegativeXLSX()
 {
     load("/chart2/qa/extras/data/xlsx/", "bar_chart_simple.xlsx");
-    xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
+    xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
     CPPUNIT_ASSERT(pXmlDoc);
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:invertIfNegative", "val", "0");
 }
@@ -1725,7 +1725,7 @@ void Chart2ExportTest::testInvertIfNegativeXLSX()
 void Chart2ExportTest::testBubble3DXLSX()
 {
     load("/chart2/qa/extras/data/xlsx/", "bubble_chart_simple.xlsx");
-    xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
+    xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
     CPPUNIT_ASSERT(pXmlDoc);
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:bubbleChart/c:ser[1]/c:bubble3D", "val", "0");
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:bubbleChart/c:ser[2]/c:bubble3D", "val", "0");
@@ -1735,7 +1735,7 @@ void Chart2ExportTest::testBubble3DXLSX()
 void Chart2ExportTest::testNoMarkerXLSX()
 {
     load("/chart2/qa/extras/data/xlsx/", "no_marker.xlsx");
-    xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
+    xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
     CPPUNIT_ASSERT(pXmlDoc);
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser[1]/c:marker/c:symbol", "val", "none");
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser[2]/c:marker/c:symbol", "val", "none");
@@ -1745,7 +1745,7 @@ void Chart2ExportTest::testNoMarkerXLSX()
 void Chart2ExportTest::testTitleManualLayoutXLSX()
 {
     load("/chart2/qa/extras/data/xlsx/", "title_manual_layout.xlsx");
-    xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
+    xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
     CPPUNIT_ASSERT(pXmlDoc);
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:layout/c:manualLayout/c:layoutTarget", 0);
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:layout/c:manualLayout/c:xMode", "val", "edge");
@@ -1766,7 +1766,7 @@ void Chart2ExportTest::testTitleManualLayoutXLSX()
 void Chart2ExportTest::testPlotAreaManualLayoutXLSX()
 {
     load("/chart2/qa/extras/data/xlsx/", "plot_area_manual_layout.xlsx");
-    xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
+    xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
     CPPUNIT_ASSERT(pXmlDoc);
 
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:layout/c:manualLayout/c:layoutTarget", "val", "inner");
@@ -1795,7 +1795,7 @@ void Chart2ExportTest::testPlotAreaManualLayoutXLSX()
 void Chart2ExportTest::testLegendManualLayoutXLSX()
 {
     load("/chart2/qa/extras/data/xlsx/", "legend_manual_layout.xlsx");
-    xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
+    xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
     CPPUNIT_ASSERT(pXmlDoc);
 
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:layout/c:manualLayout/c:layoutTarget", 0);
@@ -1827,7 +1827,7 @@ void Chart2ExportTest::testLegendManualLayoutXLSX()
 void Chart2ExportTest::testChartSubTitle()
 {
     load("/chart2/qa/extras/data/ods/", "testChartSubTitle.ods");
-    xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
+    xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
     CPPUNIT_ASSERT(pXmlDoc);
     // test properties of subtitle
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p/a:pPr/a:defRPr", "sz", "1100");
@@ -1841,7 +1841,7 @@ void Chart2ExportTest::testChartSubTitle()
 void Chart2ExportTest::testChartMainWithSubTitle()
 {
     load("/chart2/qa/extras/data/ods/", "testChartMainWithSubTitle.ods");
-    xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
+    xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
     CPPUNIT_ASSERT(pXmlDoc);
     // test properties of title
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p/a:pPr/a:defRPr", "sz", "1300");
@@ -1856,7 +1856,7 @@ void Chart2ExportTest::testChartMainWithSubTitle()
 void Chart2ExportTest::testAutoTitleDeleted()
 {
     load("/chart2/qa/extras/data/xlsx/", "testAutoTitleDeleted.xlsx");
-    xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
+    xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
     CPPUNIT_ASSERT(pXmlDoc);
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:autoTitleDeleted", "val", "1");
 }
@@ -1864,7 +1864,7 @@ void Chart2ExportTest::testAutoTitleDeleted()
 void Chart2ExportTest::testChartTitlePropertiesColorFillXLSX()
 {
     load("/chart2/qa/extras/data/xlsx/", "testChartTitlePropertiesColorFill.xlsx");
-    xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
+    xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
     CPPUNIT_ASSERT(pXmlDoc);
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:spPr/a:solidFill/a:srgbClr", "val", "ff0000");
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:spPr/a:ln/a:noFill", 1);
@@ -1873,7 +1873,7 @@ void Chart2ExportTest::testChartTitlePropertiesColorFillXLSX()
 void Chart2ExportTest::testChartTitlePropertiesGradientFillXLSX()
 {
     load("/chart2/qa/extras/data/xlsx/", "testChartTitlePropertiesGradientFill.xlsx");
-    xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
+    xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
     CPPUNIT_ASSERT(pXmlDoc);
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:spPr/a:gradFill/a:gsLst/a:gs[1]/a:srgbClr", "val", "cccccc");
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:spPr/a:gradFill/a:gsLst/a:gs[2]/a:srgbClr", "val", "666666");
@@ -1883,7 +1883,7 @@ void Chart2ExportTest::testChartTitlePropertiesGradientFillXLSX()
 void Chart2ExportTest::testChartTitlePropertiesBitmapFillXLSX()
 {
     load("/chart2/qa/extras/data/xlsx/", "testChartTitlePropertiesBitmapFill.xlsx");
-    xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
+    xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
     CPPUNIT_ASSERT(pXmlDoc);
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:spPr/a:blipFill/a:blip", "embed", "rId1");
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:spPr/a:ln/a:noFill", 1);
@@ -1892,7 +1892,7 @@ void Chart2ExportTest::testChartTitlePropertiesBitmapFillXLSX()
 void Chart2ExportTest::testBarChartDataPointPropXLSX()
 {
     load("/chart2/qa/extras/data/xlsx/", "testBarChartDataPointPropXLSX.xlsx");
-    xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
+    xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
     CPPUNIT_ASSERT(pXmlDoc);
 
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:varyColors", "val", "0");
@@ -1931,7 +1931,7 @@ void Chart2ExportTest::testDataseriesOverlapStackedChartXLSX()
 void Chart2ExportTest::testAxisCharacterPropertiesXLSX()
 {
     load("/chart2/qa/extras/data/xlsx/", "axis_character_properties.xlsx");
-    xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
+    xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
     CPPUNIT_ASSERT(pXmlDoc);
 
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:catAx/c:txPr/a:p/a:pPr/a:defRPr", "sz", "1000");
@@ -1948,7 +1948,7 @@ void Chart2ExportTest::testAxisCharacterPropertiesXLSX()
 void Chart2ExportTest::testTitleCharacterPropertiesXLSX()
 {
     load("/chart2/qa/extras/data/xlsx/", "title_character_properties.xlsx");
-    xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
+    xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
     CPPUNIT_ASSERT(pXmlDoc);
 
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p/a:pPr/a:defRPr", "sz", "2400");
@@ -1961,7 +1961,7 @@ void Chart2ExportTest::testTitleCharacterPropertiesXLSX()
 void Chart2ExportTest::testPlotVisOnlyXLSX()
 {
     load("/chart2/qa/extras/data/xlsx/", "hidden_cells.xlsx");
-    xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
+    xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
     CPPUNIT_ASSERT(pXmlDoc);
 
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotVisOnly", "val", "0");
@@ -1970,7 +1970,7 @@ void Chart2ExportTest::testPlotVisOnlyXLSX()
 void Chart2ExportTest::testBarChartVaryColorsXLSX()
 {
     load("/chart2/qa/extras/data/xlsx/", "tdf90876.xlsx");
-    xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
+    xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
     CPPUNIT_ASSERT(pXmlDoc);
 
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:varyColors", "val", "0");
@@ -1979,7 +1979,7 @@ void Chart2ExportTest::testBarChartVaryColorsXLSX()
 void Chart2ExportTest::testMultipleAxisXLSX()
 {
     load("/chart2/qa/extras/data/ods/", "multiple_axis.ods");
-    xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
+    xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
     CPPUNIT_ASSERT(pXmlDoc);
 
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:scatterChart", 2);
@@ -1994,7 +1994,7 @@ void Chart2ExportTest::testMultipleAxisXLSX()
 void Chart2ExportTest::testSecondaryAxisXLSX()
 {
     load("/chart2/qa/extras/data/ods/", "secondary_axis.ods");
-    xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
+    xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
     CPPUNIT_ASSERT(pXmlDoc);
 
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:lineChart", 2);
@@ -2020,7 +2020,7 @@ void Chart2ExportTest::testSetSeriesToSecondaryAxisXLSX()
     // Attach the second series to the secondary axis. (The third series is already attached.)
     xPropSet->setPropertyValue("AttachedAxisIndex", uno::Any(AxisIndex));
 
-    xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
+    xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
     CPPUNIT_ASSERT(pXmlDoc);
     // Check there are only two <lineChart> tag in the XML, one for the primary and one for the secondary axis.
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:lineChart", 2);
@@ -2030,7 +2030,7 @@ void Chart2ExportTest::testCombinedChartSecondaryAxisXLSX()
 {
     // Original file was created with MS Office
     load("/chart2/qa/extras/data/xlsx/", "combined_chart_secondary_axis.xlsx");
-    xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
+    xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
     CPPUNIT_ASSERT(pXmlDoc);
     // Collect barchart axID on secondary Axis
     OUString XValueIdOfBarchart = getXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:axId[1]", "val");
@@ -2049,7 +2049,7 @@ void Chart2ExportTest::testCombinedChartSecondaryAxisODS()
 {
     // Original file was created with LibreOffice
     load("/chart2/qa/extras/data/ods/", "combined_chart_secondary_axis.ods");
-    xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
+    xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
     CPPUNIT_ASSERT(pXmlDoc);
     // Collect barchart axID on secondary Axis
     OUString XValueIdOfBarchart = getXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:axId[1]", "val");
@@ -2071,13 +2071,13 @@ void Chart2ExportTest::testCrossBetweenXLSX()
     // Original files were created with MS Office
     {
         load("/chart2/qa/extras/data/xlsx/", "tdf127777.xlsx");
-        xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
+        xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
         CPPUNIT_ASSERT(pXmlDoc);
         assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:valAx/c:crossBetween", "val", "between");
     }
     {
         load("/chart2/qa/extras/data/xlsx/", "tdf132076.xlsx");
-        xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
+        xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
         CPPUNIT_ASSERT(pXmlDoc);
         assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:valAx/c:crossBetween", "val", "between");
     }
@@ -2087,7 +2087,7 @@ void Chart2ExportTest::testCrossBetweenWithDeletedAxis()
 {
     // Original file was created with MS Office (the category axis is deleted in the file)
     load("/chart2/qa/extras/data/xlsx/", "tdf128633.xlsx");
-    xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
+    xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
     CPPUNIT_ASSERT(pXmlDoc);
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:valAx/c:crossBetween", "val", "between");
 }
@@ -2096,7 +2096,7 @@ void Chart2ExportTest::testCrossBetweenODS()
 {
     // Original file was created with LibreOffice
     load("/chart2/qa/extras/data/ods/", "test_CrossBetween.ods");
-    xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
+    xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
     CPPUNIT_ASSERT(pXmlDoc);
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:valAx/c:crossBetween", "val", "between");
 }
@@ -2104,7 +2104,7 @@ void Chart2ExportTest::testCrossBetweenODS()
 void Chart2ExportTest::testAxisTitleRotationXLSX()
 {
     load("/chart2/qa/extras/data/xlsx/", "axis_title_rotation.xlsx");
-    xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
+    xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
     CPPUNIT_ASSERT(pXmlDoc);
 
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:valAx/c:title/c:tx/c:rich/a:bodyPr", "rot", "0");
@@ -2113,7 +2113,7 @@ void Chart2ExportTest::testAxisTitleRotationXLSX()
 void Chart2ExportTest::testAxisTitlePositionDOCX()
 {
     load("/chart2/qa/extras/data/docx/", "testAxisTitlePosition.docx");
-    xmlDocPtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
+    xmlDocUniquePtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
     CPPUNIT_ASSERT(pXmlDoc);
 
     // test X Axis title position
@@ -2137,14 +2137,14 @@ void Chart2ExportTest::testAxisTitlePositionDOCX()
 void Chart2ExportTest::testAxisCrossBetweenDOCX()
 {
     load("/chart2/qa/extras/data/odt/", "axis-position.odt");
-    xmlDocPtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
+    xmlDocUniquePtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
     assertXPath(pXmlDoc, "(//c:crossBetween)[1]", "val", "midCat");
 }
 
 void Chart2ExportTest::testPieChartDataPointExplosionXLSX()
 {
     load("/chart2/qa/extras/data/xlsx/", "pie_chart_datapoint_explosion.xlsx");
-    xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
+    xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
     CPPUNIT_ASSERT(pXmlDoc);
 
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:pieChart/c:ser/c:dPt/c:explosion", "val", "28");
@@ -2153,7 +2153,7 @@ void Chart2ExportTest::testPieChartDataPointExplosionXLSX()
 void Chart2ExportTest::testCustomDataLabel()
 {
     load("/chart2/qa/extras/data/pptx/", "tdf115107.pptx");
-    xmlDocPtr pXmlDoc = parseExport("ppt/charts/chart1", "Impress MS PowerPoint 2007 XML");
+    xmlDocUniquePtr pXmlDoc = parseExport("ppt/charts/chart1", "Impress MS PowerPoint 2007 XML");
     CPPUNIT_ASSERT(pXmlDoc);
     // Check the data labels font color for the complete data series
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dLbls/c:txPr/a:p/a:pPr/a:defRPr/a:solidFill/a:srgbClr", "val", "404040");
@@ -2252,7 +2252,7 @@ void Chart2ExportTest::testCustomPositionofDataLabel()
 {
     load("/chart2/qa/extras/data/xlsx/", "testCustomPosDataLabels.xlsx");
     {
-        xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
+        xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
         CPPUNIT_ASSERT(pXmlDoc);
 
         // test custom position of data label (xlsx)
@@ -2268,7 +2268,7 @@ void Chart2ExportTest::testCustomPositionofDataLabel()
 
     load("/chart2/qa/extras/data/docx/", "testTdf108110.docx");
     {
-        xmlDocPtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
+        xmlDocUniquePtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
         CPPUNIT_ASSERT(pXmlDoc);
 
         // test custom position of data label (docx)
@@ -2286,7 +2286,7 @@ void Chart2ExportTest::testCustomPositionofDataLabel()
 void Chart2ExportTest::testCustomDataLabelMultipleSeries()
 {
     load("/chart2/qa/extras/data/pptx/", "tdf115107-2.pptx");
-    xmlDocPtr pXmlDoc = parseExport("ppt/charts/chart2", "Impress MS PowerPoint 2007 XML");
+    xmlDocUniquePtr pXmlDoc = parseExport("ppt/charts/chart2", "Impress MS PowerPoint 2007 XML");
     CPPUNIT_ASSERT(pXmlDoc);
 
     Reference<chart2::XChartDocument> xChartDoc(getChartDocFromDrawImpress(0, 0), uno::UNO_QUERY);
@@ -2343,7 +2343,7 @@ void Chart2ExportTest::testCustomDataLabelMultipleSeries()
 void Chart2ExportTest::testLeaderLines()
 {
     load("/chart2/qa/extras/data/xlsx/", "testTdf90749.xlsx");
-    xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
+    xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
     CPPUNIT_ASSERT(pXmlDoc);
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser[1]/c:dLbls/c:extLst/c:ext/c15:showLeaderLines", "val", "1");
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser[2]/c:dLbls/c:extLst/c:ext/c15:showLeaderLines", "val", "1");
@@ -2352,7 +2352,7 @@ void Chart2ExportTest::testLeaderLines()
 void Chart2ExportTest::testNumberFormatExportPPTX()
 {
     load("/chart2/qa/extras/data/pptx/", "tdf115859.pptx");
-    xmlDocPtr pXmlDoc = parseExport("ppt/charts/chart", "Impress MS PowerPoint 2007 XML");
+    xmlDocUniquePtr pXmlDoc = parseExport("ppt/charts/chart", "Impress MS PowerPoint 2007 XML");
     CPPUNIT_ASSERT(pXmlDoc);
 
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dLbls/c:numFmt", "formatCode", "#,##0.00,\\K");
@@ -2366,7 +2366,7 @@ void Chart2ExportTest::testLabelSeparatorExportDOCX()
     Reference<chart2::XChartDocument> xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY);
     CPPUNIT_ASSERT(xChartDoc.is());
 
-    xmlDocPtr pXmlDoc = parseExport("word/charts/chart","Office Open XML Text");
+    xmlDocUniquePtr pXmlDoc = parseExport("word/charts/chart","Office Open XML Text");
     CPPUNIT_ASSERT(pXmlDoc);
 
     // The text separator should be a new line
@@ -2380,7 +2380,7 @@ void Chart2ExportTest::testLabelSeparatorExportDOCX()
 void Chart2ExportTest::testChartTitlePropertiesColorFillPPTX()
 {
     load("/chart2/qa/extras/data/pptx/", "testChartTitlePropertiesColorFill.pptx");
-    xmlDocPtr pXmlDoc = parseExport("ppt/charts/chart", "Impress MS PowerPoint 2007 XML");
+    xmlDocUniquePtr pXmlDoc = parseExport("ppt/charts/chart", "Impress MS PowerPoint 2007 XML");
     CPPUNIT_ASSERT(pXmlDoc);
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:spPr/a:solidFill/a:srgbClr", "val", "ff0000");
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:spPr/a:ln/a:noFill", 1);
@@ -2389,7 +2389,7 @@ void Chart2ExportTest::testChartTitlePropertiesColorFillPPTX()
 void Chart2ExportTest::testChartTitlePropertiesGradientFillPPTX()
 {
     load("/chart2/qa/extras/data/pptx/", "testChartTitlePropertiesGradientFill.pptx");
-    xmlDocPtr pXmlDoc = parseExport("ppt/charts/chart", "Impress MS PowerPoint 2007 XML");
+    xmlDocUniquePtr pXmlDoc = parseExport("ppt/charts/chart", "Impress MS PowerPoint 2007 XML");
     CPPUNIT_ASSERT(pXmlDoc);
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:spPr/a:gradFill/a:gsLst/a:gs[1]/a:srgbClr", "val", "f6f8fc");
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:spPr/a:gradFill/a:gsLst/a:gs[2]/a:srgbClr", "val", "c7d5ed");
@@ -2399,7 +2399,7 @@ void Chart2ExportTest::testChartTitlePropertiesGradientFillPPTX()
 void Chart2ExportTest::testChartTitlePropertiesBitmapFillPPTX()
 {
     load("/chart2/qa/extras/data/pptx/", "testChartTitlePropertiesBitmapFill.pptx");
-    xmlDocPtr pXmlDoc = parseExport("ppt/charts/chart", "Impress MS PowerPoint 2007 XML");
+    xmlDocUniquePtr pXmlDoc = parseExport("ppt/charts/chart", "Impress MS PowerPoint 2007 XML");
     CPPUNIT_ASSERT(pXmlDoc);
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:spPr/a:blipFill/a:blip", "embed", "rId1");
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:spPr/a:ln/a:noFill", 1);
@@ -2408,7 +2408,7 @@ void Chart2ExportTest::testChartTitlePropertiesBitmapFillPPTX()
 void Chart2ExportTest::testxAxisLabelsRotation()
 {
     load ("/chart2/qa/extras/data/xlsx/", "xAxisLabelsRotation.xlsx");
-    xmlDocPtr pXmlDoc1 = parseExport("xl/charts/chart","Calc Office Open XML");
+    xmlDocUniquePtr pXmlDoc1 = parseExport("xl/charts/chart","Calc Office Open XML");
     CPPUNIT_ASSERT(pXmlDoc1);
 
     // Chart1 xAxis labels should be 45 degree
@@ -2418,7 +2418,7 @@ void Chart2ExportTest::testxAxisLabelsRotation()
 void Chart2ExportTest::testMultipleCategoryAxisLablesXLSX()
 {
     load("/chart2/qa/extras/data/ods/", "multilevelcat.ods");
-    xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
+    xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
     CPPUNIT_ASSERT(pXmlDoc);
     // check category axis labels number of first level
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[1]/c:cat/c:multiLvlStrRef/c:multiLvlStrCache/c:ptCount", "val", "6");
@@ -2435,7 +2435,7 @@ void Chart2ExportTest::testMultipleCategoryAxisLablesXLSX()
 void Chart2ExportTest::testMultipleCategoryAxisLablesDOCX()
 {
     load("/chart2/qa/extras/data/odt/", "multilevelcat.odt");
-    xmlDocPtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
+    xmlDocUniquePtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
     CPPUNIT_ASSERT(pXmlDoc);
     // check category axis labels number of first level
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[1]/c:cat/c:multiLvlStrRef/c:multiLvlStrCache/c:ptCount", "val", "4");
@@ -2452,7 +2452,7 @@ void Chart2ExportTest::testMultipleCategoryAxisLablesDOCX()
 void Chart2ExportTest::testTdf116163()
 {
     load("/chart2/qa/extras/data/pptx/", "tdf116163.pptx");
-    xmlDocPtr pXmlDoc = parseExport("ppt/charts/chart", "Impress MS PowerPoint 2007 XML");
+    xmlDocUniquePtr pXmlDoc = parseExport("ppt/charts/chart", "Impress MS PowerPoint 2007 XML");
     CPPUNIT_ASSERT(pXmlDoc);
 
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:catAx/c:txPr/a:bodyPr", "rot", "-5400000");
@@ -2461,7 +2461,7 @@ void Chart2ExportTest::testTdf116163()
 void Chart2ExportTest::testTdf111824()
 {
     load("/chart2/qa/extras/data/xlsx/", "tdf111824.xlsx");
-    xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
+    xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
     CPPUNIT_ASSERT(pXmlDoc);
 
     // Collect 3D barchart Z axID
@@ -2473,7 +2473,7 @@ void Chart2ExportTest::testTdf111824()
 void Chart2ExportTest::test3DAreaChartZAxis()
 {
     load("/chart2/qa/extras/data/xlsx/", "test3DAreaChartZAxis.xlsx");
-    xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
+    xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
     CPPUNIT_ASSERT(pXmlDoc);
 
     // Collect 3D area chart Z axID
@@ -2486,7 +2486,7 @@ void Chart2ExportTest::testTdf119029()
 {
     load("/chart2/qa/extras/data/odp/", "tdf119029.odp");
     // Only use "chart", without number, because the number depends on the previous tests
-    xmlDocPtr pXmlDoc = parseExport("ppt/charts/chart", "Impress MS PowerPoint 2007 XML");
+    xmlDocUniquePtr pXmlDoc = parseExport("ppt/charts/chart", "Impress MS PowerPoint 2007 XML");
     CPPUNIT_ASSERT(pXmlDoc);
 
     assertXPath(pXmlDoc,
@@ -2509,7 +2509,7 @@ void Chart2ExportTest::testTdf108022()
 void Chart2ExportTest::testTdf121744()
 {
     load("/chart2/qa/extras/data/docx/", "tdf121744.docx");
-    xmlDocPtr pXmlDoc = parseExport("word/charts/chart","Office Open XML Text");
+    xmlDocUniquePtr pXmlDoc = parseExport("word/charts/chart","Office Open XML Text");
     CPPUNIT_ASSERT(pXmlDoc);
 
     OUString XValueId = getXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:axId[1]", "val");
@@ -2524,7 +2524,7 @@ void Chart2ExportTest::testTdf122031()
     //Checks pie chart data label format.
 
     load("/chart2/qa/extras/data/xlsx/", "tdf122031.xlsx");
-    xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
+    xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
     CPPUNIT_ASSERT(pXmlDoc);
 
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:pieChart/c:ser/c:dLbls/c:numFmt", "formatCode", "0.000%");
@@ -2536,7 +2536,7 @@ void Chart2ExportTest::testTdf122031()
 void Chart2ExportTest::testTdf115012()
 {
     load("/chart2/qa/extras/data/xlsx/", "tdf115012.xlsx");
-    xmlDocPtr pXmlDoc = parseExport("xl/charts/chart","Calc Office Open XML");
+    xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart","Calc Office Open XML");
     CPPUNIT_ASSERT(pXmlDoc);
     // workaround: use-zero instead of leave-gap to show the original line chart
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:dispBlanksAs", "val", "zero");
@@ -2549,7 +2549,7 @@ void Chart2ExportTest::testTdf123206_customLabelText()
     Reference<chart2::XChartDocument> xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY);
     CPPUNIT_ASSERT(xChartDoc.is());
 
-    xmlDocPtr pXmlDoc = parseExport("word/charts/chart","Office Open XML Text");
+    xmlDocUniquePtr pXmlDoc = parseExport("word/charts/chart","Office Open XML Text");
     CPPUNIT_ASSERT(pXmlDoc);
 
     assertXPathContent(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:pieChart/c:ser/c:dLbls/c:dLbl[2]/c:tx/c:rich/a:p/a:r/a:t", "kiscica");
@@ -2562,7 +2562,7 @@ void Chart2ExportTest::testCustomLabelText()
     Reference<chart2::XChartDocument> xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY);
     CPPUNIT_ASSERT(xChartDoc.is());
 
-    xmlDocPtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
+    xmlDocUniquePtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
     CPPUNIT_ASSERT(pXmlDoc);
 
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dLbls/c:dLbl[1]/c:idx", "val", "2");
@@ -2629,7 +2629,7 @@ void Chart2ExportTest::testTdf130225()
 void Chart2ExportTest::testTdf59857()
 {
     load("/chart2/qa/extras/data/ods/", "tdf59857.ods");
-    xmlDocPtr pXmlDoc = parseExport("xl/charts/chart","Calc Office Open XML");
+    xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart","Calc Office Open XML");
     CPPUNIT_ASSERT(pXmlDoc);
 
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:floor/c:spPr/a:ln/a:noFill", 1);
@@ -2641,7 +2641,7 @@ void Chart2ExportTest::testTdf59857()
 void Chart2ExportTest::testTdf126076()
 {
     load("/chart2/qa/extras/data/xlsx/", "auto_marker_excel10.xlsx");
-    xmlDocPtr pXmlDoc = parseExport("xl/charts/chart","Calc Office Open XML");
+    xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart","Calc Office Open XML");
     CPPUNIT_ASSERT(pXmlDoc);
 
     // This was 12: all series exported with square markers
@@ -2679,12 +2679,12 @@ void Chart2ExportTest::testTdf127792()
 {
     load("/chart2/qa/extras/data/docx/", "MSO_axis_position.docx");
     {
-        xmlDocPtr pXmlDoc = parseExport("word/charts/chart1", "Office Open XML Text");
+        xmlDocUniquePtr pXmlDoc = parseExport("word/charts/chart1", "Office Open XML Text");
         CPPUNIT_ASSERT(pXmlDoc);
         assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:valAx/c:crossBetween", "val", "between");
     }
     {
-        xmlDocPtr pXmlDoc = parseExport("word/charts/chart2", "Office Open XML Text");
+        xmlDocUniquePtr pXmlDoc = parseExport("word/charts/chart2", "Office Open XML Text");
         CPPUNIT_ASSERT(pXmlDoc);
         assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:valAx/c:crossBetween", "val", "midCat");
     }
@@ -2725,14 +2725,14 @@ void Chart2ExportTest::testTdf132076()
 {
     {
         load("/chart2/qa/extras/data/ods/", "tdf132076.ods");
-        xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
+        xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
         CPPUNIT_ASSERT(pXmlDoc);
         assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:catAx/c:numFmt", "formatCode", "dd");
         assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:catAx/c:numFmt", "sourceLinked", "0");
     }
     {
         load("/chart2/qa/extras/data/xlsx/", "tdf132076.xlsx");
-        xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
+        xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
         CPPUNIT_ASSERT(pXmlDoc);
         assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:dateAx/c:numFmt", "formatCode", "dd");
         assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:dateAx/c:numFmt", "sourceLinked", "0");
diff --git a/chart2/qa/extras/xshape/chart2xshape.cxx b/chart2/qa/extras/xshape/chart2xshape.cxx
index e68deadc2294..a4f24e666691 100644
--- a/chart2/qa/extras/xshape/chart2xshape.cxx
+++ b/chart2/qa/extras/xshape/chart2xshape.cxx
@@ -48,7 +48,7 @@ private:
 
     void compareAgainstReference(const OUString& rReferenceFile, bool bCreateReference = false);
     OUString getXShapeDumpString();
-    xmlDocPtr getXShapeDumpXmlDoc();
+    xmlDocUniquePtr getXShapeDumpXmlDoc();
 };
 
 namespace {
@@ -73,11 +73,11 @@ OUString Chart2XShapeTest::getXShapeDumpString()
     return xDumper->dump();
 }
 
-xmlDocPtr Chart2XShapeTest::getXShapeDumpXmlDoc()
+xmlDocUniquePtr Chart2XShapeTest::getXShapeDumpXmlDoc()
 {
     OUString rDump = getXShapeDumpString();
     OString aXmlDump = OUStringToOString(rDump, RTL_TEXTENCODING_UTF8);
-    return xmlParseDoc(reinterpret_cast<const xmlChar*>(aXmlDump.getStr()));
+    return xmlDocUniquePtr(xmlParseDoc(reinterpret_cast<const xmlChar*>(aXmlDump.getStr())));
 }
 
 void Chart2XShapeTest::compareAgainstReference(const OUString& rReferenceFile, bool bCreateReference)
@@ -173,7 +173,7 @@ void Chart2XShapeTest::testTdf76649TrendLineBug()
 
     load("chart2/qa/extras/xshape/data/ods/", "tdf76649_TrendLineBug.ods");
 
-    xmlDocPtr pXmlDoc = getXShapeDumpXmlDoc();
+    xmlDocUniquePtr pXmlDoc = getXShapeDumpXmlDoc();
 
     // Check if the regression curve exists (which means a XShape with a certain
     // name should exist in the dump)
@@ -187,7 +187,7 @@ void Chart2XShapeTest::testTdf88154LabelRotatedLayout()
     uno::Reference< qa::XDumper > xDumper( xChartDoc, UNO_QUERY_THROW );
     OUString rDump = xDumper->dump();
     OString aXmlDump = OUStringToOString(rDump, RTL_TEXTENCODING_UTF8);
-    xmlDocPtr pXmlDoc = xmlParseDoc(reinterpret_cast<const xmlChar*>(aXmlDump.getStr()));
+    xmlDocUniquePtr pXmlDoc(xmlParseDoc(reinterpret_cast<const xmlChar*>(aXmlDump.getStr())));
 
     {
         OString aPath( "//XShape[@text='Oct-12']/Transformation" );
diff --git a/drawinglayer/source/tools/primitive2dxmldump.cxx b/drawinglayer/source/tools/primitive2dxmldump.cxx
index 489161736b19..5ba531d1b1de 100644
--- a/drawinglayer/source/tools/primitive2dxmldump.cxx
+++ b/drawinglayer/source/tools/primitive2dxmldump.cxx
@@ -119,7 +119,7 @@ void Primitive2dXmlDump::dump(
     pStream->Seek(STREAM_SEEK_TO_BEGIN);
 }
 
-xmlDocPtr Primitive2dXmlDump::dumpAndParse(
+xmlDocUniquePtr Primitive2dXmlDump::dumpAndParse(
     const drawinglayer::primitive2d::Primitive2DContainer& rPrimitive2DSequence,
     const OUString& rStreamName)
 {
@@ -146,9 +146,8 @@ xmlDocPtr Primitive2dXmlDump::dumpAndParse(
     pStream->ReadBytes(pBuffer.get(), nSize);
     pBuffer[nSize] = 0;
     SAL_INFO("drawinglayer", "Parsed XML: " << pBuffer.get());
-    xmlDocPtr pDoc = xmlParseDoc(reinterpret_cast<xmlChar*>(pBuffer.get()));
 
-    return pDoc;
+    return xmlDocUniquePtr(xmlParseDoc(reinterpret_cast<xmlChar*>(pBuffer.get())));
 }
 
 void Primitive2dXmlDump::decomposeAndWrite(
diff --git a/emfio/qa/cppunit/emf/EmfImportTest.cxx b/emfio/qa/cppunit/emf/EmfImportTest.cxx
index 636216a79fc2..ac435905d570 100644
--- a/emfio/qa/cppunit/emf/EmfImportTest.cxx
+++ b/emfio/qa/cppunit/emf/EmfImportTest.cxx
@@ -77,7 +77,7 @@ Primitive2DSequence Test::parseEmf(const OUString& aSource)
 void Test::checkRectPrimitive(Primitive2DSequence const & rPrimitive)
 {
     drawinglayer::tools::Primitive2dXmlDump dumper;
-    xmlDocPtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer<Primitive2DContainer>(rPrimitive));
+    xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer<Primitive2DContainer>(rPrimitive));
 
     CPPUNIT_ASSERT (pDocument);
 
@@ -104,7 +104,7 @@ void Test::TestDrawString()
     Primitive2DSequence aSequence = parseEmf("/emfio/qa/cppunit/emf/data/TestDrawString.emf");
     CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequence.getLength()));
     drawinglayer::tools::Primitive2dXmlDump dumper;
-    xmlDocPtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer<Primitive2DContainer>(aSequence));
+    xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer<Primitive2DContainer>(aSequence));
     CPPUNIT_ASSERT (pDocument);
 
     // check correct import of the DrawString: height, position, text, color and font
@@ -126,7 +126,7 @@ void Test::TestDrawStringTransparent()
     Primitive2DSequence aSequence = parseEmf("/emfio/qa/cppunit/emf/data/TestDrawStringTransparent.emf");
     CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequence.getLength()));
     drawinglayer::tools::Primitive2dXmlDump dumper;
-    xmlDocPtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer<Primitive2DContainer>(aSequence));
+    xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer<Primitive2DContainer>(aSequence));
     CPPUNIT_ASSERT (pDocument);
 
     assertXPath(pDocument, "/primitive2D/metafile/transform/mask/transform/unifiedtransparence", "transparence", "0.498039215686275");
@@ -149,7 +149,7 @@ void Test::TestDrawLine()
     Primitive2DSequence aSequence = parseEmf("/emfio/qa/cppunit/emf/data/TestDrawLine.emf");
     CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequence.getLength()));
     drawinglayer::tools::Primitive2dXmlDump dumper;
-    xmlDocPtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer<Primitive2DContainer>(aSequence));
+    xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer<Primitive2DContainer>(aSequence));
     CPPUNIT_ASSERT (pDocument);
 
     // check correct import of the DrawLine: color and width of the line
@@ -163,7 +163,7 @@ void Test::TestLinearGradient()
     Primitive2DSequence aSequence = parseEmf("/emfio/qa/cppunit/emf/data/TestLinearGradient.emf");
     CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequence.getLength()));
     drawinglayer::tools::Primitive2dXmlDump dumper;
-    xmlDocPtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer<Primitive2DContainer>(aSequence));
+    xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer<Primitive2DContainer>(aSequence));
     CPPUNIT_ASSERT (pDocument);
 
     assertXPath(pDocument, "/primitive2D/metafile/transform", "xy11", "1.0000656512605");
diff --git a/emfio/qa/cppunit/wmf/wmfimporttest.cxx b/emfio/qa/cppunit/wmf/wmfimporttest.cxx
index 5d3c3b772de5..5dfcfdad2041 100644
--- a/emfio/qa/cppunit/wmf/wmfimporttest.cxx
+++ b/emfio/qa/cppunit/wmf/wmfimporttest.cxx
@@ -73,7 +73,7 @@ void WmfTest::testNonPlaceableWmf()
     MetafileXmlDump dumper;
     dumper.filterAllActionTypes();
     dumper.filterActionType(MetaActionType::POLYLINE, false);
-    xmlDocPtr pDoc = dumpAndParse(dumper, aGDIMetaFile);
+    xmlDocUniquePtr pDoc = dumpAndParse(dumper, aGDIMetaFile);
 
     CPPUNIT_ASSERT(pDoc);
 
@@ -102,7 +102,7 @@ void WmfTest::testSine()
     MetafileXmlDump dumper;
     dumper.filterAllActionTypes();
     dumper.filterActionType(MetaActionType::ISECTRECTCLIPREGION, false);
-    xmlDocPtr pDoc = dumpAndParse(dumper, aGDIMetaFile);
+    xmlDocUniquePtr pDoc = dumpAndParse(dumper, aGDIMetaFile);
 
     CPPUNIT_ASSERT(pDoc);
 
@@ -118,7 +118,7 @@ void WmfTest::testEmfProblem()
     MetafileXmlDump dumper;
     dumper.filterAllActionTypes();
     dumper.filterActionType(MetaActionType::ISECTRECTCLIPREGION, false);
-    xmlDocPtr pDoc = dumpAndParse(dumper, aGDIMetaFile);
+    xmlDocUniquePtr pDoc = dumpAndParse(dumper, aGDIMetaFile);
 
     CPPUNIT_ASSERT(pDoc);
 
@@ -138,7 +138,7 @@ void WmfTest::testEmfLineStyles()
     dumper.filterAllActionTypes();
     dumper.filterActionType(MetaActionType::LINE, false);
     dumper.filterActionType(MetaActionType::LINECOLOR, false);
-    xmlDocPtr pDoc = dumpAndParse(dumper, aGDIMetaFile);
+    xmlDocUniquePtr pDoc = dumpAndParse(dumper, aGDIMetaFile);
 
     CPPUNIT_ASSERT(pDoc);
 
@@ -197,7 +197,7 @@ void WmfTest::testWorldTransformFontSize()
     MetafileXmlDump dumper;
     dumper.filterAllActionTypes();
     dumper.filterActionType(MetaActionType::FONT, false);
-    xmlDocPtr pDoc = dumpAndParse(dumper, aGDIMetaFile);
+    xmlDocUniquePtr pDoc = dumpAndParse(dumper, aGDIMetaFile);
 
     CPPUNIT_ASSERT(pDoc);
 
@@ -225,7 +225,7 @@ void WmfTest::testTdf93750()
     ReadWindowMetafile(aFileStream, aGDIMetaFile);
 
     MetafileXmlDump dumper;
-    xmlDocPtr pDoc = dumpAndParse(dumper, aGDIMetaFile);
+    xmlDocUniquePtr pDoc = dumpAndParse(dumper, aGDIMetaFile);
 
     CPPUNIT_ASSERT(pDoc);
 
@@ -264,7 +264,7 @@ void WmfTest::testTdf39894()
         ReadWindowMetafile(aFileStream, aGDIMetaFile);
 
         MetafileXmlDump dumper;
-        xmlDocPtr pDoc = dumpAndParse(dumper, aGDIMetaFile);
+        xmlDocUniquePtr pDoc = dumpAndParse(dumper, aGDIMetaFile);
 
         CPPUNIT_ASSERT(pDoc);
 
@@ -285,7 +285,7 @@ void WmfTest::testETO_PDY()
         ReadWindowMetafile(aFileStream, aGDIMetaFile);
 
         MetafileXmlDump dumper;
-        xmlDocPtr pDoc = dumpAndParse(dumper, aGDIMetaFile);
+        xmlDocUniquePtr pDoc = dumpAndParse(dumper, aGDIMetaFile);
 
         CPPUNIT_ASSERT(pDoc);
 
diff --git a/filter/qa/cppunit/filters-pict-test.cxx b/filter/qa/cppunit/filters-pict-test.cxx
index 1fd6ae8e37a0..7b62c71b9d32 100644
--- a/filter/qa/cppunit/filters-pict-test.cxx
+++ b/filter/qa/cppunit/filters-pict-test.cxx
@@ -83,7 +83,7 @@ void PictFilterTest::testDontClipTooMuch()
     MetafileXmlDump dumper;
     dumper.filterAllActionTypes();
     dumper.filterActionType(MetaActionType::CLIPREGION, false);
-    xmlDocPtr pDoc = dumpAndParse(dumper, aGDIMetaFile);
+    xmlDocUniquePtr pDoc = dumpAndParse(dumper, aGDIMetaFile);
 
     CPPUNIT_ASSERT (pDoc);
 
diff --git a/filter/qa/unit/svg.cxx b/filter/qa/unit/svg.cxx
index 8e6524c688ba..9651881826c9 100644
--- a/filter/qa/unit/svg.cxx
+++ b/filter/qa/unit/svg.cxx
@@ -83,7 +83,7 @@ CPPUNIT_TEST_FIXTURE(SvgFilterTest, testPreserveJpg)
     aStream.Seek(STREAM_SEEK_TO_BEGIN);
 
     // Make sure that the original JPG data is reused and we don't perform a PNG re-compress.
-    xmlDocPtr pXmlDoc = parseXmlStream(&aStream);
+    xmlDocUniquePtr pXmlDoc = parseXmlStream(&aStream);
     OUString aAttributeValue = getXPath(pXmlDoc, "//svg:image", "href");
 
     // Without the accompanying fix in place, this test would have failed with:
@@ -110,7 +110,7 @@ CPPUNIT_TEST_FIXTURE(SvgFilterTest, testSemiTransparentLine)
     aStream.Seek(STREAM_SEEK_TO_BEGIN);
 
     // Get the style of the group around the actual <path> element.
-    xmlDocPtr pXmlDoc = parseXmlStream(&aStream);
+    xmlDocUniquePtr pXmlDoc = parseXmlStream(&aStream);
     OUString aStyle = getXPath(
         pXmlDoc, "//svg:g[@class='com.sun.star.drawing.LineShape']/svg:g/svg:g", "style");
     OUString aPrefix("opacity: ");
diff --git a/include/drawinglayer/tools/primitive2dxmldump.hxx b/include/drawinglayer/tools/primitive2dxmldump.hxx
index 3158f537262e..f8712db35fb2 100644
--- a/include/drawinglayer/tools/primitive2dxmldump.hxx
+++ b/include/drawinglayer/tools/primitive2dxmldump.hxx
@@ -14,6 +14,7 @@
 #include <drawinglayer/drawinglayerdllapi.h>
 #include <libxml/tree.h>
 #include <drawinglayer/primitive2d/baseprimitive2d.hxx>
+#include <test/xmldocptr.hxx>
 #include <vector>
 
 namespace tools { class XmlWriter; }
@@ -38,7 +39,7 @@ public:
      * into a memory stream.
      *
      */
-    xmlDocPtr dumpAndParse(const drawinglayer::primitive2d::Primitive2DContainer& aPrimitive2DSequence, const OUString& rStreamName = OUString());
+    xmlDocUniquePtr dumpAndParse(const drawinglayer::primitive2d::Primitive2DContainer& aPrimitive2DSequence, const OUString& rStreamName = OUString());
 
     /** Dumps the input primitive sequence to xml into a file. */
     void dump(const drawinglayer::primitive2d::Primitive2DContainer& rPrimitive2DSequence, const OUString& rStreamName);
diff --git a/include/test/htmltesttools.hxx b/include/test/htmltesttools.hxx
index e7bb85305227..fa5722075f87 100644
--- a/include/test/htmltesttools.hxx
+++ b/include/test/htmltesttools.hxx
@@ -12,17 +12,20 @@
 
 #include <sal/config.h>
 #include <test/testdllapi.hxx>
+#include <test/xmltesttools.hxx>
 
 #include <libxml/HTMLparser.h>
 #include <libxml/HTMLtree.h>
 
 #include <unotools/tempfile.hxx>
 
+using htmlDocUniquePtr = xmlDocUniquePtr;
+
 class OOO_DLLPUBLIC_TEST HtmlTestTools
 {
 protected:
-    static htmlDocPtr parseHtml(utl::TempFile const & aTempFile);
-    static htmlDocPtr parseHtmlStream(SvStream* pStream);
+    static htmlDocUniquePtr parseHtml(utl::TempFile const & aTempFile);
+    static htmlDocUniquePtr parseHtmlStream(SvStream* pStream);
 };
 
 #endif
diff --git a/include/test/xmldocptr.hxx b/include/test/xmldocptr.hxx
new file mode 100644
index 000000000000..abca72633c61
--- /dev/null
+++ b/include/test/xmldocptr.hxx
@@ -0,0 +1,19 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+#pragma once
+
+#include <memory>
+
+struct xmlDocDeleter
+{
+    void operator()(xmlDoc* p) { xmlFreeDoc(p); }
+};
+using xmlDocUniquePtr = std::unique_ptr<xmlDoc, xmlDocDeleter>;
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/include/test/xmltesttools.hxx b/include/test/xmltesttools.hxx
index f8f10da387bd..a2c08d7dc0e8 100644
--- a/include/test/xmltesttools.hxx
+++ b/include/test/xmltesttools.hxx
@@ -23,6 +23,7 @@
 #include <rtl/ustring.hxx>
 #include <unotools/tempfile.hxx>
 #include <vcl/mtfxmldump.hxx>
+#include <test/xmldocptr.hxx>
 
 #include <cppunit/TestAssert.h>
 
@@ -32,68 +33,68 @@ class OOO_DLLPUBLIC_TEST XmlTestTools
 {
 public:
     /// Return xmlDocPtr representation of the XML stream read from pStream.
-    static xmlDocPtr parseXmlStream(SvStream* pStream);
+    static xmlDocUniquePtr parseXmlStream(SvStream* pStream);
 
-    static xmlDocPtr dumpAndParse(MetafileXmlDump& rDumper, const GDIMetaFile& rGDIMetaFile);
+    static xmlDocUniquePtr dumpAndParse(MetafileXmlDump& rDumper, const GDIMetaFile& rGDIMetaFile);
 
 protected:
     XmlTestTools();
     virtual ~XmlTestTools();
 
-    static xmlDocPtr parseXml(utl::TempFile const & aTempFile);
+    static xmlDocUniquePtr parseXml(utl::TempFile const & aTempFile);
 
     virtual void registerNamespaces(xmlXPathContextPtr& pXmlXpathCtx);
 
     // Caller must call xmlXPathFreeObject:
-    xmlXPathObjectPtr getXPathNode(xmlDocPtr pXmlDoc, const OString& rXPath);
+    xmlXPathObjectPtr getXPathNode(const xmlDocUniquePtr& pXmlDoc, const OString& rXPath);
     /**
      * Same as the assertXPath(), but don't assert: return the string instead.
      */
-    OUString      getXPath(xmlDocPtr pXmlDoc, const OString& rXPath, const OString& rAttribute);
+    OUString      getXPath(const xmlDocUniquePtr& pXmlDoc, const OString& rXPath, const OString& rAttribute);
     /**
      * Same as the assertXPathContent(), but don't assert: return the string instead.
      */
-    OUString      getXPathContent(xmlDocPtr pXmlDoc, const OString& rXPath);
+    OUString      getXPathContent(const xmlDocUniquePtr& pXmlDoc, const OString& rXPath);
     /**
      * Get the position of the child named rName of the parent node specified by rXPath.
      * Useful for checking relative order of elements.
      */
-    int           getXPathPosition(xmlDocPtr pXmlDoc, const OString& rXPath, const OString& rChildName);
+    int           getXPathPosition(const xmlDocUniquePtr& pXmlDoc, const OString& rXPath, const OString& rChildName);
     /**
      * Assert that rXPath exists, and returns exactly one node.
      */
-    void          assertXPath(xmlDocPtr pXmlDoc, const OString& rXPath);
+    void          assertXPath(const xmlDocUniquePtr& pXmlDoc, const OString& rXPath);
     /**
      * Assert that rXPath exists, returns exactly one node, and the rXPath's attribute's value
      * equals to the rExpected value.
      */
-    void          assertXPath(xmlDocPtr pXmlDoc, const OString& rXPath, const OString& rAttribute,
+    void          assertXPath(const xmlDocUniquePtr& pXmlDoc, const OString& rXPath, const OString& rAttribute,
                               const OUString& rExpectedValue);
-    void          assertXPathAttrs(xmlDocPtr pXmlDoc, const OString& rXPath,
+    void          assertXPathAttrs(const xmlDocUniquePtr& pXmlDoc, const OString& rXPath,
                           const std::vector<std::pair<OString, OUString>>& aPairVector);
     /**
      * Assert that rXPath exists, and returns exactly nNumberOfNodes nodes.
      * Useful for checking that we do _not_ export some node (nNumberOfNodes == 0).
      */
-    void          assertXPath(xmlDocPtr pXmlDoc, const OString& rXPath, int nNumberOfNodes);
+    void          assertXPath(const xmlDocUniquePtr& pXmlDoc, const OString& rXPath, int nNumberOfNodes);
     /**
      * Assert that rXPath exists, and its content equals rContent.
      */
-    void          assertXPathContent(xmlDocPtr pXmlDoc, const OString& rXPath, const OUString& rContent);
+    void          assertXPathContent(const xmlDocUniquePtr& pXmlDoc, const OString& rXPath, const OUString& rContent);
     /**
      * Assert that rXPath exists and it has an rNSPrefix=rNSHref namespace definition.
      */
-    void assertXPathNSDef(xmlDocPtr pXmlDoc, const OString& rXPath, const OUString& rNSPrefix,
+    void          assertXPathNSDef(const xmlDocUniquePtr& pXmlDoc, const OString& rXPath, const OUString& rNSPrefix,
                           const OUString& rNSHref);
     /**
      * Assert that rXPath exists, and has exactly nNumberOfChildNodes child nodes.
      * Useful for checking that we do have a no child nodes to a specific node (nNumberOfChildNodes == 0).
      */
-    void          assertXPathChildren(xmlDocPtr pXmlDoc, const OString& rXPath, int nNumberOfChildNodes);
+    void          assertXPathChildren(const xmlDocUniquePtr& pXmlDoc, const OString& rXPath, int nNumberOfChildNodes);
     /**
      * Assert that rXPath exists, has exactly 1 child node and does *not* have an attribute named rAttribute.
      */
-    void          assertXPathNoAttribute(xmlDocPtr pXmlDoc, const OString& rXPath, const OString& rAttribute);
+    void          assertXPathNoAttribute(const xmlDocUniquePtr& pXmlDoc, const OString& rXPath, const OString& rAttribute);
 
 };
 
diff --git a/sc/qa/extras/htmlexporttest.cxx b/sc/qa/extras/htmlexporttest.cxx
index 37aa69e4a4f9..d7bbb7038fa4 100644
--- a/sc/qa/extras/htmlexporttest.cxx
+++ b/sc/qa/extras/htmlexporttest.cxx
@@ -73,7 +73,7 @@ public:
         OUString const url(aTempDir.GetURL());
         TempFile aTempFile(&url, false);
 
-        htmlDocPtr pDoc;
+        htmlDocUniquePtr pDoc;
 
         load("/sc/qa/extras/testdocuments/", "BaseForHTMLExport.ods");
         save("HTML (StarCalc)", aTempFile);
diff --git a/sc/qa/unit/helper/xpath.cxx b/sc/qa/unit/helper/xpath.cxx
index 99095798939d..39f9b36e9ed0 100644
--- a/sc/qa/unit/helper/xpath.cxx
+++ b/sc/qa/unit/helper/xpath.cxx
@@ -19,7 +19,7 @@
 
 #include <com/sun/star/packages/zip/ZipFileAccess.hpp>
 
-xmlDocPtr XPathHelper::parseExport2(ScBootstrapFixture & rFixture, ScDocShell& rShell, uno::Reference<lang::XMultiServiceFactory> const & xSFactory, const OUString& rFile, sal_Int32 nFormat)
+xmlDocUniquePtr XPathHelper::parseExport2(ScBootstrapFixture & rFixture, ScDocShell& rShell, uno::Reference<lang::XMultiServiceFactory> const & xSFactory, const OUString& rFile, sal_Int32 nFormat)
 {
     std::shared_ptr<utl::TempFile> pTempFile = rFixture.exportTo(&rShell, nFormat);
 
@@ -36,7 +36,7 @@ std::unique_ptr<SvStream> XPathHelper::parseExportStream(std::shared_ptr<utl::Te
     return pStream;
 }
 
-xmlDocPtr XPathHelper::parseExport(std::shared_ptr<utl::TempFile> const & pTempFile, uno::Reference<lang::XMultiServiceFactory> const & xSFactory, const OUString& rFile)
+xmlDocUniquePtr XPathHelper::parseExport(std::shared_ptr<utl::TempFile> const & pTempFile, uno::Reference<lang::XMultiServiceFactory> const & xSFactory, const OUString& rFile)
 {
     std::unique_ptr<SvStream> pStream = parseExportStream(pTempFile, xSFactory, rFile);
     return XmlTestTools::parseXmlStream(pStream.get());
diff --git a/sc/qa/unit/helper/xpath.hxx b/sc/qa/unit/helper/xpath.hxx
index d46e2e85da80..6ef4e01a67cf 100644
--- a/sc/qa/unit/helper/xpath.hxx
+++ b/sc/qa/unit/helper/xpath.hxx
@@ -15,6 +15,7 @@
 #include <rtl/ustring.hxx>
 #include <sal/types.h>
 #include "scqahelperdllapi.h"
+#include <test/xmltesttools.hxx>
 
 #include <memory>
 
@@ -40,7 +41,7 @@ namespace XPathHelper
      *      test several files in the same exported xml file you need to export the file manually
      *      and call the parseExport method that takes a TempFile
      */
-    SCQAHELPER_DLLPUBLIC xmlDocPtr parseExport2(ScBootstrapFixture &, ScDocShell& rShell, uno::Reference< lang::XMultiServiceFactory> const & xSFactory,
+    SCQAHELPER_DLLPUBLIC xmlDocUniquePtr parseExport2(ScBootstrapFixture &, ScDocShell& rShell, uno::Reference< lang::XMultiServiceFactory> const & xSFactory,
             const OUString& rFile, sal_Int32 nFormat);
 
     /**
@@ -55,7 +56,7 @@ namespace XPathHelper
      * Should be used when the same exported file is used for testing different files in
      * the same zip file.
      */
-    SCQAHELPER_DLLPUBLIC xmlDocPtr parseExport(std::shared_ptr<utl::TempFile> const & pTempFile, uno::Reference< lang::XMultiServiceFactory> const & xSFactory,
+    SCQAHELPER_DLLPUBLIC xmlDocUniquePtr parseExport(std::shared_ptr<utl::TempFile> const & pTempFile, uno::Reference< lang::XMultiServiceFactory> const & xSFactory,
             const OUString& rFile);
 }
 
diff --git a/sc/qa/unit/pivottable_filters_test.cxx b/sc/qa/unit/pivottable_filters_test.cxx
index 5e4efe06a447..ff9df79980b5 100644
--- a/sc/qa/unit/pivottable_filters_test.cxx
+++ b/sc/qa/unit/pivottable_filters_test.cxx
@@ -780,7 +780,7 @@ void ScPivotTableFiltersTest::testPivotTableExportXLSX()
 
     std::shared_ptr<utl::TempFile> pXPathFile
         = ScBootstrapFixture::exportTo(&(*xShell), FORMAT_XLSX);
-    xmlDocPtr pTable
+    xmlDocUniquePtr pTable
         = XPathHelper::parseExport(pXPathFile, m_xSFactory, "xl/pivotTables/pivotTable1.xml");
     CPPUNIT_ASSERT(pTable);
 
@@ -800,7 +800,7 @@ void ScPivotTableFiltersTest::testPivotTableExportXLSXSingleDataField()
 
     std::shared_ptr<utl::TempFile> pXPathFile
         = ScBootstrapFixture::exportTo(&(*xShell), FORMAT_XLSX);
-    xmlDocPtr pTable
+    xmlDocUniquePtr pTable
         = XPathHelper::parseExport(pXPathFile, m_xSFactory, "xl/pivotTables/pivotTable1.xml");
     CPPUNIT_ASSERT(pTable);
 
@@ -824,7 +824,7 @@ void ScPivotTableFiltersTest::testPivotTableExportXLSXMultipleDataFields()
 
     std::shared_ptr<utl::TempFile> pXPathFile
         = ScBootstrapFixture::exportTo(&(*xShell), FORMAT_XLSX);
-    xmlDocPtr pTable
+    xmlDocUniquePtr pTable
         = XPathHelper::parseExport(pXPathFile, m_xSFactory, "xl/pivotTables/pivotTable1.xml");
     CPPUNIT_ASSERT(pTable);
 
@@ -859,7 +859,7 @@ void ScPivotTableFiltersTest::testPivotCacheExportXLSX()
 
     std::shared_ptr<utl::TempFile> pXPathFile
         = ScBootstrapFixture::exportTo(&(*xShell), FORMAT_XLSX);
-    xmlDocPtr pCacheDef = XPathHelper::parseExport(pXPathFile, m_xSFactory,
+    xmlDocUniquePtr pCacheDef = XPathHelper::parseExport(pXPathFile, m_xSFactory,
                                                    "xl/pivotCache/pivotCacheDefinition1.xml");
     CPPUNIT_ASSERT(pCacheDef);
 
@@ -1949,7 +1949,7 @@ void ScPivotTableFiltersTest::testPivotTableFirstHeaderRowXLSX()
 
     std::shared_ptr<utl::TempFile> pXPathFile
         = ScBootstrapFixture::exportTo(&(*xShell), FORMAT_XLSX);
-    xmlDocPtr pTable
+    xmlDocUniquePtr pTable
         = XPathHelper::parseExport(pXPathFile, m_xSFactory, "xl/pivotTables/pivotTable1.xml");
     CPPUNIT_ASSERT(pTable);
     assertXPath(pTable, "/x:pivotTableDefinition/x:location", "firstHeaderRow", "1");
@@ -2332,7 +2332,7 @@ void ScPivotTableFiltersTest::testPivotTableOutlineModeXLSX()
 
     std::shared_ptr<utl::TempFile> pXPathFile
         = ScBootstrapFixture::exportTo(&(*xShell), FORMAT_XLSX);
-    xmlDocPtr pTable
+    xmlDocUniquePtr pTable
         = XPathHelper::parseExport(pXPathFile, m_xSFactory, "xl/pivotTables/pivotTable1.xml");
     CPPUNIT_ASSERT(pTable);
 
@@ -2353,7 +2353,7 @@ void ScPivotTableFiltersTest::testPivotTableDuplicatedMemberFilterXLSX()
 
     std::shared_ptr<utl::TempFile> pXPathFile
         = ScBootstrapFixture::exportTo(&(*xShell), FORMAT_XLSX);
-    xmlDocPtr pTable
+    xmlDocUniquePtr pTable
         = XPathHelper::parseExport(pXPathFile, m_xSFactory, "xl/pivotTables/pivotTable1.xml");
     CPPUNIT_ASSERT(pTable);
 
@@ -2373,7 +2373,7 @@ void ScPivotTableFiltersTest::testPivotTableTabularModeXLSX()
 
     std::shared_ptr<utl::TempFile> pXPathFile
         = ScBootstrapFixture::exportTo(&(*xShell), FORMAT_XLSX);
-    xmlDocPtr pTable
+    xmlDocUniquePtr pTable
         = XPathHelper::parseExport(pXPathFile, m_xSFactory, "xl/pivotTables/pivotTable1.xml");
     CPPUNIT_ASSERT(pTable);
 
@@ -2395,7 +2395,7 @@ void ScPivotTableFiltersTest::testPivotTableDuplicateFields()
 
     std::shared_ptr<utl::TempFile> pXPathFile
         = ScBootstrapFixture::exportTo(&(*xShell), FORMAT_XLSX);
-    xmlDocPtr pCacheDef
+    xmlDocUniquePtr pCacheDef
         = XPathHelper::parseExport(pXPathFile, m_xSFactory, "xl/pivotCache/pivotCacheDefinition1.xml");
     CPPUNIT_ASSERT(pCacheDef);
 
@@ -2448,7 +2448,7 @@ void ScPivotTableFiltersTest::testTdf123923()
 
     std::shared_ptr<utl::TempFile> pXPathFile
         = ScBootstrapFixture::exportTo(&(*xShell), FORMAT_XLSX);
-    xmlDocPtr pTable = XPathHelper::parseExport(pXPathFile, m_xSFactory,
+    xmlDocUniquePtr pTable = XPathHelper::parseExport(pXPathFile, m_xSFactory,
                                                 "xl/pivotCache/pivotCacheDefinition1.xml");
     CPPUNIT_ASSERT(pTable);
 
@@ -2465,7 +2465,7 @@ void ScPivotTableFiltersTest::testTdf123939()
 
     std::shared_ptr<utl::TempFile> pXPathFile
         = ScBootstrapFixture::exportTo(&(*xShell), FORMAT_XLSX);
-    xmlDocPtr pTable = XPathHelper::parseExport(pXPathFile, m_xSFactory,
+    xmlDocUniquePtr pTable = XPathHelper::parseExport(pXPathFile, m_xSFactory,
                                                 "xl/pivotCache/pivotCacheDefinition1.xml");
     CPPUNIT_ASSERT(pTable);
 
@@ -2488,7 +2488,7 @@ void ScPivotTableFiltersTest::testTdf124651()
     ScDocShellRef xDocSh = loadDoc("tdf124651_simplePivotTable.", FORMAT_ODS);
     CPPUNIT_ASSERT(xDocSh.is());
 
-    xmlDocPtr pDoc = XPathHelper::parseExport2(*this, *xDocSh, m_xSFactory,
+    xmlDocUniquePtr pDoc = XPathHelper::parseExport2(*this, *xDocSh, m_xSFactory,
         "xl/pivotTables/pivotTable1.xml", FORMAT_XLSX);
     CPPUNIT_ASSERT(pDoc);
     // We have to export name attribute, even though it's optional according to ECMA-376 standard,
@@ -2506,7 +2506,7 @@ void ScPivotTableFiltersTest::testTdf124736()
         = ScBootstrapFixture::exportTo(xDocSh.get(), FORMAT_XLSX);
     xDocSh->DoClose();
 
-    xmlDocPtr pTable = XPathHelper::parseExport(pXPathFile, m_xSFactory,
+    xmlDocUniquePtr pTable = XPathHelper::parseExport(pXPathFile, m_xSFactory,
                                                 "xl/pivotCache/pivotCacheDefinition1.xml");
     CPPUNIT_ASSERT(pTable);
 
@@ -2560,7 +2560,7 @@ void ScPivotTableFiltersTest::tesTtdf124772NumFmt()
         = ScBootstrapFixture::exportTo(xDocSh.get(), FORMAT_XLSX);
     xDocSh->DoClose();
 
-    xmlDocPtr pTable
+    xmlDocUniquePtr pTable
         = XPathHelper::parseExport(pXPathFile, m_xSFactory, "xl/pivotTables/pivotTable1.xml");
     CPPUNIT_ASSERT(pTable);
 
@@ -2583,7 +2583,7 @@ void ScPivotTableFiltersTest::testTdf124810()
         ScDocShellRef xDocSh = loadDoc("pivot_dark1.", FORMAT_XLSX);
         CPPUNIT_ASSERT(xDocSh.is());
 
-        xmlDocPtr pTable = XPathHelper::parseExport2(*this, *xDocSh, m_xSFactory,
+        xmlDocUniquePtr pTable = XPathHelper::parseExport2(*this, *xDocSh, m_xSFactory,
             "xl/pivotTables/pivotTable1.xml", FORMAT_XLSX);
         xDocSh->DoClose();
         CPPUNIT_ASSERT(pTable);
@@ -2605,7 +2605,7 @@ void ScPivotTableFiltersTest::testTdf124810()
         ScDocShellRef xDocSh = loadDoc("tdf124651_simplePivotTable.", FORMAT_ODS);
         CPPUNIT_ASSERT(xDocSh.is());
 
-        xmlDocPtr pTable = XPathHelper::parseExport2(*this, *xDocSh, m_xSFactory,
+        xmlDocUniquePtr pTable = XPathHelper::parseExport2(*this, *xDocSh, m_xSFactory,
             "xl/pivotTables/pivotTable1.xml", FORMAT_XLSX);
         xDocSh->DoClose();
         CPPUNIT_ASSERT(pTable);
@@ -2626,7 +2626,7 @@ void ScPivotTableFiltersTest::testTdf124883()
     ScDocShellRef xDocSh = loadDoc("pivot-table/two-data-fields.", FORMAT_XLSX);
     CPPUNIT_ASSERT(xDocSh.is());
 
-    xmlDocPtr pTable = XPathHelper::parseExport2(*this, *xDocSh, m_xSFactory,
+    xmlDocUniquePtr pTable = XPathHelper::parseExport2(*this, *xDocSh, m_xSFactory,
         "xl/pivotTables/pivotTable1.xml", FORMAT_XLSX);
     xDocSh->DoClose();
     CPPUNIT_ASSERT(pTable);
@@ -2643,7 +2643,7 @@ void ScPivotTableFiltersTest::testTdf125046()
     ScDocShellRef xDocSh = loadDoc("pivottable_long_text.", FORMAT_XLSX);
     CPPUNIT_ASSERT(xDocSh.is());
 
-    xmlDocPtr pDoc = XPathHelper::parseExport2(
+    xmlDocUniquePtr pDoc = XPathHelper::parseExport2(
         *this, *xDocSh, m_xSFactory, "xl/pivotCache/pivotCacheDefinition1.xml", FORMAT_XLSX);
     CPPUNIT_ASSERT(pDoc);
     assertXPath(pDoc, "/x:pivotCacheDefinition/x:cacheFields/x:cacheField[2]/x:sharedItems",
@@ -2655,7 +2655,7 @@ void ScPivotTableFiltersTest::testTdf125055()
     ScDocShellRef xDocSh = loadDoc("pivottable_1s_difference.", FORMAT_XLSX);
     CPPUNIT_ASSERT(xDocSh.is());
 
-    xmlDocPtr pDoc = XPathHelper::parseExport2(
+    xmlDocUniquePtr pDoc = XPathHelper::parseExport2(
         *this, *xDocSh, m_xSFactory, "xl/pivotCache/pivotCacheDefinition1.xml", FORMAT_XLSX);
     CPPUNIT_ASSERT(pDoc);
 
@@ -2691,7 +2691,7 @@ void ScPivotTableFiltersTest::testTdf125086()
     ScDocShellRef xDocSh = loadDoc("pivottable_fieldInRowsAndData.", FORMAT_ODS);
     CPPUNIT_ASSERT(xDocSh.is());
 
-    xmlDocPtr pDoc = XPathHelper::parseExport2(*this, *xDocSh, m_xSFactory,
+    xmlDocUniquePtr pDoc = XPathHelper::parseExport2(*this, *xDocSh, m_xSFactory,
                                                "xl/pivotTables/pivotTable1.xml", FORMAT_XLSX);
     CPPUNIT_ASSERT(pDoc);
     assertXPath(pDoc, "/x:pivotTableDefinition/x:pivotFields/x:pivotField[2]", "axis", "axisRow");
diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx
index 260a353884d1..4a7a3d5172ac 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -498,7 +498,7 @@ void ScExportTest::testTdf111876()
     ScDocShellRef xDocSh = saveAndReload(&(*xShell), FORMAT_XLSX);
     CPPUNIT_ASSERT(xDocSh.is());
 
-    xmlDocPtr pDoc = XPathHelper::parseExport2(*this, *xDocSh, m_xSFactory, "xl/worksheets/_rels/sheet1.xml.rels", FORMAT_XLSX);
+    xmlDocUniquePtr pDoc = XPathHelper::parseExport2(*this, *xDocSh, m_xSFactory, "xl/worksheets/_rels/sheet1.xml.rels", FORMAT_XLSX);
     CPPUNIT_ASSERT(pDoc);
     OUString sTarget = getXPath(pDoc, "/r:Relationships/r:Relationship", "Target");
 
@@ -643,7 +643,7 @@ void ScExportTest::testProtectionKeyODS_UTF16LErtlSHA1()
     // we can't assume that the user entered the password; check that we
     // round-trip the password as-is
     std::shared_ptr<utl::TempFile> pXPathFile = ScBootstrapFixture::exportTo(&(*xShell), FORMAT_ODS);
-    xmlDocPtr pXmlDoc = XPathHelper::parseExport(pXPathFile, m_xSFactory, "content.xml");
+    xmlDocUniquePtr pXmlDoc = XPathHelper::parseExport(pXPathFile, m_xSFactory, "content.xml");
     assertXPath(pXmlDoc, "//office:spreadsheet[@table:structure-protected='true' and @table:protection-key='vbnhxyBKtPHCA1wB21zG1Oha8ZA=' and @table:protection-key-digest-algorithm='http://www.w3.org/2000/09/xmldsig#sha1']");
     assertXPath(pXmlDoc, "//table:table[@table:protected='true' and @table:protection-key='vbnhxyBKtPHCA1wB21zG1Oha8ZA=' and @table:protection-key-digest-algorithm='http://www.w3.org/2000/09/xmldsig#sha1']");
 
@@ -666,7 +666,7 @@ void ScExportTest::testProtectionKeyODS_UTF8SHA1()
     // we can't assume that the user entered the password; check that we
     // round-trip the password as-is
     std::shared_ptr<utl::TempFile> pXPathFile = ScBootstrapFixture::exportTo(&(*xShell), FORMAT_ODS);
-    xmlDocPtr pXmlDoc = XPathHelper::parseExport(pXPathFile, m_xSFactory, "content.xml");
+    xmlDocUniquePtr pXmlDoc = XPathHelper::parseExport(pXPathFile, m_xSFactory, "content.xml");
     assertXPath(pXmlDoc, "//office:spreadsheet[@table:structure-protected='true' and @table:protection-key='nLHas0RIwepGDaH4c2hpyIUvIS8=' and @table:protection-key-digest-algorithm='http://www.w3.org/2000/09/xmldsig#sha1']");
     assertXPath(pXmlDoc, "//table:table[@table:protected='true' and @table:protection-key='nLHas0RIwepGDaH4c2hpyIUvIS8=' and @table:protection-key-digest-algorithm='http://www.w3.org/2000/09/xmldsig#sha1']");
 
@@ -689,7 +689,7 @@ void ScExportTest::testProtectionKeyODS_UTF8SHA256ODF12()
     // we can't assume that the user entered the password; check that we
     // round-trip the password as-is
     std::shared_ptr<utl::TempFile> pXPathFile = ScBootstrapFixture::exportTo(&(*xShell), FORMAT_ODS);
-    xmlDocPtr pXmlDoc = XPathHelper::parseExport(pXPathFile, m_xSFactory, "content.xml");
+    xmlDocUniquePtr pXmlDoc = XPathHelper::parseExport(pXPathFile, m_xSFactory, "content.xml");
     assertXPath(pXmlDoc, "//office:spreadsheet[@table:structure-protected='true' and @table:protection-key='1tnJohagR2T0yF/v69hLPuumSTsj32CumW97nkKGuSQ=' and @table:protection-key-digest-algorithm='http://www.w3.org/2000/09/xmldsig#sha256']");
     assertXPath(pXmlDoc, "//table:table[@table:protected='true' and @table:protection-key='1tnJohagR2T0yF/v69hLPuumSTsj32CumW97nkKGuSQ=' and @table:protection-key-digest-algorithm='http://www.w3.org/2000/09/xmldsig#sha256']");
 
@@ -712,7 +712,7 @@ void ScExportTest::testProtectionKeyODS_UTF8SHA256W3C()
     // we can't assume that the user entered the password; check that we
     // round-trip the password as-is
     std::shared_ptr<utl::TempFile> pXPathFile = ScBootstrapFixture::exportTo(&(*xShell), FORMAT_ODS);
-    xmlDocPtr pXmlDoc = XPathHelper::parseExport(pXPathFile, m_xSFactory, "content.xml");
+    xmlDocUniquePtr pXmlDoc = XPathHelper::parseExport(pXPathFile, m_xSFactory, "content.xml");
     assertXPath(pXmlDoc, "//office:spreadsheet[@table:structure-protected='true' and @table:protection-key='1tnJohagR2T0yF/v69hLPuumSTsj32CumW97nkKGuSQ=' and @table:protection-key-digest-algorithm='http://www.w3.org/2000/09/xmldsig#sha256']");
     assertXPath(pXmlDoc, "//table:table[@table:protected='true' and @table:protection-key='1tnJohagR2T0yF/v69hLPuumSTsj32CumW97nkKGuSQ=' and @table:protection-key-digest-algorithm='http://www.w3.org/2000/09/xmldsig#sha256']");
 
@@ -735,7 +735,7 @@ void ScExportTest::testProtectionKeyODS_XL_SHA1()
     // we can't assume that the user entered the password; check that we
     // round-trip the password as-is
     std::shared_ptr<utl::TempFile> pXPathFile = ScBootstrapFixture::exportTo(&(*xShell), FORMAT_ODS);
-    xmlDocPtr pXmlDoc = XPathHelper::parseExport(pXPathFile, m_xSFactory, "content.xml");
+    xmlDocUniquePtr pXmlDoc = XPathHelper::parseExport(pXPathFile, m_xSFactory, "content.xml");
     assertXPath(pXmlDoc, "//office:spreadsheet[@table:structure-protected='true' and @table:protection-key='OX3WkEe79fv1PE+FUmfOLdwVoqI=' and @table:protection-key-digest-algorithm='http://docs.oasis-open.org/office/ns/table/legacy-hash-excel' and @loext:protection-key-digest-algorithm-2='http://www.w3.org/2000/09/xmldsig#sha1']");
     assertXPath(pXmlDoc, "//table:table[@table:protected='true' and @table:protection-key='OX3WkEe79fv1PE+FUmfOLdwVoqI=' and @table:protection-key-digest-algorithm='http://docs.oasis-open.org/office/ns/table/legacy-hash-excel' and @loext:protection-key-digest-algorithm-2='http://www.w3.org/2000/09/xmldsig#sha1']");
 
@@ -812,7 +812,7 @@ void ScExportTest::testCommentExportXLSX()
 
     std::shared_ptr<utl::TempFile> pXPathFile
         = ScBootstrapFixture::exportTo(&(*xShell), FORMAT_XLSX);
-    const xmlDocPtr pComments
+    xmlDocUniquePtr pComments
         = XPathHelper::parseExport(pXPathFile, m_xSFactory, "xl/comments1.xml");
     CPPUNIT_ASSERT(pComments);
 
@@ -822,7 +822,7 @@ void ScExportTest::testCommentExportXLSX()
     assertXPathContent(pComments, "/x:comments/x:commentList/x:comment/x:text/x:r/x:t",
                        "Komentarz");
 
-    const xmlDocPtr pVmlDrawing
+    xmlDocUniquePtr pVmlDrawing
         = XPathHelper::parseExport(pXPathFile, m_xSFactory, "xl/drawings/vmlDrawing1.vml");
     CPPUNIT_ASSERT(pVmlDrawing);
 
@@ -860,14 +860,14 @@ void ScExportTest::testCommentExportXLSX_2_XLSX()
 
     std::shared_ptr<utl::TempFile> pXPathFile
         = ScBootstrapFixture::exportTo(&(*xShell), FORMAT_XLSX);
-    const xmlDocPtr pComments
+    xmlDocUniquePtr pComments
         = XPathHelper::parseExport(pXPathFile, m_xSFactory, "xl/comments1.xml");
     CPPUNIT_ASSERT(pComments);
 
     assertXPathContent(pComments, "/x:comments/x:commentList/x:comment/x:text/x:r/x:t",
                        "visible comment");
 
-    const xmlDocPtr pVmlDrawing
+    xmlDocUniquePtr pVmlDrawing
         = XPathHelper::parseExport(pXPathFile, m_xSFactory, "xl/drawings/vmlDrawing1.vml");
     CPPUNIT_ASSERT(pVmlDrawing);
 
@@ -884,7 +884,7 @@ void ScExportTest::testCustomColumnWidthExportXLSX()
     CPPUNIT_ASSERT(xShell.is());
 
     std::shared_ptr<utl::TempFile> pXPathFile = ScBootstrapFixture::exportTo(&(*xShell), FORMAT_XLSX);
-    xmlDocPtr pSheet = XPathHelper::parseExport(pXPathFile, m_xSFactory, "xl/worksheets/sheet1.xml");
+    xmlDocUniquePtr pSheet = XPathHelper::parseExport(pXPathFile, m_xSFactory, "xl/worksheets/sheet1.xml");
     CPPUNIT_ASSERT(pSheet);
 
     // tdf#124741: check that we export default width, otherwise the skipped columns would have
@@ -959,7 +959,7 @@ void ScExportTest::testXfDefaultValuesXLSX()
     CPPUNIT_ASSERT(xShell.is());
 
     std::shared_ptr<utl::TempFile> pXPathFile = ScBootstrapFixture::exportTo(&(*xShell), FORMAT_XLSX);
-    xmlDocPtr pSheet = XPathHelper::parseExport(pXPathFile, m_xSFactory, "xl/styles.xml");
+    xmlDocUniquePtr pSheet = XPathHelper::parseExport(pXPathFile, m_xSFactory, "xl/styles.xml");
     CPPUNIT_ASSERT(pSheet);
 
     // cellStyleXfs don't need xfId, so we need to make sure it is not saved
@@ -986,7 +986,7 @@ void ScExportTest::testColumnWidthResaveXLSX()
     CPPUNIT_ASSERT(xShell.is());
 
     std::shared_ptr<utl::TempFile> pXPathFile = ScBootstrapFixture::exportTo(&(*xShell), FORMAT_XLSX);
-    xmlDocPtr pSheet = XPathHelper::parseExport(pXPathFile, m_xSFactory, "xl/worksheets/sheet1.xml");
+    xmlDocUniquePtr pSheet = XPathHelper::parseExport(pXPathFile, m_xSFactory, "xl/worksheets/sheet1.xml");
     CPPUNIT_ASSERT(pSheet);
 
     // In original Excel document the width is "24"
@@ -1088,7 +1088,7 @@ void ScExportTest::testOutlineExportXLSX()
     CPPUNIT_ASSERT(xShell.is());
 
     std::shared_ptr<utl::TempFile> pXPathFile = ScBootstrapFixture::exportTo(&(*xShell), FORMAT_XLSX);
-    xmlDocPtr pSheet = XPathHelper::parseExport(pXPathFile, m_xSFactory, "xl/worksheets/sheet1.xml");
+    xmlDocUniquePtr pSheet = XPathHelper::parseExport(pXPathFile, m_xSFactory, "xl/worksheets/sheet1.xml");
     CPPUNIT_ASSERT(pSheet);
 
     // Maximum Outline Row is 4 for this document
@@ -1235,7 +1235,7 @@ void ScExportTest::testAllRowsHiddenXLSX()

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list