LCOV - code coverage report
Current view: top level - solver/unxlngi6.pro/inc/oox/vml - vmlformatting.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 3 3 100.0 %
Date: 2012-08-25 Functions: 5 5 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 2 4 50.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*
       3                 :            :  * This file is part of the LibreOffice project.
       4                 :            :  *
       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/.
       8                 :            :  *
       9                 :            :  * This file incorporates work covered by the following license notice:
      10                 :            :  *
      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 .
      18                 :            :  */
      19                 :            : 
      20                 :            : #ifndef OOX_VML_VMLFORMATTING_HXX
      21                 :            : #define OOX_VML_VMLFORMATTING_HXX
      22                 :            : 
      23                 :            : #include "oox/helper/helper.hxx"
      24                 :            : #include "oox/dllapi.h"
      25                 :            : 
      26                 :            : namespace oox {
      27                 :            :     class GraphicHelper;
      28                 :            :     namespace drawingml { class Color; }
      29                 :            :     namespace drawingml { class ShapePropertyMap; }
      30                 :            : }
      31                 :            : 
      32                 :            : namespace oox {
      33                 :            : namespace vml {
      34                 :            : 
      35                 :            : // ============================================================================
      36                 :            : 
      37                 :            : typedef ::std::pair< sal_Int32, sal_Int32 > Int32Pair;
      38                 :            : typedef ::std::pair< double, double >       DoublePair;
      39                 :            : 
      40                 :            : // ============================================================================
      41                 :            : 
      42                 :            : class OOX_DLLPUBLIC ConversionHelper
      43                 :            : {
      44                 :            : public:
      45                 :            :     /** Returns two values contained in rValue separated by cSep.
      46                 :            :      */
      47                 :            :     static bool         separatePair(
      48                 :            :                             ::rtl::OUString& orValue1, ::rtl::OUString& orValue2,
      49                 :            :                             const ::rtl::OUString& rValue, sal_Unicode cSep );
      50                 :            : 
      51                 :            :     /** Returns the boolean value from the passed string of a VML attribute.
      52                 :            :         Supported values: 'f', 't', 'false', 'true'. False for anything else.
      53                 :            :      */
      54                 :            :     static bool         decodeBool( const ::rtl::OUString& rValue );
      55                 :            : 
      56                 :            :     /** Converts the passed VML percentage measure string to a normalized
      57                 :            :         floating-point value.
      58                 :            : 
      59                 :            :         @param rValue  The VML percentage value. This is a floating-point value
      60                 :            :             with optional following '%' or 'f' sign. If the sign is missing, the
      61                 :            :             floating point value will be returned unmodified. If the '%' sign
      62                 :            :             is present, the value will be divided by 100. If the 'f' sign is present,
      63                 :            :             the value will be divided by 65536.
      64                 :            :      */
      65                 :            :     static double       decodePercent(
      66                 :            :                             const ::rtl::OUString& rValue,
      67                 :            :                             double fDefValue );
      68                 :            : 
      69                 :            :     /** Converts the passed VML measure string to EMU (English Metric Units).
      70                 :            : 
      71                 :            :         @param rGraphicHelper  The graphic helper needed to perform pixel
      72                 :            :             conversion according to the current output device.
      73                 :            : 
      74                 :            :         @param rValue  The VML measure value. This is a floating-point value
      75                 :            :             with optional measure string following the value.
      76                 :            : 
      77                 :            :         @param nRefValue  Reference value needed for percentage measure.
      78                 :            : 
      79                 :            :         @param bPixelX  Set to true if the value is oriented horizontally (e.g.
      80                 :            :             X coordinates, widths). Set to false if the value is oriented
      81                 :            :             vertically (e.g. Y coordinates, heights). This is needed because
      82                 :            :             output devices may specify different width and height for a pixel.
      83                 :            : 
      84                 :            :         @param bDefaultAsPixel  Set to true if omitted measure unit means
      85                 :            :             pixel. Set to false if omitted measure unit means EMU.
      86                 :            :      */
      87                 :            :     static sal_Int64    decodeMeasureToEmu(
      88                 :            :                             const GraphicHelper& rGraphicHelper,
      89                 :            :                             const ::rtl::OUString& rValue,
      90                 :            :                             sal_Int32 nRefValue,
      91                 :            :                             bool bPixelX,
      92                 :            :                             bool bDefaultAsPixel );
      93                 :            : 
      94                 :            :     /** Converts the passed VML measure string to 1/100 mm.
      95                 :            : 
      96                 :            :         @param rGraphicHelper  See above.
      97                 :            :         @param rValue  See above.
      98                 :            :         @param nRefValue  See above.
      99                 :            :         @param bPixelX  See above.
     100                 :            :         @param bDefaultAsPixel  See above.
     101                 :            :      */
     102                 :            :     static sal_Int32    decodeMeasureToHmm(
     103                 :            :                             const GraphicHelper& rGraphicHelper,
     104                 :            :                             const ::rtl::OUString& rValue,
     105                 :            :                             sal_Int32 nRefValue,
     106                 :            :                             bool bPixelX,
     107                 :            :                             bool bDefaultAsPixel );
     108                 :            : 
     109                 :            :     /** Converts VML color attributes to a DrawingML color.
     110                 :            : 
     111                 :            :         @param roVmlColor  The VML string representation of the color. If
     112                 :            :             existing, this can be a 3-digit or 6-digit hexadecimal RGB value
     113                 :            :             with leading '#' character, a predefined color name (e.g. 'black',
     114                 :            :             'red', etc.), the index into an application defined color palette
     115                 :            :             in brackets with leading color name (e.g. 'red [9]' or
     116                 :            :             'windowColor [64]'), or a color modifier used in one-color
     117                 :            :             gradients (e.g. 'fill darken(128)' or 'fill lighten(0)').
     118                 :            : 
     119                 :            :         @param roVmlOpacity  The opacity of the color. If existing, this should
     120                 :            :             be a floating-point value in the range [0.0;1.0].
     121                 :            : 
     122                 :            :         @param nDefaultRgb  Deafult RGB color used if the parameter roVmlColor
     123                 :            :             is empty.
     124                 :            : 
     125                 :            :         @param nPrimaryRgb  If set to something else than API_RGB_TRANSPARENT,
     126                 :            :             specifies the color to be used to resolve the color modifiers used
     127                 :            :             in one-color gradients.
     128                 :            : 
     129                 :            :         @return  The resulting DrawingML color.
     130                 :            :      */
     131                 :            :     static ::oox::drawingml::Color decodeColor(
     132                 :            :                             const GraphicHelper& rGraphicHelper,
     133                 :            :                             const OptValue< ::rtl::OUString >& roVmlColor,
     134                 :            :                             const OptValue< double >& roVmlOpacity,
     135                 :            :                             sal_Int32 nDefaultRgb,
     136                 :            :                             sal_Int32 nPrimaryRgb = API_RGB_TRANSPARENT );
     137                 :            : 
     138                 :            : private:
     139                 :            :                         ConversionHelper();
     140                 :            :                         ~ConversionHelper();
     141                 :            : };
     142                 :            : 
     143                 :            : // ============================================================================
     144                 :            : 
     145                 :            : /** The stroke arrow model structure contains all properties for an line end arrow. */
     146                 :        174 : struct StrokeArrowModel
     147                 :            : {
     148                 :            :     OptValue< sal_Int32 > moArrowType;
     149                 :            :     OptValue< sal_Int32 > moArrowWidth;
     150                 :            :     OptValue< sal_Int32 > moArrowLength;
     151                 :            : 
     152                 :            :     void                assignUsed( const StrokeArrowModel& rSource );
     153                 :            : };
     154                 :            : 
     155                 :            : // ============================================================================
     156                 :            : 
     157                 :            : /** The stroke model structure contains all shape border properties. */
     158                 :        174 : struct StrokeModel
     159                 :            : {
     160                 :            :     OptValue< bool >    moStroked;              ///< Shape border line on/off.
     161                 :            :     StrokeArrowModel    maStartArrow;           ///< Start line arrow style.
     162                 :            :     StrokeArrowModel    maEndArrow;             ///< End line arrow style.
     163                 :            :     OptValue< ::rtl::OUString > moColor;        ///< Solid line color.
     164                 :            :     OptValue< double > moOpacity;               ///< Solid line color opacity.
     165                 :            :     OptValue< ::rtl::OUString > moWeight;       ///< Line width.
     166                 :            :     OptValue< ::rtl::OUString > moDashStyle;    ///< Line dash (predefined or manually).
     167                 :            :     OptValue< sal_Int32 > moLineStyle;          ///< Line style (single, double, ...).
     168                 :            :     OptValue< sal_Int32 > moEndCap;             ///< Type of line end cap.
     169                 :            :     OptValue< sal_Int32 > moJoinStyle;          ///< Type of line join.
     170                 :            : 
     171                 :            :     void                assignUsed( const StrokeModel& rSource );
     172                 :            : 
     173                 :            :     /** Writes the properties to the passed property map. */
     174                 :            :     void                pushToPropMap(
     175                 :            :                             ::oox::drawingml::ShapePropertyMap& rPropMap,
     176                 :            :                             const GraphicHelper& rGraphicHelper ) const;
     177                 :            : };
     178                 :            : 
     179                 :            : // ============================================================================
     180                 :            : 
     181                 :            : /** The fill model structure contains all shape fill properties. */
     182 [ +  - ][ +  - ]:        174 : struct FillModel
     183                 :            : {
     184                 :            :     OptValue< bool >    moFilled;               ///< Shape fill on/off.
     185                 :            :     OptValue< ::rtl::OUString > moColor;        ///< Solid fill color.
     186                 :            :     OptValue< double >  moOpacity;              ///< Solid fill color opacity.
     187                 :            :     OptValue< ::rtl::OUString > moColor2;       ///< End color of gradient.
     188                 :            :     OptValue< double >  moOpacity2;             ///< End color opacity of gradient.
     189                 :            :     OptValue< sal_Int32 > moType;               ///< Fill type.
     190                 :            :     OptValue< sal_Int32 > moAngle;              ///< Gradient rotation angle.
     191                 :            :     OptValue< double >  moFocus;                ///< Linear gradient focus of second color.
     192                 :            :     OptValue< DoublePair > moFocusPos;          ///< Rectangular gradient focus position of second color.
     193                 :            :     OptValue< DoublePair > moFocusSize;         ///< Rectangular gradient focus size of second color.
     194                 :            :     OptValue< ::rtl::OUString > moBitmapPath;   ///< Path to fill bitmap fragment.
     195                 :            :     OptValue< bool >    moRotate;               ///< True = rotate gradient/bitmap with shape.
     196                 :            : 
     197                 :            :     void                assignUsed( const FillModel& rSource );
     198                 :            : 
     199                 :            :     /** Writes the properties to the passed property map. */
     200                 :            :     void                pushToPropMap(
     201                 :            :                             ::oox::drawingml::ShapePropertyMap& rPropMap,
     202                 :            :                             const GraphicHelper& rGraphicHelper ) const;
     203                 :            : };
     204                 :            : 
     205                 :            : // ============================================================================
     206                 :            : 
     207                 :            : } // namespace vml
     208                 :            : } // namespace oox
     209                 :            : 
     210                 :            : #endif
     211                 :            : 
     212                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10