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

Generated by: LCOV version 1.11