Linux x86 build fix
[LibreOffice.git] / sc / inc / columnspanset.hxx
blob797b425579c5b064562472384b0a37e2e4814593
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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 */
10 #ifndef INCLUDED_SC_INC_COLUMNSPANSET_HXX
11 #define INCLUDED_SC_INC_COLUMNSPANSET_HXX
13 #include "address.hxx"
15 #include <vector>
16 #include <mdds/flat_segment_tree.hpp>
17 #include <boost/noncopyable.hpp>
19 class ScDocument;
20 class ScColumn;
21 class ScMarkData;
22 class ScRange;
23 class ScRangeList;
25 namespace sc {
27 struct ColumnBlockConstPosition;
28 class SingleColumnSpanSet;
30 struct RowSpan
32 SCROW mnRow1;
33 SCROW mnRow2;
35 RowSpan(SCROW nRow1, SCROW nRow2);
38 struct SC_DLLPUBLIC ColRowSpan
40 SCCOLROW mnStart;
41 SCCOLROW mnEnd;
43 ColRowSpan(SCCOLROW nStart, SCCOLROW nEnd);
46 /**
47 * Structure that stores segments of boolean flags per column, and perform
48 * custom action on those segments.
50 class ColumnSpanSet : boost::noncopyable
52 public:
53 typedef mdds::flat_segment_tree<SCROW, bool> ColumnSpansType;
55 private:
56 struct ColumnType
58 ColumnSpansType maSpans;
59 ColumnSpansType::const_iterator miPos;
61 ColumnType(SCROW nStart, SCROW nEnd, bool bInit);
64 typedef std::vector<ColumnType*> TableType;
65 typedef std::vector<TableType*> DocType;
67 DocType maDoc;
68 bool mbInit;
70 ColumnType& getColumn(SCTAB nTab, SCCOL nCol);
72 public:
73 class Action
75 public:
76 virtual ~Action() = 0;
77 virtual void startColumn(SCTAB nTab, SCCOL nCol);
78 virtual void execute(const ScAddress& rPos, SCROW nLength, bool bVal) = 0;
81 class ColumnAction
83 public:
84 virtual ~ColumnAction() = 0;
85 virtual void startColumn(ScColumn* pCol) = 0;
86 virtual void execute(SCROW nRow1, SCROW nRow2, bool bVal) = 0;
89 ColumnSpanSet(bool bInit);
90 ~ColumnSpanSet();
92 void set(SCTAB nTab, SCCOL nCol, SCROW nRow, bool bVal);
93 void set(SCTAB nTab, SCCOL nCol, SCROW nRow1, SCROW nRow2, bool bVal);
94 void set(const ScRange& rRange, bool bVal);
96 void set( SCTAB nTab, SCCOL nCol, const SingleColumnSpanSet& rSingleSet, bool bVal );
98 /**
99 * Scan specified range in a specified sheet and mark all non-empty cells
100 * with specified boolean value.
102 void scan(const ScDocument& rDoc, SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, bool bVal);
104 void executeAction(Action& ac) const;
105 void executeColumnAction(ScDocument& rDoc, ColumnAction& ac) const;
107 void swap( ColumnSpanSet& r );
111 * Keep track of spans in a single column only.
113 class SingleColumnSpanSet
115 public:
116 typedef mdds::flat_segment_tree<SCROW, bool> ColumnSpansType;
118 typedef std::vector<RowSpan> SpansType;
120 SingleColumnSpanSet();
123 * Scan an entire column and tag all non-empty cell positions.
125 void scan(const ScColumn& rColumn);
128 * Scan a column between specified range, and tag all non-empty cell
129 * positions.
131 void scan(const ScColumn& rColumn, SCROW nStart, SCROW nEnd);
133 void scan(
134 ColumnBlockConstPosition& rBlockPos, const ScColumn& rColumn, SCROW nStart, SCROW nEnd);
137 * Scan all marked data and tag all marked segments in specified column.
139 void scan(const ScMarkData& rMark, SCTAB nTab, SCCOL nCol);
141 void scan(const ScRangeList& rRanges, SCTAB nTab, SCCOL nCol);
143 void set(SCROW nRow1, SCROW nRow2, bool bVal);
145 void getRows(std::vector<SCROW> &rRows) const;
147 void getSpans(SpansType& rSpans) const;
149 void swap( SingleColumnSpanSet& r );
151 private:
152 ColumnSpansType maSpans;
157 #endif
159 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */