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/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_OOX_INC_DRAWINGML_FILLPROPERTIES_HXX
21 #define INCLUDED_OOX_INC_DRAWINGML_FILLPROPERTIES_HXX
25 #include <com/sun/star/beans/PropertyValue.hpp>
26 #include <com/sun/star/geometry/IntegerRectangle2D.hpp>
27 #include <com/sun/star/awt/Size.hpp>
28 #include <com/sun/star/uno/Any.hxx>
29 #include <com/sun/star/uno/Reference.hxx>
30 #include <oox/drawingml/color.hxx>
31 #include <oox/helper/helper.hxx>
32 #include <oox/ole/oleobjecthelper.hxx>
33 #include <rtl/ustring.hxx>
34 #include <sal/types.h>
36 namespace com::sun::star
{
37 namespace graphic
{ class XGraphic
; }
44 namespace oox::drawingml
{
46 class ShapePropertyMap
;
48 struct GradientFillProperties
50 typedef ::std::multimap
< double, Color
> GradientStopMap
;
52 GradientStopMap maGradientStops
; /// Gradient stops (colors/transparence).
53 std::optional
< css::geometry::IntegerRectangle2D
> moFillToRect
;
54 std::optional
< css::geometry::IntegerRectangle2D
> moTileRect
;
55 std::optional
< sal_Int32
> moGradientPath
; /// If set, gradient follows rectangle, circle, or shape.
56 std::optional
< sal_Int32
> moShadeAngle
; /// Rotation angle of linear gradients.
57 std::optional
< sal_Int32
> moShadeFlip
; /// Flip mode of gradient, if not stretched to shape.
58 std::optional
< bool > moShadeScaled
; /// True = scale gradient into shape.
59 std::optional
< bool > moRotateWithShape
; /// True = rotate gradient with shape.
61 /** Overwrites all members that are explicitly set in rSourceProps. */
62 void assignUsed( const GradientFillProperties
& rSourceProps
);
65 struct PatternFillProperties
67 Color maPattFgColor
; /// Pattern foreground color.
68 Color maPattBgColor
; /// Pattern background color.
69 std::optional
< sal_Int32
> moPattPreset
; /// Preset pattern type.
71 /** Overwrites all members that are explicitly set in rSourceProps. */
72 void assignUsed( const PatternFillProperties
& rSourceProps
);
75 struct ArtisticEffectProperties
78 std::map
< OUString
, css::uno::Any
>
80 ::oox::ole::OleObjectInfo mrOleObjectInfo
; /// The original graphic as embedded object.
84 /** Returns the struct as a PropertyValue with Name = msName and
85 * Value = maAttribs as a Sequence< PropertyValue >. */
86 css::beans::PropertyValue
getEffect();
88 /** Overwrites all members that are explicitly set in rSourceProps. */
89 void assignUsed( const ArtisticEffectProperties
& rSourceProps
);
91 /** Translate effect tokens to strings. */
92 static OUString
getEffectString( sal_Int32 nToken
);
94 /** Translate effect strings to tokens. */
95 static sal_Int32
getEffectToken( const OUString
& sName
);
98 struct BlipFillProperties
100 css::uno::Reference
<css::graphic::XGraphic
> mxFillGraphic
; /// The fill graphic.
101 std::optional
< sal_Int32
> moBitmapMode
; /// Bitmap tile or stretch.
102 std::optional
< css::geometry::IntegerRectangle2D
>
103 moFillRect
; /// Stretch fill offsets.
104 std::optional
< css::geometry::IntegerRectangle2D
>
106 std::optional
< sal_Int32
> moTileOffsetX
; /// Width of bitmap tiles (EMUs).
107 std::optional
< sal_Int32
> moTileOffsetY
; /// Height of bitmap tiles (EMUs).
108 std::optional
< sal_Int32
> moTileScaleX
; /// Horizontal scaling of bitmap tiles (1/1000 percent).
109 std::optional
< sal_Int32
> moTileScaleY
; /// Vertical scaling of bitmap tiles (1/1000 percent).
110 std::optional
< sal_Int32
> moTileAlign
; /// Anchor point inside bitmap.
111 std::optional
< sal_Int32
> moTileFlip
; /// Flip mode of bitmap tiles.
112 std::optional
< bool > moRotateWithShape
; /// True = rotate bitmap with shape.
114 std::optional
< sal_Int32
> moColorEffect
; /// XML token for a color effect.
115 std::optional
< sal_Int32
> moBrightness
; /// Brightness in the range [-100000,100000].
116 std::optional
< sal_Int32
> moContrast
; /// Contrast in the range [-100000,100000].
117 std::optional
< sal_Int32
> moBiLevelThreshold
; /// Bi-Level (Black/White) effect threshold (1/1000 percent)
118 Color maColorChangeFrom
; /// Start color of color transformation.
119 Color maColorChangeTo
; /// Destination color of color transformation.
120 Color maDuotoneColors
[2]; /// Duotone Colors
122 ArtisticEffectProperties maEffect
; /// Artistic effect, not supported by core.
123 std::optional
<sal_Int32
> moAlphaModFix
; ///< Alpha Modulate Fixed Effect.
125 /** Overwrites all members that are explicitly set in rSourceProps. */
126 void assignUsed( const BlipFillProperties
& rSourceProps
);
129 struct FillProperties
131 std::optional
< sal_Int32
> moFillType
; /// Fill type (OOXML token).
132 Color maFillColor
; /// Solid fill color and transparence.
133 std::optional
< bool > moUseBgFill
; /// Whether the background is used as fill type
134 GradientFillProperties maGradientProps
; /// Properties for gradient fills.
135 PatternFillProperties maPatternProps
; /// Properties for pattern fills.
136 BlipFillProperties maBlipProps
; /// Properties for bitmap fills.
138 /** Overwrites all members that are explicitly set in rSourceProps. */
139 void assignUsed( const FillProperties
& rSourceProps
);
141 /** Tries to resolve current settings to a solid color, e.g. returns the
142 start color of a gradient. */
143 Color
getBestSolidColor() const;
145 /** Writes the properties to the passed property map. */
147 ShapePropertyMap
& rPropMap
,
148 const GraphicHelper
& rGraphicHelper
,
149 sal_Int32 nShapeRotation
= 0,
150 ::Color nPhClr
= API_RGB_TRANSPARENT
,
151 const css::awt::Size
& rSize
= {},
152 sal_Int16 nPhClrTheme
= -1,
155 bool bIsCustomShape
= false ) const;
158 } // namespace oox::drawingml
162 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */