From ce524556df4bf06cde1229475b9de9822a89f62b Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Thu, 13 Mar 2014 14:43:06 -0400 Subject: 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 --- sc/qa/unit/ucalc.cxx | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) 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); } -- cgit v1.2.3