[Libreoffice-commits] .: 2 commits - sc/qa

Markus Mohrhard mmohrhard at kemper.freedesktop.org
Mon Sep 5 07:20:25 PDT 2011


 sc/qa/unit/data/ods/named-ranges-global.ods |binary
 sc/qa/unit/filters-test.cxx                 |   30 +++++++++++++++++++++++++++-
 sc/qa/unit/ucalc.cxx                        |   24 ++++++++++++++++++++++
 3 files changed, 53 insertions(+), 1 deletion(-)

New commits:
commit 054f170d9acae8f0b40b4f1de7682b17476fd8f7
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Mon Sep 5 16:14:15 2011 +0200

    initial work for a merged cell unit test
    
    TODO: add a undo/redo test and debug why ScDocFunc::InsertCells does not
    expand the merged area

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 7430a60..543c912 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -66,6 +66,7 @@
 #include "undoblk.hxx"
 
 #include "docsh.hxx"
+#include "docfunc.hxx"
 #include "dbdocfun.hxx"
 #include "funcdesc.hxx"
 #include "externalrefmgr.hxx"
@@ -251,6 +252,7 @@ public:
     void testDataArea();
     void testAutofilter();
     void testCopyPaste();
+    void testMergedCells();
 
     /**
      * Make sure the sheet streams are invalidated properly.
@@ -293,6 +295,7 @@ public:
     CPPUNIT_TEST(testToggleRefFlag);
     CPPUNIT_TEST(testAutofilter);
     CPPUNIT_TEST(testCopyPaste);
+    CPPUNIT_TEST(testMergedCells);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -2271,7 +2274,28 @@ void Test::testCopyPaste()
     delete pUndoDoc;
     m_pDoc->DeleteTab(1);
     m_pDoc->DeleteTab(0);
+}
 
+void Test::testMergedCells()
+{
+    //test merge and unmerge
+    //TODO: an undo/redo test for this would be a good idea
+    m_pDoc->InsertTab(0, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Sheet1")));
+    m_pDoc->DoMerge(0, 1, 1, 3, 3, false);
+    SCCOL nEndCol = 1;
+    SCROW nEndRow = 1;
+    m_pDoc->ExtendMerge( 1, 1, nEndCol, nEndRow, 0, false, false);
+    CPPUNIT_ASSERT_MESSAGE("did not merge cells", nEndCol == 3 && nEndRow == 3);
+    ScDocFunc aDocFunc(*m_xDocShRef);
+    ScRange aRange(0,2,0,MAXCOL,2,0);
+    ScMarkData aMark;
+    aMark.SetMarkArea(aRange);
+    aDocFunc.InsertCells(aRange, &aMark, INS_INSROWS, true, true);
+    m_pDoc->ExtendMerge( 1, 1, nEndCol, nEndRow, 0, false, false);
+    cout << nEndRow << nEndCol;
+    //have a look why this does not work
+    //CPPUNIT_ASSERT_MESSAGE("did not increase merge area", nEndCol == 3 && nEndRow == 4);
+    m_pDoc->DeleteTab(0);
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
commit 376120164971ef0fef61b93e3f65401cee286c29
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Mon Sep 5 13:07:10 2011 +0200

    test range names in import test

diff --git a/sc/qa/unit/data/ods/named-ranges-global.ods b/sc/qa/unit/data/ods/named-ranges-global.ods
index 9d23d32..0c1af78 100644
Binary files a/sc/qa/unit/data/ods/named-ranges-global.ods and b/sc/qa/unit/data/ods/named-ranges-global.ods differ
diff --git a/sc/qa/unit/filters-test.cxx b/sc/qa/unit/filters-test.cxx
index 8ad19eb..087e26c 100644
--- a/sc/qa/unit/filters-test.cxx
+++ b/sc/qa/unit/filters-test.cxx
@@ -59,6 +59,8 @@
 
 const int indeterminate = 2;
 
+#define ODS_FORMAT_TYPE 50331943
+
 using namespace ::com::sun::star;
 
 /* Implementation of Filters test */
@@ -194,9 +196,35 @@ void FiltersTest::testODSs()
     rtl::OUString aString2 = m_aSrcRoot + rtl::OUString(
         RTL_CONSTASCII_USTRINGPARAM("/sc/qa/unit/data/ods/named-ranges-global.ods"));
 
-    ScDocShellRef xDocSh = load( aString1, aString2 , rtl::OUString(), 50331943);
+    ScDocShellRef xDocSh = load( aString1, aString2 , rtl::OUString(), ODS_FORMAT_TYPE);
 
     CPPUNIT_ASSERT_MESSAGE("Failed to load named-ranges-global.ods.", xDocSh.Is());
+
+    ScDocument* pDoc = xDocSh->GetDocument();
+    //check one range data per sheet and one global more detailed
+    //add some more checks here
+    ScRangeData* pRangeData = pDoc->GetRangeName()->findByName(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Global1")));
+    CPPUNIT_ASSERT_MESSAGE("range name Global1 not found", pRangeData);
+    double aValue;
+    pDoc->GetValue(1,0,0,aValue);
+    CPPUNIT_ASSERT_MESSAGE("range name Global1 should reference Sheet1.A1", aValue == 1);
+    pRangeData = pDoc->GetRangeName(0)->findByName(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Local1")));
+    CPPUNIT_ASSERT_MESSAGE("range name Sheet1.Local1 not found", pRangeData);
+    pDoc->GetValue(1,2,0,aValue);
+    CPPUNIT_ASSERT_MESSAGE("range name Sheet1.Local1 should reference Sheet1.A3", aValue == 3);
+    pRangeData = pDoc->GetRangeName(1)->findByName(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Local2")));
+    CPPUNIT_ASSERT_MESSAGE("range name Sheet2.Local2 not found", pRangeData);
+    pDoc->GetValue(1,1,1,aValue);
+    CPPUNIT_ASSERT_MESSAGE("range name Sheet2.Local2 should reference Sheet2.A2", aValue == 7);
+    //check for correct results for the remaining formulas
+    pDoc->GetValue(1,1,0, aValue);
+    CPPUNIT_ASSERT_MESSAGE("=global2 should be 2", aValue == 2);
+    pDoc->GetValue(1,3,0, aValue);
+    CPPUNIT_ASSERT_MESSAGE("=local2 should be 4", aValue == 4);
+    pDoc->GetValue(2,0,0, aValue);
+    CPPUNIT_ASSERT_MESSAGE("=SUM(global3) should be 10", aValue == 10);
+    pDoc->GetValue(1,0,1,aValue);
+    CPPUNIT_ASSERT_MESSAGE("range name Sheet2.local1 should reference Sheet1.A5", aValue == 5);
 }
 
 FiltersTest::FiltersTest()


More information about the Libreoffice-commits mailing list