summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2014-07-29 16:55:32 -0400
committerKohei Yoshida <kohei.yoshida@collabora.com>2014-07-29 17:21:33 -0400
commit2ef608aa35ee50a271ba817ef1538e663b4e0cae (patch)
tree86c9e10b776caa27255134c41f1056c3d6ab7e1e
parent7b13c6d96407b7f4c0c578693bd3b9629015489c (diff)
fdo#80846: Write test for this.
Change-Id: I80dc88028579a76c7116b3558cf560f9bfed109c
-rw-r--r--sc/qa/unit/ucalc.hxx2
-rw-r--r--sc/qa/unit/ucalc_formula.cxx38
2 files changed, 40 insertions, 0 deletions
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index 880fde6919f1..cf3d0d5f034b 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -131,6 +131,7 @@ public:
void testFormulaRefUpdateInsertColumns();
void testFormulaRefUpdateMove();
void testFormulaRefUpdateMoveUndo();
+ void testFormulaRefUpdateDeleteContent();
void testFormulaRefUpdateNamedExpression();
void testFormulaRefUpdateNamedExpressionMove();
void testFormulaRefUpdateNamedExpressionExpandRef();
@@ -405,6 +406,7 @@ public:
CPPUNIT_TEST(testFormulaRefUpdateInsertColumns);
CPPUNIT_TEST(testFormulaRefUpdateMove);
CPPUNIT_TEST(testFormulaRefUpdateMoveUndo);
+ CPPUNIT_TEST(testFormulaRefUpdateDeleteContent);
CPPUNIT_TEST(testFormulaRefUpdateNamedExpression);
CPPUNIT_TEST(testFormulaRefUpdateNamedExpressionMove);
CPPUNIT_TEST(testFormulaRefUpdateNamedExpressionExpandRef);
diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index f9a5ac189b8c..c7f03fa7081b 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -1848,6 +1848,44 @@ void Test::testFormulaRefUpdateMoveUndo()
m_pDoc->DeleteTab(0);
}
+void Test::testFormulaRefUpdateDeleteContent()
+{
+ sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
+
+ m_pDoc->InsertTab(0, "Test");
+
+ // Set value in B2.
+ m_pDoc->SetValue(ScAddress(1,1,0), 2.0);
+ // Set formula in C2 to reference B2.
+ m_pDoc->SetString(ScAddress(2,1,0), "=B2");
+
+ CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(ScAddress(2,1,0)));
+
+ // Delete B2.
+ ScDocFunc& rFunc = getDocShell().GetDocFunc();
+ ScMarkData aMark;
+ aMark.SetMarkArea(ScAddress(1,1,0));
+ rFunc.DeleteContents(aMark, IDF_CONTENTS, true, true);
+
+ CPPUNIT_ASSERT_MESSAGE("B2 should be empty.", m_pDoc->GetCellType(ScAddress(1,1,0)) == CELLTYPE_NONE);
+ CPPUNIT_ASSERT_EQUAL(0.0, m_pDoc->GetValue(ScAddress(2,1,0)));
+
+ SfxUndoManager* pUndoMgr = m_pDoc->GetUndoManager();
+ CPPUNIT_ASSERT(pUndoMgr);
+
+ // Undo and check the result of C2.
+ pUndoMgr->Undo();
+ CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(ScAddress(1,1,0))); // B2
+ CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(ScAddress(2,1,0))); // C2
+
+ // Redo and check.
+ pUndoMgr->Redo();
+ CPPUNIT_ASSERT_MESSAGE("B2 should be empty.", m_pDoc->GetCellType(ScAddress(1,1,0)) == CELLTYPE_NONE);
+ CPPUNIT_ASSERT_EQUAL(0.0, m_pDoc->GetValue(ScAddress(2,1,0)));
+
+ m_pDoc->DeleteTab(0);
+}
+
void Test::testFormulaRefUpdateNamedExpression()
{
m_pDoc->InsertTab(0, "Formula");