diff options
author | Kohei Yoshida <kohei.yoshida@collabora.com> | 2013-12-11 18:37:42 -0500 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@collabora.com> | 2013-12-11 18:39:02 -0500 |
commit | 4f94e6c20b2fee11429d7cbaef6b6fd1880317b2 (patch) | |
tree | 6ac37bd6cab839b40215409b1f19c94f9cd4238b /sc | |
parent | 77e7301aebe56b24562865efdebdbf66521942d3 (diff) |
Fix paste as link, and a test case to catch it in the future.
Change-Id: I55fd3fabb7594ee2c635cc0b02dbf506bd5ab3df
Diffstat (limited to 'sc')
-rw-r--r-- | sc/qa/unit/ucalc.cxx | 38 | ||||
-rw-r--r-- | sc/qa/unit/ucalc.hxx | 4 | ||||
-rw-r--r-- | sc/source/core/data/column3.cxx | 2 |
3 files changed, 42 insertions, 2 deletions
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx index cc235cbedd8a..1ba3db188cc6 100644 --- a/sc/qa/unit/ucalc.cxx +++ b/sc/qa/unit/ucalc.cxx @@ -3171,6 +3171,44 @@ void Test::testCopyPaste() m_pDoc->DeleteTab(0); } +void Test::testCopyPasteAsLink() +{ + sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // Turn on auto calc. + + m_pDoc->InsertTab(0, "Sheet1"); + m_pDoc->InsertTab(1, "Sheet2"); + + m_pDoc->SetValue(ScAddress(0,0,0), 1); // A1 + m_pDoc->SetValue(ScAddress(0,1,0), 2); // A2 + m_pDoc->SetValue(ScAddress(0,2,0), 3); // A3 + + ScRange aRange(0,0,0,0,2,0); // Copy A1:A3 to clip. + ScDocument aClipDoc(SCDOCMODE_CLIP); + copyToClip(m_pDoc, aRange, &aClipDoc); + + aRange = ScRange(1,1,1,1,3,1); // Paste to B2:B4 on Sheet2. + ScMarkData aMark; + aMark.SetMarkArea(aRange); + // Paste range as link. + m_pDoc->CopyFromClip(aRange, aMark, IDF_CONTENTS, NULL, &aClipDoc, true, true); + + // Check pasted content to make sure they reference the correct cells. + ScFormulaCell* pFC = m_pDoc->GetFormulaCell(ScAddress(1,1,1)); + CPPUNIT_ASSERT_MESSAGE("This should be a formula cell.", pFC); + CPPUNIT_ASSERT_EQUAL(1.0, pFC->GetValue()); + + pFC = m_pDoc->GetFormulaCell(ScAddress(1,2,1)); + CPPUNIT_ASSERT_MESSAGE("This should be a formula cell.", pFC); + CPPUNIT_ASSERT_EQUAL(2.0, pFC->GetValue()); + + pFC = m_pDoc->GetFormulaCell(ScAddress(1,3,1)); + CPPUNIT_ASSERT_MESSAGE("This should be a formula cell.", pFC); + CPPUNIT_ASSERT_EQUAL(3.0, pFC->GetValue()); + + m_pDoc->DeleteTab(1); + m_pDoc->DeleteTab(0); +} + void Test::testCopyPasteTranspose() { diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx index f87047acbdf4..2af0e6545402 100644 --- a/sc/qa/unit/ucalc.hxx +++ b/sc/qa/unit/ucalc.hxx @@ -220,6 +220,7 @@ public: void testDataArea(); void testAutofilter(); void testCopyPaste(); + void testCopyPasteAsLink(); void testCopyPasteTranspose(); void testMoveBlock(); void testCopyPasteRelativeFormula(); @@ -362,8 +363,9 @@ public: CPPUNIT_TEST(testToggleRefFlag); CPPUNIT_TEST(testAutofilter); CPPUNIT_TEST(testCopyPaste); - CPPUNIT_TEST(testMoveBlock); + CPPUNIT_TEST(testCopyPasteAsLink); CPPUNIT_TEST(testCopyPasteTranspose); + CPPUNIT_TEST(testMoveBlock); CPPUNIT_TEST(testCopyPasteRelativeFormula); CPPUNIT_TEST(testMergedCells); CPPUNIT_TEST(testUpdateReference); diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx index 7a7f0a7cdea1..921fd4330f94 100644 --- a/sc/source/core/data/column3.cxx +++ b/sc/source/core/data/column3.cxx @@ -690,7 +690,7 @@ class CopyCellsFromClipHandler void insertRefCell(SCROW nSrcRow, SCROW nDestRow) { - ScAddress aSrcPos(mnCol, nSrcRow, mnTab); + ScAddress aSrcPos(mnSrcCol, nSrcRow, mnSrcTab); ScAddress aDestPos(mnCol, nDestRow, mnTab); ScSingleRefData aRef; aRef.InitAddress(aSrcPos); |