summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2015-07-07 14:44:54 +0200
committerEike Rathke <erack@redhat.com>2015-07-07 14:47:39 +0200
commit2873d7586199adaaf43144d6b6d4b2f253cfe4dd (patch)
treebad54378f78462416ff45e490e608f4a9871e5e5
parent22935ed0a47bfc143303a8084cefd35eae94e6a9 (diff)
unit test for copy&paste put reference in order, tdf#92468
Change-Id: I69b2f294011498097372a1a46991e1ca8b6721c1
-rw-r--r--sc/qa/unit/ucalc.cxx39
-rw-r--r--sc/qa/unit/ucalc.hxx2
2 files changed, 41 insertions, 0 deletions
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 7c8171cab93e..dcdc40dc058c 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -4145,6 +4145,45 @@ void Test::testCopyPasteRepeatOneFormula()
m_pDoc->DeleteTab(0);
}
+void Test::testCopyPasteMixedReferenceFormula()
+{
+ sc::AutoCalcSwitch aAC(*m_pDoc, true); // turn on auto calc.
+ m_pDoc->InsertTab(0, "Test");
+
+ // Insert value to C3
+ m_pDoc->SetValue(2,2,0, 1.0);
+
+ // Insert formula to A1 with mixed relative/absolute addressing.
+ m_pDoc->SetString(0,0,0, "=SUM(B:$C)");
+ if (!checkFormula(*m_pDoc, ScAddress(0,0,0), "SUM(B:$C)"))
+ CPPUNIT_FAIL("Wrong formula.");
+ CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(0,0,0));
+
+ // Copy formula in A1 to clipboard.
+ ScRange aRange(ScAddress(0,0,0));
+ ScDocument aClipDoc(SCDOCMODE_CLIP);
+ copyToClip(m_pDoc, aRange, &aClipDoc);
+
+ // Paste formula to B1.
+ aRange = ScAddress(1,0,0);
+ pasteFromClip(m_pDoc, aRange, &aClipDoc);
+ if (!checkFormula(*m_pDoc, ScAddress(1,0,0), "SUM(C:$C)"))
+ CPPUNIT_FAIL("Wrong formula.");
+ CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(0,0,0));
+ CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(1,0,0));
+
+ // Paste formula to C1. All three results now must be circular reference.
+ aRange = ScAddress(2,0,0);
+ pasteFromClip(m_pDoc, aRange, &aClipDoc);
+ if (!checkFormula(*m_pDoc, ScAddress(2,0,0), "SUM($C:D)")) // reference put in order
+ CPPUNIT_FAIL("Wrong formula.");
+ CPPUNIT_ASSERT_EQUAL(OUString("Err:522"), m_pDoc->GetString(0,0,0));
+ CPPUNIT_ASSERT_EQUAL(OUString("Err:522"), m_pDoc->GetString(1,0,0));
+ CPPUNIT_ASSERT_EQUAL(OUString("Err:522"), m_pDoc->GetString(2,0,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 74031797f9ab..4a3e462093a8 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -316,6 +316,7 @@ public:
void testMoveBlock();
void testCopyPasteRelativeFormula();
void testCopyPasteRepeatOneFormula();
+ void testCopyPasteMixedReferenceFormula();
void testMergedCells();
void testUpdateReference();
void testSearchCells();
@@ -570,6 +571,7 @@ public:
CPPUNIT_TEST(testMoveBlock);
CPPUNIT_TEST(testCopyPasteRelativeFormula);
CPPUNIT_TEST(testCopyPasteRepeatOneFormula);
+ CPPUNIT_TEST(testCopyPasteMixedReferenceFormula);
CPPUNIT_TEST(testMergedCells);
CPPUNIT_TEST(testUpdateReference);
CPPUNIT_TEST(testSearchCells);