1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_svx.hxx"
30*cdf0e10cSrcweir #include "svx/EnhancedCustomShape2d.hxx"
31*cdf0e10cSrcweir #include "svx/EnhancedCustomShapeGeometry.hxx"
32*cdf0e10cSrcweir #include "svx/EnhancedCustomShapeTypeNames.hxx"
33*cdf0e10cSrcweir #include <svx/svdoashp.hxx>
34*cdf0e10cSrcweir #include <svx/svdtrans.hxx>
35*cdf0e10cSrcweir #include <svx/svdocirc.hxx>
36*cdf0e10cSrcweir #include <svx/svdogrp.hxx>
37*cdf0e10cSrcweir #include <svx/svdopath.hxx>
38*cdf0e10cSrcweir #ifndef _SVDOCAPT_HXX
39*cdf0e10cSrcweir #include <svx/svdocapt.hxx>
40*cdf0e10cSrcweir #endif
41*cdf0e10cSrcweir #include <svx/svdpage.hxx>
42*cdf0e10cSrcweir #include <svx/xflclit.hxx>
43*cdf0e10cSrcweir #include <svx/sdasaitm.hxx>
44*cdf0e10cSrcweir #include <svx/svdmodel.hxx>
45*cdf0e10cSrcweir #include <rtl/crc.h>
46*cdf0e10cSrcweir #include <rtl/math.hxx>
47*cdf0e10cSrcweir #include <svx/xfillit0.hxx>
48*cdf0e10cSrcweir #include <svx/xlnstit.hxx>
49*cdf0e10cSrcweir #include <svx/xlnedit.hxx>
50*cdf0e10cSrcweir #include <svx/xlnstwit.hxx>
51*cdf0e10cSrcweir #include <svx/xlnedwit.hxx>
52*cdf0e10cSrcweir #include <svx/xlnstcit.hxx>
53*cdf0e10cSrcweir #include <svx/xlnedcit.hxx>
54*cdf0e10cSrcweir #include <svx/xflgrit.hxx>
55*cdf0e10cSrcweir #include <svx/xflhtit.hxx>
56*cdf0e10cSrcweir #include <svx/xbtmpit.hxx>
57*cdf0e10cSrcweir #include <svx/xgrad.hxx>
58*cdf0e10cSrcweir #include <svx/xbitmap.hxx>
59*cdf0e10cSrcweir #include <svx/xhatch.hxx>
60*cdf0e10cSrcweir #include <com/sun/star/awt/Size.hpp>
61*cdf0e10cSrcweir #include <com/sun/star/drawing/EnhancedCustomShapeParameterType.hpp>
62*cdf0e10cSrcweir #ifndef __COM_SUN_STAR_DRAWING_ENHANCEDCUSTOMSHAPESEGMENTCOMMAND_HPP__
63*cdf0e10cSrcweir #include <com/sun/star/drawing/EnhancedCustomShapeSegmentCommand.hpp>
64*cdf0e10cSrcweir #endif
65*cdf0e10cSrcweir #ifndef BOOST_SHARED_PTR_HPP_INCLUDED
66*cdf0e10cSrcweir #include <boost/shared_ptr.hpp>
67*cdf0e10cSrcweir #endif
68*cdf0e10cSrcweir #include <basegfx/numeric/ftools.hxx>
69*cdf0e10cSrcweir #include <basegfx/color/bcolortools.hxx>
70*cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygon.hxx>
71*cdf0e10cSrcweir 
72*cdf0e10cSrcweir // #i76201#
73*cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygontools.hxx>
74*cdf0e10cSrcweir 
75*cdf0e10cSrcweir #include <math.h>
76*cdf0e10cSrcweir 
77*cdf0e10cSrcweir using namespace ::com::sun::star::uno;
78*cdf0e10cSrcweir using namespace ::com::sun::star::drawing;
79*cdf0e10cSrcweir using namespace ::com::sun::star::drawing::EnhancedCustomShapeSegmentCommand;
80*cdf0e10cSrcweir 
81*cdf0e10cSrcweir void EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( EnhancedCustomShapeParameter& rParameter, const sal_Int32 nValue )
82*cdf0e10cSrcweir {
83*cdf0e10cSrcweir 	sal_uInt32 nDat = (sal_uInt32)nValue;
84*cdf0e10cSrcweir 	sal_Int32  nNewValue = nValue;
85*cdf0e10cSrcweir 
86*cdf0e10cSrcweir 	// check if this is a special point
87*cdf0e10cSrcweir 	if ( ( nDat >> 16 ) == 0x8000 )
88*cdf0e10cSrcweir 	{
89*cdf0e10cSrcweir 		nNewValue = (sal_uInt16)nDat;
90*cdf0e10cSrcweir 		rParameter.Type = EnhancedCustomShapeParameterType::EQUATION;
91*cdf0e10cSrcweir 	}
92*cdf0e10cSrcweir 	else
93*cdf0e10cSrcweir 		rParameter.Type = EnhancedCustomShapeParameterType::NORMAL;
94*cdf0e10cSrcweir 	rParameter.Value <<= nNewValue;
95*cdf0e10cSrcweir }
96*cdf0e10cSrcweir 
97*cdf0e10cSrcweir rtl::OUString EnhancedCustomShape2d::GetEquation( const sal_uInt16 nFlags, sal_Int16 nP1, sal_Int16 nP2, sal_Int16 nP3 )
98*cdf0e10cSrcweir {
99*cdf0e10cSrcweir 	rtl::OUString aEquation;
100*cdf0e10cSrcweir 	sal_Bool b1Special = ( nFlags & 0x2000 ) != 0;
101*cdf0e10cSrcweir 	sal_Bool b2Special = ( nFlags & 0x4000 ) != 0;
102*cdf0e10cSrcweir 	sal_Bool b3Special = ( nFlags & 0x8000 ) != 0;
103*cdf0e10cSrcweir 	switch( nFlags & 0xff )
104*cdf0e10cSrcweir 	{
105*cdf0e10cSrcweir 		case 0 :
106*cdf0e10cSrcweir 		case 14 :
107*cdf0e10cSrcweir 		{
108*cdf0e10cSrcweir 			sal_Int32 nOptimize = 0;
109*cdf0e10cSrcweir 			if ( nP1 )
110*cdf0e10cSrcweir 				nOptimize |= 1;
111*cdf0e10cSrcweir 			if ( nP2 )
112*cdf0e10cSrcweir 				nOptimize |= 2;
113*cdf0e10cSrcweir 			if ( b1Special )
114*cdf0e10cSrcweir 				nOptimize |= 4;
115*cdf0e10cSrcweir 			if ( b2Special )
116*cdf0e10cSrcweir 				nOptimize |= 8;
117*cdf0e10cSrcweir 			switch( nOptimize )
118*cdf0e10cSrcweir 			{
119*cdf0e10cSrcweir 				case 0 :
120*cdf0e10cSrcweir 				break;
121*cdf0e10cSrcweir 				case 1 :
122*cdf0e10cSrcweir 				case 4 :
123*cdf0e10cSrcweir 				case 5 :
124*cdf0e10cSrcweir 					EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
125*cdf0e10cSrcweir 				break;
126*cdf0e10cSrcweir 				case 2 :
127*cdf0e10cSrcweir 				case 8 :
128*cdf0e10cSrcweir 				case 10:
129*cdf0e10cSrcweir 					EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special );
130*cdf0e10cSrcweir 				break;
131*cdf0e10cSrcweir 				default :
132*cdf0e10cSrcweir 				{
133*cdf0e10cSrcweir 					EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
134*cdf0e10cSrcweir 					aEquation += rtl::OUString( (sal_Unicode)'+' );
135*cdf0e10cSrcweir 					EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special );
136*cdf0e10cSrcweir 				}
137*cdf0e10cSrcweir 				break;
138*cdf0e10cSrcweir 			}
139*cdf0e10cSrcweir 			if ( b3Special || nP3 )
140*cdf0e10cSrcweir 			{
141*cdf0e10cSrcweir 				aEquation += rtl::OUString( (sal_Unicode)'-' );
142*cdf0e10cSrcweir 				EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP3, b3Special );
143*cdf0e10cSrcweir 			}
144*cdf0e10cSrcweir 		}
145*cdf0e10cSrcweir 		break;
146*cdf0e10cSrcweir 		case 1 :
147*cdf0e10cSrcweir 		{
148*cdf0e10cSrcweir 			EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
149*cdf0e10cSrcweir 			if ( b2Special || ( nP2 != 1 ) )
150*cdf0e10cSrcweir 			{
151*cdf0e10cSrcweir 				aEquation += rtl::OUString( (sal_Unicode)'*' );
152*cdf0e10cSrcweir 				EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special );
153*cdf0e10cSrcweir 			}
154*cdf0e10cSrcweir 			if ( b3Special || ( ( nP3 != 1 ) && ( nP3 != 0 ) ) )
155*cdf0e10cSrcweir 			{
156*cdf0e10cSrcweir 				aEquation += rtl::OUString( (sal_Unicode)'/' );
157*cdf0e10cSrcweir 				EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP3, b3Special );
158*cdf0e10cSrcweir 			}
159*cdf0e10cSrcweir 		}
160*cdf0e10cSrcweir 		break;
161*cdf0e10cSrcweir 		case 2 :
162*cdf0e10cSrcweir 		{
163*cdf0e10cSrcweir 			aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "(" ) );
164*cdf0e10cSrcweir 			EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
165*cdf0e10cSrcweir 			aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "+" ) );
166*cdf0e10cSrcweir 			EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special );
167*cdf0e10cSrcweir 			aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( ")/2" ) );
168*cdf0e10cSrcweir 		}
169*cdf0e10cSrcweir 		break;
170*cdf0e10cSrcweir 		case 3 :
171*cdf0e10cSrcweir 		{
172*cdf0e10cSrcweir 			aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "abs(" ) );
173*cdf0e10cSrcweir 			EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
174*cdf0e10cSrcweir 			aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( ")" ) );
175*cdf0e10cSrcweir 		}
176*cdf0e10cSrcweir 		break;
177*cdf0e10cSrcweir 		case 4 :
178*cdf0e10cSrcweir 		{
179*cdf0e10cSrcweir 			aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "min(" ) );
180*cdf0e10cSrcweir 			EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
181*cdf0e10cSrcweir 			aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "," ) );
182*cdf0e10cSrcweir 			EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special );
183*cdf0e10cSrcweir 			aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( ")" ) );
184*cdf0e10cSrcweir 		}
185*cdf0e10cSrcweir 		break;
186*cdf0e10cSrcweir 		case 5 :
187*cdf0e10cSrcweir 		{
188*cdf0e10cSrcweir 			aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "max(" ) );
189*cdf0e10cSrcweir 			EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
190*cdf0e10cSrcweir 			aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "," ) );
191*cdf0e10cSrcweir 			EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special );
192*cdf0e10cSrcweir 			aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( ")" ) );
193*cdf0e10cSrcweir 		}
194*cdf0e10cSrcweir 		break;
195*cdf0e10cSrcweir 		case 6 :
196*cdf0e10cSrcweir 		{
197*cdf0e10cSrcweir 			aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "if(" ) );
198*cdf0e10cSrcweir 			EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
199*cdf0e10cSrcweir 			aEquation += rtl::OUString( (sal_Unicode)',' );
200*cdf0e10cSrcweir 			EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special );
201*cdf0e10cSrcweir 			aEquation += rtl::OUString( (sal_Unicode)',' );
202*cdf0e10cSrcweir 			EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP3, b3Special );
203*cdf0e10cSrcweir 			aEquation += rtl::OUString( (sal_Unicode)')' );
204*cdf0e10cSrcweir 		}
205*cdf0e10cSrcweir 		break;
206*cdf0e10cSrcweir 		case 7 :
207*cdf0e10cSrcweir 		{
208*cdf0e10cSrcweir 			aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "sqrt(" ) );
209*cdf0e10cSrcweir 			EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
210*cdf0e10cSrcweir 			aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*" ) );
211*cdf0e10cSrcweir 			EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
212*cdf0e10cSrcweir 			aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "+" ) );
213*cdf0e10cSrcweir 			EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special );
214*cdf0e10cSrcweir 			aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*" ) );
215*cdf0e10cSrcweir 			EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special );
216*cdf0e10cSrcweir 			aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "+" ) );
217*cdf0e10cSrcweir 			EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP3, b3Special );
218*cdf0e10cSrcweir 			aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*" ) );
219*cdf0e10cSrcweir 			EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP3, b3Special );
220*cdf0e10cSrcweir 			aEquation += rtl::OUString( (sal_Unicode)')' );
221*cdf0e10cSrcweir 		}
222*cdf0e10cSrcweir 		break;
223*cdf0e10cSrcweir 		case 8 :
224*cdf0e10cSrcweir 		{
225*cdf0e10cSrcweir 			aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "atan2(" ) );
226*cdf0e10cSrcweir 			EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special );
227*cdf0e10cSrcweir 			aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "," ) );
228*cdf0e10cSrcweir 			EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
229*cdf0e10cSrcweir 			aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( ")/(pi/180)" ) );
230*cdf0e10cSrcweir 		}
231*cdf0e10cSrcweir 		break;
232*cdf0e10cSrcweir 		case 9 :
233*cdf0e10cSrcweir 		{
234*cdf0e10cSrcweir 			EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
235*cdf0e10cSrcweir 			aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*sin(" ) );
236*cdf0e10cSrcweir 			EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special );
237*cdf0e10cSrcweir 			aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*(pi/180))" ) );
238*cdf0e10cSrcweir 		}
239*cdf0e10cSrcweir 		break;
240*cdf0e10cSrcweir 		case 10 :
241*cdf0e10cSrcweir 		{
242*cdf0e10cSrcweir 			EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
243*cdf0e10cSrcweir 			aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*cos(" ) );
244*cdf0e10cSrcweir 			EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special );
245*cdf0e10cSrcweir 			aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*(pi/180))" ) );
246*cdf0e10cSrcweir 		}
247*cdf0e10cSrcweir 		break;
248*cdf0e10cSrcweir 		case 11 :
249*cdf0e10cSrcweir 		{
250*cdf0e10cSrcweir 			EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
251*cdf0e10cSrcweir 			aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*" ) );
252*cdf0e10cSrcweir 			aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "cos(atan2(" ) );
253*cdf0e10cSrcweir 			EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP3, b3Special );
254*cdf0e10cSrcweir 			aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "," ) );
255*cdf0e10cSrcweir 			EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special );
256*cdf0e10cSrcweir 			aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "))" ) );
257*cdf0e10cSrcweir 		}
258*cdf0e10cSrcweir 		break;
259*cdf0e10cSrcweir 		case 12 :
260*cdf0e10cSrcweir 		{
261*cdf0e10cSrcweir 			EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
262*cdf0e10cSrcweir 			aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*" ) );
263*cdf0e10cSrcweir 			aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "sin(atan2(" ) );
264*cdf0e10cSrcweir 			EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP3, b3Special );
265*cdf0e10cSrcweir 			aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "," ) );
266*cdf0e10cSrcweir 			EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special );
267*cdf0e10cSrcweir 			aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "))" ) );
268*cdf0e10cSrcweir 		}
269*cdf0e10cSrcweir 		break;
270*cdf0e10cSrcweir 		case 13 :
271*cdf0e10cSrcweir 		{
272*cdf0e10cSrcweir 			aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "sqrt(" ) );
273*cdf0e10cSrcweir 			EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
274*cdf0e10cSrcweir 			aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( ")" ) );
275*cdf0e10cSrcweir 		}
276*cdf0e10cSrcweir 		break;
277*cdf0e10cSrcweir 		case 15 :
278*cdf0e10cSrcweir 		{
279*cdf0e10cSrcweir 			EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP3, b3Special );
280*cdf0e10cSrcweir 			aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*sqrt(1-(" ) );
281*cdf0e10cSrcweir 			EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
282*cdf0e10cSrcweir 			aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "/" ) );
283*cdf0e10cSrcweir 			EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special );
284*cdf0e10cSrcweir 			aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( ")" ) );
285*cdf0e10cSrcweir 			aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*(" ) );
286*cdf0e10cSrcweir 			EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
287*cdf0e10cSrcweir 			aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "/" ) );
288*cdf0e10cSrcweir 			EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special );
289*cdf0e10cSrcweir 			aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "))" ) );
290*cdf0e10cSrcweir 		}
291*cdf0e10cSrcweir 		break;
292*cdf0e10cSrcweir 		case 16 :
293*cdf0e10cSrcweir 		{
294*cdf0e10cSrcweir 			EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
295*cdf0e10cSrcweir 			aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*tan(" ) );
296*cdf0e10cSrcweir 			EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special );
297*cdf0e10cSrcweir 			aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( ")" ) );
298*cdf0e10cSrcweir 		}
299*cdf0e10cSrcweir 		break;
300*cdf0e10cSrcweir 		case 0x80 :
301*cdf0e10cSrcweir 		{
302*cdf0e10cSrcweir 			aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "sqrt(" ) );
303*cdf0e10cSrcweir 			EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP3, b3Special );
304*cdf0e10cSrcweir 			aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*" ) );
305*cdf0e10cSrcweir 			EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP3, b3Special );
306*cdf0e10cSrcweir 			aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "-" ) );
307*cdf0e10cSrcweir 			EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
308*cdf0e10cSrcweir 			aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*" ) );
309*cdf0e10cSrcweir 			EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
310*cdf0e10cSrcweir 			aEquation += rtl::OUString( (sal_Unicode)')' );
311*cdf0e10cSrcweir 		}
312*cdf0e10cSrcweir 		break;
313*cdf0e10cSrcweir 		case 0x81 :
314*cdf0e10cSrcweir 		{
315*cdf0e10cSrcweir 			aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "(cos(" ) );
316*cdf0e10cSrcweir 			EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP3, b3Special );
317*cdf0e10cSrcweir 			aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*(pi/180))*(" ) );
318*cdf0e10cSrcweir 			EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
319*cdf0e10cSrcweir 			aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "-10800)+sin(" ) );
320*cdf0e10cSrcweir 			EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP3, b3Special );
321*cdf0e10cSrcweir 			aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*(pi/180))*(" ) );
322*cdf0e10cSrcweir 			EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special );
323*cdf0e10cSrcweir 			aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "-10800))+10800" ) );
324*cdf0e10cSrcweir 		}
325*cdf0e10cSrcweir 		break;
326*cdf0e10cSrcweir 		case 0x82 :
327*cdf0e10cSrcweir 		{
328*cdf0e10cSrcweir 			aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "-(sin(" ) );
329*cdf0e10cSrcweir 			EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP3, b3Special );
330*cdf0e10cSrcweir 			aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*(pi/180))*(" ) );
331*cdf0e10cSrcweir 			EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
332*cdf0e10cSrcweir 			aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "-10800)-cos(" ) );
333*cdf0e10cSrcweir 			EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP3, b3Special );
334*cdf0e10cSrcweir 			aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*(pi/180))*(" ) );
335*cdf0e10cSrcweir 			EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special );
336*cdf0e10cSrcweir 			aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "-10800))+10800" ) );
337*cdf0e10cSrcweir 		}
338*cdf0e10cSrcweir 		break;
339*cdf0e10cSrcweir 	}
340*cdf0e10cSrcweir 	return aEquation;
341*cdf0e10cSrcweir }
342*cdf0e10cSrcweir 
343*cdf0e10cSrcweir void EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( rtl::OUString& rParameter, const sal_Int16 nPara, const sal_Bool bIsSpecialValue )
344*cdf0e10cSrcweir {
345*cdf0e10cSrcweir 	if ( bIsSpecialValue )
346*cdf0e10cSrcweir 	{
347*cdf0e10cSrcweir 		if ( nPara & 0x400 )
348*cdf0e10cSrcweir 		{
349*cdf0e10cSrcweir 			rParameter += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "?" ) );
350*cdf0e10cSrcweir 			rParameter += rtl::OUString::valueOf( (sal_Int32)( nPara & 0xff ) );
351*cdf0e10cSrcweir 			rParameter += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( " " ) );
352*cdf0e10cSrcweir 		}
353*cdf0e10cSrcweir 		else
354*cdf0e10cSrcweir 		{
355*cdf0e10cSrcweir 			switch( nPara )
356*cdf0e10cSrcweir 			{
357*cdf0e10cSrcweir 				case DFF_Prop_adjustValue :
358*cdf0e10cSrcweir 				case DFF_Prop_adjust2Value :
359*cdf0e10cSrcweir 				case DFF_Prop_adjust3Value :
360*cdf0e10cSrcweir 				case DFF_Prop_adjust4Value :
361*cdf0e10cSrcweir 				case DFF_Prop_adjust5Value :
362*cdf0e10cSrcweir 				case DFF_Prop_adjust6Value :
363*cdf0e10cSrcweir 				case DFF_Prop_adjust7Value :
364*cdf0e10cSrcweir 				case DFF_Prop_adjust8Value :
365*cdf0e10cSrcweir 				case DFF_Prop_adjust9Value :
366*cdf0e10cSrcweir 				case DFF_Prop_adjust10Value :
367*cdf0e10cSrcweir 				{
368*cdf0e10cSrcweir 					rParameter += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "$" ) );
369*cdf0e10cSrcweir 					rParameter += rtl::OUString::valueOf( (sal_Int32)( nPara - DFF_Prop_adjustValue ) );
370*cdf0e10cSrcweir 					rParameter += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( " " ) );
371*cdf0e10cSrcweir 				}
372*cdf0e10cSrcweir 				break;
373*cdf0e10cSrcweir 				case DFF_Prop_geoLeft :
374*cdf0e10cSrcweir 				{
375*cdf0e10cSrcweir 					rParameter += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "left" ) );
376*cdf0e10cSrcweir 				}
377*cdf0e10cSrcweir 				break;
378*cdf0e10cSrcweir 				case DFF_Prop_geoTop :
379*cdf0e10cSrcweir 				{
380*cdf0e10cSrcweir 					rParameter += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "top" ) );
381*cdf0e10cSrcweir 				}
382*cdf0e10cSrcweir 				break;
383*cdf0e10cSrcweir 				case DFF_Prop_geoRight :
384*cdf0e10cSrcweir 				{
385*cdf0e10cSrcweir 					rParameter += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "right" ) );
386*cdf0e10cSrcweir 				}
387*cdf0e10cSrcweir 				break;
388*cdf0e10cSrcweir 				case DFF_Prop_geoBottom :
389*cdf0e10cSrcweir 				{
390*cdf0e10cSrcweir 					rParameter += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "bottom" ) );
391*cdf0e10cSrcweir 				}
392*cdf0e10cSrcweir 				break;
393*cdf0e10cSrcweir 			}
394*cdf0e10cSrcweir 		}
395*cdf0e10cSrcweir 	}
396*cdf0e10cSrcweir 	else
397*cdf0e10cSrcweir 	{
398*cdf0e10cSrcweir 		rParameter += rtl::OUString::valueOf( (sal_Int32)( nPara ) );
399*cdf0e10cSrcweir 	}
400*cdf0e10cSrcweir }
401*cdf0e10cSrcweir 
402*cdf0e10cSrcweir void EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( EnhancedCustomShapeParameter& rParameter, const sal_Int32 nPara, const sal_Bool bIsSpecialValue, sal_Bool bHorz )
403*cdf0e10cSrcweir {
404*cdf0e10cSrcweir 	sal_Int32 nValue = 0;
405*cdf0e10cSrcweir 	if ( bIsSpecialValue )
406*cdf0e10cSrcweir 	{
407*cdf0e10cSrcweir 		if ( ( nPara >= 0x100 ) && ( nPara <= 0x107 ) )
408*cdf0e10cSrcweir 		{
409*cdf0e10cSrcweir 			nValue = nPara & 0xff;
410*cdf0e10cSrcweir 			rParameter.Type = EnhancedCustomShapeParameterType::ADJUSTMENT;
411*cdf0e10cSrcweir 		}
412*cdf0e10cSrcweir 		else if ( ( nPara >= 3 ) && ( nPara <= 0x82 ) )
413*cdf0e10cSrcweir 		{
414*cdf0e10cSrcweir 			nValue = nPara - 3;
415*cdf0e10cSrcweir 			rParameter.Type = EnhancedCustomShapeParameterType::EQUATION;
416*cdf0e10cSrcweir 		}
417*cdf0e10cSrcweir 		else if ( nPara == 0 )
418*cdf0e10cSrcweir 		{
419*cdf0e10cSrcweir 			nValue = 0;
420*cdf0e10cSrcweir 			if ( bHorz )
421*cdf0e10cSrcweir 				rParameter.Type = EnhancedCustomShapeParameterType::LEFT;
422*cdf0e10cSrcweir 			else
423*cdf0e10cSrcweir 				rParameter.Type = EnhancedCustomShapeParameterType::TOP;
424*cdf0e10cSrcweir 		}
425*cdf0e10cSrcweir 		else if ( nPara == 1 )
426*cdf0e10cSrcweir 		{
427*cdf0e10cSrcweir 			nValue = 0;
428*cdf0e10cSrcweir 			if ( bHorz )
429*cdf0e10cSrcweir 				rParameter.Type = EnhancedCustomShapeParameterType::RIGHT;
430*cdf0e10cSrcweir 			else
431*cdf0e10cSrcweir 				rParameter.Type = EnhancedCustomShapeParameterType::BOTTOM;
432*cdf0e10cSrcweir 		}
433*cdf0e10cSrcweir 		else if ( nPara == 2 )	// means to be centered, but should not be
434*cdf0e10cSrcweir 		{						// used in our implementation
435*cdf0e10cSrcweir 			nValue = 5600;
436*cdf0e10cSrcweir 			rParameter.Type = EnhancedCustomShapeParameterType::NORMAL;
437*cdf0e10cSrcweir 		}
438*cdf0e10cSrcweir 		else
439*cdf0e10cSrcweir 		{
440*cdf0e10cSrcweir 			nValue = nPara;
441*cdf0e10cSrcweir 			rParameter.Type = EnhancedCustomShapeParameterType::NORMAL;
442*cdf0e10cSrcweir 		}
443*cdf0e10cSrcweir 	}
444*cdf0e10cSrcweir 	else
445*cdf0e10cSrcweir 	{
446*cdf0e10cSrcweir 		nValue = nPara;
447*cdf0e10cSrcweir 		rParameter.Type = EnhancedCustomShapeParameterType::NORMAL;
448*cdf0e10cSrcweir 	}
449*cdf0e10cSrcweir 	rParameter.Value <<= nValue;
450*cdf0e10cSrcweir }
451*cdf0e10cSrcweir 
452*cdf0e10cSrcweir sal_Bool EnhancedCustomShape2d::ConvertSequenceToEnhancedCustomShape2dHandle(
453*cdf0e10cSrcweir 	const com::sun::star::beans::PropertyValues& rHandleProperties,
454*cdf0e10cSrcweir 		EnhancedCustomShape2d::Handle& rDestinationHandle )
455*cdf0e10cSrcweir {
456*cdf0e10cSrcweir 	sal_Bool bRetValue = sal_False;
457*cdf0e10cSrcweir 	sal_uInt32 i, nProperties = rHandleProperties.getLength();
458*cdf0e10cSrcweir 	if ( nProperties )
459*cdf0e10cSrcweir 	{
460*cdf0e10cSrcweir 		rDestinationHandle.nFlags = 0;
461*cdf0e10cSrcweir 		for ( i = 0; i < nProperties; i++ )
462*cdf0e10cSrcweir 		{
463*cdf0e10cSrcweir 			const com::sun::star::beans::PropertyValue& rPropVal = rHandleProperties[ i ];
464*cdf0e10cSrcweir 
465*cdf0e10cSrcweir 			const rtl::OUString	sPosition			( RTL_CONSTASCII_USTRINGPARAM( "Position" ) );
466*cdf0e10cSrcweir 			const rtl::OUString	sMirroredX			( RTL_CONSTASCII_USTRINGPARAM( "MirroredX" ) );
467*cdf0e10cSrcweir 			const rtl::OUString	sMirroredY			( RTL_CONSTASCII_USTRINGPARAM( "MirroredY" ) );
468*cdf0e10cSrcweir 			const rtl::OUString	sSwitched			( RTL_CONSTASCII_USTRINGPARAM( "Switched" ) );
469*cdf0e10cSrcweir 			const rtl::OUString	sPolar				( RTL_CONSTASCII_USTRINGPARAM( "Polar" ) );
470*cdf0e10cSrcweir //			const rtl::OUString	sMap				( RTL_CONSTASCII_USTRINGPARAM( "Map" ) );
471*cdf0e10cSrcweir 			const rtl::OUString	sRefX				( RTL_CONSTASCII_USTRINGPARAM( "RefX" ) );
472*cdf0e10cSrcweir 			const rtl::OUString	sRefY				( RTL_CONSTASCII_USTRINGPARAM( "RefY" ) );
473*cdf0e10cSrcweir 			const rtl::OUString	sRefAngle			( RTL_CONSTASCII_USTRINGPARAM( "RefAngle" ) );
474*cdf0e10cSrcweir 			const rtl::OUString	sRefR				( RTL_CONSTASCII_USTRINGPARAM( "RefR" ) );
475*cdf0e10cSrcweir 			const rtl::OUString	sRadiusRangeMinimum	( RTL_CONSTASCII_USTRINGPARAM( "RadiusRangeMinimum" ) );
476*cdf0e10cSrcweir 			const rtl::OUString	sRadiusRangeMaximum	( RTL_CONSTASCII_USTRINGPARAM( "RadiusRangeMaximum" ) );
477*cdf0e10cSrcweir 			const rtl::OUString	sRangeXMinimum		( RTL_CONSTASCII_USTRINGPARAM( "RangeXMinimum" ) );
478*cdf0e10cSrcweir 			const rtl::OUString	sRangeXMaximum		( RTL_CONSTASCII_USTRINGPARAM( "RangeXMaximum" ) );
479*cdf0e10cSrcweir 			const rtl::OUString	sRangeYMinimum		( RTL_CONSTASCII_USTRINGPARAM( "RangeYMinimum" ) );
480*cdf0e10cSrcweir 			const rtl::OUString	sRangeYMaximum		( RTL_CONSTASCII_USTRINGPARAM( "RangeYMaximum" ) );
481*cdf0e10cSrcweir 
482*cdf0e10cSrcweir 			if ( rPropVal.Name.equals( sPosition ) )
483*cdf0e10cSrcweir 			{
484*cdf0e10cSrcweir 				if ( rPropVal.Value >>= rDestinationHandle.aPosition )
485*cdf0e10cSrcweir 					bRetValue = sal_True;
486*cdf0e10cSrcweir 			}
487*cdf0e10cSrcweir 			else if ( rPropVal.Name.equals( sMirroredX ) )
488*cdf0e10cSrcweir 			{
489*cdf0e10cSrcweir 				sal_Bool bMirroredX = sal_Bool();
490*cdf0e10cSrcweir 				if ( rPropVal.Value >>= bMirroredX )
491*cdf0e10cSrcweir 				{
492*cdf0e10cSrcweir 					if ( bMirroredX )
493*cdf0e10cSrcweir 						rDestinationHandle.nFlags |= HANDLE_FLAGS_MIRRORED_X;
494*cdf0e10cSrcweir 				}
495*cdf0e10cSrcweir 			}
496*cdf0e10cSrcweir 			else if ( rPropVal.Name.equals( sMirroredY ) )
497*cdf0e10cSrcweir 			{
498*cdf0e10cSrcweir 				sal_Bool bMirroredY = sal_Bool();
499*cdf0e10cSrcweir 				if ( rPropVal.Value >>= bMirroredY )
500*cdf0e10cSrcweir 				{
501*cdf0e10cSrcweir 					if ( bMirroredY )
502*cdf0e10cSrcweir 						rDestinationHandle.nFlags |= HANDLE_FLAGS_MIRRORED_Y;
503*cdf0e10cSrcweir 				}
504*cdf0e10cSrcweir 			}
505*cdf0e10cSrcweir 			else if ( rPropVal.Name.equals( sSwitched ) )
506*cdf0e10cSrcweir 			{
507*cdf0e10cSrcweir 				sal_Bool bSwitched = sal_Bool();
508*cdf0e10cSrcweir 				if ( rPropVal.Value >>= bSwitched )
509*cdf0e10cSrcweir 				{
510*cdf0e10cSrcweir 					if ( bSwitched )
511*cdf0e10cSrcweir 						rDestinationHandle.nFlags |= HANDLE_FLAGS_SWITCHED;
512*cdf0e10cSrcweir 				}
513*cdf0e10cSrcweir 			}
514*cdf0e10cSrcweir 			else if ( rPropVal.Name.equals( sPolar ) )
515*cdf0e10cSrcweir 			{
516*cdf0e10cSrcweir 				if ( rPropVal.Value >>= rDestinationHandle.aPolar )
517*cdf0e10cSrcweir 					rDestinationHandle.nFlags |= HANDLE_FLAGS_POLAR;
518*cdf0e10cSrcweir 			}
519*cdf0e10cSrcweir /* seems not to be used.
520*cdf0e10cSrcweir 			else if ( rPropVal.Name.equals( sMap ) )
521*cdf0e10cSrcweir 			{
522*cdf0e10cSrcweir 				com::sun::star::drawing::EnhancedCustomShapeParameterPair aMap;
523*cdf0e10cSrcweir 				if ( rPropVal.Value >>= aMap )
524*cdf0e10cSrcweir 				{
525*cdf0e10cSrcweir 					if ( GetValueForEnhancedCustomShapeHandleParameter( nXMap, aMap.First ) )
526*cdf0e10cSrcweir 						rDestinationHandle.Flags |= 0x800;
527*cdf0e10cSrcweir 					if ( GetValueForEnhancedCustomShapeHandleParameter( nYMap, aMap.Second ) )
528*cdf0e10cSrcweir 						rDestinationHandle.Flags |= 0x1000;
529*cdf0e10cSrcweir 					rDestinationHandle.Flags |= 0x10;
530*cdf0e10cSrcweir 				}
531*cdf0e10cSrcweir 			}
532*cdf0e10cSrcweir */
533*cdf0e10cSrcweir 			else if ( rPropVal.Name.equals( sRefX ) )
534*cdf0e10cSrcweir 			{
535*cdf0e10cSrcweir 				if ( rPropVal.Value >>= rDestinationHandle.nRefX )
536*cdf0e10cSrcweir 					rDestinationHandle.nFlags |= HANDLE_FLAGS_REFX;
537*cdf0e10cSrcweir 			}
538*cdf0e10cSrcweir 			else if ( rPropVal.Name.equals( sRefY ) )
539*cdf0e10cSrcweir 			{
540*cdf0e10cSrcweir 				if ( rPropVal.Value >>= rDestinationHandle.nRefY )
541*cdf0e10cSrcweir 					rDestinationHandle.nFlags |= HANDLE_FLAGS_REFY;
542*cdf0e10cSrcweir 			}
543*cdf0e10cSrcweir 			else if ( rPropVal.Name.equals( sRefAngle ) )
544*cdf0e10cSrcweir 			{
545*cdf0e10cSrcweir 				if ( rPropVal.Value >>= rDestinationHandle.nRefAngle )
546*cdf0e10cSrcweir 					rDestinationHandle.nFlags |= HANDLE_FLAGS_REFANGLE;
547*cdf0e10cSrcweir 			}
548*cdf0e10cSrcweir 			else if ( rPropVal.Name.equals( sRefR ) )
549*cdf0e10cSrcweir 			{
550*cdf0e10cSrcweir 				if ( rPropVal.Value >>= rDestinationHandle.nRefR )
551*cdf0e10cSrcweir 					rDestinationHandle.nFlags |= HANDLE_FLAGS_REFR;
552*cdf0e10cSrcweir 			}
553*cdf0e10cSrcweir 			else if ( rPropVal.Name.equals( sRadiusRangeMinimum ) )
554*cdf0e10cSrcweir 			{
555*cdf0e10cSrcweir 				if ( rPropVal.Value >>= rDestinationHandle.aRadiusRangeMinimum )
556*cdf0e10cSrcweir 					rDestinationHandle.nFlags |= HANDLE_FLAGS_RADIUS_RANGE_MINIMUM;
557*cdf0e10cSrcweir 			}
558*cdf0e10cSrcweir 			else if ( rPropVal.Name.equals( sRadiusRangeMaximum ) )
559*cdf0e10cSrcweir 			{
560*cdf0e10cSrcweir 				if ( rPropVal.Value >>= rDestinationHandle.aRadiusRangeMaximum )
561*cdf0e10cSrcweir 					rDestinationHandle.nFlags |= HANDLE_FLAGS_RADIUS_RANGE_MAXIMUM;
562*cdf0e10cSrcweir 			}
563*cdf0e10cSrcweir 			else if ( rPropVal.Name.equals( sRangeXMinimum ) )
564*cdf0e10cSrcweir 			{
565*cdf0e10cSrcweir 				if ( rPropVal.Value >>= rDestinationHandle.aXRangeMinimum )
566*cdf0e10cSrcweir 					rDestinationHandle.nFlags |= HANDLE_FLAGS_RANGE_X_MINIMUM;
567*cdf0e10cSrcweir 			}
568*cdf0e10cSrcweir 			else if ( rPropVal.Name.equals( sRangeXMaximum ) )
569*cdf0e10cSrcweir 			{
570*cdf0e10cSrcweir 				if ( rPropVal.Value >>= rDestinationHandle.aXRangeMaximum )
571*cdf0e10cSrcweir 					rDestinationHandle.nFlags |= HANDLE_FLAGS_RANGE_X_MAXIMUM;
572*cdf0e10cSrcweir 			}
573*cdf0e10cSrcweir 			else if ( rPropVal.Name.equals( sRangeYMinimum ) )
574*cdf0e10cSrcweir 			{
575*cdf0e10cSrcweir 				if ( rPropVal.Value >>= rDestinationHandle.aYRangeMinimum )
576*cdf0e10cSrcweir 					rDestinationHandle.nFlags |= HANDLE_FLAGS_RANGE_Y_MINIMUM;
577*cdf0e10cSrcweir 			}
578*cdf0e10cSrcweir 			else if ( rPropVal.Name.equals( sRangeYMaximum ) )
579*cdf0e10cSrcweir 			{
580*cdf0e10cSrcweir 				if ( rPropVal.Value >>= rDestinationHandle.aYRangeMaximum )
581*cdf0e10cSrcweir 					rDestinationHandle.nFlags |= HANDLE_FLAGS_RANGE_Y_MAXIMUM;
582*cdf0e10cSrcweir 			}
583*cdf0e10cSrcweir 		}
584*cdf0e10cSrcweir 	}
585*cdf0e10cSrcweir 	return bRetValue;
586*cdf0e10cSrcweir }
587*cdf0e10cSrcweir 
588*cdf0e10cSrcweir const sal_Int32* EnhancedCustomShape2d::ApplyShapeAttributes( const SdrCustomShapeGeometryItem& rGeometryItem )
589*cdf0e10cSrcweir {
590*cdf0e10cSrcweir 	const sal_Int32* pDefData = NULL;
591*cdf0e10cSrcweir 	const mso_CustomShape* pDefCustomShape = GetCustomShapeContent( eSpType );
592*cdf0e10cSrcweir 	if ( pDefCustomShape )
593*cdf0e10cSrcweir 		pDefData = pDefCustomShape->pDefData;
594*cdf0e10cSrcweir 
595*cdf0e10cSrcweir 	//////////////////////
596*cdf0e10cSrcweir 	// AdjustmentValues //
597*cdf0e10cSrcweir 	//////////////////////
598*cdf0e10cSrcweir 	const rtl::OUString	sAdjustmentValues( RTL_CONSTASCII_USTRINGPARAM ( "AdjustmentValues" ) );
599*cdf0e10cSrcweir 	const Any* pAny = ((SdrCustomShapeGeometryItem&)rGeometryItem).GetPropertyValueByName( sAdjustmentValues );
600*cdf0e10cSrcweir 	if ( pAny )
601*cdf0e10cSrcweir 		*pAny >>= seqAdjustmentValues;
602*cdf0e10cSrcweir 
603*cdf0e10cSrcweir 	///////////////
604*cdf0e10cSrcweir 	// Coordsize //
605*cdf0e10cSrcweir 	///////////////
606*cdf0e10cSrcweir 	const rtl::OUString	sViewBox( RTL_CONSTASCII_USTRINGPARAM ( "ViewBox" ) );
607*cdf0e10cSrcweir 	const Any* pViewBox = ((SdrCustomShapeGeometryItem&)rGeometryItem).GetPropertyValueByName( sViewBox );
608*cdf0e10cSrcweir 	com::sun::star::awt::Rectangle aViewBox;
609*cdf0e10cSrcweir 	if ( pViewBox && (*pViewBox >>= aViewBox ) )
610*cdf0e10cSrcweir 	{
611*cdf0e10cSrcweir 		nCoordLeft  = aViewBox.X;
612*cdf0e10cSrcweir 		nCoordTop   = aViewBox.Y;
613*cdf0e10cSrcweir 		nCoordWidth = labs( aViewBox.Width );
614*cdf0e10cSrcweir 		nCoordHeight= labs( aViewBox.Height);
615*cdf0e10cSrcweir 	}
616*cdf0e10cSrcweir 	const rtl::OUString	sPath( RTL_CONSTASCII_USTRINGPARAM ( "Path" ) );
617*cdf0e10cSrcweir 
618*cdf0e10cSrcweir 	//////////////////////
619*cdf0e10cSrcweir 	// Path/Coordinates //
620*cdf0e10cSrcweir 	//////////////////////
621*cdf0e10cSrcweir 	const rtl::OUString	sCoordinates( RTL_CONSTASCII_USTRINGPARAM ( "Coordinates" ) );
622*cdf0e10cSrcweir 	pAny = ((SdrCustomShapeGeometryItem&)rGeometryItem).GetPropertyValueByName( sPath, sCoordinates );
623*cdf0e10cSrcweir 	if ( pAny )
624*cdf0e10cSrcweir 		*pAny >>= seqCoordinates;
625*cdf0e10cSrcweir 
626*cdf0e10cSrcweir 	/////////////////////
627*cdf0e10cSrcweir 	// Path/GluePoints //
628*cdf0e10cSrcweir 	/////////////////////
629*cdf0e10cSrcweir 	const rtl::OUString	sGluePoints( RTL_CONSTASCII_USTRINGPARAM ( "GluePoints" ) );
630*cdf0e10cSrcweir 	pAny = ((SdrCustomShapeGeometryItem&)rGeometryItem).GetPropertyValueByName( sPath, sGluePoints );
631*cdf0e10cSrcweir 	if ( pAny )
632*cdf0e10cSrcweir 		*pAny >>= seqGluePoints;
633*cdf0e10cSrcweir 
634*cdf0e10cSrcweir 	///////////////////
635*cdf0e10cSrcweir 	// Path/Segments //
636*cdf0e10cSrcweir 	///////////////////
637*cdf0e10cSrcweir 	const rtl::OUString	sSegments( RTL_CONSTASCII_USTRINGPARAM ( "Segments" ) );
638*cdf0e10cSrcweir 	pAny = ((SdrCustomShapeGeometryItem&)rGeometryItem).GetPropertyValueByName( sPath, sSegments );
639*cdf0e10cSrcweir 	if ( pAny )
640*cdf0e10cSrcweir 		*pAny >>= seqSegments;
641*cdf0e10cSrcweir 
642*cdf0e10cSrcweir 	///////////////////
643*cdf0e10cSrcweir 	// Path/StretchX //
644*cdf0e10cSrcweir 	///////////////////
645*cdf0e10cSrcweir 	const rtl::OUString	sStretchX( RTL_CONSTASCII_USTRINGPARAM ( "StretchX" ) );
646*cdf0e10cSrcweir 	pAny = ((SdrCustomShapeGeometryItem&)rGeometryItem).GetPropertyValueByName( sPath, sStretchX );
647*cdf0e10cSrcweir 	if ( pAny )
648*cdf0e10cSrcweir 	{
649*cdf0e10cSrcweir 		sal_Int32 nStretchX = 0;
650*cdf0e10cSrcweir 		if ( *pAny >>= nStretchX )
651*cdf0e10cSrcweir 			nXRef = nStretchX;
652*cdf0e10cSrcweir 	}
653*cdf0e10cSrcweir 
654*cdf0e10cSrcweir 	///////////////////
655*cdf0e10cSrcweir 	// Path/StretchY //
656*cdf0e10cSrcweir 	///////////////////
657*cdf0e10cSrcweir 	const rtl::OUString	sStretchY( RTL_CONSTASCII_USTRINGPARAM ( "StretchY" ) );
658*cdf0e10cSrcweir 	pAny = ((SdrCustomShapeGeometryItem&)rGeometryItem).GetPropertyValueByName( sPath, sStretchY );
659*cdf0e10cSrcweir 	if ( pAny )
660*cdf0e10cSrcweir 	{
661*cdf0e10cSrcweir 		sal_Int32 nStretchY = 0;
662*cdf0e10cSrcweir 		if ( *pAny >>= nStretchY )
663*cdf0e10cSrcweir 			nYRef = nStretchY;
664*cdf0e10cSrcweir 	}
665*cdf0e10cSrcweir 
666*cdf0e10cSrcweir 	/////////////////////
667*cdf0e10cSrcweir 	// Path/TextFrames //
668*cdf0e10cSrcweir 	/////////////////////
669*cdf0e10cSrcweir 	const rtl::OUString	sTextFrames( RTL_CONSTASCII_USTRINGPARAM ( "TextFrames" ) );
670*cdf0e10cSrcweir 	pAny = ((SdrCustomShapeGeometryItem&)rGeometryItem).GetPropertyValueByName( sPath, sTextFrames );
671*cdf0e10cSrcweir 	if ( pAny )
672*cdf0e10cSrcweir 		*pAny >>= seqTextFrames;
673*cdf0e10cSrcweir 
674*cdf0e10cSrcweir 	///////////////
675*cdf0e10cSrcweir 	// Equations //
676*cdf0e10cSrcweir 	///////////////
677*cdf0e10cSrcweir 	const rtl::OUString	sEquations( RTL_CONSTASCII_USTRINGPARAM( "Equations" ) );
678*cdf0e10cSrcweir 	pAny = ((SdrCustomShapeGeometryItem&)rGeometryItem).GetPropertyValueByName( sEquations );
679*cdf0e10cSrcweir 	if ( pAny )
680*cdf0e10cSrcweir 		*pAny >>= seqEquations;
681*cdf0e10cSrcweir 
682*cdf0e10cSrcweir 	/////////////
683*cdf0e10cSrcweir 	// Handles //
684*cdf0e10cSrcweir 	/////////////
685*cdf0e10cSrcweir 	const rtl::OUString	sHandles( RTL_CONSTASCII_USTRINGPARAM( "Handles" ) );
686*cdf0e10cSrcweir 	pAny = ((SdrCustomShapeGeometryItem&)rGeometryItem).GetPropertyValueByName( sHandles );
687*cdf0e10cSrcweir 	if ( pAny )
688*cdf0e10cSrcweir 		*pAny >>= seqHandles;
689*cdf0e10cSrcweir 
690*cdf0e10cSrcweir 	return pDefData;
691*cdf0e10cSrcweir }
692*cdf0e10cSrcweir 
693*cdf0e10cSrcweir EnhancedCustomShape2d::~EnhancedCustomShape2d()
694*cdf0e10cSrcweir {
695*cdf0e10cSrcweir }
696*cdf0e10cSrcweir 
697*cdf0e10cSrcweir EnhancedCustomShape2d::EnhancedCustomShape2d( SdrObject* pAObj ) :
698*cdf0e10cSrcweir 	SfxItemSet			( pAObj->GetMergedItemSet() ),
699*cdf0e10cSrcweir 	pCustomShapeObj		( pAObj	),
700*cdf0e10cSrcweir 	eSpType				( mso_sptNil ),
701*cdf0e10cSrcweir 	nCoordLeft			( 0 ),
702*cdf0e10cSrcweir 	nCoordTop			( 0 ),
703*cdf0e10cSrcweir 	nCoordWidth			( 21600 ),
704*cdf0e10cSrcweir 	nCoordHeight		( 21600 ),
705*cdf0e10cSrcweir 	nXRef				( 0x80000000 ),
706*cdf0e10cSrcweir 	nYRef				( 0x80000000 ),
707*cdf0e10cSrcweir 	nFlags				( 0 ),
708*cdf0e10cSrcweir 	nColorData			( 0 ),
709*cdf0e10cSrcweir 	bTextFlow			( sal_False ),
710*cdf0e10cSrcweir 	bFilled				( ((const XFillStyleItem&)pAObj->GetMergedItem( XATTR_FILLSTYLE )).GetValue() != XFILL_NONE ),
711*cdf0e10cSrcweir 	bStroked			( ((const XLineStyleItem&)pAObj->GetMergedItem( XATTR_LINESTYLE )).GetValue() != XLINE_NONE ),
712*cdf0e10cSrcweir 	bFlipH				( sal_False ),
713*cdf0e10cSrcweir 	bFlipV				( sal_False )
714*cdf0e10cSrcweir {
715*cdf0e10cSrcweir 	// bTextFlow needs to be set before clearing the TextDirection Item
716*cdf0e10cSrcweir 
717*cdf0e10cSrcweir 	ClearItem( SDRATTR_TEXTDIRECTION );	//SJ: vertical writing is not required, by removing this item no outliner is created
718*cdf0e10cSrcweir 
719*cdf0e10cSrcweir 	// #i105323# For 2D AtoShapes, the shadow attirbute does not need to be applied to any
720*cdf0e10cSrcweir 	// of the constucted helper SdrObjects. This would lead to problems since the shadow
721*cdf0e10cSrcweir 	// of one helper object would fall on one helper object behind it (e.g. with the
722*cdf0e10cSrcweir 	// eyes of the smiley shape). This is not wanted; instead a single shadow 'behind'
723*cdf0e10cSrcweir 	// the AutoShape visualisation is wanted. This is done with primitive functionailty
724*cdf0e10cSrcweir 	// now in SdrCustomShapePrimitive2D::create2DDecomposition, but only for 2D objects
725*cdf0e10cSrcweir 	// (see there and in EnhancedCustomShape3d::Create3DObject to read more).
726*cdf0e10cSrcweir 	// This exception may be removed later when AutoShapes will create primitives directly.
727*cdf0e10cSrcweir 	// So, currently remove the ShadowAttribute from the ItemSet to not apply it to any
728*cdf0e10cSrcweir 	// 2D helper shape.
729*cdf0e10cSrcweir 	ClearItem(SDRATTR_SHADOW);
730*cdf0e10cSrcweir 
731*cdf0e10cSrcweir 	Point aP( pCustomShapeObj->GetSnapRect().Center() );
732*cdf0e10cSrcweir 	Size aS( pCustomShapeObj->GetLogicRect().GetSize() );
733*cdf0e10cSrcweir 	aP.X() -= aS.Width() / 2;
734*cdf0e10cSrcweir 	aP.Y() -= aS.Height() / 2;
735*cdf0e10cSrcweir 	aLogicRect = Rectangle( aP, aS );
736*cdf0e10cSrcweir 
737*cdf0e10cSrcweir 	const rtl::OUString	sType( RTL_CONSTASCII_USTRINGPARAM ( "Type" ) );
738*cdf0e10cSrcweir 	const rtl::OUString sMirroredX( RTL_CONSTASCII_USTRINGPARAM ( "MirroredX" ) );
739*cdf0e10cSrcweir 	const rtl::OUString sMirroredY( RTL_CONSTASCII_USTRINGPARAM ( "MirroredY" ) );
740*cdf0e10cSrcweir 
741*cdf0e10cSrcweir 	rtl::OUString sShapeType;
742*cdf0e10cSrcweir 	SdrCustomShapeGeometryItem& rGeometryItem = (SdrCustomShapeGeometryItem&)(const SdrCustomShapeGeometryItem&)pCustomShapeObj->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY );
743*cdf0e10cSrcweir 	Any* pAny = rGeometryItem.GetPropertyValueByName( sType );
744*cdf0e10cSrcweir 	if ( pAny )
745*cdf0e10cSrcweir 		*pAny >>= sShapeType;
746*cdf0e10cSrcweir 	eSpType = EnhancedCustomShapeTypeNames::Get( sShapeType );
747*cdf0e10cSrcweir 
748*cdf0e10cSrcweir 	pAny = rGeometryItem.GetPropertyValueByName( sMirroredX );
749*cdf0e10cSrcweir 	if ( pAny )
750*cdf0e10cSrcweir 		*pAny >>= bFlipH;
751*cdf0e10cSrcweir 	pAny = rGeometryItem.GetPropertyValueByName( sMirroredY );
752*cdf0e10cSrcweir 	if ( pAny )
753*cdf0e10cSrcweir 		*pAny >>= bFlipV;
754*cdf0e10cSrcweir 
755*cdf0e10cSrcweir 	if ( pCustomShapeObj->ISA( SdrObjCustomShape ) )	// should always be a SdrObjCustomShape, but you don't know
756*cdf0e10cSrcweir 		nRotateAngle = (sal_Int32)(((SdrObjCustomShape*)pCustomShapeObj)->GetObjectRotation() * 100.0);
757*cdf0e10cSrcweir 	else
758*cdf0e10cSrcweir  		nRotateAngle = pCustomShapeObj->GetRotateAngle();
759*cdf0e10cSrcweir 
760*cdf0e10cSrcweir 	/*const sal_Int32* pDefData =*/ ApplyShapeAttributes( rGeometryItem );
761*cdf0e10cSrcweir 	switch( eSpType )
762*cdf0e10cSrcweir 	{
763*cdf0e10cSrcweir 		case mso_sptCan :						nColorData = 0x20400000; break;
764*cdf0e10cSrcweir 		case mso_sptCube :						nColorData = 0x302e0000; break;
765*cdf0e10cSrcweir 		case mso_sptActionButtonBlank :			nColorData = 0x502ce400; break;
766*cdf0e10cSrcweir 		case mso_sptActionButtonHome :			nColorData = 0x702ce4ce; break;
767*cdf0e10cSrcweir 		case mso_sptActionButtonHelp :			nColorData = 0x602ce4c0; break;
768*cdf0e10cSrcweir 		case mso_sptActionButtonInformation :	nColorData = 0x702ce4c5; break;
769*cdf0e10cSrcweir 		case mso_sptActionButtonBackPrevious :	nColorData = 0x602ce4c0; break;
770*cdf0e10cSrcweir 		case mso_sptActionButtonForwardNext :	nColorData = 0x602ce4c0; break;
771*cdf0e10cSrcweir 		case mso_sptActionButtonBeginning :		nColorData = 0x602ce4c0; break;
772*cdf0e10cSrcweir 		case mso_sptActionButtonEnd :			nColorData = 0x602ce4c0; break;
773*cdf0e10cSrcweir 		case mso_sptActionButtonReturn :		nColorData = 0x602ce4c0; break;
774*cdf0e10cSrcweir 		case mso_sptActionButtonDocument :		nColorData = 0x702ce4ec; break;
775*cdf0e10cSrcweir 		case mso_sptActionButtonSound :			nColorData = 0x602ce4c0; break;
776*cdf0e10cSrcweir 		case mso_sptActionButtonMovie :			nColorData = 0x602ce4c0; break;
777*cdf0e10cSrcweir 		case mso_sptBevel :						nColorData = 0x502ce400; break;
778*cdf0e10cSrcweir 		case mso_sptFoldedCorner :				nColorData = 0x20e00000; break;
779*cdf0e10cSrcweir 		case mso_sptSmileyFace :				nColorData = 0x20e00000; break;
780*cdf0e10cSrcweir         case mso_sptNil :
781*cdf0e10cSrcweir         {
782*cdf0e10cSrcweir             if( sShapeType.getLength() > 4 &&
783*cdf0e10cSrcweir                 sShapeType.matchAsciiL( RTL_CONSTASCII_STRINGPARAM( "col-" )))
784*cdf0e10cSrcweir             {
785*cdf0e10cSrcweir                 nColorData = sShapeType.copy( 4 ).toInt32( 16 );
786*cdf0e10cSrcweir             }
787*cdf0e10cSrcweir         }
788*cdf0e10cSrcweir         break;
789*cdf0e10cSrcweir 		case mso_sptCurvedLeftArrow :
790*cdf0e10cSrcweir 		case mso_sptCurvedRightArrow :
791*cdf0e10cSrcweir 		case mso_sptCurvedUpArrow :
792*cdf0e10cSrcweir 		case mso_sptCurvedDownArrow :			nColorData = 0x20d00000; break;
793*cdf0e10cSrcweir 		case mso_sptRibbon2 :					nColorData = 0x30ee0000; break;
794*cdf0e10cSrcweir 		case mso_sptRibbon :					nColorData = 0x30ee0000; break;
795*cdf0e10cSrcweir 
796*cdf0e10cSrcweir 		case mso_sptEllipseRibbon2 :			nColorData = 0x30ee0000; break;
797*cdf0e10cSrcweir 		case mso_sptEllipseRibbon :				nColorData = 0x30ee0000; break;
798*cdf0e10cSrcweir 
799*cdf0e10cSrcweir 		case mso_sptVerticalScroll :			nColorData = 0x30ee0000; break;
800*cdf0e10cSrcweir 		case mso_sptHorizontalScroll :			nColorData = 0x30ee0000; break;
801*cdf0e10cSrcweir 		default:
802*cdf0e10cSrcweir 			break;
803*cdf0e10cSrcweir 	}
804*cdf0e10cSrcweir  	fXScale = nCoordWidth == 0 ? 0.0 : (double)aLogicRect.GetWidth() / (double)nCoordWidth;
805*cdf0e10cSrcweir  	fYScale = nCoordHeight == 0 ? 0.0 : (double)aLogicRect.GetHeight() / (double)nCoordHeight;
806*cdf0e10cSrcweir  	if ( (sal_uInt32)nXRef != 0x80000000 && aLogicRect.GetHeight() )
807*cdf0e10cSrcweir 	{
808*cdf0e10cSrcweir 		fXRatio = (double)aLogicRect.GetWidth() / (double)aLogicRect.GetHeight();
809*cdf0e10cSrcweir 		if ( fXRatio > 1 )
810*cdf0e10cSrcweir 			fXScale /= fXRatio;
811*cdf0e10cSrcweir 		else
812*cdf0e10cSrcweir 			fXRatio = 1.0;
813*cdf0e10cSrcweir 	}
814*cdf0e10cSrcweir 	else
815*cdf0e10cSrcweir 		fXRatio = 1.0;
816*cdf0e10cSrcweir 	if ( (sal_uInt32)nYRef != 0x80000000 && aLogicRect.GetWidth() )
817*cdf0e10cSrcweir 	{
818*cdf0e10cSrcweir 		fYRatio = (double)aLogicRect.GetHeight() / (double)aLogicRect.GetWidth();
819*cdf0e10cSrcweir 		if ( fYRatio > 1 )
820*cdf0e10cSrcweir 			fYScale /= fYRatio;
821*cdf0e10cSrcweir 		else
822*cdf0e10cSrcweir 			fYRatio = 1.0;
823*cdf0e10cSrcweir 	}
824*cdf0e10cSrcweir 	else
825*cdf0e10cSrcweir 		fYRatio = 1.0;
826*cdf0e10cSrcweir 
827*cdf0e10cSrcweir 	sal_Int32 i, nLength = seqEquations.getLength();
828*cdf0e10cSrcweir 
829*cdf0e10cSrcweir 
830*cdf0e10cSrcweir 	if ( nLength )
831*cdf0e10cSrcweir 	{
832*cdf0e10cSrcweir 		vNodesSharedPtr.resize( nLength );
833*cdf0e10cSrcweir 		for ( i = 0; i < seqEquations.getLength(); i++ )
834*cdf0e10cSrcweir 		{
835*cdf0e10cSrcweir 			try
836*cdf0e10cSrcweir 			{
837*cdf0e10cSrcweir 				vNodesSharedPtr[ i ] = EnhancedCustomShape::FunctionParser::parseFunction( seqEquations[ i ], *this );
838*cdf0e10cSrcweir 			}
839*cdf0e10cSrcweir 			catch ( EnhancedCustomShape::ParseError& )
840*cdf0e10cSrcweir 			{
841*cdf0e10cSrcweir 			}
842*cdf0e10cSrcweir 		}
843*cdf0e10cSrcweir 	}
844*cdf0e10cSrcweir }
845*cdf0e10cSrcweir double EnhancedCustomShape2d::GetEnumFunc( const EnumFunc eFunc ) const
846*cdf0e10cSrcweir {
847*cdf0e10cSrcweir 	double fRet = 0.0;
848*cdf0e10cSrcweir 	switch( eFunc )
849*cdf0e10cSrcweir 	{
850*cdf0e10cSrcweir 		case ENUM_FUNC_PI :			fRet = F_PI; break;
851*cdf0e10cSrcweir 		case ENUM_FUNC_LEFT :		fRet = 0.0; break;
852*cdf0e10cSrcweir 		case ENUM_FUNC_TOP :		fRet = 0.0; break;
853*cdf0e10cSrcweir 		case ENUM_FUNC_RIGHT :		fRet = (double)nCoordWidth * fXRatio;	break;
854*cdf0e10cSrcweir 		case ENUM_FUNC_BOTTOM :		fRet = (double)nCoordHeight * fYRatio; break;
855*cdf0e10cSrcweir 		case ENUM_FUNC_XSTRETCH :	fRet = nXRef; break;
856*cdf0e10cSrcweir 		case ENUM_FUNC_YSTRETCH :	fRet = nYRef; break;
857*cdf0e10cSrcweir 		case ENUM_FUNC_HASSTROKE :	fRet = bStroked ? 1.0 : 0.0; break;
858*cdf0e10cSrcweir 		case ENUM_FUNC_HASFILL :	fRet = bFilled ? 1.0 : 0.0; break;
859*cdf0e10cSrcweir 		case ENUM_FUNC_WIDTH :		fRet = nCoordWidth; break;
860*cdf0e10cSrcweir 		case ENUM_FUNC_HEIGHT :		fRet = nCoordHeight; break;
861*cdf0e10cSrcweir 		case ENUM_FUNC_LOGWIDTH :	fRet = aLogicRect.GetWidth(); break;
862*cdf0e10cSrcweir 		case ENUM_FUNC_LOGHEIGHT :	fRet = aLogicRect.GetHeight(); break;
863*cdf0e10cSrcweir 	}
864*cdf0e10cSrcweir 	return fRet;
865*cdf0e10cSrcweir }
866*cdf0e10cSrcweir double EnhancedCustomShape2d::GetAdjustValueAsDouble( const sal_Int32 nIndex ) const
867*cdf0e10cSrcweir {
868*cdf0e10cSrcweir 	double fNumber = 0.0;
869*cdf0e10cSrcweir 	if ( nIndex < seqAdjustmentValues.getLength() )
870*cdf0e10cSrcweir 	{
871*cdf0e10cSrcweir 		if ( seqAdjustmentValues[ nIndex ].Value.getValueTypeClass() == TypeClass_DOUBLE )
872*cdf0e10cSrcweir 			seqAdjustmentValues[ nIndex ].Value >>= fNumber;
873*cdf0e10cSrcweir 		else
874*cdf0e10cSrcweir 		{
875*cdf0e10cSrcweir 			sal_Int32 nNumber = 0;
876*cdf0e10cSrcweir 			seqAdjustmentValues[ nIndex ].Value >>= nNumber;
877*cdf0e10cSrcweir 			fNumber = (double)nNumber;
878*cdf0e10cSrcweir 		}
879*cdf0e10cSrcweir 	}
880*cdf0e10cSrcweir 	return fNumber;
881*cdf0e10cSrcweir }
882*cdf0e10cSrcweir double EnhancedCustomShape2d::GetEquationValueAsDouble( const sal_Int32 nIndex ) const
883*cdf0e10cSrcweir {
884*cdf0e10cSrcweir 	double fNumber = 0.0;
885*cdf0e10cSrcweir 	if ( nIndex < (sal_Int32)vNodesSharedPtr.size() )
886*cdf0e10cSrcweir 	{
887*cdf0e10cSrcweir 		if ( vNodesSharedPtr[ nIndex ].get() )
888*cdf0e10cSrcweir 		try
889*cdf0e10cSrcweir 		{
890*cdf0e10cSrcweir 			fNumber = (*vNodesSharedPtr[ nIndex ])();
891*cdf0e10cSrcweir 			if ( !rtl::math::isFinite( fNumber ) )
892*cdf0e10cSrcweir 				fNumber = 0.0;
893*cdf0e10cSrcweir 		}
894*cdf0e10cSrcweir 		catch ( ... )
895*cdf0e10cSrcweir 		{
896*cdf0e10cSrcweir 			/* sal_Bool bUps = sal_True; */
897*cdf0e10cSrcweir 		}
898*cdf0e10cSrcweir 	}
899*cdf0e10cSrcweir 	return fNumber;
900*cdf0e10cSrcweir }
901*cdf0e10cSrcweir sal_Int32 EnhancedCustomShape2d::GetAdjustValueAsInteger( const sal_Int32 nIndex, const sal_Int32 nDefault ) const
902*cdf0e10cSrcweir {
903*cdf0e10cSrcweir 	sal_Int32 nNumber = nDefault;
904*cdf0e10cSrcweir 	if ( nIndex < seqAdjustmentValues.getLength() )
905*cdf0e10cSrcweir 	{
906*cdf0e10cSrcweir 		if ( seqAdjustmentValues[ nIndex ].Value.getValueTypeClass() == TypeClass_DOUBLE )
907*cdf0e10cSrcweir 		{
908*cdf0e10cSrcweir 			double fNumber = 0;
909*cdf0e10cSrcweir 			seqAdjustmentValues[ nIndex ].Value >>= fNumber;
910*cdf0e10cSrcweir 			nNumber = (sal_Int32)fNumber;
911*cdf0e10cSrcweir 		}
912*cdf0e10cSrcweir 		else
913*cdf0e10cSrcweir 			seqAdjustmentValues[ nIndex ].Value >>= nNumber;
914*cdf0e10cSrcweir 	}
915*cdf0e10cSrcweir 	return nNumber;
916*cdf0e10cSrcweir }
917*cdf0e10cSrcweir sal_Bool EnhancedCustomShape2d::SetAdjustValueAsDouble( const double& rValue, const sal_Int32 nIndex )
918*cdf0e10cSrcweir {
919*cdf0e10cSrcweir 	sal_Bool bRetValue = sal_False;
920*cdf0e10cSrcweir 	if ( nIndex < seqAdjustmentValues.getLength() )
921*cdf0e10cSrcweir 	{
922*cdf0e10cSrcweir 		// updating our local adjustment sequence
923*cdf0e10cSrcweir 		seqAdjustmentValues[ nIndex ].Value <<= rValue;
924*cdf0e10cSrcweir 		seqAdjustmentValues[ nIndex ].State = com::sun::star::beans::PropertyState_DIRECT_VALUE;
925*cdf0e10cSrcweir 		bRetValue = sal_True;
926*cdf0e10cSrcweir 	}
927*cdf0e10cSrcweir 	return bRetValue;
928*cdf0e10cSrcweir }
929*cdf0e10cSrcweir 
930*cdf0e10cSrcweir Point EnhancedCustomShape2d::GetPoint( const com::sun::star::drawing::EnhancedCustomShapeParameterPair& rPair,
931*cdf0e10cSrcweir 										const sal_Bool bScale, const sal_Bool bReplaceGeoSize ) const
932*cdf0e10cSrcweir {
933*cdf0e10cSrcweir 	Point		aRetValue;
934*cdf0e10cSrcweir 	sal_Bool	bExchange = ( nFlags & DFF_CUSTOMSHAPE_EXCH ) != 0;	// x <-> y
935*cdf0e10cSrcweir 	sal_uInt32	nPass = 0;
936*cdf0e10cSrcweir 	do
937*cdf0e10cSrcweir 	{
938*cdf0e10cSrcweir 		sal_uInt32	nIndex = nPass;
939*cdf0e10cSrcweir 
940*cdf0e10cSrcweir 		if ( bExchange )
941*cdf0e10cSrcweir 			nIndex ^= 1;
942*cdf0e10cSrcweir 
943*cdf0e10cSrcweir 		double		fVal;
944*cdf0e10cSrcweir 		const EnhancedCustomShapeParameter& rParameter = nIndex ? rPair.Second : rPair.First;
945*cdf0e10cSrcweir 		if ( nPass )	// height
946*cdf0e10cSrcweir 		{
947*cdf0e10cSrcweir 			GetParameter( fVal, rParameter, sal_False, bReplaceGeoSize );
948*cdf0e10cSrcweir 			fVal -= nCoordTop;
949*cdf0e10cSrcweir 			if ( bScale )
950*cdf0e10cSrcweir 			{
951*cdf0e10cSrcweir 				fVal *= fYScale;
952*cdf0e10cSrcweir 
953*cdf0e10cSrcweir 				if ( nFlags & DFF_CUSTOMSHAPE_FLIP_V )
954*cdf0e10cSrcweir 					fVal = aLogicRect.GetHeight() - fVal;
955*cdf0e10cSrcweir 			}
956*cdf0e10cSrcweir 			aRetValue.Y() = (sal_Int32)fVal;
957*cdf0e10cSrcweir 		}
958*cdf0e10cSrcweir 		else			// width
959*cdf0e10cSrcweir 		{
960*cdf0e10cSrcweir 			GetParameter( fVal, rParameter, bReplaceGeoSize, sal_False );
961*cdf0e10cSrcweir 			fVal -= nCoordLeft;
962*cdf0e10cSrcweir 			if ( bScale )
963*cdf0e10cSrcweir 			{
964*cdf0e10cSrcweir 				fVal *= fXScale;
965*cdf0e10cSrcweir 
966*cdf0e10cSrcweir 				if ( nFlags & DFF_CUSTOMSHAPE_FLIP_H )
967*cdf0e10cSrcweir 					fVal = aLogicRect.GetWidth() - fVal;
968*cdf0e10cSrcweir 			}
969*cdf0e10cSrcweir 			aRetValue.X() = (sal_Int32)fVal;
970*cdf0e10cSrcweir 		}
971*cdf0e10cSrcweir 	}
972*cdf0e10cSrcweir 	while ( ++nPass < 2 );
973*cdf0e10cSrcweir 	return aRetValue;
974*cdf0e10cSrcweir }
975*cdf0e10cSrcweir 
976*cdf0e10cSrcweir sal_Bool EnhancedCustomShape2d::GetParameter( double& rRetValue, const EnhancedCustomShapeParameter& rParameter,
977*cdf0e10cSrcweir 												const sal_Bool bReplaceGeoWidth, const sal_Bool bReplaceGeoHeight ) const
978*cdf0e10cSrcweir {
979*cdf0e10cSrcweir 	rRetValue = 0.0;
980*cdf0e10cSrcweir 	sal_Bool bRetValue = sal_False;
981*cdf0e10cSrcweir 	switch ( rParameter.Type )
982*cdf0e10cSrcweir 	{
983*cdf0e10cSrcweir 		case EnhancedCustomShapeParameterType::ADJUSTMENT :
984*cdf0e10cSrcweir 		{
985*cdf0e10cSrcweir 			sal_Int32 nAdjustmentIndex = 0;
986*cdf0e10cSrcweir 			if ( rParameter.Value >>= nAdjustmentIndex )
987*cdf0e10cSrcweir 			{
988*cdf0e10cSrcweir 				rRetValue = GetAdjustValueAsDouble( nAdjustmentIndex );
989*cdf0e10cSrcweir 				bRetValue = sal_True;
990*cdf0e10cSrcweir 			}
991*cdf0e10cSrcweir 		}
992*cdf0e10cSrcweir 		break;
993*cdf0e10cSrcweir 		case EnhancedCustomShapeParameterType::EQUATION :
994*cdf0e10cSrcweir 		{
995*cdf0e10cSrcweir 			sal_Int32 nEquationIndex = 0;
996*cdf0e10cSrcweir 			if ( rParameter.Value >>= nEquationIndex )
997*cdf0e10cSrcweir 			{
998*cdf0e10cSrcweir 				rRetValue = GetEquationValueAsDouble( nEquationIndex );
999*cdf0e10cSrcweir 				bRetValue = sal_True;
1000*cdf0e10cSrcweir 			}
1001*cdf0e10cSrcweir 		}
1002*cdf0e10cSrcweir 		break;
1003*cdf0e10cSrcweir 		case EnhancedCustomShapeParameterType::NORMAL :
1004*cdf0e10cSrcweir 		{
1005*cdf0e10cSrcweir 			if ( rParameter.Value.getValueTypeClass() == TypeClass_DOUBLE )
1006*cdf0e10cSrcweir 			{
1007*cdf0e10cSrcweir 				double fValue;
1008*cdf0e10cSrcweir 				if ( rParameter.Value >>= fValue )
1009*cdf0e10cSrcweir 				{
1010*cdf0e10cSrcweir 					rRetValue = fValue;
1011*cdf0e10cSrcweir 					bRetValue = sal_True;
1012*cdf0e10cSrcweir 				}
1013*cdf0e10cSrcweir 			}
1014*cdf0e10cSrcweir 			else
1015*cdf0e10cSrcweir 			{
1016*cdf0e10cSrcweir 				sal_Int32 nValue = 0;
1017*cdf0e10cSrcweir 				if ( rParameter.Value >>= nValue )
1018*cdf0e10cSrcweir 				{
1019*cdf0e10cSrcweir 					rRetValue = nValue;
1020*cdf0e10cSrcweir 					bRetValue = sal_True;
1021*cdf0e10cSrcweir 					if ( bReplaceGeoWidth && ( nValue == nCoordWidth ) )
1022*cdf0e10cSrcweir 						rRetValue *= fXRatio;
1023*cdf0e10cSrcweir 					else if ( bReplaceGeoHeight && ( nValue == nCoordHeight ) )
1024*cdf0e10cSrcweir 						rRetValue *= fYRatio;
1025*cdf0e10cSrcweir 				}
1026*cdf0e10cSrcweir 			}
1027*cdf0e10cSrcweir 		}
1028*cdf0e10cSrcweir 		break;
1029*cdf0e10cSrcweir 		case EnhancedCustomShapeParameterType::LEFT :
1030*cdf0e10cSrcweir 		{
1031*cdf0e10cSrcweir 			rRetValue  = 0.0;
1032*cdf0e10cSrcweir 			bRetValue = sal_True;
1033*cdf0e10cSrcweir 		}
1034*cdf0e10cSrcweir 		break;
1035*cdf0e10cSrcweir 		case EnhancedCustomShapeParameterType::TOP :
1036*cdf0e10cSrcweir 		{
1037*cdf0e10cSrcweir 			rRetValue  = 0.0;
1038*cdf0e10cSrcweir 			bRetValue = sal_True;
1039*cdf0e10cSrcweir 		}
1040*cdf0e10cSrcweir 		break;
1041*cdf0e10cSrcweir 		case EnhancedCustomShapeParameterType::RIGHT :
1042*cdf0e10cSrcweir 		{
1043*cdf0e10cSrcweir 			rRetValue = nCoordWidth;
1044*cdf0e10cSrcweir 			bRetValue = sal_True;
1045*cdf0e10cSrcweir 		}
1046*cdf0e10cSrcweir 		break;
1047*cdf0e10cSrcweir 		case EnhancedCustomShapeParameterType::BOTTOM :
1048*cdf0e10cSrcweir 		{
1049*cdf0e10cSrcweir 			rRetValue = nCoordHeight;
1050*cdf0e10cSrcweir 			bRetValue = sal_True;
1051*cdf0e10cSrcweir 		}
1052*cdf0e10cSrcweir 		break;
1053*cdf0e10cSrcweir 	}
1054*cdf0e10cSrcweir 	return bRetValue;
1055*cdf0e10cSrcweir }
1056*cdf0e10cSrcweir 
1057*cdf0e10cSrcweir // nLumDat 28-31 = number of luminance entries in nLumDat
1058*cdf0e10cSrcweir // nLumDat 27-24 = nLumDatEntry 0
1059*cdf0e10cSrcweir // nLumDat 23-20 = nLumDatEntry 1 ...
1060*cdf0e10cSrcweir // each 4bit entry is to be interpreted as a 10 percent signed luminance changing
1061*cdf0e10cSrcweir sal_Int32 EnhancedCustomShape2d::GetLuminanceChange( sal_uInt32 nIndex ) const
1062*cdf0e10cSrcweir {
1063*cdf0e10cSrcweir 	const sal_uInt32 nCount = nColorData >> 28;
1064*cdf0e10cSrcweir 	if ( !nCount )
1065*cdf0e10cSrcweir         return 0;
1066*cdf0e10cSrcweir 
1067*cdf0e10cSrcweir     if ( nIndex >= nCount )
1068*cdf0e10cSrcweir         nIndex = nCount - 1;
1069*cdf0e10cSrcweir 
1070*cdf0e10cSrcweir     const sal_Int32 nLumDat = nColorData << ( ( 1 + nIndex ) << 2 );
1071*cdf0e10cSrcweir     return ( nLumDat >> 28 ) * 10;
1072*cdf0e10cSrcweir }
1073*cdf0e10cSrcweir 
1074*cdf0e10cSrcweir Color EnhancedCustomShape2d::GetColorData( const Color& rFillColor, sal_uInt32 nIndex ) const
1075*cdf0e10cSrcweir {
1076*cdf0e10cSrcweir     const sal_Int32 nLuminance = GetLuminanceChange(nIndex);
1077*cdf0e10cSrcweir     if( !nLuminance )
1078*cdf0e10cSrcweir         return rFillColor;
1079*cdf0e10cSrcweir 
1080*cdf0e10cSrcweir     basegfx::BColor aHSVColor=
1081*cdf0e10cSrcweir         basegfx::tools::rgb2hsv(
1082*cdf0e10cSrcweir             basegfx::BColor(rFillColor.GetRed()/255.0,
1083*cdf0e10cSrcweir                             rFillColor.GetGreen()/255.0,
1084*cdf0e10cSrcweir                             rFillColor.GetBlue()/255.0));
1085*cdf0e10cSrcweir     if( nLuminance > 0 )
1086*cdf0e10cSrcweir     {
1087*cdf0e10cSrcweir         aHSVColor.setGreen(
1088*cdf0e10cSrcweir             aHSVColor.getGreen() * (1.0-nLuminance/100.0));
1089*cdf0e10cSrcweir         aHSVColor.setBlue(
1090*cdf0e10cSrcweir             nLuminance/100.0 +
1091*cdf0e10cSrcweir             (1.0-nLuminance/100.0)*aHSVColor.getBlue());
1092*cdf0e10cSrcweir     }
1093*cdf0e10cSrcweir     else if( nLuminance < 0 )
1094*cdf0e10cSrcweir     {
1095*cdf0e10cSrcweir         aHSVColor.setBlue(
1096*cdf0e10cSrcweir             (1.0+nLuminance/100.0)*aHSVColor.getBlue());
1097*cdf0e10cSrcweir     }
1098*cdf0e10cSrcweir 
1099*cdf0e10cSrcweir     aHSVColor = basegfx::tools::hsv2rgb(aHSVColor);
1100*cdf0e10cSrcweir     return Color( (sal_uInt8)static_cast< sal_Int32 >( basegfx::clamp(aHSVColor.getRed(),0.0,1.0) * 255.0 + 0.5 ),
1101*cdf0e10cSrcweir                   (sal_uInt8)static_cast< sal_Int32 >( basegfx::clamp(aHSVColor.getGreen(),0.0,1.0) * 255.0 + 0.5 ),
1102*cdf0e10cSrcweir                   (sal_uInt8)static_cast< sal_Int32 >( basegfx::clamp(aHSVColor.getBlue(),0.0,1.0) * 255.0 + 0.5 ) );
1103*cdf0e10cSrcweir }
1104*cdf0e10cSrcweir 
1105*cdf0e10cSrcweir Rectangle EnhancedCustomShape2d::GetTextRect() const
1106*cdf0e10cSrcweir {
1107*cdf0e10cSrcweir 	sal_Int32 nIndex, nSize = seqTextFrames.getLength();
1108*cdf0e10cSrcweir 	if ( !nSize )
1109*cdf0e10cSrcweir 		return aLogicRect;
1110*cdf0e10cSrcweir 	nIndex = 0;
1111*cdf0e10cSrcweir 	if ( bTextFlow && ( nSize > 1 ) )
1112*cdf0e10cSrcweir 		nIndex++;
1113*cdf0e10cSrcweir 	Point aTopLeft( GetPoint( seqTextFrames[ nIndex ].TopLeft, sal_True, sal_True ) );
1114*cdf0e10cSrcweir 	Point aBottomRight( GetPoint( seqTextFrames[ nIndex ].BottomRight, sal_True, sal_True ) );
1115*cdf0e10cSrcweir 	if ( bFlipH )
1116*cdf0e10cSrcweir 	{
1117*cdf0e10cSrcweir 		aTopLeft.X() = aLogicRect.GetWidth() - aTopLeft.X();
1118*cdf0e10cSrcweir 		aBottomRight.X() = aLogicRect.GetWidth() - aBottomRight.X();
1119*cdf0e10cSrcweir 	}
1120*cdf0e10cSrcweir 	if ( bFlipV )
1121*cdf0e10cSrcweir 	{
1122*cdf0e10cSrcweir 		aTopLeft.Y() = aLogicRect.GetHeight() - aTopLeft.Y();
1123*cdf0e10cSrcweir 		aBottomRight.Y() = aLogicRect.GetHeight() - aBottomRight.Y();
1124*cdf0e10cSrcweir 	}
1125*cdf0e10cSrcweir 	Rectangle aRect( aTopLeft, aBottomRight );
1126*cdf0e10cSrcweir 	aRect.Move( aLogicRect.Left(), aLogicRect.Top() );
1127*cdf0e10cSrcweir 	aRect.Justify();
1128*cdf0e10cSrcweir 	return aRect;
1129*cdf0e10cSrcweir }
1130*cdf0e10cSrcweir 
1131*cdf0e10cSrcweir sal_uInt32 EnhancedCustomShape2d::GetHdlCount() const
1132*cdf0e10cSrcweir {
1133*cdf0e10cSrcweir 	return seqHandles.getLength();
1134*cdf0e10cSrcweir }
1135*cdf0e10cSrcweir 
1136*cdf0e10cSrcweir sal_Bool EnhancedCustomShape2d::GetHandlePosition( const sal_uInt32 nIndex, Point& rReturnPosition ) const
1137*cdf0e10cSrcweir {
1138*cdf0e10cSrcweir 	sal_Bool bRetValue = sal_False;
1139*cdf0e10cSrcweir 	if ( nIndex < GetHdlCount() )
1140*cdf0e10cSrcweir 	{
1141*cdf0e10cSrcweir 		Handle aHandle;
1142*cdf0e10cSrcweir 		if ( ConvertSequenceToEnhancedCustomShape2dHandle( seqHandles[ nIndex ], aHandle ) )
1143*cdf0e10cSrcweir 		{
1144*cdf0e10cSrcweir 			if ( aHandle.nFlags & HANDLE_FLAGS_POLAR )
1145*cdf0e10cSrcweir 			{
1146*cdf0e10cSrcweir 				Point aReferencePoint( GetPoint( aHandle.aPolar, sal_True, sal_False ) );
1147*cdf0e10cSrcweir 
1148*cdf0e10cSrcweir 				double		fAngle;
1149*cdf0e10cSrcweir 				double		fRadius;
1150*cdf0e10cSrcweir 				GetParameter( fRadius, aHandle.aPosition.First, sal_False, sal_False );
1151*cdf0e10cSrcweir 				GetParameter( fAngle,  aHandle.aPosition.Second, sal_False, sal_False );
1152*cdf0e10cSrcweir 
1153*cdf0e10cSrcweir 				double a = ( 360.0 - fAngle ) * F_PI180;
1154*cdf0e10cSrcweir 				double dx = fRadius * fXScale;
1155*cdf0e10cSrcweir 				double fX = dx * cos( a );
1156*cdf0e10cSrcweir 				double fY =-dx * sin( a );
1157*cdf0e10cSrcweir 				rReturnPosition =
1158*cdf0e10cSrcweir                     Point(
1159*cdf0e10cSrcweir                         Round( fX + aReferencePoint.X() ),
1160*cdf0e10cSrcweir                         basegfx::fTools::equalZero(fXScale) ? aReferencePoint.Y() :
1161*cdf0e10cSrcweir                         Round( ( fY * fYScale ) / fXScale + aReferencePoint.Y() ) );
1162*cdf0e10cSrcweir 			}
1163*cdf0e10cSrcweir 			else
1164*cdf0e10cSrcweir 			{
1165*cdf0e10cSrcweir 				if ( aHandle.nFlags & HANDLE_FLAGS_SWITCHED )
1166*cdf0e10cSrcweir 				{
1167*cdf0e10cSrcweir 					if ( aLogicRect.GetHeight() > aLogicRect.GetWidth() )
1168*cdf0e10cSrcweir 					{
1169*cdf0e10cSrcweir 						com::sun::star::drawing::EnhancedCustomShapeParameter aFirst = aHandle.aPosition.First;
1170*cdf0e10cSrcweir 						com::sun::star::drawing::EnhancedCustomShapeParameter aSecond = aHandle.aPosition.Second;
1171*cdf0e10cSrcweir 						aHandle.aPosition.First = aSecond;
1172*cdf0e10cSrcweir 						aHandle.aPosition.Second = aFirst;
1173*cdf0e10cSrcweir 					}
1174*cdf0e10cSrcweir 				}
1175*cdf0e10cSrcweir 				rReturnPosition = GetPoint( aHandle.aPosition, sal_True, sal_False );
1176*cdf0e10cSrcweir 			}
1177*cdf0e10cSrcweir 			const GeoStat aGeoStat( ((SdrObjCustomShape*)pCustomShapeObj)->GetGeoStat() );
1178*cdf0e10cSrcweir 			if ( aGeoStat.nShearWink )
1179*cdf0e10cSrcweir 			{
1180*cdf0e10cSrcweir 				double nTan = aGeoStat.nTan;
1181*cdf0e10cSrcweir 				if ((bFlipV&&!bFlipH )||(bFlipH&&!bFlipV))
1182*cdf0e10cSrcweir 					nTan = -nTan;
1183*cdf0e10cSrcweir 				ShearPoint( rReturnPosition, Point( aLogicRect.GetWidth() / 2, aLogicRect.GetHeight() / 2 ), nTan );
1184*cdf0e10cSrcweir 			}
1185*cdf0e10cSrcweir 			if ( nRotateAngle )
1186*cdf0e10cSrcweir 			{
1187*cdf0e10cSrcweir 				double a = nRotateAngle * F_PI18000;
1188*cdf0e10cSrcweir 				RotatePoint( rReturnPosition, Point( aLogicRect.GetWidth() / 2, aLogicRect.GetHeight() / 2 ), sin( a ), cos( a ) );
1189*cdf0e10cSrcweir 			}
1190*cdf0e10cSrcweir 			if ( bFlipH )
1191*cdf0e10cSrcweir 				rReturnPosition.X() = aLogicRect.GetWidth() - rReturnPosition.X();
1192*cdf0e10cSrcweir 			if ( bFlipV )
1193*cdf0e10cSrcweir 				rReturnPosition.Y() = aLogicRect.GetHeight() - rReturnPosition.Y();
1194*cdf0e10cSrcweir 			rReturnPosition.Move( aLogicRect.Left(), aLogicRect.Top() );
1195*cdf0e10cSrcweir 			bRetValue = sal_True;
1196*cdf0e10cSrcweir 		}
1197*cdf0e10cSrcweir 	}
1198*cdf0e10cSrcweir 	return bRetValue;
1199*cdf0e10cSrcweir }
1200*cdf0e10cSrcweir 
1201*cdf0e10cSrcweir sal_Bool EnhancedCustomShape2d::SetHandleControllerPosition( const sal_uInt32 nIndex, const com::sun::star::awt::Point& rPosition )
1202*cdf0e10cSrcweir {
1203*cdf0e10cSrcweir 	sal_Bool bRetValue = sal_False;
1204*cdf0e10cSrcweir 	if ( nIndex < GetHdlCount() )
1205*cdf0e10cSrcweir 	{
1206*cdf0e10cSrcweir 		Handle aHandle;
1207*cdf0e10cSrcweir 		if ( ConvertSequenceToEnhancedCustomShape2dHandle( seqHandles[ nIndex ], aHandle ) )
1208*cdf0e10cSrcweir 		{
1209*cdf0e10cSrcweir 			Point aP( rPosition.X, rPosition.Y );
1210*cdf0e10cSrcweir 			// apply the negative object rotation to the controller position
1211*cdf0e10cSrcweir 
1212*cdf0e10cSrcweir 			aP.Move( -aLogicRect.Left(), -aLogicRect.Top() );
1213*cdf0e10cSrcweir 			if ( bFlipH )
1214*cdf0e10cSrcweir 				aP.X() = aLogicRect.GetWidth() - aP.X();
1215*cdf0e10cSrcweir 			if ( bFlipV )
1216*cdf0e10cSrcweir 				aP.Y() = aLogicRect.GetHeight() - aP.Y();
1217*cdf0e10cSrcweir 			if ( nRotateAngle )
1218*cdf0e10cSrcweir 			{
1219*cdf0e10cSrcweir 				double a = -nRotateAngle * F_PI18000;
1220*cdf0e10cSrcweir 				RotatePoint( aP, Point( aLogicRect.GetWidth() / 2, aLogicRect.GetHeight() / 2 ), sin( a ), cos( a ) );
1221*cdf0e10cSrcweir 			}
1222*cdf0e10cSrcweir 			const GeoStat aGeoStat( ((SdrObjCustomShape*)pCustomShapeObj)->GetGeoStat() );
1223*cdf0e10cSrcweir 			if ( aGeoStat.nShearWink )
1224*cdf0e10cSrcweir 			{
1225*cdf0e10cSrcweir 				double nTan = -aGeoStat.nTan;
1226*cdf0e10cSrcweir 				if ((bFlipV&&!bFlipH )||(bFlipH&&!bFlipV))
1227*cdf0e10cSrcweir 					nTan = -nTan;
1228*cdf0e10cSrcweir 				ShearPoint( aP, Point( aLogicRect.GetWidth() / 2, aLogicRect.GetHeight() / 2 ), nTan );
1229*cdf0e10cSrcweir 			}
1230*cdf0e10cSrcweir 
1231*cdf0e10cSrcweir 			double fPos1 = aP.X();	//( bFlipH ) ? aLogicRect.GetWidth() - aP.X() : aP.X();
1232*cdf0e10cSrcweir 			double fPos2 = aP.Y();	//( bFlipV ) ? aLogicRect.GetHeight() -aP.Y() : aP.Y();
1233*cdf0e10cSrcweir 			fPos1 /= fXScale;
1234*cdf0e10cSrcweir 			fPos2 /= fYScale;
1235*cdf0e10cSrcweir 
1236*cdf0e10cSrcweir 			if ( aHandle.nFlags & HANDLE_FLAGS_SWITCHED )
1237*cdf0e10cSrcweir 			{
1238*cdf0e10cSrcweir 				if ( aLogicRect.GetHeight() > aLogicRect.GetWidth() )
1239*cdf0e10cSrcweir 				{
1240*cdf0e10cSrcweir 					double fX = fPos1;
1241*cdf0e10cSrcweir 					double fY = fPos2;
1242*cdf0e10cSrcweir 					fPos1 = fY;
1243*cdf0e10cSrcweir 					fPos2 = fX;
1244*cdf0e10cSrcweir 				}
1245*cdf0e10cSrcweir 			}
1246*cdf0e10cSrcweir 
1247*cdf0e10cSrcweir 			sal_Int32 nFirstAdjustmentValue = -1, nSecondAdjustmentValue = -1;
1248*cdf0e10cSrcweir 
1249*cdf0e10cSrcweir 			if ( aHandle.aPosition.First.Type == EnhancedCustomShapeParameterType::ADJUSTMENT )
1250*cdf0e10cSrcweir 				aHandle.aPosition.First.Value >>= nFirstAdjustmentValue;
1251*cdf0e10cSrcweir 			if ( aHandle.aPosition.Second.Type == EnhancedCustomShapeParameterType::ADJUSTMENT )
1252*cdf0e10cSrcweir 				aHandle.aPosition.Second.Value>>= nSecondAdjustmentValue;
1253*cdf0e10cSrcweir 
1254*cdf0e10cSrcweir 			if ( aHandle.nFlags & HANDLE_FLAGS_POLAR )
1255*cdf0e10cSrcweir 			{
1256*cdf0e10cSrcweir 				double fXRef, fYRef, fAngle;
1257*cdf0e10cSrcweir 				GetParameter( fXRef, aHandle.aPolar.First, sal_False, sal_False );
1258*cdf0e10cSrcweir 				GetParameter( fYRef, aHandle.aPolar.Second, sal_False, sal_False );
1259*cdf0e10cSrcweir 				const double fDX = fPos1 - fXRef;
1260*cdf0e10cSrcweir 				fAngle = -( atan2( -fPos2 + fYRef, ( ( fDX == 0.0L ) ? 0.000000001 : fDX ) ) / F_PI180 );
1261*cdf0e10cSrcweir 				double fX = ( fPos1 - fXRef );
1262*cdf0e10cSrcweir 				double fY = ( fPos2 - fYRef );
1263*cdf0e10cSrcweir 				double fRadius = sqrt( fX * fX + fY * fY );
1264*cdf0e10cSrcweir 				if ( aHandle.nFlags & HANDLE_FLAGS_RADIUS_RANGE_MINIMUM )
1265*cdf0e10cSrcweir 				{
1266*cdf0e10cSrcweir 					double fMin;
1267*cdf0e10cSrcweir 					GetParameter( fMin,  aHandle.aRadiusRangeMinimum, sal_False, sal_False );
1268*cdf0e10cSrcweir 					if ( fRadius < fMin )
1269*cdf0e10cSrcweir 						fRadius = fMin;
1270*cdf0e10cSrcweir 				}
1271*cdf0e10cSrcweir 				if ( aHandle.nFlags & HANDLE_FLAGS_RADIUS_RANGE_MAXIMUM )
1272*cdf0e10cSrcweir 				{
1273*cdf0e10cSrcweir 					double fMax;
1274*cdf0e10cSrcweir 					GetParameter( fMax, aHandle.aRadiusRangeMaximum, sal_False, sal_False );
1275*cdf0e10cSrcweir 					if ( fRadius > fMax )
1276*cdf0e10cSrcweir 						fRadius = fMax;
1277*cdf0e10cSrcweir 				}
1278*cdf0e10cSrcweir 				if ( nFirstAdjustmentValue >= 0 )
1279*cdf0e10cSrcweir 					SetAdjustValueAsDouble( fRadius, nFirstAdjustmentValue );
1280*cdf0e10cSrcweir 				if ( nSecondAdjustmentValue >= 0 )
1281*cdf0e10cSrcweir 					SetAdjustValueAsDouble( fAngle,  nSecondAdjustmentValue );
1282*cdf0e10cSrcweir 			}
1283*cdf0e10cSrcweir 			else
1284*cdf0e10cSrcweir 			{
1285*cdf0e10cSrcweir 				if ( aHandle.nFlags & HANDLE_FLAGS_REFX )
1286*cdf0e10cSrcweir 				{
1287*cdf0e10cSrcweir 					nFirstAdjustmentValue = aHandle.nRefX;
1288*cdf0e10cSrcweir 					fPos1 *= 100000.0;
1289*cdf0e10cSrcweir 					fPos1 /= nCoordWidth;
1290*cdf0e10cSrcweir 				}
1291*cdf0e10cSrcweir 				if ( aHandle.nFlags & HANDLE_FLAGS_REFY )
1292*cdf0e10cSrcweir 				{
1293*cdf0e10cSrcweir 					nSecondAdjustmentValue = aHandle.nRefY;
1294*cdf0e10cSrcweir 					fPos2 *= 100000.0;
1295*cdf0e10cSrcweir 					fPos2 /= nCoordHeight;
1296*cdf0e10cSrcweir 				}
1297*cdf0e10cSrcweir 				if ( nFirstAdjustmentValue >= 0 )
1298*cdf0e10cSrcweir 				{
1299*cdf0e10cSrcweir 					if ( aHandle.nFlags & HANDLE_FLAGS_RANGE_X_MINIMUM )		// check if horizontal handle needs to be within a range
1300*cdf0e10cSrcweir 					{
1301*cdf0e10cSrcweir 						double fXMin;
1302*cdf0e10cSrcweir 						GetParameter( fXMin, aHandle.aXRangeMinimum, sal_False, sal_False );
1303*cdf0e10cSrcweir 						if ( fPos1 < fXMin )
1304*cdf0e10cSrcweir 							fPos1 = fXMin;
1305*cdf0e10cSrcweir 					}
1306*cdf0e10cSrcweir 					if ( aHandle.nFlags & HANDLE_FLAGS_RANGE_X_MAXIMUM )		// check if horizontal handle needs to be within a range
1307*cdf0e10cSrcweir 					{
1308*cdf0e10cSrcweir 						double fXMax;
1309*cdf0e10cSrcweir 						GetParameter( fXMax, aHandle.aXRangeMaximum, sal_False, sal_False );
1310*cdf0e10cSrcweir 						if ( fPos1 > fXMax )
1311*cdf0e10cSrcweir 							fPos1 = fXMax;
1312*cdf0e10cSrcweir 					}
1313*cdf0e10cSrcweir 					SetAdjustValueAsDouble( fPos1, nFirstAdjustmentValue );
1314*cdf0e10cSrcweir 				}
1315*cdf0e10cSrcweir 				if ( nSecondAdjustmentValue >= 0 )
1316*cdf0e10cSrcweir 				{
1317*cdf0e10cSrcweir 					if ( aHandle.nFlags & HANDLE_FLAGS_RANGE_Y_MINIMUM )		// check if vertical handle needs to be within a range
1318*cdf0e10cSrcweir 					{
1319*cdf0e10cSrcweir 						double fYMin;
1320*cdf0e10cSrcweir 						GetParameter( fYMin, aHandle.aYRangeMinimum, sal_False, sal_False );
1321*cdf0e10cSrcweir 						if ( fPos2 < fYMin )
1322*cdf0e10cSrcweir 							fPos2 = fYMin;
1323*cdf0e10cSrcweir 					}
1324*cdf0e10cSrcweir 					if ( aHandle.nFlags & HANDLE_FLAGS_RANGE_Y_MAXIMUM )		// check if vertical handle needs to be within a range
1325*cdf0e10cSrcweir 					{
1326*cdf0e10cSrcweir 						double fYMax;
1327*cdf0e10cSrcweir 						GetParameter( fYMax, aHandle.aYRangeMaximum, sal_False, sal_False );
1328*cdf0e10cSrcweir 						if ( fPos2 > fYMax )
1329*cdf0e10cSrcweir 							fPos2 = fYMax;
1330*cdf0e10cSrcweir 					}
1331*cdf0e10cSrcweir 					SetAdjustValueAsDouble( fPos2, nSecondAdjustmentValue );
1332*cdf0e10cSrcweir 				}
1333*cdf0e10cSrcweir 			}
1334*cdf0e10cSrcweir 			// and writing them back into the GeometryItem
1335*cdf0e10cSrcweir 			SdrCustomShapeGeometryItem aGeometryItem((SdrCustomShapeGeometryItem&)
1336*cdf0e10cSrcweir 				(const SdrCustomShapeGeometryItem&)pCustomShapeObj->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ));
1337*cdf0e10cSrcweir 			const rtl::OUString	sAdjustmentValues( RTL_CONSTASCII_USTRINGPARAM ( "AdjustmentValues" ) );
1338*cdf0e10cSrcweir 			com::sun::star::beans::PropertyValue aPropVal;
1339*cdf0e10cSrcweir 			aPropVal.Name = sAdjustmentValues;
1340*cdf0e10cSrcweir 			aPropVal.Value <<= seqAdjustmentValues;
1341*cdf0e10cSrcweir 			aGeometryItem.SetPropertyValue( aPropVal );
1342*cdf0e10cSrcweir 			pCustomShapeObj->SetMergedItem( aGeometryItem );
1343*cdf0e10cSrcweir 			bRetValue = sal_True;
1344*cdf0e10cSrcweir 		}
1345*cdf0e10cSrcweir 	}
1346*cdf0e10cSrcweir 	return bRetValue;
1347*cdf0e10cSrcweir }
1348*cdf0e10cSrcweir 
1349*cdf0e10cSrcweir void EnhancedCustomShape2d::SwapStartAndEndArrow( SdrObject* pObj )	//#108274
1350*cdf0e10cSrcweir {
1351*cdf0e10cSrcweir 	XLineStartItem		 aLineStart;
1352*cdf0e10cSrcweir 	aLineStart.SetLineStartValue(((XLineStartItem&)pObj->GetMergedItem( XATTR_LINEEND )).GetLineStartValue());
1353*cdf0e10cSrcweir 	XLineStartWidthItem  aLineStartWidth(((XLineStartWidthItem&)pObj->GetMergedItem( XATTR_LINEENDWIDTH )).GetValue());
1354*cdf0e10cSrcweir 	XLineStartCenterItem aLineStartCenter(((XLineStartCenterItem&)pObj->GetMergedItem( XATTR_LINEENDCENTER )).GetValue());
1355*cdf0e10cSrcweir 
1356*cdf0e10cSrcweir 	XLineEndItem		 aLineEnd;
1357*cdf0e10cSrcweir 	aLineEnd.SetLineEndValue(((XLineEndItem&)pObj->GetMergedItem( XATTR_LINESTART )).GetLineEndValue());
1358*cdf0e10cSrcweir 	XLineEndWidthItem    aLineEndWidth(((XLineEndWidthItem&)pObj->GetMergedItem( XATTR_LINESTARTWIDTH )).GetValue());
1359*cdf0e10cSrcweir 	XLineEndCenterItem   aLineEndCenter(((XLineEndCenterItem&)pObj->GetMergedItem( XATTR_LINESTARTCENTER )).GetValue());
1360*cdf0e10cSrcweir 
1361*cdf0e10cSrcweir 	pObj->SetMergedItem( aLineStart );
1362*cdf0e10cSrcweir 	pObj->SetMergedItem( aLineStartWidth );
1363*cdf0e10cSrcweir 	pObj->SetMergedItem( aLineStartCenter );
1364*cdf0e10cSrcweir 	pObj->SetMergedItem( aLineEnd );
1365*cdf0e10cSrcweir 	pObj->SetMergedItem( aLineEndWidth );
1366*cdf0e10cSrcweir 	pObj->SetMergedItem( aLineEndCenter );
1367*cdf0e10cSrcweir }
1368*cdf0e10cSrcweir 
1369*cdf0e10cSrcweir basegfx::B2DPolygon CreateArc( const Rectangle& rRect, const Point& rStart, const Point& rEnd, const sal_Bool bClockwise )
1370*cdf0e10cSrcweir {
1371*cdf0e10cSrcweir 	Rectangle aRect( rRect );
1372*cdf0e10cSrcweir 	Point aStart( rStart );
1373*cdf0e10cSrcweir 	Point aEnd( rEnd );
1374*cdf0e10cSrcweir 
1375*cdf0e10cSrcweir 	sal_Int32 bSwapStartEndAngle = 0;
1376*cdf0e10cSrcweir 
1377*cdf0e10cSrcweir 	if ( aRect.Left() > aRect.Right() )
1378*cdf0e10cSrcweir 		bSwapStartEndAngle ^= 0x01;
1379*cdf0e10cSrcweir 	if ( aRect.Top() > aRect.Bottom() )
1380*cdf0e10cSrcweir 		bSwapStartEndAngle ^= 0x11;
1381*cdf0e10cSrcweir 	if ( bSwapStartEndAngle )
1382*cdf0e10cSrcweir 	{
1383*cdf0e10cSrcweir 		aRect.Justify();
1384*cdf0e10cSrcweir 		if ( bSwapStartEndAngle & 1 )
1385*cdf0e10cSrcweir 		{
1386*cdf0e10cSrcweir 			Point aTmp( aStart );
1387*cdf0e10cSrcweir 			aStart = aEnd;
1388*cdf0e10cSrcweir 			aEnd = aTmp;
1389*cdf0e10cSrcweir 		}
1390*cdf0e10cSrcweir 	}
1391*cdf0e10cSrcweir 
1392*cdf0e10cSrcweir 	Polygon aTempPoly( aRect, aStart, aEnd, POLY_ARC );
1393*cdf0e10cSrcweir 	basegfx::B2DPolygon aRetval;
1394*cdf0e10cSrcweir 
1395*cdf0e10cSrcweir 	if ( bClockwise )
1396*cdf0e10cSrcweir 	{
1397*cdf0e10cSrcweir 		for ( sal_uInt16 j = aTempPoly.GetSize(); j--; )
1398*cdf0e10cSrcweir 		{
1399*cdf0e10cSrcweir 			aRetval.append(basegfx::B2DPoint(aTempPoly[ j ].X(), aTempPoly[ j ].Y()));
1400*cdf0e10cSrcweir 		}
1401*cdf0e10cSrcweir 	}
1402*cdf0e10cSrcweir 	else
1403*cdf0e10cSrcweir 	{
1404*cdf0e10cSrcweir 		for ( sal_uInt16 j = 0; j < aTempPoly.GetSize(); j++ )
1405*cdf0e10cSrcweir 		{
1406*cdf0e10cSrcweir 			aRetval.append(basegfx::B2DPoint(aTempPoly[ j ].X(), aTempPoly[ j ].Y()));
1407*cdf0e10cSrcweir 		}
1408*cdf0e10cSrcweir 	}
1409*cdf0e10cSrcweir 
1410*cdf0e10cSrcweir 	return aRetval;
1411*cdf0e10cSrcweir }
1412*cdf0e10cSrcweir 
1413*cdf0e10cSrcweir void EnhancedCustomShape2d::CreateSubPath( sal_uInt16& rSrcPt, sal_uInt16& rSegmentInd, std::vector< SdrPathObj* >& rObjectList,
1414*cdf0e10cSrcweir 																						const sal_Bool bLineGeometryNeededOnly,
1415*cdf0e10cSrcweir 																						const sal_Bool bSortFilledObjectsToBack )
1416*cdf0e10cSrcweir {
1417*cdf0e10cSrcweir 	sal_Bool bNoFill = sal_False;
1418*cdf0e10cSrcweir 	sal_Bool bNoStroke = sal_False;
1419*cdf0e10cSrcweir 
1420*cdf0e10cSrcweir 	basegfx::B2DPolyPolygon aNewB2DPolyPolygon;
1421*cdf0e10cSrcweir 	basegfx::B2DPolygon aNewB2DPolygon;
1422*cdf0e10cSrcweir 
1423*cdf0e10cSrcweir 	sal_Int32 nCoordSize = seqCoordinates.getLength();
1424*cdf0e10cSrcweir 	sal_Int32 nSegInfoSize = seqSegments.getLength();
1425*cdf0e10cSrcweir 	if ( !nSegInfoSize )
1426*cdf0e10cSrcweir 	{
1427*cdf0e10cSrcweir 		const EnhancedCustomShapeParameterPair* pTmp = seqCoordinates.getArray();
1428*cdf0e10cSrcweir 
1429*cdf0e10cSrcweir 		for ( sal_Int32 nPtNum(0L); nPtNum < nCoordSize; nPtNum++ )
1430*cdf0e10cSrcweir 		{
1431*cdf0e10cSrcweir 			const Point aTempPoint(GetPoint( *pTmp++, sal_True, sal_True ));
1432*cdf0e10cSrcweir 			aNewB2DPolygon.append(basegfx::B2DPoint(aTempPoint.X(), aTempPoint.Y()));
1433*cdf0e10cSrcweir 		}
1434*cdf0e10cSrcweir 
1435*cdf0e10cSrcweir 		aNewB2DPolygon.setClosed(true);
1436*cdf0e10cSrcweir 	}
1437*cdf0e10cSrcweir 	else
1438*cdf0e10cSrcweir 	{
1439*cdf0e10cSrcweir 		for ( ;rSegmentInd < nSegInfoSize; )
1440*cdf0e10cSrcweir 		{
1441*cdf0e10cSrcweir 			sal_Int16 nCommand = seqSegments[ rSegmentInd ].Command;
1442*cdf0e10cSrcweir 			sal_Int16 nPntCount= seqSegments[ rSegmentInd++ ].Count;
1443*cdf0e10cSrcweir 
1444*cdf0e10cSrcweir 			switch ( nCommand )
1445*cdf0e10cSrcweir 			{
1446*cdf0e10cSrcweir 				case NOFILL :
1447*cdf0e10cSrcweir 					bNoFill = sal_True;
1448*cdf0e10cSrcweir 				break;
1449*cdf0e10cSrcweir 				case NOSTROKE :
1450*cdf0e10cSrcweir 					bNoStroke = sal_True;
1451*cdf0e10cSrcweir 				break;
1452*cdf0e10cSrcweir 				case MOVETO :
1453*cdf0e10cSrcweir 				{
1454*cdf0e10cSrcweir 					if(aNewB2DPolygon.count() > 1L)
1455*cdf0e10cSrcweir 					{
1456*cdf0e10cSrcweir 						// #i76201# Add conversion to closed polygon when first and last points are equal
1457*cdf0e10cSrcweir 						basegfx::tools::checkClosed(aNewB2DPolygon);
1458*cdf0e10cSrcweir 						aNewB2DPolyPolygon.append(aNewB2DPolygon);
1459*cdf0e10cSrcweir 					}
1460*cdf0e10cSrcweir 
1461*cdf0e10cSrcweir 					aNewB2DPolygon.clear();
1462*cdf0e10cSrcweir 
1463*cdf0e10cSrcweir 					if ( rSrcPt < nCoordSize )
1464*cdf0e10cSrcweir 					{
1465*cdf0e10cSrcweir 						const Point aTempPoint(GetPoint( seqCoordinates[ rSrcPt++ ], sal_True, sal_True ));
1466*cdf0e10cSrcweir 						aNewB2DPolygon.append(basegfx::B2DPoint(aTempPoint.X(), aTempPoint.Y()));
1467*cdf0e10cSrcweir 					}
1468*cdf0e10cSrcweir 				}
1469*cdf0e10cSrcweir 				break;
1470*cdf0e10cSrcweir 				case ENDSUBPATH :
1471*cdf0e10cSrcweir 				break;
1472*cdf0e10cSrcweir 				case CLOSESUBPATH :
1473*cdf0e10cSrcweir 				{
1474*cdf0e10cSrcweir 					if(aNewB2DPolygon.count())
1475*cdf0e10cSrcweir 					{
1476*cdf0e10cSrcweir 						if(aNewB2DPolygon.count() > 1L)
1477*cdf0e10cSrcweir 						{
1478*cdf0e10cSrcweir 							aNewB2DPolygon.setClosed(true);
1479*cdf0e10cSrcweir 							aNewB2DPolyPolygon.append(aNewB2DPolygon);
1480*cdf0e10cSrcweir 						}
1481*cdf0e10cSrcweir 
1482*cdf0e10cSrcweir 						aNewB2DPolygon.clear();
1483*cdf0e10cSrcweir 					}
1484*cdf0e10cSrcweir 				}
1485*cdf0e10cSrcweir 				break;
1486*cdf0e10cSrcweir 				case CURVETO :
1487*cdf0e10cSrcweir 				{
1488*cdf0e10cSrcweir 					for ( sal_uInt16 i = 0; ( i < nPntCount ) && ( ( rSrcPt + 2 ) < nCoordSize ); i++ )
1489*cdf0e10cSrcweir 					{
1490*cdf0e10cSrcweir 						const Point aControlA(GetPoint( seqCoordinates[ rSrcPt++ ], sal_True, sal_True ));
1491*cdf0e10cSrcweir 						const Point aControlB(GetPoint( seqCoordinates[ rSrcPt++ ], sal_True, sal_True ));
1492*cdf0e10cSrcweir 						const Point aEnd(GetPoint( seqCoordinates[ rSrcPt++ ], sal_True, sal_True ));
1493*cdf0e10cSrcweir 
1494*cdf0e10cSrcweir 						DBG_ASSERT(aNewB2DPolygon.count(), "EnhancedCustomShape2d::CreateSubPath: Error in adding control point (!)");
1495*cdf0e10cSrcweir 						aNewB2DPolygon.appendBezierSegment(
1496*cdf0e10cSrcweir 							basegfx::B2DPoint(aControlA.X(), aControlA.Y()),
1497*cdf0e10cSrcweir 							basegfx::B2DPoint(aControlB.X(), aControlB.Y()),
1498*cdf0e10cSrcweir 							basegfx::B2DPoint(aEnd.X(), aEnd.Y()));
1499*cdf0e10cSrcweir 					}
1500*cdf0e10cSrcweir 				}
1501*cdf0e10cSrcweir 				break;
1502*cdf0e10cSrcweir 
1503*cdf0e10cSrcweir 				case ANGLEELLIPSE :
1504*cdf0e10cSrcweir 				{
1505*cdf0e10cSrcweir 					if(aNewB2DPolygon.count() > 1L)
1506*cdf0e10cSrcweir 					{
1507*cdf0e10cSrcweir 						// #i76201# Add conversion to closed polygon when first and last points are equal
1508*cdf0e10cSrcweir 						basegfx::tools::checkClosed(aNewB2DPolygon);
1509*cdf0e10cSrcweir 						aNewB2DPolyPolygon.append(aNewB2DPolygon);
1510*cdf0e10cSrcweir 					}
1511*cdf0e10cSrcweir 
1512*cdf0e10cSrcweir 					aNewB2DPolygon.clear();
1513*cdf0e10cSrcweir 				}
1514*cdf0e10cSrcweir 				case ANGLEELLIPSETO :
1515*cdf0e10cSrcweir 				{
1516*cdf0e10cSrcweir 					for ( sal_uInt16 i = 0; ( i < nPntCount ) && ( ( rSrcPt + 2 ) < nCoordSize ); i++ )
1517*cdf0e10cSrcweir 					{
1518*cdf0e10cSrcweir 						// create a circle
1519*cdf0e10cSrcweir 						Point _aCenter( GetPoint( seqCoordinates[ rSrcPt ], sal_True, sal_True ) );
1520*cdf0e10cSrcweir 						double fWidth, fHeight;
1521*cdf0e10cSrcweir 						GetParameter( fWidth,  seqCoordinates[ rSrcPt + 1 ].First, sal_True, sal_False  );
1522*cdf0e10cSrcweir 						GetParameter( fHeight,  seqCoordinates[ rSrcPt + 1 ].Second, sal_False, sal_True );
1523*cdf0e10cSrcweir 						fWidth *= fXScale;
1524*cdf0e10cSrcweir 						fHeight*= fYScale;
1525*cdf0e10cSrcweir 						Point aP( (sal_Int32)( _aCenter.X() - fWidth ), (sal_Int32)( _aCenter.Y() - fHeight ) );
1526*cdf0e10cSrcweir 						Size  aS( (sal_Int32)( fWidth * 2.0 ), (sal_Int32)( fHeight * 2.0 ) );
1527*cdf0e10cSrcweir 						Rectangle aRect( aP, aS );
1528*cdf0e10cSrcweir 						if ( aRect.GetWidth() && aRect.GetHeight() )
1529*cdf0e10cSrcweir 						{
1530*cdf0e10cSrcweir 							double fStartAngle, fEndAngle;
1531*cdf0e10cSrcweir 							GetParameter( fStartAngle, seqCoordinates[ rSrcPt + 2 ].First,  sal_False, sal_False );
1532*cdf0e10cSrcweir 							GetParameter( fEndAngle  , seqCoordinates[ rSrcPt + 2 ].Second, sal_False, sal_False );
1533*cdf0e10cSrcweir 
1534*cdf0e10cSrcweir 							if ( ((sal_Int32)fStartAngle % 360) != ((sal_Int32)fEndAngle % 360) )
1535*cdf0e10cSrcweir 							{
1536*cdf0e10cSrcweir 								if ( (sal_Int32)fStartAngle & 0x7fff0000 )	// SJ: if the angle was imported from our escher import, then the
1537*cdf0e10cSrcweir 									fStartAngle /= 65536.0;					// value is shifted by 16. TODO: already change the fixed float to a
1538*cdf0e10cSrcweir 								if ( (sal_Int32)fEndAngle & 0x7fff0000 )	// double in the import filter
1539*cdf0e10cSrcweir 								{
1540*cdf0e10cSrcweir 									fEndAngle /= 65536.0;
1541*cdf0e10cSrcweir 									fEndAngle = fEndAngle + fStartAngle;
1542*cdf0e10cSrcweir 									if ( fEndAngle < 0 )
1543*cdf0e10cSrcweir 									{	// in the binary filter the endangle is the amount
1544*cdf0e10cSrcweir 										double fTemp = fStartAngle;
1545*cdf0e10cSrcweir 										fStartAngle = fEndAngle;
1546*cdf0e10cSrcweir 										fEndAngle = fTemp;
1547*cdf0e10cSrcweir 									}
1548*cdf0e10cSrcweir 								}
1549*cdf0e10cSrcweir 								double fCenterX = aRect.Center().X();
1550*cdf0e10cSrcweir 								double fCenterY = aRect.Center().Y();
1551*cdf0e10cSrcweir 								double fx1 = ( cos( fStartAngle * F_PI180 ) * 65536.0 * fXScale ) + fCenterX;
1552*cdf0e10cSrcweir 								double fy1 = ( -sin( fStartAngle * F_PI180 ) * 65536.0 * fYScale ) + fCenterY;
1553*cdf0e10cSrcweir 								double fx2 = ( cos( fEndAngle * F_PI180 ) * 65536.0 * fXScale ) + fCenterX;
1554*cdf0e10cSrcweir 								double fy2 = ( -sin( fEndAngle * F_PI180 ) * 65536.0 * fYScale ) + fCenterY;
1555*cdf0e10cSrcweir 								aNewB2DPolygon.append(CreateArc( aRect, Point( (sal_Int32)fx1, (sal_Int32)fy1 ), Point( (sal_Int32)fx2, (sal_Int32)fy2 ), sal_False));
1556*cdf0e10cSrcweir 							}
1557*cdf0e10cSrcweir 							else
1558*cdf0e10cSrcweir 							{	/* SJ: TODO: this block should be replaced sometimes, because the current point
1559*cdf0e10cSrcweir 								   is not set correct, it also does not use the correct moveto
1560*cdf0e10cSrcweir 								   point if ANGLEELLIPSETO was used, but the method CreateArc
1561*cdf0e10cSrcweir 								   is at the moment not able to draw full circles (if startangle is 0
1562*cdf0e10cSrcweir 								   and endangle 360 nothing is painted :-( */
1563*cdf0e10cSrcweir 								sal_Int32 nXControl = (sal_Int32)((double)aRect.GetWidth() * 0.2835 );
1564*cdf0e10cSrcweir 								sal_Int32 nYControl = (sal_Int32)((double)aRect.GetHeight() * 0.2835 );
1565*cdf0e10cSrcweir 								Point aCenter( aRect.Center() );
1566*cdf0e10cSrcweir 
1567*cdf0e10cSrcweir 								// append start point
1568*cdf0e10cSrcweir 								aNewB2DPolygon.append(basegfx::B2DPoint(aCenter.X(), aRect.Top()));
1569*cdf0e10cSrcweir 
1570*cdf0e10cSrcweir 								// append four bezier segments
1571*cdf0e10cSrcweir 								aNewB2DPolygon.appendBezierSegment(
1572*cdf0e10cSrcweir 									basegfx::B2DPoint(aCenter.X() + nXControl, aRect.Top()),
1573*cdf0e10cSrcweir 									basegfx::B2DPoint(aRect.Right(), aCenter.Y() - nYControl),
1574*cdf0e10cSrcweir 									basegfx::B2DPoint(aRect.Right(), aCenter.Y()));
1575*cdf0e10cSrcweir 
1576*cdf0e10cSrcweir 								aNewB2DPolygon.appendBezierSegment(
1577*cdf0e10cSrcweir 									basegfx::B2DPoint(aRect.Right(), aCenter.Y() + nYControl),
1578*cdf0e10cSrcweir 									basegfx::B2DPoint(aCenter.X() + nXControl, aRect.Bottom()),
1579*cdf0e10cSrcweir 									basegfx::B2DPoint(aCenter.X(), aRect.Bottom()));
1580*cdf0e10cSrcweir 
1581*cdf0e10cSrcweir 								aNewB2DPolygon.appendBezierSegment(
1582*cdf0e10cSrcweir 									basegfx::B2DPoint(aCenter.X() - nXControl, aRect.Bottom()),
1583*cdf0e10cSrcweir 									basegfx::B2DPoint(aRect.Left(), aCenter.Y() + nYControl),
1584*cdf0e10cSrcweir 									basegfx::B2DPoint(aRect.Left(), aCenter.Y()));
1585*cdf0e10cSrcweir 
1586*cdf0e10cSrcweir 								aNewB2DPolygon.appendBezierSegment(
1587*cdf0e10cSrcweir 									basegfx::B2DPoint(aRect.Left(), aCenter.Y() - nYControl),
1588*cdf0e10cSrcweir 									basegfx::B2DPoint(aCenter.X() - nXControl, aRect.Top()),
1589*cdf0e10cSrcweir 									basegfx::B2DPoint(aCenter.X(), aRect.Top()));
1590*cdf0e10cSrcweir 
1591*cdf0e10cSrcweir 								// close, rescue last controlpoint, remove double last point
1592*cdf0e10cSrcweir 								basegfx::tools::closeWithGeometryChange(aNewB2DPolygon);
1593*cdf0e10cSrcweir 							}
1594*cdf0e10cSrcweir 						}
1595*cdf0e10cSrcweir 						rSrcPt += 3;
1596*cdf0e10cSrcweir 					}
1597*cdf0e10cSrcweir 				}
1598*cdf0e10cSrcweir 				break;
1599*cdf0e10cSrcweir 
1600*cdf0e10cSrcweir 				case LINETO :
1601*cdf0e10cSrcweir 				{
1602*cdf0e10cSrcweir 					for ( sal_Int32 i(0L); ( i < nPntCount ) && ( rSrcPt < nCoordSize ); i++ )
1603*cdf0e10cSrcweir 					{
1604*cdf0e10cSrcweir 						const Point aTempPoint(GetPoint( seqCoordinates[ rSrcPt++ ], sal_True, sal_True ));
1605*cdf0e10cSrcweir 						aNewB2DPolygon.append(basegfx::B2DPoint(aTempPoint.X(), aTempPoint.Y()));
1606*cdf0e10cSrcweir 					}
1607*cdf0e10cSrcweir 				}
1608*cdf0e10cSrcweir 				break;
1609*cdf0e10cSrcweir 
1610*cdf0e10cSrcweir 				case ARC :
1611*cdf0e10cSrcweir 				case CLOCKWISEARC :
1612*cdf0e10cSrcweir 				{
1613*cdf0e10cSrcweir 					if(aNewB2DPolygon.count() > 1L)
1614*cdf0e10cSrcweir 					{
1615*cdf0e10cSrcweir 						// #i76201# Add conversion to closed polygon when first and last points are equal
1616*cdf0e10cSrcweir 						basegfx::tools::checkClosed(aNewB2DPolygon);
1617*cdf0e10cSrcweir 						aNewB2DPolyPolygon.append(aNewB2DPolygon);
1618*cdf0e10cSrcweir 					}
1619*cdf0e10cSrcweir 
1620*cdf0e10cSrcweir 					aNewB2DPolygon.clear();
1621*cdf0e10cSrcweir 				}
1622*cdf0e10cSrcweir 				case ARCTO :
1623*cdf0e10cSrcweir 				case CLOCKWISEARCTO :
1624*cdf0e10cSrcweir 				{
1625*cdf0e10cSrcweir 					sal_Bool bClockwise = ( nCommand == CLOCKWISEARC ) || ( nCommand == CLOCKWISEARCTO );
1626*cdf0e10cSrcweir 					sal_uInt32 nXor = bClockwise ? 3 : 2;
1627*cdf0e10cSrcweir 					for ( sal_uInt16 i = 0; ( i < nPntCount ) && ( ( rSrcPt + 3 ) < nCoordSize ); i++ )
1628*cdf0e10cSrcweir 					{
1629*cdf0e10cSrcweir 						Rectangle aRect( GetPoint( seqCoordinates[ rSrcPt ], sal_True, sal_True ), GetPoint( seqCoordinates[ rSrcPt + 1 ], sal_True, sal_True ) );
1630*cdf0e10cSrcweir 						if ( aRect.GetWidth() && aRect.GetHeight() )
1631*cdf0e10cSrcweir 						{
1632*cdf0e10cSrcweir 							Point aCenter( aRect.Center() );
1633*cdf0e10cSrcweir 							Point aStart( GetPoint( seqCoordinates[ (sal_uInt16)( rSrcPt + nXor ) ], sal_True, sal_True ) );
1634*cdf0e10cSrcweir 							Point aEnd( GetPoint( seqCoordinates[ (sal_uInt16)( rSrcPt + ( nXor ^ 1 ) ) ], sal_True, sal_True ) );
1635*cdf0e10cSrcweir 							double fRatio = (double)aRect.GetHeight() / (double)aRect.GetWidth();
1636*cdf0e10cSrcweir 							aStart.X() = (sal_Int32)( ( (double)( aStart.X() - aCenter.X() ) ) * fRatio ) + aCenter.X();
1637*cdf0e10cSrcweir 							aStart.Y() = (sal_Int32)( ( (double)( aStart.Y() - aCenter.Y() ) ) ) + aCenter.Y();
1638*cdf0e10cSrcweir 							aEnd.X() = (sal_Int32)( ( (double)( aEnd.X() - aCenter.X() ) ) * fRatio ) + aCenter.X();
1639*cdf0e10cSrcweir 							aEnd.Y() = (sal_Int32)( ( (double)( aEnd.Y() - aCenter.Y() ) ) ) + aCenter.Y();
1640*cdf0e10cSrcweir 							aNewB2DPolygon.append(CreateArc( aRect, aStart, aEnd, bClockwise));
1641*cdf0e10cSrcweir 						}
1642*cdf0e10cSrcweir 						rSrcPt += 4;
1643*cdf0e10cSrcweir 					}
1644*cdf0e10cSrcweir 				}
1645*cdf0e10cSrcweir 				break;
1646*cdf0e10cSrcweir 
1647*cdf0e10cSrcweir 				case ELLIPTICALQUADRANTX :
1648*cdf0e10cSrcweir 				case ELLIPTICALQUADRANTY :
1649*cdf0e10cSrcweir 				{
1650*cdf0e10cSrcweir 					bool bFirstDirection(true);
1651*cdf0e10cSrcweir 					basegfx::B2DPoint aControlPointA;
1652*cdf0e10cSrcweir 					basegfx::B2DPoint aControlPointB;
1653*cdf0e10cSrcweir 
1654*cdf0e10cSrcweir 					for ( sal_uInt16 i = 0; ( i < nPntCount ) && ( rSrcPt < nCoordSize ); i++ )
1655*cdf0e10cSrcweir 					{
1656*cdf0e10cSrcweir 						sal_uInt32 nModT = ( nCommand == ELLIPTICALQUADRANTX ) ? 1 : 0;
1657*cdf0e10cSrcweir 						Point aCurrent( GetPoint( seqCoordinates[ rSrcPt ], sal_True, sal_True ) );
1658*cdf0e10cSrcweir 
1659*cdf0e10cSrcweir 						if ( rSrcPt )	// we need a previous point
1660*cdf0e10cSrcweir 						{
1661*cdf0e10cSrcweir 							Point aPrev( GetPoint( seqCoordinates[ rSrcPt - 1 ], sal_True, sal_True ) );
1662*cdf0e10cSrcweir 							sal_Int32 nX, nY;
1663*cdf0e10cSrcweir 							nX = aCurrent.X() - aPrev.X();
1664*cdf0e10cSrcweir 							nY = aCurrent.Y() - aPrev.Y();
1665*cdf0e10cSrcweir 							if ( ( nY ^ nX ) & 0x80000000 )
1666*cdf0e10cSrcweir 							{
1667*cdf0e10cSrcweir 								if ( !i )
1668*cdf0e10cSrcweir 									bFirstDirection = true;
1669*cdf0e10cSrcweir 								else if ( !bFirstDirection )
1670*cdf0e10cSrcweir 									nModT ^= 1;
1671*cdf0e10cSrcweir 							}
1672*cdf0e10cSrcweir 							else
1673*cdf0e10cSrcweir 							{
1674*cdf0e10cSrcweir 								if ( !i )
1675*cdf0e10cSrcweir 									bFirstDirection = false;
1676*cdf0e10cSrcweir 								else if ( bFirstDirection )
1677*cdf0e10cSrcweir 									nModT ^= 1;
1678*cdf0e10cSrcweir 							}
1679*cdf0e10cSrcweir 							if ( nModT )			// get the right corner
1680*cdf0e10cSrcweir 							{
1681*cdf0e10cSrcweir 								nX = aCurrent.X();
1682*cdf0e10cSrcweir 								nY = aPrev.Y();
1683*cdf0e10cSrcweir 							}
1684*cdf0e10cSrcweir 							else
1685*cdf0e10cSrcweir 							{
1686*cdf0e10cSrcweir 								nX = aPrev.X();
1687*cdf0e10cSrcweir 								nY = aCurrent.Y();
1688*cdf0e10cSrcweir 							}
1689*cdf0e10cSrcweir 							sal_Int32 nXVec = ( nX - aPrev.X() ) >> 1;
1690*cdf0e10cSrcweir 							sal_Int32 nYVec = ( nY - aPrev.Y() ) >> 1;
1691*cdf0e10cSrcweir 							Point aControl1( aPrev.X() + nXVec, aPrev.Y() + nYVec );
1692*cdf0e10cSrcweir 
1693*cdf0e10cSrcweir 							aControlPointA = basegfx::B2DPoint(aControl1.X(), aControl1.Y());
1694*cdf0e10cSrcweir 
1695*cdf0e10cSrcweir 							nXVec = ( nX - aCurrent.X() ) >> 1;
1696*cdf0e10cSrcweir 							nYVec = ( nY - aCurrent.Y() ) >> 1;
1697*cdf0e10cSrcweir 							Point aControl2( aCurrent.X() + nXVec, aCurrent.Y() + nYVec );
1698*cdf0e10cSrcweir 
1699*cdf0e10cSrcweir 							aControlPointB = basegfx::B2DPoint(aControl2.X(), aControl2.Y());
1700*cdf0e10cSrcweir 
1701*cdf0e10cSrcweir 							aNewB2DPolygon.appendBezierSegment(
1702*cdf0e10cSrcweir 								aControlPointA,
1703*cdf0e10cSrcweir 								aControlPointB,
1704*cdf0e10cSrcweir 								basegfx::B2DPoint(aCurrent.X(), aCurrent.Y()));
1705*cdf0e10cSrcweir 						}
1706*cdf0e10cSrcweir 						else
1707*cdf0e10cSrcweir 						{
1708*cdf0e10cSrcweir 							aNewB2DPolygon.append(basegfx::B2DPoint(aCurrent.X(), aCurrent.Y()));
1709*cdf0e10cSrcweir 						}
1710*cdf0e10cSrcweir 
1711*cdf0e10cSrcweir 						rSrcPt++;
1712*cdf0e10cSrcweir 					}
1713*cdf0e10cSrcweir 				}
1714*cdf0e10cSrcweir 				break;
1715*cdf0e10cSrcweir 
1716*cdf0e10cSrcweir #ifdef DBG_CUSTOMSHAPE
1717*cdf0e10cSrcweir 				case UNKNOWN :
1718*cdf0e10cSrcweir 				default :
1719*cdf0e10cSrcweir 				{
1720*cdf0e10cSrcweir 					ByteString aString( "CustomShapes::unknown PolyFlagValue :" );
1721*cdf0e10cSrcweir 					aString.Append( ByteString::CreateFromInt32( nCommand ) );
1722*cdf0e10cSrcweir 					DBG_ERROR( aString.GetBuffer() );
1723*cdf0e10cSrcweir 				}
1724*cdf0e10cSrcweir 				break;
1725*cdf0e10cSrcweir #endif
1726*cdf0e10cSrcweir 			}
1727*cdf0e10cSrcweir 			if ( nCommand == ENDSUBPATH )
1728*cdf0e10cSrcweir 				break;
1729*cdf0e10cSrcweir 		}
1730*cdf0e10cSrcweir 	}
1731*cdf0e10cSrcweir 	if ( rSegmentInd == nSegInfoSize )
1732*cdf0e10cSrcweir 		rSegmentInd++;
1733*cdf0e10cSrcweir 
1734*cdf0e10cSrcweir 	if(aNewB2DPolygon.count() > 1L)
1735*cdf0e10cSrcweir 	{
1736*cdf0e10cSrcweir 		// #i76201# Add conversion to closed polygon when first and last points are equal
1737*cdf0e10cSrcweir 		basegfx::tools::checkClosed(aNewB2DPolygon);
1738*cdf0e10cSrcweir 		aNewB2DPolyPolygon.append(aNewB2DPolygon);
1739*cdf0e10cSrcweir 	}
1740*cdf0e10cSrcweir 
1741*cdf0e10cSrcweir 	if(aNewB2DPolyPolygon.count())
1742*cdf0e10cSrcweir 	{
1743*cdf0e10cSrcweir 		// #i37011#
1744*cdf0e10cSrcweir 		bool bForceCreateTwoObjects(false);
1745*cdf0e10cSrcweir 
1746*cdf0e10cSrcweir 		if(!bSortFilledObjectsToBack && !aNewB2DPolyPolygon.isClosed() && !bNoStroke)
1747*cdf0e10cSrcweir 		{
1748*cdf0e10cSrcweir 			bForceCreateTwoObjects = true;
1749*cdf0e10cSrcweir 		}
1750*cdf0e10cSrcweir 
1751*cdf0e10cSrcweir 		if(bLineGeometryNeededOnly)
1752*cdf0e10cSrcweir 		{
1753*cdf0e10cSrcweir 			bForceCreateTwoObjects = true;
1754*cdf0e10cSrcweir 			bNoFill = true;
1755*cdf0e10cSrcweir 			bNoStroke = false;
1756*cdf0e10cSrcweir 		}
1757*cdf0e10cSrcweir 
1758*cdf0e10cSrcweir 		if(bForceCreateTwoObjects || bSortFilledObjectsToBack)
1759*cdf0e10cSrcweir 		{
1760*cdf0e10cSrcweir 			if(bFilled && !bNoFill)
1761*cdf0e10cSrcweir 			{
1762*cdf0e10cSrcweir 				basegfx::B2DPolyPolygon aClosedPolyPolygon(aNewB2DPolyPolygon);
1763*cdf0e10cSrcweir 				aClosedPolyPolygon.setClosed(true);
1764*cdf0e10cSrcweir 				SdrPathObj* pFill = new SdrPathObj(OBJ_POLY, aClosedPolyPolygon);
1765*cdf0e10cSrcweir 				SfxItemSet aTempSet(*this);
1766*cdf0e10cSrcweir 				aTempSet.Put(SdrShadowItem(sal_False));
1767*cdf0e10cSrcweir 				aTempSet.Put(XLineStyleItem(XLINE_NONE));
1768*cdf0e10cSrcweir 				pFill->SetMergedItemSet(aTempSet);
1769*cdf0e10cSrcweir 				rObjectList.push_back(pFill);
1770*cdf0e10cSrcweir 			}
1771*cdf0e10cSrcweir 
1772*cdf0e10cSrcweir 			if(!bNoStroke)
1773*cdf0e10cSrcweir 			{
1774*cdf0e10cSrcweir 				// there is no reason to use OBJ_PLIN here when the polygon is actually closed,
1775*cdf0e10cSrcweir 				// the non-fill is defined by XFILL_NONE. Since SdrPathObj::ImpForceKind() needs
1776*cdf0e10cSrcweir 				// to correct the polygon (here: open it) using the type, the last edge may get lost.
1777*cdf0e10cSrcweir 				// Thus, use a type that fits the polygon
1778*cdf0e10cSrcweir 				SdrPathObj* pStroke = new SdrPathObj(
1779*cdf0e10cSrcweir 					aNewB2DPolyPolygon.isClosed() ? OBJ_POLY : OBJ_PLIN,
1780*cdf0e10cSrcweir 					aNewB2DPolyPolygon);
1781*cdf0e10cSrcweir 				SfxItemSet aTempSet(*this);
1782*cdf0e10cSrcweir 				aTempSet.Put(SdrShadowItem(sal_False));
1783*cdf0e10cSrcweir 				aTempSet.Put(XFillStyleItem(XFILL_NONE));
1784*cdf0e10cSrcweir 				pStroke->SetMergedItemSet(aTempSet);
1785*cdf0e10cSrcweir 				rObjectList.push_back(pStroke);
1786*cdf0e10cSrcweir 			}
1787*cdf0e10cSrcweir 		}
1788*cdf0e10cSrcweir 		else
1789*cdf0e10cSrcweir 		{
1790*cdf0e10cSrcweir 			SdrPathObj* pObj = 0;
1791*cdf0e10cSrcweir 			SfxItemSet aTempSet(*this);
1792*cdf0e10cSrcweir 			aTempSet.Put(SdrShadowItem(sal_False));
1793*cdf0e10cSrcweir 
1794*cdf0e10cSrcweir 			if(bNoFill)
1795*cdf0e10cSrcweir 			{
1796*cdf0e10cSrcweir 				// see comment above about OBJ_PLIN
1797*cdf0e10cSrcweir 				pObj = new SdrPathObj(
1798*cdf0e10cSrcweir 					aNewB2DPolyPolygon.isClosed() ? OBJ_POLY : OBJ_PLIN,
1799*cdf0e10cSrcweir 					aNewB2DPolyPolygon);
1800*cdf0e10cSrcweir 				aTempSet.Put(XFillStyleItem(XFILL_NONE));
1801*cdf0e10cSrcweir 			}
1802*cdf0e10cSrcweir 			else
1803*cdf0e10cSrcweir 			{
1804*cdf0e10cSrcweir 				aNewB2DPolyPolygon.setClosed(true);
1805*cdf0e10cSrcweir 				pObj = new SdrPathObj(OBJ_POLY, aNewB2DPolyPolygon);
1806*cdf0e10cSrcweir 			}
1807*cdf0e10cSrcweir 
1808*cdf0e10cSrcweir 			if(bNoStroke)
1809*cdf0e10cSrcweir 			{
1810*cdf0e10cSrcweir 				aTempSet.Put(XLineStyleItem(XLINE_NONE));
1811*cdf0e10cSrcweir 			}
1812*cdf0e10cSrcweir 
1813*cdf0e10cSrcweir 			if(pObj)
1814*cdf0e10cSrcweir 			{
1815*cdf0e10cSrcweir 				pObj->SetMergedItemSet(aTempSet);
1816*cdf0e10cSrcweir 				rObjectList.push_back(pObj);
1817*cdf0e10cSrcweir 			}
1818*cdf0e10cSrcweir 		}
1819*cdf0e10cSrcweir 	}
1820*cdf0e10cSrcweir }
1821*cdf0e10cSrcweir 
1822*cdf0e10cSrcweir void CorrectCalloutArrows( MSO_SPT eSpType, sal_uInt32 nLineObjectCount, std::vector< SdrPathObj* >& vObjectList )
1823*cdf0e10cSrcweir {
1824*cdf0e10cSrcweir 	sal_Bool bAccent = sal_False;
1825*cdf0e10cSrcweir 	switch( eSpType )
1826*cdf0e10cSrcweir 	{
1827*cdf0e10cSrcweir 		case mso_sptCallout1 :
1828*cdf0e10cSrcweir 		case mso_sptBorderCallout1 :
1829*cdf0e10cSrcweir 		case mso_sptCallout90 :
1830*cdf0e10cSrcweir 		case mso_sptBorderCallout90 :
1831*cdf0e10cSrcweir 		default:
1832*cdf0e10cSrcweir 		break;
1833*cdf0e10cSrcweir 
1834*cdf0e10cSrcweir 		case mso_sptAccentCallout1 :
1835*cdf0e10cSrcweir 		case mso_sptAccentBorderCallout1 :
1836*cdf0e10cSrcweir 		case mso_sptAccentCallout90 :
1837*cdf0e10cSrcweir 		case mso_sptAccentBorderCallout90 :
1838*cdf0e10cSrcweir 		{
1839*cdf0e10cSrcweir 			sal_uInt32 i, nLine = 0;
1840*cdf0e10cSrcweir 			for ( i = 0; i < vObjectList.size(); i++ )
1841*cdf0e10cSrcweir 			{
1842*cdf0e10cSrcweir 				SdrPathObj* pObj( vObjectList[ i ] );
1843*cdf0e10cSrcweir 				if(pObj->IsLine())
1844*cdf0e10cSrcweir 				{
1845*cdf0e10cSrcweir 					nLine++;
1846*cdf0e10cSrcweir 					if ( nLine == nLineObjectCount )
1847*cdf0e10cSrcweir 					{
1848*cdf0e10cSrcweir 						pObj->ClearMergedItem( XATTR_LINESTART );
1849*cdf0e10cSrcweir 						pObj->ClearMergedItem( XATTR_LINEEND );
1850*cdf0e10cSrcweir 					}
1851*cdf0e10cSrcweir 				}
1852*cdf0e10cSrcweir 			}
1853*cdf0e10cSrcweir 		}
1854*cdf0e10cSrcweir 		break;
1855*cdf0e10cSrcweir 
1856*cdf0e10cSrcweir 		// switch start & end
1857*cdf0e10cSrcweir 		case mso_sptAccentCallout2 :
1858*cdf0e10cSrcweir 		case mso_sptAccentBorderCallout2 :
1859*cdf0e10cSrcweir 			bAccent = sal_True;
1860*cdf0e10cSrcweir 		case mso_sptCallout2 :
1861*cdf0e10cSrcweir 		case mso_sptBorderCallout2 :
1862*cdf0e10cSrcweir 		{
1863*cdf0e10cSrcweir 			sal_uInt32 i, nLine = 0;
1864*cdf0e10cSrcweir 			for ( i = 0; i < vObjectList.size(); i++ )
1865*cdf0e10cSrcweir 			{
1866*cdf0e10cSrcweir 				SdrPathObj* pObj( vObjectList[ i ] );
1867*cdf0e10cSrcweir 				if(pObj->IsLine())
1868*cdf0e10cSrcweir 				{
1869*cdf0e10cSrcweir 					nLine++;
1870*cdf0e10cSrcweir 					if ( nLine == 1 )
1871*cdf0e10cSrcweir 						pObj->ClearMergedItem( XATTR_LINEEND );
1872*cdf0e10cSrcweir 					else if ( ( bAccent && ( nLine == nLineObjectCount - 1 ) ) || ( !bAccent && ( nLine == nLineObjectCount ) ) )
1873*cdf0e10cSrcweir 						pObj->ClearMergedItem( XATTR_LINESTART );
1874*cdf0e10cSrcweir 					else
1875*cdf0e10cSrcweir 					{
1876*cdf0e10cSrcweir 						pObj->ClearMergedItem( XATTR_LINESTART );
1877*cdf0e10cSrcweir 						pObj->ClearMergedItem( XATTR_LINEEND );
1878*cdf0e10cSrcweir 					}
1879*cdf0e10cSrcweir 				}
1880*cdf0e10cSrcweir 			}
1881*cdf0e10cSrcweir 		}
1882*cdf0e10cSrcweir 		break;
1883*cdf0e10cSrcweir 
1884*cdf0e10cSrcweir 		case mso_sptAccentCallout3 :
1885*cdf0e10cSrcweir 		case mso_sptAccentBorderCallout3 :
1886*cdf0e10cSrcweir 			bAccent = sal_False;
1887*cdf0e10cSrcweir 		case mso_sptCallout3 :
1888*cdf0e10cSrcweir 		case mso_sptBorderCallout3 :
1889*cdf0e10cSrcweir 		{
1890*cdf0e10cSrcweir 			sal_uInt32 i, nLine = 0;
1891*cdf0e10cSrcweir 			for ( i = 0; i < vObjectList.size(); i++ )
1892*cdf0e10cSrcweir 			{
1893*cdf0e10cSrcweir 				SdrPathObj* pObj( vObjectList[ i ] );
1894*cdf0e10cSrcweir 				if(pObj->IsLine())
1895*cdf0e10cSrcweir 				{
1896*cdf0e10cSrcweir 					if ( nLine )
1897*cdf0e10cSrcweir 					{
1898*cdf0e10cSrcweir 						pObj->ClearMergedItem( XATTR_LINESTART );
1899*cdf0e10cSrcweir 						pObj->ClearMergedItem( XATTR_LINEEND );
1900*cdf0e10cSrcweir 					}
1901*cdf0e10cSrcweir 					else
1902*cdf0e10cSrcweir 						EnhancedCustomShape2d::SwapStartAndEndArrow( pObj );
1903*cdf0e10cSrcweir 
1904*cdf0e10cSrcweir 					nLine++;
1905*cdf0e10cSrcweir 				}
1906*cdf0e10cSrcweir 			}
1907*cdf0e10cSrcweir 		}
1908*cdf0e10cSrcweir 		break;
1909*cdf0e10cSrcweir 	}
1910*cdf0e10cSrcweir }
1911*cdf0e10cSrcweir 
1912*cdf0e10cSrcweir void EnhancedCustomShape2d::AdaptObjColor(SdrPathObj& rObj, const SfxItemSet& rCustomShapeSet,
1913*cdf0e10cSrcweir                                           sal_uInt32& nColorIndex, sal_uInt32 nColorCount)
1914*cdf0e10cSrcweir {
1915*cdf0e10cSrcweir     if ( !rObj.IsLine() )
1916*cdf0e10cSrcweir     {
1917*cdf0e10cSrcweir         const XFillStyle eFillStyle = ((const XFillStyleItem&)rObj.GetMergedItem(XATTR_FILLSTYLE)).GetValue();
1918*cdf0e10cSrcweir         switch( eFillStyle )
1919*cdf0e10cSrcweir         {
1920*cdf0e10cSrcweir             default:
1921*cdf0e10cSrcweir             case XFILL_SOLID:
1922*cdf0e10cSrcweir             {
1923*cdf0e10cSrcweir                 Color aFillColor;
1924*cdf0e10cSrcweir                 if ( nColorCount )
1925*cdf0e10cSrcweir                 {
1926*cdf0e10cSrcweir                     aFillColor = GetColorData(
1927*cdf0e10cSrcweir                         ((XFillColorItem&)rCustomShapeSet.Get( XATTR_FILLCOLOR )).GetColorValue(),
1928*cdf0e10cSrcweir                         std::min(nColorIndex, nColorCount-1) );
1929*cdf0e10cSrcweir                     rObj.SetMergedItem( XFillColorItem( String(), aFillColor ) );
1930*cdf0e10cSrcweir                 }
1931*cdf0e10cSrcweir                 break;
1932*cdf0e10cSrcweir             }
1933*cdf0e10cSrcweir             case XFILL_GRADIENT:
1934*cdf0e10cSrcweir             {
1935*cdf0e10cSrcweir                 XGradient aXGradient(((const XFillGradientItem&)rObj.GetMergedItem(XATTR_FILLGRADIENT)).GetGradientValue());
1936*cdf0e10cSrcweir                 if ( nColorCount )
1937*cdf0e10cSrcweir                 {
1938*cdf0e10cSrcweir                     aXGradient.SetStartColor(
1939*cdf0e10cSrcweir                         GetColorData(
1940*cdf0e10cSrcweir                             aXGradient.GetStartColor(),
1941*cdf0e10cSrcweir                             std::min(nColorIndex, nColorCount-1) ));
1942*cdf0e10cSrcweir                     aXGradient.SetEndColor(
1943*cdf0e10cSrcweir                         GetColorData(
1944*cdf0e10cSrcweir                             aXGradient.GetEndColor(),
1945*cdf0e10cSrcweir                             std::min(nColorIndex, nColorCount-1) ));
1946*cdf0e10cSrcweir                 }
1947*cdf0e10cSrcweir 
1948*cdf0e10cSrcweir                 rObj.SetMergedItem( XFillGradientItem( String(), aXGradient ) );
1949*cdf0e10cSrcweir                 break;
1950*cdf0e10cSrcweir             }
1951*cdf0e10cSrcweir             case XFILL_HATCH:
1952*cdf0e10cSrcweir             {
1953*cdf0e10cSrcweir                 XHatch aXHatch(((const XFillHatchItem&)rObj.GetMergedItem(XATTR_FILLHATCH)).GetHatchValue());
1954*cdf0e10cSrcweir                 if ( nColorCount )
1955*cdf0e10cSrcweir                 {
1956*cdf0e10cSrcweir                     aXHatch.SetColor(
1957*cdf0e10cSrcweir                         GetColorData(
1958*cdf0e10cSrcweir                             aXHatch.GetColor(),
1959*cdf0e10cSrcweir                             std::min(nColorIndex, nColorCount-1) ));
1960*cdf0e10cSrcweir                 }
1961*cdf0e10cSrcweir 
1962*cdf0e10cSrcweir                 rObj.SetMergedItem( XFillHatchItem( String(), aXHatch ) );
1963*cdf0e10cSrcweir                 break;
1964*cdf0e10cSrcweir             }
1965*cdf0e10cSrcweir             case XFILL_BITMAP:
1966*cdf0e10cSrcweir             {
1967*cdf0e10cSrcweir                 Bitmap aBitmap(((const XFillBitmapItem&)rObj.GetMergedItem(XATTR_FILLBITMAP)).GetBitmapValue().GetBitmap());
1968*cdf0e10cSrcweir                 if ( nColorCount )
1969*cdf0e10cSrcweir                 {
1970*cdf0e10cSrcweir                     aBitmap.Adjust(
1971*cdf0e10cSrcweir                         static_cast< short > ( GetLuminanceChange(
1972*cdf0e10cSrcweir                             std::min(nColorIndex, nColorCount-1))));
1973*cdf0e10cSrcweir                 }
1974*cdf0e10cSrcweir 
1975*cdf0e10cSrcweir                 rObj.SetMergedItem( XFillBitmapItem( String(), aBitmap ) );
1976*cdf0e10cSrcweir                 break;
1977*cdf0e10cSrcweir             }
1978*cdf0e10cSrcweir         }
1979*cdf0e10cSrcweir 
1980*cdf0e10cSrcweir         if ( nColorIndex < nColorCount )
1981*cdf0e10cSrcweir             nColorIndex++;
1982*cdf0e10cSrcweir     }
1983*cdf0e10cSrcweir }
1984*cdf0e10cSrcweir 
1985*cdf0e10cSrcweir SdrObject* EnhancedCustomShape2d::CreatePathObj( sal_Bool bLineGeometryNeededOnly )
1986*cdf0e10cSrcweir {
1987*cdf0e10cSrcweir 	sal_Int32 nCoordSize = seqCoordinates.getLength();
1988*cdf0e10cSrcweir 	if ( !nCoordSize )
1989*cdf0e10cSrcweir 		return NULL;
1990*cdf0e10cSrcweir 
1991*cdf0e10cSrcweir 	sal_uInt16 nSrcPt = 0;
1992*cdf0e10cSrcweir 	sal_uInt16 nSegmentInd = 0;
1993*cdf0e10cSrcweir 
1994*cdf0e10cSrcweir 	std::vector< SdrPathObj* > vObjectList;
1995*cdf0e10cSrcweir 	sal_Bool bSortFilledObjectsToBack = SortFilledObjectsToBackByDefault( eSpType );
1996*cdf0e10cSrcweir 
1997*cdf0e10cSrcweir 	while( nSegmentInd <= seqSegments.getLength() )
1998*cdf0e10cSrcweir 	{
1999*cdf0e10cSrcweir 		CreateSubPath( nSrcPt, nSegmentInd, vObjectList, bLineGeometryNeededOnly, bSortFilledObjectsToBack );
2000*cdf0e10cSrcweir 	}
2001*cdf0e10cSrcweir 
2002*cdf0e10cSrcweir 	SdrObject* pRet = NULL;
2003*cdf0e10cSrcweir 	sal_uInt32 i;
2004*cdf0e10cSrcweir 
2005*cdf0e10cSrcweir 	if ( !vObjectList.empty() )
2006*cdf0e10cSrcweir 	{
2007*cdf0e10cSrcweir 		const SfxItemSet& rCustomShapeSet = pCustomShapeObj->GetMergedItemSet();
2008*cdf0e10cSrcweir 		Color			aFillColor;
2009*cdf0e10cSrcweir 		sal_uInt32		nColorCount = nColorData >> 28;
2010*cdf0e10cSrcweir 		sal_uInt32		nColorIndex	= 0;
2011*cdf0e10cSrcweir 
2012*cdf0e10cSrcweir 		// #i37011# remove invisible objects
2013*cdf0e10cSrcweir 		if(!vObjectList.empty())
2014*cdf0e10cSrcweir 		{
2015*cdf0e10cSrcweir 			std::vector< SdrPathObj* > vTempList;
2016*cdf0e10cSrcweir 
2017*cdf0e10cSrcweir 			for(i = 0L; i < vObjectList.size(); i++)
2018*cdf0e10cSrcweir 			{
2019*cdf0e10cSrcweir 				SdrPathObj* pObj(vObjectList[i]);
2020*cdf0e10cSrcweir 				const XLineStyle eLineStyle = ((const XLineStyleItem&)pObj->GetMergedItem(XATTR_LINESTYLE)).GetValue();
2021*cdf0e10cSrcweir                 const XFillStyle eFillStyle = ((const XFillStyleItem&)pObj->GetMergedItem(XATTR_FILLSTYLE)).GetValue();
2022*cdf0e10cSrcweir 
2023*cdf0e10cSrcweir 				//SJ: #i40600# if bLineGeometryNeededOnly is set linystyle does not matter
2024*cdf0e10cSrcweir 				if( !bLineGeometryNeededOnly && ( XLINE_NONE == eLineStyle ) && ( XFILL_NONE == eFillStyle ) )
2025*cdf0e10cSrcweir 					delete pObj;
2026*cdf0e10cSrcweir 				else
2027*cdf0e10cSrcweir 					vTempList.push_back(pObj);
2028*cdf0e10cSrcweir 			}
2029*cdf0e10cSrcweir 
2030*cdf0e10cSrcweir 			vObjectList = vTempList;
2031*cdf0e10cSrcweir 		}
2032*cdf0e10cSrcweir 
2033*cdf0e10cSrcweir 		if(1L == vObjectList.size())
2034*cdf0e10cSrcweir 		{
2035*cdf0e10cSrcweir 			// a single object, correct some values
2036*cdf0e10cSrcweir             AdaptObjColor(*vObjectList[0L],rCustomShapeSet,nColorIndex,nColorCount);
2037*cdf0e10cSrcweir 		}
2038*cdf0e10cSrcweir 		else
2039*cdf0e10cSrcweir 		{
2040*cdf0e10cSrcweir 			sal_Int32 nLineObjectCount = 0;
2041*cdf0e10cSrcweir 			sal_Int32 nAreaObjectCount = 0;
2042*cdf0e10cSrcweir 
2043*cdf0e10cSrcweir 			// correct some values and collect content data
2044*cdf0e10cSrcweir 			for ( i = 0; i < vObjectList.size(); i++ )
2045*cdf0e10cSrcweir 			{
2046*cdf0e10cSrcweir 				SdrPathObj* pObj( vObjectList[ i ] );
2047*cdf0e10cSrcweir 
2048*cdf0e10cSrcweir 				if(pObj->IsLine())
2049*cdf0e10cSrcweir 				{
2050*cdf0e10cSrcweir 					nLineObjectCount++;
2051*cdf0e10cSrcweir 				}
2052*cdf0e10cSrcweir 				else
2053*cdf0e10cSrcweir 				{
2054*cdf0e10cSrcweir 					nAreaObjectCount++;
2055*cdf0e10cSrcweir                     AdaptObjColor(*pObj,rCustomShapeSet,nColorIndex,nColorCount);
2056*cdf0e10cSrcweir 				}
2057*cdf0e10cSrcweir 			}
2058*cdf0e10cSrcweir 
2059*cdf0e10cSrcweir 			// #i88870# correct line arrows for callouts
2060*cdf0e10cSrcweir 			if ( nLineObjectCount )
2061*cdf0e10cSrcweir 				CorrectCalloutArrows( eSpType, nLineObjectCount, vObjectList );
2062*cdf0e10cSrcweir 
2063*cdf0e10cSrcweir 			// sort objects so that filled ones are in front. Necessary
2064*cdf0e10cSrcweir 			// for some strange objects
2065*cdf0e10cSrcweir 			if ( bSortFilledObjectsToBack )
2066*cdf0e10cSrcweir 			{
2067*cdf0e10cSrcweir 				std::vector< SdrPathObj* > vTempList;
2068*cdf0e10cSrcweir 
2069*cdf0e10cSrcweir 				for ( i = 0; i < vObjectList.size(); i++ )
2070*cdf0e10cSrcweir 				{
2071*cdf0e10cSrcweir 					SdrPathObj* pObj( vObjectList[ i ] );
2072*cdf0e10cSrcweir 
2073*cdf0e10cSrcweir 					if ( !pObj->IsLine() )
2074*cdf0e10cSrcweir 					{
2075*cdf0e10cSrcweir 						vTempList.push_back(pObj);
2076*cdf0e10cSrcweir 					}
2077*cdf0e10cSrcweir 				}
2078*cdf0e10cSrcweir 
2079*cdf0e10cSrcweir 				for ( i = 0; i < vObjectList.size(); i++ )
2080*cdf0e10cSrcweir 				{
2081*cdf0e10cSrcweir 					SdrPathObj* pObj( vObjectList[ i ] );
2082*cdf0e10cSrcweir 
2083*cdf0e10cSrcweir 					if ( pObj->IsLine() )
2084*cdf0e10cSrcweir 					{
2085*cdf0e10cSrcweir 						vTempList.push_back(pObj);
2086*cdf0e10cSrcweir 					}
2087*cdf0e10cSrcweir 				}
2088*cdf0e10cSrcweir 
2089*cdf0e10cSrcweir 				vObjectList = vTempList;
2090*cdf0e10cSrcweir 			}
2091*cdf0e10cSrcweir 		}
2092*cdf0e10cSrcweir 	}
2093*cdf0e10cSrcweir 
2094*cdf0e10cSrcweir 	// #i37011#
2095*cdf0e10cSrcweir 	if(!vObjectList.empty())
2096*cdf0e10cSrcweir 	{
2097*cdf0e10cSrcweir 		// copy remaining objects to pRet
2098*cdf0e10cSrcweir 		if(vObjectList.size() > 1L)
2099*cdf0e10cSrcweir 		{
2100*cdf0e10cSrcweir 	        pRet = new SdrObjGroup;
2101*cdf0e10cSrcweir 
2102*cdf0e10cSrcweir 			for (i = 0L; i < vObjectList.size(); i++)
2103*cdf0e10cSrcweir 			{
2104*cdf0e10cSrcweir 				SdrObject* pObj(vObjectList[i]);
2105*cdf0e10cSrcweir 				pRet->GetSubList()->NbcInsertObject(pObj);
2106*cdf0e10cSrcweir 			}
2107*cdf0e10cSrcweir 		}
2108*cdf0e10cSrcweir 		else if(1L == vObjectList.size())
2109*cdf0e10cSrcweir 		{
2110*cdf0e10cSrcweir 			pRet = vObjectList[0L];
2111*cdf0e10cSrcweir 		}
2112*cdf0e10cSrcweir 
2113*cdf0e10cSrcweir 		if(pRet)
2114*cdf0e10cSrcweir 		{
2115*cdf0e10cSrcweir 			// move to target position
2116*cdf0e10cSrcweir 			Rectangle aCurRect(pRet->GetSnapRect());
2117*cdf0e10cSrcweir 			aCurRect.Move(aLogicRect.Left(), aLogicRect.Top());
2118*cdf0e10cSrcweir 			pRet->NbcSetSnapRect(aCurRect);
2119*cdf0e10cSrcweir 		}
2120*cdf0e10cSrcweir 	}
2121*cdf0e10cSrcweir 
2122*cdf0e10cSrcweir 	return pRet;
2123*cdf0e10cSrcweir }
2124*cdf0e10cSrcweir 
2125*cdf0e10cSrcweir SdrObject* EnhancedCustomShape2d::CreateObject( sal_Bool bLineGeometryNeededOnly )
2126*cdf0e10cSrcweir {
2127*cdf0e10cSrcweir 	SdrObject* pRet = NULL;
2128*cdf0e10cSrcweir 
2129*cdf0e10cSrcweir 	if ( eSpType == mso_sptRectangle )
2130*cdf0e10cSrcweir 	{
2131*cdf0e10cSrcweir 		pRet = new SdrRectObj( aLogicRect );
2132*cdf0e10cSrcweir // SJ: not setting model, so we save a lot of broadcasting and the model is not modified any longer
2133*cdf0e10cSrcweir //		pRet->SetModel( pCustomShapeObj->GetModel() );
2134*cdf0e10cSrcweir 		pRet->SetMergedItemSet( *this );
2135*cdf0e10cSrcweir 	}
2136*cdf0e10cSrcweir 	if ( !pRet )
2137*cdf0e10cSrcweir 		pRet = CreatePathObj( bLineGeometryNeededOnly );
2138*cdf0e10cSrcweir 
2139*cdf0e10cSrcweir 	return pRet;
2140*cdf0e10cSrcweir }
2141*cdf0e10cSrcweir 
2142*cdf0e10cSrcweir void EnhancedCustomShape2d::ApplyGluePoints( SdrObject* pObj )
2143*cdf0e10cSrcweir {
2144*cdf0e10cSrcweir 	if ( pObj && seqGluePoints.getLength() )
2145*cdf0e10cSrcweir 	{
2146*cdf0e10cSrcweir 		sal_uInt32 i, nCount = seqGluePoints.getLength();
2147*cdf0e10cSrcweir 		for ( i = 0; i < nCount; i++ )
2148*cdf0e10cSrcweir 		{
2149*cdf0e10cSrcweir 			SdrGluePoint aGluePoint;
2150*cdf0e10cSrcweir 
2151*cdf0e10cSrcweir 			aGluePoint.SetPos( GetPoint( seqGluePoints[ i ], sal_True, sal_True ) );
2152*cdf0e10cSrcweir 			aGluePoint.SetPercent( sal_False );
2153*cdf0e10cSrcweir 
2154*cdf0e10cSrcweir //			const Point& rPoint = GetPoint( seqGluePoints[ i ], sal_True, sal_True );
2155*cdf0e10cSrcweir //			double fXRel = rPoint.X();
2156*cdf0e10cSrcweir //			double fYRel = rPoint.Y();
2157*cdf0e10cSrcweir //			fXRel = aLogicRect.GetWidth() == 0 ? 0.0 : fXRel / aLogicRect.GetWidth() * 10000;
2158*cdf0e10cSrcweir //			fYRel = aLogicRect.GetHeight() == 0 ? 0.0 : fYRel / aLogicRect.GetHeight() * 10000;
2159*cdf0e10cSrcweir //			aGluePoint.SetPos( Point( (sal_Int32)fXRel, (sal_Int32)fYRel ) );
2160*cdf0e10cSrcweir //			aGluePoint.SetPercent( sal_True );
2161*cdf0e10cSrcweir 			aGluePoint.SetAlign( SDRVERTALIGN_TOP | SDRHORZALIGN_LEFT );
2162*cdf0e10cSrcweir 			aGluePoint.SetEscDir( SDRESC_SMART );
2163*cdf0e10cSrcweir 			SdrGluePointList* pList = pObj->ForceGluePointList();
2164*cdf0e10cSrcweir 			if( pList )
2165*cdf0e10cSrcweir 				/* sal_uInt16 nId = */ pList->Insert( aGluePoint );
2166*cdf0e10cSrcweir 		}
2167*cdf0e10cSrcweir 	}
2168*cdf0e10cSrcweir }
2169*cdf0e10cSrcweir 
2170*cdf0e10cSrcweir SdrObject* EnhancedCustomShape2d::CreateLineGeometry()
2171*cdf0e10cSrcweir {
2172*cdf0e10cSrcweir 	return CreateObject( sal_True );
2173*cdf0e10cSrcweir }
2174*cdf0e10cSrcweir 
2175*cdf0e10cSrcweir 
2176