[Libreoffice-commits] core.git: sc/qa

Kohei Yoshida kohei.yoshida at gmail.com
Thu Aug 1 12:46:02 PDT 2013


 sc/qa/unit/ucalc.cxx |   34 ++++++++++++++++++++++++++++++++++
 sc/qa/unit/ucalc.hxx |    2 ++
 2 files changed, 36 insertions(+)

New commits:
commit 55dbf8795467892abe210e4adcc6cf14f02516d7
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Thu Aug 1 15:45:07 2013 -0400

    fdo#67489: Add test for this.
    
    The master branch doesn't have this bug, but it's good to have a test
    case for this.
    
    Change-Id: I986d51bb78effc829f01f40b9ad63647f5341fa9

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 9132cc5..468d7c6 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -2943,6 +2943,40 @@ void Test::testCopyPaste()
     m_pDoc->DeleteTab(0);
 }
 
+void Test::testCopyPasteRelativeFormula()
+{
+    m_pDoc->InsertTab(0, "Formula");
+
+    sc::AutoCalcSwitch aACSwitch(*m_pDoc, true);
+
+    // Insert values to A2 and A4.
+    m_pDoc->SetValue(ScAddress(0,1,0), 1);
+    m_pDoc->SetValue(ScAddress(0,3,0), 2);
+
+    // Insert formula to B4.
+    m_pDoc->SetString(ScAddress(1,3,0), "=A4");
+    CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(ScAddress(1,3,0)));
+
+    // Select and copy B3:B4 to the clipboard.
+    ScRange aRange(1,2,0,1,3,0);
+    ScClipParam aClipParam(aRange, false);
+    ScMarkData aMark;
+    aMark.SetMarkArea(aRange);
+    ScDocument aClipDoc(SCDOCMODE_CLIP);
+    m_pDoc->CopyToClip(aClipParam, &aClipDoc, &aMark);
+
+    // Paste it to B1:B2.
+    sal_uInt16 nFlags = IDF_ALL;
+    ScRange aDestRange(1,0,0,1,1,0);
+    aMark.SetMarkArea(aDestRange);
+    m_pDoc->CopyFromClip(aDestRange, aMark, nFlags, NULL, &aClipDoc);
+
+    // B2 references A2, so the value should be 1.
+    CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(ScAddress(1,1,0)));
+
+    m_pDoc->DeleteTab(0);
+}
+
 void Test::testMergedCells()
 {
     //test merge and unmerge
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index 2413317..ebc3221 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -214,6 +214,7 @@ public:
     void testDataArea();
     void testAutofilter();
     void testCopyPaste();
+    void testCopyPasteRelativeFormula();
     void testMergedCells();
     void testUpdateReference();
     void testSearchCells();
@@ -339,6 +340,7 @@ public:
     CPPUNIT_TEST(testToggleRefFlag);
     CPPUNIT_TEST(testAutofilter);
     CPPUNIT_TEST(testCopyPaste);
+    CPPUNIT_TEST(testCopyPasteRelativeFormula);
     CPPUNIT_TEST(testMergedCells);
     CPPUNIT_TEST(testUpdateReference);
     CPPUNIT_TEST(testSearchCells);


More information about the Libreoffice-commits mailing list