sc/qa/unit/filters-test.cxx | 57 +++++++++++++++++++++++++++++++++- sc/qa/unit/subsequent_export_test.cxx | 52 ------------------------------- 2 files changed, 56 insertions(+), 53 deletions(-)
New commits: commit 111ec417d2289b6231216650ccacbb1b7a35268e Author: Xisco Fauli <xiscofa...@libreoffice.org> AuthorDate: Thu Nov 24 17:03:30 2022 +0100 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Thu Nov 24 20:06:48 2022 +0100 sc: fix todo When I change CppunitTest_sc_subsequent_export_test to inherit from UnoApiXmlTest in a865d042eff3cdd4d78badcc55c9d8fdf9ef52aa this test started to fail with * testTdf90299 fails now with - Expected: 'file:///tmp/lu23738863wthph.tmp/dummy.xls'#$Sheet1.A1 - Actual : 'file:///tmp/lu23738863wthph.tmp/lu23738863wthpg.tmp/dummy.xls'#$Sheet1.A1 For now, move it to filters-test.cxx to use the old way to load and save the documents so the test doesn't fail. Change-Id: Ibccbc4a422a7374be7c4b09fbec3985b52b8b140 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143239 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 d7b2197f1a29..c165869a1afb 100644 --- a/sc/qa/unit/filters-test.cxx +++ b/sc/qa/unit/filters-test.cxx @@ -25,9 +25,13 @@ #include <scopetools.hxx> #include <undomanager.hxx> +#include <osl/file.hxx> +#include <sfx2/docfilt.hxx> +#include <sfx2/docfile.hxx> #include <svx/svdpage.hxx> #include <tools/stream.hxx> #include <tools/urlobj.hxx> +#include <unotools/tempfile.hxx> using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -50,12 +54,13 @@ public: void testContentofz9704(); void testTooManyColsRows(); - + void testTdf90299(); CPPUNIT_TEST_SUITE(ScFiltersTest); CPPUNIT_TEST(testCVEs); CPPUNIT_TEST(testContentofz9704); CPPUNIT_TEST(testTooManyColsRows); + CPPUNIT_TEST(testTdf90299); CPPUNIT_TEST_SUITE_END(); @@ -151,6 +156,56 @@ void ScFiltersTest::testTooManyColsRows() xDocSh->DoClose(); } +void ScFiltersTest::testTdf90299() +{ + const OUString aTmpDirectory1URL = utl::CreateTempURL(nullptr, true); + const OUString aTmpDirectory2URL = utl::CreateTempURL(nullptr, true); + const OUString aSavedFileURL = utl::CreateTempURL(&aTmpDirectory1URL); + + OUString aReferencedFileURL; + OUString aReferencingFileURL; + createFileURL(u"tdf90299.", u"xls", aReferencingFileURL); + + auto eError = osl::File::copy(aReferencingFileURL, aTmpDirectory1URL + "/tdf90299.xls"); + CPPUNIT_ASSERT_EQUAL(osl::File::E_None, eError); + + aReferencingFileURL = aTmpDirectory1URL + "/tdf90299.xls"; + aReferencedFileURL = aTmpDirectory1URL + "/dummy.xls"; + + ScDocShellRef xShell = loadDoc(aReferencingFileURL, "MS Excel 97", OUString(), OUString(), + XLS_FORMAT_TYPE, SotClipboardFormatId::STARCALC_8); + + ScDocument& rDoc = xShell->GetDocument(); + CPPUNIT_ASSERT_EQUAL(OUString("='" + aReferencedFileURL + "'#$Sheet1.A1"), rDoc.GetFormula(0, 0, 0)); + + aReferencingFileURL = aSavedFileURL; + + SfxMedium aStoreMedium(aReferencingFileURL, StreamMode::STD_WRITE); + + auto pExportFilter = std::make_shared<SfxFilter>( + "MS Excel 97", OUString(), XLS_FORMAT_TYPE, SotClipboardFormatId::NONE, OUString(), + OUString(), OUString(), "private:factory/scalc*"); + pExportFilter->SetVersion(SOFFICE_FILEFORMAT_CURRENT); + + aStoreMedium.SetFilter(pExportFilter); + + xShell->DoSaveAs(aStoreMedium); + xShell->DoClose(); + + eError = osl::File::copy(aReferencingFileURL, aTmpDirectory2URL + "/tdf90299.xls"); + CPPUNIT_ASSERT_EQUAL(osl::File::E_None, eError); + + aReferencingFileURL = aTmpDirectory2URL + "/tdf90299.xls"; + aReferencedFileURL = aTmpDirectory2URL + "/dummy.xls"; + + xShell = loadDoc(aReferencingFileURL, "MS Excel 97", OUString(), OUString(), + XLS_FORMAT_TYPE, SotClipboardFormatId::STARCALC_8); + ScDocument& rDoc2 = xShell->GetDocument(); + CPPUNIT_ASSERT_EQUAL(OUString("='" + aReferencedFileURL + "'#$Sheet1.A1"), rDoc2.GetFormula(0, 0, 0)); + + xShell->DoClose(); +} + ScFiltersTest::ScFiltersTest() : ScFilterTestBase() { diff --git a/sc/qa/unit/subsequent_export_test.cxx b/sc/qa/unit/subsequent_export_test.cxx index 64ed8639c1aa..f455f90b6ee5 100644 --- a/sc/qa/unit/subsequent_export_test.cxx +++ b/sc/qa/unit/subsequent_export_test.cxx @@ -188,7 +188,6 @@ public: void testPreserveTextWhitespace2XLSX(); void testTdf113646(); void testDateStandardfilterXLSX(); - void testTdf90299(); CPPUNIT_TEST_SUITE(ScExportTest); CPPUNIT_TEST(test); @@ -296,7 +295,6 @@ public: CPPUNIT_TEST(testMoveCellAnchoredShapesODS); CPPUNIT_TEST(testTdf113646); CPPUNIT_TEST(testDateStandardfilterXLSX); - CPPUNIT_TEST(testTdf90299); CPPUNIT_TEST_SUITE_END(); private: @@ -4307,56 +4305,6 @@ void ScExportTest::testDateStandardfilterXLSX() "dateTimeGrouping", "day"); } -void ScExportTest::testTdf90299() -{ - const OUString aTmpDirectory1URL = utl::CreateTempURL(nullptr, true); - const OUString aTmpDirectory2URL = utl::CreateTempURL(nullptr, true); - - struct - { - void checkFormula(ScDocShell& rDocSh, OUString aExpectedFormula) - { - rDocSh.ReloadAllLinks(); - - ScDocument& rDoc = rDocSh.GetDocument(); - - ScAddress aPos(0, 0, 0); - ScTokenArray* pCode = getTokens(rDoc, aPos); - CPPUNIT_ASSERT_MESSAGE("empty token array", pCode); - - OUString aFormula = toString(rDoc, aPos, *pCode, rDoc.GetGrammar()); - - CPPUNIT_ASSERT_EQUAL(aExpectedFormula, aFormula); - } - - } aCheckShell; - - OUString aReferencingFileURL = aTmpDirectory1URL + "/tdf90299.xls"; - OUString aReferencedFileURL = aTmpDirectory1URL + "/dummy.xls"; - - auto eError = osl::File::copy(createFileURL(u"xls/tdf90299.xls"), aReferencingFileURL); - CPPUNIT_ASSERT_EQUAL(osl::File::E_None, eError); - - load(aReferencingFileURL); - ScDocShell* pDocSh = getScDocShell(); - aCheckShell.checkFormula(*pDocSh, "'" + aReferencedFileURL + "'#$Sheet1.A1"); - - save("MS Excel 97"); - - OUString aReferencingFileURL2 = aTmpDirectory2URL + "/tdf90299.xls"; - - eError = osl::File::copy(maTempFile.GetURL(), aReferencingFileURL2); - CPPUNIT_ASSERT_EQUAL(osl::File::E_None, eError); - - load(aReferencingFileURL2); - pDocSh = getScDocShell(); - - /* TODO: xisco - OUString aReferencedFileURL2 = aTmpDirectory2URL + "/dummy.xls"; - aCheckShell.checkFormula(*pDocSh, "'" + aReferencedFileURL2 + "'#$Sheet1.A1"); - */ -} - CPPUNIT_TEST_SUITE_REGISTRATION(ScExportTest); CPPUNIT_PLUGIN_IMPLEMENT();