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/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_SC_INC_SEGMENTTREE_HXX
21 #define INCLUDED_SC_INC_SEGMENTTREE_HXX
24 #include <rtl/string.hxx>
28 class ScFlatBoolSegmentsImpl
;
30 class ScFlatBoolRowSegments
43 explicit ForwardIterator(ScFlatBoolRowSegments
& rSegs
);
46 bool getValue(SCROW nPos
, bool& rVal
);
47 SCROW
getLastPos() const { return mnLastPos
;}
50 ScFlatBoolRowSegments
& mrSegs
;
60 explicit RangeIterator(ScFlatBoolRowSegments
const & rSegs
);
61 bool getFirst(RangeData
& rRange
);
62 bool getNext(RangeData
& rRange
);
64 ScFlatBoolRowSegments
const & mrSegs
;
67 ScFlatBoolRowSegments();
68 ScFlatBoolRowSegments(const ScFlatBoolRowSegments
& r
);
69 ~ScFlatBoolRowSegments();
71 bool setTrue(SCROW nRow1
, SCROW nRow2
);
72 bool setFalse(SCROW nRow1
, SCROW nRow2
);
73 bool getRangeData(SCROW nRow
, RangeData
& rData
) const;
74 bool getRangeDataLeaf(SCROW nRow
, RangeData
& rData
);
75 void removeSegment(SCROW nRow1
, SCROW nRow2
);
76 void insertSegment(SCROW nRow
, SCROW nSize
);
78 SCROW
findLastTrue() const;
80 OString
dumpAsString();
83 ::std::unique_ptr
<ScFlatBoolSegmentsImpl
> mpImpl
;
86 class ScFlatBoolColSegments
95 ScFlatBoolColSegments();
96 ScFlatBoolColSegments(const ScFlatBoolColSegments
& r
);
97 ~ScFlatBoolColSegments();
99 bool setTrue(SCCOL nCol1
, SCCOL nCol2
);
100 bool setFalse(SCCOL nCol1
, SCCOL nCol2
);
101 bool getRangeData(SCCOL nCol
, RangeData
& rData
);
102 void removeSegment(SCCOL nCol1
, SCCOL nCol2
);
103 void insertSegment(SCCOL nCol
, SCCOL nSize
);
105 OString
dumpAsString();
108 ::std::unique_ptr
<ScFlatBoolSegmentsImpl
> mpImpl
;
111 class ScFlatUInt16SegmentsImpl
;
113 class ScFlatUInt16RowSegments
123 class ForwardIterator
126 explicit ForwardIterator(ScFlatUInt16RowSegments
& rSegs
);
128 bool getValue(SCROW nPos
, sal_uInt16
& rVal
);
129 SCROW
getLastPos() const { return mnLastPos
;}
132 ScFlatUInt16RowSegments
& mrSegs
;
136 sal_uInt16 mnCurValue
;
139 ScFlatUInt16RowSegments(sal_uInt16 nDefault
);
140 ScFlatUInt16RowSegments(const ScFlatUInt16RowSegments
& r
);
141 ~ScFlatUInt16RowSegments();
143 void setValue(SCROW nRow1
, SCROW nRow2
, sal_uInt16 nValue
);
144 void setValueIf(SCROW nRow1
, SCROW nRow2
, sal_uInt16 nValue
, const std::function
<bool(sal_uInt16
)>& rPredicate
);
145 sal_uInt16
getValue(SCROW nRow
);
146 sal_uInt32
getSumValue(SCROW nRow1
, SCROW nRow2
);
147 bool getRangeData(SCROW nRow
, RangeData
& rData
);
148 void removeSegment(SCROW nRow1
, SCROW nRow2
);
149 void insertSegment(SCROW nRow
, SCROW nSize
);
151 SCROW
findLastTrue(sal_uInt16 nValue
) const;
153 void enableTreeSearch(bool bEnable
);
155 OString
dumpAsString();
158 ::std::unique_ptr
<ScFlatUInt16SegmentsImpl
> mpImpl
;
163 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */