diff options
author | Eike Rathke <erack@redhat.com> | 2015-01-14 23:37:43 +0100 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2015-01-15 17:27:27 +0100 |
commit | 1a2b8b2358fe5954a5c3960c9a48467de3dc5ba8 (patch) | |
tree | 3f66a350cafd32d74046f558837eb7f407ede7b2 | |
parent | 98a940b60c666792127c58aee989a87820fb7294 (diff) |
add unit test for fdo#88398
Check that grouped area listeners aren't discarded when unsharing a
grouped formula.
Change-Id: Ic3d3e9acb5b97d927a85ca433de127dd3b74a30c
-rw-r--r-- | sc/qa/unit/ucalc.hxx | 2 | ||||
-rw-r--r-- | sc/qa/unit/ucalc_sharedformula.cxx | 31 |
2 files changed, 33 insertions, 0 deletions
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx index 6f6af6b729cb..867b27597732 100644 --- a/sc/qa/unit/ucalc.hxx +++ b/sc/qa/unit/ucalc.hxx @@ -329,6 +329,7 @@ public: void testSharedFormulaUpdateOnNamedRangeChange(); void testSharedFormulaUpdateOnDBChange(); void testSharedFormulaAbsCellListener(); + void testSharedFormulaUnshareAreaListeners(); void testFormulaPosition(); void testMixData(); @@ -568,6 +569,7 @@ public: CPPUNIT_TEST(testSharedFormulaUpdateOnNamedRangeChange); CPPUNIT_TEST(testSharedFormulaUpdateOnDBChange); CPPUNIT_TEST(testSharedFormulaAbsCellListener); + CPPUNIT_TEST(testSharedFormulaUnshareAreaListeners); 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 36fb824c98bf..0cc63e5ad3e1 100644 --- a/sc/qa/unit/ucalc_sharedformula.cxx +++ b/sc/qa/unit/ucalc_sharedformula.cxx @@ -1702,4 +1702,35 @@ void Test::testSharedFormulaAbsCellListener() m_pDoc->DeleteTab(0); } +void Test::testSharedFormulaUnshareAreaListeners() +{ + sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn on auto calc. + + m_pDoc->InsertTab(0, "Test"); + + const char* pData[][2] = { + { "=SUM(B1:B2)", "1" }, + { "=SUM(B2:B3)", "2" }, + { "=SUM(B3:B4)", "4" }, + { 0, "8" } + }; + + insertRangeData(m_pDoc, ScAddress(0,0,0), pData, SAL_N_ELEMENTS(pData)); + + // Check that A1:A3 is a formula group. + const ScFormulaCell* pFC = m_pDoc->GetFormulaCell(ScAddress(0,0,0)); + CPPUNIT_ASSERT(pFC); + CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(0), pFC->GetSharedTopRow()); + CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(3), pFC->GetSharedLength()); + + m_pDoc->SetValue(ScAddress(0,1,0), 23.0); // unshare at A2 + m_pDoc->SetValue(ScAddress(1,1,0), 16.0); // change value of B2 + m_pDoc->SetValue(ScAddress(1,2,0), 32.0); // change value of B3 + // A1 and A3 should be recalculated. + CPPUNIT_ASSERT_EQUAL(17.0, m_pDoc->GetValue(ScAddress(0,0,0))); + CPPUNIT_ASSERT_EQUAL(40.0, m_pDoc->GetValue(ScAddress(0,2,0))); + + m_pDoc->DeleteTab(0); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |