update credits
[LibreOffice.git] / include / svx / EnhancedCustomShape2d.hxx
blob2aee4f52748809663124e2876dd07b55988905ea
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef _ENHANCEDCUSTOMSHAPE2D_HXX
21 #define _ENHANCEDCUSTOMSHAPE2D_HXX
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>
38 #include <boost/shared_ptr.hpp>
39 #include <vector>
41 #define DFF_CUSTOMSHAPE_FLIP_V 1
42 #define DFF_CUSTOMSHAPE_FLIP_H 2
43 #define DFF_CUSTOMSHAPE_EXCH 4
45 class SdrModel;
46 class SdrObject;
47 class SfxItemSet;
48 struct SvxMSDffVertPair;
49 struct SvxMSDffCalculationData;
50 struct SvxMSDffTextRectangles;
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
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
72 class SdrPathObj;
74 class EnhancedCustomShape2d : public SfxItemSet
76 SdrObject* pCustomShapeObj;
77 MSO_SPT eSpType;
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;
87 double fXScale;
88 double fYScale;
89 double fXRatio;
90 double fYRatio;
92 sal_Bool bOOXMLShape;
94 sal_Int32 nXRef;
95 sal_Int32 nYRef;
96 sal_uInt32 nFlags;
97 sal_uInt32 nColorData;
102 struct EquationResult {
103 sal_Bool bReady;
104 double fValue;
106 com::sun::star::uno::Sequence< OUString > seqEquations;
107 std::vector< ::boost::shared_ptr< EnhancedCustomShape::ExpressionNode > > vNodesSharedPtr;
108 std::vector< EquationResult > vEquationResults;
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;
118 sal_Bool bTextFlow : 1;
119 sal_Bool bFilled : 1;
120 sal_Bool bStroked : 1;
122 sal_Bool bFlipH;
123 sal_Bool bFlipV;
124 sal_Int32 nRotateAngle;
126 bool SetAdjustValueAsDouble( const double& rValue, const sal_Int32 nIndex );
127 sal_Int32 GetLuminanceChange( sal_uInt32 nIndex ) const;
128 Color GetColorData( const Color& rFillColor, sal_uInt32 nIndex, double dBrightness ) const;
129 void AdaptObjColor(SdrPathObj& rObj, const SfxItemSet& rCustomShapeSet,
130 sal_uInt32& nColorIndex, sal_uInt32 nColorCount);
131 bool GetParameter( double& rParameterReturnValue, const com::sun::star::drawing::EnhancedCustomShapeParameter&,
132 const bool bReplaceGeoWidth, const bool bReplaceGeoHeight ) const;
133 Point GetPoint( const com::sun::star::drawing::EnhancedCustomShapeParameterPair&,
134 const bool bScale = true, const bool bReplaceGeoSize = false ) const;
136 void CreateSubPath( sal_uInt16& rSrcPt, sal_uInt16& rSegmentInd, std::vector< SdrPathObj* >& rObjectList,
137 sal_Bool bLineGeometryNeededOnly, sal_Bool bSortFilledObjectsToBack,
138 sal_Int32 nIndex );
139 SdrObject* CreatePathObj( sal_Bool bLineGeometryNeededOnly );
140 const sal_Int32* ApplyShapeAttributes( const SdrCustomShapeGeometryItem& rItem );
142 void SetPathSize( sal_Int32 nIndex = 0 );
144 public :
146 struct Handle
148 sal_uInt32 nFlags;
150 sal_Bool bMirroredX;
151 sal_Bool bMirroredY;
152 sal_Bool bSwitched;
154 com::sun::star::drawing::EnhancedCustomShapeParameterPair aPosition;
155 com::sun::star::drawing::EnhancedCustomShapeParameterPair aPolar;
157 sal_Int32 nRefX;
158 sal_Int32 nRefY;
159 sal_Int32 nRefAngle;
160 sal_Int32 nRefR;
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;
169 Handle() : bMirroredX ( sal_False ), bMirroredY ( sal_False ), bSwitched( sal_False ),
170 nRefX( -1 ), nRefY( -1 ), nRefAngle( -1 ), nRefR( -1 ) {};
173 sal_Bool IsFlipVert() { return bFlipV; };
174 sal_Bool IsFlipHorz() { return bFlipH; };
175 sal_Int32 GetRotateAngle() { return nRotateAngle; };
176 SVX_DLLPUBLIC bool IsPostRotate() const;
178 SVX_DLLPUBLIC SdrObject* CreateLineGeometry();
179 SVX_DLLPUBLIC SdrObject* CreateObject( sal_Bool bLineGeometryNeededOnly );
180 SVX_DLLPUBLIC void ApplyGluePoints( SdrObject* pObj );
181 SVX_DLLPUBLIC Rectangle GetTextRect() const;
183 SVX_DLLPUBLIC sal_uInt32 GetHdlCount() const;
184 SVX_DLLPUBLIC bool GetHandlePosition( const sal_uInt32 nIndex, Point& rReturnPosition ) const;
185 SVX_DLLPUBLIC bool SetHandleControllerPosition( const sal_uInt32 nIndex, const com::sun::star::awt::Point& rPosition );
187 SVX_DLLPUBLIC EnhancedCustomShape2d( SdrObject* pSdrObjCustomShape );
188 SVX_DLLPUBLIC ~EnhancedCustomShape2d();
190 enum EnumFunc
192 ENUM_FUNC_PI,
193 ENUM_FUNC_LEFT,
194 ENUM_FUNC_TOP,
195 ENUM_FUNC_RIGHT,
196 ENUM_FUNC_BOTTOM,
197 ENUM_FUNC_XSTRETCH,
198 ENUM_FUNC_YSTRETCH,
199 ENUM_FUNC_HASSTROKE,
200 ENUM_FUNC_HASFILL,
201 ENUM_FUNC_WIDTH,
202 ENUM_FUNC_HEIGHT,
203 ENUM_FUNC_LOGWIDTH,
204 ENUM_FUNC_LOGHEIGHT
206 double GetEnumFunc( const EnumFunc eVal ) const;
208 double GetAdjustValueAsDouble( const sal_Int32 nIndex ) const;
209 double GetEquationValueAsDouble( const sal_Int32 nIndex ) const;
210 sal_Int32 GetAdjustValueAsInteger( const sal_Int32 nIndex, const sal_Int32 nDefault = 0 ) const;
212 SVX_DLLPUBLIC static OUString GetEquation( const sal_uInt16 nFlags, sal_Int32 nPara1, sal_Int32 nPara2, sal_Int32 nPara3 );
214 static void AppendEnhancedCustomShapeEquationParameter( OUString& rParameter, const sal_Int32 nPara, const bool bIsSpecialValue );
216 static void SetEnhancedCustomShapeEquationParameter( com::sun::star::drawing::EnhancedCustomShapeParameter&
217 rParameter, const sal_Int16 nPara, const sal_Bool bIsSpecialValue );
218 SVX_DLLPUBLIC static void SetEnhancedCustomShapeParameter( com::sun::star::drawing::EnhancedCustomShapeParameter&
219 rParameter, const sal_Int32 nValue );
220 SVX_DLLPUBLIC static void SetEnhancedCustomShapeHandleParameter( com::sun::star::drawing::EnhancedCustomShapeParameter&
221 rParameter, const sal_Int32 nPara, const bool bIsSpecialValue, bool bHorz );
222 static bool ConvertSequenceToEnhancedCustomShape2dHandle( const com::sun::star::beans::PropertyValues& rHandleProperties,
223 EnhancedCustomShape2d::Handle& rDestinationHandle );
224 static void SwapStartAndEndArrow( SdrObject* pObj );
226 #endif
228 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */