LCOV - code coverage report
Current view: top level - include/svx - EnhancedCustomShape2d.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 7 7 100.0 %
Date: 2014-11-03 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 INCLUDED_SVX_ENHANCEDCUSTOMSHAPE2D_HXX
      21             : #define INCLUDED_SVX_ENHANCEDCUSTOMSHAPE2D_HXX
      22             : 
      23             : #include <svx/msdffdef.hxx>
      24             : #include <svx/sdasitm.hxx>
      25             : #include <com/sun/star/uno/Sequence.h>
      26             : #include <com/sun/star/beans/PropertyValues.hpp>
      27             : #include <com/sun/star/awt/Point.hpp>
      28             : #include <com/sun/star/awt/Size.hpp>
      29             : #include <svl/itemset.hxx>
      30             : #include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp>
      31             : #include <com/sun/star/drawing/EnhancedCustomShapeSegment.hpp>
      32             : #include <com/sun/star/drawing/EnhancedCustomShapeParameter.hpp>
      33             : #include <com/sun/star/drawing/EnhancedCustomShapeTextFrame.hpp>
      34             : #include <com/sun/star/drawing/EnhancedCustomShapeAdjustmentValue.hpp>
      35             : #include <svx/EnhancedCustomShapeFunctionParser.hxx>
      36             : #include <tools/gen.hxx>
      37             : 
      38             : #include <boost/shared_ptr.hpp>
      39             : #include <vector>
      40             : 
      41             : #define DFF_CUSTOMSHAPE_FLIP_V      1
      42             : #define DFF_CUSTOMSHAPE_FLIP_H      2
      43             : #define DFF_CUSTOMSHAPE_EXCH            4
      44             : 
      45             : class SdrModel;
      46             : class SdrObject;
      47             : class SfxItemSet;
      48             : struct SvxMSDffVertPair;
      49             : struct SvxMSDffCalculationData;
      50             : struct SvxMSDffTextRectangles;
      51             : 
      52             : #define HANDLE_FLAGS_MIRRORED_X             0x0001
      53             : #define HANDLE_FLAGS_MIRRORED_Y             0x0002
      54             : #define HANDLE_FLAGS_SWITCHED               0x0004
      55             : #define HANDLE_FLAGS_POLAR                  0x0008
      56             : #define HANDLE_FLAGS_MAP                    0x0010
      57             : #define HANDLE_FLAGS_RANGE_X_MINIMUM        0x0020
      58             : #define HANDLE_FLAGS_RANGE_X_MAXIMUM        0x0040
      59             : #define HANDLE_FLAGS_RANGE_Y_MINIMUM        0x0080
      60             : #define HANDLE_FLAGS_RANGE_Y_MAXIMUM        0x0100
      61             : #define HANDLE_FLAGS_RADIUS_RANGE_MINIMUM   0x0200
      62             : #define HANDLE_FLAGS_RADIUS_RANGE_MAXIMUM   0x0400
      63             : #define HANDLE_FLAGS_REFX                   0x0800
      64             : #define HANDLE_FLAGS_REFY                   0x1000
      65             : #define HANDLE_FLAGS_REFANGLE               0x2000
      66             : #define HANDLE_FLAGS_REFR                   0x4000
      67             : 
      68             : // MSDFF_HANDLE_FLAGS_RANGE_Y seems to be not defined in
      69             : // escher, but we are using it internally in to differentiate
      70             : // between X_RANGE and Y_RANGE
      71             : 
      72             : class SdrPathObj;
      73             : 
      74             : class SVX_DLLPUBLIC EnhancedCustomShape2d : public SfxItemSet
      75             : {
      76             :         SdrObject*                  pCustomShapeObj;
      77             :         MSO_SPT                     eSpType;
      78             : 
      79             :         sal_Int32                   nCoordLeft;
      80             :         sal_Int32                   nCoordTop;
      81             :         sal_Int32                   nCoordWidthG;
      82             :         sal_Int32                   nCoordHeightG;
      83             :         sal_Int32                   nCoordWidth;
      84             :         sal_Int32                   nCoordHeight;
      85             :         Rectangle                   aLogicRect;
      86             : 
      87             :         double                      fXScale;
      88             :         double                      fYScale;
      89             :         double                      fXRatio;
      90             :         double                      fYRatio;
      91             : 
      92             :         bool                        bOOXMLShape;
      93             : 
      94             :         sal_Int32                   nXRef;
      95             :         sal_Int32                   nYRef;
      96             :         sal_uInt32                  nFlags;
      97             :         sal_uInt32                  nColorData;
      98             : 
      99             :         /*
     100             : 
     101             :         */
     102             :         struct SAL_DLLPRIVATE EquationResult {
     103             :             bool bReady;
     104             :             double fValue;
     105             :         };
     106             :         com::sun::star::uno::Sequence< OUString >                                                  seqEquations;
     107             :         std::vector< ::boost::shared_ptr< EnhancedCustomShape::ExpressionNode > >                       vNodesSharedPtr;
     108             :         std::vector< EquationResult >                                                                   vEquationResults;
     109             : 
     110             :         com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeSegment >            seqSegments;
     111             :         com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeParameterPair>       seqCoordinates;
     112             :         com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeTextFrame >          seqTextFrames;
     113             :         com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeParameterPair>       seqGluePoints;
     114             :         com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeAdjustmentValue >    seqAdjustmentValues;
     115             :         com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValues >                          seqHandles;
     116             :         com::sun::star::uno::Sequence< com::sun::star::awt::Size >                                      seqSubViewSize;
     117             : 
     118             :         bool                    bTextFlow       : 1;
     119             :         bool                    bFilled         : 1;
     120             :         bool                    bStroked        : 1;
     121             : 
     122             :         bool                    bFlipH;
     123             :         bool                    bFlipV;
     124             :         sal_Int32               nRotateAngle;
     125             : 
     126             :         SAL_DLLPRIVATE bool     SetAdjustValueAsDouble( const double& rValue, const sal_Int32 nIndex );
     127             :         SAL_DLLPRIVATE sal_Int32 GetLuminanceChange( sal_uInt32 nIndex ) const;
     128             :         SAL_DLLPRIVATE Color    GetColorData( const Color& rFillColor, sal_uInt32 nIndex, double dBrightness ) const;
     129             :         SAL_DLLPRIVATE void     AdaptObjColor(SdrPathObj& rObj, const SfxItemSet& rCustomShapeSet,
     130             :                                                   sal_uInt32& nColorIndex, sal_uInt32 nColorCount);
     131             :         SAL_DLLPRIVATE bool     GetParameter( double& rParameterReturnValue,  const com::sun::star::drawing::EnhancedCustomShapeParameter&,
     132             :                                                   const bool bReplaceGeoWidth, const bool bReplaceGeoHeight ) const;
     133             :         SAL_DLLPRIVATE Point    GetPoint( const com::sun::star::drawing::EnhancedCustomShapeParameterPair&,
     134             :                                                     const bool bScale = true, const bool bReplaceGeoSize = false ) const;
     135             : 
     136             :         SAL_DLLPRIVATE void     CreateSubPath( sal_uInt16& rSrcPt, sal_uInt16& rSegmentInd, std::vector< SdrPathObj* >& rObjectList,
     137             :                                                    bool bLineGeometryNeededOnly, bool bSortFilledObjectsToBack,
     138             :                                                    sal_Int32 nIndex );
     139             :         SAL_DLLPRIVATE SdrObject* CreatePathObj( bool bLineGeometryNeededOnly );
     140             :         SAL_DLLPRIVATE const sal_Int32* ApplyShapeAttributes( const SdrCustomShapeGeometryItem& rItem );
     141             : 
     142             :         SAL_DLLPRIVATE void     SetPathSize( sal_Int32 nIndex = 0 );
     143             : 
     144             :     public :
     145             : 
     146         130 :         struct SAL_DLLPRIVATE Handle
     147             :         {
     148             :             sal_uInt32  nFlags;
     149             : 
     150             :             bool        bMirroredX;
     151             :             bool        bMirroredY;
     152             :             bool        bSwitched;
     153             : 
     154             :             com::sun::star::drawing::EnhancedCustomShapeParameterPair   aPosition;
     155             :             com::sun::star::drawing::EnhancedCustomShapeParameterPair   aPolar;
     156             : 
     157             :             sal_Int32   nRefX;
     158             :             sal_Int32   nRefY;
     159             :             sal_Int32   nRefAngle;
     160             :             sal_Int32   nRefR;
     161             : 
     162             :             com::sun::star::drawing::EnhancedCustomShapeParameter       aRadiusRangeMinimum;
     163             :             com::sun::star::drawing::EnhancedCustomShapeParameter       aRadiusRangeMaximum;
     164             :             com::sun::star::drawing::EnhancedCustomShapeParameter       aXRangeMinimum;
     165             :             com::sun::star::drawing::EnhancedCustomShapeParameter       aXRangeMaximum;
     166             :             com::sun::star::drawing::EnhancedCustomShapeParameter       aYRangeMinimum;
     167             :             com::sun::star::drawing::EnhancedCustomShapeParameter       aYRangeMaximum;
     168             : 
     169         130 :             Handle()
     170             :                 : nFlags(0)
     171             :                 , bMirroredX ( false )
     172             :                 , bMirroredY ( false )
     173             :                 , bSwitched( false )
     174             :                 , nRefX( -1 )
     175             :                 , nRefY( -1 )
     176             :                 , nRefAngle( -1 )
     177         130 :                 , nRefR( -1 )
     178             :             {
     179         130 :             }
     180             :         };
     181             : 
     182       10172 :         SAL_DLLPRIVATE bool     IsFlipVert() { return bFlipV; };
     183       10172 :         SAL_DLLPRIVATE bool     IsFlipHorz() { return bFlipH; };
     184       10172 :         SAL_DLLPRIVATE sal_Int32 GetRotateAngle() { return nRotateAngle; };
     185             :         bool                    IsPostRotate() const;
     186             : 
     187             :         SdrObject*              CreateLineGeometry();
     188             :         SdrObject*              CreateObject( bool bLineGeometryNeededOnly );
     189             :         void                    ApplyGluePoints( SdrObject* pObj );
     190             :         Rectangle               GetTextRect() const;
     191             : 
     192             :         sal_uInt32              GetHdlCount() const;
     193             :         bool                    GetHandlePosition( const sal_uInt32 nIndex, Point& rReturnPosition ) const;
     194             :         bool                    SetHandleControllerPosition( const sal_uInt32 nIndex, const com::sun::star::awt::Point& rPosition );
     195             : 
     196             :         EnhancedCustomShape2d( SdrObject* pSdrObjCustomShape );
     197             :         virtual ~EnhancedCustomShape2d();
     198             : 
     199             :         enum SAL_DLLPRIVATE EnumFunc
     200             :         {
     201             :             ENUM_FUNC_PI,
     202             :             ENUM_FUNC_LEFT,
     203             :             ENUM_FUNC_TOP,
     204             :             ENUM_FUNC_RIGHT,
     205             :             ENUM_FUNC_BOTTOM,
     206             :             ENUM_FUNC_XSTRETCH,
     207             :             ENUM_FUNC_YSTRETCH,
     208             :             ENUM_FUNC_HASSTROKE,
     209             :             ENUM_FUNC_HASFILL,
     210             :             ENUM_FUNC_WIDTH,
     211             :             ENUM_FUNC_HEIGHT,
     212             :             ENUM_FUNC_LOGWIDTH,
     213             :             ENUM_FUNC_LOGHEIGHT
     214             :         };
     215             :         SAL_DLLPRIVATE double   GetEnumFunc( const EnumFunc eVal ) const;
     216             : 
     217             :         SAL_DLLPRIVATE double   GetAdjustValueAsDouble( const sal_Int32 nIndex ) const;
     218             :         SAL_DLLPRIVATE double   GetEquationValueAsDouble( const sal_Int32 nIndex ) const;
     219             :         SAL_DLLPRIVATE sal_Int32 GetAdjustValueAsInteger( const sal_Int32 nIndex, const sal_Int32 nDefault = 0 ) const;
     220             : 
     221             :         static OUString         GetEquation( const sal_uInt16 nFlags, sal_Int32 nPara1, sal_Int32 nPara2, sal_Int32 nPara3 );
     222             : 
     223             :         SAL_DLLPRIVATE static void AppendEnhancedCustomShapeEquationParameter( OUString& rParameter, const sal_Int32 nPara, const bool bIsSpecialValue );
     224             : 
     225             :         SAL_DLLPRIVATE static void SetEnhancedCustomShapeEquationParameter( com::sun::star::drawing::EnhancedCustomShapeParameter&
     226             :                                         rParameter, const sal_Int16 nPara, const bool bIsSpecialValue );
     227             :         static void             SetEnhancedCustomShapeParameter( com::sun::star::drawing::EnhancedCustomShapeParameter&
     228             :                                         rParameter, const sal_Int32 nValue );
     229             :         static void             SetEnhancedCustomShapeHandleParameter( com::sun::star::drawing::EnhancedCustomShapeParameter&
     230             :                                         rParameter, const sal_Int32 nPara, const bool bIsSpecialValue, bool bHorz );
     231             :         SAL_DLLPRIVATE static bool ConvertSequenceToEnhancedCustomShape2dHandle( const com::sun::star::beans::PropertyValues& rHandleProperties,
     232             :                                         EnhancedCustomShape2d::Handle& rDestinationHandle );
     233             :         SAL_DLLPRIVATE static void SwapStartAndEndArrow( SdrObject* pObj );
     234             : };
     235             : #endif
     236             : 
     237             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10