LibreOffice Module sc (master)  1
columnspanset.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  */
9 
10 #ifndef INCLUDED_SC_INC_COLUMNSPANSET_HXX
11 #define INCLUDED_SC_INC_COLUMNSPANSET_HXX
12 
13 #include "address.hxx"
14 
15 #include <vector>
16 #include <mdds/flat_segment_tree.hpp>
17 
18 class ScDocument;
19 class ScColumn;
20 class ScMarkData;
21 class ScRangeList;
22 struct ScSheetLimits;
23 
24 namespace sc {
25 
26 struct ColumnBlockConstPosition;
27 class SingleColumnSpanSet;
28 
29 struct RowSpan
30 {
33 
34  RowSpan(SCROW nRow1, SCROW nRow2);
35 };
36 
38 {
41 
42  ColRowSpan(SCCOLROW nStart, SCCOLROW nEnd);
43 };
44 
50 {
51 public:
52  typedef mdds::flat_segment_tree<SCROW, bool> ColumnSpansType;
53 
54 private:
55  struct ColumnType
56  {
57  ColumnSpansType maSpans;
58  ColumnSpansType::const_iterator miPos;
59 
60  ColumnType(SCROW nStart, SCROW nEnd, bool bInit);
61  };
62 
63  typedef std::vector<std::unique_ptr<ColumnType>> TableType;
64 
65  std::vector<std::unique_ptr<TableType>> maTables;
66 
67  ColumnType& getColumn(const ScDocument& rDoc, SCTAB nTab, SCCOL nCol);
68 
69 public:
70  class Action
71  {
72  public:
73  virtual ~Action() = 0;
74  virtual void startColumn(SCTAB nTab, SCCOL nCol);
75  virtual void execute(const ScAddress& rPos, SCROW nLength, bool bVal) = 0;
76  };
77 
79  {
80  public:
81  virtual ~ColumnAction() = 0;
82  virtual void startColumn(ScColumn* pCol) = 0;
83  virtual void execute(SCROW nRow1, SCROW nRow2, bool bVal) = 0;
84  virtual void executeSum(SCROW, SCROW, bool, double& ) { return; } ;
85  };
86 
87  ColumnSpanSet();
88  ColumnSpanSet(const ColumnSpanSet&) = delete;
89  const ColumnSpanSet& operator=(const ColumnSpanSet&) = delete;
91 
92  void set(const ScDocument& rDoc, SCTAB nTab, SCCOL nCol, SCROW nRow, bool bVal);
93  void set(const ScDocument& rDoc, SCTAB nTab, SCCOL nCol, SCROW nRow1, SCROW nRow2, bool bVal);
94  void set(const ScDocument& rDoc, const ScRange& rRange, bool bVal);
95 
96  void set(const ScDocument& rDoc, SCTAB nTab, SCCOL nCol, const SingleColumnSpanSet& rSingleSet, bool bVal );
97 
102  void scan(const ScDocument& rDoc, SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, bool bVal);
103 
104  void executeAction(Action& ac) const;
105  void executeColumnAction(ScDocument& rDoc, ColumnAction& ac) const;
106 };
107 
112 {
113 public:
114  typedef mdds::flat_segment_tree<SCROW, bool> ColumnSpansType;
115 
116  typedef std::vector<RowSpan> SpansType;
117 
119 
123  void scan(const ScColumn& rColumn);
124 
129  void scan(const ScColumn& rColumn, SCROW nStart, SCROW nEnd);
130 
131  void scan(
132  ColumnBlockConstPosition& rBlockPos, const ScColumn& rColumn, SCROW nStart, SCROW nEnd);
133 
137  void scan(const ScMarkData& rMark, SCTAB nTab, SCCOL nCol);
138 
139  void scan(const ScRangeList& rRanges, SCTAB nTab, SCCOL nCol);
140 
141  void set(SCROW nRow1, SCROW nRow2, bool bVal);
142 
143  void getRows(std::vector<SCROW> &rRows) const;
144 
145  void getSpans(SpansType& rSpans) const;
146 
147  void swap( SingleColumnSpanSet& r );
148 
150  bool empty() const;
151 
152 private:
154  ColumnSpansType maSpans;
155 };
156 
161 {
162 public:
163  RangeColumnSpanSet( const ScRange& spanRange )
164  : range( spanRange ) {}
166  void executeColumnAction(ScDocument& rDoc, sc::ColumnSpanSet::ColumnAction& ac, double& fMem) const;
167 private:
169 };
170 
171 
172 }
173 
174 #endif
175 
176 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
todo: It should be possible to have MarkArrays for each table, in order to enable "search all" across...
Definition: markdata.hxx:43
ColumnType & getColumn(const ScDocument &rDoc, SCTAB nTab, SCCOL nCol)
virtual void execute(const ScAddress &rPos, SCROW nLength, bool bVal)=0
virtual void startColumn(SCTAB nTab, SCCOL nCol)
void scan(const ScDocument &rDoc, SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, bool bVal)
Scan specified range in a specified sheet and mark all non-empty cells with specified boolean value...
mdds::flat_segment_tree< SCROW, bool > ColumnSpansType
mdds::flat_segment_tree< SCROW, bool > ColumnSpansType
bool empty() const
Whether there isn't any row tagged.
ScSheetLimits const & mrSheetLimits
Keep track of spans in a single column only.
sal_Int32 SCCOLROW
a type capable of holding either SCCOL or SCROW
Definition: types.hxx:24
void set(const ScDocument &rDoc, SCTAB nTab, SCCOL nCol, SCROW nRow, bool bVal)
Optimized ColumnSpanSet version that operates on a single ScRange.
void executeColumnAction(ScDocument &rDoc, ColumnAction &ac) const
void getSpans(SpansType &rSpans) const
sal_Int16 SCCOL
Definition: types.hxx:22
void getRows(std::vector< SCROW > &rRows) const
void set(SCROW nRow1, SCROW nRow2, bool bVal)
Structure that stores segments of boolean flags per column, and perform custom action on those segmen...
const ColumnSpanSet & operator=(const ColumnSpanSet &)=delete
RangeColumnSpanSet(const ScRange &spanRange)
ColumnSpansType::const_iterator miPos
sal_Int32 SCROW
Definition: types.hxx:18
RowSpan(SCROW nRow1, SCROW nRow2)
virtual void executeSum(SCROW, SCROW, bool, double &)
std::vector< RowSpan > SpansType
ColumnType(SCROW nStart, SCROW nEnd, bool bInit)
void scan(const ScColumn &rColumn)
Scan an entire column and tag all non-empty cell positions.
void executeColumnAction(ScDocument &rDoc, sc::ColumnSpanSet::ColumnAction &ac) const
sal_Int32 nLength
SingleColumnSpanSet(ScSheetLimits const &)
void swap(SingleColumnSpanSet &r)
virtual void execute(SCROW nRow1, SCROW nRow2, bool bVal)=0
std::vector< std::unique_ptr< TableType > > maTables
std::vector< std::unique_ptr< ColumnType > > TableType
#define SC_DLLPUBLIC
Definition: scdllapi.h:28
virtual void startColumn(ScColumn *pCol)=0
void executeAction(Action &ac) const
sal_Int16 SCTAB
Definition: types.hxx:23