diff options
author | Eike Rathke <erack@redhat.com> | 2015-06-16 17:48:27 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2015-06-16 18:06:28 +0200 |
commit | 2d4a931208acd0060bfaa00a9444e6e0ceb7e83c (patch) | |
tree | 809a96af8f359a87cea876bf9ef1a5d78aa46565 | |
parent | a6c07d2c263a39c829385d17cc125bd7d2b01531 (diff) |
unit test for tdf#91411
Change-Id: I963674ad6c6a4ca95f1a65041f7ced64d7d86a43
-rw-r--r-- | sc/qa/unit/ucalc.hxx | 2 | ||||
-rw-r--r-- | sc/qa/unit/ucalc_sharedformula.cxx | 44 |
2 files changed, 46 insertions, 0 deletions
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx index afc4d0ae3610..0c3e57a82a03 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 719b27c0d4d2..c0772f15f61e 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: */ |