diff --git a/include/test/unoapi_test.hxx b/include/test/unoapi_test.hxx index 577c2d62ece7..d5b8d2145d99 100644 --- a/include/test/unoapi_test.hxx +++ b/include/test/unoapi_test.hxx @@ -38,7 +38,7 @@ public: utl::TempFileNamed save(const OUString& rFilter); utl::TempFileNamed saveAndClose(const OUString& rFilter); - void saveAndReload(const OUString& rFilter); + utl::TempFileNamed saveAndReload(const OUString& rFilter); protected: // reference to document component that we are testing diff --git a/sc/CppunitTest_sc_jumbosheets_test.mk b/sc/CppunitTest_sc_jumbosheets_test.mk index 867589c4fa60..554d3152cbc3 100644 --- a/sc/CppunitTest_sc_jumbosheets_test.mk +++ b/sc/CppunitTest_sc_jumbosheets_test.mk @@ -32,10 +32,12 @@ $(eval $(call gb_CppunitTest_use_libraries,sc_jumbosheets_test, \ sc \ scqahelper \ sfx \ + subsequenttest \ svxcore \ test \ tl \ unotest \ + utl \ vcl \ )) diff --git a/sc/qa/unit/helper/qahelper.cxx b/sc/qa/unit/helper/qahelper.cxx index 40cc56859c4f..be0fe4d2bcf6 100644 --- a/sc/qa/unit/helper/qahelper.cxx +++ b/sc/qa/unit/helper/qahelper.cxx @@ -827,17 +827,6 @@ ScDocShellRef ScBootstrapFixture::saveAndReloadPassword( ScDocShell& rShell, sal return xDocSh; } -ScDocShellRef ScBootstrapFixture::saveAndReloadNoClose( ScDocShell& rShell, sal_Int32 nFormat, std::shared_ptr* pTempFile ) -{ - OUString aFilterName(aFileFormats[nFormat].pFilterName, strlen(aFileFormats[nFormat].pFilterName), RTL_TEXTENCODING_UTF8) ; - OUString aFilterType(aFileFormats[nFormat].pTypeName, strlen(aFileFormats[nFormat].pTypeName), RTL_TEXTENCODING_UTF8); - - ScDocShellRef xDocSh = saveAndReload(rShell, aFilterName, OUString(), aFilterType, aFileFormats[nFormat].nFormatType, pTempFile, nullptr, false); - - CPPUNIT_ASSERT(xDocSh.is()); - return xDocSh; -} - std::shared_ptr ScBootstrapFixture::exportTo( ScDocShell& rShell, sal_Int32 nFormat, bool bValidate ) { OUString aFilterName(aFileFormats[nFormat].pFilterName, strlen(aFileFormats[nFormat].pFilterName), RTL_TEXTENCODING_UTF8) ; diff --git a/sc/qa/unit/helper/qahelper.hxx b/sc/qa/unit/helper/qahelper.hxx index b3541d9c0c5f..32447f716c02 100644 --- a/sc/qa/unit/helper/qahelper.hxx +++ b/sc/qa/unit/helper/qahelper.hxx @@ -226,7 +226,6 @@ public: ScDocShellRef saveAndReload( ScDocShell& rShell, sal_Int32 nFormat, std::shared_ptr* pTempFile = nullptr ); ScDocShellRef saveAndReloadPassword( ScDocShell& rShell, sal_Int32 nFormat, std::shared_ptr* pTempFile = nullptr ); - ScDocShellRef saveAndReloadNoClose( ScDocShell& rShell, sal_Int32 nFormat, std::shared_ptr* pTempFile = nullptr ); std::shared_ptr exportTo(ScDocShell& rShell, sal_Int32 nFormat, bool bValidate = true); diff --git a/sc/qa/unit/jumbosheets-test.cxx b/sc/qa/unit/jumbosheets-test.cxx index 388967e9c43c..1cf820895ed5 100644 --- a/sc/qa/unit/jumbosheets-test.cxx +++ b/sc/qa/unit/jumbosheets-test.cxx @@ -8,8 +8,7 @@ */ #include -#include -#include +#include #include #include #include @@ -19,13 +18,14 @@ #include #include +#include #include #include #include #include #include +#include -#include "helper/qahelper.hxx" #include "helper/xpath.hxx" using namespace ::com::sun::star; @@ -33,7 +33,7 @@ using namespace ::com::sun::star::uno; /* Tests for sheets larger than 1024 columns and/or 1048576 rows. */ -class ScJumboSheetsTest : public unotest::MacrosTest, public ScBootstrapFixture, public XmlTestTools +class ScJumboSheetsTest : public UnoApiTest, public XmlTestTools { public: ScJumboSheetsTest(); @@ -43,8 +43,10 @@ public: void testRoundtripColumn2000Ods(); void testRoundtripColumn2000Xlsx(); - void testRoundtripColumnRange(); - void testRoundtripNamedRanges(); + void testRoundtripColumnRangeOds(); + void testRoundtripColumnRangeXlsx(); + void testRoundtripNamedRangesOds(); + void testRoundtripNamedRangesXlsx(); void testNamedRangeNameConflict(); void testTdf134553(); void testTdf134392(); @@ -56,8 +58,10 @@ public: CPPUNIT_TEST(testRoundtripColumn2000Ods); CPPUNIT_TEST(testRoundtripColumn2000Xlsx); - CPPUNIT_TEST(testRoundtripColumnRange); - CPPUNIT_TEST(testRoundtripNamedRanges); + CPPUNIT_TEST(testRoundtripColumnRangeOds); + CPPUNIT_TEST(testRoundtripColumnRangeXlsx); + CPPUNIT_TEST(testRoundtripNamedRangesOds); + CPPUNIT_TEST(testRoundtripNamedRangesXlsx); CPPUNIT_TEST(testNamedRangeNameConflict); CPPUNIT_TEST(testTdf134553); CPPUNIT_TEST(testTdf134392); @@ -71,104 +75,108 @@ protected: virtual void registerNamespaces(xmlXPathContextPtr& pXmlXPathCtx) override; private: - void testRoundtripColumn2000(std::u16string_view name, int format); + void testRoundtripColumn2000(std::u16string_view name, const char* format); + void testRoundtripNamedRanges(std::u16string_view name, const char* format); }; void ScJumboSheetsTest::testRoundtripColumn2000Ods() { - testRoundtripColumn2000(u"value-in-column-2000.", FORMAT_ODS); + testRoundtripColumn2000(u"ods/value-in-column-2000.ods", "calc8"); } void ScJumboSheetsTest::testRoundtripColumn2000Xlsx() { - testRoundtripColumn2000(u"value-in-column-2000.", FORMAT_XLSX); + testRoundtripColumn2000(u"xlsx/value-in-column-2000.xlsx", "Calc Office Open XML"); } -void ScJumboSheetsTest::testRoundtripColumn2000(std::u16string_view name, int format) +void ScJumboSheetsTest::testRoundtripColumn2000(std::u16string_view name, const char* format) { - ScDocShellRef xDocSh1 = loadDoc(name, format); - + loadFromURL(name); { - ScDocument& rDoc = xDocSh1->GetDocument(); + ScModelObj* pModelObj = dynamic_cast(mxComponent.get()); + CPPUNIT_ASSERT(pModelObj); + ScDocument* pDoc = pModelObj->GetDocument(); // Check the value at BXX1 (2000th column). - CPPUNIT_ASSERT_EQUAL(-5.0, rDoc.GetValue(1999, 0, 0)); + CPPUNIT_ASSERT_EQUAL(-5.0, pDoc->GetValue(1999, 0, 0)); // Check the formula referencing the value. - CPPUNIT_ASSERT_EQUAL(OUString("=BXX1"), rDoc.GetFormula(0, 0, 0)); + CPPUNIT_ASSERT_EQUAL(OUString("=BXX1"), pDoc->GetFormula(0, 0, 0)); // Recalc and check value in the reference. - rDoc.CalcAll(); - CPPUNIT_ASSERT_EQUAL(-5.0, rDoc.GetValue(0, 0, 0)); + pDoc->CalcAll(); + CPPUNIT_ASSERT_EQUAL(-5.0, pDoc->GetValue(0, 0, 0)); } - ScDocShellRef xDocSh2 = saveAndReload(*xDocSh1, format); - CPPUNIT_ASSERT(xDocSh2.is()); - + saveAndReload(OUString::createFromAscii(format)); { - // Check again. - ScDocument& rDoc = xDocSh2->GetDocument(); - CPPUNIT_ASSERT_EQUAL(-5.0, rDoc.GetValue(1999, 0, 0)); - CPPUNIT_ASSERT_EQUAL(OUString("=BXX1"), rDoc.GetFormula(0, 0, 0)); - rDoc.CalcAll(); - CPPUNIT_ASSERT_EQUAL(-5.0, rDoc.GetValue(0, 0, 0)); - } + ScModelObj* pModelObj = dynamic_cast(mxComponent.get()); + CPPUNIT_ASSERT(pModelObj); - xDocSh1->DoClose(); - xDocSh2->DoClose(); + ScDocument* pDoc = pModelObj->GetDocument(); + // Check again. + CPPUNIT_ASSERT_EQUAL(-5.0, pDoc->GetValue(1999, 0, 0)); + CPPUNIT_ASSERT_EQUAL(OUString("=BXX1"), pDoc->GetFormula(0, 0, 0)); + pDoc->CalcAll(); + CPPUNIT_ASSERT_EQUAL(-5.0, pDoc->GetValue(0, 0, 0)); + } } -void ScJumboSheetsTest::testRoundtripColumnRange() +void ScJumboSheetsTest::testRoundtripColumnRangeOds() { - ScDocShellRef xDocSh1 = loadDoc(u"sum-whole-column-row.", FORMAT_ODS); - + loadFromURL(u"ods/sum-whole-column-row.ods"); { - ScDocument& rDoc = xDocSh1->GetDocument(); + ScModelObj* pModelObj = dynamic_cast(mxComponent.get()); + CPPUNIT_ASSERT(pModelObj); + ScDocument* pDoc = pModelObj->GetDocument(); // Check the formula referencing the whole-row range. - CPPUNIT_ASSERT_EQUAL(OUString("=SUM(2:2)"), rDoc.GetFormula(0, 0, 0)); + CPPUNIT_ASSERT_EQUAL(OUString("=SUM(2:2)"), pDoc->GetFormula(0, 0, 0)); // Check the formula referencing the whole-column range. - CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C:C)"), rDoc.GetFormula(1, 0, 0)); + CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C:C)"), pDoc->GetFormula(1, 0, 0)); } - std::shared_ptr exportedFile; - ScDocShellRef xDocSh2 = saveAndReloadNoClose(*xDocSh1, FORMAT_ODS, &exportedFile); - CPPUNIT_ASSERT(xDocSh2.is()); - + auto pExportedFile = std::make_shared(saveAndReload("calc8")); { - ScDocument& rDoc = xDocSh2->GetDocument(); - CPPUNIT_ASSERT_EQUAL(OUString("=SUM(2:2)"), rDoc.GetFormula(0, 0, 0)); - CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C:C)"), rDoc.GetFormula(1, 0, 0)); - xmlDocUniquePtr pDoc = XPathHelper::parseExport(exportedFile, m_xSFactory, "content.xml"); - CPPUNIT_ASSERT(pDoc); - assertXPath(pDoc, + ScModelObj* pModelObj = dynamic_cast(mxComponent.get()); + CPPUNIT_ASSERT(pModelObj); + + ScDocument* pDoc = pModelObj->GetDocument(); + CPPUNIT_ASSERT_EQUAL(OUString("=SUM(2:2)"), pDoc->GetFormula(0, 0, 0)); + CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C:C)"), pDoc->GetFormula(1, 0, 0)); + xmlDocUniquePtr pXmlDoc + = XPathHelper::parseExport(pExportedFile, m_xSFactory, "content.xml"); + CPPUNIT_ASSERT(pXmlDoc); + assertXPath(pXmlDoc, "/office:document-content/office:body/office:spreadsheet/table:table/" "table:table-row[1]/table:table-cell[1]", "formula", "of:=SUM([.2:.2])"); - assertXPath(pDoc, + assertXPath(pXmlDoc, "/office:document-content/office:body/office:spreadsheet/table:table/" "table:table-row[1]/table:table-cell[2]", "formula", "of:=SUM([.C:.C])"); } - - ScDocShellRef xDocSh3 = saveAndReloadNoClose(*xDocSh1, FORMAT_XLSX, &exportedFile); - CPPUNIT_ASSERT(xDocSh3.is()); - - { - ScDocument& rDoc = xDocSh3->GetDocument(); - CPPUNIT_ASSERT_EQUAL(OUString("=SUM(2:2)"), rDoc.GetFormula(0, 0, 0)); - CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C:C)"), rDoc.GetFormula(1, 0, 0)); - xmlDocUniquePtr pDoc - = XPathHelper::parseExport(exportedFile, m_xSFactory, "xl/worksheets/sheet1.xml"); - CPPUNIT_ASSERT(pDoc); - assertXPathContent(pDoc, "/x:worksheet/x:sheetData/x:row[1]/x:c[1]/x:f", "SUM(2:2)"); - assertXPathContent(pDoc, "/x:worksheet/x:sheetData/x:row[1]/x:c[2]/x:f", "SUM(C:C)"); - } - - xDocSh1->DoClose(); - xDocSh2->DoClose(); - xDocSh3->DoClose(); } -void ScJumboSheetsTest::testRoundtripNamedRanges() +void ScJumboSheetsTest::testRoundtripColumnRangeXlsx() { - ScDocShellRef xDocSh1 = loadDoc(u"ranges-column-2000.", FORMAT_ODS); + loadFromURL(u"ods/sum-whole-column-row.ods"); + auto pExportedFile + = std::make_shared(saveAndReload("Calc Office Open XML")); + { + ScModelObj* pModelObj = dynamic_cast(mxComponent.get()); + CPPUNIT_ASSERT(pModelObj); + + ScDocument* pDoc = pModelObj->GetDocument(); + CPPUNIT_ASSERT_EQUAL(OUString("=SUM(2:2)"), pDoc->GetFormula(0, 0, 0)); + CPPUNIT_ASSERT_EQUAL(OUString("=SUM(C:C)"), pDoc->GetFormula(1, 0, 0)); + xmlDocUniquePtr pXmlDoc + = XPathHelper::parseExport(pExportedFile, m_xSFactory, "xl/worksheets/sheet1.xml"); + CPPUNIT_ASSERT(pXmlDoc); + assertXPathContent(pXmlDoc, "/x:worksheet/x:sheetData/x:row[1]/x:c[1]/x:f", "SUM(2:2)"); + assertXPathContent(pXmlDoc, "/x:worksheet/x:sheetData/x:row[1]/x:c[2]/x:f", "SUM(C:C)"); + } +} + +void ScJumboSheetsTest::testRoundtripNamedRanges(std::u16string_view name, const char* format) +{ + loadFromURL(name); std::pair ranges[] = { { "CELLBXX1", "$Sheet1.$BXX$1" }, { "CELLSA4_AMJ4", "$Sheet1.$A$4:$AMJ$4" }, @@ -179,77 +187,76 @@ void ScJumboSheetsTest::testRoundtripNamedRanges() { "COLUMN_E", "$Sheet1.$E:$E" }, { "ROW_4", "$Sheet1.$4:$4" } }; { - ScDocument& rDoc = xDocSh1->GetDocument(); + ScModelObj* pModelObj = dynamic_cast(mxComponent.get()); + CPPUNIT_ASSERT(pModelObj); + ScDocument* pDoc = pModelObj->GetDocument(); for (const auto& range : ranges) { - ScRangeData* rangeData = rDoc.GetRangeName()->findByUpperName(range.first); + ScRangeData* rangeData = pDoc->GetRangeName()->findByUpperName(range.first); CPPUNIT_ASSERT(rangeData); CPPUNIT_ASSERT_EQUAL(range.second, rangeData->GetSymbol()); } } - std::shared_ptr exportedFile; - ScDocShellRef xDocSh2 = saveAndReloadNoClose(*xDocSh1, FORMAT_ODS, &exportedFile); - CPPUNIT_ASSERT(xDocSh2.is()); - + saveAndReload(OUString::createFromAscii(format)); { - ScDocument& rDoc = xDocSh2->GetDocument(); + ScModelObj* pModelObj = dynamic_cast(mxComponent.get()); + CPPUNIT_ASSERT(pModelObj); + ScDocument* pDoc = pModelObj->GetDocument(); for (const auto& range : ranges) { - ScRangeData* rangeData = rDoc.GetRangeName()->findByUpperName(range.first); + ScRangeData* rangeData = pDoc->GetRangeName()->findByUpperName(range.first); CPPUNIT_ASSERT(rangeData); CPPUNIT_ASSERT_EQUAL(range.second, rangeData->GetSymbol()); } } +} - ScDocShellRef xDocSh3 = saveAndReloadNoClose(*xDocSh1, FORMAT_XLSX, &exportedFile); - CPPUNIT_ASSERT(xDocSh3.is()); +void ScJumboSheetsTest::testRoundtripNamedRangesOds() +{ + testRoundtripNamedRanges(u"ods/ranges-column-2000.ods", "calc8"); +} - { - ScDocument& rDoc = xDocSh3->GetDocument(); - for (const auto& range : ranges) - { - ScRangeData* rangeData = rDoc.GetRangeName()->findByUpperName(range.first); - CPPUNIT_ASSERT(rangeData); - CPPUNIT_ASSERT_EQUAL(range.second, rangeData->GetSymbol()); - } - } - - xDocSh1->DoClose(); - xDocSh2->DoClose(); - xDocSh3->DoClose(); +void ScJumboSheetsTest::testRoundtripNamedRangesXlsx() +{ + testRoundtripNamedRanges(u"ods/ranges-column-2000.ods", "Calc Office Open XML"); } void ScJumboSheetsTest::testNamedRangeNameConflict() { // The document contains named ranges named 'num1' and 'num2', that should be still treated // as named references even though with 16k columns those are normally NUM1 and NUM2 cells. - ScDocShellRef xDocSh = loadDoc(u"named-range-conflict.", FORMAT_ODS); - ScDocument& rDoc = xDocSh->GetDocument(); - rDoc.CalcAll(); - CPPUNIT_ASSERT_EQUAL(0.0, rDoc.GetValue(10022, 0, 0)); // NUM1 - CPPUNIT_ASSERT_EQUAL(0.0, rDoc.GetValue(10022, 1, 0)); // NUM2 - CPPUNIT_ASSERT_EQUAL(2.0, rDoc.GetValue(0, 0, 0)); // = num1 - CPPUNIT_ASSERT_EQUAL(3.0, rDoc.GetValue(0, 1, 0)); // = sheet2.num2 - CPPUNIT_ASSERT_EQUAL(0.0, rDoc.GetValue(0, 2, 0)); // = SUM(NUM1:NUM2) (not named ranges) - rDoc.SetValue(10022, 0, 0, 100); // NUM1 - rDoc.SetValue(10022, 1, 0, 200); // NUM2 - rDoc.CalcAll(); - // First two are the same, the sum changes. - CPPUNIT_ASSERT_EQUAL(2.0, rDoc.GetValue(0, 0, 0)); - CPPUNIT_ASSERT_EQUAL(3.0, rDoc.GetValue(0, 1, 0)); - CPPUNIT_ASSERT_EQUAL(300.0, rDoc.GetValue(0, 2, 0)); + loadFromURL(u"ods/named-range-conflict.ods"); - xDocSh->DoClose(); + ScModelObj* pModelObj = dynamic_cast(mxComponent.get()); + CPPUNIT_ASSERT(pModelObj); + ScDocument* pDoc = pModelObj->GetDocument(); + pDoc->CalcAll(); + CPPUNIT_ASSERT_EQUAL(0.0, pDoc->GetValue(10022, 0, 0)); // NUM1 + CPPUNIT_ASSERT_EQUAL(0.0, pDoc->GetValue(10022, 1, 0)); // NUM2 + CPPUNIT_ASSERT_EQUAL(2.0, pDoc->GetValue(0, 0, 0)); // = num1 + CPPUNIT_ASSERT_EQUAL(3.0, pDoc->GetValue(0, 1, 0)); // = sheet2.num2 + CPPUNIT_ASSERT_EQUAL(0.0, pDoc->GetValue(0, 2, 0)); // = SUM(NUM1:NUM2) (not named ranges) + pDoc->SetValue(10022, 0, 0, 100); // NUM1 + pDoc->SetValue(10022, 1, 0, 200); // NUM2 + pDoc->CalcAll(); + // First two are the same, the sum changes. + CPPUNIT_ASSERT_EQUAL(2.0, pDoc->GetValue(0, 0, 0)); + CPPUNIT_ASSERT_EQUAL(3.0, pDoc->GetValue(0, 1, 0)); + CPPUNIT_ASSERT_EQUAL(300.0, pDoc->GetValue(0, 2, 0)); } void ScJumboSheetsTest::testTdf134553() { - ScDocShellRef xDocSh = loadDocAndSetupModelViewController(u"tdf134553.", FORMAT_XLSX); + loadFromURL(u"xlsx/tdf134553.xlsx"); - ScDocument& rDoc = xDocSh->GetDocument(); + ScModelObj* pModelObj = dynamic_cast(mxComponent.get()); + CPPUNIT_ASSERT(pModelObj); + ScDocument* pDoc = pModelObj->GetDocument(); - const SdrOle2Obj* pOleObj = getSingleChartObject(rDoc, 0); + ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer(); + const SdrPage* pPage = pDrawLayer->GetPage(0); + const SdrObject* pOleObj = pPage->GetObj(0); // Without the fix in place, this test would have failed here CPPUNIT_ASSERT(pOleObj); @@ -267,125 +274,106 @@ void ScJumboSheetsTest::testTdf134553() CPPUNIT_ASSERT_EQUAL(tools::Long(4574), pOleObj->GetLogicRect().getX()); CPPUNIT_ASSERT_EQUAL(tools::Long(437), pOleObj->GetLogicRect().getY()); - ScTabViewShell* pViewShell = xDocSh->GetBestViewShell(false); - CPPUNIT_ASSERT(pViewShell); - + ScTabViewShell* pViewShell = ScDocShell::GetViewData()->GetViewShell(); pViewShell->SelectObject(u"Diagram 1"); - uno::Reference xComponent = xDocSh->GetModel(); - dispatchCommand(xComponent, ".uno:Cut", {}); + dispatchCommand(mxComponent, ".uno:Cut", {}); Scheduler::ProcessEventsToIdle(); - ScDrawLayer* pDrawLayer = rDoc.GetDrawLayer(); - const SdrPage* pPage = pDrawLayer->GetPage(0); CPPUNIT_ASSERT_EQUAL(static_cast(0), pPage->GetObjCount()); - dispatchCommand(xComponent, ".uno:Paste", {}); + dispatchCommand(mxComponent, ".uno:Paste", {}); Scheduler::ProcessEventsToIdle(); - pOleObj = getSingleChartObject(rDoc, 0); + pOleObj = pPage->GetObj(0); CPPUNIT_ASSERT(pOleObj); CPPUNIT_ASSERT_EQUAL(tools::Long(12741), pOleObj->GetLogicRect().getOpenWidth()); CPPUNIT_ASSERT_EQUAL(tools::Long(7620), pOleObj->GetLogicRect().getOpenHeight()); - CPPUNIT_ASSERT_EQUAL(tools::Long(5097), pOleObj->GetLogicRect().getX()); + CPPUNIT_ASSERT_EQUAL(tools::Long(1700), pOleObj->GetLogicRect().getX()); // tdf#147458: Without the fix in place, this test would have failed with - // - Expected: 1058 + // - Expected: 2117 // - Actual : -7421 - CPPUNIT_ASSERT_EQUAL(tools::Long(1058), pOleObj->GetLogicRect().getY()); - - xDocSh->DoClose(); + CPPUNIT_ASSERT_EQUAL(tools::Long(2117), pOleObj->GetLogicRect().getY()); } void ScJumboSheetsTest::testTdf134392() { // Without the fix in place, the file would have crashed - ScDocShellRef xDocSh = loadDoc(u"tdf134392.", FORMAT_XLSX); + loadFromURL(u"xlsx/tdf134392.xlsx"); - ScDocument& rDoc = xDocSh->GetDocument(); - rDoc.CalcAll(); // perform hard re-calculation. - xDocSh->DoClose(); + ScModelObj* pModelObj = dynamic_cast(mxComponent.get()); + CPPUNIT_ASSERT(pModelObj); + ScDocument* pDoc = pModelObj->GetDocument(); + pDoc->CalcAll(); // perform hard re-calculation. } void ScJumboSheetsTest::testTdf147509() { - ScDocShellRef xDocSh = loadEmptyDocument(); - CPPUNIT_ASSERT(xDocSh); + mxComponent = loadFromDesktop("private:factory/scalc"); + ScModelObj* pModelObj = dynamic_cast(mxComponent.get()); + CPPUNIT_ASSERT(pModelObj); - ScDocument& rDoc = xDocSh->GetDocument(); + ScDocument* pDoc = pModelObj->GetDocument(); - rDoc.SetString(0, 0, 0, "A"); - rDoc.SetString(1, 0, 0, "B"); + pDoc->SetString(0, 0, 0, "A"); + pDoc->SetString(1, 0, 0, "B"); - ScTabViewShell* pViewShell = xDocSh->GetBestViewShell(false); - CPPUNIT_ASSERT(pViewShell); - ScViewData& rViewData = pViewShell->GetViewData(); + CPPUNIT_ASSERT_EQUAL(sal_Int16(0), ScDocShell::GetViewData()->GetCurX()); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), ScDocShell::GetViewData()->GetCurY()); - CPPUNIT_ASSERT_EQUAL(sal_Int16(0), rViewData.GetCurX()); - CPPUNIT_ASSERT_EQUAL(sal_Int32(0), rViewData.GetCurY()); - - uno::Reference xComponent = xDocSh->GetModel(); - dispatchCommand(xComponent, ".uno:SelectColumn", {}); + dispatchCommand(mxComponent, ".uno:SelectColumn", {}); Scheduler::ProcessEventsToIdle(); - dispatchCommand(xComponent, ".uno:InsertColumnsAfter", {}); + dispatchCommand(mxComponent, ".uno:InsertColumnsAfter", {}); Scheduler::ProcessEventsToIdle(); - CPPUNIT_ASSERT_EQUAL(OUString("A"), rDoc.GetString(ScAddress(0, 0, 0))); + CPPUNIT_ASSERT_EQUAL(OUString("A"), pDoc->GetString(ScAddress(0, 0, 0))); // Without the fix in place, this test would have failed with // - Expected: // - Actual : B - CPPUNIT_ASSERT_EQUAL(OUString(""), rDoc.GetString(ScAddress(1, 0, 0))); - CPPUNIT_ASSERT_EQUAL(OUString("B"), rDoc.GetString(ScAddress(2, 0, 0))); - - xDocSh->DoClose(); + CPPUNIT_ASSERT_EQUAL(OUString(""), pDoc->GetString(ScAddress(1, 0, 0))); + CPPUNIT_ASSERT_EQUAL(OUString("B"), pDoc->GetString(ScAddress(2, 0, 0))); } void ScJumboSheetsTest::testTdf133033() { - ScDocShellRef xDocSh = loadEmptyDocument(); - CPPUNIT_ASSERT(xDocSh); - - ScTabViewShell* pViewShell = xDocSh->GetBestViewShell(false); - CPPUNIT_ASSERT(pViewShell); - - uno::Reference xComponent = xDocSh->GetModel(); - ScModelObj* pModelObj = dynamic_cast(xComponent.get()); + mxComponent = loadFromDesktop("private:factory/scalc"); + ScModelObj* pModelObj = dynamic_cast(mxComponent.get()); CPPUNIT_ASSERT(pModelObj); pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_DOWN | KEY_MOD1); Scheduler::ProcessEventsToIdle(); - ScViewData& rViewData = pViewShell->GetViewData(); - - CPPUNIT_ASSERT_EQUAL(sal_Int16(0), rViewData.GetCurX()); - CPPUNIT_ASSERT_EQUAL(sal_Int32(16777215), rViewData.GetCurY()); - - xDocSh->DoClose(); + CPPUNIT_ASSERT_EQUAL(sal_Int16(0), ScDocShell::GetViewData()->GetCurX()); + CPPUNIT_ASSERT_EQUAL(sal_Int32(16777215), ScDocShell::GetViewData()->GetCurY()); } void ScJumboSheetsTest::testTdf109061() { // Without the fix in place, the file would have crashed - ScDocShellRef xDocSh = loadDoc(u"tdf109061.", FORMAT_XLSX); + loadFromURL(u"xlsx/tdf109061.xlsx"); - ScDocument& rDoc = xDocSh->GetDocument(); - rDoc.CalcAll(); // perform hard re-calculation. + ScModelObj* pModelObj = dynamic_cast(mxComponent.get()); + CPPUNIT_ASSERT(pModelObj); + ScDocument* pDoc = pModelObj->GetDocument(); + pDoc->CalcAll(); // perform hard re-calculation. - CPPUNIT_ASSERT_EQUAL(6.0, rDoc.GetValue(1, 3, 0)); - - xDocSh->DoClose(); + CPPUNIT_ASSERT_EQUAL(6.0, pDoc->GetValue(1, 3, 0)); } ScJumboSheetsTest::ScJumboSheetsTest() - : ScBootstrapFixture("sc/qa/unit/data") + : UnoApiTest("/sc/qa/unit/data/") { } void ScJumboSheetsTest::setUp() { - ScBootstrapFixture::setUp(); + UnoApiTest::setUp(); + + //Init before GetDefaultsOptions + ScDLL::Init(); ScDefaultsOptions aDefaultsOption = SC_MOD()->GetDefaultsOptions(); aDefaultsOption.SetInitJumboSheets(true); @@ -398,7 +386,7 @@ void ScJumboSheetsTest::tearDown() aDefaultsOption.SetInitJumboSheets(false); SC_MOD()->SetDefaultsOptions(aDefaultsOption); - ScBootstrapFixture::tearDown(); + UnoApiTest::tearDown(); } void ScJumboSheetsTest::registerNamespaces(xmlXPathContextPtr& pXmlXPathCtx) diff --git a/test/source/unoapi_test.cxx b/test/source/unoapi_test.cxx index 0a04e46fd831..476e7eeae1de 100644 --- a/test/source/unoapi_test.cxx +++ b/test/source/unoapi_test.cxx @@ -127,11 +127,13 @@ utl::TempFileNamed UnoApiTest::saveAndClose(const OUString& rFilter) return aTempFile; } -void UnoApiTest::saveAndReload(const OUString& rFilter) +utl::TempFileNamed UnoApiTest::saveAndReload(const OUString& rFilter) { utl::TempFileNamed aTempFile = saveAndClose(rFilter); mxComponent = loadFromDesktop(aTempFile.GetURL()); + + return aTempFile; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */