Debian Codegraph @

include/docmodel/theme/FormatScheme.hxx

raw
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 #pragma once
12
13 #include <docmodel/dllapi.h>
14 #include <docmodel/color/ComplexColor.hxx>
15 #include <com/sun/star/graphic/XGraphic.hpp>
16
17 namespace model
18 {
19 enum class FillType
20 {
21 None,
22 Solid,
23 Gradient,
24 Pattern,
25 Blip
26 };
27
28 class DOCMODEL_DLLPUBLIC Fill
29 {
30 public:
31 Fill(FillType eType)
32 : meType(eType)
33 {
34 }
35
36 FillType meType;
37 };
38
39 class DOCMODEL_DLLPUBLIC NoFill : public Fill
40 {
41 public:
42 NoFill()
43 : Fill(FillType::None)
44 {
45 }
46 };
47
48 class DOCMODEL_DLLPUBLIC SolidFill : public Fill
49 {
50 public:
51 ComplexColor maColor;
52
53 SolidFill()
54 : Fill(FillType::Solid)
55 {
56 }
57 };
58
59 class DOCMODEL_DLLPUBLIC GradientStop
60 {
61 public:
62 double mfPosition = 0.0; // 0.0 - 1.0
63 ComplexColor maColor;
64 };
65
66 enum class GradientType
67 {
68 Undefined,
69 Linear,
70 Circle,
71 Rectangle,
72 Shape,
73 };
74
75 struct DOCMODEL_DLLPUBLIC LinearGradientProperties
76 {
77 sal_Int32 mnAngle = 0;
78 bool mbScaled = false;
79 };
80
81 struct DOCMODEL_DLLPUBLIC RelativeRectangle
82 {
83 sal_Int32 mnLeft = 0;
84 sal_Int32 mnTop = 0;
85 sal_Int32 mnRight = 0;
86 sal_Int32 mnBottom = 0;
87 };
88
89 class DOCMODEL_DLLPUBLIC GradientFill : public Fill
90 {
91 public:
92 bool mbRotateWithShape = false;
93 GradientType meGradientType = GradientType::Undefined;
94 std::vector<GradientStop> maGradientStops;
95 LinearGradientProperties maLinearGradient;
96 RelativeRectangle maFillToRectangle;
97 RelativeRectangle maTileRectangle;
98
99 GradientFill()
100 : Fill(FillType::Gradient)
101 {
102 }
103 };
104
105 enum class PatternPreset
106 {
107 Unused,
108 Percent_5,
109 Percent_10,
110 Percent_20,
111 Percent_25,
112 Percent_30,
113 Percent_40,
114 Percent_50,
115 Percent_60,
116 Percent_70,
117 Percent_75,
118 Percent_80,
119 Percent_90,
120 Horizontal,
121 Vertical,
122 LightHorizontal,
123 LightVertical,
124 DarkHorizontal,
125 DarkVertical,
126 NarrowHorizontal,
127 NarrowVertical,
128 DashedHorizontal,
129 DashedVertical,
130 Cross,
131 DownwardDiagonal,
132 UpwardDiagonal,
133 LightDownwardDiagonal,
134 LightUpwardDiagonal,
135 DarkDownwardDiagonal,
136 DarkUpwardDiagonal,
137 WideDownwardDiagonal,
138 WideUpwardDiagonal,
139 DashedDownwardDiagonal,
140 DashedUpwardDiagonal,
141 DiagonalCross,
142 SmallCheckerBoard,
143 LargeCheckerBoard,
144 SmallGrid,
145 LargeGrid,
146 DottedGrid,
147 SmallConfetti,
148 LargeConfetti,
149 HorizontalBrick,
150 DiagonalBrick,
151 SolidDiamond,
152 OpenDiamond,
153 DottedDiamond,
154 Plaid,
155 Sphere,
156 Weave,
157 Divot,
158 Shingle,
159 Wave,
160 Trellis,
161 ZigZag
162 };
163
164 class DOCMODEL_DLLPUBLIC PatternFill : public Fill
165 {
166 public:
167 PatternPreset mePatternPreset = PatternPreset::Unused;
168 ComplexColor maForegroundColor;
169 ComplexColor maBackgroundColor;
170
171 PatternFill()
172 : Fill(FillType::Pattern)
173 {
174 }
175 };
176
177 enum class BitmapMode
178 {
179 Unused,
180 Tile,
181 Stretch,
182 };
183
184 enum class FlipMode
185 {
186 None,
187 X,
188 Y,
189 XY
190 };
191
192 enum class RectangleAlignment
193 {
194 Unset,
195 TopLeft,
196 Top,
197 TopRight,
198 Left,
199 Center,
200 Right,
201 BottomLeft,
202 Bottom,
203 BottomRight
204 };
205 constexpr sal_uInt16 RECTANGLE_ALIGNMENT_COUNT
206 = static_cast<sal_uInt16>(RectangleAlignment::BottomRight) + 1;
207
208 enum class BlipEffectType
209 {
210 None,
211 AlphaBiLevel,
212 AlphaCeiling,
213 AlphaFloor,
214 AlphaInverse,
215 AlphaModulate,
216 AlphaModulateFixed,
217 AlphaReplace,
218 BiLevel,
219 Blur,
220 ColorChange,
221 ColorReplace,
222 DuoTone,
223 FillOverlay,
224 Grayscale,
225 HSL,
226 Luminance,
227 Tint,
228 };
229
230 class BlipEffect
231 {
232 public:
233 BlipEffectType meType = BlipEffectType::None;
234
235 sal_Int32 mnThreshold = 0; // AlphaBiLevel, BiLevel
236 ComplexColor maColor1; // AlphaInverse, ColorReplace, DuoTone, ColorChange (from)
237 ComplexColor maColor2; // DuoTone, ColorChange (to)
238 sal_Int32 mnAmount = 0; // AlphaModulateFixed, Tint
239 sal_Int32 mnRadius = 0; // Blur
240 bool mbGrow = false; // Blur
241 sal_Int32 mnAlpha = 0; // AlphaReplace
242 bool mbUseAlpha = false; // ColorChange
243 sal_Int32 mnHue = 0; // HSL, Tint
244 sal_Int32 mnSaturation = 0; // HSL
245 sal_Int32 mnLuminance = 0; // HSL
246 sal_Int32 mnBrightness = 0; // Luminance
247 sal_Int32 mnContrast = 0; // Luminance
248
249 ComplexColor& getColorFrom() { return maColor1; }
250 ComplexColor& getColorTo() { return maColor2; }
251 };
252
253 class DOCMODEL_DLLPUBLIC BlipFill : public Fill
254 {
255 public:
256 bool mbRotateWithShape = false;
257 RelativeRectangle maClipRectangle;
258 RelativeRectangle maFillRectangle;
259 BitmapMode meMode = BitmapMode::Unused;
260
261 sal_Int32 mnTileOffsetX = 0;
262 sal_Int32 mnTileOffsetY = 0;
263 sal_Int32 mnTileScaleX = 0;
264 sal_Int32 mnTileScaleY = 0;
265 FlipMode meTileFlipMode = FlipMode::None;
266 RectangleAlignment meTileAlignment = RectangleAlignment::TopLeft;
267
268 css::uno::Reference<css::graphic::XGraphic> mxGraphic;
269 std::vector<BlipEffect> maBlipEffects;
270
271 BlipFill()
272 : Fill(FillType::Blip)
273 {
274 }
275 };
276
277 class DOCMODEL_DLLPUBLIC FillStyle
278 {
279 public:
280 std::shared_ptr<Fill> mpFill;
281 };
282
283 enum class CapType
284 {
285 Unset,
286 Flat,
287 Round,
288 Square
289 };
290
291 enum class PenAlignmentType
292 {
293 Unset,
294 Center,
295 Inset
296 };
297
298 enum class CompoundLineType
299 {
300 Unset,
301 Single,
302 Double,
303 ThickThin_Double,
304 ThinThick_Double,
305 Triple,
306 };
307
308 enum class PresetDashType
309 {
310 Unset,
311 Dash,
312 DashDot,
313 Dot,
314 LargeDash,
315 LargeDashDot,
316 LargeDashDotDot,
317 Solid,
318 SystemDash,
319 SystemDashDot,
320 SystemDashDotDot,
321 SystemDot,
322 };
323
324 enum class LineJoinType
325 {
326 Unset,
327 Round,
328 Bevel,
329 Miter,
330 };
331
332 struct DOCMODEL_DLLPUBLIC LineJoin
333 {
334 LineJoinType meType = LineJoinType::Unset;
335 sal_Int32 mnMiterLimit = 0; // Percentage
336 };
337
338 enum class LineEndType
339 {
340 None,
341 Triangle,
342 Stealth,
343 Diamond,
344 Oval,
345 Arrow
346 };
347
348 enum class LineEndWidth
349 {
350 Unset,
351 Small,
352 Medium,
353 Large
354 };
355
356 enum class LineEndLength
357 {
358 Unset,
359 Small,
360 Medium,
361 Large
362 };
363
364 struct DOCMODEL_DLLPUBLIC LineEnd
365 {
366 LineEndType meType = LineEndType::None;
367 LineEndWidth meWidth = LineEndWidth::Unset;
368 LineEndLength meLength = LineEndLength::Unset;
369 };
370
371 struct DOCMODEL_DLLPUBLIC DashStop
372 {
373 sal_Int32 mnDashLength = 0;
374 sal_Int32 mnStopLength = 0;
375 };
376
377 struct DOCMODEL_DLLPUBLIC LineDash
378 {
379 PresetDashType mePresetType = PresetDashType::Unset;
380 std::vector<DashStop> maCustomList;
381 };
382
383 class DOCMODEL_DLLPUBLIC LineStyle
384 {
385 public:
386 sal_Int32 mnWidth;
387 CapType meCapType;
388 PenAlignmentType mePenAlignment;
389 CompoundLineType meCompoundLineType;
390 LineDash maLineDash;
391 LineJoin maLineJoin;
392 LineEnd maHeadEnd;
393 LineEnd maTailEnd;
394
395 FillStyle maLineFillStyle;
396 };
397
398 enum class EffectType
399 {
400 Unset,
401 OuterShadow,
402 InnerShadow,
403 Glow,
404 SoftEdge,
405 Reflection,
406 Blur
407 };
408
409 class DOCMODEL_DLLPUBLIC Effect
410 {
411 public:
412 EffectType meType = EffectType::Unset;
413 sal_Int32 mnBlurRadius = 0;
414 sal_Int32 mnRadius = 0;
415 sal_Int32 mnDistance = 0;
416 sal_Int32 mnDirection = 0;
417 sal_Int32 mnScaleX = 100;
418 sal_Int32 mnScaley = 100;
419 sal_Int32 mnScewX = 0;
420 sal_Int32 mnScewY = 0;
421 RectangleAlignment meAlignment = RectangleAlignment::Bottom;
422 bool mbRotateWithShape = true;
423 ComplexColor maColor;
424 double mnEndAlpha = 100.0;
425 double mnEndPosition = 0.0;
426 double mnStartAlpha = 0.0;
427 double mnStartPosition = 100.0;
428 sal_Int32 mnFadeDirection = 0;
429 bool mbGrow = false;
430 };
431
432 class DOCMODEL_DLLPUBLIC EffectStyle
433 {
434 public:
435 std::vector<Effect> maEffectList;
436 };
437
438 class DOCMODEL_DLLPUBLIC FormatScheme
439 {
440 private:
441 OUString maName;
442 std::vector<FillStyle> maFillStyleList;
443 std::vector<LineStyle> maLineStyleList;
444 std::vector<EffectStyle> maEffectStyleList;
445 std::vector<FillStyle> maBackgroundFillStyleList;
446
447 public:
448 FormatScheme() = default;
449
450 FormatScheme(OUString const& rName)
451 : maName(rName)
452 {
453 }
454
455 const OUString& getName() const { return maName; }
456
457 std::vector<FillStyle> const& getFillStyleList() const { return maFillStyleList; }
458
459 FillStyle* addFillStyle()
460 {
461 if (maFillStyleList.size() > 3)
462 return nullptr;
463 auto& rFillStyle = maFillStyleList.emplace_back();
464 return &rFillStyle;
465 }
466
467 void ensureFillStyleList() const
468 {
469 if (!maFillStyleList.empty())
470 return;
471
472 auto* pThis = const_cast<FormatScheme*>(this);
473 {
474 FillStyle* pFillStyle = pThis->addFillStyle();
475 auto pFill = std::make_shared<SolidFill>();
476 pFill->maColor.setThemePlaceholder();
477 pFillStyle->mpFill = pFill;
478 }
479 {
480 FillStyle* pFillStyle = pThis->addFillStyle();
481 auto pFill = std::make_shared<SolidFill>();
482 pFill->maColor.setThemePlaceholder();
483 pFillStyle->mpFill = pFill;
484 }
485 {
486 FillStyle* pFillStyle = pThis->addFillStyle();
487 auto pFill = std::make_shared<SolidFill>();
488 pFill->maColor.setThemePlaceholder();
489 pFillStyle->mpFill = pFill;
490 }
491 }
492
493 std::vector<LineStyle> const& getLineStyleList() const { return maLineStyleList; }
494
495 LineStyle* addLineStyle()
496 {
497 if (maLineStyleList.size() > 3)
498 return nullptr;
499 auto& rLineStyle = maLineStyleList.emplace_back();
500 return &rLineStyle;
501 }
502
503 void ensureLineStyleList() const
504 {
505 if (!maLineStyleList.empty())
506 return;
507
508 auto* pThis = const_cast<FormatScheme*>(this);
509
510 {
511 LineStyle* pLineStyle = pThis->addLineStyle();
512 pLineStyle->mnWidth = 6350;
513 pLineStyle->meCapType = CapType::Flat;
514 pLineStyle->mePenAlignment = PenAlignmentType::Center;
515 pLineStyle->meCompoundLineType = CompoundLineType::Single;
516 pLineStyle->maLineDash.mePresetType = PresetDashType::Solid;
517 pLineStyle->maLineJoin.meType = LineJoinType::Miter;
518 auto pFill = std::make_shared<SolidFill>();
519 pFill->maColor.setThemePlaceholder();
520 pLineStyle->maLineFillStyle.mpFill = pFill;
521 }
522 {
523 LineStyle* pLineStyle = pThis->addLineStyle();
524 pLineStyle->mnWidth = 6350;
525 pLineStyle->meCapType = CapType::Flat;
526 pLineStyle->mePenAlignment = PenAlignmentType::Center;
527 pLineStyle->meCompoundLineType = CompoundLineType::Single;
528 pLineStyle->maLineDash.mePresetType = PresetDashType::Solid;
529 pLineStyle->maLineJoin.meType = LineJoinType::Miter;
530 auto pFill = std::make_shared<SolidFill>();
531 pFill->maColor.setThemePlaceholder();
532 pLineStyle->maLineFillStyle.mpFill = pFill;
533 }
534 {
535 LineStyle* pLineStyle = pThis->addLineStyle();
536 pLineStyle->mnWidth = 6350;
537 pLineStyle->meCapType = CapType::Flat;
538 pLineStyle->mePenAlignment = PenAlignmentType::Center;
539 pLineStyle->meCompoundLineType = CompoundLineType::Single;
540 pLineStyle->maLineDash.mePresetType = PresetDashType::Solid;
541 pLineStyle->maLineJoin.meType = LineJoinType::Miter;
542 auto pFill = std::make_shared<SolidFill>();
543 pFill->maColor.setThemePlaceholder();
544 pLineStyle->maLineFillStyle.mpFill = pFill;
545 }
546 }
547
548 std::vector<EffectStyle> const& getEffectStyleList() const { return maEffectStyleList; }
549
550 EffectStyle* addEffectStyle()
551 {
552 if (maEffectStyleList.size() > 3)
553 return nullptr;
554 auto& rEffectStyle = maEffectStyleList.emplace_back();
555 return &rEffectStyle;
556 }
557
558 void ensureEffectStyleList() const
559 {
560 if (!maEffectStyleList.empty())
561 return;
562
563 auto* pThis = const_cast<FormatScheme*>(this);
564
565 pThis->addEffectStyle();
566 pThis->addEffectStyle();
567 pThis->addEffectStyle();
568 }
569
570 std::vector<FillStyle> const& getBackgroundFillStyleList() const
571 {
572 return maBackgroundFillStyleList;
573 }
574
575 FillStyle* addBackgroundFillStyle()
576 {
577 if (maBackgroundFillStyleList.size() > 3)
578 return nullptr;
579 auto& rBackgroundFillStyle = maBackgroundFillStyleList.emplace_back();
580 return &rBackgroundFillStyle;
581 }
582
583 void ensureBackgroundFillStyleList() const
584 {
585 if (!maBackgroundFillStyleList.empty())
586 return;
587
588 auto* pThis = const_cast<FormatScheme*>(this);
589
590 {
591 FillStyle* pFillStyle = pThis->addBackgroundFillStyle();
592 auto pFill = std::make_shared<SolidFill>();
593 pFill->maColor.setThemePlaceholder();
594 pFillStyle->mpFill = pFill;
595 }
596 {
597 FillStyle* pFillStyle = pThis->addBackgroundFillStyle();
598 auto pFill = std::make_shared<SolidFill>();
599 pFill->maColor.setThemePlaceholder();
600 pFillStyle->mpFill = pFill;
601 }
602 {
603 FillStyle* pFillStyle = pThis->addBackgroundFillStyle();
604 auto pFill = std::make_shared<SolidFill>();
605 pFill->maColor.setThemePlaceholder();
606 pFillStyle->mpFill = pFill;
607 }
608 }
609 };
610
611 } // end of namespace svx
612
613 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */