sc/CppunitTest_sc_pivottable_filters_test.mk |   44 -
 sc/qa/unit/pivottable_filters_test.cxx       |  671 ++++++++++-----------------
 2 files changed, 268 insertions(+), 447 deletions(-)

New commits:
commit 3e1890ca6f66ccf675092f2841a1b99da0d85ec2
Author:     Xisco Fauli <[email protected]>
AuthorDate: Tue Nov 15 17:47:02 2022 +0100
Commit:     Xisco Fauli <[email protected]>
CommitDate: Tue Nov 15 21:02:21 2022 +0100

    CppunitTest_sc_pivottable_filters_test: inherit from UnoApiXmlTest
    
    This fixes the TODO in testPivotCacheExportXLSX
    
    Change-Id: I904fd97754a7facd9c8896154965ff7d16cada9c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142743
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <[email protected]>

diff --git a/sc/CppunitTest_sc_pivottable_filters_test.mk 
b/sc/CppunitTest_sc_pivottable_filters_test.mk
index 7ace51fba53b..45ceded3698e 100644
--- a/sc/CppunitTest_sc_pivottable_filters_test.mk
+++ b/sc/CppunitTest_sc_pivottable_filters_test.mk
@@ -41,6 +41,7 @@ $(eval $(call 
gb_CppunitTest_use_libraries,sc_pivottable_filters_test, \
     scqahelper \
     sfx \
     sot \
+    subsequenttest \
     svl \
     svt \
     svx \
@@ -70,48 +71,7 @@ $(eval $(call 
gb_CppunitTest_use_api,sc_pivottable_filters_test,\
 $(eval $(call gb_CppunitTest_use_ure,sc_pivottable_filters_test))
 $(eval $(call gb_CppunitTest_use_vcl,sc_pivottable_filters_test))
 
-$(eval $(call gb_CppunitTest_use_components,sc_pivottable_filters_test,\
-    chart2/source/chartcore \
-    chart2/source/controller/chartcontroller \
-    comphelper/util/comphelp \
-    configmgr/source/configmgr \
-    dbaccess/util/dba \
-    embeddedobj/util/embobj \
-    eventattacher/source/evtatt \
-    filter/source/config/cache/filterconfig1 \
-    forms/util/frm \
-    framework/util/fwk \
-    i18npool/source/search/i18nsearch \
-    i18npool/util/i18npool \
-    linguistic/source/lng \
-    oox/util/oox \
-    package/source/xstor/xstor \
-    package/util/package2 \
-    sax/source/expatwrap/expwrap \
-    scaddins/source/analysis/analysis \
-    scaddins/source/datefunc/date \
-    sc/util/sc \
-    sc/util/scfilt \
-    sfx2/util/sfx \
-    sot/util/sot \
-    svl/util/svl \
-    svtools/util/svt \
-    toolkit/util/tk \
-    ucb/source/core/ucb1 \
-    ucb/source/ucp/file/ucpfile1 \
-    ucb/source/ucp/tdoc/ucptdoc1 \
-    unotools/util/utl \
-    unoxml/source/rdf/unordf \
-    unoxml/source/service/unoxml \
-    uui/util/uui \
-    vcl/vcl.common \
-    xmloff/util/xo \
-    xmlsecurity/util/xmlsecurity \
-))
-
-$(eval $(call gb_CppunitTest_use_components,sc_pivottable_filters_test,\
-    xmlsecurity/util/xsec_xmlsec \
-))
+$(eval $(call gb_CppunitTest_use_rdb,sc_pivottable_filters_test,services))
 
 $(eval $(call gb_CppunitTest_use_custom_headers,sc_pivottable_filters_test,\
        officecfg/registry \
diff --git a/sc/qa/unit/pivottable_filters_test.cxx 
b/sc/qa/unit/pivottable_filters_test.cxx
index 6bbbc39e0a2e..6d006bfc4431 100644
--- a/sc/qa/unit/pivottable_filters_test.cxx
+++ b/sc/qa/unit/pivottable_filters_test.cxx
@@ -11,7 +11,6 @@
 
 #include "helper/qahelper.hxx"
 #include "helper/debughelper.hxx"
-#include "helper/xpath.hxx"
 
 #include <patattr.hxx>
 #include <scitems.hxx>
@@ -36,7 +35,7 @@
 using namespace ::com::sun::star;
 using namespace ::com::sun::star::uno;
 
-class ScPivotTableFiltersTest : public ScBootstrapFixture, public XmlTestTools
+class ScPivotTableFiltersTest : public ScModelTestBase
 {
 protected:
     virtual void registerNamespaces(xmlXPathContextPtr& pXmlXPathCtx) override;
@@ -156,7 +155,7 @@ public:
 };
 
 ScPivotTableFiltersTest::ScPivotTableFiltersTest()
-    : ScBootstrapFixture("sc/qa/unit/data")
+    : ScModelTestBase("sc/qa/unit/data")
 {
 }
 
@@ -188,13 +187,13 @@ bool hasDimension(const std::vector<const 
ScDPSaveDimension*>& rDims, const OUSt
 
 void ScPivotTableFiltersTest::testPivotTableBasicODS()
 {
-    ScDocShellRef xDocSh = loadDoc(u"pivot-table-basic.", FORMAT_ODS);
+    createScDoc("ods/pivot-table-basic.ods");
 
-    ScDocument& rDoc = xDocSh->GetDocument();
+    ScDocument* pDoc = getScDoc();
     CPPUNIT_ASSERT_EQUAL_MESSAGE("There should be exactly two sheets.", 
sal_Int16(2),
-                                 rDoc.GetTableCount());
+                                 pDoc->GetTableCount());
 
-    ScDPCollection* pDPs = rDoc.GetDPCollection();
+    ScDPCollection* pDPs = pDoc->GetDPCollection();
     CPPUNIT_ASSERT_MESSAGE("Failed to get a live ScDPCollection instance.", 
pDPs);
     CPPUNIT_ASSERT_EQUAL_MESSAGE("There should be exactly one pivot table 
instance.", size_t(1),
                                  pDPs->GetCount());
@@ -240,17 +239,15 @@ void ScPivotTableFiltersTest::testPivotTableBasicODS()
     CPPUNIT_ASSERT_EQUAL_MESSAGE("Function for the data field should be 
COUNT.",
                                  sal_uInt16(ScGeneralFunction::COUNT),
                                  sal_uInt16(pDim->GetFunction()));
-
-    xDocSh->DoClose();
 }
 
 void ScPivotTableFiltersTest::testPivotTableNamedRangeSourceODS()
 {
-    ScDocShellRef xDocSh = loadDoc(u"pivot-table-named-range-source.", 
FORMAT_ODS);
+    createScDoc("ods/pivot-table-named-range-source.ods");
 
-    ScDocument& rDoc = xDocSh->GetDocument();
+    ScDocument* pDoc = getScDoc();
 
-    ScDPCollection* pDPs = rDoc.GetDPCollection();
+    ScDPCollection* pDPs = pDoc->GetDPCollection();
     CPPUNIT_ASSERT_EQUAL(size_t(1), pDPs->GetCount());
 
     ScDPObject* pDP = &(*pDPs)[0];
@@ -266,8 +263,6 @@ void 
ScPivotTableFiltersTest::testPivotTableNamedRangeSourceODS()
     CPPUNIT_ASSERT_EQUAL_MESSAGE("Failed to detect header dimension.", 
tools::Long(0), nDim);
     CPPUNIT_ASSERT_EQUAL_MESSAGE("This dimension should be a page dimension.",
                                  sheet::DataPilotFieldOrientation_PAGE, 
nOrient);
-
-    xDocSh->DoClose();
 }
 
 namespace
@@ -299,12 +294,12 @@ bool checkVisiblePageFieldMember(const 
ScDPSaveDimension::MemberList& rMembers,
 
 void ScPivotTableFiltersTest::testPivotTableSharedCacheGroupODS()
 {
-    ScDocShellRef xDocSh = loadDoc(u"pivot-table-shared-cache-with-group.", 
FORMAT_ODS);
-    ScDocument& rDoc = xDocSh->GetDocument();
+    createScDoc("ods/pivot-table-shared-cache-with-group.ods");
+    ScDocument* pDoc = getScDoc();
 
     // Make sure that page field's visibility settings are loaded correctly.
 
-    ScDPObject* pDPObj = rDoc.GetDPAtCursor(0, 0, 1); // A1 on 2nd sheet
+    ScDPObject* pDPObj = pDoc->GetDPAtCursor(0, 0, 1); // A1 on 2nd sheet
     CPPUNIT_ASSERT_MESSAGE("There should be a pivot table here.", pDPObj);
     ScDPSaveData* pSaveData = pDPObj->GetSaveData();
     CPPUNIT_ASSERT_MESSAGE("Save data is expected.", pSaveData);
@@ -315,7 +310,7 @@ void 
ScPivotTableFiltersTest::testPivotTableSharedCacheGroupODS()
     CPPUNIT_ASSERT_MESSAGE("Incorrect member visibility.",
                            checkVisiblePageFieldMember(*pMembers, 
u"APL-01-1"));
 
-    pDPObj = rDoc.GetDPAtCursor(0, 1, 2); // A2 on 3rd sheet
+    pDPObj = pDoc->GetDPAtCursor(0, 1, 2); // A2 on 3rd sheet
     CPPUNIT_ASSERT_MESSAGE("There should be a pivot table here.", pDPObj);
     pSaveData = pDPObj->GetSaveData();
     CPPUNIT_ASSERT_MESSAGE("Save data is expected.", pSaveData);
@@ -328,7 +323,7 @@ void 
ScPivotTableFiltersTest::testPivotTableSharedCacheGroupODS()
 
     // These two pivot tables share the same data range. We should only have
     // one pivot cache.
-    ScDPCollection* pDPs = rDoc.GetDPCollection();
+    ScDPCollection* pDPs = pDoc->GetDPCollection();
     ScDPCollection::SheetCaches& rSheetCaches = pDPs->GetSheetCaches();
     CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), rSheetCaches.size());
 
@@ -427,52 +422,48 @@ void 
ScPivotTableFiltersTest::testPivotTableSharedCacheGroupODS()
 
     CPPUNIT_ASSERT_MESSAGE("Pivot cache doesn't have an additional year 
group.", bHasYears);
     CPPUNIT_ASSERT_MESSAGE("Pivot cache doesn't have an additional month 
group.", bHasMonths);
-
-    xDocSh->DoClose();
 }
 
 void ScPivotTableFiltersTest::testGetPivotDataXLS()
 {
-    ScDocShellRef xDocSh = loadDoc(u"pivot-getpivotdata.", FORMAT_XLS);
-    ScDocument& rDoc = xDocSh->GetDocument();
-    rDoc.CalcAll();
+    createScDoc("xls/pivot-getpivotdata.xls");
+    ScDocument* pDoc = getScDoc();
+    pDoc->CalcAll();
 
     // Check GETPIVOTDATA results in E3:E20. Expected results are given in
     // F3:F20.
 
     for (SCROW nRow = 2; nRow <= 19; ++nRow)
-        CPPUNIT_ASSERT_EQUAL(rDoc.GetValue(ScAddress(4, nRow, 1)),
-                             rDoc.GetValue(ScAddress(5, nRow, 1)));
-
-    xDocSh->DoClose();
+        CPPUNIT_ASSERT_EQUAL(pDoc->GetValue(ScAddress(4, nRow, 1)),
+                             pDoc->GetValue(ScAddress(5, nRow, 1)));
 }
 
 void ScPivotTableFiltersTest::testPivotTableSharedGroupXLSX()
 {
-    ScDocShellRef xDocSh = loadDoc(u"pivot-table/shared-group-field.", 
FORMAT_XLSX);
-    ScDocument& rDoc = xDocSh->GetDocument();
+    createScDoc("xlsx/pivot-table/shared-group-field.xlsx");
+    ScDocument* pDoc = getScDoc();
 
     // Check whether right group names are imported for both tables
     // First table
-    CPPUNIT_ASSERT_EQUAL(OUString("a2"), rDoc.GetString(ScAddress(0, 1, 0)));
-    CPPUNIT_ASSERT_EQUAL(OUString("Csoport1"), rDoc.GetString(ScAddress(0, 2, 
0)));
-    CPPUNIT_ASSERT_EQUAL(OUString("Csoport2"), rDoc.GetString(ScAddress(0, 3, 
0)));
-    CPPUNIT_ASSERT_EQUAL(OUString("Csoport3"), rDoc.GetString(ScAddress(0, 4, 
0)));
-    CPPUNIT_ASSERT_EQUAL(OUString("16"), rDoc.GetString(ScAddress(0, 5, 0)));
-    CPPUNIT_ASSERT_EQUAL(OUString("17"), rDoc.GetString(ScAddress(0, 6, 0)));
-    CPPUNIT_ASSERT_EQUAL(OUString("18"), rDoc.GetString(ScAddress(0, 7, 0)));
+    CPPUNIT_ASSERT_EQUAL(OUString("a2"), pDoc->GetString(ScAddress(0, 1, 0)));
+    CPPUNIT_ASSERT_EQUAL(OUString("Csoport1"), pDoc->GetString(ScAddress(0, 2, 
0)));
+    CPPUNIT_ASSERT_EQUAL(OUString("Csoport2"), pDoc->GetString(ScAddress(0, 3, 
0)));
+    CPPUNIT_ASSERT_EQUAL(OUString("Csoport3"), pDoc->GetString(ScAddress(0, 4, 
0)));
+    CPPUNIT_ASSERT_EQUAL(OUString("16"), pDoc->GetString(ScAddress(0, 5, 0)));
+    CPPUNIT_ASSERT_EQUAL(OUString("17"), pDoc->GetString(ScAddress(0, 6, 0)));
+    CPPUNIT_ASSERT_EQUAL(OUString("18"), pDoc->GetString(ScAddress(0, 7, 0)));
 
     // Second table
-    CPPUNIT_ASSERT_EQUAL(OUString("a2"), rDoc.GetString(ScAddress(0, 11, 0)));
-    CPPUNIT_ASSERT_EQUAL(OUString("Csoport1"), rDoc.GetString(ScAddress(0, 12, 
0)));
-    CPPUNIT_ASSERT_EQUAL(OUString("Csoport2"), rDoc.GetString(ScAddress(0, 13, 
0)));
-    CPPUNIT_ASSERT_EQUAL(OUString("Csoport3"), rDoc.GetString(ScAddress(0, 14, 
0)));
-    CPPUNIT_ASSERT_EQUAL(OUString("16"), rDoc.GetString(ScAddress(0, 15, 0)));
-    CPPUNIT_ASSERT_EQUAL(OUString("17"), rDoc.GetString(ScAddress(0, 16, 0)));
-    CPPUNIT_ASSERT_EQUAL(OUString("18"), rDoc.GetString(ScAddress(0, 17, 0)));
+    CPPUNIT_ASSERT_EQUAL(OUString("a2"), pDoc->GetString(ScAddress(0, 11, 0)));
+    CPPUNIT_ASSERT_EQUAL(OUString("Csoport1"), pDoc->GetString(ScAddress(0, 
12, 0)));
+    CPPUNIT_ASSERT_EQUAL(OUString("Csoport2"), pDoc->GetString(ScAddress(0, 
13, 0)));
+    CPPUNIT_ASSERT_EQUAL(OUString("Csoport3"), pDoc->GetString(ScAddress(0, 
14, 0)));
+    CPPUNIT_ASSERT_EQUAL(OUString("16"), pDoc->GetString(ScAddress(0, 15, 0)));
+    CPPUNIT_ASSERT_EQUAL(OUString("17"), pDoc->GetString(ScAddress(0, 16, 0)));
+    CPPUNIT_ASSERT_EQUAL(OUString("18"), pDoc->GetString(ScAddress(0, 17, 0)));
 
     // There should be exactly 2 pivot tables and 1 cache.
-    ScDPCollection* pDPs = rDoc.GetDPCollection();
+    ScDPCollection* pDPs = pDoc->GetDPCollection();
     CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), pDPs->GetCount());
 
     ScDPCollection::SheetCaches& rSheetCaches = pDPs->GetSheetCaches();
@@ -482,16 +473,11 @@ void 
ScPivotTableFiltersTest::testPivotTableSharedGroupXLSX()
     CPPUNIT_ASSERT_MESSAGE("Pivot cache is expected for A1:N19 on the second 
sheet.", pCache);
     CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(14), pCache->GetFieldCount());
     CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pCache->GetGroupFieldCount());
-
-    xDocSh->DoClose();
 }
 
 void ScPivotTableFiltersTest::testPivotTableSharedDateGroupXLSX()
 {
-    auto testThis = [](ScDocShellRef& xDocSh) {
-        CPPUNIT_ASSERT_MESSAGE("Failed to load file", xDocSh.is());
-        ScDocument& rDoc = xDocSh->GetDocument();
-
+    auto testThis = [](ScDocument& rDoc) {
         // Check whether right date labels are imported for both tables
         // First table
         CPPUNIT_ASSERT_EQUAL(OUString("a"), rDoc.GetString(ScAddress(0, 3, 
1)));
@@ -522,21 +508,16 @@ void 
ScPivotTableFiltersTest::testPivotTableSharedDateGroupXLSX()
         CPPUNIT_ASSERT_MESSAGE("Pivot cache is expected for A1:J25 on the 
first sheet.", pCache);
         CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(10), pCache->GetFieldCount());
     };
-    ScDocShellRef xDocSh1 = loadDoc(u"pivot-table/shared-dategroup.", 
FORMAT_XLSX);
-    testThis(xDocSh1);
+    createScDoc("xlsx/pivot-table/shared-dategroup.xlsx");
+    testThis(*getScDoc());
     // Now test round-trip of group fields
-    ScDocShellRef xDocSh2 = saveAndReload(*xDocSh1, FORMAT_XLSX);
-    testThis(xDocSh2);
-    xDocSh2->DoClose();
-    xDocSh1->DoClose();
+    saveAndReload("Calc Office Open XML");
+    testThis(*getScDoc());
 }
 
 void ScPivotTableFiltersTest::testPivotTableSharedNestedDateGroupXLSX()
 {
-    auto testThis = [](ScDocShellRef& xDocSh) {
-        CPPUNIT_ASSERT_MESSAGE("Failed to load file", xDocSh.is());
-        ScDocument& rDoc = xDocSh->GetDocument();
-
+    auto testThis = [](ScDocument& rDoc) {
         // Check whether right date groups are imported for both tables
         // First table
         CPPUNIT_ASSERT_EQUAL(OUString("Years"), rDoc.GetString(ScAddress(0, 3, 
1)));
@@ -574,39 +555,37 @@ void 
ScPivotTableFiltersTest::testPivotTableSharedNestedDateGroupXLSX()
         CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), 
pCache->GetGroupFieldCount());
     };
 
-    ScDocShellRef xDocSh1 = loadDoc(u"pivot-table/shared-nested-dategroup.", 
FORMAT_XLSX);
-    testThis(xDocSh1);
+    createScDoc("xlsx/pivot-table/shared-nested-dategroup.xlsx");
+    testThis(*getScDoc());
     // Now test round-trip of group fields
-    ScDocShellRef xDocSh2 = saveAndReload(*xDocSh1, FORMAT_XLSX);
-    testThis(xDocSh2);
-    xDocSh2->DoClose();
-    xDocSh1->DoClose();
+    saveAndReload("Calc Office Open XML");
+    testThis(*getScDoc());
 }
 
 void ScPivotTableFiltersTest::testPivotTableSharedNumGroupXLSX()
 {
-    ScDocShellRef xDocSh = loadDoc(u"pivot-table/shared-numgroup.", 
FORMAT_XLSX);
-    ScDocument& rDoc = xDocSh->GetDocument();
+    createScDoc("xlsx/pivot-table/shared-numgroup.xlsx");
+    ScDocument* pDoc = getScDoc();
 
     // Check whether right number groups are imported for both tables
     // First table
-    CPPUNIT_ASSERT_EQUAL(OUString("f"), rDoc.GetString(ScAddress(0, 3, 1)));
-    CPPUNIT_ASSERT_EQUAL(OUString("32674-47673"), rDoc.GetString(ScAddress(0, 
4, 1)));
-    CPPUNIT_ASSERT_EQUAL(OUString("47674-62673"), rDoc.GetString(ScAddress(0, 
5, 1)));
-    CPPUNIT_ASSERT_EQUAL(OUString("62674-77673"), rDoc.GetString(ScAddress(0, 
6, 1)));
-    CPPUNIT_ASSERT_EQUAL(OUString("77674-92673"), rDoc.GetString(ScAddress(0, 
7, 1)));
-    CPPUNIT_ASSERT_EQUAL(OUString("92674-107673"), rDoc.GetString(ScAddress(0, 
8, 1)));
+    CPPUNIT_ASSERT_EQUAL(OUString("f"), pDoc->GetString(ScAddress(0, 3, 1)));
+    CPPUNIT_ASSERT_EQUAL(OUString("32674-47673"), pDoc->GetString(ScAddress(0, 
4, 1)));
+    CPPUNIT_ASSERT_EQUAL(OUString("47674-62673"), pDoc->GetString(ScAddress(0, 
5, 1)));
+    CPPUNIT_ASSERT_EQUAL(OUString("62674-77673"), pDoc->GetString(ScAddress(0, 
6, 1)));
+    CPPUNIT_ASSERT_EQUAL(OUString("77674-92673"), pDoc->GetString(ScAddress(0, 
7, 1)));
+    CPPUNIT_ASSERT_EQUAL(OUString("92674-107673"), 
pDoc->GetString(ScAddress(0, 8, 1)));
 
     // Second table
-    CPPUNIT_ASSERT_EQUAL(OUString("f"), rDoc.GetString(ScAddress(5, 3, 1)));
-    CPPUNIT_ASSERT_EQUAL(OUString("32674-47673"), rDoc.GetString(ScAddress(5, 
4, 1)));
-    CPPUNIT_ASSERT_EQUAL(OUString("47674-62673"), rDoc.GetString(ScAddress(5, 
5, 1)));
-    CPPUNIT_ASSERT_EQUAL(OUString("62674-77673"), rDoc.GetString(ScAddress(5, 
6, 1)));
-    CPPUNIT_ASSERT_EQUAL(OUString("77674-92673"), rDoc.GetString(ScAddress(5, 
7, 1)));
-    CPPUNIT_ASSERT_EQUAL(OUString("92674-107673"), rDoc.GetString(ScAddress(5, 
8, 1)));
+    CPPUNIT_ASSERT_EQUAL(OUString("f"), pDoc->GetString(ScAddress(5, 3, 1)));
+    CPPUNIT_ASSERT_EQUAL(OUString("32674-47673"), pDoc->GetString(ScAddress(5, 
4, 1)));
+    CPPUNIT_ASSERT_EQUAL(OUString("47674-62673"), pDoc->GetString(ScAddress(5, 
5, 1)));
+    CPPUNIT_ASSERT_EQUAL(OUString("62674-77673"), pDoc->GetString(ScAddress(5, 
6, 1)));
+    CPPUNIT_ASSERT_EQUAL(OUString("77674-92673"), pDoc->GetString(ScAddress(5, 
7, 1)));
+    CPPUNIT_ASSERT_EQUAL(OUString("92674-107673"), 
pDoc->GetString(ScAddress(5, 8, 1)));
 
     // There should be exactly 2 pivot tables and 1 cache.
-    ScDPCollection* pDPs = rDoc.GetDPCollection();
+    ScDPCollection* pDPs = pDoc->GetDPCollection();
     CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), pDPs->GetCount());
 
     ScDPCollection::SheetCaches& rSheetCaches = pDPs->GetSheetCaches();
@@ -615,23 +594,21 @@ void 
ScPivotTableFiltersTest::testPivotTableSharedNumGroupXLSX()
     const ScDPCache* pCache = rSheetCaches.getExistingCache(ScRange(0, 0, 0, 
9, 24, 0));
     CPPUNIT_ASSERT_MESSAGE("Pivot cache is expected for A1:J25 on the first 
sheet.", pCache);
     CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(10), pCache->GetFieldCount());
-
-    xDocSh->DoClose();
 }
 
 void ScPivotTableFiltersTest::testPivotTableNoColumnsLayout()
 {
     // tdf#113268 - Pivot table: Missing popup button after opening a pivot 
table from ODS
-    ScDocShellRef xDocSh = loadDoc(u"pivottable_no_columns_layout.", 
FORMAT_ODS);
-    ScDocument& rDoc = xDocSh->GetDocument();
+    createScDoc("ods/pivottable_no_columns_layout.ods");
+    ScDocument* pDoc = getScDoc();
 
     // There should be exactly 2 pivot tables
-    ScDPCollection* pDPs = rDoc.GetDPCollection();
+    ScDPCollection* pDPs = pDoc->GetDPCollection();
     CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), pDPs->GetCount());
 
     // Check first pivot table's popup button (headerlayout flag)
     {
-        const ScPatternAttr* pPattern = rDoc.GetPattern(0, 1, 1);
+        const ScPatternAttr* pPattern = pDoc->GetPattern(0, 1, 1);
         const SfxPoolItem& rPoolItem = pPattern->GetItem(ATTR_MERGE_FLAG);
         const ScMergeFlagAttr& rMergeFlag = static_cast<const 
ScMergeFlagAttr&>(rPoolItem);
         CPPUNIT_ASSERT(rMergeFlag.GetValue() & ScMF::ButtonPopup);
@@ -639,22 +616,20 @@ void 
ScPivotTableFiltersTest::testPivotTableNoColumnsLayout()
 
     // Check second pivot table's popup button
     {
-        const ScPatternAttr* pPattern = rDoc.GetPattern(3, 0, 1);
+        const ScPatternAttr* pPattern = pDoc->GetPattern(3, 0, 1);
         const SfxPoolItem& rPoolItem = pPattern->GetItem(ATTR_MERGE_FLAG);
         const ScMergeFlagAttr& rMergeFlag = static_cast<const 
ScMergeFlagAttr&>(rPoolItem);
         CPPUNIT_ASSERT(rMergeFlag.GetValue() & ScMF::ButtonPopup);
     }
-
-    xDocSh->DoClose();
 }
 
 void ScPivotTableFiltersTest::testTdf112501()
 {
-    ScDocShellRef xDocSh = loadDoc(u"tdf112501.", FORMAT_XLS);
-    ScDocument& rDoc = xDocSh->GetDocument();
+    createScDoc("xls/tdf112501.xls");
+    ScDocument* pDoc = getScDoc();
 
     // There should be exactly 2 pivot tables
-    ScDPCollection* pDPs = rDoc.GetDPCollection();
+    ScDPCollection* pDPs = pDoc->GetDPCollection();
     CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), pDPs->GetCount());
 
     // Check first pivot table popup buttons (compact)
@@ -664,21 +639,21 @@ void ScPivotTableFiltersTest::testTdf112501()
         // Check whether we have the buttons at the right buttons
         // Row button
         {
-            const ScPatternAttr* pPattern = rDoc.GetPattern(0, 3, 0);
+            const ScPatternAttr* pPattern = pDoc->GetPattern(0, 3, 0);
             const SfxPoolItem& rPoolItem = pPattern->GetItem(ATTR_MERGE_FLAG);
             const ScMergeFlagAttr& rMergeFlag = static_cast<const 
ScMergeFlagAttr&>(rPoolItem);
             CPPUNIT_ASSERT(rMergeFlag.GetValue() & ScMF::ButtonPopup);
         }
         // Column button
         {
-            const ScPatternAttr* pPattern = rDoc.GetPattern(1, 2, 0);
+            const ScPatternAttr* pPattern = pDoc->GetPattern(1, 2, 0);
             const SfxPoolItem& rPoolItem = pPattern->GetItem(ATTR_MERGE_FLAG);
             const ScMergeFlagAttr& rMergeFlag = static_cast<const 
ScMergeFlagAttr&>(rPoolItem);
             CPPUNIT_ASSERT(rMergeFlag.GetValue() & ScMF::ButtonPopup);
         }
         // Check also C3 to make sure column button is not placed there
         {
-            const ScPatternAttr* pPattern = rDoc.GetPattern(2, 2, 0);
+            const ScPatternAttr* pPattern = pDoc->GetPattern(2, 2, 0);
             const SfxPoolItem& rPoolItem = pPattern->GetItem(ATTR_MERGE_FLAG);
             const ScMergeFlagAttr& rMergeFlag = static_cast<const 
ScMergeFlagAttr&>(rPoolItem);
             CPPUNIT_ASSERT(!(rMergeFlag.GetValue() & ScMF::ButtonPopup));
@@ -692,39 +667,35 @@ void ScPivotTableFiltersTest::testTdf112501()
         // Check whether we have the buttons at the right buttons
         // Two row buttons
         {
-            const ScPatternAttr* pPattern = rDoc.GetPattern(7, 3, 0);
+            const ScPatternAttr* pPattern = pDoc->GetPattern(7, 3, 0);
             const SfxPoolItem& rPoolItem = pPattern->GetItem(ATTR_MERGE_FLAG);
             const ScMergeFlagAttr& rMergeFlag = static_cast<const 
ScMergeFlagAttr&>(rPoolItem);
             CPPUNIT_ASSERT(rMergeFlag.GetValue() & ScMF::ButtonPopup);
         }
         {
-            const ScPatternAttr* pPattern = rDoc.GetPattern(8, 3, 0);
+            const ScPatternAttr* pPattern = pDoc->GetPattern(8, 3, 0);
             const SfxPoolItem& rPoolItem = pPattern->GetItem(ATTR_MERGE_FLAG);
             const ScMergeFlagAttr& rMergeFlag = static_cast<const 
ScMergeFlagAttr&>(rPoolItem);
             CPPUNIT_ASSERT(rMergeFlag.GetValue() & ScMF::ButtonPopup);
         }
         // Column button
         {
-            const ScPatternAttr* pPattern = rDoc.GetPattern(9, 2, 0);
+            const ScPatternAttr* pPattern = pDoc->GetPattern(9, 2, 0);
             const SfxPoolItem& rPoolItem = pPattern->GetItem(ATTR_MERGE_FLAG);
             const ScMergeFlagAttr& rMergeFlag = static_cast<const 
ScMergeFlagAttr&>(rPoolItem);
             CPPUNIT_ASSERT(rMergeFlag.GetValue() & ScMF::ButtonPopup);
         }
     }
-
-    xDocSh->DoClose();
 }
 
 void ScPivotTableFiltersTest::testPivotTableExportXLSX()
 {
     // tdf#89139: pivot table definition needs to list items, including hidden
 
-    ScDocShellRef xShell = loadDoc(u"tdf89139_pivot_table.", FORMAT_XLSX);
+    createScDoc("xlsx/tdf89139_pivot_table.xlsx");
 
-    std::shared_ptr<utl::TempFileNamed> pXPathFile
-        = ScBootstrapFixture::exportTo(*xShell, FORMAT_XLSX);
-    xmlDocUniquePtr pTable
-        = XPathHelper::parseExport(pXPathFile, m_xSFactory, 
"xl/pivotTables/pivotTable1.xml");
+    save("Calc Office Open XML");
+    xmlDocUniquePtr pTable = parseExport("xl/pivotTables/pivotTable1.xml");
     CPPUNIT_ASSERT(pTable);
 
     assertXPath(pTable, 
"/x:pivotTableDefinition/x:pivotFields/x:pivotField[3]/x:items", "count",
@@ -732,18 +703,14 @@ void ScPivotTableFiltersTest::testPivotTableExportXLSX()
     assertXPath(pTable, 
"/x:pivotTableDefinition/x:pivotFields/x:pivotField[3]/x:items/x:item", 4);
     assertXPath(pTable, 
"/x:pivotTableDefinition/x:pivotFields/x:pivotField[3]/x:items/x:item[3]",
                 "h", "1");
-
-    xShell->DoClose();
 }
 
 void ScPivotTableFiltersTest::testPivotTableExportXLSXSingleDataField()
 {
-    ScDocShellRef xShell = loadDoc(u"tdf123421_1datafield.", FORMAT_ODS);
+    createScDoc("ods/tdf123421_1datafield.ods");
 
-    std::shared_ptr<utl::TempFileNamed> pXPathFile
-        = ScBootstrapFixture::exportTo(*xShell, FORMAT_XLSX);
-    xmlDocUniquePtr pTable
-        = XPathHelper::parseExport(pXPathFile, m_xSFactory, 
"xl/pivotTables/pivotTable1.xml");
+    save("Calc Office Open XML");
+    xmlDocUniquePtr pTable = parseExport("xl/pivotTables/pivotTable1.xml");
     CPPUNIT_ASSERT(pTable);
 
     assertXPath(pTable, "/x:pivotTableDefinition/x:location", "ref", "A3:B6");
@@ -755,18 +722,14 @@ void 
ScPivotTableFiltersTest::testPivotTableExportXLSXSingleDataField()
     // There should not be any colFields tag, before the fix there used to be 
a singleton with
     // <field x="-2"/> as child node.
     assertXPath(pTable, "/x:pivotTableDefinition/x:colFields", 0);
-
-    xShell->DoClose();
 }
 
 void ScPivotTableFiltersTest::testPivotTableExportXLSXMultipleDataFields()
 {
-    ScDocShellRef xShell = loadDoc(u"tdf123421_2datafields.", FORMAT_ODS);
+    createScDoc("ods/tdf123421_2datafields.ods");
 
-    std::shared_ptr<utl::TempFileNamed> pXPathFile
-        = ScBootstrapFixture::exportTo(*xShell, FORMAT_XLSX);
-    xmlDocUniquePtr pTable
-        = XPathHelper::parseExport(pXPathFile, m_xSFactory, 
"xl/pivotTables/pivotTable1.xml");
+    save("Calc Office Open XML");
+    xmlDocUniquePtr pTable = parseExport("xl/pivotTables/pivotTable1.xml");
     CPPUNIT_ASSERT(pTable);
 
     assertXPath(pTable, "/x:pivotTableDefinition/x:location", "ref", "A1:C6");
@@ -782,8 +745,6 @@ void 
ScPivotTableFiltersTest::testPivotTableExportXLSXMultipleDataFields()
     assertXPath(pTable, "/x:pivotTableDefinition/x:colFields", "count", "1");
     assertXPath(pTable, "/x:pivotTableDefinition/x:colFields/x:field", 1);
     assertXPath(pTable, "/x:pivotTableDefinition/x:colFields/x:field", "x", 
"-2");
-
-    xShell->DoClose();
 }
 
 void ScPivotTableFiltersTest::testPivotCacheExportXLSX()
@@ -795,12 +756,10 @@ void ScPivotTableFiltersTest::testPivotCacheExportXLSX()
     // This test case ensures, that such values are properly set according to 
documentation:
     // 
https://technet.microsoft.com/en-us/library/documentformat.openxml.spreadsheet.shareditems.aspx
 
-    ScDocShellRef xShell = 
loadDoc(u"pivot-table/with-strings-integers-and-dates.", FORMAT_XLSX);
+    createScDoc("xlsx/pivot-table/with-strings-integers-and-dates.xlsx");
 
-    std::shared_ptr<utl::TempFileNamed> pXPathFile
-        = ScBootstrapFixture::exportTo(*xShell, FORMAT_XLSX);
-    xmlDocUniquePtr pCacheDef = XPathHelper::parseExport(pXPathFile, 
m_xSFactory,
-                                                         
"xl/pivotCache/pivotCacheDefinition1.xml");
+    save("Calc Office Open XML");
+    xmlDocUniquePtr pCacheDef = 
parseExport("xl/pivotCache/pivotCacheDefinition1.xml");
     CPPUNIT_ASSERT(pCacheDef);
 
     assertXPath(pCacheDef, 
"/x:pivotCacheDefinition/x:cacheFields/x:cacheField", 6);
@@ -975,11 +934,10 @@ void ScPivotTableFiltersTest::testPivotCacheExportXLSX()
                 "containsDate", "1");
     assertXPath(pCacheDef, 
"/x:pivotCacheDefinition/x:cacheFields/x:cacheField[5]/x:sharedItems",
                 "containsString", "0");
-    //TODO: date generator in tests are one day higher, than during standard 
xlsx export. It should be: minDate="1899-12-31T00:00:00" 
maxDate="2009-07-06T10:53:02"
     assertXPath(pCacheDef, 
"/x:pivotCacheDefinition/x:cacheFields/x:cacheField[5]/x:sharedItems",
-                "minDate", "1900-01-01T00:00:00");
+                "minDate", "1899-12-31T00:00:00");
     assertXPath(pCacheDef, 
"/x:pivotCacheDefinition/x:cacheFields/x:cacheField[5]/x:sharedItems",
-                "maxDate", "2009-07-07T10:53:02");
+                "maxDate", "2009-07-06T10:53:02");
     assertXPathNoAttribute(pCacheDef,
                            
"/x:pivotCacheDefinition/x:cacheFields/x:cacheField[5]/x:sharedItems",
                            "containsNumber");
@@ -1033,8 +991,6 @@ void ScPivotTableFiltersTest::testPivotCacheExportXLSX()
                            "maxValue");
     assertXPath(pCacheDef, 
"/x:pivotCacheDefinition/x:cacheFields/x:cacheField[6]/x:sharedItems",
                 "count", "1");
-
-    xShell->DoClose();
 }
 
 void ScPivotTableFiltersTest::testPivotTableXLSX()
@@ -1157,23 +1113,19 @@ void ScPivotTableFiltersTest::testPivotTableXLSX()
 
     } aTest;
 
-    ScDocShellRef xDocSh = loadDoc(u"pivot-table/many-fields-in-cache.", 
FORMAT_XLSX);
-    ScDocument* pDoc = &xDocSh->GetDocument();
+    createScDoc("xlsx/pivot-table/many-fields-in-cache.xlsx");
+    ScDocument* pDoc = getScDoc();
 
     // Initial check.
     bool bCheck = aTest.check(*pDoc);
     CPPUNIT_ASSERT_MESSAGE("Initial check failed.", bCheck);
 
-    ScDocShellRef xDocSh2 = saveAndReload(*xDocSh, FORMAT_XLSX);
-    xDocSh->DoClose();
-    CPPUNIT_ASSERT(xDocSh2.is());
-    pDoc = &xDocSh2->GetDocument();
+    saveAndReload("Calc Office Open XML");
+    pDoc = getScDoc();
 
     // Reload check.
     bCheck = aTest.check(*pDoc);
     CPPUNIT_ASSERT_MESSAGE("Reload check failed.", bCheck);
-
-    xDocSh2->DoClose();
 }
 
 void ScPivotTableFiltersTest::testPivotTableTwoDataFieldsXLSX()
@@ -1280,40 +1232,35 @@ void 
ScPivotTableFiltersTest::testPivotTableTwoDataFieldsXLSX()
 
     } aTest;
 
-    ScDocShellRef xDocSh = loadDoc(u"pivot-table/two-data-fields.", 
FORMAT_XLSX);
-    ScDocument* pDoc = &xDocSh->GetDocument();
+    createScDoc("xlsx/pivot-table/two-data-fields.xlsx");
+    ScDocument* pDoc = getScDoc();
 
     // Initial check.
     bool bCheck = aTest.check(*pDoc);
     CPPUNIT_ASSERT_MESSAGE("Initial check failed.", bCheck);
 
-    ScDocShellRef xDocSh2 = saveAndReload(*xDocSh, FORMAT_XLSX);
-    xDocSh->DoClose();
-    CPPUNIT_ASSERT(xDocSh2.is());
-    pDoc = &xDocSh2->GetDocument();
+    saveAndReload("Calc Office Open XML");
+    pDoc = getScDoc();
 
     // Reload check.
     bCheck = aTest.check(*pDoc);
     CPPUNIT_ASSERT_MESSAGE("Reload check failed.", bCheck);
-
-    xDocSh2->DoClose();
 }
 
 void ScPivotTableFiltersTest::testPivotTableMedianODS()
 {
-    ScDocShellRef xDocSh = loadDoc(u"pivot-table-median.", FORMAT_ODS);
+    createScDoc("ods/pivot-table-median.ods");
 
     // Export the document and import again for a check
-    ScDocShellRef xDocSh2 = saveAndReload(*xDocSh, FORMAT_ODS);
-    xDocSh->DoClose();
+    saveAndReload("calc8");
 
     // Check sheet
-    ScDocument& rDoc = xDocSh2->GetDocument();
+    ScDocument* pDoc = getScDoc();
     CPPUNIT_ASSERT_EQUAL_MESSAGE("There should be exactly one sheet.", 
sal_Int16(1),
-                                 rDoc.GetTableCount());
+                                 pDoc->GetTableCount());
 
     // Check pivot table
-    ScDPCollection* pDPs = rDoc.GetDPCollection();
+    ScDPCollection* pDPs = pDoc->GetDPCollection();
     CPPUNIT_ASSERT_MESSAGE("Failed to get a live ScDPCollection instance.", 
pDPs);
     CPPUNIT_ASSERT_EQUAL_MESSAGE("There should be one pivot table instance.", 
size_t(1),
                                  pDPs->GetCount());
@@ -1332,17 +1279,15 @@ void ScPivotTableFiltersTest::testPivotTableMedianODS()
     CPPUNIT_ASSERT_EQUAL_MESSAGE("Function for the data field should be 
MEDIAN.",
                                  sal_uInt16(ScGeneralFunction::MEDIAN),
                                  sal_uInt16(pDim->GetFunction()));
-
-    xDocSh2->DoClose();
 }
 
 void ScPivotTableFiltersTest::testPivotTableRowHeaderXLS()
 {
-    ScDocShellRef xDocSh = loadDoc(u"pivot_row_header.", FORMAT_XLS);
-    ScDocument& rDoc = xDocSh->GetDocument();
+    createScDoc("xls/pivot_row_header.xls");
+    ScDocument* pDoc = getScDoc();
 
     // There should be exactly 2 pivot tables
-    ScDPCollection* pDPs = rDoc.GetDPCollection();
+    ScDPCollection* pDPs = pDoc->GetDPCollection();
     CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), pDPs->GetCount());
 
     // First table has extra row header
@@ -1351,7 +1296,7 @@ void ScPivotTableFiltersTest::testPivotTableRowHeaderXLS()
         CPPUNIT_ASSERT_MESSAGE("Failed to get a pivot table object.", pDPObj);
         CPPUNIT_ASSERT(pDPObj->GetHeaderLayout());
         // Check whether the row header has the right popupbutton flag
-        const ScPatternAttr* pPattern = rDoc.GetPattern(3, 3, 0);
+        const ScPatternAttr* pPattern = pDoc->GetPattern(3, 3, 0);
         const SfxPoolItem& rPoolItem = pPattern->GetItem(ATTR_MERGE_FLAG);
         const ScMergeFlagAttr& rMergeFlag = static_cast<const 
ScMergeFlagAttr&>(rPoolItem);
         CPPUNIT_ASSERT(rMergeFlag.GetValue() & ScMF::ButtonPopup);
@@ -1363,19 +1308,18 @@ void 
ScPivotTableFiltersTest::testPivotTableRowHeaderXLS()
         CPPUNIT_ASSERT_MESSAGE("Failed to get a pivot table object.", pDPObj);
         CPPUNIT_ASSERT(!pDPObj->GetHeaderLayout());
         // Check whether the row header has the right popupbutton flag
-        const ScPatternAttr* pPattern = rDoc.GetPattern(0, 2, 0);
+        const ScPatternAttr* pPattern = pDoc->GetPattern(0, 2, 0);
         const SfxPoolItem& rPoolItem = pPattern->GetItem(ATTR_MERGE_FLAG);
         const ScMergeFlagAttr& rMergeFlag = static_cast<const 
ScMergeFlagAttr&>(rPoolItem);
         CPPUNIT_ASSERT(rMergeFlag.GetValue() & ScMF::ButtonPopup);
     }
 
     // Check also after a reload
-    xDocSh = saveAndReload(*xDocSh, FORMAT_XLS);
-    CPPUNIT_ASSERT_MESSAGE("Failed to load file", xDocSh.is());
-    ScDocument& rLoadedDoc = xDocSh->GetDocument();
+    saveAndReload("MS Excel 97");
+    pDoc = getScDoc();
 
     // There should be exactly 2 pivot tables
-    pDPs = rLoadedDoc.GetDPCollection();
+    pDPs = pDoc->GetDPCollection();
     CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), pDPs->GetCount());
 
     // First table has extra row header
@@ -1384,7 +1328,7 @@ void ScPivotTableFiltersTest::testPivotTableRowHeaderXLS()
         CPPUNIT_ASSERT_MESSAGE("Failed to get a pivot table object.", pDPObj);
         CPPUNIT_ASSERT(pDPObj->GetHeaderLayout());
         // Check whether the row header has the right popupbutton flag
-        const ScPatternAttr* pPattern = rLoadedDoc.GetPattern(3, 3, 0);
+        const ScPatternAttr* pPattern = pDoc->GetPattern(3, 3, 0);
         const SfxPoolItem& rPoolItem = pPattern->GetItem(ATTR_MERGE_FLAG);
         const ScMergeFlagAttr& rMergeFlag = static_cast<const 
ScMergeFlagAttr&>(rPoolItem);
         CPPUNIT_ASSERT(rMergeFlag.GetValue() & ScMF::ButtonPopup);
@@ -1396,27 +1340,24 @@ void 
ScPivotTableFiltersTest::testPivotTableRowHeaderXLS()
         CPPUNIT_ASSERT_MESSAGE("Failed to get a pivot table object.", pDPObj);
         CPPUNIT_ASSERT(!pDPObj->GetHeaderLayout());
         // Check whether the row header has the right popupbutton flag
-        const ScPatternAttr* pPattern = rLoadedDoc.GetPattern(0, 2, 0);
+        const ScPatternAttr* pPattern = pDoc->GetPattern(0, 2, 0);
         const SfxPoolItem& rPoolItem = pPattern->GetItem(ATTR_MERGE_FLAG);
         const ScMergeFlagAttr& rMergeFlag = static_cast<const 
ScMergeFlagAttr&>(rPoolItem);
         CPPUNIT_ASSERT(rMergeFlag.GetValue() & ScMF::ButtonPopup);
     }
