Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef _ENHANCEDCUSTOMSHAPE2D_HXX
30 : : #define _ENHANCEDCUSTOMSHAPE2D_HXX
31 : :
32 : : #include <svx/msdffdef.hxx>
33 : : #include <svx/sdasitm.hxx>
34 : : #include <com/sun/star/uno/Sequence.h>
35 : : #include <com/sun/star/beans/PropertyValues.hpp>
36 : : #include <com/sun/star/awt/Point.hpp>
37 : : #include <com/sun/star/awt/Size.hpp>
38 : : #include <svl/itemset.hxx>
39 : : #include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp>
40 : : #include <com/sun/star/drawing/EnhancedCustomShapeSegment.hpp>
41 : : #include <com/sun/star/drawing/EnhancedCustomShapeParameter.hpp>
42 : : #include <com/sun/star/drawing/EnhancedCustomShapeTextFrame.hpp>
43 : : #include <com/sun/star/drawing/EnhancedCustomShapeAdjustmentValue.hpp>
44 : : #include <svx/EnhancedCustomShapeFunctionParser.hxx>
45 : :
46 : : #include <boost/shared_ptr.hpp>
47 : : #include <vector>
48 : :
49 : : #define DFF_CUSTOMSHAPE_FLIP_V 1
50 : : #define DFF_CUSTOMSHAPE_FLIP_H 2
51 : : #define DFF_CUSTOMSHAPE_EXCH 4
52 : :
53 : : class SdrModel;
54 : : class SdrObject;
55 : : class SfxItemSet;
56 : : struct SvxMSDffVertPair;
57 : : struct SvxMSDffCalculationData;
58 : : struct SvxMSDffTextRectangles;
59 : :
60 : : #define HANDLE_FLAGS_MIRRORED_X 0x0001
61 : : #define HANDLE_FLAGS_MIRRORED_Y 0x0002
62 : : #define HANDLE_FLAGS_SWITCHED 0x0004
63 : : #define HANDLE_FLAGS_POLAR 0x0008
64 : : #define HANDLE_FLAGS_MAP 0x0010
65 : : #define HANDLE_FLAGS_RANGE_X_MINIMUM 0x0020
66 : : #define HANDLE_FLAGS_RANGE_X_MAXIMUM 0x0040
67 : : #define HANDLE_FLAGS_RANGE_Y_MINIMUM 0x0080
68 : : #define HANDLE_FLAGS_RANGE_Y_MAXIMUM 0x0100
69 : : #define HANDLE_FLAGS_RADIUS_RANGE_MINIMUM 0x0200
70 : : #define HANDLE_FLAGS_RADIUS_RANGE_MAXIMUM 0x0400
71 : : #define HANDLE_FLAGS_REFX 0x0800
72 : : #define HANDLE_FLAGS_REFY 0x1000
73 : : #define HANDLE_FLAGS_REFANGLE 0x2000
74 : : #define HANDLE_FLAGS_REFR 0x4000
75 : :
76 : : // MSDFF_HANDLE_FLAGS_RANGE_Y seems to be not defined in
77 : : // escher, but we are using it internally in to differentiate
78 : : // between X_RANGE and Y_RANGE
79 : :
80 : : class SdrPathObj;
81 : :
82 : : class EnhancedCustomShape2d : public SfxItemSet
83 : : {
84 : : SdrObject* pCustomShapeObj;
85 : : MSO_SPT eSpType;
86 : :
87 : : sal_Int32 nCoordLeft;
88 : : sal_Int32 nCoordTop;
89 : : sal_Int32 nCoordWidthG;
90 : : sal_Int32 nCoordHeightG;
91 : : sal_Int32 nCoordWidth;
92 : : sal_Int32 nCoordHeight;
93 : : Rectangle aLogicRect;
94 : :
95 : : double fXScale;
96 : : double fYScale;
97 : : double fXRatio;
98 : : double fYRatio;
99 : :
100 : : sal_Bool bOOXMLShape;
101 : :
102 : : sal_Int32 nXRef;
103 : : sal_Int32 nYRef;
104 : : sal_uInt32 nFlags;
105 : : sal_uInt32 nColorData;
106 : :
107 : : /*
108 : :
109 : : */
110 : : struct EquationResult {
111 : : sal_Bool bReady;
112 : : double fValue;
113 : : };
114 : : com::sun::star::uno::Sequence< rtl::OUString > seqEquations;
115 : : std::vector< ::boost::shared_ptr< EnhancedCustomShape::ExpressionNode > > vNodesSharedPtr;
116 : : std::vector< EquationResult > vEquationResults;
117 : :
118 : : com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeSegment > seqSegments;
119 : : com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeParameterPair> seqCoordinates;
120 : : com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeTextFrame > seqTextFrames;
121 : : com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeParameterPair> seqGluePoints;
122 : : com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeAdjustmentValue > seqAdjustmentValues;
123 : : com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValues > seqHandles;
124 : : com::sun::star::uno::Sequence< com::sun::star::awt::Size > seqSubViewSize;
125 : :
126 : : sal_Bool bTextFlow : 1;
127 : : sal_Bool bFilled : 1;
128 : : sal_Bool bStroked : 1;
129 : :
130 : : sal_Bool bFlipH;
131 : : sal_Bool bFlipV;
132 : : sal_Int32 nRotateAngle;
133 : :
134 : : sal_Bool SetAdjustValueAsDouble( const double& rValue, const sal_Int32 nIndex );
135 : : sal_Int32 GetLuminanceChange( sal_uInt32 nIndex ) const;
136 : : Color GetColorData( const Color& rFillColor, sal_uInt32 nIndex, double dBrightness ) const;
137 : : void AdaptObjColor(SdrPathObj& rObj, const SfxItemSet& rCustomShapeSet,
138 : : sal_uInt32& nColorIndex, sal_uInt32 nColorCount);
139 : : sal_Bool GetParameter( double& rParameterReturnValue, const com::sun::star::drawing::EnhancedCustomShapeParameter&,
140 : : const sal_Bool bReplaceGeoWidth, const sal_Bool bReplaceGeoHeight ) const;
141 : : Point GetPoint( const com::sun::star::drawing::EnhancedCustomShapeParameterPair&,
142 : : const sal_Bool bScale = sal_True, const sal_Bool bReplaceGeoSize = sal_False ) const;
143 : :
144 : : void CreateSubPath( sal_uInt16& rSrcPt, sal_uInt16& rSegmentInd, std::vector< SdrPathObj* >& rObjectList,
145 : : sal_Bool bLineGeometryNeededOnly, sal_Bool bSortFilledObjectsToBack,
146 : : sal_Int32 nIndex );
147 : : SdrObject* CreatePathObj( sal_Bool bLineGeometryNeededOnly );
148 : : const sal_Int32* ApplyShapeAttributes( const SdrCustomShapeGeometryItem& rItem );
149 : :
150 : : void SetPathSize( sal_Int32 nIndex = 0 );
151 : :
152 : : public :
153 : :
154 : 0 : struct Handle
155 : : {
156 : : sal_uInt32 nFlags;
157 : :
158 : : sal_Bool bMirroredX;
159 : : sal_Bool bMirroredY;
160 : : sal_Bool bSwitched;
161 : :
162 : : com::sun::star::drawing::EnhancedCustomShapeParameterPair aPosition;
163 : : com::sun::star::drawing::EnhancedCustomShapeParameterPair aPolar;
164 : :
165 : : sal_Int32 nRefX;
166 : : sal_Int32 nRefY;
167 : : sal_Int32 nRefAngle;
168 : : sal_Int32 nRefR;
169 : :
170 : : com::sun::star::drawing::EnhancedCustomShapeParameter aRadiusRangeMinimum;
171 : : com::sun::star::drawing::EnhancedCustomShapeParameter aRadiusRangeMaximum;
172 : : com::sun::star::drawing::EnhancedCustomShapeParameter aXRangeMinimum;
173 : : com::sun::star::drawing::EnhancedCustomShapeParameter aXRangeMaximum;
174 : : com::sun::star::drawing::EnhancedCustomShapeParameter aYRangeMinimum;
175 : : com::sun::star::drawing::EnhancedCustomShapeParameter aYRangeMaximum;
176 : :
177 : 0 : Handle() : bMirroredX ( sal_False ), bMirroredY ( sal_False ), bSwitched( sal_False ),
178 : 0 : nRefX( -1 ), nRefY( -1 ), nRefAngle( -1 ), nRefR( -1 ) {};
179 : : };
180 : :
181 : 0 : sal_Bool IsFlipVert() { return bFlipV; };
182 : 0 : sal_Bool IsFlipHorz() { return bFlipH; };
183 : 0 : sal_Int32 GetRotateAngle() { return nRotateAngle; };
184 : : SVX_DLLPUBLIC bool IsPostRotate() const;
185 : :
186 : : SVX_DLLPUBLIC SdrObject* CreateLineGeometry();
187 : : SVX_DLLPUBLIC SdrObject* CreateObject( sal_Bool bLineGeometryNeededOnly );
188 : : SVX_DLLPUBLIC void ApplyGluePoints( SdrObject* pObj );
189 : : SVX_DLLPUBLIC Rectangle GetTextRect() const;
190 : :
191 : : SVX_DLLPUBLIC sal_uInt32 GetHdlCount() const;
192 : : SVX_DLLPUBLIC sal_Bool GetHandlePosition( const sal_uInt32 nIndex, Point& rReturnPosition ) const;
193 : : SVX_DLLPUBLIC sal_Bool SetHandleControllerPosition( const sal_uInt32 nIndex, const com::sun::star::awt::Point& rPosition );
194 : :
195 : : SVX_DLLPUBLIC EnhancedCustomShape2d( SdrObject* pSdrObjCustomShape );
196 : : SVX_DLLPUBLIC ~EnhancedCustomShape2d();
197 : :
198 : : enum EnumFunc
199 : : {
200 : : ENUM_FUNC_PI,
201 : : ENUM_FUNC_LEFT,
202 : : ENUM_FUNC_TOP,
203 : : ENUM_FUNC_RIGHT,
204 : : ENUM_FUNC_BOTTOM,
205 : : ENUM_FUNC_XSTRETCH,
206 : : ENUM_FUNC_YSTRETCH,
207 : : ENUM_FUNC_HASSTROKE,
208 : : ENUM_FUNC_HASFILL,
209 : : ENUM_FUNC_WIDTH,
210 : : ENUM_FUNC_HEIGHT,
211 : : ENUM_FUNC_LOGWIDTH,
212 : : ENUM_FUNC_LOGHEIGHT
213 : : };
214 : : double GetEnumFunc( const EnumFunc eVal ) const;
215 : :
216 : : double GetAdjustValueAsDouble( const sal_Int32 nIndex ) const;
217 : : double GetEquationValueAsDouble( const sal_Int32 nIndex ) const;
218 : : sal_Int32 GetAdjustValueAsInteger( const sal_Int32 nIndex, const sal_Int32 nDefault = 0 ) const;
219 : :
220 : : SVX_DLLPUBLIC static rtl::OUString GetEquation( const sal_uInt16 nFlags, sal_Int16 nPara1, sal_Int16 nPara2, sal_Int16 nPara3 );
221 : :
222 : : static void AppendEnhancedCustomShapeEquationParameter( rtl::OUString& rParameter, const sal_Int16 nPara, const sal_Bool bIsSpecialValue );
223 : :
224 : : static void SetEnhancedCustomShapeEquationParameter( com::sun::star::drawing::EnhancedCustomShapeParameter&
225 : : rParameter, const sal_Int16 nPara, const sal_Bool bIsSpecialValue );
226 : : SVX_DLLPUBLIC static void SetEnhancedCustomShapeParameter( com::sun::star::drawing::EnhancedCustomShapeParameter&
227 : : rParameter, const sal_Int32 nValue );
228 : : SVX_DLLPUBLIC static void SetEnhancedCustomShapeHandleParameter( com::sun::star::drawing::EnhancedCustomShapeParameter&
229 : : rParameter, const sal_Int32 nPara, const sal_Bool bIsSpecialValue, sal_Bool bHorz );
230 : : static sal_Bool ConvertSequenceToEnhancedCustomShape2dHandle( const com::sun::star::beans::PropertyValues& rHandleProperties,
231 : : EnhancedCustomShape2d::Handle& rDestinationHandle );
232 : : static void SwapStartAndEndArrow( SdrObject* pObj );
233 : : };
234 : : #endif
235 : :
236 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|