summaryrefslogtreecommitdiff
path: root/sc/inc
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@gmail.com>2013-07-01 23:08:14 -0400
committerKohei Yoshida <kohei.yoshida@gmail.com>2013-07-02 13:19:32 -0400
commitcfb2ce587b097b407eb15699cff7ce9fb6844123 (patch)
tree9ca222bdaf03e11ae3c3951ac84d0b3a2ce92aeb /sc/inc
parentdb377e02c309c20419aef1360409be09fe50fc42 (diff)
Re-implement the COUNT function for efficiency.
By taking advantage of the block structure of the new cell storage. Change-Id: Ib953c14d364ccdff7df5caf70d57cec86189e3be
Diffstat (limited to 'sc/inc')
-rw-r--r--sc/inc/column.hxx6
-rw-r--r--sc/inc/columnspanset.hxx29
-rw-r--r--sc/inc/document.hxx3
-rw-r--r--sc/inc/table.hxx4
4 files changed, 38 insertions, 4 deletions
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 6cc3c4b11a93..7ce53ade706c 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -44,6 +44,7 @@ namespace sc {
class CopyToClipContext;
class CopyToDocContext;
class MixDocContext;
+ class ColumnSpanSet;
struct ColumnBlockPosition;
class SingleColumnSpanSet;
}
@@ -116,7 +117,6 @@ class ScColumn
friend class ScDocument; // for FillInfo
friend class ScTable;
-friend class ScDocumentIterator;
friend class ScValueIterator;
friend class ScHorizontalValueIterator;
friend class ScDBQueryDataIterator;
@@ -127,6 +127,7 @@ friend class ScHorizontalAttrIterator;
friend class ScColumnTextWidthIterator;
friend class ScDocumentImport;
friend class sc::SingleColumnSpanSet;
+friend class sc::ColumnSpanSet;
ScColumn(const ScColumn&); // disabled
ScColumn& operator= (const ScColumn&); // disabled
@@ -242,6 +243,7 @@ public:
void SwapCol(ScColumn& rCol);
void MoveTo(SCROW nStartRow, SCROW nEndRow, ScColumn& rCol);
+ void MarkSubTotalCells( sc::ColumnSpanSet& rSet, SCROW nRow1, SCROW nRow2, bool bVal ) const;
bool HasEditCells(SCROW nStartRow, SCROW nEndRow, SCROW& rFirst);
@@ -407,6 +409,8 @@ public:
void ClearSelectionItems( const sal_uInt16* pWhich, const ScMarkData& rMark );
void ChangeSelectionIndent( bool bIncrement, const ScMarkData& rMark );
+ size_t CountNumericCells( sc::ColumnBlockConstPosition& rPos, SCROW nRow1, SCROW nRow2 ) const;
+
long GetNeededSize(
SCROW nRow, OutputDevice* pDev, double nPPTX, double nPPTY,
const Fraction& rZoomX, const Fraction& rZoomY,
diff --git a/sc/inc/columnspanset.hxx b/sc/inc/columnspanset.hxx
index 55c3f57507e9..98533e240f37 100644
--- a/sc/inc/columnspanset.hxx
+++ b/sc/inc/columnspanset.hxx
@@ -16,8 +16,10 @@
#include <mdds/flat_segment_tree.hpp>
#include <boost/noncopyable.hpp>
+class ScDocument;
class ScColumn;
class ScMarkData;
+class ScRange;
namespace sc {
@@ -30,12 +32,22 @@ struct ColumnBlockConstPosition;
class ColumnSpanSet : boost::noncopyable
{
typedef mdds::flat_segment_tree<SCROW, bool> ColumnSpansType;
- typedef std::vector<ColumnSpansType*> TableType;
+
+ struct ColumnType
+ {
+ ColumnSpansType maSpans;
+ ColumnSpansType::const_iterator miPos;
+
+ ColumnType(SCROW nStart, SCROW nEnd, bool bInit);
+ };
+
+ typedef std::vector<ColumnType*> TableType;
typedef std::vector<TableType*> DocType;
DocType maDoc;
+ bool mbInit;
- ColumnSpansType& getColumnSpans(SCTAB nTab, SCCOL nCol);
+ ColumnType& getColumn(SCTAB nTab, SCCOL nCol);
public:
class Action
@@ -46,12 +58,23 @@ public:
virtual void execute(const ScAddress& rPos, SCROW nLength, bool bVal) = 0;
};
+ class ColumnAction
+ {
+ public:
+ virtual ~ColumnAction() = 0;
+ virtual void startColumn(ScColumn* pCol) = 0;
+ virtual void execute(SCROW nRow1, SCROW nRow2, bool bVal) = 0;
+ };
+
+ ColumnSpanSet(bool bInit);
~ColumnSpanSet();
void set(SCTAB nTab, SCCOL nCol, SCROW nRow, bool bVal);
void set(SCTAB nTab, SCCOL nCol, SCROW nRow1, SCROW nRow2, bool bVal);
+ void set(const ScRange& rRange, bool bVal);
- void executeFromTop(Action& ac) const;
+ void executeAction(Action& ac) const;
+ void executeColumnAction(ScDocument& rDoc, ColumnAction& ac) const;
};
/**
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 806fb770e6a0..4d415659c24f 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -53,6 +53,7 @@ namespace sc {
class StartListeningContext;
class EndListeningContext;
class CopyFromClipContext;
+ class ColumnSpanSet;
struct ColumnBlockPosition;
}
class SvxFontItem;
@@ -228,6 +229,7 @@ friend class ScFormulaCell;
friend class ScTable;
friend struct ScRefCellValue;
friend class ScDocumentImport;
+friend class sc::ColumnSpanSet;
typedef ::std::vector<ScTable*> TableContainer;
private:
@@ -1960,6 +1962,7 @@ public:
void AddSubTotalCell(ScFormulaCell* pCell);
void RemoveSubTotalCell(ScFormulaCell* pCell);
void SetSubTotalCellsDirty(const ScRange& rDirtyRange);
+ void MarkSubTotalCells( sc::ColumnSpanSet& rSet, const ScRange& rRange, bool bVal ) const;
sal_uInt16 GetTextWidth( const ScAddress& rPos ) const;
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index 03060bb4f2f2..a8d51288a04a 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -57,6 +57,7 @@ namespace sc {
class CopyToClipContext;
class CopyToDocContext;
class MixDocContext;
+ class ColumnSpanSet;
struct ColumnBlockPosition;
}
@@ -203,6 +204,7 @@ friend class ScDocAttrIterator;
friend class ScAttrRectIterator;
friend class ScColumnTextWidthIterator;
friend class ScDocumentImport;
+friend class sc::ColumnSpanSet;
public:
ScTable( ScDocument* pDoc, SCTAB nNewTab, const OUString& rNewName,
@@ -231,6 +233,8 @@ public:
void RemoveSubTotals( ScSubTotalParam& rParam );
bool DoSubTotals( ScSubTotalParam& rParam );
+ void MarkSubTotalCells( sc::ColumnSpanSet& rSet, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, bool bVal ) const;
+
const ScSheetEvents* GetSheetEvents() const { return pSheetEvents; }
void SetSheetEvents( const ScSheetEvents* pNew );