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 <optional>
15#include <vector>
16#include <mdds/flat_segment_tree.hpp>
17
18class ScDocument;
19class ScColumn;
20class ScMarkData;
21class ScRangeList;
22struct ScSheetLimits;
23
24namespace sc {
25
26struct ColumnBlockConstPosition;
27class SingleColumnSpanSet;
28
29struct RowSpan
30{
33
34 RowSpan(SCROW nRow1, SCROW nRow2);
35};
36
38{
41
42 ColRowSpan(SCCOLROW nStart, SCCOLROW nEnd);
43};
44
50{
51public:
52 typedef mdds::flat_segment_tree<SCROW, bool> ColumnSpansType;
53
54private:
56 {
58 ColumnSpansType::const_iterator miPos;
59
60 ColumnType(SCROW nStart, SCROW nEnd, bool bInit);
61 ColumnType(const ColumnType& rOther);
62 };
63
64 typedef std::vector<std::optional<ColumnType>> TableType;
65
66 std::vector<TableType> maTables;
67
68 ColumnType& getColumn(const ScDocument& rDoc, SCTAB nTab, SCCOL nCol);
69
70public:
71 class Action
72 {
73 public:
74 virtual ~Action() = 0;
75 virtual void startColumn(SCTAB nTab, SCCOL nCol);
76 virtual void execute(const ScAddress& rPos, SCROW nLength, bool bVal) = 0;
77 };
78
80 {
81 public:
82 virtual ~ColumnAction() = 0;
83 virtual void startColumn(ScColumn* pCol) = 0;
84 virtual void execute(SCROW nRow1, SCROW nRow2, bool bVal) = 0;
85 };
86
88 ColumnSpanSet(const ColumnSpanSet&) = delete;
93
94 void set(const ScDocument& rDoc, SCTAB nTab, SCCOL nCol, SCROW nRow, bool bVal);
95 void set(const ScDocument& rDoc, SCTAB nTab, SCCOL nCol, SCROW nRow1, SCROW nRow2, bool bVal);
96 void set(const ScDocument& rDoc, const ScRange& rRange, bool bVal);
97
98 void set(const ScDocument& rDoc, SCTAB nTab, SCCOL nCol, const SingleColumnSpanSet& rSingleSet, bool bVal );
99
104 void scan(const ScDocument& rDoc, SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, bool bVal);
105
106 void executeAction(ScDocument& rDoc, Action& ac) const;
107 void executeColumnAction(ScDocument& rDoc, ColumnAction& ac) const;
108};
109
114{
115public:
116 typedef mdds::flat_segment_tree<SCROW, bool> ColumnSpansType;
117
118 typedef std::vector<RowSpan> SpansType;
119
121
125 void scan(const ScColumn& rColumn);
126
131 void scan(const ScColumn& rColumn, SCROW nStart, SCROW nEnd);
132
133 void scan(
134 ColumnBlockConstPosition& rBlockPos, const ScColumn& rColumn, SCROW nStart, SCROW nEnd);
135
139 void scan(const ScMarkData& rMark, SCTAB nTab, SCCOL nCol);
140
141 void scan(const ScRangeList& rRanges, SCTAB nTab, SCCOL nCol);
142
143 void set(SCROW nRow1, SCROW nRow2, bool bVal);
144
145 void getRows(std::vector<SCROW> &rRows) const;
146
147 void getSpans(SpansType& rSpans) const;
148
149 void swap( SingleColumnSpanSet& r );
150
152 bool empty() const;
153
154private:
157};
158
163{
164public:
165 RangeColumnSpanSet( const ScRange& spanRange )
166 : range( spanRange ) {}
168private:
170};
171
172
173}
174
175/* 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
virtual void startColumn(SCTAB nTab, SCCOL nCol)
virtual void execute(const ScAddress &rPos, SCROW nLength, bool bVal)=0
virtual void execute(SCROW nRow1, SCROW nRow2, bool bVal)=0
virtual void startColumn(ScColumn *pCol)=0
Structure that stores segments of boolean flags per column, and perform custom action on those segmen...
ColumnSpanSet & operator=(ColumnSpanSet &&)=default
mdds::flat_segment_tree< SCROW, bool > ColumnSpansType
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.
ColumnType & getColumn(const ScDocument &rDoc, SCTAB nTab, SCCOL nCol)
ColumnSpanSet(const ColumnSpanSet &)=delete
ColumnSpanSet(ColumnSpanSet &&)=default
std::vector< std::optional< ColumnType > > TableType
std::vector< TableType > maTables
ColumnSpanSet & operator=(const ColumnSpanSet &)=delete
void executeAction(ScDocument &rDoc, Action &ac) const
void executeColumnAction(ScDocument &rDoc, ColumnAction &ac) const
void set(const ScDocument &rDoc, SCTAB nTab, SCCOL nCol, SCROW nRow, bool bVal)
Optimized ColumnSpanSet version that operates on a single ScRange.
RangeColumnSpanSet(const ScRange &spanRange)
void executeColumnAction(ScDocument &rDoc, sc::ColumnSpanSet::ColumnAction &ac) const
Keep track of spans in a single column only.
void scan(const ScColumn &rColumn)
Scan an entire column and tag all non-empty cell positions.
ScSheetLimits const & mrSheetLimits
SingleColumnSpanSet(ScSheetLimits const &)
void swap(SingleColumnSpanSet &r)
std::vector< RowSpan > SpansType
void getSpans(SpansType &rSpans) const
void getRows(std::vector< SCROW > &rRows) const
bool empty() const
Whether there isn't any row tagged.
void set(SCROW nRow1, SCROW nRow2, bool bVal)
mdds::flat_segment_tree< SCROW, bool > ColumnSpansType
CAUTION! The following defines must be in the same namespace as the respective type.
Definition: broadcast.cxx:15
#define SC_DLLPUBLIC
Definition: scdllapi.h:27
ColumnType(SCROW nStart, SCROW nEnd, bool bInit)
ColumnSpansType::const_iterator miPos
RowSpan(SCROW nRow1, SCROW nRow2)
sal_Int32 SCCOLROW
a type capable of holding either SCCOL or SCROW
Definition: types.hxx:23
sal_Int16 SCTAB
Definition: types.hxx:22
sal_Int16 SCCOL
Definition: types.hxx:21
sal_Int32 SCROW
Definition: types.hxx:17