summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2018-09-21 12:59:08 +0200
committerLuboš Luňák <l.lunak@collabora.com>2018-10-10 13:00:37 +0200
commit18ff25ff596552ee2755b41af11c9e1ec95fd2e7 (patch)
tree1601ad4c64e3a00a078283a5c91b68604c84b8c7 /sc
parentcaf0595f05c0b9199c28c96415878ffc22cb05ec (diff)
ColumnSpanSet variant optimized for just one ScRange
Since ScInterpreter::IterateParameters() iterates over just one range, there's no point to to set flags for that range and then generically walk over that range, just directly use the range. Change-Id: I13003eb09bd98f145e9ead5e485596168d9399cb Reviewed-on: https://gerrit.libreoffice.org/60866 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/columnspanset.hxx16
-rw-r--r--sc/inc/document.hxx2
-rw-r--r--sc/inc/table.hxx2
-rw-r--r--sc/qa/unit/ucalc.cxx1
-rw-r--r--sc/source/core/data/columnspanset.cxx60
-rw-r--r--sc/source/core/data/table4.cxx1
-rw-r--r--sc/source/core/tool/interpr6.cxx3
-rw-r--r--sc/source/ui/vba/vbarange.cxx1
-rw-r--r--sc/source/ui/view/preview.cxx1
-rw-r--r--sc/source/ui/view/viewfun2.cxx1
10 files changed, 81 insertions, 7 deletions
diff --git a/sc/inc/columnspanset.hxx b/sc/inc/columnspanset.hxx
index 17bccaa57236..4eb83b916deb 100644
--- a/sc/inc/columnspanset.hxx
+++ b/sc/inc/columnspanset.hxx
@@ -154,6 +154,22 @@ private:
ColumnSpansType maSpans;
};
+/**
+ * Optimized ColumnSpanSet version that operates on a single ScRange.
+ */
+class RangeColumnSpanSet
+{
+public:
+ RangeColumnSpanSet( const ScRange& spanRange )
+ : range( spanRange ) {}
+ void executeAction(ScDocument& rDoc, sc::ColumnSpanSet::Action& ac) const;
+ void executeColumnAction(ScDocument& rDoc, sc::ColumnSpanSet::ColumnAction& ac) const;
+ void executeColumnAction(ScDocument& rDoc, sc::ColumnSpanSet::ColumnAction& ac, double& fMem) const;
+private:
+ ScRange range;
+};
+
+
}
#endif
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 931188800862..06c155a07aa4 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -74,6 +74,7 @@ class StartListeningContext;
class EndListeningContext;
class CopyFromClipContext;
class ColumnSpanSet;
+class RangeColumnSpanSet;
struct ColumnBlockPosition;
struct RefUpdateContext;
class EditTextIterator;
@@ -322,6 +323,7 @@ friend struct ScRefCellValue;
friend class ScDocumentImport;
friend class sc::DocumentStreamAccess;
friend class sc::ColumnSpanSet;
+friend class sc::RangeColumnSpanSet;
friend class sc::EditTextIterator;
friend class sc::FormulaGroupAreaListener;
friend class sc::TableColumnBlockPositionSet;
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index e9aee6b689a5..85699da8c890 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -60,6 +60,7 @@ class CopyToClipContext;
class CopyToDocContext;
class MixDocContext;
class ColumnSpanSet;
+class RangeColumnSpanSet;
class ColumnSet;
struct ColumnBlockPosition;
struct RefUpdateContext;
@@ -255,6 +256,7 @@ friend class ScColumnTextWidthIterator;
friend class ScDocumentImport;
friend class sc::DocumentStreamAccess;
friend class sc::ColumnSpanSet;
+friend class sc::RangeColumnSpanSet;
friend class sc::EditTextIterator;
friend class sc::FormulaGroupAreaListener;
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index aae265dacd9d..ee1c7da229cd 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -58,7 +58,6 @@
#include <cellform.hxx>
#include <asciiopt.hxx>
#include <impex.hxx>
-#include <columnspanset.hxx>
#include <docoptio.hxx>
#include <patattr.hxx>
#include <docpool.hxx>
diff --git a/sc/source/core/data/columnspanset.cxx b/sc/source/core/data/columnspanset.cxx
index f6b54d9314fc..b9651ce4ef05 100644
--- a/sc/source/core/data/columnspanset.cxx
+++ b/sc/source/core/data/columnspanset.cxx
@@ -378,6 +378,66 @@ bool SingleColumnSpanSet::empty() const
return (it->first == 0) && !(it->second) && (++it != maSpans.end()) && (it->first == MAXROWCOUNT);
}
+
+void RangeColumnSpanSet::executeAction(ScDocument& rDoc, sc::ColumnSpanSet::Action& ac) const
+{
+ for (SCTAB nTab = range.aStart.Tab(); nTab <= range.aEnd.Tab(); ++nTab)
+ {
+ for (SCCOL nCol = range.aStart.Col(); nCol <= range.aEnd.Col(); ++nCol)
+ {
+ ScTable* pTab = rDoc.FetchTable(nTab);
+ if (!pTab)
+ continue;
+
+ if (!ValidCol(nCol))
+ break;
+
+ ac.startColumn(nTab, nCol);
+ ac.execute(ScAddress(nCol, range.aStart.Row(), nTab), range.aEnd.Row() - range.aStart.Row() + 1, true);
+ }
+ }
+}
+
+void RangeColumnSpanSet::executeColumnAction(ScDocument& rDoc, sc::ColumnSpanSet::ColumnAction& ac) const
+{
+ for (SCTAB nTab = range.aStart.Tab(); nTab <= range.aEnd.Tab(); ++nTab)
+ {
+ for (SCCOL nCol = range.aStart.Col(); nCol <= range.aEnd.Col(); ++nCol)
+ {
+ ScTable* pTab = rDoc.FetchTable(nTab);
+ if (!pTab)
+ continue;
+
+ if (!ValidCol(nCol))
+ break;
+
+ ScColumn& rColumn = pTab->aCol[nCol];
+ ac.startColumn(&rColumn);
+ ac.execute( range.aStart.Row(), range.aEnd.Row(), true );
+ }
+ }
+}
+
+void RangeColumnSpanSet::executeColumnAction(ScDocument& rDoc, sc::ColumnSpanSet::ColumnAction& ac, double& fMem) const
+{
+ for (SCTAB nTab = range.aStart.Tab(); nTab <= range.aEnd.Tab(); ++nTab)
+ {
+ for (SCCOL nCol = range.aStart.Col(); nCol <= range.aEnd.Col(); ++nCol)
+ {
+ ScTable* pTab = rDoc.FetchTable(nTab);
+ if (!pTab)
+ continue;
+
+ if (!ValidCol(nCol))
+ break;
+
+ ScColumn& rColumn = pTab->aCol[nCol];
+ ac.startColumn(&rColumn);
+ ac.executeSum( range.aStart.Row(), range.aEnd.Row(), true, fMem );
+ }
+ }
}
+} // namespace sc
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/data/table4.cxx b/sc/source/core/data/table4.cxx
index a565ab8433a0..860f8a51bd41 100644
--- a/sc/source/core/data/table4.cxx
+++ b/sc/source/core/data/table4.cxx
@@ -59,7 +59,6 @@
#include <segmenttree.hxx>
#include <conditio.hxx>
#include <editutil.hxx>
-#include <columnspanset.hxx>
#include <listenercontext.hxx>
#include <math.h>
diff --git a/sc/source/core/tool/interpr6.cxx b/sc/source/core/tool/interpr6.cxx
index f54dacf2b20f..466cbb307f12 100644
--- a/sc/source/core/tool/interpr6.cxx
+++ b/sc/source/core/tool/interpr6.cxx
@@ -819,8 +819,7 @@ void ScInterpreter::IterateParameters( ScIterFunc eFunc, bool bTextAsZero )
}
else if ( ( eFunc == ifSUM || eFunc == ifCOUNT ) && mnSubTotalFlags == SubtotalFlags::NONE )
{
- sc::ColumnSpanSet aSet( false );
- aSet.set( aRange, true );
+ sc::RangeColumnSpanSet aSet( aRange );
if ( eFunc == ifSUM )
{
diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx
index e36dfc298e77..a806f89ddade 100644
--- a/sc/source/ui/vba/vbarange.cxx
+++ b/sc/source/ui/vba/vbarange.cxx
@@ -176,7 +176,6 @@
#include <com/sun/star/bridge/oleautomation/Date.hpp>
#include <tokenarray.hxx>
#include <tokenuno.hxx>
-#include <columnspanset.hxx>
#include <memory>
diff --git a/sc/source/ui/view/preview.cxx b/sc/source/ui/view/preview.cxx
index 304be3fc5f1f..ec9206921c9c 100644
--- a/sc/source/ui/view/preview.cxx
+++ b/sc/source/ui/view/preview.cxx
@@ -63,7 +63,6 @@
#include <AccessibilityHints.hxx>
#include <vcl/svapp.hxx>
#include <viewutil.hxx>
-#include <columnspanset.hxx>
#include <docpool.hxx>
#include <patattr.hxx>
diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx
index a60715eba83f..2fef51b340c7 100644
--- a/sc/source/ui/view/viewfun2.cxx
+++ b/sc/source/ui/view/viewfun2.cxx
@@ -83,7 +83,6 @@
#include <prnsave.hxx>
#include <searchresults.hxx>
#include <tokenarray.hxx>
-#include <columnspanset.hxx>
#include <rowheightcontext.hxx>
#include <LibreOfficeKit/LibreOfficeKitEnums.h>
#include <comphelper/lok.hxx>