Fix rudimentary Emscripten Qt6 copy -> paste support
[LibreOffice.git] / include / docmodel / theme / FormatScheme.hxx
blobeb1eea3fbdcae161dc4443d2c6adb8ff7836ab6b
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 <docmodel/color/ComplexColor.hxx>
15 #include <com/sun/star/graphic/XGraphic.hpp>
17 namespace model
19 enum class FillType
21 None,
22 Solid,
23 Gradient,
24 Pattern,
25 Blip
28 class DOCMODEL_DLLPUBLIC Fill
30 public:
31 Fill(FillType eType)
32 : meType(eType)
36 FillType meType;
39 class DOCMODEL_DLLPUBLIC NoFill : public Fill
41 public:
42 NoFill()
43 : Fill(FillType::None)
48 class DOCMODEL_DLLPUBLIC SolidFill : public Fill
50 public:
51 ComplexColor maColor;
53 SolidFill()
54 : Fill(FillType::Solid)
59 class DOCMODEL_DLLPUBLIC GradientStop
61 public:
62 double mfPosition = 0.0; // 0.0 - 1.0
63 ComplexColor maColor;
66 enum class GradientType
68 Undefined,
69 Linear,
70 Circle,
71 Rectangle,
72 Shape,
75 struct DOCMODEL_DLLPUBLIC LinearGradientProperties
77 sal_Int32 mnAngle = 0;
78 bool mbScaled = false;
81 struct DOCMODEL_DLLPUBLIC RelativeRectangle
83 sal_Int32 mnLeft = 0;
84 sal_Int32 mnTop = 0;
85 sal_Int32 mnRight = 0;
86 sal_Int32 mnBottom = 0;
89 class DOCMODEL_DLLPUBLIC GradientFill : public Fill
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;
99 GradientFill()
100 : Fill(FillType::Gradient)
105 enum class PatternPreset
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
164 class DOCMODEL_DLLPUBLIC PatternFill : public Fill
166 public:
167 PatternPreset mePatternPreset = PatternPreset::Unused;
168 ComplexColor maForegroundColor;
169 ComplexColor maBackgroundColor;
171 PatternFill()
172 : Fill(FillType::Pattern)
177 enum class BitmapMode
179 Unused,
180 Tile,
181 Stretch,
184 enum class FlipMode
186 None,
192 enum class RectangleAlignment
194 Unset,
195 TopLeft,
196 Top,
197 TopRight,
198 Left,
199 Center,
200 Right,
201 BottomLeft,
202 Bottom,
203 BottomRight
205 constexpr sal_uInt16 RECTANGLE_ALIGNMENT_COUNT
206 = static_cast<sal_uInt16>(RectangleAlignment::BottomRight) + 1;
208 enum class BlipEffectType
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,
230 class BlipEffect
232 public:
233 BlipEffectType meType = BlipEffectType::None;
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
249 ComplexColor& getColorFrom() { return maColor1; }
250 ComplexColor& getColorTo() { return maColor2; }
253 class DOCMODEL_DLLPUBLIC BlipFill : public Fill
255 public:
256 bool mbRotateWithShape = false;
257 RelativeRectangle maClipRectangle;
258 RelativeRectangle maFillRectangle;
259 BitmapMode meMode = BitmapMode::Unused;
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;
268 css::uno::Reference<css::graphic::XGraphic> mxGraphic;
269 std::vector<BlipEffect> maBlipEffects;
271 BlipFill()
272 : Fill(FillType::Blip)
277 class DOCMODEL_DLLPUBLIC FillStyle
279 public:
280 std::shared_ptr<Fill> mpFill;
283 enum class CapType
285 Unset,
286 Flat,
287 Round,
288 Square
291 enum class PenAlignmentType
293 Unset,
294 Center,
295 Inset
298 enum class CompoundLineType
300 Unset,
301 Single,
302 Double,
303 ThickThin_Double,
304 ThinThick_Double,
305 Triple,
308 enum class PresetDashType
310 Unset,
311 Dash,
312 DashDot,
313 Dot,
314 LargeDash,
315 LargeDashDot,
316 LargeDashDotDot,
317 Solid,
318 SystemDash,
319 SystemDashDot,
320 SystemDashDotDot,
321 SystemDot,
324 enum class LineJoinType
326 Unset,
327 Round,
328 Bevel,
329 Miter,
332 struct DOCMODEL_DLLPUBLIC LineJoin
334 LineJoinType meType = LineJoinType::Unset;
335 sal_Int32 mnMiterLimit = 0; // Percentage
338 enum class LineEndType
340 None,
341 Triangle,
342 Stealth,
343 Diamond,
344 Oval,
345 Arrow
348 enum class LineEndWidth
350 Unset,
351 Small,
352 Medium,
353 Large
356 enum class LineEndLength
358 Unset,
359 Small,
360 Medium,
361 Large
364 struct DOCMODEL_DLLPUBLIC LineEnd
366 LineEndType meType = LineEndType::None;
367 LineEndWidth meWidth = LineEndWidth::Unset;
368 LineEndLength meLength = LineEndLength::Unset;
371 struct DOCMODEL_DLLPUBLIC DashStop
373 sal_Int32 mnDashLength = 0;
374 sal_Int32 mnStopLength = 0;
377 struct DOCMODEL_DLLPUBLIC LineDash
379 PresetDashType mePresetType = PresetDashType::Unset;
380 std::vector<DashStop> maCustomList;
383 class DOCMODEL_DLLPUBLIC LineStyle
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;
395 FillStyle maLineFillStyle;
398 enum class EffectType
400 Unset,
401 OuterShadow,
402 InnerShadow,
403 Glow,
404 SoftEdge,
405 Reflection,
406 Blur
409 class DOCMODEL_DLLPUBLIC Effect
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;
432 class DOCMODEL_DLLPUBLIC EffectStyle
434 public:
435 std::vector<Effect> maEffectList;
438 class DOCMODEL_DLLPUBLIC FormatScheme
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;
447 public:
448 FormatScheme() = default;
450 FormatScheme(OUString const& rName)
451 : maName(rName)
455 const OUString& getName() const { return maName; }
457 std::vector<FillStyle> const& getFillStyleList() const { return maFillStyleList; }
459 FillStyle* addFillStyle()
461 if (maFillStyleList.size() > 3)
462 return nullptr;
463 auto& rFillStyle = maFillStyleList.emplace_back();
464 return &rFillStyle;
467 void ensureFillStyleList() const
469 if (!maFillStyleList.empty())
470 return;
472 auto* pThis = const_cast<FormatScheme*>(this);
474 FillStyle* pFillStyle = pThis->addFillStyle();
475 auto pFill = std::make_shared<SolidFill>();
476 pFill->maColor.setThemePlaceholder();
477 pFillStyle->mpFill = pFill;
480 FillStyle* pFillStyle = pThis->addFillStyle();
481 auto pFill = std::make_shared<SolidFill>();
482 pFill->maColor.setThemePlaceholder();
483 pFillStyle->mpFill = pFill;
486 FillStyle* pFillStyle = pThis->addFillStyle();
487 auto pFill = std::make_shared<SolidFill>();
488 pFill->maColor.setThemePlaceholder();
489 pFillStyle->mpFill = pFill;
493 std::vector<LineStyle> const& getLineStyleList() const { return maLineStyleList; }
495 LineStyle* addLineStyle()
497 if (maLineStyleList.size() > 3)
498 return nullptr;
499 auto& rLineStyle = maLineStyleList.emplace_back();
500 return &rLineStyle;
503 void ensureLineStyleList() const
505 if (!maLineStyleList.empty())
506 return;
508 auto* pThis = const_cast<FormatScheme*>(this);
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;
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;
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;
548 std::vector<EffectStyle> const& getEffectStyleList() const { return maEffectStyleList; }
550 EffectStyle* addEffectStyle()
552 if (maEffectStyleList.size() > 3)
553 return nullptr;
554 auto& rEffectStyle = maEffectStyleList.emplace_back();
555 return &rEffectStyle;
558 void ensureEffectStyleList() const
560 if (!maEffectStyleList.empty())
561 return;
563 auto* pThis = const_cast<FormatScheme*>(this);
565 pThis->addEffectStyle();
566 pThis->addEffectStyle();
567 pThis->addEffectStyle();
570 std::vector<FillStyle> const& getBackgroundFillStyleList() const
572 return maBackgroundFillStyleList;
575 FillStyle* addBackgroundFillStyle()
577 if (maBackgroundFillStyleList.size() > 3)
578 return nullptr;
579 auto& rBackgroundFillStyle = maBackgroundFillStyleList.emplace_back();
580 return &rBackgroundFillStyle;
583 void ensureBackgroundFillStyleList() const
585 if (!maBackgroundFillStyleList.empty())
586 return;
588 auto* pThis = const_cast<FormatScheme*>(this);
591 FillStyle* pFillStyle = pThis->addBackgroundFillStyle();
592 auto pFill = std::make_shared<SolidFill>();
593 pFill->maColor.setThemePlaceholder();
594 pFillStyle->mpFill = pFill;
597 FillStyle* pFillStyle = pThis->addBackgroundFillStyle();
598 auto pFill = std::make_shared<SolidFill>();
599 pFill->maColor.setThemePlaceholder();
600 pFillStyle->mpFill = pFill;
603 FillStyle* pFillStyle = pThis->addBackgroundFillStyle();
604 auto pFill = std::make_shared<SolidFill>();
605 pFill->maColor.setThemePlaceholder();
606 pFillStyle->mpFill = pFill;
611 } // end of namespace svx
613 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */