sc/qa/unit/filters-test.cxx             |   20 
 sc/qa/unit/helper/qahelper.cxx          |   44 
 sc/qa/unit/helper/qahelper.hxx          |   22 
 sc/qa/unit/subsequent_export_test.cxx   |    6 
 sc/qa/unit/subsequent_filters_test2.cxx | 1451 +++++++++++++-------------------
 5 files changed, 649 insertions(+), 894 deletions(-)

New commits:
commit ad40ad91c5400391a0848832e91c596be8fbd811
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Tue Nov 15 12:59:53 2022 +0100
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Tue Nov 15 17:57:35 2022 +0100

    CppunitTest_sc_subsequent_filters_test2: inherit from UnoApiXmlTest
    
    I couldn't find a way to test testTooManyColsRows,
    move it to sc/qa/unit/filters-test.cxx for the
    time being
    
    Change-Id: Ie841dea8aeebcbeff8c9a75ddb91d134c2b52c53
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142741
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sc/qa/unit/filters-test.cxx b/sc/qa/unit/filters-test.cxx
index 91422c840ca2..862768af8390 100644
--- a/sc/qa/unit/filters-test.cxx
+++ b/sc/qa/unit/filters-test.cxx
@@ -26,6 +26,7 @@
 #include <globalnames.hxx>
 #include <dbdata.hxx>
 #include <sortparam.hxx>
+#include <scerrors.hxx>
 #include <scopetools.hxx>
 #include <scmod.hxx>
 #include <undomanager.hxx>
@@ -84,6 +85,7 @@ public:
     void testSortWithSheetExternalReferencesODS_Impl( ScDocShellRef const & 
xDocShRef, SCROW nRow1, SCROW nRow2,
             bool bCheckRelativeInSheet );
     void testSortWithFormattingXLS();
+    void testTooManyColsRows();
     void testForcepoint107();
 
     CPPUNIT_TEST_SUITE(ScFiltersTest);
@@ -112,6 +114,7 @@ public:
     CPPUNIT_TEST(testSortWithSharedFormulasODS);
     CPPUNIT_TEST(testSortWithSheetExternalReferencesODS);
     CPPUNIT_TEST(testSortWithFormattingXLS);
+    CPPUNIT_TEST(testTooManyColsRows);
     CPPUNIT_TEST(testForcepoint107);
 
     CPPUNIT_TEST_SUITE_END();
@@ -887,6 +890,23 @@ void ScFiltersTest::testSortWithFormattingXLS()
     xDocSh->DoClose();
 }
 
+void ScFiltersTest::testTooManyColsRows()
+{
+    // The intentionally doc has cells beyond our MAXROW/MAXCOL, so there
+    // should be a warning on load.
+    ScDocShellRef xDocSh = loadDoc(u"too-many-cols-rows.", FORMAT_ODS, 
/*bReadWrite*/ false,
+                                   /*bCheckErrorCode*/ false);
+    CPPUNIT_ASSERT(xDocSh->GetErrorCode() == SCWARN_IMPORT_ROW_OVERFLOW
+                   || xDocSh->GetErrorCode() == SCWARN_IMPORT_COLUMN_OVERFLOW);
+    xDocSh->DoClose();
+
+    xDocSh = loadDoc(u"too-many-cols-rows.", FORMAT_XLSX, /*bReadWrite*/ false,
+                     /*bCheckErrorCode*/ false);
+    CPPUNIT_ASSERT(xDocSh->GetErrorCode() == SCWARN_IMPORT_ROW_OVERFLOW
+                   || xDocSh->GetErrorCode() == SCWARN_IMPORT_COLUMN_OVERFLOW);
+    xDocSh->DoClose();
+}
+
 // just needs to not crash on recalc
 void ScFiltersTest::testForcepoint107()
 {
diff --git a/sc/qa/unit/helper/qahelper.cxx b/sc/qa/unit/helper/qahelper.cxx
index 59d4177ef19c..3dad0c66be3f 100644
--- a/sc/qa/unit/helper/qahelper.cxx
+++ b/sc/qa/unit/helper/qahelper.cxx
@@ -933,48 +933,6 @@ std::shared_ptr<utl::TempFileNamed> 
ScBootstrapFixture::exportTo( ScDocShell& rS
     return pTempFile;
 }
 
-void ScBootstrapFixture::miscRowHeightsTest( TestParam const * aTestValues, 
unsigned int numElems )
-{
-    for ( unsigned int index=0; index<numElems; ++index )
-    {
-        OUString sFileName = OUString::createFromAscii( aTestValues[ index 
].sTestDoc );
-        SAL_INFO( "sc.qa", "aTestValues[" << index << "] " << sFileName );
-        int nImportType =  aTestValues[ index ].nImportType;
-        int nExportType =  aTestValues[ index ].nExportType;
-        ScDocShellRef xShell = loadDoc( sFileName, nImportType );
-
-        if ( nExportType != -1 )
-            xShell = saveAndReload(*xShell, nExportType );
-
-        CPPUNIT_ASSERT(xShell.is());
-
-        ScDocument& rDoc = xShell->GetDocument();
-
-        for (int i=0; i<aTestValues[ index ].nRowData; ++i)
-        {
-            SCROW nRow = aTestValues[ index ].pData[ i].nStartRow;
-            SCROW nEndRow = aTestValues[ index ].pData[ i ].nEndRow;
-            SCTAB nTab = aTestValues[ index ].pData[ i ].nTab;
-            int nExpectedHeight = aTestValues[ index ].pData[ i 
].nExpectedHeight;
-            if ( nExpectedHeight == -1 )
-                nExpectedHeight = 
convertTwipToMm100(ScGlobal::GetStandardRowHeight());
-            bool bCheckOpt = ( ( aTestValues[ index ].pData[ i ].nCheck & 
CHECK_OPTIMAL ) == CHECK_OPTIMAL );
-            for ( ; nRow <= nEndRow; ++nRow )
-            {
-                SAL_INFO( "sc.qa", " checking row " << nRow << " for height " 
<< nExpectedHeight );
-                int nHeight = convertTwipToMm100(rDoc.GetRowHeight(nRow, nTab, 
false));
-                if ( bCheckOpt )
-                {
-                    bool bOpt = !(rDoc.GetRowFlags( nRow, nTab ) & 
CRFlags::ManualSize);
-                    CPPUNIT_ASSERT_EQUAL(aTestValues[ index ].pData[ i 
].bOptimal, bOpt);
-                }
-                CPPUNIT_ASSERT_EQUAL(nExpectedHeight, nHeight);
-            }
-        }
-        xShell->DoClose();
-    }
-}
-
 void ScBootstrapFixture::setUp()
 {
     test::BootstrapFixture::setUp();
@@ -1041,7 +999,7 @@ ScDocShell* ScModelTestBase::getScDocShell()
     return pDocSh;
 }
 
-void ScModelTestBase::miscRowHeightsTest( TestParam2 const * aTestValues, 
unsigned int numElems)
+void ScModelTestBase::miscRowHeightsTest( TestParam const * aTestValues, 
unsigned int numElems)
 {
     for ( unsigned int index=0; index<numElems; ++index )
     {
diff --git a/sc/qa/unit/helper/qahelper.hxx b/sc/qa/unit/helper/qahelper.hxx
index f2dc6fae94e2..f330e2bc5979 100644
--- a/sc/qa/unit/helper/qahelper.hxx
+++ b/sc/qa/unit/helper/qahelper.hxx
@@ -73,24 +73,6 @@ class ScTokenArray;
 
 // data format for row height tests
 struct TestParam
-{
-    struct RowData
-    {
-        SCROW nStartRow;
-        SCROW nEndRow;
-        SCTAB nTab;
-        int nExpectedHeight; // -1 for default height
-        int nCheck; // currently only CHECK_OPTIMAL ( we could add 
CHECK_MANUAL etc.)
-        bool bOptimal;
-    };
-    const char* sTestDoc;
-    int nImportType;
-    int nExportType; // -1 for import test, otherwise this is an export test
-    int nRowData;
-    RowData const * pData;
-};
-
-struct TestParam2
 {
     struct RowData
     {
@@ -244,8 +226,6 @@ public:
 
     std::shared_ptr<utl::TempFileNamed> exportTo(ScDocShell& rShell, sal_Int32 
nFormat, bool bValidate = true);
 
-    void miscRowHeightsTest( TestParam const * aTestValues, unsigned int 
numElems );
-
     virtual void setUp() override;
     virtual void tearDown() override;
 };
@@ -272,7 +252,7 @@ public:
     void createScDoc(const char* pName = nullptr, const char* pPassword = 
nullptr);
     ScDocument* getScDoc();
     ScDocShell* getScDocShell();
-    void miscRowHeightsTest( TestParam2 const * aTestValues, unsigned int 
numElems);
+    void miscRowHeightsTest( TestParam const * aTestValues, unsigned int 
numElems);
 };
 
 #define ASSERT_DOUBLES_EQUAL( expected, result )    \
diff --git a/sc/qa/unit/subsequent_export_test.cxx 
b/sc/qa/unit/subsequent_export_test.cxx
index 360e090b843a..34f675f36677 100644
--- a/sc/qa/unit/subsequent_export_test.cxx
+++ b/sc/qa/unit/subsequent_export_test.cxx
@@ -1342,7 +1342,7 @@ void ScExportTest::testDataBarExportXLSX()
 
 void ScExportTest::testMiscRowHeightExport()
 {
-    static const TestParam2::RowData DfltRowData[] = {
+    static const TestParam::RowData DfltRowData[] = {
         { 0, 4, 0, 529, 0, false },
         { 5, 10, 0, 1058, 0, false },
         { 17, 20, 0, 1746, 0, false },
@@ -1351,7 +1351,7 @@ void ScExportTest::testMiscRowHeightExport()
         { 1048573, 1048575, 0, 529, 0, false },
     };
 
-    static const TestParam2::RowData EmptyRepeatRowData[] = {
+    static const TestParam::RowData EmptyRepeatRowData[] = {
         // rows 0-4, 5-10, 17-20 are all set at various
         // heights, there is no content in the rows, there
         // was a bug where only the first row ( of repeated rows )
@@ -1361,7 +1361,7 @@ void ScExportTest::testMiscRowHeightExport()
         { 17, 20, 0, 1767, 0, false },
     };
 
-    TestParam2 aTestValues[] = {
+    TestParam aTestValues[] = {
         // Checks that some distributed ( non-empty ) heights remain set after 
export (roundtrip)
         // additionally there is effectively a default row height ( 5.29 mm ). 
So we test the
         // unset rows at the end of the document to ensure the effective xlsx 
default height
diff --git a/sc/qa/unit/subsequent_filters_test2.cxx 
b/sc/qa/unit/subsequent_filters_test2.cxx
index 293c7300d7fb..782d407bcb42 100644
--- a/sc/qa/unit/subsequent_filters_test2.cxx
+++ b/sc/qa/unit/subsequent_filters_test2.cxx
@@ -11,7 +11,7 @@
 
 #include <memory>
 
-#include <test/bootstrapfixture.hxx>
+#include <test/unoapixml_test.hxx>
 
 #include <osl/thread.h>
 #include <svl/numformat.hxx>
@@ -66,7 +66,7 @@
 using namespace ::com::sun::star;
 using namespace ::com::sun::star::uno;
 
-class ScFiltersTest2 : public ScBootstrapFixture
+class ScFiltersTest2 : public ScModelTestBase
 {
 public:
     ScFiltersTest2();
@@ -186,7 +186,6 @@ public:
     void testTdf139763ShapeAnchor();
     void testAutofilterNamedRangesXLSX();
     void testInvalidBareBiff5();
-    void testTooManyColsRows();
     void testTdf83671_SmartArt_import();
     void testTdf83671_SmartArt_import2();
     void testTdf151818_SmartArtFontColor();
@@ -305,7 +304,6 @@ public:
     CPPUNIT_TEST(testTdf139763ShapeAnchor);
     CPPUNIT_TEST(testAutofilterNamedRangesXLSX);
     CPPUNIT_TEST(testInvalidBareBiff5);
-    CPPUNIT_TEST(testTooManyColsRows);
     CPPUNIT_TEST(testTdf83671_SmartArt_import);
     CPPUNIT_TEST(testTdf83671_SmartArt_import2);
     CPPUNIT_TEST(testTdf151818_SmartArtFontColor);
@@ -314,7 +312,7 @@ public:
 };
 
 ScFiltersTest2::ScFiltersTest2()
-    : ScBootstrapFixture("sc/qa/unit/data")
+    : ScModelTestBase("sc/qa/unit/data")
 {
 }
 
@@ -345,11 +343,12 @@ void ScFiltersTest2::testMiscRowHeights()
            have default row heights ( there was a problem where the optimal
            height was being calculated after import if no hard height )
         */
-        { "alldefaultheights.", FORMAT_ODS, -1, SAL_N_ELEMENTS(DfltRowData), 
DfltRowData },
+        { u"ods/alldefaultheights.ods", OUString(), 
SAL_N_ELEMENTS(DfltRowData), DfltRowData },
         /* Checks the imported height of some multiline input, additionally 
checks
            that the optimal height flag is set ( or not )
         */
-        { "multilineoptimal.", FORMAT_ODS, -1, 
SAL_N_ELEMENTS(MultiLineOptData), MultiLineOptData },
+        { u"ods/multilineoptimal.ods", OUString(), 
SAL_N_ELEMENTS(MultiLineOptData),
+          MultiLineOptData },
     };
     miscRowHeightsTest(aTestValues, SAL_N_ELEMENTS(aTestValues));
 }
@@ -365,44 +364,44 @@ void ScFiltersTest2::testOptimalHeightReset()
     if (!IsDefaultDPI())
         return;
 
-    ScDocShellRef xDocSh = loadDoc(u"multilineoptimal.", FORMAT_ODS, true);
+    createScDoc("ods/multilineoptimal.ods");
     SCTAB nTab = 0;
     SCROW nRow = 0;
-    ScDocument& rDoc = xDocSh->GetDocument();
+    ScDocument* pDoc = getScDoc();
     // open document in read/write mode ( otherwise optimal height stuff won't
     // be triggered ) *and* you can't delete cell contents.
-    int nHeight = convertTwipToMm100(rDoc.GetRowHeight(nRow, nTab, false));
+    int nHeight = convertTwipToMm100(pDoc->GetRowHeight(nRow, nTab, false));
     CPPUNIT_ASSERT_EQUAL(1236, nHeight);
 
-    ScDocFunc& rFunc = xDocSh->GetDocFunc();
+    ScDocShell* pDocSh = getScDocShell();
+    ScDocFunc& rFunc = pDocSh->GetDocFunc();
 
     // delete content of A1
     ScRange aDelRange(0, 0, 0, 0, 0, 0);
-    ScMarkData aMark(rDoc.GetSheetLimits());
+    ScMarkData aMark(pDoc->GetSheetLimits());
     aMark.SetMarkArea(aDelRange);
     bool bRet = rFunc.DeleteContents(aMark, InsertDeleteFlags::ALL, false, 
true);
     CPPUNIT_ASSERT_MESSAGE("DeleteContents failed", bRet);
 
     // get the new height of A1
-    nHeight = convertTwipToMm100(rDoc.GetRowHeight(nRow, nTab, false));
+    nHeight = convertTwipToMm100(pDoc->GetRowHeight(nRow, nTab, false));
 
     // set optimal height for empty row 2
     std::vector<sc::ColRowSpan> aRowArr(1, sc::ColRowSpan(2, 2));
     rFunc.SetWidthOrHeight(false, aRowArr, nTab, SC_SIZE_OPTIMAL, 0, true, 
true);
 
     // retrieve optimal height
-    int nOptimalHeight = 
convertTwipToMm100(rDoc.GetRowHeight(aRowArr[0].mnStart, nTab, false));
+    int nOptimalHeight = 
convertTwipToMm100(pDoc->GetRowHeight(aRowArr[0].mnStart, nTab, false));
 
     // check if the new height of A1 ( after delete ) is now the optimal 
height of an empty cell
     CPPUNIT_ASSERT_EQUAL(nOptimalHeight, nHeight);
-    xDocSh->DoClose();
 }
 
 void ScFiltersTest2::testCustomNumFormatHybridCellODS()
 {
-    ScDocShellRef xDocSh = loadDoc(u"custom-numfmt-hybrid-cell.", FORMAT_ODS, 
false);
-    ScDocument& rDoc = xDocSh->GetDocument();
-    rDoc.SetAutoCalc(true);
+    createScDoc("ods/custom-numfmt-hybrid-cell.ods");
+    ScDocument* pDoc = getScDoc();
+    pDoc->SetAutoCalc(true);
 
     // All of B14, B16 and B18 should be displaying empty strings by virtue
     // of the custom number format being set on those cells.
@@ -410,109 +409,97 @@ void ScFiltersTest2::testCustomNumFormatHybridCellODS()
     for (SCROW nRow : { 13, 15, 17 })
     {
         ScAddress aPos(1, nRow, 0);
-        OUString aStr = rDoc.GetString(aPos);
+        OUString aStr = pDoc->GetString(aPos);
         CPPUNIT_ASSERT(aStr.isEmpty());
     }
 
     // Now, set value of 1 to B15.  This should trigger re-calc on B18 and B18
     // should now show a value of 1.
-    rDoc.SetValue(ScAddress(1, 15, 0), 1.0);
+    pDoc->SetValue(ScAddress(1, 15, 0), 1.0);
 
-    OUString aStr = rDoc.GetString(ScAddress(1, 17, 0));
+    OUString aStr = pDoc->GetString(ScAddress(1, 17, 0));
     CPPUNIT_ASSERT_EQUAL(OUString("1"), aStr);
 
     // Make sure the cell doesn't have an error value.
-    ScFormulaCell* pFC = rDoc.GetFormulaCell(ScAddress(1, 17, 0));
+    ScFormulaCell* pFC = pDoc->GetFormulaCell(ScAddress(1, 17, 0));
     CPPUNIT_ASSERT(pFC);
     CPPUNIT_ASSERT_EQUAL(FormulaError::NONE, pFC->GetErrCode());
-
-    xDocSh->DoClose();
 }
 
 void ScFiltersTest2::testTdf121040()
 {
-    ScDocShellRef xDocSh = loadDoc(u"tdf121040.", FORMAT_ODS);
+    createScDoc("ods/tdf121040.ods");
 
     const SCTAB nTab = 0;
-    ScDocument& rDoc = xDocSh->GetDocument();
+    ScDocument* pDoc = getScDoc();
 
     // The first 9 rows should have the same height
-    const sal_uInt16 nHeight = rDoc.GetRowHeight(0, nTab, false);
+    const sal_uInt16 nHeight = pDoc->GetRowHeight(0, nTab, false);
     for (SCTAB nRow = 1; nRow < 9; nRow++)
     {
-        CPPUNIT_ASSERT_EQUAL(nHeight, rDoc.GetRowHeight(nRow, nTab, false));
+        CPPUNIT_ASSERT_EQUAL(nHeight, pDoc->GetRowHeight(nRow, nTab, false));
     }
-
-    xDocSh->DoClose();
 }
 
 void ScFiltersTest2::testTdf118086()
 {
-    ScDocShellRef xDocSh = loadDoc(u"tdf118086.", FORMAT_ODS);
+    createScDoc("ods/tdf118086.ods");
 
-    ScDocument& rDoc = xDocSh->GetDocument();
+    ScDocument* pDoc = getScDoc();
 
     // Depending on DPI, this might be 477 or 480
-    CPPUNIT_ASSERT_DOUBLES_EQUAL(477, rDoc.GetRowHeight(2, 
static_cast<SCTAB>(0), false), 5);
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(477, pDoc->GetRowHeight(2, 
static_cast<SCTAB>(0), false), 5);
 
     // Without the fix in place, this test would have failed with
     // - Expected: 256
     // - Actual  : 477
-    CPPUNIT_ASSERT_EQUAL(sal_uInt16(256), rDoc.GetRowHeight(2, 
static_cast<SCTAB>(1), false));
-    CPPUNIT_ASSERT_EQUAL(sal_uInt16(256), rDoc.GetRowHeight(2, 
static_cast<SCTAB>(2), false));
-
-    xDocSh->DoClose();
+    CPPUNIT_ASSERT_EQUAL(sal_uInt16(256), pDoc->GetRowHeight(2, 
static_cast<SCTAB>(1), false));
+    CPPUNIT_ASSERT_EQUAL(sal_uInt16(256), pDoc->GetRowHeight(2, 
static_cast<SCTAB>(2), false));
 }
 
 void ScFiltersTest2::testTdf118624()
 {
-    ScDocShellRef xDocSh = loadDoc(u"tdf118624.", FORMAT_ODS);
+    createScDoc("ods/tdf118624.ods");
 
-    ScDocument& rDoc = xDocSh->GetDocument();
+    ScDocument* pDoc = getScDoc();
 
     CPPUNIT_ASSERT_MESSAGE("RAND() in array/matrix mode shouldn't return the 
same value",
-                           rDoc.GetString(ScAddress(0, 0, 0))
-                               != rDoc.GetString(ScAddress(0, 1, 0)));
-
-    xDocSh->DoClose();
+                           pDoc->GetString(ScAddress(0, 0, 0))
+                               != pDoc->GetString(ScAddress(0, 1, 0)));
 }
 
 void ScFiltersTest2::testTdf124454()
 {
-    ScDocShellRef xDocSh = loadDoc(u"tdf124454.", FORMAT_ODS);
+    createScDoc("ods/tdf124454.ods");
 
-    ScDocument& rDoc = xDocSh->GetDocument();
+    ScDocument* pDoc = getScDoc();
 
-    CPPUNIT_ASSERT_EQUAL(OUString("1"), rDoc.GetString(ScAddress(1, 0, 0)));
-    CPPUNIT_ASSERT_EQUAL(OUString("1"), rDoc.GetString(ScAddress(2, 0, 0)));
+    CPPUNIT_ASSERT_EQUAL(OUString("1"), pDoc->GetString(ScAddress(1, 0, 0)));
+    CPPUNIT_ASSERT_EQUAL(OUString("1"), pDoc->GetString(ScAddress(2, 0, 0)));
     // Without the fix in place, double negation with text in array
     // would have returned -1
-    CPPUNIT_ASSERT_EQUAL(OUString("1"), rDoc.GetString(ScAddress(3, 0, 0)));
-
-    xDocSh->DoClose();
+    CPPUNIT_ASSERT_EQUAL(OUString("1"), pDoc->GetString(ScAddress(3, 0, 0)));
 }
 
 void ScFiltersTest2::testPrintRangeODS()
 {
-    ScDocShellRef xDocSh = loadDoc(u"print-range.", FORMAT_ODS);
-    ScDocument& rDoc = xDocSh->GetDocument();
-    std::optional<ScRange> pRange = rDoc.GetRepeatRowRange(0);
+    createScDoc("ods/print-range.ods");
+    ScDocument* pDoc = getScDoc();
+    std::optional<ScRange> pRange = pDoc->GetRepeatRowRange(0);
     CPPUNIT_ASSERT(pRange);
     CPPUNIT_ASSERT_EQUAL(ScRange(0, 0, 0, 0, 1, 0), *pRange);
 
-    pRange = rDoc.GetRepeatRowRange(1);
+    pRange = pDoc->GetRepeatRowRange(1);
     CPPUNIT_ASSERT(pRange);
     CPPUNIT_ASSERT_EQUAL(ScRange(0, 2, 0, 0, 4, 0), *pRange);
-
-    xDocSh->DoClose();
 }
 
 void ScFiltersTest2::testOutlineODS()
 {
-    ScDocShellRef xDocSh = loadDoc(u"outline.", FORMAT_ODS);
-    ScDocument& rDoc = xDocSh->GetDocument();
+    createScDoc("ods/outline.ods");
+    ScDocument* pDoc = getScDoc();
 
-    const ScOutlineTable* pTable = rDoc.GetOutlineTable(0);
+    const ScOutlineTable* pTable = pDoc->GetOutlineTable(0);
     CPPUNIT_ASSERT(pTable);
 
     const ScOutlineArray& rArr = pTable->GetRowArray();
@@ -555,48 +542,42 @@ void ScFiltersTest2::testOutlineODS()
         bool bVisible = pEntry->IsVisible();
         CPPUNIT_ASSERT_EQUAL(aRow[i].bVisible, bVisible);
     }
-
-    xDocSh->DoClose();
 }
 
 void ScFiltersTest2::testColumnStyleXLSX()
 {
-    ScDocShellRef xDocSh = loadDoc(u"column-style.", FORMAT_XLSX);
-    ScDocument& rDoc = xDocSh->GetDocument();
+    createScDoc("xlsx/column-style.xlsx");
+    ScDocument* pDoc = getScDoc();
 
-    const ScPatternAttr* pPattern = rDoc.GetPattern(0, 0, 0);
+    const ScPatternAttr* pPattern = pDoc->GetPattern(0, 0, 0);
     CPPUNIT_ASSERT(pPattern);
 
     const ScProtectionAttr& rAttr = pPattern->GetItem(ATTR_PROTECTION);
     CPPUNIT_ASSERT(rAttr.GetProtection());
 
-    pPattern = rDoc.GetPattern(0, 1, 0);
+    pPattern = pDoc->GetPattern(0, 1, 0);
     CPPUNIT_ASSERT(pPattern);
 
     const ScProtectionAttr& rAttrNew = pPattern->GetItem(ATTR_PROTECTION);
     CPPUNIT_ASSERT(!rAttrNew.GetProtection());
-
-    xDocSh->DoClose();
 }
 
 void ScFiltersTest2::testColumnStyleAutoFilterXLSX()
 {
-    ScDocShellRef xDocSh = loadDoc(u"column-style-autofilter.", FORMAT_XLSX);
-    ScDocument& rDoc = xDocSh->GetDocument();
+    createScDoc("xlsx/column-style-autofilter.xlsx");
+    ScDocument* pDoc = getScDoc();
 
-    const ScPatternAttr* pPattern = rDoc.GetPattern(0, 10, 18);
+    const ScPatternAttr* pPattern = pDoc->GetPattern(0, 10, 18);
     CPPUNIT_ASSERT(pPattern);
 
     const ScMergeFlagAttr& rAttr = pPattern->GetItem(ATTR_MERGE_FLAG);
     CPPUNIT_ASSERT(!rAttr.HasAutoFilter());
-
-    xDocSh->DoClose();
 }
 
 void ScFiltersTest2::testSharedFormulaHorizontalXLS()
 {
-    ScDocShellRef xDocSh = loadDoc(u"shared-formula/horizontal.", FORMAT_XLS);
-    ScDocument& rDoc = xDocSh->GetDocument();
+    createScDoc("xls/shared-formula/horizontal.xls");
+    ScDocument* pDoc = getScDoc();
 
     // Make sure K2:S2 on the 2nd sheet are all formula cells.
     ScAddress aPos(0, 1, 1);
@@ -604,7 +585,7 @@ void ScFiltersTest2::testSharedFormulaHorizontalXLS()
     {
         aPos.SetCol(nCol);
         CPPUNIT_ASSERT_EQUAL_MESSAGE("Formula cell is expected here.", 
CELLTYPE_FORMULA,
-                                     rDoc.GetCellType(aPos));
+                                     pDoc->GetCellType(aPos));
     }
 
     // Likewise, B3:J9 all should be formula cells.
@@ -615,7 +596,7 @@ void ScFiltersTest2::testSharedFormulaHorizontalXLS()
         {
             aPos.SetRow(nRow);
             CPPUNIT_ASSERT_EQUAL_MESSAGE("Formula cell is expected here.", 
CELLTYPE_FORMULA,
-                                         rDoc.GetCellType(aPos));
+                                         pDoc->GetCellType(aPos));
         }
     }
 
@@ -625,198 +606,184 @@ void ScFiltersTest2::testSharedFormulaHorizontalXLS()
     {
         aPos.SetCol(nCol);
         CPPUNIT_ASSERT_EQUAL_MESSAGE("Formula cell is expected here.", 
CELLTYPE_FORMULA,
-                                     rDoc.GetCellType(aPos));
+                                     pDoc->GetCellType(aPos));
     }
 
     // J2 has a string of "MW".
     aPos.SetCol(9);
-    CPPUNIT_ASSERT_EQUAL(OUString("MW"), rDoc.GetString(aPos));
-
-    xDocSh->DoClose();
+    CPPUNIT_ASSERT_EQUAL(OUString("MW"), pDoc->GetString(aPos));
 }
 
 void ScFiltersTest2::testSharedFormulaWrappedRefsXLS()
 {
-    ScDocShellRef xDocSh = loadDoc(u"shared-formula/wrapped-refs.", 
FORMAT_XLS);
-    ScDocument& rDoc = xDocSh->GetDocument();
-    rDoc.CalcAll();
+    createScDoc("xls/shared-formula/wrapped-refs.xls");
+    ScDocument* pDoc = getScDoc();
+    pDoc->CalcAll();
 
     // Check the values of H7:H10.
-    CPPUNIT_ASSERT_EQUAL(7.0, rDoc.GetValue(ScAddress(7, 6, 0)));
-    CPPUNIT_ASSERT_EQUAL(8.0, rDoc.GetValue(ScAddress(7, 7, 0)));
-    CPPUNIT_ASSERT_EQUAL(9.0, rDoc.GetValue(ScAddress(7, 8, 0)));
-    CPPUNIT_ASSERT_EQUAL(10.0, rDoc.GetValue(ScAddress(7, 9, 0)));
+    CPPUNIT_ASSERT_EQUAL(7.0, pDoc->GetValue(ScAddress(7, 6, 0)));
+    CPPUNIT_ASSERT_EQUAL(8.0, pDoc->GetValue(ScAddress(7, 7, 0)));
+    CPPUNIT_ASSERT_EQUAL(9.0, pDoc->GetValue(ScAddress(7, 8, 0)));
+    CPPUNIT_ASSERT_EQUAL(10.0, pDoc->GetValue(ScAddress(7, 9, 0)));
 
     // EM7:EM10 should reference H7:H10.
-    CPPUNIT_ASSERT_EQUAL(7.0, rDoc.GetValue(ScAddress(142, 6, 0)));
-    CPPUNIT_ASSERT_EQUAL(8.0, rDoc.GetValue(ScAddress(142, 7, 0)));
-    CPPUNIT_ASSERT_EQUAL(9.0, rDoc.GetValue(ScAddress(142, 8, 0)));
-    CPPUNIT_ASSERT_EQUAL(10.0, rDoc.GetValue(ScAddress(142, 9, 0)));
+    CPPUNIT_ASSERT_EQUAL(7.0, pDoc->GetValue(ScAddress(142, 6, 0)));
+    CPPUNIT_ASSERT_EQUAL(8.0, pDoc->GetValue(ScAddress(142, 7, 0)));
+    CPPUNIT_ASSERT_EQUAL(9.0, pDoc->GetValue(ScAddress(142, 8, 0)));
+    CPPUNIT_ASSERT_EQUAL(10.0, pDoc->GetValue(ScAddress(142, 9, 0)));
 
     // Make sure EM7:EM10 are grouped.
-    const ScFormulaCell* pFC = rDoc.GetFormulaCell(ScAddress(142, 6, 0));
+    const ScFormulaCell* pFC = pDoc->GetFormulaCell(ScAddress(142, 6, 0));
     CPPUNIT_ASSERT(pFC);
     CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(6), pFC->GetSharedTopRow());
     CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(4), pFC->GetSharedLength());
-
-    xDocSh->DoClose();
 }
 
 void ScFiltersTest2::testSharedFormulaBIFF5()
 {
-    ScDocShellRef xDocSh = loadDoc(u"shared-formula/biff5.", FORMAT_XLS);
-    ScDocument& rDoc = xDocSh->GetDocument();
-    rDoc.CalcAll();
+    createScDoc("xls/shared-formula/biff5.xls");
+    ScDocument* pDoc = getScDoc();
+    pDoc->CalcAll();
 
     // E6:E376 should be all formulas, and they should belong to the same 
group.
-    const ScFormulaCell* pFC = rDoc.GetFormulaCell(ScAddress(4, 5, 0));
+    const ScFormulaCell* pFC = pDoc->GetFormulaCell(ScAddress(4, 5, 0));
     CPPUNIT_ASSERT(pFC);
     CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(5), pFC->GetSharedTopRow());
     CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(371), pFC->GetSharedLength());
-
-    xDocSh->DoClose();
 }
 
 void ScFiltersTest2::testSharedFormulaXLSB()
 {
-    ScDocShellRef xDocSh = loadDoc(u"shared_formula.", FORMAT_XLSB);
-    ScDocument& rDoc = xDocSh->GetDocument();
-    rDoc.CalcAll();
+    createScDoc("xlsb/shared_formula.xlsb");
+    ScDocument* pDoc = getScDoc();
+    pDoc->CalcAll();
 
     // A1:A30 should be all formulas, and they should belong to the same group.
-    const ScFormulaCell* pFC = rDoc.GetFormulaCell(ScAddress(0, 0, 0));
+    const ScFormulaCell* pFC = pDoc->GetFormulaCell(ScAddress(0, 0, 0));
     CPPUNIT_ASSERT(pFC);
     CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(0), pFC->GetSharedTopRow());
     CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(30), pFC->GetSharedLength());
 
     for (SCROW nRow = 0; nRow < 30; ++nRow)
     {
-        ASSERT_DOUBLES_EQUAL(3.0, rDoc.GetValue(0, nRow, 0));
+        ASSERT_DOUBLES_EQUAL(3.0, pDoc->GetValue(0, nRow, 0));
     }
-
-    xDocSh->DoClose();
 }
 
 void ScFiltersTest2::testSharedFormulaXLS()
 {
     {
         // fdo#80091
-        ScDocShellRef xDocSh = loadDoc(u"shared-formula/relative-refs1.", 
FORMAT_XLS);
-        ScDocument& rDoc = xDocSh->GetDocument();
-        rDoc.CalcAll();
+        createScDoc("xls/shared-formula/relative-refs1.xls");
+        ScDocument* pDoc = getScDoc();
+        pDoc->CalcAll();
 
         // A1:A30 should be all formulas, and they should belong to the same 
group.
-        const ScFormulaCell* pFC = rDoc.GetFormulaCell(ScAddress(0, 1, 0));
+        const ScFormulaCell* pFC = pDoc->GetFormulaCell(ScAddress(0, 1, 0));
         CPPUNIT_ASSERT(pFC);
         CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(1), pFC->GetSharedTopRow());
         CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(29), pFC->GetSharedLength());
 
         for (SCROW nRow = 0; nRow < 30; ++nRow)
         {
-            ASSERT_DOUBLES_EQUAL(double(nRow + 1), rDoc.GetValue(0, nRow, 0));
+            ASSERT_DOUBLES_EQUAL(double(nRow + 1), pDoc->GetValue(0, nRow, 0));
         }
-
-        xDocSh->DoClose();
     }
 
     {
         // fdo#84556 and some related tests
-        ScDocShellRef xDocSh = loadDoc(u"shared-formula/relative-refs2.", 
FORMAT_XLS);
-        ScDocument& rDoc = xDocSh->GetDocument();
-        rDoc.CalcAll();
+        createScDoc("xls/shared-formula/relative-refs2.xls");
+        ScDocument* pDoc = getScDoc();
+        pDoc->CalcAll();
 
         {
-            const ScFormulaCell* pFC = rDoc.GetFormulaCell(ScAddress(2, 1, 0));
+            const ScFormulaCell* pFC = pDoc->GetFormulaCell(ScAddress(2, 1, 
0));
             CPPUNIT_ASSERT(pFC);
             CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(1), 
pFC->GetSharedTopRow());
             CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(10), 
pFC->GetSharedLength());
 
-            pFC = rDoc.GetFormulaCell(ScAddress(2, 10, 0));
+            pFC = pDoc->GetFormulaCell(ScAddress(2, 10, 0));
             CPPUNIT_ASSERT(pFC);
             CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(1), 
pFC->GetSharedTopRow());
             CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(10), 
pFC->GetSharedLength());
 
-            OUString aFormula = rDoc.GetFormula(2, 1, 0);
+            OUString aFormula = pDoc->GetFormula(2, 1, 0);
             CPPUNIT_ASSERT_EQUAL(OUString("=SUM(B9:D9)"), aFormula);
 
-            aFormula = rDoc.GetFormula(2, 10, 0);
+            aFormula = pDoc->GetFormula(2, 10, 0);
             CPPUNIT_ASSERT_EQUAL(OUString("=SUM(B18:D18)"), aFormula);
         }
 
         {
-            const ScFormulaCell* pFC = rDoc.GetFormulaCell(ScAddress(4, 8, 0));
+            const ScFormulaCell* pFC = pDoc->GetFormulaCell(ScAddress(4, 8, 
0));
             CPPUNIT_ASSERT(pFC);
             CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(8), 
pFC->GetSharedTopRow());
             CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(10), 
pFC->GetSharedLength());
 
-            pFC = rDoc.GetFormulaCell(ScAddress(4, 17, 0));
+            pFC = pDoc->GetFormulaCell(ScAddress(4, 17, 0));
             CPPUNIT_ASSERT(pFC);
             CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(8), 
pFC->GetSharedTopRow());
             CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(10), 
pFC->GetSharedLength());
 
-            OUString aFormula = rDoc.GetFormula(4, 8, 0);
+            OUString aFormula = pDoc->GetFormula(4, 8, 0);
             CPPUNIT_ASSERT_EQUAL(OUString("=SUM(G9:EY9)"), aFormula);
 
-            aFormula = rDoc.GetFormula(4, 17, 0);
+            aFormula = pDoc->GetFormula(4, 17, 0);
             CPPUNIT_ASSERT_EQUAL(OUString("=SUM(G18:EY18)"), aFormula);
         }
 
         {
-            const ScFormulaCell* pFC = rDoc.GetFormulaCell(ScAddress(6, 15, 
0));
+            const ScFormulaCell* pFC = pDoc->GetFormulaCell(ScAddress(6, 15, 
0));
             CPPUNIT_ASSERT(pFC);
             CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(15), 
pFC->GetSharedTopRow());
             CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(10), 
pFC->GetSharedLength());
 
-            pFC = rDoc.GetFormulaCell(ScAddress(6, 24, 0));
+            pFC = pDoc->GetFormulaCell(ScAddress(6, 24, 0));
             CPPUNIT_ASSERT(pFC);
             CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(15), 
pFC->GetSharedTopRow());
             CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(10), 
pFC->GetSharedLength());
 
-            OUString aFormula = rDoc.GetFormula(6, 15, 0);
+            OUString aFormula = pDoc->GetFormula(6, 15, 0);
             CPPUNIT_ASSERT_EQUAL(OUString("=SUM(A16:A40000)"), aFormula);
 
-            aFormula = rDoc.GetFormula(6, 24, 0);
+            aFormula = pDoc->GetFormula(6, 24, 0);
             CPPUNIT_ASSERT_EQUAL(OUString("=SUM(A25:A40009)"), aFormula);
         }
-
-        xDocSh->DoClose();
     }
 }
 
 void ScFiltersTest2::testSharedFormulaColumnLabelsODS()
 {
-    ScDocShellRef xDocSh = loadDoc(u"shared-formula/column-labels.", 
FORMAT_ODS);
-
-    ScDocument& rDoc = xDocSh->GetDocument();
-    rDoc.CalcAll();
+    createScDoc("ods/shared-formula/column-labels.ods");
 
-    CPPUNIT_ASSERT_EQUAL(5.0, rDoc.GetValue(ScAddress(2, 1, 0)));
-    CPPUNIT_ASSERT_EQUAL(15.0, rDoc.GetValue(ScAddress(2, 2, 0)));
-    CPPUNIT_ASSERT_EQUAL(30.0, rDoc.GetValue(ScAddress(2, 3, 0)));
-    CPPUNIT_ASSERT_EQUAL(28.0, rDoc.GetValue(ScAddress(2, 4, 0)));
-    CPPUNIT_ASSERT_EQUAL(48.0, rDoc.GetValue(ScAddress(2, 5, 0)));
+    ScDocument* pDoc = getScDoc();
+    pDoc->CalcAll();
 
-    CPPUNIT_ASSERT_EQUAL(0.0, rDoc.GetValue(ScAddress(3, 1, 0)));
-    CPPUNIT_ASSERT_EQUAL(50.0, rDoc.GetValue(ScAddress(3, 2, 0)));
-    CPPUNIT_ASSERT_EQUAL(144.0, rDoc.GetValue(ScAddress(3, 3, 0)));
-    CPPUNIT_ASSERT_EQUAL(147.0, rDoc.GetValue(ScAddress(3, 4, 0)));
-    CPPUNIT_ASSERT_EQUAL(320.0, rDoc.GetValue(ScAddress(3, 5, 0)));
+    CPPUNIT_ASSERT_EQUAL(5.0, pDoc->GetValue(ScAddress(2, 1, 0)));
+    CPPUNIT_ASSERT_EQUAL(15.0, pDoc->GetValue(ScAddress(2, 2, 0)));
+    CPPUNIT_ASSERT_EQUAL(30.0, pDoc->GetValue(ScAddress(2, 3, 0)));
+    CPPUNIT_ASSERT_EQUAL(28.0, pDoc->GetValue(ScAddress(2, 4, 0)));
+    CPPUNIT_ASSERT_EQUAL(48.0, pDoc->GetValue(ScAddress(2, 5, 0)));
 
-    CPPUNIT_ASSERT_EQUAL(0.0, rDoc.GetValue(ScAddress(4, 1, 0)));
-    CPPUNIT_ASSERT_EQUAL(2.0, rDoc.GetValue(ScAddress(4, 2, 0)));
-    CPPUNIT_ASSERT_EQUAL(4.0, rDoc.GetValue(ScAddress(4, 3, 0)));
-    CPPUNIT_ASSERT_EQUAL(3.0, rDoc.GetValue(ScAddress(4, 4, 0)));
-    CPPUNIT_ASSERT_EQUAL(5.0, rDoc.GetValue(ScAddress(4, 5, 0)));
+    CPPUNIT_ASSERT_EQUAL(0.0, pDoc->GetValue(ScAddress(3, 1, 0)));
+    CPPUNIT_ASSERT_EQUAL(50.0, pDoc->GetValue(ScAddress(3, 2, 0)));
+    CPPUNIT_ASSERT_EQUAL(144.0, pDoc->GetValue(ScAddress(3, 3, 0)));
+    CPPUNIT_ASSERT_EQUAL(147.0, pDoc->GetValue(ScAddress(3, 4, 0)));
+    CPPUNIT_ASSERT_EQUAL(320.0, pDoc->GetValue(ScAddress(3, 5, 0)));
 
-    xDocSh->DoClose();
+    CPPUNIT_ASSERT_EQUAL(0.0, pDoc->GetValue(ScAddress(4, 1, 0)));
+    CPPUNIT_ASSERT_EQUAL(2.0, pDoc->GetValue(ScAddress(4, 2, 0)));
+    CPPUNIT_ASSERT_EQUAL(4.0, pDoc->GetValue(ScAddress(4, 3, 0)));
+    CPPUNIT_ASSERT_EQUAL(3.0, pDoc->GetValue(ScAddress(4, 4, 0)));
+    CPPUNIT_ASSERT_EQUAL(5.0, pDoc->GetValue(ScAddress(4, 5, 0)));
 }
 
 void ScFiltersTest2::testSharedFormulaColumnRowLabelsODS()
 {
-    ScDocShellRef xDocSh = loadDoc(u"shared-formula/column-row-labels.", 
FORMAT_ODS);
+    createScDoc("ods/shared-formula/column-row-labels.ods");
 
-    ScDocument& rDoc = xDocSh->GetDocument();
-    rDoc.CalcAll();
+    ScDocument* pDoc = getScDoc();
+    pDoc->CalcAll();
 
     // Expected output in each of the three ranges.
     //
@@ -835,7 +802,7 @@ void ScFiltersTest2::testSharedFormulaColumnRowLabelsODS()
             for (SCROW nRow = 0; nRow <= 2; ++nRow)
             {
                 ScAddress aPos(nStartCol + nCol, nStartRow + nRow, 0);
-                CPPUNIT_ASSERT_EQUAL(fExpected, rDoc.GetValue(aPos));
+                CPPUNIT_ASSERT_EQUAL(fExpected, pDoc->GetValue(aPos));
                 fExpected += 1.0;
             }
         }
@@ -844,88 +811,78 @@ void ScFiltersTest2::testSharedFormulaColumnRowLabelsODS()
     aCheckFunc(5, 1); // F2:H4
     aCheckFunc(9, 1); // J2:L4
     aCheckFunc(1, 6); // B7:D9
-
-    xDocSh->DoClose();
 }
 
 void ScFiltersTest2::testExternalRefCacheXLSX()
 {
-    ScDocShellRef xDocSh = loadDoc(u"external-refs.", FORMAT_XLSX);
-    ScDocument& rDoc = xDocSh->GetDocument();
+    createScDoc("xlsx/external-refs.xlsx");
+    ScDocument* pDoc = getScDoc();
 
     // These string values are cached external cell values.
-    CPPUNIT_ASSERT_EQUAL(OUString("Name"), rDoc.GetString(ScAddress(0, 0, 0)));
-    CPPUNIT_ASSERT_EQUAL(OUString("Andy"), rDoc.GetString(ScAddress(0, 1, 0)));
-    CPPUNIT_ASSERT_EQUAL(OUString("Bruce"), rDoc.GetString(ScAddress(0, 2, 
0)));
-    CPPUNIT_ASSERT_EQUAL(OUString("Charlie"), rDoc.GetString(ScAddress(0, 3, 
0)));
-
-    xDocSh->DoClose();
+    CPPUNIT_ASSERT_EQUAL(OUString("Name"), pDoc->GetString(ScAddress(0, 0, 
0)));
+    CPPUNIT_ASSERT_EQUAL(OUString("Andy"), pDoc->GetString(ScAddress(0, 1, 
0)));
+    CPPUNIT_ASSERT_EQUAL(OUString("Bruce"), pDoc->GetString(ScAddress(0, 2, 
0)));
+    CPPUNIT_ASSERT_EQUAL(OUString("Charlie"), pDoc->GetString(ScAddress(0, 3, 
0)));
 }
 
 void ScFiltersTest2::testExternalRefCacheODS()
 {
-    ScDocShellRef xDocSh = loadDoc(u"external-ref-cache.", FORMAT_ODS);
+    createScDoc("ods/external-ref-cache.ods");
 
-    ScDocument& rDoc = xDocSh->GetDocument();
+    ScDocument* pDoc = getScDoc();
 
     // Cells B2:B4 have VLOOKUP with external references which should all show 
"text".
-    CPPUNIT_ASSERT_EQUAL(OUString("text"), rDoc.GetString(ScAddress(1, 1, 0)));
-    CPPUNIT_ASSERT_EQUAL(OUString("text"), rDoc.GetString(ScAddress(1, 2, 0)));
-    CPPUNIT_ASSERT_EQUAL(OUString("text"), rDoc.GetString(ScAddress(1, 3, 0)));
+    CPPUNIT_ASSERT_EQUAL(OUString("text"), pDoc->GetString(ScAddress(1, 1, 
0)));
+    CPPUNIT_ASSERT_EQUAL(OUString("text"), pDoc->GetString(ScAddress(1, 2, 
0)));
+    CPPUNIT_ASSERT_EQUAL(OUString("text"), pDoc->GetString(ScAddress(1, 3, 
0)));
 
     // Both cells A6 and A7 should be registered with scExternalRefManager 
properly
     CPPUNIT_ASSERT_EQUAL(
-        true, 
rDoc.GetExternalRefManager()->hasCellExternalReference(ScAddress(0, 5, 0)));
+        true, 
pDoc->GetExternalRefManager()->hasCellExternalReference(ScAddress(0, 5, 0)));
     CPPUNIT_ASSERT_EQUAL(
-        true, 
rDoc.GetExternalRefManager()->hasCellExternalReference(ScAddress(0, 6, 0)));
-
-    xDocSh->DoClose();
+        true, 
pDoc->GetExternalRefManager()->hasCellExternalReference(ScAddress(0, 6, 0)));
 }
 
 void ScFiltersTest2::testHybridSharedStringODS()
 {
-    ScDocShellRef xDocSh = loadDoc(u"hybrid-shared-string.", FORMAT_ODS);
+    createScDoc("ods/hybrid-shared-string.ods");
 
-    ScDocument& rDoc = xDocSh->GetDocument();
+    ScDocument* pDoc = getScDoc();
 
     // A2 contains formula with MATCH function.  The result must be 2, not 
#N/A!
-    CPPUNIT_ASSERT_EQUAL(2.0, rDoc.GetValue(ScAddress(0, 1, 0)));
-
-    xDocSh->DoClose();
+    CPPUNIT_ASSERT_EQUAL(2.0, pDoc->GetValue(ScAddress(0, 1, 0)));
 }
 
 void ScFiltersTest2::testCopyMergedNumberFormats()
 {
-    ScDocShellRef xDocSh = loadDoc(u"copy-merged-number-formats.", FORMAT_ODS);
-    ScDocument& rDoc = xDocSh->GetDocument();
+    createScDoc("ods/copy-merged-number-formats.ods");
+    ScDocument* pDoc = getScDoc();
 
     // Cells B1, C1 and D1 are formatted as dates.
-    OUString aStrB1 = rDoc.GetString(ScAddress(1, 0, 0));
-    OUString aStrC1 = rDoc.GetString(ScAddress(2, 0, 0));
-    OUString aStrD1 = rDoc.GetString(ScAddress(3, 0, 0));
+    OUString aStrB1 = pDoc->GetString(ScAddress(1, 0, 0));
+    OUString aStrC1 = pDoc->GetString(ScAddress(2, 0, 0));
+    OUString aStrD1 = pDoc->GetString(ScAddress(3, 0, 0));
 
     ScDocument aCopyDoc;
     aCopyDoc.InsertTab(0, "CopyHere");
-    rDoc.CopyStaticToDocument(ScRange(1, 0, 0, 3, 0, 0), 0, aCopyDoc);
+    pDoc->CopyStaticToDocument(ScRange(1, 0, 0, 3, 0, 0), 0, aCopyDoc);
 
     // Make sure the date formats are copied to the new document.
     CPPUNIT_ASSERT_EQUAL(aStrB1, aCopyDoc.GetString(ScAddress(1, 0, 0)));
     CPPUNIT_ASSERT_EQUAL(aStrC1, aCopyDoc.GetString(ScAddress(2, 0, 0)));
     CPPUNIT_ASSERT_EQUAL(aStrD1, aCopyDoc.GetString(ScAddress(3, 0, 0)));
-
-    xDocSh->DoClose();
 }
 
 void ScFiltersTest2::testVBAUserFunctionXLSM()
 {
-    ScDocShellRef xDocSh = loadDoc(u"vba-user-function.", FORMAT_XLSM);
-    ScDocument& rDoc = xDocSh->GetDocument();
+    createScDoc("xlsm/vba-user-function.xlsm");
+    ScDocument* pDoc = getScDoc();
 
     // A1 contains formula with user-defined function, and the function is 
defined in VBA.
-    ScFormulaCell* pFC = rDoc.GetFormulaCell(ScAddress(0, 0, 0));
+    ScFormulaCell* pFC = pDoc->GetFormulaCell(ScAddress(0, 0, 0));
     CPPUNIT_ASSERT(pFC);
 
-    sc::CompileFormulaContext aCxt(rDoc);
+    sc::CompileFormulaContext aCxt(*pDoc);
     OUString aFormula = pFC->GetFormula(aCxt);
 
     CPPUNIT_ASSERT_EQUAL(OUString("=MYFUNC()"), aFormula);
@@ -935,9 +892,7 @@ void ScFiltersTest2::testVBAUserFunctionXLSM()
     CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(nErrCode));
 
     // Check the result.
-    CPPUNIT_ASSERT_EQUAL(42.0, rDoc.GetValue(ScAddress(0, 0, 0)));
-
-    xDocSh->DoClose();
+    CPPUNIT_ASSERT_EQUAL(42.0, pDoc->GetValue(ScAddress(0, 0, 0)));
 }
 
 void ScFiltersTest2::testEmbeddedImageXLS()
@@ -945,10 +900,10 @@ void ScFiltersTest2::testEmbeddedImageXLS()
     // The document has one embedded image on the first sheet.  Make sure it's
     // imported properly.
 
-    ScDocShellRef xDocSh = loadDoc(u"file-with-png-image.", FORMAT_XLS);
-    ScDocument& rDoc = xDocSh->GetDocument();
+    createScDoc("xls/file-with-png-image.xls");
+    ScDocument* pDoc = getScDoc();
 
-    ScDrawLayer* pDL = rDoc.GetDrawLayer();
+    ScDrawLayer* pDL = pDoc->GetDrawLayer();
     CPPUNIT_ASSERT(pDL);
     const SdrPage* pPage = pDL->GetPage(0);
     CPPUNIT_ASSERT(pPage);
@@ -961,97 +916,92 @@ void ScFiltersTest2::testEmbeddedImageXLS()
     CPPUNIT_ASSERT_MESSAGE(
         "Bitmap content should not be empty if the image has been properly 
imported.",
         !aBMP.IsEmpty());
-
-    xDocSh->DoClose();
 }
 
 void ScFiltersTest2::testErrorOnExternalReferences()
 {
-    ScDocShellRef xDocSh = loadDoc(u"blank.", FORMAT_ODS);
+    createScDoc("ods/blank.ods");
 
-    ScDocument& rDoc = xDocSh->GetDocument();
+    ScDocument* pDoc = getScDoc();
 
     // Test tdf#89330
-    rDoc.SetString(ScAddress(0, 0, 0), 
"='file:///Path/To/FileA.ods'#$Sheet1.A1A");
+    pDoc->SetString(ScAddress(0, 0, 0), 
"='file:///Path/To/FileA.ods'#$Sheet1.A1A");
 
-    ScFormulaCell* pFC = rDoc.GetFormulaCell(ScAddress(0, 0, 0));
+    ScFormulaCell* pFC = pDoc->GetFormulaCell(ScAddress(0, 0, 0));
     CPPUNIT_ASSERT(pFC);
     CPPUNIT_ASSERT_EQUAL(int(FormulaError::NoName), 
static_cast<int>(pFC->GetErrCode()));
 
-    ASSERT_FORMULA_EQUAL(rDoc, ScAddress(0, 0, 0), 
"'file:///Path/To/FileA.ods'#$Sheet1.A1A",
+    ASSERT_FORMULA_EQUAL(*pDoc, ScAddress(0, 0, 0), 
"'file:///Path/To/FileA.ods'#$Sheet1.A1A",
                          "Formula changed");
-
-    xDocSh->DoClose();
 }
 
 void ScFiltersTest2::testTdf145054()
 {
-    ScDocShellRef xDocSh = loadDoc(u"tdf145054.", FORMAT_XLSX);
+    createScDoc("xlsx/tdf145054.xlsx");
 
-    ScDocument& rDoc = xDocSh->GetDocument();
+    ScDocument* pDoc = getScDoc();
 
     // Copy sheet
-    rDoc.CopyTab(0, 1);
-    CPPUNIT_ASSERT_EQUAL(SCTAB(2), rDoc.GetTableCount());
+    pDoc->CopyTab(0, 1);
+    CPPUNIT_ASSERT_EQUAL(SCTAB(2), pDoc->GetTableCount());
 
     // Make sure named DB was copied
-    ScDBData* pDBData = 
rDoc.GetDBCollection()->getNamedDBs().findByName("__Anonymous_Sheet_DB__1");
+    ScDBData* pDBData
+        = 
pDoc->GetDBCollection()->getNamedDBs().findByName("__Anonymous_Sheet_DB__1");
     CPPUNIT_ASSERT(pDBData);
 }
 
 void ScFiltersTest2::testTdf84762()
 {
-    ScDocShellRef xDocSh = loadDoc(u"blank.", FORMAT_ODS);
+    createScDoc("ods/blank.ods");
 
-    ScDocument& rDoc = xDocSh->GetDocument();
+    ScDocument* pDoc = getScDoc();
 
-    rDoc.SetString(ScAddress(0, 0, 0), "=RAND()");
-    rDoc.SetString(ScAddress(0, 1, 0), "=RAND()");
-    rDoc.SetString(ScAddress(1, 0, 0), "=RAND()*A1");
-    rDoc.SetString(ScAddress(1, 1, 0), "=RAND()*B1");
+    pDoc->SetString(ScAddress(0, 0, 0), "=RAND()");
+    pDoc->SetString(ScAddress(0, 1, 0), "=RAND()");
+    pDoc->SetString(ScAddress(1, 0, 0), "=RAND()*A1");
+    pDoc->SetString(ScAddress(1, 1, 0), "=RAND()*B1");
 
     double nValA1, nValB1, nValA2, nValB2;
 
+    ScDocShell* pDocSh = getScDocShell();
+
     // Without the fix in place, some cells wouldn't have been updated
     // after using F9 a few times
     for (sal_Int16 i = 0; i < 10; ++i)
     {
-        nValA1 = rDoc.GetValue(0, 0, 0);
-        nValB1 = rDoc.GetValue(0, 1, 0);
-        nValA2 = rDoc.GetValue(1, 0, 0);
-        nValB2 = rDoc.GetValue(1, 1, 0);
+        nValA1 = pDoc->GetValue(0, 0, 0);
+        nValB1 = pDoc->GetValue(0, 1, 0);
+        nValA2 = pDoc->GetValue(1, 0, 0);
+        nValB2 = pDoc->GetValue(1, 1, 0);
 
-        xDocSh->DoRecalc(false);
+        pDocSh->DoRecalc(false);
 
-        CPPUNIT_ASSERT(nValA1 != rDoc.GetValue(0, 0, 0));
-        CPPUNIT_ASSERT(nValA2 != rDoc.GetValue(0, 1, 0));
-        CPPUNIT_ASSERT(nValB1 != rDoc.GetValue(1, 0, 0));
-        CPPUNIT_ASSERT(nValB2 != rDoc.GetValue(1, 1, 0));
+        CPPUNIT_ASSERT(nValA1 != pDoc->GetValue(0, 0, 0));
+        CPPUNIT_ASSERT(nValA2 != pDoc->GetValue(0, 1, 0));
+        CPPUNIT_ASSERT(nValB1 != pDoc->GetValue(1, 0, 0));
+        CPPUNIT_ASSERT(nValB2 != pDoc->GetValue(1, 1, 0));
     }
-
-    xDocSh->DoClose();
 }
 
 void ScFiltersTest2::testTdf44076()
 {
-    ScDocShellRef xDocSh = loadDoc(u"blank.", FORMAT_ODS);
-
-    ScDocument& rDoc = xDocSh->GetDocument();
+    createScDoc("ods/blank.ods");
 
-    rDoc.SetString(ScAddress(0, 0, 0), "=(-8)^(1/3)");
+    ScDocument* pDoc = getScDoc();
 
-    CPPUNIT_ASSERT_EQUAL(-2.0, rDoc.GetValue(ScAddress(0, 0, 0)));
+    pDoc->SetString(ScAddress(0, 0, 0), "=(-8)^(1/3)");
 
-    xDocSh->DoClose();
+    CPPUNIT_ASSERT_EQUAL(-2.0, pDoc->GetValue(ScAddress(0, 0, 0)));
 }
 
 void ScFiltersTest2::testEditEngStrikeThroughXLSX()
 {
-    ScDocShellRef xDocSh = loadDoc(u"strike-through.", FORMAT_XLSX);
+    createScDoc("xlsx/strike-through.xlsx");
 
-    ScDocument& rDoc = xDocSh->GetDocument();
+    ScDocument* pDoc = getScDoc();
 
-    const EditTextObject* pObj = rDoc.GetEditText(ScAddress(0, 0, 0));
+    const EditTextObject* pObj = pDoc->GetEditText(ScAddress(0, 0, 0));
     CPPUNIT_ASSERT(pObj);
     CPPUNIT_ASSERT_EQUAL(sal_Int32(1), pObj->GetParagraphCount());
     CPPUNIT_ASSERT_EQUAL(OUString("this is strike through  this not"), 
pObj->GetText(0));
@@ -1073,31 +1023,27 @@ void ScFiltersTest2::testEditEngStrikeThroughXLSX()
             }
         }
     }
-
-    xDocSh->DoClose();
 }
 
 void ScFiltersTest2::testRefStringXLSX()
 {
-    ScDocShellRef xDocSh = loadDoc(u"ref_string.", FORMAT_XLSX);
+    createScDoc("xlsx/ref_string.xlsx");
 
-    ScDocument& rDoc = xDocSh->GetDocument();
+    ScDocument* pDoc = getScDoc();
 
-    double nVal = rDoc.GetValue(2, 2, 0);
+    double nVal = pDoc->GetValue(2, 2, 0);
     ASSERT_DOUBLES_EQUAL(3.0, nVal);
 
-    const ScCalcConfig& rCalcConfig = rDoc.GetCalcConfig();
+    const ScCalcConfig& rCalcConfig = pDoc->GetCalcConfig();
     CPPUNIT_ASSERT_EQUAL(formula::FormulaGrammar::CONV_XL_A1, 
rCalcConfig.meStringRefAddressSyntax);
-
-    xDocSh->DoClose();
 }
 
 void ScFiltersTest2::testTdf130132()
 {
-    ScDocShellRef xDocSh = loadDoc(u"tdf130132.", FORMAT_ODS);
+    createScDoc("ods/tdf130132.ods");
 
-    ScDocument& rDoc = xDocSh->GetDocument();
-    const ScPatternAttr* pAttr = rDoc.GetPattern(434, 0, 0);
+    ScDocument* pDoc = getScDoc();
+    const ScPatternAttr* pAttr = pDoc->GetPattern(434, 0, 0);
 
     {
         const SfxPoolItem& rItem = pAttr->GetItem(ATTR_BACKGROUND);
@@ -1110,11 +1056,11 @@ void ScFiltersTest2::testTdf130132()
 
 void ScFiltersTest2::testTdf133327()
 {
-    ScDocShellRef xDocSh = loadDoc(u"tdf133327.", FORMAT_ODS);
+    createScDoc("ods/tdf133327.ods");
 
-    ScDocument& rDoc = xDocSh->GetDocument();
+    ScDocument* pDoc = getScDoc();
 
-    const ScPatternAttr* pAttr = rDoc.GetPattern(250, 1, 0);
+    const ScPatternAttr* pAttr = pDoc->GetPattern(250, 1, 0);
 
     const SfxPoolItem& rItem = pAttr->GetItem(ATTR_BACKGROUND);
     const SvxBrushItem& rBackground = static_cast<const SvxBrushItem&>(rItem);
@@ -1128,10 +1074,10 @@ void ScFiltersTest2::testTdf133327()
 
 void ScFiltersTest2::testColumnStyle2XLSX()
 {
-    ScDocShellRef xDocSh = loadDoc(u"column_style.", FORMAT_XLSX);
+    createScDoc("xlsx/column_style.xlsx");
 
-    ScDocument& rDoc = xDocSh->GetDocument();
-    const ScPatternAttr* pAttr = rDoc.GetPattern(1, 1, 0);
+    ScDocument* pDoc = getScDoc();
+    const ScPatternAttr* pAttr = pDoc->GetPattern(1, 1, 0);
 
     {
         const SfxPoolItem& rItem = pAttr->GetItem(ATTR_BACKGROUND);
@@ -1159,16 +1105,13 @@ void ScFiltersTest2::testColumnStyle2XLSX()
         OUString aName = rFont.GetFamilyName();
         CPPUNIT_ASSERT_EQUAL(OUString("Linux Biolinum G"), aName);
     }
-
-    xDocSh->DoClose();
 }
 
 void ScFiltersTest2::testTdf110440XLSX()
 {
-    ScDocShellRef xDocSh = loadDoc(u"tdf110440.", FORMAT_XLSX);
+    createScDoc("xlsx/tdf110440.xlsx");
 
-    uno::Reference<frame::XModel> xModel = xDocSh->GetModel();
-    uno::Reference<sheet::XSpreadsheetDocument> xDoc(xModel, 
uno::UNO_QUERY_THROW);
+    uno::Reference<sheet::XSpreadsheetDocument> xDoc(mxComponent, 
uno::UNO_QUERY_THROW);
     uno::Reference<container::XIndexAccess> xIA(xDoc->getSheets(), 
uno::UNO_QUERY_THROW);
     uno::Reference<drawing::XDrawPageSupplier> 
xDrawPageSupplier(xIA->getByIndex(0),
                                                                  
uno::UNO_QUERY_THROW);
@@ -1178,16 +1121,14 @@ void ScFiltersTest2::testTdf110440XLSX()
     xShape->getPropertyValue("Visible") >>= bVisible;
     // This failed: group shape's hidden property was lost on import.
     CPPUNIT_ASSERT(!bVisible);
-
-    xDocSh->DoClose();
 }
 
 void ScFiltersTest2::testBnc762542()
 {
-    ScDocShellRef xDocSh = loadDoc(u"bnc762542.", FORMAT_XLSX);
+    createScDoc("xlsx/bnc762542.xlsx");
 
-    ScDocument& rDoc = xDocSh->GetDocument();
-    ScDrawLayer* pDrawLayer = rDoc.GetDrawLayer();
+    ScDocument* pDoc = getScDoc();
+    ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer();
     SdrPage* pPage = pDrawLayer->GetPage(0);
     CPPUNIT_ASSERT_MESSAGE("draw page for sheet 1 should exist.", pPage);
 
@@ -1204,34 +1145,28 @@ void ScFiltersTest2::testBnc762542()
         CPPUNIT_ASSERT_MESSAGE("Drawing object shouldn't be rotated.",
                                aRect.GetWidth() > aRect.GetHeight());
     }
-
-    xDocSh->DoClose();
 }
 
 void ScFiltersTest2::testHiddenSheetsXLSX()
 {
-    ScDocShellRef xDocSh = loadDoc(u"hidden_sheets.", FORMAT_XLSX);
-
-    ScDocument& rDoc = xDocSh->GetDocument();
-    CPPUNIT_ASSERT_EQUAL_MESSAGE("1st sheet should be hidden", false, 
rDoc.IsVisible(0));
-    CPPUNIT_ASSERT_EQUAL_MESSAGE("2nd sheet should be visible", true, 
rDoc.IsVisible(1));
-    CPPUNIT_ASSERT_EQUAL_MESSAGE("3rd sheet should be hidden", false, 
rDoc.IsVisible(2));
+    createScDoc("xlsx/hidden_sheets.xlsx");
 
-    xDocSh->DoClose();
+    ScDocument* pDoc = getScDoc();
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("1st sheet should be hidden", false, 
pDoc->IsVisible(0));
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("2nd sheet should be visible", true, 
pDoc->IsVisible(1));
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("3rd sheet should be hidden", false, 
pDoc->IsVisible(2));
 }
 
 void ScFiltersTest2::testAutofilterXLSX()
 {
-    ScDocShellRef xDocSh = loadDoc(u"autofilter.", FORMAT_XLSX);
+    createScDoc("xlsx/autofilter.xlsx");
 
-    ScDocument& rDoc = xDocSh->GetDocument();
-    const ScDBData* pData = rDoc.GetDBCollection()->GetDBNearCursor(0, 0, 0);
+    ScDocument* pDoc = getScDoc();
+    const ScDBData* pData = pDoc->GetDBCollection()->GetDBNearCursor(0, 0, 0);
     CPPUNIT_ASSERT(pData);
     ScRange aRange;
     pData->GetArea(aRange);
     CPPUNIT_ASSERT_EQUAL(ScRange(0, 0, 0, 2, 4, 0), aRange);
-
-    xDocSh->DoClose();
 }
 
 namespace
@@ -1252,307 +1187,277 @@ void checkValidationFormula(const ScAddress& rPos, 
const ScDocument& rDoc,
 
 void ScFiltersTest2::testRelFormulaValidationXLS()
 {
-    ScDocShellRef xDocSh = loadDoc(u"validation.", FORMAT_XLS);
+    createScDoc("xls/validation.xls");
 
-    ScDocument& rDoc = xDocSh->GetDocument();
+    ScDocument* pDoc = getScDoc();
 
-    checkValidationFormula(ScAddress(3, 4, 0), rDoc, "C5");
-    checkValidationFormula(ScAddress(5, 8, 0), rDoc, "D7");
-
-    xDocSh->DoClose();
+    checkValidationFormula(ScAddress(3, 4, 0), *pDoc, "C5");
+    checkValidationFormula(ScAddress(5, 8, 0), *pDoc, "D7");
 }
 
 void ScFiltersTest2::testTdf136364()
 {
-    ScDocShellRef xDocSh = loadDoc(u"tdf136364.", FORMAT_XLSX);
+    createScDoc("xlsx/tdf136364.xlsx");
 
-    ScDocument& rDoc = xDocSh->GetDocument();
+    ScDocument* pDoc = getScDoc();
 
     // Without the fix in place, it would have failed with
     // - Expected: =SUM((B2:B3~C4:C5~D6:D7))
     // - Actual  : =SUM((B2:B3~C4:C5,D6:D7))
-    OUString aFormula = rDoc.GetFormula(4, 0, 0);
+    OUString aFormula = pDoc->GetFormula(4, 0, 0);
     CPPUNIT_ASSERT_EQUAL(OUString("=SUM((B2:B3~C4:C5~D6:D7))"), aFormula);
-    CPPUNIT_ASSERT_EQUAL(27.0, rDoc.GetValue(ScAddress(4, 0, 0)));
+    CPPUNIT_ASSERT_EQUAL(27.0, pDoc->GetValue(ScAddress(4, 0, 0)));
 
     // - Expected: =SUM((B2~C4~D6))
     // - Actual  : =SUM((B2~C4,D6))
-    aFormula = rDoc.GetFormula(4, 1, 0);
+    aFormula = pDoc->GetFormula(4, 1, 0);
     CPPUNIT_ASSERT_EQUAL(OUString("=SUM((B2~C4~D6))"), aFormula);
-    CPPUNIT_ASSERT_EQUAL(12.0, rDoc.GetValue(ScAddress(4, 1, 0)));
-
-    xDocSh->DoClose();
+    CPPUNIT_ASSERT_EQUAL(12.0, pDoc->GetValue(ScAddress(4, 1, 0)));
 }
 
 void ScFiltersTest2::testTdf103734()
 {
-    ScDocShellRef xDocSh = loadDoc(u"tdf103734.", FORMAT_ODS);
-    ScDocument& rDoc = xDocSh->GetDocument();
+    createScDoc("ods/tdf103734.ods");
+    ScDocument* pDoc = getScDoc();
 
     // Without the fix in place, MAX() would have returned -1.8E+308
-    CPPUNIT_ASSERT_EQUAL(OUString("#N/A"), rDoc.GetString(ScAddress(2, 0, 0)));
-
-    xDocSh->DoClose();
+    CPPUNIT_ASSERT_EQUAL(OUString("#N/A"), pDoc->GetString(ScAddress(2, 0, 
0)));
 }
 
 void ScFiltersTest2::testTdf126116()
 {
-    ScDocShellRef xDocSh = loadDoc(u"tdf126116.", FORMAT_FODS);
-    ScDocument& rDoc = xDocSh->GetDocument();
+    createScDoc("fods/tdf126116.fods");
+    ScDocument* pDoc = getScDoc();
 
-    CPPUNIT_ASSERT_EQUAL(OUString("02/02/21"), rDoc.GetString(ScAddress(0, 0, 
0)));
+    CPPUNIT_ASSERT_EQUAL(OUString("02/02/21"), pDoc->GetString(ScAddress(0, 0, 
0)));
 
-    rDoc.SetString(ScAddress(0, 0, 0), "03/03");
+    pDoc->SetString(ScAddress(0, 0, 0), "03/03");
 
-    sal_uInt32 nNumberFormat = rDoc.GetNumberFormat(0, 0, 0);
-    const SvNumberformat* pNumberFormat = 
rDoc.GetFormatTable()->GetEntry(nNumberFormat);
+    sal_uInt32 nNumberFormat = pDoc->GetNumberFormat(0, 0, 0);
+    const SvNumberformat* pNumberFormat = 
pDoc->GetFormatTable()->GetEntry(nNumberFormat);
     const OUString& rFormatStr = pNumberFormat->GetFormatstring();
 
     // Without the fix in place, this test would have failed with
     // - Expected: MM/DD/YY
     // - Actual  : MM/DD/YYYY
     CPPUNIT_ASSERT_EQUAL(OUString("MM/DD/YY"), rFormatStr);
-
-    xDocSh->DoClose();
 }
 
 void ScFiltersTest2::testTdf144209()
 {
-    ScDocShellRef xDocSh = loadDoc(u"tdf144209.", FORMAT_ODS);
-    ScDocument& rDoc = xDocSh->GetDocument();
+    createScDoc("ods/tdf144209.ods");
+    ScDocument* pDoc = getScDoc();
 
-    CPPUNIT_ASSERT_EQUAL(OUString("AA 0"), rDoc.GetString(ScAddress(0, 0, 0)));
+    CPPUNIT_ASSERT_EQUAL(OUString("AA 0"), pDoc->GetString(ScAddress(0, 0, 
0)));
 
-    xDocSh->DoHardRecalc();
+    ScDocShell* pDocSh = getScDocShell();
+    pDocSh->DoHardRecalc();
 
     // Without the fix in place, this test would have failed with
     // - Expected: AA 33263342642.5385
     // - Actual  : AA 0
-    CPPUNIT_ASSERT_EQUAL(OUString("AA 33263342642.5385"), 
rDoc.GetString(ScAddress(0, 0, 0)));
-
-    xDocSh->DoClose();
+    CPPUNIT_ASSERT_EQUAL(OUString("AA 33263342642.5385"), 
pDoc->GetString(ScAddress(0, 0, 0)));
 }
 
 void ScFiltersTest2::testTdf98844()
 {
-    ScDocShellRef xDocSh = loadDoc(u"tdf98844.", FORMAT_ODS);
-    ScDocument& rDoc = xDocSh->GetDocument();
+    createScDoc("ods/tdf98844.ods");
+    ScDocument* pDoc = getScDoc();
 
-    CPPUNIT_ASSERT_EQUAL(47.6227, rDoc.GetValue(ScAddress(0, 7, 0)));
-    CPPUNIT_ASSERT_EQUAL(48.0, rDoc.GetValue(ScAddress(0, 8, 0)));
+    CPPUNIT_ASSERT_EQUAL(47.6227, pDoc->GetValue(ScAddress(0, 7, 0)));
+    CPPUNIT_ASSERT_EQUAL(48.0, pDoc->GetValue(ScAddress(0, 8, 0)));
 
-    xDocSh->DoHardRecalc();
+    ScDocShell* pDocSh = getScDocShell();
+    pDocSh->DoHardRecalc();
 
     // Without the fix in place, SUM() wouldn't have been updated when
     // Precision as shown is enabled
-    CPPUNIT_ASSERT_EQUAL(48.0, rDoc.GetValue(ScAddress(0, 7, 0)));
-    CPPUNIT_ASSERT_EQUAL(48.0, rDoc.GetValue(ScAddress(0, 8, 0)));
-
-    xDocSh->DoClose();
+    CPPUNIT_ASSERT_EQUAL(48.0, pDoc->GetValue(ScAddress(0, 7, 0)));
+    CPPUNIT_ASSERT_EQUAL(48.0, pDoc->GetValue(ScAddress(0, 8, 0)));
 }
 
 void ScFiltersTest2::testTdf100458()
 {
-    ScDocShellRef xDocSh = loadDoc(u"tdf100458_lost_zero_value.", FORMAT_ODS);
-    ScDocument& rDoc = xDocSh->GetDocument();
-    CPPUNIT_ASSERT(rDoc.HasValueData(0, 0, 0));
-    CPPUNIT_ASSERT_EQUAL(0.0, rDoc.GetValue(0, 0, 0));
-    CPPUNIT_ASSERT(!rDoc.HasStringData(0, 0, 0));
-    xDocSh->DoClose();
+    createScDoc("ods/tdf100458_lost_zero_value.ods");
+    ScDocument* pDoc = getScDoc();
+    CPPUNIT_ASSERT(pDoc->HasValueData(0, 0, 0));
+    CPPUNIT_ASSERT_EQUAL(0.0, pDoc->GetValue(0, 0, 0));
+    CPPUNIT_ASSERT(!pDoc->HasStringData(0, 0, 0));
 }
 
 void ScFiltersTest2::testTdf118561()
 {
-    ScDocShellRef xDocSh = loadDoc(u"tdf118561.", FORMAT_ODS);
-    ScDocument& rDoc = xDocSh->GetDocument();
+    createScDoc("ods/tdf118561.ods");
+    ScDocument* pDoc = getScDoc();
 
     //Without the fix in place, it would have failed with
     //- Expected: apple
     //- Actual  : Err:502
-    CPPUNIT_ASSERT_EQUAL(OUString("apple"), rDoc.GetString(ScAddress(1, 1, 
1)));
-    CPPUNIT_ASSERT_EQUAL(OUString("apple"), rDoc.GetString(ScAddress(2, 1, 
1)));
-    CPPUNIT_ASSERT_EQUAL(OUString("TRUE"), rDoc.GetString(ScAddress(3, 1, 1)));
-    CPPUNIT_ASSERT_EQUAL(OUString("fruits"), rDoc.GetString(ScAddress(4, 1, 
1)));
-    CPPUNIT_ASSERT_EQUAL(OUString("apple"), rDoc.GetString(ScAddress(5, 1, 
1)));
-    CPPUNIT_ASSERT_EQUAL(OUString("hat"), rDoc.GetString(ScAddress(6, 1, 1)));
-
-    xDocSh->DoClose();
+    CPPUNIT_ASSERT_EQUAL(OUString("apple"), pDoc->GetString(ScAddress(1, 1, 
1)));
+    CPPUNIT_ASSERT_EQUAL(OUString("apple"), pDoc->GetString(ScAddress(2, 1, 
1)));
+    CPPUNIT_ASSERT_EQUAL(OUString("TRUE"), pDoc->GetString(ScAddress(3, 1, 
1)));
+    CPPUNIT_ASSERT_EQUAL(OUString("fruits"), pDoc->GetString(ScAddress(4, 1, 
1)));
+    CPPUNIT_ASSERT_EQUAL(OUString("apple"), pDoc->GetString(ScAddress(5, 1, 
1)));
+    CPPUNIT_ASSERT_EQUAL(OUString("hat"), pDoc->GetString(ScAddress(6, 1, 1)));
 }
 
 void ScFiltersTest2::testTdf125099()
 {
-    ScDocShellRef xDocSh = loadDoc(u"tdf125099.", FORMAT_ODS);
-    ScDocument& rDoc = xDocSh->GetDocument();
+    createScDoc("ods/tdf125099.ods");
+    ScDocument* pDoc = getScDoc();
 
-    CPPUNIT_ASSERT_EQUAL(OUString("03:53:46"), rDoc.GetString(ScAddress(0, 0, 
0)));
-    CPPUNIT_ASSERT_EQUAL(OUString("03:23:59"), rDoc.GetString(ScAddress(0, 1, 
0)));
+    CPPUNIT_ASSERT_EQUAL(OUString("03:53:46"), pDoc->GetString(ScAddress(0, 0, 
0)));
+    CPPUNIT_ASSERT_EQUAL(OUString("03:23:59"), pDoc->GetString(ScAddress(0, 1, 
0)));
 
-    xDocSh->DoHardRecalc();
+    ScDocShell* pDocSh = getScDocShell();
+    pDocSh->DoHardRecalc();
 
-    CPPUNIT_ASSERT_EQUAL(OUString("03:53:46"), rDoc.GetString(ScAddress(0, 0, 
0)));
+    CPPUNIT_ASSERT_EQUAL(OUString("03:53:46"), pDoc->GetString(ScAddress(0, 0, 
0)));
 
     // Without the fix in place, this would have failed with
     // - Expected: 03:24:00
     // - Actual  : 03:23:59
-    CPPUNIT_ASSERT_EQUAL(OUString("03:24:00"), rDoc.GetString(ScAddress(0, 1, 
0)));
-
-    xDocSh->DoClose();
+    CPPUNIT_ASSERT_EQUAL(OUString("03:24:00"), pDoc->GetString(ScAddress(0, 1, 
0)));
 }
 
 void ScFiltersTest2::testTdf134455()
 {
-    ScDocShellRef xDocSh = loadDoc(u"tdf134455.", FORMAT_XLSX);
-    ScDocument& rDoc = xDocSh->GetDocument();
+    createScDoc("xlsx/tdf134455.xlsx");
+    ScDocument* pDoc = getScDoc();
 
-    CPPUNIT_ASSERT_EQUAL(OUString("00:05"), rDoc.GetString(ScAddress(3, 4, 
0)));
-    CPPUNIT_ASSERT_EQUAL(OUString("00:10"), rDoc.GetString(ScAddress(3, 5, 
0)));
-    CPPUNIT_ASSERT_EQUAL(OUString("00:59"), rDoc.GetString(ScAddress(3, 6, 
0)));
+    CPPUNIT_ASSERT_EQUAL(OUString("00:05"), pDoc->GetString(ScAddress(3, 4, 
0)));
+    CPPUNIT_ASSERT_EQUAL(OUString("00:10"), pDoc->GetString(ScAddress(3, 5, 
0)));
+    CPPUNIT_ASSERT_EQUAL(OUString("00:59"), pDoc->GetString(ScAddress(3, 6, 
0)));
 
     // Without the fix in place, TIMEVALUE would have returned Err:502 for 
values
     // greater than 59
-    CPPUNIT_ASSERT_EQUAL(OUString("01:05"), rDoc.GetString(ScAddress(3, 7, 
0)));
-    CPPUNIT_ASSERT_EQUAL(OUString("04:00"), rDoc.GetString(ScAddress(3, 8, 
0)));
-
-    xDocSh->DoClose();
+    CPPUNIT_ASSERT_EQUAL(OUString("01:05"), pDoc->GetString(ScAddress(3, 7, 
0)));
+    CPPUNIT_ASSERT_EQUAL(OUString("04:00"), pDoc->GetString(ScAddress(3, 8, 
0)));
 }
 
 void ScFiltersTest2::testTdf119533()
 {
-    ScDocShellRef xDocSh = loadDoc(u"tdf119533.", FORMAT_ODS);
-    ScDocument& rDoc = xDocSh->GetDocument();
+    createScDoc("ods/tdf119533.ods");
+    ScDocument* pDoc = getScDoc();
 
     // Without fix in place, this test would have failed with
     // - Expected: 0.5
     // - Actual  : 0.483333333333333
-    CPPUNIT_ASSERT_EQUAL(OUString("0.5"), rDoc.GetString(ScAddress(4, 0, 0)));
+    CPPUNIT_ASSERT_EQUAL(OUString("0.5"), pDoc->GetString(ScAddress(4, 0, 0)));
 
     // Without fix in place, this test would have failed with
     // - Expected: 9.5
     // - Actual  : 9.51666666666667
-    CPPUNIT_ASSERT_EQUAL(OUString("9.5"), rDoc.GetString(ScAddress(5, 0, 0)));
-
-    xDocSh->DoClose();
+    CPPUNIT_ASSERT_EQUAL(OUString("9.5"), pDoc->GetString(ScAddress(5, 0, 0)));
 }
 
 void ScFiltersTest2::testTdf127982()
 {
-    ScDocShellRef xDocSh = loadDoc(u"tdf127982.", FORMAT_ODS);
-    ScDocument& rDoc = xDocSh->GetDocument();
+    createScDoc("ods/tdf127982.ods");
+    ScDocument* pDoc = getScDoc();
 
     // Without the fix in place, these cells would be empty
-    CPPUNIT_ASSERT_EQUAL(OUString("R1"), rDoc.GetString(ScAddress(3, 5, 0)));
-    CPPUNIT_ASSERT_EQUAL(OUString("R6"), rDoc.GetString(ScAddress(3, 6, 0)));
-    CPPUNIT_ASSERT_EQUAL(OUString("R7"), rDoc.GetString(ScAddress(3, 7, 0)));
+    CPPUNIT_ASSERT_EQUAL(OUString("R1"), pDoc->GetString(ScAddress(3, 5, 0)));
+    CPPUNIT_ASSERT_EQUAL(OUString("R6"), pDoc->GetString(ScAddress(3, 6, 0)));
+    CPPUNIT_ASSERT_EQUAL(OUString("R7"), pDoc->GetString(ScAddress(3, 7, 0)));
 
-    CPPUNIT_ASSERT_EQUAL(OUString("R1"), rDoc.GetString(ScAddress(4, 5, 0)));
-    CPPUNIT_ASSERT_EQUAL(OUString("R6"), rDoc.GetString(ScAddress(4, 6, 0)));
-    CPPUNIT_ASSERT_EQUAL(OUString("R7"), rDoc.GetString(ScAddress(4, 7, 0)));
+    CPPUNIT_ASSERT_EQUAL(OUString("R1"), pDoc->GetString(ScAddress(4, 5, 0)));
+    CPPUNIT_ASSERT_EQUAL(OUString("R6"), pDoc->GetString(ScAddress(4, 6, 0)));
+    CPPUNIT_ASSERT_EQUAL(OUString("R7"), pDoc->GetString(ScAddress(4, 7, 0)));
 
     // Without the fix in place, these cells would be empty
-    CPPUNIT_ASSERT_EQUAL(OUString("R1"), rDoc.GetString(ScAddress(4, 5, 0)));
-    CPPUNIT_ASSERT_EQUAL(OUString("R6"), rDoc.GetString(ScAddress(4, 6, 0)));
-    CPPUNIT_ASSERT_EQUAL(OUString("R7"), rDoc.GetString(ScAddress(4, 7, 0)));
-
-    xDocSh->DoClose();
+    CPPUNIT_ASSERT_EQUAL(OUString("R1"), pDoc->GetString(ScAddress(4, 5, 0)));
+    CPPUNIT_ASSERT_EQUAL(OUString("R6"), pDoc->GetString(ScAddress(4, 6, 0)));
+    CPPUNIT_ASSERT_EQUAL(OUString("R7"), pDoc->GetString(ScAddress(4, 7, 0)));
 }
 
 void ScFiltersTest2::testTdf109409()
 {
-    ScDocShellRef xDocSh = loadDoc(u"tdf109409.", FORMAT_ODS);
-    ScDocument& rDoc = xDocSh->GetDocument();
+    createScDoc("ods/tdf109409.ods");
+    ScDocument* pDoc = getScDoc();
 
     // TEXTJOIN
-    CPPUNIT_ASSERT_EQUAL(OUString("A1;B1;A2;B2;A3;B3"), 
rDoc.GetString(ScAddress(3, 1, 0)));
-    CPPUNIT_ASSERT_EQUAL(OUString("A1;B1;A2;B2;A3;B3"), 
rDoc.GetString(ScAddress(3, 2, 0)));
-    CPPUNIT_ASSERT_EQUAL(OUString("A1;A2;A3;B1;B2;B3"), 
rDoc.GetString(ScAddress(3, 4, 0)));
+    CPPUNIT_ASSERT_EQUAL(OUString("A1;B1;A2;B2;A3;B3"), 
pDoc->GetString(ScAddress(3, 1, 0)));
+    CPPUNIT_ASSERT_EQUAL(OUString("A1;B1;A2;B2;A3;B3"), 
pDoc->GetString(ScAddress(3, 2, 0)));
+    CPPUNIT_ASSERT_EQUAL(OUString("A1;A2;A3;B1;B2;B3"), 
pDoc->GetString(ScAddress(3, 4, 0)));
 
     // Without the fix in place, it would have failed with
     //- Expected: A1;B1;A2;B2;A3;B3
     //- Actual  : A1;A2;A3;B1;B2;B3
-    CPPUNIT_ASSERT_EQUAL(OUString("A1;B1;A2;B2;A3;B3"), 
rDoc.GetString(ScAddress(3, 5, 0)));
+    CPPUNIT_ASSERT_EQUAL(OUString("A1;B1;A2;B2;A3;B3"), 
pDoc->GetString(ScAddress(3, 5, 0)));
 
     // CONCAT
-    CPPUNIT_ASSERT_EQUAL(OUString("A1B1A2B2A3B3"), rDoc.GetString(ScAddress(6, 
1, 0)));
-    CPPUNIT_ASSERT_EQUAL(OUString("A1B1A2B2A3B3"), rDoc.GetString(ScAddress(6, 
2, 0)));
-    CPPUNIT_ASSERT_EQUAL(OUString("A1A2A3B1B2B3"), rDoc.GetString(ScAddress(6, 
4, 0)));
+    CPPUNIT_ASSERT_EQUAL(OUString("A1B1A2B2A3B3"), 
pDoc->GetString(ScAddress(6, 1, 0)));
+    CPPUNIT_ASSERT_EQUAL(OUString("A1B1A2B2A3B3"), 
pDoc->GetString(ScAddress(6, 2, 0)));
+    CPPUNIT_ASSERT_EQUAL(OUString("A1A2A3B1B2B3"), 
pDoc->GetString(ScAddress(6, 4, 0)));
 
     // Without the fix in place, it would have failed with
     //- Expected: A1B1A2B2A3B3
     //- Actual  : A1A2A3B1B2B3
-    CPPUNIT_ASSERT_EQUAL(OUString("A1B1A2B2A3B3"), rDoc.GetString(ScAddress(6, 
5, 0)));
-
-    xDocSh->DoClose();
+    CPPUNIT_ASSERT_EQUAL(OUString("A1B1A2B2A3B3"), 
pDoc->GetString(ScAddress(6, 5, 0)));
 }
 
 void ScFiltersTest2::testTdf132105()
 {
-    ScDocShellRef xDocSh = loadDoc(u"tdf132105.", FORMAT_ODS);
-    ScDocument& rDoc = xDocSh->GetDocument();
+    createScDoc("ods/tdf132105.ods");
+    ScDocument* pDoc = getScDoc();
 
     // MATCH
-    CPPUNIT_ASSERT_EQUAL(OUString("5"), rDoc.GetString(ScAddress(0, 1, 0)));
-    CPPUNIT_ASSERT_EQUAL(OUString("5"), rDoc.GetString(ScAddress(1, 1, 0)));
+    CPPUNIT_ASSERT_EQUAL(OUString("5"), pDoc->GetString(ScAddress(0, 1, 0)));
+    CPPUNIT_ASSERT_EQUAL(OUString("5"), pDoc->GetString(ScAddress(1, 1, 0)));
 
     // COUNT
-    CPPUNIT_ASSERT_EQUAL(OUString("0"), rDoc.GetString(ScAddress(0, 2, 0)));
-    CPPUNIT_ASSERT_EQUAL(OUString("20"), rDoc.GetString(ScAddress(1, 2, 0)));
+    CPPUNIT_ASSERT_EQUAL(OUString("0"), pDoc->GetString(ScAddress(0, 2, 0)));
+    CPPUNIT_ASSERT_EQUAL(OUString("20"), pDoc->GetString(ScAddress(1, 2, 0)));
 
     // COUNTA
-    CPPUNIT_ASSERT_EQUAL(OUString("20"), rDoc.GetString(ScAddress(0, 3, 0)));
-    CPPUNIT_ASSERT_EQUAL(OUString("20"), rDoc.GetString(ScAddress(1, 3, 0)));
+    CPPUNIT_ASSERT_EQUAL(OUString("20"), pDoc->GetString(ScAddress(0, 3, 0)));
+    CPPUNIT_ASSERT_EQUAL(OUString("20"), pDoc->GetString(ScAddress(1, 3, 0)));
 
     // COUNTBLANK
     // Without the fix in place, it would have failed with
     // - Expected: 0
     //- Actual  : Err:504
-    CPPUNIT_ASSERT_EQUAL(OUString("0"), rDoc.GetString(ScAddress(0, 4, 0)));
-    CPPUNIT_ASSERT_EQUAL(OUString("0"), rDoc.GetString(ScAddress(1, 4, 0)));
-
-    xDocSh->DoClose();
+    CPPUNIT_ASSERT_EQUAL(OUString("0"), pDoc->GetString(ScAddress(0, 4, 0)));
+    CPPUNIT_ASSERT_EQUAL(OUString("0"), pDoc->GetString(ScAddress(1, 4, 0)));
 }
 
 void ScFiltersTest2::testTdf131424()
 {
-    ScDocShellRef xDocSh = loadDoc(u"tdf131424.", FORMAT_XLSX);
-    ScDocument& rDoc = xDocSh->GetDocument();
+    createScDoc("xlsx/tdf131424.xlsx");
+    ScDocument* pDoc = getScDoc();
 
     // Without the fix in place, table reference would have failed
-    CPPUNIT_ASSERT_EQUAL(35.0, rDoc.GetValue(ScAddress(2, 1, 0)));
-    CPPUNIT_ASSERT_EQUAL(58.0, rDoc.GetValue(ScAddress(2, 2, 0)));
-    CPPUNIT_ASSERT_EQUAL(81.0, rDoc.GetValue(ScAddress(2, 3, 0)));
-    CPPUNIT_ASSERT_EQUAL(104.0, rDoc.GetValue(ScAddress(2, 4, 0)));
-
-    xDocSh->DoClose();
+    CPPUNIT_ASSERT_EQUAL(35.0, pDoc->GetValue(ScAddress(2, 1, 0)));
+    CPPUNIT_ASSERT_EQUAL(58.0, pDoc->GetValue(ScAddress(2, 2, 0)));
+    CPPUNIT_ASSERT_EQUAL(81.0, pDoc->GetValue(ScAddress(2, 3, 0)));
+    CPPUNIT_ASSERT_EQUAL(104.0, pDoc->GetValue(ScAddress(2, 4, 0)));
 }
 
 void ScFiltersTest2::testTdf100709XLSX()
 {
-    ScDocShellRef xDocSh = ScBootstrapFixture::loadDoc(u"tdf100709.", 
FORMAT_XLSX);
+    createScDoc("xlsx/tdf100709.xlsx");
 
-    ScDocument& rDoc = xDocSh->GetDocument();
+    ScDocument* pDoc = getScDoc();
     CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell B52 should not be formatted with a $", 
OUString("218"),
-                                 rDoc.GetString(1, 51, 0));
+                                 pDoc->GetString(1, 51, 0));
     CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell A75 should not be formatted as a date", 
OUString("218"),
-                                 rDoc.GetString(0, 74, 0));
-
-    xDocSh->DoClose();
+                                 pDoc->GetString(0, 74, 0));
 }
 
 void ScFiltersTest2::testTdf97598XLSX()
 {
-    ScDocShellRef xDocSh = loadDoc(u"tdf97598_scenarios.", FORMAT_XLSX);
+    createScDoc("xlsx/tdf97598_scenarios.xlsx");
 
-    ScDocument& rDoc = xDocSh->GetDocument();
-    OUString aStr = rDoc.GetString(0, 0, 0); // A1
+    ScDocument* pDoc = getScDoc();
+    OUString aStr = pDoc->GetString(0, 0, 0); // A1
     CPPUNIT_ASSERT_EQUAL(OUString("Cell A1"), aStr);
-
-    xDocSh->DoClose();
 }
 
 void ScFiltersTest2::testTdf83672XLSX()
 {
-    ScDocShellRef xDocSh = loadDoc(u"tdf83672.", FORMAT_XLSX);
-    uno::Reference<drawing::XDrawPagesSupplier> xDoc(xDocSh->GetModel(), 
uno::UNO_QUERY_THROW);
+    createScDoc("xlsx/tdf83672.xlsx");
+    uno::Reference<drawing::XDrawPagesSupplier> xDoc(mxComponent, 
uno::UNO_QUERY_THROW);
     uno::Reference<drawing::XDrawPage> 
xPage(xDoc->getDrawPages()->getByIndex(0),
                                              uno::UNO_QUERY_THROW);
     uno::Reference<drawing::XShape> xShape(xPage->getByIndex(0), 
uno::UNO_QUERY_THROW);
@@ -1560,7 +1465,6 @@ void ScFiltersTest2::testTdf83672XLSX()
     sal_Int32 nRotate = 0;
     xShapeProperties->getPropertyValue("RotateAngle") >>= nRotate;
     CPPUNIT_ASSERT(nRotate != 0);
-    xDocSh->DoClose();
 }
 
 void ScFiltersTest2::testUnicodeFileNameGnumeric()
@@ -1573,48 +1477,44 @@ void ScFiltersTest2::testUnicodeFileNameGnumeric()
     {
         return;
     }
-    ScDocShellRef xDocSh = loadDoc(u"t\u00E4\u00DFt.", FORMAT_GNUMERIC);
-
-    xDocSh->DoClose();
+    loadFromURL(u"gnumeric/t\u00E4\u00DFt.gnumeric");
 }
 
 void ScFiltersTest2::testMergedCellsXLSXML()
 {
-    ScDocShellRef xDocSh = loadDoc(u"merged-cells.", FORMAT_XLS_XML);
-    ScDocument& rDoc = xDocSh->GetDocument();
+    createScDoc("xml/merged-cells.xml");
+    ScDocument* pDoc = getScDoc();
 
     // B1:C1 is merged.
     ScRange aMergedRange(1, 0, 0); // B1
-    rDoc.ExtendTotalMerge(aMergedRange);
+    pDoc->ExtendTotalMerge(aMergedRange);
     CPPUNIT_ASSERT_EQUAL(ScRange(1, 0, 0, 2, 0, 0), aMergedRange);
 
     // D1:F1 is merged.
     aMergedRange = ScRange(3, 0, 0); // D1
-    rDoc.ExtendTotalMerge(aMergedRange);
+    pDoc->ExtendTotalMerge(aMergedRange);
     CPPUNIT_ASSERT_EQUAL(ScRange(3, 0, 0, 5, 0, 0), aMergedRange);
 
     // A2:A3 is merged.
     aMergedRange = ScRange(0, 1, 0); // A2
-    rDoc.ExtendTotalMerge(aMergedRange);
+    pDoc->ExtendTotalMerge(aMergedRange);
     CPPUNIT_ASSERT_EQUAL(ScRange(0, 1, 0, 0, 2, 0), aMergedRange);
 
     // A4:A6 is merged.
     aMergedRange = ScRange(0, 3, 0); // A4
-    rDoc.ExtendTotalMerge(aMergedRange);
+    pDoc->ExtendTotalMerge(aMergedRange);
     CPPUNIT_ASSERT_EQUAL(ScRange(0, 3, 0, 0, 5, 0), aMergedRange);
 
     // C3:F6 is merged.
     aMergedRange = ScRange(2, 2, 0); // C3
-    rDoc.ExtendTotalMerge(aMergedRange);
+    pDoc->ExtendTotalMerge(aMergedRange);
     CPPUNIT_ASSERT_EQUAL(ScRange(2, 2, 0, 5, 5, 0), aMergedRange);
-
-    xDocSh->DoClose();
 }
 
 void ScFiltersTest2::testBackgroundColorStandardXLSXML()
 {
-    ScDocShellRef xDocSh = loadDoc(u"background-color-standard.", 
FORMAT_XLS_XML);
-    ScDocument& rDoc = xDocSh->GetDocument();
+    createScDoc("xml/background-color-standard.xml");
+    ScDocument* pDoc = getScDoc();
 
     struct Check
     {
@@ -1640,10 +1540,10 @@ void ScFiltersTest2::testBackgroundColorStandardXLSXML()
     for (size_t nRow = 0; nRow < aChecks.size(); ++nRow)
     {
         ScAddress aPos(0, nRow, 0);
-        OUString aStr = rDoc.GetString(aPos);
+        OUString aStr = pDoc->GetString(aPos);
         CPPUNIT_ASSERT_EQUAL(aChecks[nRow].aCellValue, aStr);
 
-        const ScPatternAttr* pPat = rDoc.GetPattern(aPos);
+        const ScPatternAttr* pPat = pDoc->GetPattern(aPos);
         CPPUNIT_ASSERT(pPat);
 
         const SvxColorItem& rColor = pPat->GetItem(ATTR_FONT_COLOR);
@@ -1652,28 +1552,26 @@ void ScFiltersTest2::testBackgroundColorStandardXLSXML()
         const SvxBrushItem& rBgColor = pPat->GetItem(ATTR_BACKGROUND);
         CPPUNIT_ASSERT_EQUAL(aChecks[nRow].aBgColor, rBgColor.GetColor());
     }
-
-    xDocSh->DoClose();
 }
 
 void ScFiltersTest2::testTdf131536()
 {
-    ScDocShellRef xDocSh = loadDoc(u"tdf131536.", FORMAT_XLSX);
-    ScDocument& rDoc = xDocSh->GetDocument();
+    createScDoc("xlsx/tdf131536.xlsx");
+    ScDocument* pDoc = getScDoc();
 
     ScAddress aPos(3, 9, 0);
-    CPPUNIT_ASSERT_EQUAL(1.0, rDoc.GetValue(aPos));
+    CPPUNIT_ASSERT_EQUAL(1.0, pDoc->GetValue(aPos));
     ASSERT_FORMULA_EQUAL(
-        rDoc, aPos,
+        *pDoc, aPos,
         
"IF(D$4=\"-\",\"-\",MID(TEXT(INDEX($Comparison.$I:$J,$Comparison.$A5,$Comparison.D$2),\"\")"
         ",2,4)"
         
"=RIGHT(TEXT(INDEX($Comparison.$L:$Z,$Comparison.$A5,$Comparison.D$4),\"\"),4))",
         nullptr);
 
     ScAddress aPos2(4, 9, 0);
-    CPPUNIT_ASSERT_EQUAL(1.0, rDoc.GetValue(aPos2));
+    CPPUNIT_ASSERT_EQUAL(1.0, pDoc->GetValue(aPos2));
     ASSERT_FORMULA_EQUAL(
-        rDoc, aPos2,
+        *pDoc, aPos2,
         
"IF(D$4=\"-\",\"-\",MID(TEXT(INDEX($Comparison.$I:$J,$Comparison.$A5,$Comparison.D$2),"
         "\"0\"),2,4)"
         
"=RIGHT(TEXT(INDEX($Comparison.$L:$Z,$Comparison.$A5,$Comparison.D$4),\"0\"),4))",
@@ -1682,58 +1580,58 @@ void ScFiltersTest2::testTdf131536()
 
 void ScFiltersTest2::testTdf130583()
 {
-    ScDocShellRef xDocSh = loadDoc(u"tdf130583.", FORMAT_ODS);
-    ScDocument& rDoc = xDocSh->GetDocument();
+    createScDoc("ods/tdf130583.ods");
+    ScDocument* pDoc = getScDoc();
 
-    CPPUNIT_ASSERT_EQUAL(OUString("b"), rDoc.GetString(ScAddress(1, 0, 0)));
-    CPPUNIT_ASSERT_EQUAL(OUString("c"), rDoc.GetString(ScAddress(1, 1, 0)));
-    CPPUNIT_ASSERT_EQUAL(OUString("a"), rDoc.GetString(ScAddress(1, 2, 0)));
-    CPPUNIT_ASSERT_EQUAL(OUString("d"), rDoc.GetString(ScAddress(1, 3, 0)));
-    CPPUNIT_ASSERT_EQUAL(OUString("#N/A"), rDoc.GetString(ScAddress(1, 4, 0)));
+    CPPUNIT_ASSERT_EQUAL(OUString("b"), pDoc->GetString(ScAddress(1, 0, 0)));
+    CPPUNIT_ASSERT_EQUAL(OUString("c"), pDoc->GetString(ScAddress(1, 1, 0)));
+    CPPUNIT_ASSERT_EQUAL(OUString("a"), pDoc->GetString(ScAddress(1, 2, 0)));
+    CPPUNIT_ASSERT_EQUAL(OUString("d"), pDoc->GetString(ScAddress(1, 3, 0)));
+    CPPUNIT_ASSERT_EQUAL(OUString("#N/A"), pDoc->GetString(ScAddress(1, 4, 
0)));
 
     // Without the fix in place, SWITCH would have returned #VALUE!
-    CPPUNIT_ASSERT_EQUAL(OUString("b"), rDoc.GetString(ScAddress(4, 0, 0)));
-    CPPUNIT_ASSERT_EQUAL(OUString("c"), rDoc.GetString(ScAddress(4, 1, 0)));
-    CPPUNIT_ASSERT_EQUAL(OUString("a"), rDoc.GetString(ScAddress(4, 2, 0)));
-    CPPUNIT_ASSERT_EQUAL(OUString("d"), rDoc.GetString(ScAddress(4, 3, 0)));
-    CPPUNIT_ASSERT_EQUAL(OUString("#N/A"), rDoc.GetString(ScAddress(4, 4, 0)));
+    CPPUNIT_ASSERT_EQUAL(OUString("b"), pDoc->GetString(ScAddress(4, 0, 0)));
+    CPPUNIT_ASSERT_EQUAL(OUString("c"), pDoc->GetString(ScAddress(4, 1, 0)));
+    CPPUNIT_ASSERT_EQUAL(OUString("a"), pDoc->GetString(ScAddress(4, 2, 0)));
+    CPPUNIT_ASSERT_EQUAL(OUString("d"), pDoc->GetString(ScAddress(4, 3, 0)));
+    CPPUNIT_ASSERT_EQUAL(OUString("#N/A"), pDoc->GetString(ScAddress(4, 4, 
0)));
 }
 
 void ScFiltersTest2::testTdf85617()
 {
-    ScDocShellRef xDocSh = loadDoc(u"tdf85617.", FORMAT_XLSX);
-    ScDocument& rDoc = xDocSh->GetDocument();
+    createScDoc("xlsx/tdf85617.xlsx");
+    ScDocument* pDoc = getScDoc();
 
     ScAddress aPos(2, 2, 0);
     //Without the fix in place, it would be Err:509
-    CPPUNIT_ASSERT_EQUAL(4.5, rDoc.GetValue(aPos));
+    CPPUNIT_ASSERT_EQUAL(4.5, pDoc->GetValue(aPos));
 }
 
 void ScFiltersTest2::testTdf134234()
 {
-    ScDocShellRef xDocSh = loadDoc(u"tdf134234.", FORMAT_ODS);
-    ScDocument& rDoc = xDocSh->GetDocument();
+    createScDoc("ods/tdf134234.ods");
+    ScDocument* pDoc = getScDoc();
 
-    CPPUNIT_ASSERT_EQUAL(3.0, rDoc.GetValue(ScAddress(1, 0, 1)));
+    CPPUNIT_ASSERT_EQUAL(3.0, pDoc->GetValue(ScAddress(1, 0, 1)));
 
     //Without the fix in place, SUMPRODUCT would have returned 0
-    CPPUNIT_ASSERT_EQUAL(36.54, rDoc.GetValue(ScAddress(2, 0, 1)));
+    CPPUNIT_ASSERT_EQUAL(36.54, pDoc->GetValue(ScAddress(2, 0, 1)));
     CPPUNIT_ASSERT_EQUAL(sal_uInt32(833),
-                         static_cast<sal_uInt32>(rDoc.GetValue(ScAddress(3, 0, 
1))));
+                         static_cast<sal_uInt32>(pDoc->GetValue(ScAddress(3, 
0, 1))));
 }
 
 void ScFiltersTest2::testTdf42481()
 {
-    ScDocShellRef xDocSh = loadDoc(u"tdf42481.", FORMAT_ODS);
-    ScDocument& rDoc = xDocSh->GetDocument();
+    createScDoc("ods/tdf42481.ods");
+    ScDocument* pDoc = getScDoc();
 
-    CPPUNIT_ASSERT_EQUAL(OUString("#VALUE!"), rDoc.GetString(ScAddress(3, 9, 
0)));
+    CPPUNIT_ASSERT_EQUAL(OUString("#VALUE!"), pDoc->GetString(ScAddress(3, 9, 
0)));
 
     // Without the fix in place, this test would have failed with
     // - Expected: #VALUE!
     // - Actual  : 14
-    CPPUNIT_ASSERT_EQUAL(OUString("#VALUE!"), rDoc.GetString(ScAddress(3, 10, 
0)));
-    CPPUNIT_ASSERT_EQUAL(OUString("14"), rDoc.GetString(ScAddress(3, 11, 0)));
+    CPPUNIT_ASSERT_EQUAL(OUString("#VALUE!"), pDoc->GetString(ScAddress(3, 10, 
0)));
+    CPPUNIT_ASSERT_EQUAL(OUString("14"), pDoc->GetString(ScAddress(3, 11, 0)));
 }
 
 void ScFiltersTest2::testNamedExpressionsXLSXML()
@@ -1741,60 +1639,56 @@ void ScFiltersTest2::testNamedExpressionsXLSXML()
     {
         // global named expressions
 
-        ScDocShellRef xDocSh = loadDoc(u"named-exp-global.", FORMAT_XLS_XML);
-        ScDocument& rDoc = xDocSh->GetDocument();
+        createScDoc("xml/named-exp-global.xml");
+        ScDocument* pDoc = getScDoc();
 
         // A7
         ScAddress aPos(0, 6, 0);
-        CPPUNIT_ASSERT_EQUAL(15.0, rDoc.GetValue(aPos));
-        ASSERT_FORMULA_EQUAL(rDoc, aPos, "SUM(MyRange)", nullptr);
+        CPPUNIT_ASSERT_EQUAL(15.0, pDoc->GetValue(aPos));
+        ASSERT_FORMULA_EQUAL(*pDoc, aPos, "SUM(MyRange)", nullptr);
 
         // B7
         aPos.IncCol();
-        CPPUNIT_ASSERT_EQUAL(55.0, rDoc.GetValue(aPos));
-        ASSERT_FORMULA_EQUAL(rDoc, aPos, "SUM(MyRange2)", nullptr);
+        CPPUNIT_ASSERT_EQUAL(55.0, pDoc->GetValue(aPos));
+        ASSERT_FORMULA_EQUAL(*pDoc, aPos, "SUM(MyRange2)", nullptr);
 
-        const ScRangeData* pRD = 
rDoc.GetRangeName()->findByUpperName("MYRANGE");
+        const ScRangeData* pRD = 
pDoc->GetRangeName()->findByUpperName("MYRANGE");
         CPPUNIT_ASSERT(pRD);
-        pRD = rDoc.GetRangeName()->findByUpperName("MYRANGE2");
+        pRD = pDoc->GetRangeName()->findByUpperName("MYRANGE2");
         CPPUNIT_ASSERT(pRD);
-
-        xDocSh->DoClose();
     }
 
     {
         // sheet-local named expressions
 
-        ScDocShellRef xDocSh = loadDoc(u"named-exp-local.", FORMAT_XLS_XML);
-        ScDocument& rDoc = xDocSh->GetDocument();
+        createScDoc("xml/named-exp-local.xml");
+        ScDocument* pDoc = getScDoc();
 
         // A7 on Sheet1
         ScAddress aPos(0, 6, 0);
-        CPPUNIT_ASSERT_EQUAL(27.0, rDoc.GetValue(aPos));
-        ASSERT_FORMULA_EQUAL(rDoc, aPos, "SUM(MyRange)", nullptr);
+        CPPUNIT_ASSERT_EQUAL(27.0, pDoc->GetValue(aPos));
+        ASSERT_FORMULA_EQUAL(*pDoc, aPos, "SUM(MyRange)", nullptr);
 
         // A7 on Sheet2
         aPos.IncTab();
-        CPPUNIT_ASSERT_EQUAL(74.0, rDoc.GetValue(aPos));
-        ASSERT_FORMULA_EQUAL(rDoc, aPos, "SUM(MyRange)", nullptr);
+        CPPUNIT_ASSERT_EQUAL(74.0, pDoc->GetValue(aPos));
+        ASSERT_FORMULA_EQUAL(*pDoc, aPos, "SUM(MyRange)", nullptr);
 
-        const ScRangeName* pRN = rDoc.GetRangeName(0);
+        const ScRangeName* pRN = pDoc->GetRangeName(0);
         CPPUNIT_ASSERT(pRN);
         const ScRangeData* pRD = pRN->findByUpperName("MYRANGE");
         CPPUNIT_ASSERT(pRD);
-        pRN = rDoc.GetRangeName(1);
+        pRN = pDoc->GetRangeName(1);
         CPPUNIT_ASSERT(pRN);
         pRD = pRN->findByUpperName("MYRANGE");
         CPPUNIT_ASSERT(pRD);
-
-        xDocSh->DoClose();
     }
 }
 
 void ScFiltersTest2::testEmptyRowsXLSXML()
 {
-    ScDocShellRef xDocSh = loadDoc(u"empty-rows.", FORMAT_XLS_XML);
-    ScDocument& rDoc = xDocSh->GetDocument();
+    createScDoc("xml/empty-rows.xml");
+    ScDocument* pDoc = getScDoc();
 
     {
         // Expected output table content.  0 = empty cell
@@ -1811,22 +1705,20 @@ void ScFiltersTest2::testEmptyRowsXLSXML()
         };
 
         ScRange aDataRange;
-        aDataRange.Parse("A1:B9", rDoc);
-        bool bSuccess = checkOutput(&rDoc, aDataRange, aOutputCheck, "Expected 
output");
+        aDataRange.Parse("A1:B9", *pDoc);
+        bool bSuccess = checkOutput(pDoc, aDataRange, aOutputCheck, "Expected 
output");
         CPPUNIT_ASSERT_MESSAGE("Table output check failed", bSuccess);
     }
 
     ScAddress aPos;
-    aPos.Parse("B9", rDoc);
-    ASSERT_FORMULA_EQUAL(rDoc, aPos, "SUM(B4:B8)", nullptr);
-
-    xDocSh->DoClose();
+    aPos.Parse("B9", *pDoc);
+    ASSERT_FORMULA_EQUAL(*pDoc, aPos, "SUM(B4:B8)", nullptr);
 }
 
 void ScFiltersTest2::testBorderDirectionsXLSXML()
 {
-    ScDocShellRef xDocSh = loadDoc(u"border-directions.", FORMAT_XLS_XML);
-    ScDocument& rDoc = xDocSh->GetDocument();
+    createScDoc("xml/border-directions.xml");
+    ScDocument* pDoc = getScDoc();
 
     struct Check
     {
@@ -1884,7 +1776,7 @@ void ScFiltersTest2::testBorderDirectionsXLSXML()
 
     for (const Check& c : aChecks)
     {
-        const ScPatternAttr* pPat = rDoc.GetPattern(c.aPos);
+        const ScPatternAttr* pPat = pDoc->GetPattern(c.aPos);
         CPPUNIT_ASSERT(pPat);
 
         const SvxBoxItem& rBox = pPat->GetItem(ATTR_BORDER);
@@ -1907,17 +1799,15 @@ void ScFiltersTest2::testBorderDirectionsXLSXML()
         pLine = pPat->GetItem(ATTR_BORDER_BLTR).GetLine();
         CPPUNIT_ASSERT(funcCheckBorder(c.bTRtoBL, pLine));
     }
-
-    xDocSh->DoClose();
 }
 
 void ScFiltersTest2::testBorderColorsXLSXML()
 {
-    ScDocShellRef xDocSh = loadDoc(u"border-colors.", FORMAT_XLS_XML);
-    ScDocument& rDoc = xDocSh->GetDocument();
+    createScDoc("xml/border-colors.xml");
+    ScDocument* pDoc = getScDoc();
 
     // B3 - red
-    const ScPatternAttr* pPat = rDoc.GetPattern(ScAddress(1, 2, 0));
+    const ScPatternAttr* pPat = pDoc->GetPattern(ScAddress(1, 2, 0));
     CPPUNIT_ASSERT(pPat);
     const editeng::SvxBorderLine* pLine = 
pPat->GetItem(ATTR_BORDER).GetRight();
     CPPUNIT_ASSERT(pLine);
@@ -1925,7 +1815,7 @@ void ScFiltersTest2::testBorderColorsXLSXML()
     CPPUNIT_ASSERT_EQUAL(Color(255, 0, 0), pLine->GetColor());
 
     // B4 - blue
-    pPat = rDoc.GetPattern(ScAddress(1, 3, 0));
+    pPat = pDoc->GetPattern(ScAddress(1, 3, 0));
     CPPUNIT_ASSERT(pPat);
     pLine = pPat->GetItem(ATTR_BORDER).GetRight();
     CPPUNIT_ASSERT(pLine);
@@ -1933,7 +1823,7 @@ void ScFiltersTest2::testBorderColorsXLSXML()
     CPPUNIT_ASSERT_EQUAL(Color(0, 112, 192), pLine->GetColor());
 
     // B5 - green
-    pPat = rDoc.GetPattern(ScAddress(1, 4, 0));
+    pPat = pDoc->GetPattern(ScAddress(1, 4, 0));
     CPPUNIT_ASSERT(pPat);
     pLine = pPat->GetItem(ATTR_BORDER).GetRight();
     CPPUNIT_ASSERT(pLine);
@@ -1941,7 +1831,7 @@ void ScFiltersTest2::testBorderColorsXLSXML()
     CPPUNIT_ASSERT_EQUAL(Color(0, 176, 80), pLine->GetColor());
 
     // B7 - yellow (left), purple (right), light blue (cross)
-    pPat = rDoc.GetPattern(ScAddress(1, 6, 0));
+    pPat = pDoc->GetPattern(ScAddress(1, 6, 0));
     CPPUNIT_ASSERT(pPat);
 
     pLine = pPat->GetItem(ATTR_BORDER).GetLeft();
@@ -1963,14 +1853,12 @@ void ScFiltersTest2::testBorderColorsXLSXML()
     CPPUNIT_ASSERT(pLine);
     CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID, 
pLine->GetBorderLineStyle());
     CPPUNIT_ASSERT_EQUAL(Color(0, 176, 240), pLine->GetColor()); // light blue
-
-    xDocSh->DoClose();
 }
 
 void ScFiltersTest2::testHiddenRowsColumnsXLSXML()
 {
-    ScDocShellRef xDocSh = loadDoc(u"hidden-rows-columns.", FORMAT_XLS_XML);
-    ScDocument& rDoc = xDocSh->GetDocument();
+    createScDoc("xml/hidden-rows-columns.xml");
+    ScDocument* pDoc = getScDoc();
 
     struct Check
     {
@@ -1986,13 +1874,13 @@ void ScFiltersTest2::testHiddenRowsColumnsXLSXML()
         { 4, 4, false },
         { 5, 7, true },
         { 8, 8, false },
-        { 9, rDoc.MaxRow(), true },
+        { 9, pDoc->MaxRow(), true },
     };
 
     for (const Check& c : aRowChecks)
     {
         SCROW nRow1 = -1, nRow2 = -1;
-        bool bVisible = !rDoc.RowHidden(c.nPos1, 0, &nRow1, &nRow2);
+        bool bVisible = !pDoc->RowHidden(c.nPos1, 0, &nRow1, &nRow2);
         CPPUNIT_ASSERT_EQUAL(bVisible, c.bVisible);
         CPPUNIT_ASSERT_EQUAL(c.nPos1, nRow1);
         CPPUNIT_ASSERT_EQUAL(c.nPos2, nRow2);
@@ -2003,25 +1891,23 @@ void ScFiltersTest2::testHiddenRowsColumnsXLSXML()
         { 2, 5, false },
         { 6, 9, true },
         { 10, 10, false },
-        { 11, rDoc.MaxCol(), true },
+        { 11, pDoc->MaxCol(), true },
     };
 
     for (const Check& c : aColChecks)
     {
         SCCOL nCol1 = -1, nCol2 = -1;
-        bool bVisible = !rDoc.ColHidden(c.nPos1, 1, &nCol1, &nCol2);
+        bool bVisible = !pDoc->ColHidden(c.nPos1, 1, &nCol1, &nCol2);
         CPPUNIT_ASSERT_EQUAL(bVisible, c.bVisible);
         CPPUNIT_ASSERT_EQUAL(c.nPos1, SCCOLROW(nCol1));
         CPPUNIT_ASSERT_EQUAL(c.nPos2, SCCOLROW(nCol2));
     }
-
-    xDocSh->DoClose();
 }
 
 void ScFiltersTest2::testColumnWidthRowHeightXLSXML()
 {
-    ScDocShellRef xDocSh = loadDoc(u"column-width-row-height.", 
FORMAT_XLS_XML);
-    ScDocument& rDoc = xDocSh->GetDocument();
+    createScDoc("xml/column-width-row-height.xml");
+    ScDocument* pDoc = getScDoc();
 
     struct RowHeight
     {
@@ -2038,7 +1924,7 @@ void ScFiltersTest2::testColumnWidthRowHeightXLSXML()
     {
         for (SCROW i = rh.nRow1; i <= rh.nRow2; ++i)
         {
-            sal_uInt16 nHeight = rDoc.GetRowHeight(i, 0);
+            sal_uInt16 nHeight = pDoc->GetRowHeight(i, 0);
             CPPUNIT_ASSERT_EQUAL(sal_uInt16(rh.nHeight * 20), nHeight);
         }
     }
@@ -2058,23 +1944,21 @@ void ScFiltersTest2::testColumnWidthRowHeightXLSXML()
     {
         for (SCCOL i = cw.nCol1; i <= cw.nCol2; ++i)
         {
-            sal_uInt16 nWidth = rDoc.GetColWidth(i, 0);
+            sal_uInt16 nWidth = pDoc->GetColWidth(i, 0);
             CPPUNIT_ASSERT_EQUAL(sal_uInt16(cw.nWidth * 20), nWidth);
         }
     }
-
-    xDocSh->DoClose();
 }
 
 void ScFiltersTest2::testCharacterSetXLSXML()
 {
-    ScDocShellRef xDocSh = loadDoc(u"character-set.", FORMAT_XLS_XML);
-    ScDocument& rDoc = xDocSh->GetDocument();
+    createScDoc("xml/character-set.xml");
+    ScDocument* pDoc = getScDoc();
 
-    CPPUNIT_ASSERT_EQUAL(SCTAB(1), rDoc.GetTableCount());
+    CPPUNIT_ASSERT_EQUAL(SCTAB(1), pDoc->GetTableCount());
 
     OUString aName;
-    rDoc.GetName(0, aName);
+    pDoc->GetName(0, aName);
 
     // Check the sheet name.  The values are all Cyrillic letters.
     std::vector<sal_Unicode> aBuf = { 0x041b, 0x0438, 0x0441, 0x0442, 0x0031 };
@@ -2082,58 +1966,51 @@ void ScFiltersTest2::testCharacterSetXLSXML()
     CPPUNIT_ASSERT_EQUAL(aExpected, aName);
 
     // Check the value of I4
-    OUString aVal = rDoc.GetString(ScAddress(8, 3, 0));
+    OUString aVal = pDoc->GetString(ScAddress(8, 3, 0));
     aBuf = { 0x0421, 0x0443, 0x043c, 0x043c, 0x0430 };
     aExpected = OUString(aBuf.data(), aBuf.size());
     CPPUNIT_ASSERT_EQUAL(aExpected, aVal);
 
     // Check the value of J3
-    aVal = rDoc.GetString(ScAddress(9, 2, 0));
+    aVal = pDoc->GetString(ScAddress(9, 2, 0));
     aBuf = { 0x041e, 0x0441, 0x0442, 0x0430, 0x0442, 0x043e, 0x043a };
     aExpected = OUString(aBuf.data(), aBuf.size());
     CPPUNIT_ASSERT_EQUAL(aExpected, aVal);
-
-    xDocSh->DoClose();
 }
 
 void ScFiltersTest2::testCondFormatXLSB()
 {
-    ScDocShellRef xDocSh = loadDoc(u"cond_format.", FORMAT_XLSB);
+    createScDoc("xlsb/cond_format.xlsb");
 
-    ScDocument& rDoc = xDocSh->GetDocument();
-    ScConditionalFormatList* pList = rDoc.GetCondFormList(0);
+    ScDocument* pDoc = getScDoc();
+    ScConditionalFormatList* pList = pDoc->GetCondFormList(0);
     CPPUNIT_ASSERT(pList);
 
     CPPUNIT_ASSERT_EQUAL(size_t(1), pList->size());
     ScConditionalFormat* pFormat = pList->begin()->get();
     CPPUNIT_ASSERT(pFormat);
     CPPUNIT_ASSERT_EQUAL(size_t(1), pFormat->size());
-
-    xDocSh->DoClose();
 }
 
 void ScFiltersTest2::testPageScalingXLSX()
 {
-    ScDocShellRef xDocSh = loadDoc(u"page_scale.", FORMAT_XLSX);
-    ScDocument& rDoc = xDocSh->GetDocument();
+    createScDoc("xlsx/page_scale.xlsx");
+    ScDocument* pDoc = getScDoc();
 
-    OUString aStyleName = rDoc.GetPageStyle(0);
-    ScStyleSheetPool* pStylePool = rDoc.GetStyleSheetPool();
+    OUString aStyleName = pDoc->GetPageStyle(0);
+    ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool();
     SfxStyleSheetBase* pStyleSheet = pStylePool->Find(aStyleName, 
SfxStyleFamily::Page);
     CPPUNIT_ASSERT(pStyleSheet);
 
     SfxItemSet& rSet = pStyleSheet->GetItemSet();
     sal_uInt16 nVal = rSet.Get(ATTR_PAGE_SCALE).GetValue();
     CPPUNIT_ASSERT_EQUAL(sal_uInt16(90), nVal);
-
-    xDocSh->DoClose();
 }
 
 void ScFiltersTest2::testActiveXCheckboxXLSX()
 {
-    ScDocShellRef xDocSh = loadDoc(u"activex_checkbox.", FORMAT_XLSX);
-    uno::Reference<frame::XModel> xModel = xDocSh->GetModel();
-    uno::Reference<sheet::XSpreadsheetDocument> xDoc(xModel, UNO_QUERY_THROW);
+    createScDoc("xlsx/activex_checkbox.xlsx");
+    uno::Reference<sheet::XSpreadsheetDocument> xDoc(mxComponent, 
UNO_QUERY_THROW);
     uno::Reference<container::XIndexAccess> xIA(xDoc->getSheets(), 
UNO_QUERY_THROW);
     uno::Reference<drawing::XDrawPageSupplier> 
xDrawPageSupplier(xIA->getByIndex(0),
                                                                  
UNO_QUERY_THROW);
@@ -2166,15 +2043,12 @@ void ScFiltersTest2::testActiveXCheckboxXLSX()
     sal_Int16 nState;
     xPropertySet->getPropertyValue("State") >>= nState;
     CPPUNIT_ASSERT_EQUAL(sal_Int16(1), nState);
-
-    xDocSh->DoClose();
 }
 
 void ScFiltersTest2::testTdf60673()
 {
-    ScDocShellRef xDocSh = loadDoc(u"tdf60673.", FORMAT_XLSX);
-    uno::Reference<frame::XModel> xModel = xDocSh->GetModel();
-    uno::Reference<sheet::XSpreadsheetDocument> xDoc(xModel, UNO_QUERY_THROW);
+    createScDoc("xlsx/tdf60673.xlsx");
+    uno::Reference<sheet::XSpreadsheetDocument> xDoc(mxComponent, 
UNO_QUERY_THROW);
     uno::Reference<container::XIndexAccess> xIA(xDoc->getSheets(), 
UNO_QUERY_THROW);
     uno::Reference<drawing::XDrawPageSupplier> 
xDrawPageSupplier(xIA->getByIndex(0),
                                                                  
UNO_QUERY_THROW);
@@ -2196,9 +2070,8 @@ void ScFiltersTest2::testTdf60673()
 
 void ScFiltersTest2::testtdf120301_xmlSpaceParsingXLSX()
 {
-    ScDocShellRef xDocSh = loadDoc(u"tdf120301_xmlSpaceParsing.", FORMAT_XLSX);
-    uno::Reference<frame::XModel> xModel = xDocSh->GetModel();
-    uno::Reference<sheet::XSpreadsheetDocument> xDoc(xModel, UNO_QUERY_THROW);
+    createScDoc("xlsx/tdf120301_xmlSpaceParsing.xlsx");
+    uno::Reference<sheet::XSpreadsheetDocument> xDoc(mxComponent, 
UNO_QUERY_THROW);
     uno::Reference<container::XIndexAccess> xIA(xDoc->getSheets(), 
UNO_QUERY_THROW);
     uno::Reference<drawing::XDrawPageSupplier> 
xDrawPageSupplier(xIA->getByIndex(0),
                                                                  
UNO_QUERY_THROW);
@@ -2211,7 +2084,6 @@ void ScFiltersTest2::testtdf120301_xmlSpaceParsingXLSX()
     OUString sCaption;
     XPropSet->getPropertyValue("Label") >>= sCaption;
     CPPUNIT_ASSERT_EQUAL(OUString("Check Box 1"), sCaption);
-    xDocSh->DoClose();
 }
 
 namespace
@@ -2236,22 +2108,21 @@ struct PaintListener : public SfxListener
 
 void ScFiltersTest2::testCondFormatFormulaListenerXLSX()
 {
-    ScDocShellRef xDocSh = loadDoc(u"cond_format_formula_listener.", 
FORMAT_XLSX);
+    createScDoc("xlsx/cond_format_formula_listener.xlsx");
+    ScDocShell* pDocSh = getScDocShell();
     PaintListener aListener;
-    aListener.StartListening(*xDocSh);
-    ScDocument& rDoc = xDocSh->GetDocument();
-    ScConditionalFormatList* pList = rDoc.GetCondFormList(0);
+    aListener.StartListening(*pDocSh);
+    ScDocument* pDoc = getScDoc();
+    ScConditionalFormatList* pList = pDoc->GetCondFormList(0);
     CPPUNIT_ASSERT(pList);
 
     CPPUNIT_ASSERT_EQUAL(size_t(1), pList->size());
     ScConditionalFormat* pFormat = pList->begin()->get();
     CPPUNIT_ASSERT(pFormat);
-    rDoc.SetDocVisible(true);
-    rDoc.SetValue(0, 0, 0, 2.0);
+    pDoc->SetDocVisible(true);
+    pDoc->SetValue(0, 0, 0, 2.0);
 
     CPPUNIT_ASSERT(aListener.mbCalled);
-
-    xDocSh->DoClose();
 }
 
 void ScFiltersTest2::testTdf137091()
@@ -2266,14 +2137,13 @@ void ScFiltersTest2::testTdf137091()
         aOptions.Commit();
     });
 
-    ScDocShellRef xDocSh = loadDoc(u"tdf137091.", FORMAT_XLSX);
-    ScDocument& rDoc = xDocSh->GetDocument();
+    createScDoc("xlsx/tdf137091.xlsx");
+    ScDocument* pDoc = getScDoc();
 
     // Without the fix in place, this test would have failed with
     // - Expected: 28/4
     // - Actual  : Err:507
-    CPPUNIT_ASSERT_EQUAL(OUString("28/4"), rDoc.GetString(ScAddress(2, 1, 0)));
-    xDocSh->DoClose();
+    CPPUNIT_ASSERT_EQUAL(OUString("28/4"), pDoc->GetString(ScAddress(2, 1, 
0)));
 }
 
 void ScFiltersTest2::testTdf141495()
@@ -2288,162 +2158,146 @@ void ScFiltersTest2::testTdf141495()
         aOptions.Commit();
     });
 
-    ScDocShellRef xDocSh = loadDoc(u"tdf141495.", FORMAT_XLSX);
-    ScDocument& rDoc = xDocSh->GetDocument();
+    createScDoc("xlsx/tdf141495.xlsx");
+    ScDocument* pDoc = getScDoc();
 
-    xDocSh->DoHardRecalc();
+    ScDocShell* pDocSh = getScDocShell();
+    pDocSh->DoHardRecalc();
 
     // Without the fix in place, this test would have failed with
-    // - Expected: 44956
+    // - Expected: 44926
     // - Actual  : #ADDIN?
-    CPPUNIT_ASSERT_EQUAL(OUString("44956"), rDoc.GetString(ScAddress(11, 6, 
0)));
-    xDocSh->DoClose();
+    CPPUNIT_ASSERT_EQUAL(OUString("44926"), pDoc->GetString(ScAddress(11, 6, 
0)));
 }
 
 void ScFiltersTest2::testTdf70455()
 {
-    ScDocShellRef xDocSh = loadDoc(u"tdf70455.", FORMAT_XLSX);
-    ScDocument& rDoc = xDocSh->GetDocument();
+    createScDoc("xlsx/tdf70455.xlsx");
+    ScDocument* pDoc = getScDoc();
 
     // Without the fix in place, this test would have failed with
     // - Expected: €780.00
     // - Actual  : Err:509
-    CPPUNIT_ASSERT_EQUAL(OUString(u"€780.00"), rDoc.GetString(ScAddress(7, 7, 
0)));
-    xDocSh->DoClose();
+    CPPUNIT_ASSERT_EQUAL(OUString(u"€780.00"), pDoc->GetString(ScAddress(7, 7, 
0)));
 }
 
 void ScFiltersTest2::testTdf62268()
 {
-    ScDocShellRef xDocSh = loadDoc(u"tdf62268.", FORMAT_ODS);
-    ScDocument& rDoc = xDocSh->GetDocument();
+    createScDoc("ods/tdf62268.ods");
+    ScDocument* pDoc = getScDoc();
     int nHeight;
 
     SCTAB nTab = 0;
-    nHeight = rDoc.GetRowHeight(0, nTab, false);
+    nHeight = pDoc->GetRowHeight(0, nTab, false);
     CPPUNIT_ASSERT_LESSEQUAL(3, abs(256 - nHeight));
-    nHeight = rDoc.GetRowHeight(1, nTab, false);
+    nHeight = pDoc->GetRowHeight(1, nTab, false);
     CPPUNIT_ASSERT_LESSEQUAL(19, abs(1905 - nHeight));
-
-    xDocSh->DoClose();
 }
 
 void ScFiltersTest2::testTdf137453()
 {
-    ScDocShellRef xDocSh = loadDoc(u"tdf137453.", FORMAT_ODS);
+    createScDoc("ods/tdf137453.ods");
 
-    ScDocument& rDoc = xDocSh->GetDocument();
+    ScDocument* pDoc = getScDoc();
 
     // Without the fix in place, this test would have failed with
     // - Expected: 3333333333/100
     // - Actual  : -961633963/100
-    CPPUNIT_ASSERT_EQUAL(OUString("3333333333/100"), 
rDoc.GetString(ScAddress(0, 0, 0)));
-
-    xDocSh->DoClose();
+    CPPUNIT_ASSERT_EQUAL(OUString("3333333333/100"), 
pDoc->GetString(ScAddress(0, 0, 0)));
 }
 
 void ScFiltersTest2::testTdf112780()
 {
-    ScDocShellRef xDocSh = loadDoc(u"tdf112780.", FORMAT_ODS);
+    createScDoc("ods/tdf112780.ods");
 
-    ScDocument& rDoc = xDocSh->GetDocument();
+    ScDocument* pDoc = getScDoc();
 
     // Without the fix in place, this test would have failed with
     // - Expected:
     // - Actual  : #VALUE!
-    CPPUNIT_ASSERT_EQUAL(OUString(""), rDoc.GetString(ScAddress(3, 5, 0)));
+    CPPUNIT_ASSERT_EQUAL(OUString(""), pDoc->GetString(ScAddress(3, 5, 0)));
 
-    OUString aFormula = rDoc.GetFormula(3, 5, 0);
+    OUString aFormula = pDoc->GetFormula(3, 5, 0);
     CPPUNIT_ASSERT_EQUAL(OUString("=G6+J6+M6"), aFormula);
-
-    xDocSh->DoClose();
 }
 
 void ScFiltersTest2::testTdf72470()
 {
     // Without the fix in place, this test would have hung
 
-    ScDocShellRef xDocSh = loadDoc(u"tdf72470.", FORMAT_XLS);
-
-    ScDocument& rDoc = xDocSh->GetDocument();
+    createScDoc("xls/tdf72470.xls");
 
-    CPPUNIT_ASSERT_EQUAL(OUString("name"), rDoc.GetString(ScAddress(0, 0, 0)));
-    CPPUNIT_ASSERT_EQUAL(OUString(u"أسمي walid"), rDoc.GetString(ScAddress(0, 
1, 0)));
+    ScDocument* pDoc = getScDoc();
 
-    xDocSh->DoClose();
+    CPPUNIT_ASSERT_EQUAL(OUString("name"), pDoc->GetString(ScAddress(0, 0, 
0)));
+    CPPUNIT_ASSERT_EQUAL(OUString(u"أسمي walid"), pDoc->GetString(ScAddress(0, 
1, 0)));
 }
 
 void ScFiltersTest2::testTdf35636()
 {
-    ScDocShellRef xDocSh = loadDoc(u"tdf35636.", FORMAT_ODS);
+    createScDoc("ods/tdf35636.ods");
 
-    ScDocument& rDoc = xDocSh->GetDocument();
+    ScDocument* pDoc = getScDoc();
 
     // Without the fix in place, SUMIF would have returned 0.0
     // with empty cells in the criteria
-    CPPUNIT_ASSERT_EQUAL(50.0, rDoc.GetValue(ScAddress(1, 4, 0)));
-
-    xDocSh->DoClose();
+    CPPUNIT_ASSERT_EQUAL(50.0, pDoc->GetValue(ScAddress(1, 4, 0)));
 }
 
 void ScFiltersTest2::testTdf98481()
 {
-    ScDocShellRef xDocSh = loadDoc(u"tdf98481.", FORMAT_XLSX);
+    createScDoc("xlsx/tdf98481.xlsx");
 
-    ScDocument& rDoc = xDocSh->GetDocument();
+    ScDocument* pDoc = getScDoc();
 
     // Without the fix in place, this test would have failed with
     // - Expected: 4
     // - Actual  : 0
-    CPPUNIT_ASSERT_EQUAL(4.0, rDoc.GetValue(ScAddress(4, 1, 0)));
-    CPPUNIT_ASSERT_EQUAL(0.0, rDoc.GetValue(ScAddress(4, 2, 0)));
-    CPPUNIT_ASSERT_EQUAL(3.0, rDoc.GetValue(ScAddress(4, 3, 0)));
-    CPPUNIT_ASSERT_EQUAL(4.0, rDoc.GetValue(ScAddress(1, 4, 0)));
-    CPPUNIT_ASSERT_EQUAL(0.0, rDoc.GetValue(ScAddress(2, 4, 0)));
-    CPPUNIT_ASSERT_EQUAL(3.0, rDoc.GetValue(ScAddress(3, 4, 0)));
-
-    xDocSh->DoClose();
+    CPPUNIT_ASSERT_EQUAL(4.0, pDoc->GetValue(ScAddress(4, 1, 0)));
+    CPPUNIT_ASSERT_EQUAL(0.0, pDoc->GetValue(ScAddress(4, 2, 0)));
+    CPPUNIT_ASSERT_EQUAL(3.0, pDoc->GetValue(ScAddress(4, 3, 0)));
+    CPPUNIT_ASSERT_EQUAL(4.0, pDoc->GetValue(ScAddress(1, 4, 0)));
+    CPPUNIT_ASSERT_EQUAL(0.0, pDoc->GetValue(ScAddress(2, 4, 0)));
+    CPPUNIT_ASSERT_EQUAL(3.0, pDoc->GetValue(ScAddress(3, 4, 0)));
 }
 
 void ScFiltersTest2::testTdf115022()
 {
-    ScDocShellRef xDocSh = loadDoc(u"tdf115022.", FORMAT_XLSX);
+    createScDoc("xlsx/tdf115022.xlsx");
 
-    ScDocument& rDoc = xDocSh->GetDocument();
+    ScDocument* pDoc = getScDoc();
 
-    CPPUNIT_ASSERT_EQUAL(6.0, rDoc.GetValue(ScAddress(1, 8, 0)));
+    CPPUNIT_ASSERT_EQUAL(6.0, pDoc->GetValue(ScAddress(1, 8, 0)));
 
-    xDocSh->DoHardRecalc();
+    ScDocShell* pDocSh = getScDocShell();
+    pDocSh->DoHardRecalc();
 
     // Without the fix in place, this test would have failed with
     // - Expected: 6
     // - Actual  : 21
-    CPPUNIT_ASSERT_EQUAL(6.0, rDoc.GetValue(ScAddress(1, 8, 0)));
-
-    xDocSh->DoClose();
+    CPPUNIT_ASSERT_EQUAL(6.0, pDoc->GetValue(ScAddress(1, 8, 0)));
 }
 
 void ScFiltersTest2::testVBAMacroFunctionODS()
 {
-    ScDocShellRef xDocSh = loadDoc(u"vba_macro_functions.", FORMAT_ODS);
-    ScDocument& rDoc = xDocSh->GetDocument();
+    createScDoc("ods/vba_macro_functions.ods");
+    ScDocument* pDoc = getScDoc();
 
-    OUString aFunction = rDoc.GetFormula(2, 0, 0);
+    OUString aFunction = pDoc->GetFormula(2, 0, 0);
     std::cout << aFunction << std::endl;
-    CPPUNIT_ASSERT_DOUBLES_EQUAL(10.0, rDoc.GetValue(2, 0, 0), 1e-6);
-
-    xDocSh->DoClose();
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(10.0, pDoc->GetValue(2, 0, 0), 1e-6);
 }
 
 void ScFiltersTest2::testAutoheight2Rows()
 {
-    ScDocShellRef xDocSh = loadDoc(u"autoheight2rows.", FORMAT_ODS);
-    ScDocument& rDoc = xDocSh->GetDocument();
+    createScDoc("ods/autoheight2rows.ods");
+    ScDocument* pDoc = getScDoc();
 
     SCTAB nTab = 0;
-    int nHeight1 = rDoc.GetRowHeight(0, nTab, false);
-    int nHeight2 = rDoc.GetRowHeight(1, nTab, false);
-    int nHeight4 = rDoc.GetRowHeight(3, nTab, false);
-    int nHeight5 = rDoc.GetRowHeight(4, nTab, false);
+    int nHeight1 = pDoc->GetRowHeight(0, nTab, false);
+    int nHeight2 = pDoc->GetRowHeight(1, nTab, false);
+    int nHeight4 = pDoc->GetRowHeight(3, nTab, false);
+    int nHeight5 = pDoc->GetRowHeight(4, nTab, false);
 
     // We will do relative comparison, because calculated autoheight
     // can be different on different platforms

... etc. - the rest is truncated

Reply via email to