sc/qa/unit/ucalc.cxx            |   38 ++++++++++++++++++++++++++++++++++++++
 sc/qa/unit/ucalc.hxx            |    4 +++-
 sc/source/core/data/column3.cxx |    2 +-
 3 files changed, 42 insertions(+), 2 deletions(-)

New commits:
commit 4f94e6c20b2fee11429d7cbaef6b6fd1880317b2
Author: Kohei Yoshida <kohei.yosh...@collabora.com>
Date:   Wed Dec 11 18:37:42 2013 -0500

    Fix paste as link, and a test case to catch it in the future.
    
    Change-Id: I55fd3fabb7594ee2c635cc0b02dbf506bd5ab3df

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index cc235cb..1ba3db1 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 f87047a..2af0e65 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 7a7f0a7..921fd43 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);
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to