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

New commits:
commit 2873d7586199adaaf43144d6b6d4b2f253cfe4dd
Author: Eike Rathke <er...@redhat.com>
Date:   Tue Jul 7 14:44:54 2015 +0200

    unit test for copy&paste put reference in order, tdf#92468
    
    Change-Id: I69b2f294011498097372a1a46991e1ca8b6721c1

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 7c8171c..dcdc40d 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -4145,6 +4145,45 @@ void Test::testCopyPasteRepeatOneFormula()
     m_pDoc->DeleteTab(0);
 }
 
+void Test::testCopyPasteMixedReferenceFormula()
+{
+    sc::AutoCalcSwitch aAC(*m_pDoc, true); // turn on auto calc.
+    m_pDoc->InsertTab(0, "Test");
+
+    // Insert value to C3
+    m_pDoc->SetValue(2,2,0, 1.0);
+
+    // Insert formula to A1 with mixed relative/absolute addressing.
+    m_pDoc->SetString(0,0,0, "=SUM(B:$C)");
+    if (!checkFormula(*m_pDoc, ScAddress(0,0,0), "SUM(B:$C)"))
+        CPPUNIT_FAIL("Wrong formula.");
+    CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(0,0,0));
+
+    // Copy formula in A1 to clipboard.
+    ScRange aRange(ScAddress(0,0,0));
+    ScDocument aClipDoc(SCDOCMODE_CLIP);
+    copyToClip(m_pDoc, aRange, &aClipDoc);
+
+    // Paste formula to B1.
+    aRange = ScAddress(1,0,0);
+    pasteFromClip(m_pDoc, aRange, &aClipDoc);
+    if (!checkFormula(*m_pDoc, ScAddress(1,0,0), "SUM(C:$C)"))
+        CPPUNIT_FAIL("Wrong formula.");
+    CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(0,0,0));
+    CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(1,0,0));
+
+    // Paste formula to C1. All three results now must be circular reference.
+    aRange = ScAddress(2,0,0);
+    pasteFromClip(m_pDoc, aRange, &aClipDoc);
+    if (!checkFormula(*m_pDoc, ScAddress(2,0,0), "SUM($C:D)"))  // reference 
put in order
+        CPPUNIT_FAIL("Wrong formula.");
+    CPPUNIT_ASSERT_EQUAL(OUString("Err:522"), m_pDoc->GetString(0,0,0));
+    CPPUNIT_ASSERT_EQUAL(OUString("Err:522"), m_pDoc->GetString(1,0,0));
+    CPPUNIT_ASSERT_EQUAL(OUString("Err:522"), m_pDoc->GetString(2,0,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 7403179..4a3e462 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -316,6 +316,7 @@ public:
     void testMoveBlock();
     void testCopyPasteRelativeFormula();
     void testCopyPasteRepeatOneFormula();
+    void testCopyPasteMixedReferenceFormula();
     void testMergedCells();
     void testUpdateReference();
     void testSearchCells();
@@ -570,6 +571,7 @@ public:
     CPPUNIT_TEST(testMoveBlock);
     CPPUNIT_TEST(testCopyPasteRelativeFormula);
     CPPUNIT_TEST(testCopyPasteRepeatOneFormula);
+    CPPUNIT_TEST(testCopyPasteMixedReferenceFormula);
     CPPUNIT_TEST(testMergedCells);
     CPPUNIT_TEST(testUpdateReference);
     CPPUNIT_TEST(testSearchCells);
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to