From cc84ff4a51790f52f2e729cc61f7515fbbd51f35 Mon Sep 17 00:00:00 2001 From: Markus Mohrhard Date: Fri, 4 Jan 2013 22:41:50 +0100 Subject: add unit test for dependency tree during ods import Change-Id: I92bff38304959237042b9a0078be25948d642b25 --- sc/qa/unit/data/ods/dependencyTree.ods | Bin 0 -> 7967 bytes sc/qa/unit/subsequent_filters-test.cxx | 30 ++++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 sc/qa/unit/data/ods/dependencyTree.ods diff --git a/sc/qa/unit/data/ods/dependencyTree.ods b/sc/qa/unit/data/ods/dependencyTree.ods new file mode 100644 index 000000000000..fc5aae0a94b9 Binary files /dev/null and b/sc/qa/unit/data/ods/dependencyTree.ods differ diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx index c283508d7693..5acbfb812380 100644 --- a/sc/qa/unit/subsequent_filters-test.cxx +++ b/sc/qa/unit/subsequent_filters-test.cxx @@ -168,6 +168,7 @@ public: void testCellAnchoredShapesODS(); void testPivotTableBasicODS(); + void testFormulaDependency(); void testRowHeight(); @@ -213,6 +214,7 @@ public: CPPUNIT_TEST(testPivotTableBasicODS); // CPPUNIT_TEST(testRowHeight); + CPPUNIT_TEST(testFormulaDependency); //disable testPassword on MacOSX due to problems with libsqlite3 //also crashes on DragonFly due to problems with nss/nspr headers @@ -1749,6 +1751,34 @@ void ScFiltersTest::testNewCondFormat() testCondFile(aCSVPath, pDoc, 0); } +void ScFiltersTest::testFormulaDependency() +{ + const rtl::OUString aFileNameBase("dependencyTree."); + rtl::OUString aFileExtension(aFileFormats[ODS].pName, strlen(aFileFormats[ODS].pName), RTL_TEXTENCODING_UTF8 ); + rtl::OUString aFilterName(aFileFormats[ODS].pFilterName, strlen(aFileFormats[ODS].pFilterName), RTL_TEXTENCODING_UTF8) ; + rtl::OUString aFileName; + createFileURL(aFileNameBase, aFileExtension, aFileName); + rtl::OUString aFilterType(aFileFormats[ODS].pTypeName, strlen(aFileFormats[ODS].pTypeName), RTL_TEXTENCODING_UTF8); + std::cout << aFileFormats[ODS].pName << " Test" << std::endl; + + unsigned int nFormatType = aFileFormats[ODS].nFormatType; + unsigned int nClipboardId = nFormatType ? SFX_FILTER_IMPORT | SFX_FILTER_USESOPTIONS : 0; + ScDocShellRef xDocSh = load(aFilterName, aFileName, rtl::OUString(), aFilterType, + nFormatType, nClipboardId, SOFFICE_FILEFORMAT_CURRENT); + + ScDocument* pDoc = xDocSh->GetDocument(); + + // check if formula in A1 changes value + double nVal = pDoc->GetValue(0,0,0); + CPPUNIT_ASSERT_DOUBLES_EQUAL(nVal, 1.0, 1e-10); + pDoc->SetValue(0,1,0, 0.0); + nVal = pDoc->GetValue(0,0,0); + CPPUNIT_ASSERT_DOUBLES_EQUAL(nVal, 2.0, 1e-10); + + // check that the number format is implicity inherited + // CPPUNIT_ASSERT_EQUAL(pDoc->GetString(0,4,0), pDoc->GetString(0,5,0)); +} + ScFiltersTest::ScFiltersTest() : m_aBaseString(RTL_CONSTASCII_USTRINGPARAM("/sc/qa/unit/data")) { -- cgit v1.2.3