1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir #ifndef OOX_VML_VMLFORMATTING_HXX 29*cdf0e10cSrcweir #define OOX_VML_VMLFORMATTING_HXX 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include "oox/helper/helper.hxx" 32*cdf0e10cSrcweir 33*cdf0e10cSrcweir namespace oox { 34*cdf0e10cSrcweir class GraphicHelper; 35*cdf0e10cSrcweir namespace drawingml { class Color; } 36*cdf0e10cSrcweir namespace drawingml { class ShapePropertyMap; } 37*cdf0e10cSrcweir } 38*cdf0e10cSrcweir 39*cdf0e10cSrcweir namespace oox { 40*cdf0e10cSrcweir namespace vml { 41*cdf0e10cSrcweir 42*cdf0e10cSrcweir // ============================================================================ 43*cdf0e10cSrcweir 44*cdf0e10cSrcweir typedef ::std::pair< sal_Int32, sal_Int32 > Int32Pair; 45*cdf0e10cSrcweir typedef ::std::pair< double, double > DoublePair; 46*cdf0e10cSrcweir 47*cdf0e10cSrcweir // ============================================================================ 48*cdf0e10cSrcweir 49*cdf0e10cSrcweir class ConversionHelper 50*cdf0e10cSrcweir { 51*cdf0e10cSrcweir public: 52*cdf0e10cSrcweir /** Returns two values contained in rValue separated by cSep. 53*cdf0e10cSrcweir */ 54*cdf0e10cSrcweir static bool separatePair( 55*cdf0e10cSrcweir ::rtl::OUString& orValue1, ::rtl::OUString& orValue2, 56*cdf0e10cSrcweir const ::rtl::OUString& rValue, sal_Unicode cSep ); 57*cdf0e10cSrcweir 58*cdf0e10cSrcweir /** Returns the boolean value from the passed string of a VML attribute. 59*cdf0e10cSrcweir Supported values: 'f', 't', 'false', 'true'. False for anything else. 60*cdf0e10cSrcweir */ 61*cdf0e10cSrcweir static bool decodeBool( const ::rtl::OUString& rValue ); 62*cdf0e10cSrcweir 63*cdf0e10cSrcweir /** Converts the passed VML percentage measure string to a normalized 64*cdf0e10cSrcweir floating-point value. 65*cdf0e10cSrcweir 66*cdf0e10cSrcweir @param rValue The VML percentage value. This is a floating-point value 67*cdf0e10cSrcweir with optional following '%' sign. If the '%' sign is missing, the 68*cdf0e10cSrcweir floating point value will be returned unmodified. If the '%' sign 69*cdf0e10cSrcweir is present, the value will be divided by 100. 70*cdf0e10cSrcweir */ 71*cdf0e10cSrcweir static double decodePercent( 72*cdf0e10cSrcweir const ::rtl::OUString& rValue, 73*cdf0e10cSrcweir double fDefValue ); 74*cdf0e10cSrcweir 75*cdf0e10cSrcweir /** Converts the passed VML measure string to EMU (English Metric Units). 76*cdf0e10cSrcweir 77*cdf0e10cSrcweir @param rGraphicHelper The graphic helper needed to perform pixel 78*cdf0e10cSrcweir conversion according to the current output device. 79*cdf0e10cSrcweir 80*cdf0e10cSrcweir @param rValue The VML measure value. This is a floating-point value 81*cdf0e10cSrcweir with optional measure string following the value. 82*cdf0e10cSrcweir 83*cdf0e10cSrcweir @param nRefValue Reference value needed for percentage measure. 84*cdf0e10cSrcweir 85*cdf0e10cSrcweir @param bPixelX Set to true if the value is oriented horizontally (e.g. 86*cdf0e10cSrcweir X coordinates, widths). Set to false if the value is oriented 87*cdf0e10cSrcweir vertically (e.g. Y coordinates, heights). This is needed because 88*cdf0e10cSrcweir output devices may specify different width and height for a pixel. 89*cdf0e10cSrcweir 90*cdf0e10cSrcweir @param bDefaultAsPixel Set to true if omitted measure unit means 91*cdf0e10cSrcweir pixel. Set to false if omitted measure unit means EMU. 92*cdf0e10cSrcweir */ 93*cdf0e10cSrcweir static sal_Int64 decodeMeasureToEmu( 94*cdf0e10cSrcweir const GraphicHelper& rGraphicHelper, 95*cdf0e10cSrcweir const ::rtl::OUString& rValue, 96*cdf0e10cSrcweir sal_Int32 nRefValue, 97*cdf0e10cSrcweir bool bPixelX, 98*cdf0e10cSrcweir bool bDefaultAsPixel ); 99*cdf0e10cSrcweir 100*cdf0e10cSrcweir /** Converts the passed VML measure string to 1/100 mm. 101*cdf0e10cSrcweir 102*cdf0e10cSrcweir @param rGraphicHelper See above. 103*cdf0e10cSrcweir @param rValue See above. 104*cdf0e10cSrcweir @param nRefValue See above. 105*cdf0e10cSrcweir @param bPixelX See above. 106*cdf0e10cSrcweir @param bDefaultAsPixel See above. 107*cdf0e10cSrcweir */ 108*cdf0e10cSrcweir static sal_Int32 decodeMeasureToHmm( 109*cdf0e10cSrcweir const GraphicHelper& rGraphicHelper, 110*cdf0e10cSrcweir const ::rtl::OUString& rValue, 111*cdf0e10cSrcweir sal_Int32 nRefValue, 112*cdf0e10cSrcweir bool bPixelX, 113*cdf0e10cSrcweir bool bDefaultAsPixel ); 114*cdf0e10cSrcweir 115*cdf0e10cSrcweir /** Converts VML color attributes to a DrawingML color. 116*cdf0e10cSrcweir 117*cdf0e10cSrcweir @param roVmlColor The VML string representation of the color. If 118*cdf0e10cSrcweir existing, this can be a 3-digit or 6-digit hexadecimal RGB value 119*cdf0e10cSrcweir with leading '#' character, a predefined color name (e.g. 'black', 120*cdf0e10cSrcweir 'red', etc.), the index into an application defined color palette 121*cdf0e10cSrcweir in brackets with leading color name (e.g. 'red [9]' or 122*cdf0e10cSrcweir 'windowColor [64]'), or a color modifier used in one-color 123*cdf0e10cSrcweir gradients (e.g. 'fill darken(128)' or 'fill lighten(0)'). 124*cdf0e10cSrcweir 125*cdf0e10cSrcweir @param roVmlOpacity The opacity of the color. If existing, this should 126*cdf0e10cSrcweir be a floating-point value in the range [0.0;1.0]. 127*cdf0e10cSrcweir 128*cdf0e10cSrcweir @param nDefaultRgb Deafult RGB color used if the parameter roVmlColor 129*cdf0e10cSrcweir is empty. 130*cdf0e10cSrcweir 131*cdf0e10cSrcweir @param nPrimaryRgb If set to something else than API_RGB_TRANSPARENT, 132*cdf0e10cSrcweir specifies the color to be used to resolve the color modifiers used 133*cdf0e10cSrcweir in one-color gradients. 134*cdf0e10cSrcweir 135*cdf0e10cSrcweir @return The resulting DrawingML color. 136*cdf0e10cSrcweir */ 137*cdf0e10cSrcweir static ::oox::drawingml::Color decodeColor( 138*cdf0e10cSrcweir const GraphicHelper& rGraphicHelper, 139*cdf0e10cSrcweir const OptValue< ::rtl::OUString >& roVmlColor, 140*cdf0e10cSrcweir const OptValue< double >& roVmlOpacity, 141*cdf0e10cSrcweir sal_Int32 nDefaultRgb, 142*cdf0e10cSrcweir sal_Int32 nPrimaryRgb = API_RGB_TRANSPARENT ); 143*cdf0e10cSrcweir 144*cdf0e10cSrcweir private: 145*cdf0e10cSrcweir ConversionHelper(); 146*cdf0e10cSrcweir ~ConversionHelper(); 147*cdf0e10cSrcweir }; 148*cdf0e10cSrcweir 149*cdf0e10cSrcweir // ============================================================================ 150*cdf0e10cSrcweir 151*cdf0e10cSrcweir /** The stroke arrow model structure contains all properties for an line end arrow. */ 152*cdf0e10cSrcweir struct StrokeArrowModel 153*cdf0e10cSrcweir { 154*cdf0e10cSrcweir OptValue< sal_Int32 > moArrowType; 155*cdf0e10cSrcweir OptValue< sal_Int32 > moArrowWidth; 156*cdf0e10cSrcweir OptValue< sal_Int32 > moArrowLength; 157*cdf0e10cSrcweir 158*cdf0e10cSrcweir void assignUsed( const StrokeArrowModel& rSource ); 159*cdf0e10cSrcweir }; 160*cdf0e10cSrcweir 161*cdf0e10cSrcweir // ============================================================================ 162*cdf0e10cSrcweir 163*cdf0e10cSrcweir /** The stroke model structure contains all shape border properties. */ 164*cdf0e10cSrcweir struct StrokeModel 165*cdf0e10cSrcweir { 166*cdf0e10cSrcweir OptValue< bool > moStroked; /// Shape border line on/off. 167*cdf0e10cSrcweir StrokeArrowModel maStartArrow; /// Start line arrow style. 168*cdf0e10cSrcweir StrokeArrowModel maEndArrow; /// End line arrow style. 169*cdf0e10cSrcweir OptValue< ::rtl::OUString > moColor; /// Solid line color. 170*cdf0e10cSrcweir OptValue< double > moOpacity; /// Solid line color opacity. 171*cdf0e10cSrcweir OptValue< ::rtl::OUString > moWeight; /// Line width. 172*cdf0e10cSrcweir OptValue< ::rtl::OUString > moDashStyle; /// Line dash (predefined or manually). 173*cdf0e10cSrcweir OptValue< sal_Int32 > moLineStyle; /// Line style (single, double, ...). 174*cdf0e10cSrcweir OptValue< sal_Int32 > moEndCap; /// Type of line end cap. 175*cdf0e10cSrcweir OptValue< sal_Int32 > moJoinStyle; /// Type of line join. 176*cdf0e10cSrcweir 177*cdf0e10cSrcweir void assignUsed( const StrokeModel& rSource ); 178*cdf0e10cSrcweir 179*cdf0e10cSrcweir /** Writes the properties to the passed property map. */ 180*cdf0e10cSrcweir void pushToPropMap( 181*cdf0e10cSrcweir ::oox::drawingml::ShapePropertyMap& rPropMap, 182*cdf0e10cSrcweir const GraphicHelper& rGraphicHelper ) const; 183*cdf0e10cSrcweir }; 184*cdf0e10cSrcweir 185*cdf0e10cSrcweir // ============================================================================ 186*cdf0e10cSrcweir 187*cdf0e10cSrcweir /** The fill model structure contains all shape fill properties. */ 188*cdf0e10cSrcweir struct FillModel 189*cdf0e10cSrcweir { 190*cdf0e10cSrcweir OptValue< bool > moFilled; /// Shape fill on/off. 191*cdf0e10cSrcweir OptValue< ::rtl::OUString > moColor; /// Solid fill color. 192*cdf0e10cSrcweir OptValue< double > moOpacity; /// Solid fill color opacity. 193*cdf0e10cSrcweir OptValue< ::rtl::OUString > moColor2; /// End color of gradient. 194*cdf0e10cSrcweir OptValue< double > moOpacity2; /// End color opycity of gradient. 195*cdf0e10cSrcweir OptValue< sal_Int32 > moType; /// Fill type. 196*cdf0e10cSrcweir OptValue< sal_Int32 > moAngle; /// Gradient rotation angle. 197*cdf0e10cSrcweir OptValue< double > moFocus; /// Linear gradient focus of second color. 198*cdf0e10cSrcweir OptValue< DoublePair > moFocusPos; /// Rectanguar gradient focus position of second color. 199*cdf0e10cSrcweir OptValue< DoublePair > moFocusSize; /// Rectanguar gradient focus size of second color. 200*cdf0e10cSrcweir OptValue< ::rtl::OUString > moBitmapPath; /// Path to fill bitmap fragment. 201*cdf0e10cSrcweir OptValue< bool > moRotate; /// True = rotate gradient/bitmap with shape. 202*cdf0e10cSrcweir 203*cdf0e10cSrcweir void assignUsed( const FillModel& rSource ); 204*cdf0e10cSrcweir 205*cdf0e10cSrcweir /** Writes the properties to the passed property map. */ 206*cdf0e10cSrcweir void pushToPropMap( 207*cdf0e10cSrcweir ::oox::drawingml::ShapePropertyMap& rPropMap, 208*cdf0e10cSrcweir const GraphicHelper& rGraphicHelper ) const; 209*cdf0e10cSrcweir }; 210*cdf0e10cSrcweir 211*cdf0e10cSrcweir // ============================================================================ 212*cdf0e10cSrcweir 213*cdf0e10cSrcweir } // namespace vml 214*cdf0e10cSrcweir } // namespace oox 215*cdf0e10cSrcweir 216*cdf0e10cSrcweir #endif 217