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

Kohei Yoshida kohei.yoshida at collabora.com
Tue Jul 29 19:35:32 PDT 2014


 sc/qa/unit/ucalc.cxx          |   42 ++++++++++++++++++++++++++++++++++++++++++
 sc/qa/unit/ucalc.hxx          |    2 ++
 sc/source/core/tool/token.cxx |    5 +++++
 3 files changed, 49 insertions(+)

New commits:
commit 5e55d5ffb70437e917e4092f4030d5a454fd20d6
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Tue Jul 29 22:33:56 2014 -0400

    fdo#81330: When moving to a different sheet, set 3D flag on.
    
    Change-Id: I16c6e687259635c4d0ac0e5dab0140941b409bc8

diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 99a26a8..569834a 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -2812,6 +2812,8 @@ sc::RefUpdateResult ScTokenArray::AdjustReferenceOnMove(
     ScRange aOldRange = rCxt.maRange;
     aOldRange.Move(-rCxt.mnColDelta, -rCxt.mnRowDelta, -rCxt.mnTabDelta);
 
+    bool b3DFlag = rOldPos.Tab() != rNewPos.Tab();
+
     FormulaToken** p = pCode;
     FormulaToken** pEnd = p + static_cast<size_t>(nLen);
     for (; p != pEnd; ++p)
@@ -2830,6 +2832,7 @@ sc::RefUpdateResult ScTokenArray::AdjustReferenceOnMove(
                 }
 
                 rRef.SetAddress(aAbs, rNewPos);
+                rRef.SetFlag3D(b3DFlag);
             }
             break;
             case svDoubleRef:
@@ -2844,6 +2847,8 @@ sc::RefUpdateResult ScTokenArray::AdjustReferenceOnMove(
                 }
 
                 rRef.SetRange(aAbs, rNewPos);
+                if (b3DFlag)
+                    rRef.Ref1.SetFlag3D(true);
             }
             break;
             case svIndex:
commit 6a816d1fdd63532c3a85ee9e7fe20040ee754f1a
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Tue Jul 29 21:19:29 2014 -0400

    fdo#81330: Write test for this.
    
    Change-Id: Id781b13b180c0622bfb01cf2ca844fa452061b50

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index bbed0c7..02950cf 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -3942,6 +3942,48 @@ void Test::testCutPasteRefUndo()
     m_pDoc->DeleteTab(0);
 }
 
+void Test::testMoveRefBetweenSheets()
+{
+    sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn on auto calc.
+
+    m_pDoc->InsertTab(0, "Test1");
+    m_pDoc->InsertTab(1, "Test2");
+
+    m_pDoc->SetValue(ScAddress(0,0,0), 12.0);
+    m_pDoc->SetValue(ScAddress(1,0,0), 10.0);
+    m_pDoc->SetValue(ScAddress(2,0,0),  8.0);
+    m_pDoc->SetString(ScAddress(0,1,0), "=A1");
+    m_pDoc->SetString(ScAddress(0,2,0), "=SUM(A1:C1)");
+
+    CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(ScAddress(0,0,0)));
+    CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(ScAddress(0,1,0)));
+    CPPUNIT_ASSERT_EQUAL(30.0, m_pDoc->GetValue(ScAddress(0,2,0)));
+
+    // These formulas should not display the sheet name.
+    if (!checkFormula(*m_pDoc, ScAddress(0,1,0), "A1"))
+        CPPUNIT_FAIL("Wrong formula!");
+    if (!checkFormula(*m_pDoc, ScAddress(0,2,0), "SUM(A1:C1)"))
+        CPPUNIT_FAIL("Wrong formula!");
+
+    // Move Test1.A2:A3 to Test2.A2:A3.
+    ScDocFunc& rFunc = getDocShell().GetDocFunc();
+    bool bMoved = rFunc.MoveBlock(ScRange(0,1,0,0,2,0), ScAddress(0,1,1), true, true, false, true);
+    CPPUNIT_ASSERT(bMoved);
+
+    CPPUNIT_ASSERT_MESSAGE("This cell should be empty after the move.", m_pDoc->GetCellType(ScAddress(0,1,0)) == CELLTYPE_NONE);
+    CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(ScAddress(0,1,1)));
+    CPPUNIT_ASSERT_EQUAL(30.0, m_pDoc->GetValue(ScAddress(0,2,1)));
+
+    // The reference in the pasted formula should display sheet name after the move.
+    if (!checkFormula(*m_pDoc, ScAddress(0,1,1), "Test1.A1"))
+        CPPUNIT_FAIL("Wrong formula!");
+    if (!checkFormula(*m_pDoc, ScAddress(0,2,1), "SUM(Test1.A1:C1)"))
+        CPPUNIT_FAIL("Wrong formula!");
+
+    m_pDoc->DeleteTab(1);
+    m_pDoc->DeleteTab(0);
+}
+
 void Test::testUndoCut()
 {
     m_pDoc->InsertTab(0, "Test");
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index cf3d0d5..471cf82 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -280,6 +280,7 @@ public:
     void testCopyPasteSkipEmpty2();
     void testCopyPasteSkipEmptyConditionalFormatting();
     void testCutPasteRefUndo();
+    void testMoveRefBetweenSheets();
     void testUndoCut();
     void testMoveBlock();
     void testCopyPasteRelativeFormula();
@@ -487,6 +488,7 @@ public:
     CPPUNIT_TEST(testCopyPasteSkipEmpty2);
     //CPPUNIT_TEST(testCopyPasteSkipEmptyConditionalFormatting);
     CPPUNIT_TEST(testCutPasteRefUndo);
+    CPPUNIT_TEST(testMoveRefBetweenSheets);
     CPPUNIT_TEST(testUndoCut);
     CPPUNIT_TEST(testMoveBlock);
     CPPUNIT_TEST(testCopyPasteRelativeFormula);


More information about the Libreoffice-commits mailing list