summaryrefslogtreecommitdiff
path: root/sc/qa
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@gmail.com>2013-08-01 15:45:07 -0400
committerKohei Yoshida <kohei.yoshida@gmail.com>2013-08-01 15:46:47 -0400
commit55dbf8795467892abe210e4adcc6cf14f02516d7 (patch)
tree912616c2a46f702b402e7f517589ab1a2a2e758f /sc/qa
parent33bc5a2737de53ae2c60c2c1be5738760d0762b3 (diff)
fdo#67489: Add test for this.
The master branch doesn't have this bug, but it's good to have a test case for this. Change-Id: I986d51bb78effc829f01f40b9ad63647f5341fa9
Diffstat (limited to 'sc/qa')
-rw-r--r--sc/qa/unit/ucalc.cxx34
-rw-r--r--sc/qa/unit/ucalc.hxx2
2 files changed, 36 insertions, 0 deletions
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 9132cc56974b..468d7c694a02 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -2943,6 +2943,40 @@ void Test::testCopyPaste()
m_pDoc->DeleteTab(0);
}
+void Test::testCopyPasteRelativeFormula()
+{
+ m_pDoc->InsertTab(0, "Formula");
+
+ sc::AutoCalcSwitch aACSwitch(*m_pDoc, true);
+
+ // Insert values to A2 and A4.
+ m_pDoc->SetValue(ScAddress(0,1,0), 1);
+ m_pDoc->SetValue(ScAddress(0,3,0), 2);
+
+ // Insert formula to B4.
+ m_pDoc->SetString(ScAddress(1,3,0), "=A4");
+ CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(ScAddress(1,3,0)));
+
+ // Select and copy B3:B4 to the clipboard.
+ ScRange aRange(1,2,0,1,3,0);
+ ScClipParam aClipParam(aRange, false);
+ ScMarkData aMark;
+ aMark.SetMarkArea(aRange);
+ ScDocument aClipDoc(SCDOCMODE_CLIP);
+ m_pDoc->CopyToClip(aClipParam, &aClipDoc, &aMark);
+
+ // Paste it to B1:B2.
+ sal_uInt16 nFlags = IDF_ALL;
+ ScRange aDestRange(1,0,0,1,1,0);
+ aMark.SetMarkArea(aDestRange);
+ m_pDoc->CopyFromClip(aDestRange, aMark, nFlags, NULL, &aClipDoc);
+
+ // B2 references A2, so the value should be 1.
+ CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(ScAddress(1,1,0)));
+
+ m_pDoc->DeleteTab(0);
+}
+
void Test::testMergedCells()
{
//test merge and unmerge
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index 241331791c5a..ebc3221868d2 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -214,6 +214,7 @@ public:
void testDataArea();
void testAutofilter();
void testCopyPaste();
+ void testCopyPasteRelativeFormula();
void testMergedCells();
void testUpdateReference();
void testSearchCells();
@@ -339,6 +340,7 @@ public:
CPPUNIT_TEST(testToggleRefFlag);
CPPUNIT_TEST(testAutofilter);
CPPUNIT_TEST(testCopyPaste);
+ CPPUNIT_TEST(testCopyPasteRelativeFormula);
CPPUNIT_TEST(testMergedCells);
CPPUNIT_TEST(testUpdateReference);
CPPUNIT_TEST(testSearchCells);