/src/libreoffice/sc/source/ui/sparklines/SparklineAttributes.cxx
Line | Count | Source |
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 | | |
11 | | #include <SparklineAttributes.hxx> |
12 | | |
13 | | namespace sc |
14 | | { |
15 | | /** Holder of sparkline attributes */ |
16 | | class SparklineAttributes::Implementation |
17 | | { |
18 | | public: |
19 | | model::ComplexColor m_aColorSeries; |
20 | | model::ComplexColor m_aColorNegative; |
21 | | model::ComplexColor m_aColorAxis; |
22 | | model::ComplexColor m_aColorMarkers; |
23 | | model::ComplexColor m_aColorFirst; |
24 | | model::ComplexColor m_aColorLast; |
25 | | model::ComplexColor m_aColorHigh; |
26 | | model::ComplexColor m_aColorLow; |
27 | | |
28 | | AxisType m_eMinAxisType; |
29 | | AxisType m_eMaxAxisType; |
30 | | |
31 | | double m_fLineWeight; // In pt |
32 | | |
33 | | SparklineType m_eType; |
34 | | |
35 | | bool m_bDateAxis; |
36 | | |
37 | | DisplayEmptyCellsAs m_eDisplayEmptyCellsAs; // span, gap, zero |
38 | | |
39 | | bool m_bMarkers; |
40 | | bool m_bHigh; |
41 | | bool m_bLow; |
42 | | bool m_bFirst; |
43 | | bool m_bLast; |
44 | | bool m_bNegative; |
45 | | bool m_bDisplayXAxis; |
46 | | bool m_bDisplayHidden; |
47 | | bool m_bRightToLeft; |
48 | | |
49 | | std::optional<double> m_aManualMax; |
50 | | std::optional<double> m_aManualMin; |
51 | | static constexpr Color COL_STANDARD_RED = 0xff0000; |
52 | | static constexpr Color COL_STANDARD_BLUE = 0x2a6099; |
53 | | |
54 | | Implementation() |
55 | 2 | : m_aColorSeries(model::ComplexColor::createRGB(COL_STANDARD_BLUE)) |
56 | 2 | , m_aColorNegative(model::ComplexColor::createRGB(COL_STANDARD_RED)) |
57 | 2 | , m_aColorAxis(model::ComplexColor::createRGB(COL_STANDARD_RED)) |
58 | 2 | , m_aColorMarkers(model::ComplexColor::createRGB(COL_STANDARD_RED)) |
59 | 2 | , m_aColorFirst(model::ComplexColor::createRGB(COL_STANDARD_RED)) |
60 | 2 | , m_aColorLast(model::ComplexColor::createRGB(COL_STANDARD_RED)) |
61 | 2 | , m_aColorHigh(model::ComplexColor::createRGB(COL_STANDARD_RED)) |
62 | 2 | , m_aColorLow(model::ComplexColor::createRGB(COL_STANDARD_RED)) |
63 | 2 | , m_eMinAxisType(AxisType::Individual) |
64 | 2 | , m_eMaxAxisType(AxisType::Individual) |
65 | 2 | , m_fLineWeight(0.75) |
66 | 2 | , m_eType(SparklineType::Line) |
67 | 2 | , m_bDateAxis(false) |
68 | 2 | , m_eDisplayEmptyCellsAs(DisplayEmptyCellsAs::Zero) |
69 | 2 | , m_bMarkers(false) |
70 | 2 | , m_bHigh(false) |
71 | 2 | , m_bLow(false) |
72 | 2 | , m_bFirst(false) |
73 | 2 | , m_bLast(false) |
74 | 2 | , m_bNegative(false) |
75 | 2 | , m_bDisplayXAxis(false) |
76 | 2 | , m_bDisplayHidden(false) |
77 | 2 | , m_bRightToLeft(false) |
78 | 2 | { |
79 | 2 | } |
80 | | |
81 | | Implementation(Implementation const& pOther) |
82 | 0 | : m_aColorSeries(pOther.m_aColorSeries) |
83 | 0 | , m_aColorNegative(pOther.m_aColorNegative) |
84 | 0 | , m_aColorAxis(pOther.m_aColorAxis) |
85 | 0 | , m_aColorMarkers(pOther.m_aColorMarkers) |
86 | 0 | , m_aColorFirst(pOther.m_aColorFirst) |
87 | 0 | , m_aColorLast(pOther.m_aColorLast) |
88 | 0 | , m_aColorHigh(pOther.m_aColorHigh) |
89 | 0 | , m_aColorLow(pOther.m_aColorLow) |
90 | 0 | , m_eMinAxisType(pOther.m_eMinAxisType) |
91 | 0 | , m_eMaxAxisType(pOther.m_eMaxAxisType) |
92 | 0 | , m_fLineWeight(pOther.m_fLineWeight) |
93 | 0 | , m_eType(pOther.m_eType) |
94 | 0 | , m_bDateAxis(pOther.m_bDateAxis) |
95 | 0 | , m_eDisplayEmptyCellsAs(pOther.m_eDisplayEmptyCellsAs) |
96 | 0 | , m_bMarkers(pOther.m_bMarkers) |
97 | 0 | , m_bHigh(pOther.m_bHigh) |
98 | 0 | , m_bLow(pOther.m_bLow) |
99 | 0 | , m_bFirst(pOther.m_bFirst) |
100 | 0 | , m_bLast(pOther.m_bLast) |
101 | 0 | , m_bNegative(pOther.m_bNegative) |
102 | 0 | , m_bDisplayXAxis(pOther.m_bDisplayXAxis) |
103 | 0 | , m_bDisplayHidden(pOther.m_bDisplayHidden) |
104 | 0 | , m_bRightToLeft(pOther.m_bRightToLeft) |
105 | 0 | , m_aManualMax(pOther.m_aManualMax) |
106 | 0 | , m_aManualMin(pOther.m_aManualMin) |
107 | 0 | { |
108 | 0 | } |
109 | | |
110 | | bool operator==(const Implementation& rImpl) const |
111 | 0 | { |
112 | 0 | return (m_aColorSeries == rImpl.m_aColorSeries) |
113 | 0 | && (m_aColorNegative == rImpl.m_aColorNegative) |
114 | 0 | && (m_aColorAxis == rImpl.m_aColorAxis) && (m_aColorMarkers == rImpl.m_aColorMarkers) |
115 | 0 | && (m_aColorFirst == rImpl.m_aColorFirst) && (m_aColorLast == rImpl.m_aColorLast) |
116 | 0 | && (m_aColorHigh == rImpl.m_aColorHigh) && (m_aColorLow == rImpl.m_aColorLow) |
117 | 0 | && (m_eMinAxisType == rImpl.m_eMinAxisType) |
118 | 0 | && (m_eMaxAxisType == rImpl.m_eMaxAxisType) && (m_fLineWeight == rImpl.m_fLineWeight) |
119 | 0 | && (m_eType == rImpl.m_eType) && (m_bDateAxis == rImpl.m_bDateAxis) |
120 | 0 | && (m_eDisplayEmptyCellsAs == rImpl.m_eDisplayEmptyCellsAs) |
121 | 0 | && (m_bMarkers == rImpl.m_bMarkers) && (m_bHigh == rImpl.m_bHigh) |
122 | 0 | && (m_bLow == rImpl.m_bLow) && (m_bFirst == rImpl.m_bFirst) |
123 | 0 | && (m_bLast == rImpl.m_bLast) && (m_bNegative == rImpl.m_bNegative) |
124 | 0 | && (m_bDisplayXAxis == rImpl.m_bDisplayXAxis) |
125 | 0 | && (m_bDisplayHidden == rImpl.m_bDisplayHidden) |
126 | 0 | && (m_bRightToLeft == rImpl.m_bRightToLeft) && (m_aManualMax == rImpl.m_aManualMax) |
127 | 0 | && (m_aManualMin == rImpl.m_aManualMin); |
128 | 0 | } |
129 | | }; |
130 | | |
131 | 2 | SparklineAttributes::SparklineAttributes() = default; |
132 | | |
133 | 2 | SparklineAttributes::~SparklineAttributes() = default; |
134 | | |
135 | 0 | SparklineAttributes::SparklineAttributes(SparklineAttributes const&) = default; |
136 | | |
137 | 0 | SparklineAttributes::SparklineAttributes(SparklineAttributes&&) = default; |
138 | | |
139 | 0 | SparklineAttributes& SparklineAttributes::operator=(SparklineAttributes const&) = default; |
140 | | |
141 | 0 | SparklineAttributes& SparklineAttributes::operator=(SparklineAttributes&&) = default; |
142 | | |
143 | | bool SparklineAttributes::operator==(SparklineAttributes const& rOther) const |
144 | 0 | { |
145 | 0 | return m_aImplementation == rOther.m_aImplementation; |
146 | 0 | } |
147 | | |
148 | | void SparklineAttributes::resetColors() |
149 | 2 | { |
150 | 2 | m_aImplementation->m_aColorSeries = model::ComplexColor(); |
151 | 2 | m_aImplementation->m_aColorNegative = model::ComplexColor(); |
152 | 2 | m_aImplementation->m_aColorAxis = model::ComplexColor(); |
153 | 2 | m_aImplementation->m_aColorMarkers = model::ComplexColor(); |
154 | 2 | m_aImplementation->m_aColorFirst = model::ComplexColor(); |
155 | 2 | m_aImplementation->m_aColorLast = model::ComplexColor(); |
156 | 2 | m_aImplementation->m_aColorHigh = model::ComplexColor(); |
157 | 2 | m_aImplementation->m_aColorLow = model::ComplexColor(); |
158 | 2 | } |
159 | | |
160 | | const model::ComplexColor& SparklineAttributes::getColorSeries() const |
161 | 0 | { |
162 | 0 | return m_aImplementation->m_aColorSeries; |
163 | 0 | } |
164 | | |
165 | | void SparklineAttributes::setColorSeries(model::ComplexColor const& rColor) |
166 | 2 | { |
167 | 2 | m_aImplementation->m_aColorSeries = rColor; |
168 | 2 | } |
169 | | |
170 | | const model::ComplexColor& SparklineAttributes::getColorNegative() const |
171 | 0 | { |
172 | 0 | return m_aImplementation->m_aColorNegative; |
173 | 0 | } |
174 | | |
175 | | void SparklineAttributes::setColorNegative(model::ComplexColor const& rColor) |
176 | 2 | { |
177 | 2 | m_aImplementation->m_aColorNegative = rColor; |
178 | 2 | } |
179 | | |
180 | | const model::ComplexColor& SparklineAttributes::getColorAxis() const |
181 | 0 | { |
182 | 0 | return m_aImplementation->m_aColorAxis; |
183 | 0 | } |
184 | | |
185 | | void SparklineAttributes::setColorAxis(model::ComplexColor const& rColor) |
186 | 2 | { |
187 | 2 | m_aImplementation->m_aColorAxis = rColor; |
188 | 2 | } |
189 | | |
190 | | const model::ComplexColor& SparklineAttributes::getColorMarkers() const |
191 | 0 | { |
192 | 0 | return m_aImplementation->m_aColorMarkers; |
193 | 0 | } |
194 | | void SparklineAttributes::setColorMarkers(model::ComplexColor const& rColor) |
195 | 2 | { |
196 | 2 | m_aImplementation->m_aColorMarkers = rColor; |
197 | 2 | } |
198 | | |
199 | | const model::ComplexColor& SparklineAttributes::getColorFirst() const |
200 | 0 | { |
201 | 0 | return m_aImplementation->m_aColorFirst; |
202 | 0 | } |
203 | | void SparklineAttributes::setColorFirst(model::ComplexColor const& rColor) |
204 | 2 | { |
205 | 2 | m_aImplementation->m_aColorFirst = rColor; |
206 | 2 | } |
207 | | |
208 | | const model::ComplexColor& SparklineAttributes::getColorLast() const |
209 | 0 | { |
210 | 0 | return m_aImplementation->m_aColorLast; |
211 | 0 | } |
212 | | void SparklineAttributes::setColorLast(model::ComplexColor const& rColor) |
213 | 2 | { |
214 | 2 | m_aImplementation->m_aColorLast = rColor; |
215 | 2 | } |
216 | | |
217 | | const model::ComplexColor& SparklineAttributes::getColorHigh() const |
218 | 0 | { |
219 | 0 | return m_aImplementation->m_aColorHigh; |
220 | 0 | } |
221 | | void SparklineAttributes::setColorHigh(model::ComplexColor const& rColor) |
222 | 2 | { |
223 | 2 | m_aImplementation->m_aColorHigh = rColor; |
224 | 2 | } |
225 | | |
226 | | const model::ComplexColor& SparklineAttributes::getColorLow() const |
227 | 0 | { |
228 | 0 | return m_aImplementation->m_aColorLow; |
229 | 0 | } |
230 | | void SparklineAttributes::setColorLow(model::ComplexColor const& rColor) |
231 | 2 | { |
232 | 2 | m_aImplementation->m_aColorLow = rColor; |
233 | 2 | } |
234 | | |
235 | 2 | AxisType SparklineAttributes::getMinAxisType() const { return m_aImplementation->m_eMinAxisType; } |
236 | | void SparklineAttributes::setMinAxisType(AxisType eAxisType) |
237 | 2 | { |
238 | 2 | m_aImplementation->m_eMinAxisType = eAxisType; |
239 | 2 | } |
240 | | |
241 | 2 | AxisType SparklineAttributes::getMaxAxisType() const { return m_aImplementation->m_eMaxAxisType; } |
242 | | void SparklineAttributes::setMaxAxisType(AxisType eAxisType) |
243 | 2 | { |
244 | 2 | m_aImplementation->m_eMaxAxisType = eAxisType; |
245 | 2 | } |
246 | | |
247 | 0 | double SparklineAttributes::getLineWeight() const { return m_aImplementation->m_fLineWeight; } |
248 | | void SparklineAttributes::setLineWeight(double nWeight) |
249 | 2 | { |
250 | 2 | m_aImplementation->m_fLineWeight = nWeight; |
251 | 2 | } |
252 | | |
253 | 0 | SparklineType SparklineAttributes::getType() const { return m_aImplementation->m_eType; } |
254 | 2 | void SparklineAttributes::setType(SparklineType eType) { m_aImplementation->m_eType = eType; } |
255 | | |
256 | 0 | bool SparklineAttributes::isDateAxis() const { return m_aImplementation->m_bDateAxis; } |
257 | 2 | void SparklineAttributes::setDateAxis(bool bValue) { m_aImplementation->m_bDateAxis = bValue; } |
258 | | |
259 | | DisplayEmptyCellsAs SparklineAttributes::getDisplayEmptyCellsAs() const |
260 | 0 | { |
261 | 0 | return m_aImplementation->m_eDisplayEmptyCellsAs; |
262 | 0 | } |
263 | | void SparklineAttributes::setDisplayEmptyCellsAs(DisplayEmptyCellsAs eValue) |
264 | 2 | { |
265 | 2 | m_aImplementation->m_eDisplayEmptyCellsAs = eValue; |
266 | 2 | } |
267 | | |
268 | 0 | bool SparklineAttributes::isMarkers() const { return m_aImplementation->m_bMarkers; } |
269 | 2 | void SparklineAttributes::setMarkers(bool bValue) { m_aImplementation->m_bMarkers = bValue; } |
270 | | |
271 | 0 | bool SparklineAttributes::isHigh() const { return m_aImplementation->m_bHigh; } |
272 | 2 | void SparklineAttributes::setHigh(bool bValue) { m_aImplementation->m_bHigh = bValue; } |
273 | | |
274 | 0 | bool SparklineAttributes::isLow() const { return m_aImplementation->m_bLow; } |
275 | 2 | void SparklineAttributes::setLow(bool bValue) { m_aImplementation->m_bLow = bValue; } |
276 | | |
277 | 0 | bool SparklineAttributes::isFirst() const { return m_aImplementation->m_bFirst; } |
278 | 2 | void SparklineAttributes::setFirst(bool bValue) { m_aImplementation->m_bFirst = bValue; } |
279 | | |
280 | 0 | bool SparklineAttributes::isLast() const { return m_aImplementation->m_bLast; } |
281 | 2 | void SparklineAttributes::setLast(bool bValue) { m_aImplementation->m_bLast = bValue; } |
282 | | |
283 | 0 | bool SparklineAttributes::isNegative() const { return m_aImplementation->m_bNegative; } |
284 | 2 | void SparklineAttributes::setNegative(bool bValue) { m_aImplementation->m_bNegative = bValue; } |
285 | | |
286 | 0 | bool SparklineAttributes::shouldDisplayXAxis() const { return m_aImplementation->m_bDisplayXAxis; } |
287 | | void SparklineAttributes::setDisplayXAxis(bool bValue) |
288 | 2 | { |
289 | 2 | m_aImplementation->m_bDisplayXAxis = bValue; |
290 | 2 | } |
291 | | |
292 | | bool SparklineAttributes::shouldDisplayHidden() const |
293 | 0 | { |
294 | 0 | return m_aImplementation->m_bDisplayHidden; |
295 | 0 | } |
296 | | void SparklineAttributes::setDisplayHidden(bool bValue) |
297 | 2 | { |
298 | 2 | m_aImplementation->m_bDisplayHidden = bValue; |
299 | 2 | } |
300 | | |
301 | 0 | bool SparklineAttributes::isRightToLeft() const { return m_aImplementation->m_bRightToLeft; } |
302 | | void SparklineAttributes::setRightToLeft(bool bValue) |
303 | 2 | { |
304 | 2 | m_aImplementation->m_bRightToLeft = bValue; |
305 | 2 | } |
306 | | |
307 | | std::optional<double> SparklineAttributes::getManualMax() const |
308 | 0 | { |
309 | 0 | return m_aImplementation->m_aManualMax; |
310 | 0 | } |
311 | | void SparklineAttributes::setManualMax(std::optional<double> aValue) |
312 | 0 | { |
313 | 0 | m_aImplementation->m_aManualMax = aValue; |
314 | 0 | } |
315 | | |
316 | | std::optional<double> SparklineAttributes::getManualMin() const |
317 | 0 | { |
318 | 0 | return m_aImplementation->m_aManualMin; |
319 | 0 | } |
320 | | void SparklineAttributes::setManualMin(std::optional<double> aValue) |
321 | 0 | { |
322 | 0 | m_aImplementation->m_aManualMin = aValue; |
323 | 0 | } |
324 | | |
325 | | } // end sc |
326 | | |
327 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |