tdf#48459 sw inline heading: don't apply inside frames or over 120 chars
[LibreOffice.git] / sc / inc / segmenttree.hxx
blobc980f9db56a02bbfa2d805e3ab5f63602f07701d
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/.
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 #pragma once
22 #include "types.hxx"
23 #include <rtl/string.hxx>
25 #include <memory>
27 class ScFlatBoolSegmentsImpl;
29 class ScFlatBoolRowSegments
31 public:
32 struct RangeData
34 SCROW mnRow1;
35 SCROW mnRow2;
36 bool mbValue;
39 class ForwardIterator
41 public:
42 explicit ForwardIterator(ScFlatBoolRowSegments& rSegs);
44 [[nodiscard]] bool getValue(SCROW nPos, bool& rVal);
45 SCROW getLastPos() const { return mnLastPos; }
47 private:
48 ScFlatBoolRowSegments& mrSegs;
50 SCROW mnCurPos;
51 SCROW mnLastPos;
52 bool mbCurValue;
55 class RangeIterator
57 public:
58 explicit RangeIterator(ScFlatBoolRowSegments const& rSegs);
59 bool getFirst(RangeData& rRange);
60 bool getNext(RangeData& rRange);
62 private:
63 ScFlatBoolRowSegments const& mrSegs;
66 ScFlatBoolRowSegments(SCROW nMaxRow);
67 ScFlatBoolRowSegments(const ScFlatBoolRowSegments& r);
68 ~ScFlatBoolRowSegments();
70 bool setTrue(SCROW nRow1, SCROW nRow2);
71 bool setFalse(SCROW nRow1, SCROW nRow2);
72 bool getRangeData(SCROW nRow, RangeData& rData) const;
73 bool getRangeDataLeaf(SCROW nRow, RangeData& rData);
74 void removeSegment(SCROW nRow1, SCROW nRow2);
75 void insertSegment(SCROW nRow, SCROW nSize);
77 SCROW findLastTrue() const;
79 // Builds internal data (so that it doesn't build them while used in threads).
80 void makeReady();
82 OString dumpAsString();
84 private:
85 ::std::unique_ptr<ScFlatBoolSegmentsImpl> mpImpl;
88 class ScFlatBoolColSegments
90 public:
91 struct RangeData
93 SCCOL mnCol1;
94 SCCOL mnCol2;
95 bool mbValue;
97 ScFlatBoolColSegments(SCCOL nMaxCol);
98 ScFlatBoolColSegments(const ScFlatBoolColSegments& r);
99 ~ScFlatBoolColSegments();
101 bool setTrue(SCCOL nCol1, SCCOL nCol2);
102 bool setFalse(SCCOL nCol1, SCCOL nCol2);
103 bool getRangeData(SCCOL nCol, RangeData& rData);
104 void removeSegment(SCCOL nCol1, SCCOL nCol2);
105 void insertSegment(SCCOL nCol, SCCOL nSize);
107 // Builds internal data (so that it doesn't build them while used in threads).
108 void makeReady();
110 OString dumpAsString();
112 private:
113 ::std::unique_ptr<ScFlatBoolSegmentsImpl> mpImpl;
116 class ScFlatUInt16SegmentsImpl;
118 class ScFlatUInt16RowSegments
120 public:
121 struct RangeData
123 SCROW mnRow1;
124 SCROW mnRow2;
125 sal_uInt16 mnValue;
128 class ForwardIterator
130 public:
131 explicit ForwardIterator(ScFlatUInt16RowSegments& rSegs);
133 bool getValue(SCROW nPos, sal_uInt16& rVal);
134 SCROW getLastPos() const { return mnLastPos; }
136 private:
137 ScFlatUInt16RowSegments& mrSegs;
139 SCROW mnCurPos;
140 SCROW mnLastPos;
141 sal_uInt16 mnCurValue;
144 ScFlatUInt16RowSegments(SCROW nMaxRow, sal_uInt16 nDefault);
145 ScFlatUInt16RowSegments(const ScFlatUInt16RowSegments& r);
146 ~ScFlatUInt16RowSegments();
148 void setValue(SCROW nRow1, SCROW nRow2, sal_uInt16 nValue);
149 void setValueIf(SCROW nRow1, SCROW nRow2, sal_uInt16 nValue,
150 const std::function<bool(sal_uInt16)>& rPredicate);
151 sal_uInt16 getValue(SCROW nRow);
152 sal_uInt64 getSumValue(SCROW nRow1, SCROW nRow2);
153 bool getRangeData(SCROW nRow, RangeData& rData);
154 void removeSegment(SCROW nRow1, SCROW nRow2);
155 void insertSegment(SCROW nRow, SCROW nSize);
157 SCROW findLastTrue(sal_uInt16 nValue) const;
159 void enableTreeSearch(bool bEnable);
161 // Builds internal data (so that it doesn't build them while used in threads).
162 void makeReady();
164 OString dumpAsString();
166 private:
167 ::std::unique_ptr<ScFlatUInt16SegmentsImpl> mpImpl;
170 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */