1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/.
13 #include <docmodel/dllapi.h>
14 #include <docmodel/color/ComplexColor.hxx>
15 #include <com/sun/star/graphic/XGraphic.hpp>
28 class DOCMODEL_DLLPUBLIC Fill
39 class DOCMODEL_DLLPUBLIC NoFill
: public Fill
43 : Fill(FillType::None
)
48 class DOCMODEL_DLLPUBLIC SolidFill
: public Fill
54 : Fill(FillType::Solid
)
59 class DOCMODEL_DLLPUBLIC GradientStop
62 double mfPosition
= 0.0; // 0.0 - 1.0
66 enum class GradientType
75 struct DOCMODEL_DLLPUBLIC LinearGradientProperties
77 sal_Int32 mnAngle
= 0;
78 bool mbScaled
= false;
81 struct DOCMODEL_DLLPUBLIC RelativeRectangle
85 sal_Int32 mnRight
= 0;
86 sal_Int32 mnBottom
= 0;
89 class DOCMODEL_DLLPUBLIC GradientFill
: public Fill
92 bool mbRotateWithShape
= false;
93 GradientType meGradientType
= GradientType::Undefined
;
94 std::vector
<GradientStop
> maGradientStops
;
95 LinearGradientProperties maLinearGradient
;
96 RelativeRectangle maFillToRectangle
;
97 RelativeRectangle maTileRectangle
;
100 : Fill(FillType::Gradient
)
105 enum class PatternPreset
133 LightDownwardDiagonal
,
135 DarkDownwardDiagonal
,
137 WideDownwardDiagonal
,
139 DashedDownwardDiagonal
,
140 DashedUpwardDiagonal
,
164 class DOCMODEL_DLLPUBLIC PatternFill
: public Fill
167 PatternPreset mePatternPreset
= PatternPreset::Unused
;
168 ComplexColor maForegroundColor
;
169 ComplexColor maBackgroundColor
;
172 : Fill(FillType::Pattern
)
177 enum class BitmapMode
192 enum class RectangleAlignment
205 constexpr sal_uInt16 RECTANGLE_ALIGNMENT_COUNT
206 = static_cast<sal_uInt16
>(RectangleAlignment::BottomRight
) + 1;
208 enum class BlipEffectType
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
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
;
272 : Fill(FillType::Blip
)
277 class DOCMODEL_DLLPUBLIC FillStyle
280 std::shared_ptr
<Fill
> mpFill
;
291 enum class PenAlignmentType
298 enum class CompoundLineType
308 enum class PresetDashType
324 enum class LineJoinType
332 struct DOCMODEL_DLLPUBLIC LineJoin
334 LineJoinType meType
= LineJoinType::Unset
;
335 sal_Int32 mnMiterLimit
= 0; // Percentage
338 enum class LineEndType
348 enum class LineEndWidth
356 enum class LineEndLength
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
388 PenAlignmentType mePenAlignment
;
389 CompoundLineType meCompoundLineType
;
395 FillStyle maLineFillStyle
;
398 enum class EffectType
409 class DOCMODEL_DLLPUBLIC Effect
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;
432 class DOCMODEL_DLLPUBLIC EffectStyle
435 std::vector
<Effect
> maEffectList
;
438 class DOCMODEL_DLLPUBLIC FormatScheme
442 std::vector
<FillStyle
> maFillStyleList
;
443 std::vector
<LineStyle
> maLineStyleList
;
444 std::vector
<EffectStyle
> maEffectStyleList
;
445 std::vector
<FillStyle
> maBackgroundFillStyleList
;
448 FormatScheme() = default;
450 FormatScheme(OUString
const& 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)
463 auto& rFillStyle
= maFillStyleList
.emplace_back();
467 void ensureFillStyleList() const
469 if (!maFillStyleList
.empty())
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)
499 auto& rLineStyle
= maLineStyleList
.emplace_back();
503 void ensureLineStyleList() const
505 if (!maLineStyleList
.empty())
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)
554 auto& rEffectStyle
= maEffectStyleList
.emplace_back();
555 return &rEffectStyle
;
558 void ensureEffectStyleList() const
560 if (!maEffectStyleList
.empty())
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)
579 auto& rBackgroundFillStyle
= maBackgroundFillStyleList
.emplace_back();
580 return &rBackgroundFillStyle
;
583 void ensureBackgroundFillStyleList() const
585 if (!maBackgroundFillStyleList
.empty())
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: */