LCOV - code coverage report
Current view: top level - include/oox/vml - vmlformatting.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 5 5 100.0 %
Date: 2015-06-13 12:38:46 Functions: 7 7 100.0 %
Legend: Lines: hit not hit

          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 INCLUDED_OOX_VML_VMLFORMATTING_HXX
      21             : #define INCLUDED_OOX_VML_VMLFORMATTING_HXX
      22             : 
      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>
      28             : 
      29             : #include <vector>
      30             : 
      31             : namespace oox {
      32             :     class GraphicHelper;
      33             :     namespace drawingml { class Color; }
      34             :     namespace drawingml { class ShapePropertyMap; }
      35             : }
      36             : 
      37             : namespace oox {
      38             : namespace vml {
      39             : 
      40             : 
      41             : 
      42             : typedef ::std::pair< sal_Int32, sal_Int32 > Int32Pair;
      43             : typedef ::std::pair< double, double >       DoublePair;
      44             : 
      45             : 
      46             : 
      47             : namespace ConversionHelper
      48             : {
      49             :     /** Returns two values contained in rValue separated by cSep.
      50             :      */
      51             :     OOX_DLLPUBLIC bool         separatePair(
      52             :                             OUString& orValue1, OUString& orValue2,
      53             :                             const OUString& rValue, sal_Unicode cSep );
      54             : 
      55             :     /** Returns the boolean value from the passed string of a VML attribute.
      56             :         Supported values: 'f', 't', 'false', 'true'. False for anything else.
      57             :      */
      58             :     OOX_DLLPUBLIC bool         decodeBool( const OUString& rValue );
      59             : 
      60             :     /** Converts the passed VML percentage measure string to a normalized
      61             :         floating-point value.
      62             : 
      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.
      68             :      */
      69             :     OOX_DLLPUBLIC double       decodePercent(
      70             :                             const OUString& rValue,
      71             :                             double fDefValue );
      72             : 
      73             :     /** Converts the passed VML measure string to EMU (English Metric Units).
      74             : 
      75             :         @param rGraphicHelper  The graphic helper needed to perform pixel
      76             :             conversion according to the current output device.
      77             : 
      78             :         @param rValue  The VML measure value. This is a floating-point value
      79             :             with optional measure string following the value.
      80             : 
      81             :         @param nRefValue  Reference value needed for percentage measure.
      82             : 
      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.
      87             : 
      88             :         @param bDefaultAsPixel  Set to true if omitted measure unit means
      89             :             pixel. Set to false if omitted measure unit means EMU.
      90             :      */
      91             :     OOX_DLLPUBLIC sal_Int64    decodeMeasureToEmu(
      92             :                             const GraphicHelper& rGraphicHelper,
      93             :                             const OUString& rValue,
      94             :                             sal_Int32 nRefValue,
      95             :                             bool bPixelX,
      96             :                             bool bDefaultAsPixel );
      97             : 
      98             :     /** Converts the passed VML measure string to 1/100 mm.
      99             : 
     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.
     105             :      */
     106             :     OOX_DLLPUBLIC sal_Int32    decodeMeasureToHmm(
     107             :                             const GraphicHelper& rGraphicHelper,
     108             :                             const OUString& rValue,
     109             :                             sal_Int32 nRefValue,
     110             :                             bool bPixelX,
     111             :                             bool bDefaultAsPixel );
     112             : 
     113             :     /** Converts VML color attributes to a DrawingML color.
     114             : 
     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)').
     122             : 
     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].
     125             : 
     126             :         @param nDefaultRgb  Deafult RGB color used if the parameter roVmlColor
     127             :             is empty.
     128             : 
     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.
     132             : 
     133             :         @return  The resulting DrawingML color.
     134             :      */
     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 );
     141             : 
     142             :     /** Converts VML path string into point and flag vectors.
     143             : 
     144             :         @param rPoints  The point vector to fill with coordinates.
     145             : 
     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.
     149             : 
     150             :         @param rPath  The VML path string.
     151             : 
     152             :         @param rGraphicHelper  See above.
     153             :     */
     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 );
     158             : }
     159             : 
     160             : 
     161             : 
     162             : /** The stroke arrow model structure contains all properties for an line end arrow. */
     163        2336 : struct StrokeArrowModel
     164             : {
     165             :     OptValue< sal_Int32 > moArrowType;
     166             :     OptValue< sal_Int32 > moArrowWidth;
     167             :     OptValue< sal_Int32 > moArrowLength;
     168             : 
     169             :     void                assignUsed( const StrokeArrowModel& rSource );
     170             : };
     171             : 
     172             : 
     173             : 
     174             : /** The stroke model structure contains all shape border properties. */
     175        2336 : struct StrokeModel
     176             : {
     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.
     187             : 
     188             :     void                assignUsed( const StrokeModel& rSource );
     189             : 
     190             :     /** Writes the properties to the passed property map. */
     191             :     void                pushToPropMap(
     192             :                             ::oox::drawingml::ShapePropertyMap& rPropMap,
     193             :                             const GraphicHelper& rGraphicHelper ) const;
     194             : };
     195             : 
     196             : 
     197             : 
     198             : /** The fill model structure contains all shape fill properties. */
     199        2554 : struct OOX_DLLPUBLIC FillModel
     200             : {
     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.
     213             : 
     214             :     void                assignUsed( const FillModel& rSource );
     215             : 
     216             :     /** Writes the properties to the passed property map. */
     217             :     void                pushToPropMap(
     218             :                             ::oox::drawingml::ShapePropertyMap& rPropMap,
     219             :                             const GraphicHelper& rGraphicHelper ) const;
     220             : };
     221             : 
     222             : 
     223             : 
     224             : /** The shadow model structure contains all shape shadow properties. */
     225        1277 : struct OOX_DLLPUBLIC ShadowModel
     226             : {
     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.
     232             : 
     233             :     ShadowModel();
     234             : 
     235             :     /** Writes the properties to the passed property map. */
     236             :     void pushToPropMap(oox::drawingml::ShapePropertyMap& rPropMap, const GraphicHelper& rGraphicHelper) const;
     237             : };
     238             : 
     239             : /** The shadow model structure contains all shape textpath properties. */
     240        1168 : struct OOX_DLLPUBLIC TextpathModel
     241             : {
     242             :     OptValue<OUString> moString;                  ///< Specifies the string of the textpath.
     243             : 
     244             :     TextpathModel();
     245             : 
     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;
     248             : };
     249             : 
     250             : } // namespace vml
     251             : } // namespace oox
     252             : 
     253             : #endif
     254             : 
     255             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11