Branch libreoffice-5-0-4
[LibreOffice.git] / include / oox / vml / vmlformatting.hxx
blobdaaaef965cbcf9d4636558969ff6abcf6c4abfdf
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 * 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>
29 #include <vector>
31 namespace oox {
32 class GraphicHelper;
33 namespace drawingml { class Color; }
34 namespace drawingml { class ShapePropertyMap; }
37 namespace oox {
38 namespace vml {
42 typedef ::std::pair< sal_Int32, sal_Int32 > Int32Pair;
43 typedef ::std::pair< double, double > DoublePair;
47 namespace ConversionHelper
49 /** Returns two values contained in rValue separated by cSep.
51 OOX_DLLPUBLIC bool separatePair(
52 OUString& orValue1, OUString& orValue2,
53 const OUString& rValue, sal_Unicode cSep );
55 /** Returns the boolean value from the passed string of a VML attribute.
56 Supported values: 'f', 't', 'false', 'true'. False for anything else.
58 OOX_DLLPUBLIC bool decodeBool( const OUString& rValue );
60 /** Converts the passed VML percentage measure string to a normalized
61 floating-point value.
63 @param rValue The VML percentage value. This is a floating-point value
64 with optional following '%' or 'f' sign. If the sign is missing, the
65 floating point value will be returned unmodified. If the '%' sign
66 is present, the value will be divided by 100. If the 'f' sign is present,
67 the value will be divided by 65536.
69 OOX_DLLPUBLIC double decodePercent(
70 const OUString& rValue,
71 double fDefValue );
73 /** Converts the passed VML measure string to EMU (English Metric Units).
75 @param rGraphicHelper The graphic helper needed to perform pixel
76 conversion according to the current output device.
78 @param rValue The VML measure value. This is a floating-point value
79 with optional measure string following the value.
81 @param nRefValue Reference value needed for percentage measure.
83 @param bPixelX Set to true if the value is oriented horizontally (e.g.
84 X coordinates, widths). Set to false if the value is oriented
85 vertically (e.g. Y coordinates, heights). This is needed because
86 output devices may specify different width and height for a pixel.
88 @param bDefaultAsPixel Set to true if omitted measure unit means
89 pixel. Set to false if omitted measure unit means EMU.
91 OOX_DLLPUBLIC sal_Int64 decodeMeasureToEmu(
92 const GraphicHelper& rGraphicHelper,
93 const OUString& rValue,
94 sal_Int32 nRefValue,
95 bool bPixelX,
96 bool bDefaultAsPixel );
98 /** Converts the passed VML measure string to 1/100 mm.
100 @param rGraphicHelper See above.
101 @param rValue See above.
102 @param nRefValue See above.
103 @param bPixelX See above.
104 @param bDefaultAsPixel See above.
106 OOX_DLLPUBLIC sal_Int32 decodeMeasureToHmm(
107 const GraphicHelper& rGraphicHelper,
108 const OUString& rValue,
109 sal_Int32 nRefValue,
110 bool bPixelX,
111 bool bDefaultAsPixel );
113 /** Converts VML color attributes to a DrawingML color.
115 @param roVmlColor The VML string representation of the color. If
116 existing, this can be a 3-digit or 6-digit hexadecimal RGB value
117 with leading '#' character, a predefined color name (e.g. 'black',
118 'red', etc.), the index into an application defined color palette
119 in brackets with leading color name (e.g. 'red [9]' or
120 'windowColor [64]'), or a color modifier used in one-color
121 gradients (e.g. 'fill darken(128)' or 'fill lighten(0)').
123 @param roVmlOpacity The opacity of the color. If existing, this should
124 be a floating-point value in the range [0.0;1.0].
126 @param nDefaultRgb Deafult RGB color used if the parameter roVmlColor
127 is empty.
129 @param nPrimaryRgb If set to something else than API_RGB_TRANSPARENT,
130 specifies the color to be used to resolve the color modifiers used
131 in one-color gradients.
133 @return The resulting DrawingML color.
135 OOX_DLLPUBLIC ::oox::drawingml::Color decodeColor(
136 const GraphicHelper& rGraphicHelper,
137 const OptValue< OUString >& roVmlColor,
138 const OptValue< double >& roVmlOpacity,
139 sal_Int32 nDefaultRgb,
140 sal_Int32 nPrimaryRgb = API_RGB_TRANSPARENT );
142 /** Converts VML path string into point and flag vectors.
144 @param rPoints The point vector to fill with coordinates.
146 @param rFlags The flag vector to fill. PolygonFlags_NORMAL indicates
147 a corresponding plain shape coordinate in rPoints and
148 PolygonFlags_CONTROL indicates a bezier curve control point.
150 @param rPath The VML path string.
152 @param rGraphicHelper See above.
154 OOX_DLLPUBLIC void decodeVmlPath(
155 ::std::vector< ::std::vector< ::com::sun::star::awt::Point > >& rPoints,
156 ::std::vector< ::std::vector< ::com::sun::star::drawing::PolygonFlags > >& rFlags,
157 const OUString& rPath );
162 /** The stroke arrow model structure contains all properties for an line end arrow. */
163 struct StrokeArrowModel
165 OptValue< sal_Int32 > moArrowType;
166 OptValue< sal_Int32 > moArrowWidth;
167 OptValue< sal_Int32 > moArrowLength;
169 void assignUsed( const StrokeArrowModel& rSource );
174 /** The stroke model structure contains all shape border properties. */
175 struct StrokeModel
177 OptValue< bool > moStroked; ///< Shape border line on/off.
178 StrokeArrowModel maStartArrow; ///< Start line arrow style.
179 StrokeArrowModel maEndArrow; ///< End line arrow style.
180 OptValue< OUString > moColor; ///< Solid line color.
181 OptValue< double > moOpacity; ///< Solid line color opacity.
182 OptValue< OUString > moWeight; ///< Line width.
183 OptValue< OUString > moDashStyle; ///< Line dash (predefined or manually).
184 OptValue< sal_Int32 > moLineStyle; ///< Line style (single, double, ...).
185 OptValue< sal_Int32 > moEndCap; ///< Type of line end cap.
186 OptValue< sal_Int32 > moJoinStyle; ///< Type of line join.
188 void assignUsed( const StrokeModel& rSource );
190 /** Writes the properties to the passed property map. */
191 void pushToPropMap(
192 ::oox::drawingml::ShapePropertyMap& rPropMap,
193 const GraphicHelper& rGraphicHelper ) const;
198 /** The fill model structure contains all shape fill properties. */
199 struct OOX_DLLPUBLIC FillModel
201 OptValue< bool > moFilled; ///< Shape fill on/off.
202 OptValue< OUString > moColor; ///< Solid fill color.
203 OptValue< double > moOpacity; ///< Solid fill color opacity.
204 OptValue< OUString > moColor2; ///< End color of gradient.
205 OptValue< double > moOpacity2; ///< End color opacity of gradient.
206 OptValue< sal_Int32 > moType; ///< Fill type.
207 OptValue< sal_Int32 > moAngle; ///< Gradient rotation angle.
208 OptValue< double > moFocus; ///< Linear gradient focus of second color.
209 OptValue< DoublePair > moFocusPos; ///< Rectangular gradient focus position of second color.
210 OptValue< DoublePair > moFocusSize; ///< Rectangular gradient focus size of second color.
211 OptValue< OUString > moBitmapPath; ///< Path to fill bitmap fragment.
212 OptValue< bool > moRotate; ///< True = rotate gradient/bitmap with shape.
214 void assignUsed( const FillModel& rSource );
216 /** Writes the properties to the passed property map. */
217 void pushToPropMap(
218 ::oox::drawingml::ShapePropertyMap& rPropMap,
219 const GraphicHelper& rGraphicHelper ) const;
224 /** The shadow model structure contains all shape shadow properties. */
225 struct OOX_DLLPUBLIC ShadowModel
227 bool mbHasShadow; ///< Is a v:shadow element seen?
228 OptValue<bool> moShadowOn; ///< Is the element turned on?
229 OptValue<OUString> moColor; ///< Specifies the color of the shadow.
230 OptValue<OUString> moOffset; ///< Specifies the shadow's offset from the shape's location.
231 OptValue<double> moOpacity; ///< Specifies the opacity of the shadow.
233 ShadowModel();
235 /** Writes the properties to the passed property map. */
236 void pushToPropMap(oox::drawingml::ShapePropertyMap& rPropMap, const GraphicHelper& rGraphicHelper) const;
239 /** The shadow model structure contains all shape textpath properties. */
240 struct OOX_DLLPUBLIC TextpathModel
242 OptValue<OUString> moString; ///< Specifies the string of the textpath.
244 TextpathModel();
246 /** Writes the properties to the passed property map. */
247 void pushToPropMap(oox::drawingml::ShapePropertyMap& rPropMap, com::sun::star::uno::Reference<com::sun::star::drawing::XShape> xShape) const;
250 } // namespace vml
251 } // namespace oox
253 #endif
255 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */