summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2014-03-13 14:43:06 -0400
committerKohei Yoshida <kohei.yoshida@collabora.com>2014-03-13 16:09:32 -0400
commitce524556df4bf06cde1229475b9de9822a89f62b (patch)
treebd1e57e30020a62da377d403bd17e69236214f0e
parentccd765079ae573d24ded2a07ec434e4e89b619a2 (diff)
fdo#76132: Write test for this first.
The crash is a result of the pasted formula cell (single cell) being marked "shared", which should never happen. Change-Id: I7b7fa536c520c76b56cce78457e11b6e2eaee76f
-rw-r--r--sc/qa/unit/ucalc.cxx31
1 files changed, 31 insertions, 0 deletions
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index ed5e894bf483..c903f4fcb19e 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -3765,6 +3765,37 @@ void Test::testCopyPasteRelativeFormula()
// B2 references A2, so the value should be 1.
CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(ScAddress(1,1,0)));
+ // Clear content and start over.
+ clearSheet(m_pDoc, 0);
+ clearSheet(&aClipDoc, 0);
+
+ // Insert a single formula cell in A1.
+ m_pDoc->SetString(ScAddress(0,0,0), "=ROW()");
+ const ScFormulaCell* pFC = m_pDoc->GetFormulaCell(ScAddress(0,0,0));
+ CPPUNIT_ASSERT(pFC);
+ CPPUNIT_ASSERT(!pFC->IsShared()); // single formula cell is never shared.
+
+ // Copy A1 to clipboard.
+ aClipParam = ScClipParam(ScAddress(0,0,0), false);
+ m_pDoc->CopyToClip(aClipParam, &aClipDoc, &aMark);
+
+ pFC = aClipDoc.GetFormulaCell(ScAddress(0,0,0));
+ CPPUNIT_ASSERT(pFC);
+ CPPUNIT_ASSERT(!pFC->IsShared());
+
+ // Paste to A3.
+ aDestRange = ScRange(0,2,0,0,2,0);
+ aMark.SetMarkArea(aDestRange);
+ m_pDoc->CopyFromClip(aDestRange, aMark, nFlags, NULL, &aClipDoc);
+
+ pFC = m_pDoc->GetFormulaCell(ScAddress(0,2,0));
+ CPPUNIT_ASSERT(pFC);
+ CPPUNIT_ASSERT(!pFC->IsShared());
+
+ // Delete A3 and make sure it doesn't crash (see fdo#76132).
+ clearRange(m_pDoc, ScAddress(0,2,0));
+ CPPUNIT_ASSERT(m_pDoc->GetCellType(ScAddress(0,2,0)) == CELLTYPE_NONE);
+
m_pDoc->DeleteTab(0);
}