Update ooo320-m1
[ooovba.git] / svx / source / customshapes / EnhancedCustomShape2d.hxx
blobe8f40b49dd980183eac47252b92720fc4e1f68ad
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: EnhancedCustomShape2d.hxx,v $
10 * $Revision: 1.11.148.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _ENHANCEDCUSTOMSHAPE2D_HXX
32 #define _ENHANCEDCUSTOMSHAPE2D_HXX
34 #include <svx/msdffdef.hxx>
35 #include <svx/sdasitm.hxx>
36 #include <com/sun/star/uno/Sequence.h>
37 #include <com/sun/star/beans/PropertyValues.hpp>
38 #include <com/sun/star/awt/Point.hpp>
39 #include <svtools/itemset.hxx>
40 #include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp>
41 #include <com/sun/star/drawing/EnhancedCustomShapeSegment.hpp>
42 #include <com/sun/star/drawing/EnhancedCustomShapeParameter.hpp>
43 #include <com/sun/star/drawing/EnhancedCustomShapeTextFrame.hpp>
44 #include <com/sun/star/drawing/EnhancedCustomShapeAdjustmentValue.hpp>
45 #include <EnhancedCustomShapeFunctionParser.hxx>
47 #include <boost/shared_ptr.hpp>
48 #include <vector>
50 #define DFF_CUSTOMSHAPE_FLIP_V 1
51 #define DFF_CUSTOMSHAPE_FLIP_H 2
52 #define DFF_CUSTOMSHAPE_EXCH 4
54 class SdrModel;
55 class SfxItemSet;
56 struct SvxMSDffVertPair;
57 struct SvxMSDffCalculationData;
58 struct SvxMSDffTextRectangles;
59 class SvxMSDffAdjustmentHandle;
61 #define HANDLE_FLAGS_MIRRORED_X 0x0001
62 #define HANDLE_FLAGS_MIRRORED_Y 0x0002
63 #define HANDLE_FLAGS_SWITCHED 0x0004
64 #define HANDLE_FLAGS_POLAR 0x0008
65 #define HANDLE_FLAGS_MAP 0x0010
66 #define HANDLE_FLAGS_RANGE_X_MINIMUM 0x0020
67 #define HANDLE_FLAGS_RANGE_X_MAXIMUM 0x0040
68 #define HANDLE_FLAGS_RANGE_Y_MINIMUM 0x0080
69 #define HANDLE_FLAGS_RANGE_Y_MAXIMUM 0x0100
70 #define HANDLE_FLAGS_RADIUS_RANGE_MINIMUM 0x0200
71 #define HANDLE_FLAGS_RADIUS_RANGE_MAXIMUM 0x0400
73 // MSDFF_HANDLE_FLAGS_RANGE_Y seems to be not defined in
74 // escher, but we are using it internally in to differentiate
75 // between X_RANGE and Y_RANGE
77 class SdrPathObj;
79 class EnhancedCustomShape2d : public SfxItemSet
81 SdrObject* pCustomShapeObj;
82 MSO_SPT eSpType;
84 sal_Int32 nCoordLeft;
85 sal_Int32 nCoordTop;
86 sal_Int32 nCoordWidth;
87 sal_Int32 nCoordHeight;
88 Rectangle aLogicRect;
90 double fXScale;
91 double fYScale;
92 double fXRatio;
93 double fYRatio;
95 sal_Int32 nXRef;
96 sal_Int32 nYRef;
97 sal_uInt32 nFlags;
98 sal_uInt32 nColorData;
103 com::sun::star::uno::Sequence< rtl::OUString > seqEquations;
104 std::vector< ::boost::shared_ptr< EnhancedCustomShape::ExpressionNode > > vNodesSharedPtr;
107 com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeSegment > seqSegments;
108 com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeParameterPair> seqCoordinates;
109 com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeTextFrame > seqTextFrames;
110 com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeParameterPair> seqGluePoints;
111 com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeAdjustmentValue > seqAdjustmentValues;
112 com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValues > seqHandles;
114 sal_Bool bTextFlow : 1;
115 sal_Bool bFilled : 1;
116 sal_Bool bStroked : 1;
118 sal_Bool bFlipH;
119 sal_Bool bFlipV;
120 sal_Int32 nRotateAngle;
122 sal_Bool SetAdjustValueAsDouble( const double& rValue, const sal_Int32 nIndex );
123 sal_Int32 GetLuminanceChange( sal_uInt32 nIndex ) const;
124 Color GetColorData( const Color& rFillColor, sal_uInt32 nIndex ) const;
125 void AdaptObjColor(SdrPathObj& rObj, const SfxItemSet& rCustomShapeSet,
126 sal_uInt32& nColorIndex, sal_uInt32 nColorCount);
127 sal_Bool GetParameter( double& rParameterReturnValue, const com::sun::star::drawing::EnhancedCustomShapeParameter&,
128 const sal_Bool bReplaceGeoWidth, const sal_Bool bReplaceGeoHeight ) const;
129 Point GetPoint( const com::sun::star::drawing::EnhancedCustomShapeParameterPair&,
130 const sal_Bool bScale = sal_True, const sal_Bool bReplaceGeoSize = sal_False ) const;
132 void CreateSubPath( sal_uInt16& rSrcPt, sal_uInt16& rSegmentInd, std::vector< SdrPathObj* >& rObjectList,
133 sal_Bool bLineGeometryNeededOnly, sal_Bool bSortFilledObjectsToBack );
134 SdrObject* CreatePathObj( sal_Bool bLineGeometryNeededOnly );
135 const sal_Int32* ApplyShapeAttributes( const SdrCustomShapeGeometryItem& rItem );
137 public :
139 struct Handle
141 sal_uInt32 nFlags;
143 sal_Bool bMirroredX;
144 sal_Bool bMirroredY;
145 sal_Bool bSwitched;
147 com::sun::star::drawing::EnhancedCustomShapeParameterPair aPosition;
148 com::sun::star::drawing::EnhancedCustomShapeParameterPair aPolar;
150 com::sun::star::drawing::EnhancedCustomShapeParameter aRadiusRangeMinimum;
151 com::sun::star::drawing::EnhancedCustomShapeParameter aRadiusRangeMaximum;
152 com::sun::star::drawing::EnhancedCustomShapeParameter aXRangeMinimum;
153 com::sun::star::drawing::EnhancedCustomShapeParameter aXRangeMaximum;
154 com::sun::star::drawing::EnhancedCustomShapeParameter aYRangeMinimum;
155 com::sun::star::drawing::EnhancedCustomShapeParameter aYRangeMaximum;
158 sal_Bool IsFlipVert() { return bFlipV; };
159 sal_Bool IsFlipHorz() { return bFlipH; };
160 sal_Int32 GetRotateAngle() { return nRotateAngle; };
162 SVX_DLLPUBLIC SdrObject* CreateLineGeometry();
163 SVX_DLLPUBLIC SdrObject* CreateObject( sal_Bool bLineGeometryNeededOnly );
164 SVX_DLLPUBLIC void ApplyGluePoints( SdrObject* pObj );
165 SVX_DLLPUBLIC Rectangle GetTextRect() const;
167 SVX_DLLPUBLIC sal_uInt32 GetHdlCount() const;
168 SVX_DLLPUBLIC sal_Bool GetHandlePosition( const sal_uInt32 nIndex, Point& rReturnPosition ) const;
169 SVX_DLLPUBLIC sal_Bool SetHandleControllerPosition( const sal_uInt32 nIndex, const com::sun::star::awt::Point& rPosition );
171 SVX_DLLPUBLIC EnhancedCustomShape2d( SdrObject* pSdrObjCustomShape );
172 SVX_DLLPUBLIC ~EnhancedCustomShape2d();
174 enum EnumFunc
176 ENUM_FUNC_PI,
177 ENUM_FUNC_LEFT,
178 ENUM_FUNC_TOP,
179 ENUM_FUNC_RIGHT,
180 ENUM_FUNC_BOTTOM,
181 ENUM_FUNC_XSTRETCH,
182 ENUM_FUNC_YSTRETCH,
183 ENUM_FUNC_HASSTROKE,
184 ENUM_FUNC_HASFILL,
185 ENUM_FUNC_WIDTH,
186 ENUM_FUNC_HEIGHT,
187 ENUM_FUNC_LOGWIDTH,
188 ENUM_FUNC_LOGHEIGHT
190 double GetEnumFunc( const EnumFunc eVal ) const;
192 double GetAdjustValueAsDouble( const sal_Int32 nIndex ) const;
193 double GetEquationValueAsDouble( const sal_Int32 nIndex ) const;
194 sal_Int32 GetAdjustValueAsInteger( const sal_Int32 nIndex, const sal_Int32 nDefault = 0 ) const;
196 SVX_DLLPUBLIC static rtl::OUString GetEquation( const sal_uInt16 nFlags, sal_Int16 nPara1, sal_Int16 nPara2, sal_Int16 nPara3 );
198 static void AppendEnhancedCustomShapeEquationParameter( rtl::OUString& rParameter, const sal_Int16 nPara, const sal_Bool bIsSpecialValue );
200 static void SetEnhancedCustomShapeEquationParameter( com::sun::star::drawing::EnhancedCustomShapeParameter&
201 rParameter, const sal_Int16 nPara, const sal_Bool bIsSpecialValue );
202 SVX_DLLPUBLIC static void SetEnhancedCustomShapeParameter( com::sun::star::drawing::EnhancedCustomShapeParameter&
203 rParameter, const sal_Int32 nValue );
204 SVX_DLLPUBLIC static void SetEnhancedCustomShapeHandleParameter( com::sun::star::drawing::EnhancedCustomShapeParameter&
205 rParameter, const sal_Int32 nPara, const sal_Bool bIsSpecialValue, sal_Bool bHorz );
206 static sal_Bool ConvertSequenceToEnhancedCustomShape2dHandle( const com::sun::star::beans::PropertyValues& rHandleProperties,
207 EnhancedCustomShape2d::Handle& rDestinationHandle );
208 static void SwapStartAndEndArrow( SdrObject* pObj );
210 #endif