kbrown / rpms / libreoffice

Forked from rpms/libreoffice 2 years ago
Clone

Blame SOURCES/0063-fdo-81617-Split-formula-groups-at-sort-range-boundar.patch

f085be
From 290d0d779551b84dfa42e0c026ce4d7c0f00ea7a Mon Sep 17 00:00:00 2001
f085be
From: Kohei Yoshida <kohei.yoshida@collabora.com>
f085be
Date: Sun, 27 Jul 2014 14:35:37 -0400
f085be
Subject: [PATCH 063/137] fdo#81617: Split formula groups at sort range
f085be
 boundaries.
f085be
f085be
Otherwise, partially sorting a range may crash, or at best incorrectly
f085be
update formula references.
f085be
f085be
Change-Id: Iefcb86d205d83ccc5b684048bfd9aadabf6e13eb
f085be
(cherry picked from commit a3fc7f20089062afa4f778e70ba8be84032a30a7)
f085be
Reviewed-on: https://gerrit.libreoffice.org/10583
f085be
Reviewed-by: Eike Rathke <erack@redhat.com>
f085be
Tested-by: Eike Rathke <erack@redhat.com>
f085be
---
f085be
 sc/inc/table.hxx               | 1 +
f085be
 sc/source/core/data/table3.cxx | 8 ++++++++
f085be
 sc/source/core/data/table7.cxx | 8 ++++++++
f085be
 3 files changed, 17 insertions(+)
f085be
f085be
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
f085be
index 97ee720..f8928de 100644
f085be
--- a/sc/inc/table.hxx
f085be
+++ b/sc/inc/table.hxx
f085be
@@ -888,6 +888,7 @@ public:
f085be
     formula::FormulaTokenRef ResolveStaticReference( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
f085be
     formula::VectorRefArray FetchVectorRefArray( SCCOL nCol, SCROW nRow1, SCROW nRow2 );
f085be
 
f085be
+    void SplitFormulaGroups( SCCOL nCol, std::vector<SCROW>& rRows );
f085be
     void UnshareFormulaCells( SCCOL nCol, std::vector<SCROW>& rRows );
f085be
     void RegroupFormulaCells( SCCOL nCol );
f085be
 
f085be
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
f085be
index 31cfe2e..3b63f7e 100644
f085be
--- a/sc/source/core/data/table3.cxx
f085be
+++ b/sc/source/core/data/table3.cxx
f085be
@@ -755,6 +755,14 @@ void ScTable::SortReorderByRow(
f085be
     ScSortInfoArray::RowsType* pRows = pArray->GetDataRows();
f085be
     assert(pRows); // In sort-by-row mode we must have data rows already populated.
f085be
 
f085be
+    // Split formula groups at the sort range boundaries (if applicable).
f085be
+    std::vector<SCROW> aRowBounds;
f085be
+    aRowBounds.reserve(2);
f085be
+    aRowBounds.push_back(nRow1);
f085be
+    aRowBounds.push_back(nRow2+1);
f085be
+    for (SCCOL nCol = nCol1; nCol <= nCol2; ++nCol)
f085be
+        SplitFormulaGroups(nCol, aRowBounds);
f085be
+
f085be
     // Cells in the data rows only reference values in the document. Make
f085be
     // a copy before updating the document.
f085be
 
f085be
diff --git a/sc/source/core/data/table7.cxx b/sc/source/core/data/table7.cxx
f085be
index f3528dd..b427617 100644
f085be
--- a/sc/source/core/data/table7.cxx
f085be
+++ b/sc/source/core/data/table7.cxx
f085be
@@ -79,6 +79,14 @@ bool ScTable::HasUniformRowHeight( SCROW nRow1, SCROW nRow2 ) const
f085be
     return nRow2 <= aData.mnRow2;
f085be
 }
f085be
 
f085be
+void ScTable::SplitFormulaGroups( SCCOL nCol, std::vector<SCROW>& rRows )
f085be
+{
f085be
+    if (!ValidCol(nCol))
f085be
+        return;
f085be
+
f085be
+    sc::SharedFormulaUtil::splitFormulaCellGroups(aCol[nCol].maCells, rRows);
f085be
+}
f085be
+
f085be
 void ScTable::UnshareFormulaCells( SCCOL nCol, std::vector<SCROW>& rRows )
f085be
 {
f085be
     if (!ValidCol(nCol))
f085be
-- 
f085be
1.9.3
f085be