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_VML_VMLFORMATTING_HXX
21 #define INCLUDED_OOX_VML_VMLFORMATTING_HXX
23 #include <oox/helper/helper.hxx>
24 #include <oox/dllapi.h>
25 #include <com/sun/star/awt/Point.hpp>
26 #include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp>
27 #include <com/sun/star/drawing/XShape.hpp>
33 namespace drawingml
{ class Color
; }
34 namespace drawingml
{ class ShapePropertyMap
; }
41 typedef ::std::pair
< sal_Int32
, sal_Int32
> Int32Pair
;
42 typedef ::std::pair
< double, double > DoublePair
;
45 namespace ConversionHelper
47 /** Returns two values contained in rValue separated by cSep.
49 OOX_DLLPUBLIC
bool separatePair(
50 OUString
& orValue1
, OUString
& orValue2
,
51 const OUString
& rValue
, sal_Unicode cSep
);
53 /** Returns the boolean value from the passed string of a VML attribute.
54 Supported values: 'f', 't', 'false', 'true'. False for anything else.
56 OOX_DLLPUBLIC
bool decodeBool( const OUString
& rValue
);
58 /** Converts the passed VML percentage measure string to a normalized
61 @param rValue The VML percentage value. This is a floating-point value
62 with optional following '%' or 'f' sign. If the sign is missing, the
63 floating point value will be returned unmodified. If the '%' sign
64 is present, the value will be divided by 100. If the 'f' sign is present,
65 the value will be divided by 65536.
67 OOX_DLLPUBLIC
double decodePercent(
68 const OUString
& rValue
,
71 /** Converts the passed VML measure string to EMU (English Metric Units).
73 @param rGraphicHelper The graphic helper needed to perform pixel
74 conversion according to the current output device.
76 @param rValue The VML measure value. This is a floating-point value
77 with optional measure string following the value.
79 @param nRefValue Reference value needed for percentage measure.
81 @param bPixelX Set to true if the value is oriented horizontally (e.g.
82 X coordinates, widths). Set to false if the value is oriented
83 vertically (e.g. Y coordinates, heights). This is needed because
84 output devices may specify different width and height for a pixel.
86 @param bDefaultAsPixel Set to true if omitted measure unit means
87 pixel. Set to false if omitted measure unit means EMU.
89 OOX_DLLPUBLIC sal_Int64
decodeMeasureToEmu(
90 const GraphicHelper
& rGraphicHelper
,
91 const OUString
& rValue
,
94 bool bDefaultAsPixel
);
96 /** Converts the passed VML measure string to 1/100 mm.
98 @param rGraphicHelper See above.
99 @param rValue See above.
100 @param nRefValue See above.
101 @param bPixelX See above.
102 @param bDefaultAsPixel See above.
104 OOX_DLLPUBLIC sal_Int32
decodeMeasureToHmm(
105 const GraphicHelper
& rGraphicHelper
,
106 const OUString
& rValue
,
109 bool bDefaultAsPixel
);
111 /** Converts VML color attributes to a DrawingML color.
113 @param roVmlColor The VML string representation of the color. If
114 existing, this can be a 3-digit or 6-digit hexadecimal RGB value
115 with leading '#' character, a predefined color name (e.g. 'black',
116 'red', etc.), the index into an application defined color palette
117 in brackets with leading color name (e.g. 'red [9]' or
118 'windowColor [64]'), or a color modifier used in one-color
119 gradients (e.g. 'fill darken(128)' or 'fill lighten(0)').
121 @param roVmlOpacity The opacity of the color. If existing, this should
122 be a floating-point value in the range [0.0;1.0].
124 @param nDefaultRgb Default RGB color used if the parameter roVmlColor
127 @param nPrimaryRgb If set to something else than API_RGB_TRANSPARENT,
128 specifies the color to be used to resolve the color modifiers used
129 in one-color gradients.
131 @return The resulting DrawingML color.
133 OOX_DLLPUBLIC ::oox::drawingml::Color
decodeColor(
134 const GraphicHelper
& rGraphicHelper
,
135 const OptValue
< OUString
>& roVmlColor
,
136 const OptValue
< double >& roVmlOpacity
,
137 sal_Int32 nDefaultRgb
,
138 sal_Int32 nPrimaryRgb
= API_RGB_TRANSPARENT
);
140 /** Converts VML path string into point and flag vectors.
142 @param rPoints The point vector to fill with coordinates.
144 @param rFlags The flag vector to fill. PolygonFlags_NORMAL indicates
145 a corresponding plain shape coordinate in rPoints and
146 PolygonFlags_CONTROL indicates a bezier curve control point.
148 @param rPath The VML path string.
150 @param rGraphicHelper See above.
152 OOX_DLLPUBLIC
void decodeVmlPath(
153 ::std::vector
< ::std::vector
< css::awt::Point
> >& rPoints
,
154 ::std::vector
< ::std::vector
< css::drawing::PolygonFlags
> >& rFlags
,
155 const OUString
& rPath
);
159 /** The stroke arrow model structure contains all properties for an line end arrow. */
160 struct StrokeArrowModel
162 OptValue
< sal_Int32
> moArrowType
;
163 OptValue
< sal_Int32
> moArrowWidth
;
164 OptValue
< sal_Int32
> moArrowLength
;
166 void assignUsed( const StrokeArrowModel
& rSource
);
170 /** The stroke model structure contains all shape border properties. */
173 OptValue
< bool > moStroked
; ///< Shape border line on/off.
174 StrokeArrowModel maStartArrow
; ///< Start line arrow style.
175 StrokeArrowModel maEndArrow
; ///< End line arrow style.
176 OptValue
< OUString
> moColor
; ///< Solid line color.
177 OptValue
< double > moOpacity
; ///< Solid line color opacity.
178 OptValue
< OUString
> moWeight
; ///< Line width.
179 OptValue
< OUString
> moDashStyle
; ///< Line dash (predefined or manually).
180 OptValue
< sal_Int32
> moLineStyle
; ///< Line style (single, double, ...).
181 OptValue
< sal_Int32
> moEndCap
; ///< Type of line end cap.
182 OptValue
< sal_Int32
> moJoinStyle
; ///< Type of line join.
184 void assignUsed( const StrokeModel
& rSource
);
186 /** Writes the properties to the passed property map. */
188 ::oox::drawingml::ShapePropertyMap
& rPropMap
,
189 const GraphicHelper
& rGraphicHelper
) const;
193 /** The fill model structure contains all shape fill properties. */
194 struct OOX_DLLPUBLIC FillModel
196 OptValue
< bool > moFilled
; ///< Shape fill on/off.
197 OptValue
< OUString
> moColor
; ///< Solid fill color.
198 OptValue
< double > moOpacity
; ///< Solid fill color opacity.
199 OptValue
< OUString
> moColor2
; ///< End color of gradient.
200 OptValue
< double > moOpacity2
; ///< End color opacity of gradient.
201 OptValue
< sal_Int32
> moType
; ///< Fill type.
202 OptValue
< sal_Int32
> moAngle
; ///< Gradient rotation angle.
203 OptValue
< double > moFocus
; ///< Linear gradient focus of second color.
204 OptValue
< DoublePair
> moFocusPos
; ///< Rectangular gradient focus position of second color.
205 OptValue
< DoublePair
> moFocusSize
; ///< Rectangular gradient focus size of second color.
206 OptValue
< OUString
> moBitmapPath
; ///< Path to fill bitmap fragment.
207 OptValue
< bool > moRotate
; ///< True = rotate gradient/bitmap with shape.
209 void assignUsed( const FillModel
& rSource
);
211 /** Writes the properties to the passed property map. */
213 ::oox::drawingml::ShapePropertyMap
& rPropMap
,
214 const GraphicHelper
& rGraphicHelper
) const;
218 /** The shadow model structure contains all shape shadow properties. */
219 struct OOX_DLLPUBLIC ShadowModel
221 bool mbHasShadow
; ///< Is a v:shadow element seen?
222 OptValue
<bool> moShadowOn
; ///< Is the element turned on?
223 OptValue
<OUString
> moColor
; ///< Specifies the color of the shadow.
224 OptValue
<OUString
> moOffset
; ///< Specifies the shadow's offset from the shape's location.
225 OptValue
<double> moOpacity
; ///< Specifies the opacity of the shadow.
229 /** Writes the properties to the passed property map. */
230 void pushToPropMap(oox::drawingml::ShapePropertyMap
& rPropMap
, const GraphicHelper
& rGraphicHelper
) const;
233 /** The shadow model structure contains all shape textpath properties. */
234 struct OOX_DLLPUBLIC TextpathModel
236 OptValue
<OUString
> moString
; ///< Specifies the string of the textpath.
240 /** Writes the properties to the passed property map. */
241 void pushToPropMap(oox::drawingml::ShapePropertyMap
& rPropMap
, const css::uno::Reference
<css::drawing::XShape
>& xShape
) const;
249 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */