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 <tools/color.hxx>
15 #include <docmodel/theme/ThemeColor.hxx>
16 #include <docmodel/color/ComplexColor.hxx>
17 #include <com/sun/star/graphic/XGraphic.hpp>
30 class DOCMODEL_DLLPUBLIC Fill
41 class DOCMODEL_DLLPUBLIC NoFill
: public Fill
45 : Fill(FillType::None
)
50 class DOCMODEL_DLLPUBLIC SolidFill
: public Fill
56 : Fill(FillType::Solid
)
61 class DOCMODEL_DLLPUBLIC GradientStop
64 double mfPosition
= 0.0; // 0.0 - 1.0
68 enum class GradientType
77 struct DOCMODEL_DLLPUBLIC LinearGradientProperties
79 sal_Int32 mnAngle
= 0;
80 bool mbScaled
= false;
83 struct DOCMODEL_DLLPUBLIC RelativeRectangle
87 sal_Int32 mnRight
= 0;
88 sal_Int32 mnBottom
= 0;
91 class DOCMODEL_DLLPUBLIC GradientFill
: public Fill
94 bool mbRotateWithShape
= false;
95 GradientType meGradientType
= GradientType::Undefined
;
96 std::vector
<GradientStop
> maGradientStops
;
97 LinearGradientProperties maLinearGradient
;
98 RelativeRectangle maFillToRectangle
;
99 RelativeRectangle maTileRectangle
;
102 : Fill(FillType::Gradient
)
107 enum class PatternPreset
135 LightDownwardDiagonal
,
137 DarkDownwardDiagonal
,
139 WideDownwardDiagonal
,
141 DashedDownwardDiagonal
,
142 DashedUpwardDiagonal
,
166 class DOCMODEL_DLLPUBLIC PatternFill
: public Fill
169 PatternPreset mePatternPreset
= PatternPreset::Unused
;
170 ComplexColor maForegroundColor
;
171 ComplexColor maBackgroundColor
;
174 : Fill(FillType::Pattern
)
179 enum class BitmapMode
194 enum class RectangleAlignment
207 constexpr sal_uInt16 RECTANGLE_ALIGNMENT_COUNT
208 = static_cast<sal_uInt16
>(RectangleAlignment::BottomRight
) + 1;
210 enum class BlipEffectType
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
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
;
274 : Fill(FillType::Blip
)
279 class DOCMODEL_DLLPUBLIC FillStyle
282 std::shared_ptr
<Fill
> mpFill
;
293 enum class PenAlignmentType
300 enum class CompoundLineType
310 enum class PresetDashType
326 enum class LineJoinType
334 struct DOCMODEL_DLLPUBLIC LineJoin
336 LineJoinType meType
= LineJoinType::Unset
;
337 sal_Int32 mnMiterLimit
= 0; // Percentage
340 enum class LineEndType
350 enum class LineEndWidth
358 enum class LineEndLength
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
390 PenAlignmentType mePenAlignment
;
391 CompoundLineType meCompoundLineType
;
397 FillStyle maLineFillStyle
;
400 enum class EffectType
411 class DOCMODEL_DLLPUBLIC Effect
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;
434 class DOCMODEL_DLLPUBLIC EffectStyle
437 std::vector
<Effect
> maEffectList
;
440 class DOCMODEL_DLLPUBLIC FormatScheme
444 std::vector
<FillStyle
> maFillStyleList
;
445 std::vector
<LineStyle
> maLineStyleList
;
446 std::vector
<EffectStyle
> maEffectStyleList
;
447 std::vector
<FillStyle
> maBackgroundFillStyleList
;
450 FormatScheme() = default;
452 FormatScheme(OUString
const& 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)
465 auto& rFillStyle
= maFillStyleList
.emplace_back();
469 void ensureFillStyleList() const
471 if (!maFillStyleList
.empty())
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)
501 auto& rLineStyle
= maLineStyleList
.emplace_back();
505 void ensureLineStyleList() const
507 if (!maLineStyleList
.empty())
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)
556 auto& rEffectStyle
= maEffectStyleList
.emplace_back();
557 return &rEffectStyle
;
560 void ensureEffectStyleList() const
562 if (!maEffectStyleList
.empty())
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)
581 auto& rBackgroundFillStyle
= maBackgroundFillStyleList
.emplace_back();
582 return &rBackgroundFillStyle
;
585 void ensureBackgroundFillStyleList() const
587 if (!maBackgroundFillStyleList
.empty())
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: */