sc/qa/unit/data/ods/dependencyTree.ods |binary
 sc/qa/unit/subsequent_filters-test.cxx |   30 ++++++++++++++++++++++++++++++
 2 files changed, 30 insertions(+)

New commits:
commit cc84ff4a51790f52f2e729cc61f7515fbbd51f35
Author: Markus Mohrhard <markus.mohrh...@googlemail.com>
Date:   Fri Jan 4 22:41:50 2013 +0100

    add unit test for dependency tree during ods import
    
    Change-Id: I92bff38304959237042b9a0078be25948d642b25

diff --git a/sc/qa/unit/data/ods/dependencyTree.ods 
b/sc/qa/unit/data/ods/dependencyTree.ods
new file mode 100644
index 0000000..fc5aae0
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 c283508..5acbfb8 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"))
 {
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to