summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sc/qa/unit/ucalc.cxx38
-rw-r--r--sc/qa/unit/ucalc.hxx4
-rw-r--r--sc/source/core/data/column3.cxx2
3 files changed, 42 insertions, 2 deletions
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 681283ca9f2a..107825b48d66 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -3167,6 +3167,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 1298e73e62a8..1e2a4832bcf5 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();
@@ -361,8 +362,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);