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 #pragma once
11 
12 #include "address.hxx"
13 
14 #include <vector>
15 #include <mdds/flat_segment_tree.hpp>
16 
17 class ScDocument;
18 class ScColumn;
19 class ScMarkData;
20 class ScRangeList;
21 struct ScSheetLimits;
22 
23 namespace sc {
24 
25 struct ColumnBlockConstPosition;
26 class SingleColumnSpanSet;
27 
28 struct RowSpan
29 {
32 
33  RowSpan(SCROW nRow1, SCROW nRow2);
34 };
35 
37 {
40 
41  ColRowSpan(SCCOLROW nStart, SCCOLROW nEnd);
42 };
43 
49 {
50 public:
51  typedef mdds::flat_segment_tree<SCROW, bool> ColumnSpansType;
52 
53 private:
54  struct ColumnType
55  {
56  ColumnSpansType maSpans;
57  ColumnSpansType::const_iterator miPos;
58 
59  ColumnType(SCROW nStart, SCROW nEnd, bool bInit);
60  };
61 
62  typedef std::vector<std::unique_ptr<ColumnType>> TableType;
63 
64  std::vector<std::unique_ptr<TableType>> maTables;
65 
66  ColumnType& getColumn(const ScDocument& rDoc, SCTAB nTab, SCCOL nCol);
67 
68 public:
69  class Action
70  {
71  public:
72  virtual ~Action() = 0;
73  virtual void startColumn(SCTAB nTab, SCCOL nCol);
74  virtual void execute(const ScAddress& rPos, SCROW nLength, bool bVal) = 0;
75  };
76 
78  {
79  public:
80  virtual ~ColumnAction() = 0;
81  virtual void startColumn(ScColumn* pCol) = 0;
82  virtual void execute(SCROW nRow1, SCROW nRow2, bool bVal) = 0;
83  };
84 
85  ColumnSpanSet();
86  ColumnSpanSet(const ColumnSpanSet&) = delete;
87  const ColumnSpanSet& operator=(const ColumnSpanSet&) = delete;
89 
90  void set(const ScDocument& rDoc, SCTAB nTab, SCCOL nCol, SCROW nRow, bool bVal);
91  void set(const ScDocument& rDoc, SCTAB nTab, SCCOL nCol, SCROW nRow1, SCROW nRow2, bool bVal);
92  void set(const ScDocument& rDoc, const ScRange& rRange, bool bVal);
93 
94  void set(const ScDocument& rDoc, SCTAB nTab, SCCOL nCol, const SingleColumnSpanSet& rSingleSet, bool bVal );
95 
100  void scan(const ScDocument& rDoc, SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, bool bVal);
101 
102  void executeAction(Action& ac) const;
103  void executeColumnAction(ScDocument& rDoc, ColumnAction& ac) const;
104 };
105 
110 {
111 public:
112  typedef mdds::flat_segment_tree<SCROW, bool> ColumnSpansType;
113 
114  typedef std::vector<RowSpan> SpansType;
115 
117 
121  void scan(const ScColumn& rColumn);
122 
127  void scan(const ScColumn& rColumn, SCROW nStart, SCROW nEnd);
128 
129  void scan(
130  ColumnBlockConstPosition& rBlockPos, const ScColumn& rColumn, SCROW nStart, SCROW nEnd);
131 
135  void scan(const ScMarkData& rMark, SCTAB nTab, SCCOL nCol);
136 
137  void scan(const ScRangeList& rRanges, SCTAB nTab, SCCOL nCol);
138 
139  void set(SCROW nRow1, SCROW nRow2, bool bVal);
140 
141  void getRows(std::vector<SCROW> &rRows) const;
142 
143  void getSpans(SpansType& rSpans) const;
144 
145  void swap( SingleColumnSpanSet& r );
146 
148  bool empty() const;
149 
150 private:
152  ColumnSpansType maSpans;
153 };
154 
159 {
160 public:
161  RangeColumnSpanSet( const ScRange& spanRange )
162  : range( spanRange ) {}
164 private:
166 };
167 
168 
169 }
170 
171 /* 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:42
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:23
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:21
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:17
RowSpan(SCROW nRow1, SCROW nRow2)
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:27
virtual void startColumn(ScColumn *pCol)=0
void executeAction(Action &ac) const
sal_Int16 SCTAB
Definition: types.hxx:22