-
-    xDocSh->DoClose();
 }
 
 void ScPivotTableFiltersTest::testPivotTableDoubleFieldFilter()
 {
-    ScDocShellRef xDocSh = loadDoc(u"pivottable_double_field_filter.", 
FORMAT_XLS);
-    ScDocument& rDoc = xDocSh->GetDocument();
-    ScDPCollection* pDPs = rDoc.GetDPCollection();
+    createScDoc("xls/pivottable_double_field_filter.xls");
+    ScDocument* pDoc = getScDoc();
+    ScDPCollection* pDPs = pDoc->GetDPCollection();
     CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(3), pDPs->GetCount());
 
     // Reload and check filtering of row dimensions
-    xDocSh = saveAndReload(*xDocSh, FORMAT_XLS);
-    CPPUNIT_ASSERT_MESSAGE("Failed to load file", xDocSh.is());
-    ScDocument& rLoadedDoc = xDocSh->GetDocument();
-    pDPs = rLoadedDoc.GetDPCollection();
+    saveAndReload("MS Excel 97");
+    pDoc = getScDoc();
+    pDPs = pDoc->GetDPCollection();
     CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(3), pDPs->GetCount());
 
     // Field with general formatting
@@ -1502,22 +1443,19 @@ void 
ScPivotTableFiltersTest::testPivotTableDoubleFieldFilter()
         CPPUNIT_ASSERT(pMember->HasIsVisible());
         CPPUNIT_ASSERT(pMember->GetIsVisible());
     }
-
-    xDocSh->DoClose();
 }
 
 void ScPivotTableFiltersTest::testPivotTableStringFieldFilter()
 {
-    ScDocShellRef xDocSh = loadDoc(u"pivottable_string_field_filter.", 
FORMAT_XLS);
-    ScDocument& rDoc = xDocSh->GetDocument();
-    ScDPCollection* pDPs = rDoc.GetDPCollection();
+    createScDoc("xls/pivottable_string_field_filter.xls");
+    ScDocument* pDoc = getScDoc();
+    ScDPCollection* pDPs = pDoc->GetDPCollection();
     CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pDPs->GetCount());
 
     // Reload and check filtering of row dimensions
-    xDocSh = saveAndReload(*xDocSh, FORMAT_XLS);
-    CPPUNIT_ASSERT_MESSAGE("Failed to load file", xDocSh.is());
-    ScDocument& rLoadedDoc = xDocSh->GetDocument();
-    pDPs = rLoadedDoc.GetDPCollection();
+    saveAndReload("MS Excel 97");
+    pDoc = getScDoc();
+    pDPs = pDoc->GetDPCollection();
     CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pDPs->GetCount());
 
     const ScDPObject* pDPObj = &(*pDPs)[0];
@@ -1537,22 +1475,19 @@ void 
ScPivotTableFiltersTest::testPivotTableStringFieldFilter()
     CPPUNIT_ASSERT(pMember);
     CPPUNIT_ASSERT(pMember->HasIsVisible());
     CPPUNIT_ASSERT(pMember->GetIsVisible());
-
-    xDocSh->DoClose();
 }
 
 void ScPivotTableFiltersTest::testPivotTableDateFieldFilter()
 {
-    ScDocShellRef xDocSh = loadDoc(u"pivottable_date_field_filter.", 
FORMAT_XLS);
-    ScDocument& rDoc = xDocSh->GetDocument();
-    ScDPCollection* pDPs = rDoc.GetDPCollection();
+    createScDoc("xls/pivottable_date_field_filter.xls");
+    ScDocument* pDoc = getScDoc();
+    ScDPCollection* pDPs = pDoc->GetDPCollection();
     CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pDPs->GetCount());
 
     // Reload and check filtering of row dimensions
-    xDocSh = saveAndReload(*xDocSh, FORMAT_XLS);
-    CPPUNIT_ASSERT_MESSAGE("Failed to load file", xDocSh.is());
-    ScDocument& rLoadedDoc = xDocSh->GetDocument();
-    pDPs = rLoadedDoc.GetDPCollection();
+    saveAndReload("MS Excel 97");
+    pDoc = getScDoc();
+    pDPs = pDoc->GetDPCollection();
     CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pDPs->GetCount());
     const ScDPObject* pDPObj = &(*pDPs)[0];
     CPPUNIT_ASSERT(pDPObj);
@@ -1627,22 +1562,19 @@ void 
ScPivotTableFiltersTest::testPivotTableDateFieldFilter()
         CPPUNIT_ASSERT(pMember->HasIsVisible());
         CPPUNIT_ASSERT(pMember->GetIsVisible());
     }
-
-    xDocSh->DoClose();
 }
 
 void ScPivotTableFiltersTest::testPivotTableBoolFieldFilter()
 {
-    ScDocShellRef xDocSh = loadDoc(u"pivottable_bool_field_filter.", 
FORMAT_XLS);
-    ScDocument& rDoc = xDocSh->GetDocument();
-    ScDPCollection* pDPs = rDoc.GetDPCollection();
+    createScDoc("xls/pivottable_bool_field_filter.xls");
+    ScDocument* pDoc = getScDoc();
+    ScDPCollection* pDPs = pDoc->GetDPCollection();
     CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pDPs->GetCount());
 
     // Reload and check filtering of row dimensions
-    xDocSh = saveAndReload(*xDocSh, FORMAT_XLS);
-    CPPUNIT_ASSERT_MESSAGE("Failed to load file", xDocSh.is());
-    ScDocument& rLoadedDoc = xDocSh->GetDocument();
-    pDPs = rLoadedDoc.GetDPCollection();
+    saveAndReload("MS Excel 97");
+    pDoc = getScDoc();
+    pDPs = pDoc->GetDPCollection();
     CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pDPs->GetCount());
     const ScDPObject* pDPObj = &(*pDPs)[0];
     CPPUNIT_ASSERT(pDPObj);
@@ -1662,22 +1594,19 @@ void 
ScPivotTableFiltersTest::testPivotTableBoolFieldFilter()
     CPPUNIT_ASSERT(pMember);
     CPPUNIT_ASSERT(pMember->HasIsVisible());
     CPPUNIT_ASSERT(pMember->GetIsVisible());
-
-    xDocSh->DoClose();
 }
 
 void ScPivotTableFiltersTest::testPivotTableRowColPageFieldFilter()
 {
-    ScDocShellRef xDocSh = loadDoc(u"pivottable_rowcolpage_field_filter.", 
FORMAT_XLS);
-    ScDocument& rDoc = xDocSh->GetDocument();
-    ScDPCollection* pDPs = rDoc.GetDPCollection();
+    createScDoc("xls/pivottable_rowcolpage_field_filter.xls");
+    ScDocument* pDoc = getScDoc();
+    ScDPCollection* pDPs = pDoc->GetDPCollection();
     CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pDPs->GetCount());
 
     // Reload and check filtering of row dimensions
-    xDocSh = saveAndReload(*xDocSh, FORMAT_XLS);
-    CPPUNIT_ASSERT_MESSAGE("Failed to load file", xDocSh.is());
-    ScDocument& rLoadedDoc = xDocSh->GetDocument();
-    pDPs = rLoadedDoc.GetDPCollection();
+    saveAndReload("MS Excel 97");
+    pDoc = getScDoc();
+    pDPs = pDoc->GetDPCollection();
     CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pDPs->GetCount());
     const ScDPObject* pDPObj = &(*pDPs)[0];
     CPPUNIT_ASSERT(pDPObj);
@@ -1771,22 +1700,19 @@ void 
ScPivotTableFiltersTest::testPivotTableRowColPageFieldFilter()
         CPPUNIT_ASSERT(pMember->HasIsVisible());
         CPPUNIT_ASSERT(pMember->GetIsVisible());
     }
-
-    xDocSh->DoClose();
 }
 
 void ScPivotTableFiltersTest::testPivotTableEmptyItem()
 {
-    ScDocShellRef xDocSh = loadDoc(u"pivottable_empty_item.", FORMAT_XLS);
-    ScDocument& rDoc = xDocSh->GetDocument();
-    ScDPCollection* pDPs = rDoc.GetDPCollection();
+    createScDoc("xls/pivottable_empty_item.xls");
+    ScDocument* pDoc = getScDoc();
+    ScDPCollection* pDPs = pDoc->GetDPCollection();
     CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pDPs->GetCount());
 
     // Reload and check filtering of row dimensions
-    xDocSh = saveAndReload(*xDocSh, FORMAT_XLS);
-    CPPUNIT_ASSERT_MESSAGE("Failed to load file", xDocSh.is());
-    ScDocument& rLoadedDoc = xDocSh->GetDocument();
-    pDPs = rLoadedDoc.GetDPCollection();
+    saveAndReload("MS Excel 97");
+    pDoc = getScDoc();
+    pDPs = pDoc->GetDPCollection();
     CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pDPs->GetCount());
     const ScDPObject* pDPObj = &(*pDPs)[0];
     CPPUNIT_ASSERT(pDPObj);
@@ -1810,22 +1736,19 @@ void ScPivotTableFiltersTest::testPivotTableEmptyItem()
     CPPUNIT_ASSERT(pMember);
     CPPUNIT_ASSERT(pMember->HasIsVisible());
     CPPUNIT_ASSERT(!pMember->GetIsVisible());
-
-    xDocSh->DoClose();
 }
 
 void ScPivotTableFiltersTest::testPivotTablePageFieldFilter()
 {
-    ScDocShellRef xDocSh = loadDoc(u"pivottable_page_field_filter.", 
FORMAT_XLS);
-    ScDocument& rDoc = xDocSh->GetDocument();
-    ScDPCollection* pDPs = rDoc.GetDPCollection();
+    createScDoc("xls/pivottable_page_field_filter.xls");
+    ScDocument* pDoc = getScDoc();
+    ScDPCollection* pDPs = pDoc->GetDPCollection();
     CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pDPs->GetCount());
 
     // Reload and check filtering of row dimensions
-    xDocSh = saveAndReload(*xDocSh, FORMAT_XLS);
-    CPPUNIT_ASSERT_MESSAGE("Failed to load file", xDocSh.is());
-    ScDocument& rLoadedDoc = xDocSh->GetDocument();
-    pDPs = rLoadedDoc.GetDPCollection();
+    saveAndReload("MS Excel 97");
+    pDoc = getScDoc();
+    pDPs = pDoc->GetDPCollection();
     CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pDPs->GetCount());
     const ScDPObject* pDPObj = &(*pDPs)[0];
     CPPUNIT_ASSERT(pDPObj);
@@ -1914,46 +1837,39 @@ void 
ScPivotTableFiltersTest::testPivotTablePageFieldFilter()
         CPPUNIT_ASSERT(pMember->HasIsVisible());
         CPPUNIT_ASSERT(!pMember->GetIsVisible());
     }
-
-    xDocSh->DoClose();
 }
 
 void ScPivotTableFiltersTest::testPivotTableFirstHeaderRowXLSX()
 {
     // tdf#112733: We have different tables here, but have the same value as 
firstHeaderRow
     // The documentation is not clear about what firstHeaderRow actually 
means, but MS Excel works on this way
-    ScDocShellRef xShell = loadDoc(u"pivot_table_first_header_row.", 
FORMAT_XLSX);
+    createScDoc("xlsx/pivot_table_first_header_row.xlsx");
 
-    std::shared_ptr<utl::TempFileNamed> pXPathFile
-        = ScBootstrapFixture::exportTo(*xShell, FORMAT_XLSX);
-    xmlDocUniquePtr pTable
-        = XPathHelper::parseExport(pXPathFile, m_xSFactory, 
"xl/pivotTables/pivotTable1.xml");
+    save("Calc Office Open XML");
+    xmlDocUniquePtr pTable = parseExport("xl/pivotTables/pivotTable1.xml");
     CPPUNIT_ASSERT(pTable);
     assertXPath(pTable, "/x:pivotTableDefinition/x:location", 
"firstHeaderRow", "1");
 
-    pTable = XPathHelper::parseExport(pXPathFile, m_xSFactory, 
"xl/pivotTables/pivotTable2.xml");
+    pTable = parseExport("xl/pivotTables/pivotTable2.xml");
     CPPUNIT_ASSERT(pTable);
     assertXPath(pTable, "/x:pivotTableDefinition/x:location", 
"firstHeaderRow", "1");
 
-    pTable = XPathHelper::parseExport(pXPathFile, m_xSFactory, 
"xl/pivotTables/pivotTable3.xml");
+    pTable = parseExport("xl/pivotTables/pivotTable3.xml");
     CPPUNIT_ASSERT(pTable);
     assertXPath(pTable, "/x:pivotTableDefinition/x:location", 
"firstHeaderRow", "1");
-
-    xShell->DoClose();
 }
 
 void ScPivotTableFiltersTest::testPivotTableDoubleFieldFilterXLSX()
 {
-    ScDocShellRef xDocSh = loadDoc(u"pivottable_double_field_filter.", 
FORMAT_XLSX);
-    ScDocument& rDoc = xDocSh->GetDocument();
-    ScDPCollection* pDPs = rDoc.GetDPCollection();
+    createScDoc("xlsx/pivottable_double_field_filter.xlsx");
+    ScDocument* pDoc = getScDoc();
+    ScDPCollection* pDPs = pDoc->GetDPCollection();
     CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(3), pDPs->GetCount());
 
     // Reload and check filtering of row dimensions
-    xDocSh = saveAndReload(*xDocSh, FORMAT_XLSX);
-    CPPUNIT_ASSERT_MESSAGE("Failed to load file", xDocSh.is());
-    ScDocument& rLoadedDoc = xDocSh->GetDocument();
-    pDPs = rLoadedDoc.GetDPCollection();
+    saveAndReload("Calc Office Open XML");
+    pDoc = getScDoc();
+    pDPs = pDoc->GetDPCollection();
     CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(3), pDPs->GetCount());
 
     // Field with general formatting
@@ -2039,22 +1955,19 @@ void 
ScPivotTableFiltersTest::testPivotTableDoubleFieldFilterXLSX()
         CPPUNIT_ASSERT(pMember->HasIsVisible());
         CPPUNIT_ASSERT(pMember->GetIsVisible());
     }
-
-    xDocSh->DoClose();
 }
 
 void ScPivotTableFiltersTest::testPivotTableStringFieldFilterXLSX()
 {
-    ScDocShellRef xDocSh = loadDoc(u"pivottable_string_field_filter.", 
FORMAT_XLSX);
-    ScDocument& rDoc = xDocSh->GetDocument();
-    ScDPCollection* pDPs = rDoc.GetDPCollection();
+    createScDoc("xlsx/pivottable_string_field_filter.xlsx");
+    ScDocument* pDoc = getScDoc();
+    ScDPCollection* pDPs = pDoc->GetDPCollection();
     CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pDPs->GetCount());
 
     // Reload and check filtering of row dimensions
-    xDocSh = saveAndReload(*xDocSh, FORMAT_XLSX);
-    CPPUNIT_ASSERT_MESSAGE("Failed to load file", xDocSh.is());
-    ScDocument& rLoadedDoc = xDocSh->GetDocument();
-    pDPs = rLoadedDoc.GetDPCollection();
+    saveAndReload("Calc Office Open XML");
+    pDoc = getScDoc();
+    pDPs = pDoc->GetDPCollection();
     CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pDPs->GetCount());
 
     const ScDPObject* pDPObj = &(*pDPs)[0];
@@ -2074,22 +1987,19 @@ void 
ScPivotTableFiltersTest::testPivotTableStringFieldFilterXLSX()
     CPPUNIT_ASSERT(pMember);
     CPPUNIT_ASSERT(pMember->HasIsVisible());
     CPPUNIT_ASSERT(pMember->GetIsVisible());
-
-    xDocSh->DoClose();
 }
 
 void ScPivotTableFiltersTest::testPivotTableDateFieldFilterXLSX()
 {
-    ScDocShellRef xDocSh = loadDoc(u"pivottable_date_field_filter.", 
FORMAT_XLSX);
-    ScDocument& rDoc = xDocSh->GetDocument();
-    ScDPCollection* pDPs = rDoc.GetDPCollection();
+    createScDoc("xlsx/pivottable_date_field_filter.xlsx");
+    ScDocument* pDoc = getScDoc();
+    ScDPCollection* pDPs = pDoc->GetDPCollection();
     CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pDPs->GetCount());
 
     // Reload and check filtering of row dimensions
-    xDocSh = saveAndReload(*xDocSh, FORMAT_XLSX);
-    CPPUNIT_ASSERT_MESSAGE("Failed to load file", xDocSh.is());
-    ScDocument& rLoadedDoc = xDocSh->GetDocument();
-    pDPs = rLoadedDoc.GetDPCollection();
+    saveAndReload("Calc Office Open XML");
+    pDoc = getScDoc();
+    pDPs = pDoc->GetDPCollection();
     CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pDPs->GetCount());
     const ScDPObject* pDPObj = &(*pDPs)[0];
     CPPUNIT_ASSERT(pDPObj);
@@ -2111,7 +2021,7 @@ void 
ScPivotTableFiltersTest::testPivotTableDateFieldFilterXLSX()
         pMember = *aIter; // "2016. január 8."
         CPPUNIT_ASSERT(pMember);
         CPPUNIT_ASSERT(pMember->HasIsVisible());
-        CPPUNIT_ASSERT(!pMember->GetIsVisible());
+        CPPUNIT_ASSERT(pMember->GetIsVisible());
     }
 
     {
@@ -2129,7 +2039,7 @@ void 
ScPivotTableFiltersTest::testPivotTableDateFieldFilterXLSX()
         pMember = *aIter; // "2016-01-08"
         CPPUNIT_ASSERT(pMember);
         CPPUNIT_ASSERT(pMember->HasIsVisible());
-        CPPUNIT_ASSERT(!pMember->GetIsVisible());
+        CPPUNIT_ASSERT(pMember->GetIsVisible());
     }
 
     {
@@ -2142,30 +2052,27 @@ void 
ScPivotTableFiltersTest::testPivotTableDateFieldFilterXLSX()
         ScDPSaveMember* pMember = *aIter; // "2016. 1. 7. 0:00"
         CPPUNIT_ASSERT(pMember);
         CPPUNIT_ASSERT(pMember->HasIsVisible());
-        CPPUNIT_ASSERT(!pMember->GetIsVisible());
+        CPPUNIT_ASSERT(pMember->GetIsVisible());
         ++aIter;
         pMember = *aIter; // "2016. 1. 8. 0:00"
         CPPUNIT_ASSERT(pMember);
         CPPUNIT_ASSERT(pMember->HasIsVisible());
-        CPPUNIT_ASSERT(pMember->GetIsVisible());
+        CPPUNIT_ASSERT(!pMember->GetIsVisible());
     }
-
-    xDocSh->DoClose();
 }
 
 void ScPivotTableFiltersTest::testPivotTableBoolFieldFilterXLSX()
 {
-    ScDocShellRef xDocSh = loadDoc(u"pivottable_bool_field_filter.", 
FORMAT_XLSX);
-    ScDocument& rDoc = xDocSh->GetDocument();
-    ScDPCollection* pDPs = rDoc.GetDPCollection();
+    createScDoc("xlsx/pivottable_bool_field_filter.xlsx");
+    ScDocument* pDoc = getScDoc();
+    ScDPCollection* pDPs = pDoc->GetDPCollection();
     CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pDPs->GetCount());
-    CPPUNIT_ASSERT_EQUAL(OUString("TRUE"), rDoc.GetString(ScAddress(0, 1, 
0))); //A2
+    CPPUNIT_ASSERT_EQUAL(OUString("TRUE"), pDoc->GetString(ScAddress(0, 1, 
0))); //A2
 
     // Reload and check filtering of row dimensions
-    xDocSh = saveAndReload(*xDocSh, FORMAT_XLSX);
-    CPPUNIT_ASSERT_MESSAGE("Failed to load file", xDocSh.is());
-    ScDocument& rLoadedDoc = xDocSh->GetDocument();
-    pDPs = rLoadedDoc.GetDPCollection();
+    saveAndReload("Calc Office Open XML");
+    pDoc = getScDoc();
+    pDPs = pDoc->GetDPCollection();
     CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pDPs->GetCount());
     const ScDPObject* pDPObj = &(*pDPs)[0];
     CPPUNIT_ASSERT(pDPObj);
@@ -2185,22 +2092,19 @@ void 
ScPivotTableFiltersTest::testPivotTableBoolFieldFilterXLSX()
     CPPUNIT_ASSERT(pMember);
     CPPUNIT_ASSERT(pMember->HasIsVisible());
     CPPUNIT_ASSERT(pMember->GetIsVisible());
-
-    xDocSh->DoClose();
 }
 
 void ScPivotTableFiltersTest::testPivotTableRowColPageFieldFilterXLSX()
 {
-    ScDocShellRef xDocSh = loadDoc(u"pivottable_rowcolpage_field_filter.", 
FORMAT_XLSX);
-    ScDocument& rDoc = xDocSh->GetDocument();
-    ScDPCollection* pDPs = rDoc.GetDPCollection();
+    createScDoc("xlsx/pivottable_rowcolpage_field_filter.xlsx");
+    ScDocument* pDoc = getScDoc();
+    ScDPCollection* pDPs = pDoc->GetDPCollection();
     CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pDPs->GetCount());
 
     // Reload and check filtering of row dimensions
-    xDocSh = saveAndReload(*xDocSh, FORMAT_XLSX);
-    CPPUNIT_ASSERT_MESSAGE("Failed to load file", xDocSh.is());
-    ScDocument& rLoadedDoc = xDocSh->GetDocument();
-    pDPs = rLoadedDoc.GetDPCollection();
+    saveAndReload("Calc Office Open XML");
+    pDoc = getScDoc();
+    pDPs = pDoc->GetDPCollection();
     CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pDPs->GetCount());
     const ScDPObject* pDPObj = &(*pDPs)[0];
     CPPUNIT_ASSERT(pDPObj);
@@ -2292,22 +2196,19 @@ void 
ScPivotTableFiltersTest::testPivotTableRowColPageFieldFilterXLSX()
         CPPUNIT_ASSERT(pMember);
         CPPUNIT_ASSERT(pMember->HasIsVisible() && pMember->GetIsVisible());
     }*/
-
-    xDocSh->DoClose();
 }
 
 void ScPivotTableFiltersTest::testPivotTableErrorItemFilterXLSX()
 {
-    ScDocShellRef xDocSh = loadDoc(u"pivottable_error_item_filter.", 
FORMAT_XLSX);
-    ScDocument& rDoc = xDocSh->GetDocument();
-    ScDPCollection* pDPs = rDoc.GetDPCollection();
+    createScDoc("xlsx/pivottable_error_item_filter.xlsx");
+    ScDocument* pDoc = getScDoc();
+    ScDPCollection* pDPs = pDoc->GetDPCollection();
     CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pDPs->GetCount());
 
     // Reload and check whether filtering is preserved
-    xDocSh = saveAndReload(*xDocSh, FORMAT_XLSX);
-    CPPUNIT_ASSERT_MESSAGE("Failed to load file", xDocSh.is());
-    ScDocument& rLoadedDoc = xDocSh->GetDocument();
-    pDPs = rLoadedDoc.GetDPCollection();
+    saveAndReload("Calc Office Open XML");
+    pDoc = getScDoc();
+    pDPs = pDoc->GetDPCollection();
     CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pDPs->GetCount());
     const ScDPObject* pDPObj = &(*pDPs)[0];
     CPPUNIT_ASSERT(pDPObj);
@@ -2322,15 +2223,13 @@ void 
ScPivotTableFiltersTest::testPivotTableErrorItemFilterXLSX()
     CPPUNIT_ASSERT(pMember);
     CPPUNIT_ASSERT(pMember->HasIsVisible());
     CPPUNIT_ASSERT(!pMember->GetIsVisible());
-
-    xDocSh->DoClose();
 }
 
 void ScPivotTableFiltersTest::testPivotTableErrorItemFilterXLSB()
 {
-    ScDocShellRef xDocSh = loadDoc(u"pivottable_error_item_filter.", 
FORMAT_XLSB);
-    ScDocument& rDoc = xDocSh->GetDocument();
-    ScDPCollection* pDPs = rDoc.GetDPCollection();
+    createScDoc("xlsb/pivottable_error_item_filter.xlsb");
+    ScDocument* pDoc = getScDoc();
+    ScDPCollection* pDPs = pDoc->GetDPCollection();
     CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pDPs->GetCount());
     const ScDPObject* pDPObj = &(*pDPs)[0];
     CPPUNIT_ASSERT(pDPObj);
@@ -2345,22 +2244,19 @@ void 
ScPivotTableFiltersTest::testPivotTableErrorItemFilterXLSB()
     CPPUNIT_ASSERT(pMember);
     CPPUNIT_ASSERT(pMember->HasIsVisible());
     CPPUNIT_ASSERT(!pMember->GetIsVisible());
-
-    xDocSh->DoClose();
 }
 
 void ScPivotTableFiltersTest::testPivotTableErrorItem2FilterXLSX()
 {
-    ScDocShellRef xDocSh = loadDoc(u"tdf122471.", FORMAT_XLSX);
-    ScDocument& rDoc = xDocSh->GetDocument();
-    ScDPCollection* pDPs = rDoc.GetDPCollection();
+    createScDoc("xlsx/tdf122471.xlsx");
+    ScDocument* pDoc = getScDoc();
+    ScDPCollection* pDPs = pDoc->GetDPCollection();
     CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pDPs->GetCount());
 
     // Reload and check whether filtering is preserved
-    xDocSh = saveAndReload(*xDocSh, FORMAT_XLSX);
-    CPPUNIT_ASSERT_MESSAGE("Failed to load file", xDocSh.is());
-    ScDocument& rLoadedDoc = xDocSh->GetDocument();
-    pDPs = rLoadedDoc.GetDPCollection();
+    saveAndReload("Calc Office Open XML");
+    pDoc = getScDoc();
+    pDPs = pDoc->GetDPCollection();
     CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pDPs->GetCount());
     const ScDPObject* pDPObj = &(*pDPs)[0];
     CPPUNIT_ASSERT(pDPObj);
@@ -2372,18 +2268,14 @@ void 
ScPivotTableFiltersTest::testPivotTableErrorItem2FilterXLSX()
     const ScDPSaveDimension::MemberList& rMembers = pSaveDim->GetMembers();
     // prior to the patch, columns were missing due to an exception dropping 
the column data
     CPPUNIT_ASSERT_EQUAL(size_t(21), rMembers.size());
-
-    xDocSh->DoClose();
 }
 
 void ScPivotTableFiltersTest::testPivotTableOutlineModeXLSX()
 {
-    ScDocShellRef xShell = loadDoc(u"pivottable_outline_mode.", FORMAT_XLSX);
+    createScDoc("xlsx/pivottable_outline_mode.xlsx");
 
-    std::shared_ptr<utl::TempFileNamed> pXPathFile
-        = ScBootstrapFixture::exportTo(*xShell, FORMAT_XLSX);
-    xmlDocUniquePtr pTable
-        = XPathHelper::parseExport(pXPathFile, m_xSFactory, 
"xl/pivotTables/pivotTable1.xml");
+    save("Calc Office Open XML");
+    xmlDocUniquePtr pTable = parseExport("xl/pivotTables/pivotTable1.xml");
     CPPUNIT_ASSERT(pTable);
 
     // Next to the outline flags, compact flags also should be set (true is 
the default)
@@ -2392,18 +2284,14 @@ void 
ScPivotTableFiltersTest::testPivotTableOutlineModeXLSX()
     assertXPath(pTable, "/x:pivotTableDefinition", "compact", "0");
     assertXPath(pTable, "/x:pivotTableDefinition", "compactData", "0");
     assertXPath(pTable, 
"/x:pivotTableDefinition/x:pivotFields/x:pivotField[1]", "compact", "0");
-
-    xShell->DoClose();
 }
 
 void ScPivotTableFiltersTest::testPivotTableDuplicatedMemberFilterXLSX()
 {
-    ScDocShellRef xShell = loadDoc(u"pivottable_duplicated_member_filter.", 
FORMAT_XLSX);
+    createScDoc("xlsx/pivottable_duplicated_member_filter.xlsx");
 
-    std::shared_ptr<utl::TempFileNamed> pXPathFile
-        = ScBootstrapFixture::exportTo(*xShell, FORMAT_XLSX);
-    xmlDocUniquePtr pTable
-        = XPathHelper::parseExport(pXPathFile, m_xSFactory, 
"xl/pivotTables/pivotTable1.xml");
+    save("Calc Office Open XML");
+    xmlDocUniquePtr pTable = parseExport("xl/pivotTables/pivotTable1.xml");
     CPPUNIT_ASSERT(pTable);
 
     // Check whether page field has the right number of items
@@ -2411,18 +2299,14 @@ void 
ScPivotTableFiltersTest::testPivotTableDuplicatedMemberFilterXLSX()
                 "axisPage");
     assertXPath(pTable, 
"/x:pivotTableDefinition/x:pivotFields/x:pivotField[5]/x:items", "count",
                 "21");
-
-    xShell->DoClose();
 }
 
 void ScPivotTableFiltersTest::testPivotTableTabularModeXLSX()
 {
-    ScDocShellRef xShell = loadDoc(u"pivottable_tabular_mode.", FORMAT_XLSX);
+    createScDoc("xlsx/pivottable_tabular_mode.xlsx");
 
-    std::shared_ptr<utl::TempFileNamed> pXPathFile
-        = ScBootstrapFixture::exportTo(*xShell, FORMAT_XLSX);
-    xmlDocUniquePtr pTable
-        = XPathHelper::parseExport(pXPathFile, m_xSFactory, 
"xl/pivotTables/pivotTable1.xml");
+    save("Calc Office Open XML");
+    xmlDocUniquePtr pTable = parseExport("xl/pivotTables/pivotTable1.xml");
     CPPUNIT_ASSERT(pTable);
 
     // In tabular mode both outline and compact flag should be false
@@ -2432,18 +2316,14 @@ void 
ScPivotTableFiltersTest::testPivotTableTabularModeXLSX()
     assertXPath(pTable, "/x:pivotTableDefinition", "compactData", "0");
     assertXPath(pTable, 
"/x:pivotTableDefinition/x:pivotFields/x:pivotField[1]", "compact", "0");
     assertXPath(pTable, 
"/x:pivotTableDefinition/x:pivotFields/x:pivotField[1]", "outline", "0");
-
-    xShell->DoClose();
 }
 
 void ScPivotTableFiltersTest::testPivotTableDuplicateFields()
 {
-    ScDocShellRef xShell = loadDoc(u"caseinsensitive-duplicate-fields.", 
FORMAT_ODS);
+    createScDoc("ods/caseinsensitive-duplicate-fields.ods");
 
-    std::shared_ptr<utl::TempFileNamed> pXPathFile
-        = ScBootstrapFixture::exportTo(*xShell, FORMAT_XLSX);
-    xmlDocUniquePtr pCacheDef = XPathHelper::parseExport(pXPathFile, 
m_xSFactory,
-                                                         
"xl/pivotCache/pivotCacheDefinition1.xml");
+    save("Calc Office Open XML");
+    xmlDocUniquePtr pCacheDef = 
parseExport("xl/pivotCache/pivotCacheDefinition1.xml");
     CPPUNIT_ASSERT(pCacheDef);
 
     assertXPath(pCacheDef, "/x:pivotCacheDefinition/x:cacheFields", "count", 
"6");
@@ -2457,22 +2337,19 @@ void 
ScPivotTableFiltersTest::testPivotTableDuplicateFields()
                 "method2");
     assertXPath(pCacheDef, 
"/x:pivotCacheDefinition/x:cacheFields/x:cacheField[6]", "name",
                 "Method3");
-
-    xShell->DoClose();
 }
 
 void ScPivotTableFiltersTest::testTdf112106()
 {
-    ScDocShellRef xDocSh = loadDoc(u"tdf112106.", FORMAT_XLSX);
-    ScDocument& rDoc = xDocSh->GetDocument();
-    ScDPCollection* pDPs = rDoc.GetDPCollection();
+    createScDoc("xlsx/tdf112106.xlsx");
+    ScDocument* pDoc = getScDoc();
+    ScDPCollection* pDPs = pDoc->GetDPCollection();
     CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pDPs->GetCount());
 
     // Reload and check data layout dim
-    xDocSh = saveAndReload(*xDocSh, FORMAT_XLS);
-    CPPUNIT_ASSERT_MESSAGE("Failed to load file", xDocSh.is());
-    ScDocument& rLoadedDoc = xDocSh->GetDocument();
-    pDPs = rLoadedDoc.GetDPCollection();
+    saveAndReload("MS Excel 97");
+    pDoc = getScDoc();
+    pDPs = pDoc->GetDPCollection();
     CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pDPs->GetCount());
     const ScDPObject* pDPObj = &(*pDPs)[0];
     CPPUNIT_ASSERT(pDPObj);
@@ -2485,20 +2362,16 @@ void ScPivotTableFiltersTest::testTdf112106()
     const std::optional<OUString>& pLayoutName = pDim->GetLayoutName();
     CPPUNIT_ASSERT(pLayoutName);
     CPPUNIT_ASSERT_EQUAL(ScResId(STR_PIVOT_DATA), (*pLayoutName));
-
-    xDocSh->DoClose();
 }
 
 void ScPivotTableFiltersTest::testTdf123923()
 {
     // tdf#123923: Excel fails when it finds "Err:504" instead of "#REF!" in 
pivot table cache
 
-    ScDocShellRef xShell = loadDoc(u"pivot-table-err-in-cache.", FORMAT_ODS);
+    createScDoc("ods/pivot-table-err-in-cache.ods");
 
-    std::shared_ptr<utl::TempFileNamed> pXPathFile
-        = ScBootstrapFixture::exportTo(*xShell, FORMAT_XLSX);
-    xmlDocUniquePtr pTable = XPathHelper::parseExport(pXPathFile, m_xSFactory,
-                                                      
"xl/pivotCache/pivotCacheDefinition1.xml");
+    save("Calc Office Open XML");
+    xmlDocUniquePtr pTable = 
parseExport("xl/pivotCache/pivotCacheDefinition1.xml");
     CPPUNIT_ASSERT(pTable);
 
     assertXPath(pTable, 
"/x:pivotCacheDefinition/x:cacheFields/x:cacheField[1]/x:sharedItems/x:e",
@@ -2509,12 +2382,10 @@ void ScPivotTableFiltersTest::testTdf123939()
 {
     // tdf#123939: Excel warns on containsMixedTypes="1" if sharedItems has 
only strings and errors
 
-    ScDocShellRef xShell = loadDoc(u"pivot-table-str-and-err-in-data.", 
FORMAT_ODS);
+    createScDoc("ods/pivot-table-str-and-err-in-data.ods");
 
-    std::shared_ptr<utl::TempFileNamed> pXPathFile
-        = ScBootstrapFixture::exportTo(*xShell, FORMAT_XLSX);
-    xmlDocUniquePtr pTable = XPathHelper::parseExport(pXPathFile, m_xSFactory,
-                                                      
"xl/pivotCache/pivotCacheDefinition1.xml");
+    save("Calc Office Open XML");
+    xmlDocUniquePtr pTable = 
parseExport("xl/pivotCache/pivotCacheDefinition1.xml");
     CPPUNIT_ASSERT(pTable);
 
     assertXPathNoAttribute(pTable,
@@ -2523,8 +2394,7 @@ void ScPivotTableFiltersTest::testTdf123939()
 
     // But we must emit containsMixedTypes="1" for a mix of errors and 
non-string types!
 
-    pTable = XPathHelper::parseExport(pXPathFile, m_xSFactory,
-                                      
"xl/pivotCache/pivotCacheDefinition2.xml");
+    pTable = parseExport("xl/pivotCache/pivotCacheDefinition2.xml");
     CPPUNIT_ASSERT(pTable);
 
     assertXPath(pTable, 
"/x:pivotCacheDefinition/x:cacheFields/x:cacheField[1]/x:sharedItems",
@@ -2533,10 +2403,10 @@ void ScPivotTableFiltersTest::testTdf123939()
 
 void ScPivotTableFiltersTest::testTdf124651()
 {
-    ScDocShellRef xDocSh = loadDoc(u"tdf124651_simplePivotTable.", FORMAT_ODS);
+    createScDoc("ods/tdf124651_simplePivotTable.ods");
 
-    xmlDocUniquePtr pDoc = XPathHelper::parseExport2(*this, *xDocSh, 
m_xSFactory,
-                                                     
"xl/pivotTables/pivotTable1.xml", FORMAT_XLSX);
+    save("Calc Office Open XML");
+    xmlDocUniquePtr pDoc = parseExport("xl/pivotTables/pivotTable1.xml");
     CPPUNIT_ASSERT(pDoc);
     // We have to export name attribute, even though it's optional according 
to ECMA-376 standard,
     // because Excel (at least 2016) seems to require it.
@@ -2546,14 +2416,11 @@ void ScPivotTableFiltersTest::testTdf124651()
 
 void ScPivotTableFiltersTest::testTdf124736()
 {
-    ScDocShellRef xDocSh = loadDoc(u"pivot-table/shared-dategroup.", 
FORMAT_XLSX);
+    createScDoc("xlsx/pivot-table/shared-dategroup.xlsx");
 
-    std::shared_ptr<utl::TempFileNamed> pXPathFile
-        = ScBootstrapFixture::exportTo(*xDocSh, FORMAT_XLSX);
-    xDocSh->DoClose();
+    save("Calc Office Open XML");
 
-    xmlDocUniquePtr pTable = XPathHelper::parseExport(pXPathFile, m_xSFactory,
-                                                      
"xl/pivotCache/pivotCacheDefinition1.xml");
+    xmlDocUniquePtr pTable = 
parseExport("xl/pivotCache/pivotCacheDefinition1.xml");
     CPPUNIT_ASSERT(pTable);
 
     assertXPath(pTable,
@@ -2579,7 +2446,7 @@ void ScPivotTableFiltersTest::testTdf124736()
 
     // Now check that table references these in correct order 
(document-dependent, so this is how
     // it should be in this specific testdoc which shows "<" and ">" values in 
the end)
-    pTable = XPathHelper::parseExport(pXPathFile, m_xSFactory, 
"xl/pivotTables/pivotTable1.xml");
+    pTable = parseExport("xl/pivotTables/pivotTable1.xml");
     CPPUNIT_ASSERT(pTable);
     assertXPath(pTable, 
"/x:pivotTableDefinition/x:pivotFields/x:pivotField[1]/x:items", "count",
                 "46");
@@ -2599,21 +2466,18 @@ void ScPivotTableFiltersTest::testTdf124736()
 
 void ScPivotTableFiltersTest::tesTtdf124772NumFmt()
 {
-    ScDocShellRef xDocSh = loadDoc(u"pivot-table-num-fmt.", FORMAT_ODS);
+    createScDoc("ods/pivot-table-num-fmt.ods");
 
-    std::shared_ptr<utl::TempFileNamed> pXPathFile
-        = ScBootstrapFixture::exportTo(*xDocSh, FORMAT_XLSX);
-    xDocSh->DoClose();
+    save("Calc Office Open XML");
 
-    xmlDocUniquePtr pTable
-        = XPathHelper::parseExport(pXPathFile, m_xSFactory, 
"xl/pivotTables/pivotTable1.xml");
+    xmlDocUniquePtr pTable = parseExport("xl/pivotTables/pivotTable1.xml");
     CPPUNIT_ASSERT(pTable);
 
     // This asserts that numFmtId attribute is present
     const OUString sXclNumFmt
         = getXPath(pTable, "/x:pivotTableDefinition/x:dataFields/x:dataField", 
"numFmtId");
 
-    pTable = XPathHelper::parseExport(pXPathFile, m_xSFactory, 
"xl/styles.xml");
+    pTable = parseExport("xl/styles.xml");
     CPPUNIT_ASSERT(pTable);
 
     // Check that we refer to correct format
@@ -2625,11 +2489,10 @@ void ScPivotTableFiltersTest::testTdf124810()
 {
     {
         // First, test that we roundtrip existing pivot table style 
information from XLSX.
-        ScDocShellRef xDocSh = loadDoc(u"pivot_dark1.", FORMAT_XLSX);
+        createScDoc("xlsx/pivot_dark1.xlsx");
 
-        xmlDocUniquePtr pTable = XPathHelper::parseExport2(
-            *this, *xDocSh, m_xSFactory, "xl/pivotTables/pivotTable1.xml", 
FORMAT_XLSX);
-        xDocSh->DoClose();
+        save("Calc Office Open XML");
+        xmlDocUniquePtr pTable = parseExport("xl/pivotTables/pivotTable1.xml");
         CPPUNIT_ASSERT(pTable);
 
         // All attributes must have been roundtripped correctly (testdoc uses 
some non-default values)
@@ -2646,11 +2509,10 @@ void ScPivotTableFiltersTest::testTdf124810()
         // Now check that we export default style information when there's no 
such information in
         // original document. Just use some ODS as source. This might be 
changed when we start
         // exporting better pivot table style information.
-        ScDocShellRef xDocSh = loadDoc(u"tdf124651_simplePivotTable.", 
FORMAT_ODS);
+        createScDoc("ods/tdf124651_simplePivotTable.ods");
 
-        xmlDocUniquePtr pTable = XPathHelper::parseExport2(
-            *this, *xDocSh, m_xSFactory, "xl/pivotTables/pivotTable1.xml", 
FORMAT_XLSX);
-        xDocSh->DoClose();
+        save("Calc Office Open XML");
+        xmlDocUniquePtr pTable = parseExport("xl/pivotTables/pivotTable1.xml");
         CPPUNIT_ASSERT(pTable);
 
         // The default style for pivot tables in Excel 2007 through 2016 is 
PivotStyleLight16
@@ -2666,11 +2528,10 @@ void ScPivotTableFiltersTest::testTdf124810()
 
 void ScPivotTableFiltersTest::testTdf124883()
 {
-    ScDocShellRef xDocSh = loadDoc(u"pivot-table/two-data-fields.", 
FORMAT_XLSX);
+    createScDoc("xlsx/pivot-table/two-data-fields.xlsx");
 
-    xmlDocUniquePtr pTable = XPathHelper::parseExport2(
-        *this, *xDocSh, m_xSFactory, "xl/pivotTables/pivotTable1.xml", 
FORMAT_XLSX);
-    xDocSh->DoClose();
+    save("Calc Office Open XML");
+    xmlDocUniquePtr pTable = parseExport("xl/pivotTables/pivotTable1.xml");
     CPPUNIT_ASSERT(pTable);
 
     // The field names must be kept just as they appear in original XLSX
@@ -2682,10 +2543,10 @@ void ScPivotTableFiltersTest::testTdf124883()
 
 void ScPivotTableFiltersTest::testTdf125046()
 {
-    ScDocShellRef xDocSh = loadDoc(u"pivottable_long_text.", FORMAT_XLSX);
+    createScDoc("xlsx/pivottable_long_text.xlsx");
 
-    xmlDocUniquePtr pDoc = XPathHelper::parseExport2(
-        *this, *xDocSh, m_xSFactory, 
"xl/pivotCache/pivotCacheDefinition1.xml", FORMAT_XLSX);
+    save("Calc Office Open XML");
+    xmlDocUniquePtr pDoc = 
parseExport("xl/pivotCache/pivotCacheDefinition1.xml");
     CPPUNIT_ASSERT(pDoc);
     assertXPath(pDoc, 
"/x:pivotCacheDefinition/x:cacheFields/x:cacheField[2]/x:sharedItems",
                 "longText", "1");
@@ -2693,10 +2554,10 @@ void ScPivotTableFiltersTest::testTdf125046()
 
 void ScPivotTableFiltersTest::testTdf125055()
 {
-    ScDocShellRef xDocSh = loadDoc(u"pivottable_1s_difference.", FORMAT_XLSX);
+    createScDoc("xlsx/pivottable_1s_difference.xlsx");
 
-    xmlDocUniquePtr pDoc = XPathHelper::parseExport2(
-        *this, *xDocSh, m_xSFactory, 
"xl/pivotCache/pivotCacheDefinition1.xml", FORMAT_XLSX);
+    save("Calc Office Open XML");
+    xmlDocUniquePtr pDoc = 
parseExport("xl/pivotCache/pivotCacheDefinition1.xml");
     CPPUNIT_ASSERT(pDoc);
 
     // 1-second precision should not result in duplicated entries for values 
different by ~1 s.
@@ -2728,10 +2589,10 @@ void ScPivotTableFiltersTest::testTdf125055()
 
 void ScPivotTableFiltersTest::testTdf125086()
 {
-    ScDocShellRef xDocSh = loadDoc(u"pivottable_fieldInRowsAndData.", 
FORMAT_ODS);
+    createScDoc("ods/pivottable_fieldInRowsAndData.ods");
 
-    xmlDocUniquePtr pDoc = XPathHelper::parseExport2(*this, *xDocSh, 
m_xSFactory,
-                                                     
"xl/pivotTables/pivotTable1.xml", FORMAT_XLSX);
+    save("Calc Office Open XML");
+    xmlDocUniquePtr pDoc = parseExport("xl/pivotTables/pivotTable1.xml");
     CPPUNIT_ASSERT(pDoc);
     assertXPath(pDoc, "/x:pivotTableDefinition/x:pivotFields/x:pivotField[2]", 
"axis", "axisRow");
     // "dataField" attribute was not written for this "axisRow" field
@@ -2742,9 +2603,9 @@ void ScPivotTableFiltersTest::testTdf73845()
 {
     // Query filter is set for individual pivot table in this ODS document.
     // This test checks the query filter is restored for ByEmpty and 
ByNonEmpty query.
-    ScDocShellRef xDocSh = loadDoc(u"pivottable_restore_query_filter.", 
FORMAT_ODS);
-    ScDocument& rDoc = xDocSh->GetDocument();
-    ScDPCollection* pDPs = rDoc.GetDPCollection();
+    createScDoc("ods/pivottable_restore_query_filter.ods");
+    ScDocument* pDoc = getScDoc();
+    ScDPCollection* pDPs = pDoc->GetDPCollection();
     CPPUNIT_ASSERT_MESSAGE("Failed to get a live ScDPCollection instance.", 
pDPs);
 
     // Three pivot tables are created in the spreadsheet. Query filters are 
set as follow:

Reply via email to