summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2018-10-16 11:22:20 +0200
committerAndras Timar <andras.timar@collabora.com>2019-04-24 22:48:14 +0200
commit7a4657825a258b2c83cbb23dabaa29937bb0bdbc (patch)
treeb2f891436b978e9a098cf5e3b1dbbe5ab8eaa413
parentc444aab457f1383cb94f9ab7b39ae87d37a4c817 (diff)
Unit test deleting shared formula group top cell, tdf#119623
Change-Id: I9a497b9d9ae09c8764f62549a60c8a2a952bc9e9 Reviewed-on: https://gerrit.libreoffice.org/61822 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Jenkins
-rw-r--r--sc/qa/unit/ucalc.hxx2
-rw-r--r--sc/qa/unit/ucalc_sharedformula.cxx42
2 files changed, 44 insertions, 0 deletions
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index f2304ccb823e..cd1f6b06914b 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -398,6 +398,7 @@ public:
void testSharedFormulaUnshareAreaListeners();
void testSharedFormulaListenerDeleteArea();
void testSharedFormulaUpdateOnReplacement();
+ void testSharedFormulaDeleteTopCell();
void testSharedFormulaCutCopyMoveIntoRef();
void testSharedFormulaCutCopyMoveWithRef();
void testSharedFormulaCutCopyMoveWithinRun();
@@ -736,6 +737,7 @@ public:
CPPUNIT_TEST(testSharedFormulaUnshareAreaListeners);
CPPUNIT_TEST(testSharedFormulaListenerDeleteArea);
CPPUNIT_TEST(testSharedFormulaUpdateOnReplacement);
+ CPPUNIT_TEST(testSharedFormulaDeleteTopCell);
CPPUNIT_TEST(testSharedFormulaCutCopyMoveIntoRef);
CPPUNIT_TEST(testSharedFormulaCutCopyMoveWithRef);
CPPUNIT_TEST(testSharedFormulaCutCopyMoveWithinRun);
diff --git a/sc/qa/unit/ucalc_sharedformula.cxx b/sc/qa/unit/ucalc_sharedformula.cxx
index e2205ba98358..8acbb06a1c4d 100644
--- a/sc/qa/unit/ucalc_sharedformula.cxx
+++ b/sc/qa/unit/ucalc_sharedformula.cxx
@@ -2344,6 +2344,48 @@ void Test::testSharedFormulaUpdateOnReplacement()
m_pDoc->DeleteTab(0);
}
+void Test::testSharedFormulaDeleteTopCell()
+{
+ sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn on auto calc.
+
+ m_pDoc->InsertTab(0, "Test");
+
+ const char* pData[][2] = {
+ { "=SUM(B$1:B$2)", "1" },
+ { "=SUM(B$1:B$2)", "2" }
+ };
+
+ insertRangeData( m_pDoc, ScAddress(0,0,0), pData, SAL_N_ELEMENTS(pData));
+
+ // Check that A1:A2 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>(2), pFC->GetSharedLength());
+
+ // Check results A1:A2.
+ CPPUNIT_ASSERT_EQUAL( 3.0, m_pDoc->GetValue( ScAddress(0,0,0)));
+ CPPUNIT_ASSERT_EQUAL( 3.0, m_pDoc->GetValue( ScAddress(0,1,0)));
+
+ // Delete cell A1.
+ ScMarkData aMark;
+ aMark.SelectOneTable(0);
+ getDocShell().GetDocFunc().DeleteCell( ScAddress(0,0,0), aMark, InsertDeleteFlags::CONTENTS, false);
+ // Check it's gone.
+ CPPUNIT_ASSERT(!m_pDoc->GetFormulaCell( ScAddress(0,0,0)));
+
+ // Check result A2.
+ CPPUNIT_ASSERT_EQUAL( 3.0, m_pDoc->GetValue( ScAddress(0,1,0)));
+
+ // Replace B1 with 4.
+ m_pDoc->SetString( ScAddress(1,0,0), "4");
+
+ // Check result A2.
+ CPPUNIT_ASSERT_EQUAL( 6.0, m_pDoc->GetValue( ScAddress(0,1,0)));
+
+ m_pDoc->DeleteTab(0);
+}
+
void Test::testSharedFormulaCutCopyMoveIntoRef()
{