tdf#134332, tdf#134796: sc_subsequent_export_test: Add unittest

Change-Id: I4b67937dbec76c32c61a85ed24ca67bfcf3f83a8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98743
Tested-by: Luboš Luňák <l.lunak@collabora.com>
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
(cherry picked from commit c60ce3d48dbccd616cfa989ca3d8f1ded4ccd411)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98844
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
diff --git a/sc/qa/unit/data/ods/tdf134332.ods b/sc/qa/unit/data/ods/tdf134332.ods
new file mode 100644
index 0000000..2046093
--- /dev/null
+++ b/sc/qa/unit/data/ods/tdf134332.ods
Binary files differ
diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx
index 6d4830a..096c95e 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -94,6 +94,7 @@ public:
    void test();
    void testTdf111876();
    void testPasswordExportODS();
    void testTdf134332();
    void testConditionalFormatExportODS();
    void testConditionalFormatExportXLSX();
    void testCondFormatExportCellIs();
@@ -253,6 +254,7 @@ public:
    CPPUNIT_TEST(test);
    CPPUNIT_TEST(testTdf111876);
    CPPUNIT_TEST(testPasswordExportODS);
    CPPUNIT_TEST(testTdf134332);
    CPPUNIT_TEST(testConditionalFormatExportODS);
    CPPUNIT_TEST(testCondFormatExportCellIs);
    CPPUNIT_TEST(testConditionalFormatExportXLSX);
@@ -540,6 +542,33 @@ void ScExportTest::testPasswordExportODS()
    xDocSh->DoClose();
}

void ScExportTest::testTdf134332()
{
    ScDocShellRef xShell = loadDoc("tdf134332.", FORMAT_ODS);
    CPPUNIT_ASSERT(xShell.is());

    ScDocument& rDoc = xShell->GetDocument();

    ASSERT_DOUBLES_EQUAL(190.0, rDoc.GetValue(ScAddress(0,0,0)));

    ASSERT_DOUBLES_EQUAL(238.0, rDoc.GetValue(ScAddress(0,10144,0)));

    sal_Int32 nFormat = FORMAT_ODS;
    OUString aFilterName(getFileFormats()[nFormat].pFilterName, strlen(getFileFormats()[nFormat].pFilterName), RTL_TEXTENCODING_UTF8) ;
    OUString aFilterType(getFileFormats()[nFormat].pTypeName, strlen(getFileFormats()[nFormat].pTypeName), RTL_TEXTENCODING_UTF8);
    ScDocShellRef xDocSh = saveAndReloadPassword(static_cast<ScDocShell*>(rDoc.GetDocumentShell()), aFilterName, OUString(),
            aFilterType, getFileFormats()[nFormat].nFormatType);

    // Without the fixes in place, it would have failed here
    CPPUNIT_ASSERT(xDocSh.is());
    ScDocument& rLoadedDoc = xDocSh->GetDocument();
    ASSERT_DOUBLES_EQUAL(190.0, rLoadedDoc.GetValue(ScAddress(0,0,0)));

    ASSERT_DOUBLES_EQUAL(238.0, rLoadedDoc.GetValue(ScAddress(0,10144,0)));

    xDocSh->DoClose();
}

void ScExportTest::testConditionalFormatExportODS()
{
    ScDocShellRef xShell = loadDoc("new_cond_format_test_export.", FORMAT_ODS);