summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2014-07-29 21:19:29 -0400
committerKohei Yoshida <kohei.yoshida@collabora.com>2014-07-29 22:35:14 -0400
commit6a816d1fdd63532c3a85ee9e7fe20040ee754f1a (patch)
tree08ccf9ab9d98c519166c13223d1c0f2bbfb5e6dd /sc
parent52d21ee6516e29e55d09f346c8712eb68b3f52f0 (diff)
fdo#81330: Write test for this.
Change-Id: Id781b13b180c0622bfb01cf2ca844fa452061b50
Diffstat (limited to 'sc')
-rw-r--r--sc/qa/unit/ucalc.cxx42
-rw-r--r--sc/qa/unit/ucalc.hxx2
2 files changed, 44 insertions, 0 deletions
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index bbed0c7e795b..02950cfdd588 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -3942,6 +3942,48 @@ void Test::testCutPasteRefUndo()
m_pDoc->DeleteTab(0);
}
+void Test::testMoveRefBetweenSheets()
+{
+ sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn on auto calc.
+
+ m_pDoc->InsertTab(0, "Test1");
+ m_pDoc->InsertTab(1, "Test2");
+
+ m_pDoc->SetValue(ScAddress(0,0,0), 12.0);
+ m_pDoc->SetValue(ScAddress(1,0,0), 10.0);
+ m_pDoc->SetValue(ScAddress(2,0,0), 8.0);
+ m_pDoc->SetString(ScAddress(0,1,0), "=A1");
+ m_pDoc->SetString(ScAddress(0,2,0), "=SUM(A1:C1)");
+
+ CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(ScAddress(0,0,0)));
+ CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(ScAddress(0,1,0)));
+ CPPUNIT_ASSERT_EQUAL(30.0, m_pDoc->GetValue(ScAddress(0,2,0)));
+
+ // These formulas should not display the sheet name.
+ if (!checkFormula(*m_pDoc, ScAddress(0,1,0), "A1"))
+ CPPUNIT_FAIL("Wrong formula!");
+ if (!checkFormula(*m_pDoc, ScAddress(0,2,0), "SUM(A1:C1)"))
+ CPPUNIT_FAIL("Wrong formula!");
+
+ // Move Test1.A2:A3 to Test2.A2:A3.
+ ScDocFunc& rFunc = getDocShell().GetDocFunc();
+ bool bMoved = rFunc.MoveBlock(ScRange(0,1,0,0,2,0), ScAddress(0,1,1), true, true, false, true);
+ CPPUNIT_ASSERT(bMoved);
+
+ CPPUNIT_ASSERT_MESSAGE("This cell should be empty after the move.", m_pDoc->GetCellType(ScAddress(0,1,0)) == CELLTYPE_NONE);
+ CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(ScAddress(0,1,1)));
+ CPPUNIT_ASSERT_EQUAL(30.0, m_pDoc->GetValue(ScAddress(0,2,1)));
+
+ // The reference in the pasted formula should display sheet name after the move.
+ if (!checkFormula(*m_pDoc, ScAddress(0,1,1), "Test1.A1"))
+ CPPUNIT_FAIL("Wrong formula!");
+ if (!checkFormula(*m_pDoc, ScAddress(0,2,1), "SUM(Test1.A1:C1)"))
+ CPPUNIT_FAIL("Wrong formula!");
+
+ m_pDoc->DeleteTab(1);
+ m_pDoc->DeleteTab(0);
+}
+
void Test::testUndoCut()
{
m_pDoc->InsertTab(0, "Test");
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index cf3d0d5f034b..471cf823acef 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -280,6 +280,7 @@ public:
void testCopyPasteSkipEmpty2();
void testCopyPasteSkipEmptyConditionalFormatting();
void testCutPasteRefUndo();
+ void testMoveRefBetweenSheets();
void testUndoCut();
void testMoveBlock();
void testCopyPasteRelativeFormula();
@@ -487,6 +488,7 @@ public:
CPPUNIT_TEST(testCopyPasteSkipEmpty2);
//CPPUNIT_TEST(testCopyPasteSkipEmptyConditionalFormatting);
CPPUNIT_TEST(testCutPasteRefUndo);
+ CPPUNIT_TEST(testMoveRefBetweenSheets);
CPPUNIT_TEST(testUndoCut);
CPPUNIT_TEST(testMoveBlock);
CPPUNIT_TEST(testCopyPasteRelativeFormula);