[Libreoffice-commits] core.git: sc/qa

Eike Rathke erack at redhat.com
Tue Jun 16 09:07:19 PDT 2015


 sc/qa/unit/ucalc.hxx               |    2 +
 sc/qa/unit/ucalc_sharedformula.cxx |   44 +++++++++++++++++++++++++++++++++++++
 2 files changed, 46 insertions(+)

New commits:
commit 2d4a931208acd0060bfaa00a9444e6e0ceb7e83c
Author: Eike Rathke <erack at redhat.com>
Date:   Tue Jun 16 17:48:27 2015 +0200

    unit test for tdf#91411
    
    Change-Id: I963674ad6c6a4ca95f1a65041f7ced64d7d86a43

diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index afc4d0a..0c3e57a 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -337,6 +337,7 @@ public:
     void testSharedFormulaUpdateOnDBChange();
     void testSharedFormulaAbsCellListener();
     void testSharedFormulaUnshareAreaListeners();
+    void testSharedFormulaListenerDeleteArea();
     void testFormulaPosition();
 
     void testMixData();
@@ -586,6 +587,7 @@ public:
     CPPUNIT_TEST(testSharedFormulaUpdateOnDBChange);
     CPPUNIT_TEST(testSharedFormulaAbsCellListener);
     CPPUNIT_TEST(testSharedFormulaUnshareAreaListeners);
+    CPPUNIT_TEST(testSharedFormulaListenerDeleteArea);
     CPPUNIT_TEST(testFormulaPosition);
     CPPUNIT_TEST(testMixData);
     CPPUNIT_TEST(testJumpToPrecedentsDependents);
diff --git a/sc/qa/unit/ucalc_sharedformula.cxx b/sc/qa/unit/ucalc_sharedformula.cxx
index 719b27c..c0772f1 100644
--- a/sc/qa/unit/ucalc_sharedformula.cxx
+++ b/sc/qa/unit/ucalc_sharedformula.cxx
@@ -1733,4 +1733,48 @@ void Test::testSharedFormulaUnshareAreaListeners()
     m_pDoc->DeleteTab(0);
 }
 
+void Test::testSharedFormulaListenerDeleteArea()
+{
+    sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn on auto calc.
+
+    m_pDoc->InsertTab(0, "Test0");
+    m_pDoc->InsertTab(1, "Test1");
+
+    const char* pData0[][3] = {
+        { "", "", "=Test1.C1" },
+        { "", "", "=Test1.C2" }
+    };
+    const char* pData1[][3] = {
+        { "=Test0.A1", "=Test0.B1", "=SUM(A1:B1)" },
+        { "=Test0.A2", "=Test0.B2", "=SUM(A2:B2)" },
+    };
+
+    insertRangeData(m_pDoc, ScAddress(0,0,0), pData0, SAL_N_ELEMENTS(pData0));
+    insertRangeData(m_pDoc, ScAddress(0,0,1), pData1, SAL_N_ELEMENTS(pData1));
+
+    // Check that Test1.A1:A2 and Test1.B1:B2 are formula groups.
+    const ScFormulaCell* pFC = m_pDoc->GetFormulaCell(ScAddress(0,0,1));
+    CPPUNIT_ASSERT(pFC);
+    CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(0), pFC->GetSharedTopRow());
+    CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(2), pFC->GetSharedLength());
+
+    pFC = m_pDoc->GetFormulaCell(ScAddress(1,0,1));
+    CPPUNIT_ASSERT(pFC);
+    CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(0), pFC->GetSharedTopRow());
+    CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(2), pFC->GetSharedLength());
+
+    m_pDoc->SetValue(ScAddress(0,1,0), 1.0);   // change value of Test0.A2
+    m_pDoc->SetValue(ScAddress(1,1,0), 2.0);   // change value of Test0.B2
+    // Test0.C2 should be recalculated.
+    CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(ScAddress(2,1,0)));
+
+    // Delete Test0.B2
+    clearRange(m_pDoc, ScRange(1,1,0));
+    // Test0.C2 should be recalculated.
+    CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(ScAddress(2,1,0)));
+
+    m_pDoc->DeleteTab(1);
+    m_pDoc->DeleteTab(0);
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list