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

Kohei Yoshida kohei.yoshida at collabora.com
Mon Oct 27 08:54:46 PDT 2014


 sc/qa/unit/ucalc_sort.cxx      |   34 +++++++++++++++++++++++++++++++++-
 sc/source/core/data/table3.cxx |   15 +++++++++++++++
 2 files changed, 48 insertions(+), 1 deletion(-)

New commits:
commit 0b3f0f0bad8752c2ff2a1933ced57874ee846805
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Mon Oct 27 08:53:33 2014 -0700

    fdo#85215: Write test for this.
    
    Change-Id: I789da5d81e6211ed8f5fae1e293833bde5ce375b

diff --git a/sc/qa/unit/ucalc_sort.cxx b/sc/qa/unit/ucalc_sort.cxx
index d0997c3..a1189dd 100644
--- a/sc/qa/unit/ucalc_sort.cxx
+++ b/sc/qa/unit/ucalc_sort.cxx
@@ -18,6 +18,7 @@
 #include <scopetools.hxx>
 #include <globalnames.hxx>
 #include <dbdocfun.hxx>
+#include <docfunc.hxx>
 #include <scitems.hxx>
 #include <editutil.hxx>
 
@@ -1430,7 +1431,38 @@ void Test::testSortRefUpdate6()
             { "9", "1", "7" },
         };
 
-        bool bSuccess = checkOutput<3>(m_pDoc, aDataRange, aOutputCheck, "Sorted without reference update");
+        bool bSuccess = checkOutput<3>(m_pDoc, aDataRange, aOutputCheck, "After redo");
+        CPPUNIT_ASSERT_MESSAGE("Table output check failed", bSuccess);
+    }
+
+    // Change the value of C1 and make sure the formula broadcasting chain still works.
+    ScDocFunc& rFunc = getDocShell().GetDocFunc();
+    rFunc.SetValueCell(ScAddress(2,0,0), 11.0, false);
+    {
+        // Expected output table content.  0 = empty cell
+        const char* aOutputCheck[][3] = {
+            { "Order", "Value", "11" },
+            { "1", "2", "13" },
+            { "8", "3", "16" },
+            { "9", "1", "17" },
+        };
+
+        bool bSuccess = checkOutput<3>(m_pDoc, aDataRange, aOutputCheck, "Change the header value");
+        CPPUNIT_ASSERT_MESSAGE("Table output check failed", bSuccess);
+    }
+
+    // Undo and check.
+    pUndoMgr->Undo();
+    {
+        // Expected output table content.  0 = empty cell
+        const char* aOutputCheck[][3] = {
+            { "Order", "Value", "1" },
+            { "1", "2", "3" },
+            { "8", "3", "6" },
+            { "9", "1", "7" },
+        };
+
+        bool bSuccess = checkOutput<3>(m_pDoc, aDataRange, aOutputCheck, "After undo of header value change");
         CPPUNIT_ASSERT_MESSAGE("Table output check failed", bSuccess);
     }
 
commit 1eb82c78a223d9a0b2bb5c3f5c129c1ee8bdf303
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Mon Oct 27 08:52:38 2014 -0700

    fdo#85215: Ensure that formula broadcasting works after sort.
    
    When the reference update on sort is turned off.
    
    Change-Id: I547dd1525a638dd447fe331e22583af4a7947308

diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index 3e8250a..04bbbce 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -801,6 +801,15 @@ void ScTable::SortReorderByRow(
     ScSortInfoArray::RowsType* pRows = pArray->GetDataRows();
     assert(pRows); // In sort-by-row mode we must have data rows already populated.
 
+    if (!pArray->IsUpdateRefs())
+    {
+        // When the update ref mode is disabled, we need to detach all formula
+        // cells in the sorted range before reordering, and re-start them
+        // afterward.
+        sc::EndListeningContext aCxt(*pDocument);
+        DetachFormulaCells(aCxt, nCol1, nRow1, nCol2, nRow2);
+    }
+
     // Split formula groups at the sort range boundaries (if applicable).
     std::vector<SCROW> aRowBounds;
     aRowBounds.reserve(2);
@@ -1081,6 +1090,12 @@ void ScTable::SortReorderByRow(
     // Re-group columns in the sorted range too.
     for (SCCOL i = nCol1; i <= nCol2; ++i)
         aCol[i].RegroupFormulaCells();
+
+    if (!pArray->IsUpdateRefs())
+    {
+        sc::StartListeningContext aCxt(*pDocument);
+        AttachFormulaCells(aCxt, nCol1, nRow1, nCol2, nRow2);
+    }
 }
 
 short ScTable::CompareCell(


More information about the Libreoffice-commits mailing list