bump product version to 7.6.3.2-android
[LibreOffice.git] / include / docmodel / theme / FormatScheme.hxx
blob6e20d88b51ca58bcffe9887f205fa4b237862b57
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 */
11 #pragma once
13 #include <docmodel/dllapi.h>
14 #include <tools/color.hxx>
15 #include <docmodel/theme/ThemeColor.hxx>
16 #include <docmodel/color/ComplexColor.hxx>
17 #include <com/sun/star/graphic/XGraphic.hpp>
19 namespace model
21 enum class FillType
23 None,
24 Solid,
25 Gradient,
26 Pattern,
27 Blip
30 class DOCMODEL_DLLPUBLIC Fill
32 public:
33 Fill(FillType eType)
34 : meType(eType)
38 FillType meType;
41 class DOCMODEL_DLLPUBLIC NoFill : public Fill
43 public:
44 NoFill()
45 : Fill(FillType::None)
50 class DOCMODEL_DLLPUBLIC SolidFill : public Fill
52 public:
53 ComplexColor maColor;
55 SolidFill()
56 : Fill(FillType::Solid)
61 class DOCMODEL_DLLPUBLIC GradientStop
63 public:
64 double mfPosition = 0.0; // 0.0 - 1.0
65 ComplexColor maColor;
68 enum class GradientType
70 Undefined,
71 Linear,
72 Circle,
73 Rectangle,
74 Shape,
77 struct DOCMODEL_DLLPUBLIC LinearGradientProperties
79 sal_Int32 mnAngle = 0;
80 bool mbScaled = false;
83 struct DOCMODEL_DLLPUBLIC RelativeRectangle
85 sal_Int32 mnLeft = 0;
86 sal_Int32 mnTop = 0;
87 sal_Int32 mnRight = 0;
88 sal_Int32 mnBottom = 0;
91 class DOCMODEL_DLLPUBLIC GradientFill : public Fill
93 public:
94 bool mbRotateWithShape = false;
95 GradientType meGradientType = GradientType::Undefined;
96 std::vector<GradientStop> maGradientStops;
97 LinearGradientProperties maLinearGradient;
98 RelativeRectangle maFillToRectangle;
99 RelativeRectangle maTileRectangle;
101 GradientFill()
102 : Fill(FillType::Gradient)
107 enum class PatternPreset
109 Unused,
110 Percent_5,
111 Percent_10,
112 Percent_20,
113 Percent_25,
114 Percent_30,
115 Percent_40,
116 Percent_50,
117 Percent_60,
118 Percent_70,
119 Percent_75,
120 Percent_80,
121 Percent_90,
122 Horizontal,
123 Vertical,
124 LightHorizontal,
125 LightVertical,
126 DarkHorizontal,
127 DarkVertical,
128 NarrowHorizontal,
129 NarrowVertical,
130 DashedHorizontal,
131 DashedVertical,
132 Cross,
133 DownwardDiagonal,
134 UpwardDiagonal,
135 LightDownwardDiagonal,
136 LightUpwardDiagonal,
137 DarkDownwardDiagonal,
138 DarkUpwardDiagonal,
139 WideDownwardDiagonal,
140 WideUpwardDiagonal,
141 DashedDownwardDiagonal,
142 DashedUpwardDiagonal,
143 DiagonalCross,
144 SmallCheckerBoard,
145 LargeCheckerBoard,
146 SmallGrid,
147 LargeGrid,
148 DottedGrid,
149 SmallConfetti,
150 LargeConfetti,
151 HorizontalBrick,
152 DiagonalBrick,
153 SolidDiamond,
154 OpenDiamond,
155 DottedDiamond,
156 Plaid,
157 Sphere,
158 Weave,
159 Divot,
160 Shingle,
161 Wave,
162 Trellis,
163 ZigZag
166 class DOCMODEL_DLLPUBLIC PatternFill : public Fill
168 public:
169 PatternPreset mePatternPreset = PatternPreset::Unused;
170 ComplexColor maForegroundColor;
171 ComplexColor maBackgroundColor;
173 PatternFill()
174 : Fill(FillType::Pattern)
179 enum class BitmapMode
181 Unused,
182 Tile,
183 Stretch,
186 enum class FlipMode
188 None,
194 enum class RectangleAlignment
196 Unset,
197 TopLeft,
198 Top,
199 TopRight,
200 Left,
201 Center,
202 Right,
203 BottomLeft,
204 Bottom,
205 BottomRight
207 constexpr sal_uInt16 RECTANGLE_ALIGNMENT_COUNT
208 = static_cast<sal_uInt16>(RectangleAlignment::BottomRight) + 1;
210 enum class BlipEffectType
212 None,
213 AlphaBiLevel,
214 AlphaCeiling,
215 AlphaFloor,
216 AlphaInverse,
217 AlphaModulate,
218 AlphaModulateFixed,
219 AlphaReplace,
220 BiLevel,
221 Blur,
222 ColorChange,
223 ColorReplace,
224 DuoTone,
225 FillOverlay,
226 Grayscale,
227 HSL,
228 Luminance,
229 Tint,
232 class BlipEffect
234 public:
235 BlipEffectType meType = BlipEffectType::None;
237 sal_Int32 mnThreshold = 0; // AlphaBiLevel, BiLevel
238 ComplexColor maColor1; // AlphaInverse, ColorReplace, DuoTone, ColorChange (from)
239 ComplexColor maColor2; // DuoTone, ColorChange (to)
240 sal_Int32 mnAmount = 0; // AlphaModulateFixed, Tint
241 sal_Int32 mnRadius = 0; // Blur
242 bool mbGrow = false; // Blur
243 sal_Int32 mnAlpha = 0; // AlphaReplace
244 bool mbUseAlpha = false; // ColorChange
245 sal_Int32 mnHue = 0; // HSL, Tint
246 sal_Int32 mnSaturation = 0; // HSL
247 sal_Int32 mnLuminance = 0; // HSL
248 sal_Int32 mnBrightness = 0; // Luminance
249 sal_Int32 mnContrast = 0; // Luminance
251 ComplexColor& getColorFrom() { return maColor1; }
252 ComplexColor& getColorTo() { return maColor2; }
255 class DOCMODEL_DLLPUBLIC BlipFill : public Fill
257 public:
258 bool mbRotateWithShape = false;
259 RelativeRectangle maClipRectangle;
260 RelativeRectangle maFillRectangle;
261 BitmapMode meMode = BitmapMode::Unused;
263 sal_Int32 mnTileOffsetX = 0;
264 sal_Int32 mnTileOffsetY = 0;
265 sal_Int32 mnTileScaleX = 0;
266 sal_Int32 mnTileScaleY = 0;
267 FlipMode meTileFlipMode = FlipMode::None;
268 RectangleAlignment meTileAlignment = RectangleAlignment::TopLeft;
270 css::uno::Reference<css::graphic::XGraphic> mxGraphic;
271 std::vector<BlipEffect> maBlipEffects;
273 BlipFill()
274 : Fill(FillType::Blip)
279 class DOCMODEL_DLLPUBLIC FillStyle
281 public:
282 std::shared_ptr<Fill> mpFill;
285 enum class CapType
287 Unset,
288 Flat,
289 Round,
290 Square
293 enum class PenAlignmentType
295 Unset,
296 Center,
297 Inset
300 enum class CompoundLineType
302 Unset,
303 Single,
304 Double,
305 ThickThin_Double,
306 ThinThick_Double,
307 Triple,
310 enum class PresetDashType
312 Unset,
313 Dash,
314 DashDot,
315 Dot,
316 LargeDash,
317 LargeDashDot,
318 LargeDashDotDot,
319 Solid,
320 SystemDash,
321 SystemDashDot,
322 SystemDashDotDot,
323 SystemDot,
326 enum class LineJoinType
328 Unset,
329 Round,
330 Bevel,
331 Miter,
334 struct DOCMODEL_DLLPUBLIC LineJoin
336 LineJoinType meType = LineJoinType::Unset;
337 sal_Int32 mnMiterLimit = 0; // Percentage
340 enum class LineEndType
342 None,
343 Triangle,
344 Stealth,
345 Diamond,
346 Oval,
347 Arrow
350 enum class LineEndWidth
352 Unset,
353 Small,
354 Medium,
355 Large
358 enum class LineEndLength
360 Unset,
361 Small,
362 Medium,
363 Large
366 struct DOCMODEL_DLLPUBLIC LineEnd
368 LineEndType meType = LineEndType::None;
369 LineEndWidth meWidth = LineEndWidth::Unset;
370 LineEndLength meLength = LineEndLength::Unset;
373 struct DOCMODEL_DLLPUBLIC DashStop
375 sal_Int32 mnDashLength = 0;
376 sal_Int32 mnStopLength = 0;
379 struct DOCMODEL_DLLPUBLIC LineDash
381 PresetDashType mePresetType = PresetDashType::Unset;
382 std::vector<DashStop> maCustomList;
385 class DOCMODEL_DLLPUBLIC LineStyle
387 public:
388 sal_Int32 mnWidth;
389 CapType meCapType;
390 PenAlignmentType mePenAlignment;
391 CompoundLineType meCompoundLineType;
392 LineDash maLineDash;
393 LineJoin maLineJoin;
394 LineEnd maHeadEnd;
395 LineEnd maTailEnd;
397 FillStyle maLineFillStyle;
400 enum class EffectType
402 Unset,
403 OuterShadow,
404 InnerShadow,
405 Glow,
406 SoftEdge,
407 Reflection,
408 Blur
411 class DOCMODEL_DLLPUBLIC Effect
413 public:
414 EffectType meType = EffectType::Unset;
415 sal_Int32 mnBlurRadius = 0;
416 sal_Int32 mnRadius = 0;
417 sal_Int32 mnDistance = 0;
418 sal_Int32 mnDirection = 0;
419 sal_Int32 mnScaleX = 100;
420 sal_Int32 mnScaley = 100;
421 sal_Int32 mnScewX = 0;
422 sal_Int32 mnScewY = 0;
423 RectangleAlignment meAlignment = RectangleAlignment::Bottom;
424 bool mbRotateWithShape = true;
425 ComplexColor maColor;
426 double mnEndAlpha = 100.0;
427 double mnEndPosition = 0.0;
428 double mnStartAlpha = 0.0;
429 double mnStartPosition = 100.0;
430 sal_Int32 mnFadeDirection = 0;
431 bool mbGrow = false;
434 class DOCMODEL_DLLPUBLIC EffectStyle
436 public:
437 std::vector<Effect> maEffectList;
440 class DOCMODEL_DLLPUBLIC FormatScheme
442 private:
443 OUString maName;
444 std::vector<FillStyle> maFillStyleList;
445 std::vector<LineStyle> maLineStyleList;
446 std::vector<EffectStyle> maEffectStyleList;
447 std::vector<FillStyle> maBackgroundFillStyleList;
449 public:
450 FormatScheme() = default;
452 FormatScheme(OUString const& rName)
453 : maName(rName)
457 const OUString& getName() const { return maName; }
459 std::vector<FillStyle> const& getFillStyleList() const { return maFillStyleList; }
461 FillStyle* addFillStyle()
463 if (maFillStyleList.size() > 3)
464 return nullptr;
465 auto& rFillStyle = maFillStyleList.emplace_back();
466 return &rFillStyle;
469 void ensureFillStyleList() const
471 if (!maFillStyleList.empty())
472 return;
474 auto* pThis = const_cast<FormatScheme*>(this);
476 FillStyle* pFillStyle = pThis->addFillStyle();
477 auto pFill = std::make_shared<SolidFill>();
478 pFill->maColor.meType = model::ColorType::Placeholder;
479 pFillStyle->mpFill = pFill;
482 FillStyle* pFillStyle = pThis->addFillStyle();
483 auto pFill = std::make_shared<SolidFill>();
484 pFill->maColor.meType = model::ColorType::Placeholder;
485 pFillStyle->mpFill = pFill;
488 FillStyle* pFillStyle = pThis->addFillStyle();
489 auto pFill = std::make_shared<SolidFill>();
490 pFill->maColor.meType = model::ColorType::Placeholder;
491 pFillStyle->mpFill = pFill;
495 std::vector<LineStyle> const& getLineStyleList() const { return maLineStyleList; }
497 LineStyle* addLineStyle()
499 if (maLineStyleList.size() > 3)
500 return nullptr;
501 auto& rLineStyle = maLineStyleList.emplace_back();
502 return &rLineStyle;
505 void ensureLineStyleList() const
507 if (!maLineStyleList.empty())
508 return;
510 auto* pThis = const_cast<FormatScheme*>(this);
513 LineStyle* pLineStyle = pThis->addLineStyle();
514 pLineStyle->mnWidth = 6350;
515 pLineStyle->meCapType = CapType::Flat;
516 pLineStyle->mePenAlignment = PenAlignmentType::Center;
517 pLineStyle->meCompoundLineType = CompoundLineType::Single;
518 pLineStyle->maLineDash.mePresetType = PresetDashType::Solid;
519 pLineStyle->maLineJoin.meType = LineJoinType::Miter;
520 auto pFill = std::make_shared<SolidFill>();
521 pFill->maColor.meType = model::ColorType::Placeholder;
522 pLineStyle->maLineFillStyle.mpFill = pFill;
525 LineStyle* pLineStyle = pThis->addLineStyle();
526 pLineStyle->mnWidth = 6350;
527 pLineStyle->meCapType = CapType::Flat;
528 pLineStyle->mePenAlignment = PenAlignmentType::Center;
529 pLineStyle->meCompoundLineType = CompoundLineType::Single;
530 pLineStyle->maLineDash.mePresetType = PresetDashType::Solid;
531 pLineStyle->maLineJoin.meType = LineJoinType::Miter;
532 auto pFill = std::make_shared<SolidFill>();
533 pFill->maColor.meType = model::ColorType::Placeholder;
534 pLineStyle->maLineFillStyle.mpFill = pFill;
537 LineStyle* pLineStyle = pThis->addLineStyle();
538 pLineStyle->mnWidth = 6350;
539 pLineStyle->meCapType = CapType::Flat;
540 pLineStyle->mePenAlignment = PenAlignmentType::Center;
541 pLineStyle->meCompoundLineType = CompoundLineType::Single;
542 pLineStyle->maLineDash.mePresetType = PresetDashType::Solid;
543 pLineStyle->maLineJoin.meType = LineJoinType::Miter;
544 auto pFill = std::make_shared<SolidFill>();
545 pFill->maColor.meType = model::ColorType::Placeholder;
546 pLineStyle->maLineFillStyle.mpFill = pFill;
550 std::vector<EffectStyle> const& getEffectStyleList() const { return maEffectStyleList; }
552 EffectStyle* addEffectStyle()
554 if (maEffectStyleList.size() > 3)
555 return nullptr;
556 auto& rEffectStyle = maEffectStyleList.emplace_back();
557 return &rEffectStyle;
560 void ensureEffectStyleList() const
562 if (!maEffectStyleList.empty())
563 return;
565 auto* pThis = const_cast<FormatScheme*>(this);
567 pThis->addEffectStyle();
568 pThis->addEffectStyle();
569 pThis->addEffectStyle();
572 std::vector<FillStyle> const& getBackgroundFillStyleList() const
574 return maBackgroundFillStyleList;
577 FillStyle* addBackgroundFillStyle()
579 if (maBackgroundFillStyleList.size() > 3)
580 return nullptr;
581 auto& rBackgroundFillStyle = maBackgroundFillStyleList.emplace_back();
582 return &rBackgroundFillStyle;
585 void ensureBackgroundFillStyleList() const
587 if (!maBackgroundFillStyleList.empty())
588 return;
590 auto* pThis = const_cast<FormatScheme*>(this);
593 FillStyle* pFillStyle = pThis->addBackgroundFillStyle();
594 auto pFill = std::make_shared<SolidFill>();
595 pFill->maColor.meType = model::ColorType::Placeholder;
596 pFillStyle->mpFill = pFill;
599 FillStyle* pFillStyle = pThis->addBackgroundFillStyle();
600 auto pFill = std::make_shared<SolidFill>();
601 pFill->maColor.meType = model::ColorType::Placeholder;
602 pFillStyle->mpFill = pFill;
605 FillStyle* pFillStyle = pThis->addBackgroundFillStyle();
606 auto pFill = std::make_shared<SolidFill>();
607 pFill->maColor.meType = model::ColorType::Placeholder;
608 pFillStyle->mpFill = pFill;
613 } // end of namespace svx
615 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */