summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sc/qa/unit/ucalc.hxx2
-rw-r--r--sc/qa/unit/ucalc_formula.cxx65
2 files changed, 67 insertions, 0 deletions
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index 90fc183d08fd..3bc864734874 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -161,6 +161,7 @@ public:
void testFormulaRefUpdateMoveUndo2();
void testFormulaRefUpdateMoveUndo3NonShared();
void testFormulaRefUpdateMoveUndo3Shared();
+ void testFormulaRefUpdateMoveUndoDependents();
void testFormulaRefUpdateMoveToSheet();
void testFormulaRefUpdateDeleteContent();
void testFormulaRefUpdateDeleteAndShiftLeft();
@@ -599,6 +600,7 @@ public:
CPPUNIT_TEST(testFormulaRefUpdateMoveUndo2);
CPPUNIT_TEST(testFormulaRefUpdateMoveUndo3NonShared);
CPPUNIT_TEST(testFormulaRefUpdateMoveUndo3Shared);
+ CPPUNIT_TEST(testFormulaRefUpdateMoveUndoDependents);
CPPUNIT_TEST(testFormulaRefUpdateMoveToSheet);
CPPUNIT_TEST(testFormulaRefUpdateDeleteContent);
CPPUNIT_TEST(testFormulaRefUpdateDeleteAndShiftLeft);
diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index 1248692f5a50..ebc65177b301 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -2806,6 +2806,71 @@ void Test::testFormulaRefUpdateMoveUndo3Shared()
m_pDoc->DeleteTab(0);
}
+void Test::testFormulaRefUpdateMoveUndoDependents()
+{
+ m_pDoc->InsertTab(0, "Test");
+
+ sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
+ std::vector<std::vector<const char*>> aData = {
+ { "1" },
+ { "22" },
+ { "3" },
+ { "4" },
+ { "5" },
+ { "=SUM(C1:C5)" },
+ { "=C6" },
+ };
+
+ ScRange aOutRange = insertRangeData(m_pDoc, ScAddress(2,0,0), aData);
+
+ std::vector<std::vector<const char*>> aCheckInitial = {
+ { "1" },
+ { "22" },
+ { "3" },
+ { "4" },
+ { "5" },
+ { "35" },
+ { "35" },
+ };
+
+ bool bGood = checkOutput(m_pDoc, aOutRange, aCheckInitial, "initial data");
+ CPPUNIT_ASSERT(bGood);
+
+ // Drag C2 into D2.
+ ScDocFunc& rFunc = getDocShell().GetDocFunc();
+ bool bMoved = rFunc.MoveBlock(ScRange(2, 1, 0, 2, 1, 0), ScAddress(3, 1, 0), true, true, false, true);
+ CPPUNIT_ASSERT(bMoved);
+
+ std::vector<std::vector<const char*>> aCheckAfter = {
+ { "1" },
+ { nullptr },
+ { "3" },
+ { "4" },
+ { "5" },
+ { "13" },
+ { "13" },
+ };
+
+ bGood = checkOutput(m_pDoc, aOutRange, aCheckAfter, "C2 moved to D2");
+ CPPUNIT_ASSERT(bGood);
+
+ // Undo the move.
+ SfxUndoManager* pUndoMgr = m_pDoc->GetUndoManager();
+ CPPUNIT_ASSERT(pUndoMgr);
+ pUndoMgr->Undo();
+
+ bGood = checkOutput(m_pDoc, aOutRange, aCheckInitial, "after undo");
+ CPPUNIT_ASSERT(bGood);
+
+ // Redo and check.
+ pUndoMgr->Redo();
+
+ bGood = checkOutput(m_pDoc, aOutRange, aCheckAfter, "after redo");
+ CPPUNIT_ASSERT(bGood);
+
+ m_pDoc->DeleteTab(0);
+}
+
void Test::testFormulaRefUpdateMoveToSheet()
{
sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.