LCOV - code coverage report
Current view: top level - libreoffice/solver/unxlngi6.pro/inc/oox/vml - vmlformatting.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 3 3 100.0 %
Date: 2012-12-27 Functions: 5 5 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 OOX_VML_VMLFORMATTING_HXX
      21             : #define 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             : 
      28             : #include <vector>
      29             : 
      30             : namespace oox {
      31             :     class GraphicHelper;
      32             :     namespace drawingml { class Color; }
      33             :     namespace drawingml { class ShapePropertyMap; }
      34             : }
      35             : 
      36             : namespace oox {
      37             : namespace vml {
      38             : 
      39             : // ============================================================================
      40             : 
      41             : typedef ::std::pair< sal_Int32, sal_Int32 > Int32Pair;
      42             : typedef ::std::pair< double, double >       DoublePair;
      43             : 
      44             : // ============================================================================
      45             : 
      46             : class OOX_DLLPUBLIC ConversionHelper
      47             : {
      48             : public:
      49             :     /** Returns two values contained in rValue separated by cSep.
      50             :      */
      51             :     static bool         separatePair(
      52             :                             ::rtl::OUString& orValue1, ::rtl::OUString& orValue2,
      53             :                             const ::rtl::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             :     static bool         decodeBool( const ::rtl::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             :     static double       decodePercent(
      70             :                             const ::rtl::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             :     static sal_Int64    decodeMeasureToEmu(
      92             :                             const GraphicHelper& rGraphicHelper,
      93             :                             const ::rtl::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             :     static sal_Int32    decodeMeasureToHmm(
     107             :                             const GraphicHelper& rGraphicHelper,
     108             :                             const ::rtl::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             :     static ::oox::drawingml::Color decodeColor(
     136             :                             const GraphicHelper& rGraphicHelper,
     137             :                             const OptValue< ::rtl::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             :     static 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             : private:
     160             :                         ConversionHelper();
     161             :                         ~ConversionHelper();
     162             : };
     163             : 
     164             : // ============================================================================
     165             : 
     166             : /** The stroke arrow model structure contains all properties for an line end arrow. */
     167          86 : struct StrokeArrowModel
     168             : {
     169             :     OptValue< sal_Int32 > moArrowType;
     170             :     OptValue< sal_Int32 > moArrowWidth;
     171             :     OptValue< sal_Int32 > moArrowLength;
     172             : 
     173             :     void                assignUsed( const StrokeArrowModel& rSource );
     174             : };
     175             : 
     176             : // ============================================================================
     177             : 
     178             : /** The stroke model structure contains all shape border properties. */
     179          86 : struct StrokeModel
     180             : {
     181             :     OptValue< bool >    moStroked;              ///< Shape border line on/off.
     182             :     StrokeArrowModel    maStartArrow;           ///< Start line arrow style.
     183             :     StrokeArrowModel    maEndArrow;             ///< End line arrow style.
     184             :     OptValue< ::rtl::OUString > moColor;        ///< Solid line color.
     185             :     OptValue< double > moOpacity;               ///< Solid line color opacity.
     186             :     OptValue< ::rtl::OUString > moWeight;       ///< Line width.
     187             :     OptValue< ::rtl::OUString > moDashStyle;    ///< Line dash (predefined or manually).
     188             :     OptValue< sal_Int32 > moLineStyle;          ///< Line style (single, double, ...).
     189             :     OptValue< sal_Int32 > moEndCap;             ///< Type of line end cap.
     190             :     OptValue< sal_Int32 > moJoinStyle;          ///< Type of line join.
     191             : 
     192             :     void                assignUsed( const StrokeModel& rSource );
     193             : 
     194             :     /** Writes the properties to the passed property map. */
     195             :     void                pushToPropMap(
     196             :                             ::oox::drawingml::ShapePropertyMap& rPropMap,
     197             :                             const GraphicHelper& rGraphicHelper ) const;
     198             : };
     199             : 
     200             : // ============================================================================
     201             : 
     202             : /** The fill model structure contains all shape fill properties. */
     203          86 : struct FillModel
     204             : {
     205             :     OptValue< bool >    moFilled;               ///< Shape fill on/off.
     206             :     OptValue< ::rtl::OUString > moColor;        ///< Solid fill color.
     207             :     OptValue< double >  moOpacity;              ///< Solid fill color opacity.
     208             :     OptValue< ::rtl::OUString > moColor2;       ///< End color of gradient.
     209             :     OptValue< double >  moOpacity2;             ///< End color opacity of gradient.
     210             :     OptValue< sal_Int32 > moType;               ///< Fill type.
     211             :     OptValue< sal_Int32 > moAngle;              ///< Gradient rotation angle.
     212             :     OptValue< double >  moFocus;                ///< Linear gradient focus of second color.
     213             :     OptValue< DoublePair > moFocusPos;          ///< Rectangular gradient focus position of second color.
     214             :     OptValue< DoublePair > moFocusSize;         ///< Rectangular gradient focus size of second color.
     215             :     OptValue< ::rtl::OUString > moBitmapPath;   ///< Path to fill bitmap fragment.
     216             :     OptValue< bool >    moRotate;               ///< True = rotate gradient/bitmap with shape.
     217             : 
     218             :     void                assignUsed( const FillModel& rSource );
     219             : 
     220             :     /** Writes the properties to the passed property map. */
     221             :     void                pushToPropMap(
     222             :                             ::oox::drawingml::ShapePropertyMap& rPropMap,
     223             :                             const GraphicHelper& rGraphicHelper ) const;
     224             : };
     225             : 
     226             : // ============================================================================
     227             : 
     228             : } // namespace vml
     229             : } // namespace oox
     230             : 
     231             : #endif
     232             : 
     233             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10