1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/.
10 #ifndef SC_COLUMNSPANSET_HXX
11 #define SC_COLUMNSPANSET_HXX
13 #include "address.hxx"
16 #include <mdds/flat_segment_tree.hpp>
17 #include <boost/noncopyable.hpp>
26 struct ColumnBlockConstPosition
;
29 * Structure that stores segments of boolean flags per column, and perform
30 * custom action on those segments.
32 class ColumnSpanSet
: boost::noncopyable
34 typedef mdds::flat_segment_tree
<SCROW
, bool> ColumnSpansType
;
38 ColumnSpansType maSpans
;
39 ColumnSpansType::const_iterator miPos
;
41 ColumnType(SCROW nStart
, SCROW nEnd
, bool bInit
);
44 typedef std::vector
<ColumnType
*> TableType
;
45 typedef std::vector
<TableType
*> DocType
;
50 ColumnType
& getColumn(SCTAB nTab
, SCCOL nCol
);
56 virtual ~Action() = 0;
57 virtual void startColumn(SCTAB nTab
, SCCOL nCol
);
58 virtual void execute(const ScAddress
& rPos
, SCROW nLength
, bool bVal
) = 0;
64 virtual ~ColumnAction() = 0;
65 virtual void startColumn(ScColumn
* pCol
) = 0;
66 virtual void execute(SCROW nRow1
, SCROW nRow2
, bool bVal
) = 0;
69 ColumnSpanSet(bool bInit
);
72 void set(SCTAB nTab
, SCCOL nCol
, SCROW nRow
, bool bVal
);
73 void set(SCTAB nTab
, SCCOL nCol
, SCROW nRow1
, SCROW nRow2
, bool bVal
);
74 void set(const ScRange
& rRange
, bool bVal
);
76 void executeAction(Action
& ac
) const;
77 void executeColumnAction(ScDocument
& rDoc
, ColumnAction
& ac
) const;
81 * Keep track of spans in a single column only.
83 class SingleColumnSpanSet
86 typedef mdds::flat_segment_tree
<SCROW
, bool> ColumnSpansType
;
93 Span(SCROW nRow1
, SCROW nRow2
) : mnRow1(nRow1
), mnRow2(nRow2
) {}
96 typedef std::vector
<Span
> SpansType
;
98 SingleColumnSpanSet();
101 * Scan an entire column and tag all non-empty cell positions.
103 void scan(const ScColumn
& rColumn
);
106 * Scan a column between specified range, and tag all non-empty cell
109 void scan(const ScColumn
& rColumn
, SCROW nStart
, SCROW nEnd
);
112 ColumnBlockConstPosition
& rBlockPos
, const ScColumn
& rColumn
, SCROW nStart
, SCROW nEnd
);
115 * Scan all marked data and tag all marked segments in specified column.
117 void scan(const ScMarkData
& rMark
, SCTAB nTab
, SCCOL nCol
);
119 void set(SCROW nRow1
, SCROW nRow2
, bool bVal
);
121 void getRows(std::vector
<SCROW
> &rRows
) const;
123 void getSpans(SpansType
& rSpans
) const;
126 ColumnSpansType maSpans
;
133 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */