[Libreoffice-commits] core.git: Branch 'libreoffice-4-3' - sc/inc sc/source
Seyeong Kim
seyeong.kim at canonical.com
Mon Nov 24 01:42:01 PST 2014
sc/inc/column.hxx | 3 ++-
sc/inc/columnspanset.hxx | 3 +++
sc/source/core/data/column2.cxx | 4 ++--
sc/source/core/data/columnspanset.cxx | 12 ++++++++++--
sc/source/core/data/table2.cxx | 31 +++++++++++++++++++++++--------
sc/source/core/data/table3.cxx | 4 +++-
6 files changed, 43 insertions(+), 14 deletions(-)
New commits:
commit ec4d045328d4651fe666169272fc5a2d0bcd1362
Author: Seyeong Kim <seyeong.kim at canonical.com>
Date: Sat Aug 16 05:25:32 2014 +0200
fdo#77382, lp#1342175: fix poor performance with find & replace with empty value
this cherry-picks three master commits:
1cf19ea84794ca065749667b480dfed2d27d47b7
don't call ScMarkData::GetMarkedRanges in ScColumn, related fdo#79422
1e721077b43de84edab2a3ed2f316ddcbec6e3ec
fdo#83141: optimize slow performance after when using replaceall or searchall
Reviewed-on: https://gerrit.libreoffice.org/11829
91502a72c12c559442e8bf77c27a516b49c2a68d
fdo#83141: also optimize ScTable::HasAttribSelection
Reviewed-on: https://gerrit.libreoffice.org/11877
Change-Id: I2df0eeefbe27b6a267e960f9ffedab0d4774c8a8
Reviewed-on: https://gerrit.libreoffice.org/13041
Reviewed-by: Seyeong Kim <seyeong.kim at canonical.com>
Reviewed-by: Björn Michaelsen <bjoern.michaelsen at canonical.com>
Tested-by: Björn Michaelsen <bjoern.michaelsen at canonical.com>
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index d2b7799..8f8a93c 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -24,6 +24,7 @@
#include "global.hxx"
#include "address.hxx"
#include "rangenam.hxx"
+#include "rangelst.hxx"
#include "types.hxx"
#include "mtvelements.hxx"
#include <formula/types.hxx>
@@ -262,7 +263,7 @@ public:
ScAttrIterator* CreateAttrIterator( SCROW nStartRow, SCROW nEndRow ) const;
void UpdateSelectionFunction(
- const ScMarkData& rMark, ScFunctionData& rData, ScFlatBoolRowSegments& rHiddenRows );
+ const ScRangeList& rRanges, ScFunctionData& rData, ScFlatBoolRowSegments& rHiddenRows );
void CopyToColumn(
sc::CopyToDocContext& rCxt, SCROW nRow1, SCROW nRow2, sal_uInt16 nFlags, bool bMarked,
diff --git a/sc/inc/columnspanset.hxx b/sc/inc/columnspanset.hxx
index 7c7fdf5..f397c3e 100644
--- a/sc/inc/columnspanset.hxx
+++ b/sc/inc/columnspanset.hxx
@@ -20,6 +20,7 @@ class ScDocument;
class ScColumn;
class ScMarkData;
class ScRange;
+class ScRangeList;
namespace sc {
@@ -132,6 +133,8 @@ public:
*/
void scan(const ScMarkData& rMark, SCTAB nTab, SCCOL nCol);
+ void scan(const ScRangeList& rRanges, SCTAB nTab, SCCOL nCol);
+
void set(SCROW nRow1, SCROW nRow2, bool bVal);
void getRows(std::vector<SCROW> &rRows) const;
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index c19be82..08a00c0 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -3072,10 +3072,10 @@ public:
// multiple selections:
void ScColumn::UpdateSelectionFunction(
- const ScMarkData& rMark, ScFunctionData& rData, ScFlatBoolRowSegments& rHiddenRows )
+ const ScRangeList& rRanges, ScFunctionData& rData, ScFlatBoolRowSegments& rHiddenRows )
{
sc::SingleColumnSpanSet aSpanSet;
- aSpanSet.scan(rMark, nTab, nCol); // mark all selected rows.
+ aSpanSet.scan(rRanges, nTab, nCol); // mark all selected rows.
// Exclude all hidden rows.
ScFlatBoolRowSegments::RangeData aRange;
diff --git a/sc/source/core/data/columnspanset.cxx b/sc/source/core/data/columnspanset.cxx
index e431361..faf99ad 100644
--- a/sc/source/core/data/columnspanset.cxx
+++ b/sc/source/core/data/columnspanset.cxx
@@ -278,9 +278,17 @@ void SingleColumnSpanSet::scan(const ScMarkData& rMark, SCTAB nTab, SCCOL nCol)
return;
ScRangeList aRanges = rMark.GetMarkedRanges();
- for (size_t i = 0, n = aRanges.size(); i < n; ++i)
+ scan(aRanges, nTab, nCol);
+}
+
+void SingleColumnSpanSet::scan(const ScRangeList& rRanges, SCTAB nTab, SCCOL nCol)
+{
+ for (size_t i = 0, n = rRanges.size(); i < n; ++i)
{
- const ScRange* p = aRanges[i];
+ const ScRange* p = rRanges[i];
+ if (nTab < p->aStart.Tab() || p->aEnd.Tab() < nTab)
+ continue;
+
if (nCol < p->aStart.Col() || p->aEnd.Col() < nCol)
// This column is not in this range. Skip it.
continue;
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index 9b4fd02..8f81660 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -50,6 +50,7 @@
#include "refupdatecontext.hxx"
#include "scopetools.hxx"
#include "tabprotection.hxx"
+#include "columnspanset.hxx"
#include <rowheightcontext.hxx>
#include <refhint.hxx>
@@ -1887,10 +1888,17 @@ bool ScTable::HasAttrib( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, sal
bool ScTable::HasAttribSelection( const ScMarkData& rMark, sal_uInt16 nMask ) const
{
- bool bFound = false;
- for (SCCOL i=0; i<=MAXCOL && !bFound; i++)
- bFound |= aCol[i].HasAttribSelection( rMark, nMask );
- return bFound;
+ std::vector<sc::ColRowSpan> aSpans = rMark.GetMarkedColSpans();
+
+ for (size_t i = 0; i < aSpans.size(); ++i)
+ {
+ for (SCCOLROW j = aSpans[i].mnStart; j < aSpans[i].mnEnd; ++j)
+ {
+ if (aCol[j].HasAttribSelection(rMark, nMask))
+ return true;
+ }
+ }
+ return false;
}
@@ -2161,10 +2169,17 @@ bool ScTable::HasBlockMatrixFragment( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCR
bool ScTable::HasSelectionMatrixFragment( const ScMarkData& rMark ) const
{
- bool bFound = false;
- for (SCCOL i=0; i<=MAXCOL && !bFound; i++)
- bFound |= aCol[i].HasSelectionMatrixFragment(rMark);
- return bFound;
+ std::vector<sc::ColRowSpan> aSpans = rMark.GetMarkedColSpans();
+
+ for ( size_t i=0; i<aSpans.size(); i++ )
+ {
+ for ( SCCOLROW j=aSpans[i].mnStart; j<aSpans[i].mnEnd; j++ )
+ {
+ if ( aCol[j].HasSelectionMatrixFragment(rMark) )
+ return true;
+ }
+ }
+ return false;
}
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index f7589dd..af9793d 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -62,6 +62,7 @@
#include <refhint.hxx>
#include <listenerquery.hxx>
#include <bcaslot.hxx>
+#include "rangelst.hxx"
#include <svl/sharedstringpool.hxx>
@@ -3029,12 +3030,13 @@ sal_Int32 ScTable::GetMaxNumberStringLen(
void ScTable::UpdateSelectionFunction( ScFunctionData& rData, const ScMarkData& rMark )
{
+ ScRangeList aRanges = rMark.GetMarkedRanges();
for (SCCOL nCol = 0; nCol <= MAXCOL && !rData.bError; ++nCol)
{
if (pColFlags && ColHidden(nCol))
continue;
- aCol[nCol].UpdateSelectionFunction(rMark, rData, *mpHiddenRows);
+ aCol[nCol].UpdateSelectionFunction(aRanges, rData, *mpHiddenRows);
}
}
More information about the Libreoffice-commits
mailing list