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

Kohei Yoshida kohei.yoshida at collabora.com
Mon Apr 28 20:01:20 PDT 2014


 sc/inc/document.hxx              |    4 +--
 sc/qa/unit/ucalc.hxx             |    2 +
 sc/qa/unit/ucalc_formula.cxx     |   43 ++++++++++++++++++++++++++++++++++++++-
 sc/source/core/data/documen2.cxx |   10 +++++++++
 sc/source/core/tool/token.cxx    |    2 -
 5 files changed, 57 insertions(+), 4 deletions(-)

New commits:
commit c3e40f47abe3da7e24059281a9047b1292241398
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Mon Apr 28 22:57:56 2014 -0400

    fdo#77647: Expand reference only when the top of the selected range is...
    
    below the top of the reference range.
    
    Change-Id: Ibb3dadb50dd076ae05033b046c9506c60605f713

diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 5344454..016ff79 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -2562,7 +2562,7 @@ bool expandRange( const sc::RefUpdateContext& rCxt, ScRange& rRefRange, const Sc
             // Selected range is only partially overlapping in horizontal direction. Bail out.
             return false;
 
-        if (!rCxt.mrDoc.IsExpandRefs() && rSelectedRange.aStart.Row() == rRefRange.aStart.Row())
+        if (!rCxt.mrDoc.IsExpandRefs() && rSelectedRange.aStart.Row() <= rRefRange.aStart.Row())
             // Selected range is at the top end and the edge expansion is turned off.  No expansion.
             return false;
 
commit ce0228af2da5cea2accb91c3ca770cbe01005bab
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Mon Apr 28 22:56:09 2014 -0400

    Make these non inline.
    
    Change-Id: Icfed6fa13a04eb9b2006296421d52c566635ac33

diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index f16b292..f86bdda 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -1956,8 +1956,8 @@ public:
                                 return *pRecursionHelper;
                             }
     bool                IsInDtorClear() const { return bInDtorClear; }
-    void                SetExpandRefs( bool bVal ) { bExpandRefs = bVal; }
-    bool                IsExpandRefs() { return bExpandRefs; }
+    void SetExpandRefs( bool bVal );
+    bool IsExpandRefs() const;
 
     sal_uLong               GetXMLImportedFormulaCount() const { return nXMLImportedFormulaCount; }
     void                IncXMLImportedFormulaCount( sal_uLong nVal )
diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx
index 20b38f6..28f3ca7 100644
--- a/sc/source/core/data/documen2.cxx
+++ b/sc/source/core/data/documen2.cxx
@@ -364,6 +364,16 @@ IMPL_LINK_NOARG(ScDocument, TrackTimeHdl)
     return 0;
 }
 
+void ScDocument::SetExpandRefs( bool bVal )
+{
+    bExpandRefs = bVal;
+}
+
+bool ScDocument::IsExpandRefs() const
+{
+    return bExpandRefs;
+}
+
 void ScDocument::StartTrackTimer()
 {
     if (!aTrackTimer.IsActive())        // nicht ewig aufschieben
commit e4a886f657723040ba10a0ce0101f14763f5605a
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Mon Apr 28 20:52:29 2014 -0400

    fdo#77647: Write test for this.
    
    Change-Id: I25b04c4790fcdae1e85b5d7b9cb85792226af757

diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index 9a81c5e..06bab38 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -118,6 +118,7 @@ public:
     void testFormulaRefUpdate();
     void testFormulaRefUpdateRange();
     void testFormulaRefUpdateSheets();
+    void testFormulaRefUpdateInsertRows();
     void testFormulaRefUpdateMove();
     void testFormulaRefUpdateMoveUndo();
     void testFormulaRefUpdateNamedExpression();
@@ -370,6 +371,7 @@ public:
     CPPUNIT_TEST(testFormulaRefUpdate);
     CPPUNIT_TEST(testFormulaRefUpdateRange);
     CPPUNIT_TEST(testFormulaRefUpdateSheets);
+    CPPUNIT_TEST(testFormulaRefUpdateInsertRows);
     CPPUNIT_TEST(testFormulaRefUpdateMove);
     CPPUNIT_TEST(testFormulaRefUpdateMoveUndo);
     CPPUNIT_TEST(testFormulaRefUpdateNamedExpression);
diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index 1ecc5d2..937c96e 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -1477,6 +1477,43 @@ void Test::testFormulaRefUpdateSheets()
     m_pDoc->DeleteTab(0);
 }
 
+void Test::testFormulaRefUpdateInsertRows()
+{
+    ScModule* pMod = SC_MOD();
+    ScInputOptions aOpt = pMod->GetInputOptions();
+    aOpt.SetExpandRefs(false);
+    pMod->SetInputOptions(aOpt);
+
+    sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
+    m_pDoc->InsertTab(0, "Formula");
+
+    // Insert raw values in B2:B4.
+    m_pDoc->SetValue(ScAddress(1,1,0), 1.0);
+    m_pDoc->SetValue(ScAddress(1,2,0), 2.0);
+    m_pDoc->SetValue(ScAddress(1,3,0), 3.0);
+
+    // Insert a formula in B5 to sum up B2:B4.
+    m_pDoc->SetString(ScAddress(1,4,0), "=SUM(B2:B4)");
+
+    CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(ScAddress(1,4,0)));
+
+    // Insert rows over rows 1:2.
+    ScMarkData aMark;
+    aMark.SelectOneTable(0);
+    ScDocFunc& rFunc = getDocShell().GetDocFunc();
+    rFunc.InsertCells(ScRange(0,0,0,MAXCOL,1,0), &aMark, INS_INSROWS, false, true, false);
+
+    // The raw data should have shifted to B4:B6.
+    CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(ScAddress(1,3,0)));
+    CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(ScAddress(1,4,0)));
+    CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(ScAddress(1,5,0)));
+
+    if (!checkFormula(*m_pDoc, ScAddress(1,6,0), "SUM(B4:B6)"))
+        CPPUNIT_FAIL("Wrong formula!");
+
+    m_pDoc->DeleteTab(0);
+}
+
 void Test::testFormulaRefUpdateMove()
 {
     m_pDoc->InsertTab(0, "Sheet1");
@@ -1900,10 +1937,14 @@ void Test::testFormulaRefUpdateNamedExpressionMove()
 
 void Test::testFormulaRefUpdateNamedExpressionExpandRef()
 {
+    ScModule* pMod = SC_MOD();
+    ScInputOptions aOpt = pMod->GetInputOptions();
+    aOpt.SetExpandRefs(true); // turn on automatic range expansion.
+    pMod->SetInputOptions(aOpt);
+
     sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
 
     m_pDoc->InsertTab(0, "Test");
-    m_pDoc->SetExpandRefs(true); // turn on automatic range expansion.
 
     bool bInserted = m_pDoc->InsertNewRangeName("MyRange", ScAddress(0,0,0), "$A$1:$A$3");
     CPPUNIT_ASSERT(bInserted);


More information about the Libreoffice-commits mailing list