xref: /AOO41X/main/svx/source/svdraw/svdoashp.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
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/svdoashp.hxx>
31*cdf0e10cSrcweir #include "svx/unoapi.hxx"
32*cdf0e10cSrcweir #include <svx/unoshape.hxx>
33*cdf0e10cSrcweir #include <ucbhelper/content.hxx>
34*cdf0e10cSrcweir #include <ucbhelper/contentbroker.hxx>
35*cdf0e10cSrcweir #include <unotools/datetime.hxx>
36*cdf0e10cSrcweir #include <sfx2/lnkbase.hxx>
37*cdf0e10cSrcweir #include <tools/urlobj.hxx>
38*cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
39*cdf0e10cSrcweir #include <com/sun/star/drawing/XShape.hpp>
40*cdf0e10cSrcweir #include <com/sun/star/drawing/XCustomShapeEngine.hpp>
41*cdf0e10cSrcweir #include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp>
42*cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp>
43*cdf0e10cSrcweir #include <com/sun/star/awt/Rectangle.hpp>
44*cdf0e10cSrcweir #include "unopolyhelper.hxx"
45*cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
46*cdf0e10cSrcweir #include <svl/urihelper.hxx>
47*cdf0e10cSrcweir #include <com/sun/star/uno/Sequence.h>
48*cdf0e10cSrcweir #include <svx/svdogrp.hxx>
49*cdf0e10cSrcweir #include <vcl/salbtype.hxx>		// FRound
50*cdf0e10cSrcweir #include <svx/svddrag.hxx>
51*cdf0e10cSrcweir #include <svx/xpool.hxx>
52*cdf0e10cSrcweir #include <svx/xpoly.hxx>
53*cdf0e10cSrcweir #include <svx/svdmodel.hxx>
54*cdf0e10cSrcweir #include <svx/svdpage.hxx>
55*cdf0e10cSrcweir #include "svx/svditer.hxx"
56*cdf0e10cSrcweir #include <svx/svdobj.hxx>
57*cdf0e10cSrcweir #include <svx/svdtrans.hxx>
58*cdf0e10cSrcweir #include <svx/svdetc.hxx>
59*cdf0e10cSrcweir #include <svx/svdattrx.hxx>  // NotPersistItems
60*cdf0e10cSrcweir #include <svx/svdoedge.hxx>  // #32383# Die Verbinder nach Move nochmal anbroadcasten
61*cdf0e10cSrcweir #include "svx/svdglob.hxx"   // StringCache
62*cdf0e10cSrcweir #include "svx/svdstr.hrc"    // Objektname
63*cdf0e10cSrcweir #include <editeng/eeitem.hxx>
64*cdf0e10cSrcweir #include "editeng/editstat.hxx"
65*cdf0e10cSrcweir #include <svx/svdoutl.hxx>
66*cdf0e10cSrcweir #include <editeng/outlobj.hxx>
67*cdf0e10cSrcweir #include <svx/sdtfchim.hxx>
68*cdf0e10cSrcweir #include "../svx/EnhancedCustomShapeGeometry.hxx"
69*cdf0e10cSrcweir #include "../svx/EnhancedCustomShapeTypeNames.hxx"
70*cdf0e10cSrcweir #include "../svx/EnhancedCustomShape2d.hxx"
71*cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValues.hpp>
72*cdf0e10cSrcweir #include <com/sun/star/drawing/EnhancedCustomShapeAdjustmentValue.hpp>
73*cdf0e10cSrcweir #include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp>
74*cdf0e10cSrcweir #include <com/sun/star/drawing/EnhancedCustomShapeTextFrame.hpp>
75*cdf0e10cSrcweir #include <com/sun/star/drawing/EnhancedCustomShapeSegment.hpp>
76*cdf0e10cSrcweir #include <com/sun/star/drawing/EnhancedCustomShapeSegmentCommand.hpp>
77*cdf0e10cSrcweir #include <editeng/writingmodeitem.hxx>
78*cdf0e10cSrcweir #include <svx/xlnclit.hxx>
79*cdf0e10cSrcweir #include <svx/svxids.hrc>
80*cdf0e10cSrcweir #include <svl/whiter.hxx>
81*cdf0e10cSrcweir #include <svx/sdr/properties/customshapeproperties.hxx>
82*cdf0e10cSrcweir #include <svx/sdr/contact/viewcontactofsdrobjcustomshape.hxx>
83*cdf0e10cSrcweir #include <svx/xlnclit.hxx>
84*cdf0e10cSrcweir #include <svx/xlntrit.hxx>
85*cdf0e10cSrcweir #include <svx/xfltrit.hxx>
86*cdf0e10cSrcweir #include <svx/xflclit.hxx>
87*cdf0e10cSrcweir #include <svx/xflgrit.hxx>
88*cdf0e10cSrcweir #include <svx/xflhtit.hxx>
89*cdf0e10cSrcweir #include <svx/xbtmpit.hxx>
90*cdf0e10cSrcweir #include <vcl/bmpacc.hxx>
91*cdf0e10cSrcweir #include <svx/svdview.hxx>
92*cdf0e10cSrcweir #include <basegfx/polygon/b2dpolypolygontools.hxx>
93*cdf0e10cSrcweir #include <basegfx/matrix/b2dhommatrix.hxx>
94*cdf0e10cSrcweir #include <basegfx/matrix/b2dhommatrixtools.hxx>
95*cdf0e10cSrcweir 
96*cdf0e10cSrcweir // #104018# replace macros above with type-safe methods
97*cdf0e10cSrcweir inline double ImplTwipsToMM(double fVal) { return (fVal * (127.0 / 72.0)); }
98*cdf0e10cSrcweir inline double ImplMMToTwips(double fVal) { return (fVal * (72.0 / 127.0)); }
99*cdf0e10cSrcweir 
100*cdf0e10cSrcweir using namespace ::com::sun::star;
101*cdf0e10cSrcweir using namespace ::com::sun::star::uno;
102*cdf0e10cSrcweir using namespace ::com::sun::star::lang;
103*cdf0e10cSrcweir using namespace ::com::sun::star::beans;
104*cdf0e10cSrcweir using namespace ::com::sun::star::drawing;
105*cdf0e10cSrcweir 
106*cdf0e10cSrcweir static MSO_SPT ImpGetCustomShapeType( const SdrObjCustomShape& rCustoShape )
107*cdf0e10cSrcweir {
108*cdf0e10cSrcweir 	MSO_SPT eRetValue = mso_sptNil;
109*cdf0e10cSrcweir 
110*cdf0e10cSrcweir 	rtl::OUString aEngine( ( (SdrCustomShapeEngineItem&)rCustoShape.GetMergedItem( SDRATTR_CUSTOMSHAPE_ENGINE ) ).GetValue() );
111*cdf0e10cSrcweir 	if ( !aEngine.getLength() || aEngine.equalsAscii( "com.sun.star.drawing.EnhancedCustomShapeEngine" ) )
112*cdf0e10cSrcweir 	{
113*cdf0e10cSrcweir 		rtl::OUString sShapeType;
114*cdf0e10cSrcweir 		const rtl::OUString	sType( RTL_CONSTASCII_USTRINGPARAM ( "Type" ) );
115*cdf0e10cSrcweir 		SdrCustomShapeGeometryItem& rGeometryItem( (SdrCustomShapeGeometryItem&)rCustoShape.GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) );
116*cdf0e10cSrcweir 		Any* pAny = rGeometryItem.GetPropertyValueByName( sType );
117*cdf0e10cSrcweir 		if ( pAny && ( *pAny >>= sShapeType ) )
118*cdf0e10cSrcweir 			eRetValue = EnhancedCustomShapeTypeNames::Get( sShapeType );
119*cdf0e10cSrcweir 	}
120*cdf0e10cSrcweir 	return eRetValue;
121*cdf0e10cSrcweir };
122*cdf0e10cSrcweir 
123*cdf0e10cSrcweir static sal_Bool ImpVerticalSwitch( const SdrObjCustomShape& rCustoShape )
124*cdf0e10cSrcweir {
125*cdf0e10cSrcweir 	sal_Bool bRet = sal_False;
126*cdf0e10cSrcweir 	MSO_SPT eShapeType( ImpGetCustomShapeType( rCustoShape ) );
127*cdf0e10cSrcweir 	switch( eShapeType )
128*cdf0e10cSrcweir 	{
129*cdf0e10cSrcweir 		case mso_sptAccentBorderCallout90 :		// 2 ortho
130*cdf0e10cSrcweir 		case mso_sptBorderCallout1 :			// 2 diag
131*cdf0e10cSrcweir 		case mso_sptBorderCallout2 :			// 3
132*cdf0e10cSrcweir 		{
133*cdf0e10cSrcweir 			bRet = sal_True;
134*cdf0e10cSrcweir 		}
135*cdf0e10cSrcweir 		break;
136*cdf0e10cSrcweir /*
137*cdf0e10cSrcweir 		case mso_sptCallout1 :
138*cdf0e10cSrcweir 		case mso_sptAccentCallout1 :
139*cdf0e10cSrcweir 		case mso_sptAccentBorderCallout1 :
140*cdf0e10cSrcweir 		case mso_sptBorderCallout90 :
141*cdf0e10cSrcweir 		case mso_sptCallout90 :
142*cdf0e10cSrcweir 		case mso_sptAccentCallout90 :
143*cdf0e10cSrcweir 		case mso_sptCallout2 :
144*cdf0e10cSrcweir 		case mso_sptCallout3 :
145*cdf0e10cSrcweir 		case mso_sptAccentCallout2 :
146*cdf0e10cSrcweir 		case mso_sptAccentCallout3 :
147*cdf0e10cSrcweir 		case mso_sptBorderCallout3 :
148*cdf0e10cSrcweir 		case mso_sptAccentBorderCallout2 :
149*cdf0e10cSrcweir 		case mso_sptAccentBorderCallout3 :
150*cdf0e10cSrcweir */
151*cdf0e10cSrcweir 		default: break;
152*cdf0e10cSrcweir 	}
153*cdf0e10cSrcweir 	return bRet;
154*cdf0e10cSrcweir }
155*cdf0e10cSrcweir 
156*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
157*cdf0e10cSrcweir // #i37011# create a clone with all attributes changed to shadow attributes
158*cdf0e10cSrcweir // and translation executed, too.
159*cdf0e10cSrcweir SdrObject* ImpCreateShadowObjectClone(const SdrObject& rOriginal, const SfxItemSet& rOriginalSet)
160*cdf0e10cSrcweir {
161*cdf0e10cSrcweir 	SdrObject* pRetval = 0L;
162*cdf0e10cSrcweir 	const sal_Bool bShadow(((SdrShadowItem&)rOriginalSet.Get(SDRATTR_SHADOW)).GetValue());
163*cdf0e10cSrcweir 
164*cdf0e10cSrcweir 	if(bShadow)
165*cdf0e10cSrcweir 	{
166*cdf0e10cSrcweir 		// create a shadow representing object
167*cdf0e10cSrcweir 		const sal_Int32 nXDist(((SdrShadowXDistItem&)(rOriginalSet.Get(SDRATTR_SHADOWXDIST))).GetValue());
168*cdf0e10cSrcweir 		const sal_Int32 nYDist(((SdrShadowYDistItem&)(rOriginalSet.Get(SDRATTR_SHADOWYDIST))).GetValue());
169*cdf0e10cSrcweir 		const ::Color aShadowColor(((SdrShadowColorItem&)(rOriginalSet.Get(SDRATTR_SHADOWCOLOR))).GetColorValue());
170*cdf0e10cSrcweir 		const sal_uInt16 nShadowTransparence(((SdrShadowTransparenceItem&)(rOriginalSet.Get(SDRATTR_SHADOWTRANSPARENCE))).GetValue());
171*cdf0e10cSrcweir 		pRetval = rOriginal.Clone();
172*cdf0e10cSrcweir 		DBG_ASSERT(pRetval, "ImpCreateShadowObjectClone: Could not clone object (!)");
173*cdf0e10cSrcweir 
174*cdf0e10cSrcweir 		// look for used stuff
175*cdf0e10cSrcweir 		SdrObjListIter aIterator(rOriginal);
176*cdf0e10cSrcweir 		sal_Bool bLineUsed(sal_False);
177*cdf0e10cSrcweir 		sal_Bool bAllFillUsed(sal_False);
178*cdf0e10cSrcweir 		sal_Bool bSolidFillUsed(sal_False);
179*cdf0e10cSrcweir 		sal_Bool bGradientFillUsed(sal_False);
180*cdf0e10cSrcweir 		sal_Bool bHatchFillUsed(sal_False);
181*cdf0e10cSrcweir 		sal_Bool bBitmapFillUsed(sal_False);
182*cdf0e10cSrcweir 
183*cdf0e10cSrcweir 		while(aIterator.IsMore())
184*cdf0e10cSrcweir 		{
185*cdf0e10cSrcweir 			SdrObject* pObj = aIterator.Next();
186*cdf0e10cSrcweir 			XFillStyle eFillStyle = ((XFillStyleItem&)(pObj->GetMergedItem(XATTR_FILLSTYLE))).GetValue();
187*cdf0e10cSrcweir 
188*cdf0e10cSrcweir 			if(!bLineUsed)
189*cdf0e10cSrcweir 			{
190*cdf0e10cSrcweir 				XLineStyle eLineStyle = ((XLineStyleItem&)(pObj->GetMergedItem(XATTR_LINESTYLE))).GetValue();
191*cdf0e10cSrcweir 
192*cdf0e10cSrcweir 				if(XLINE_NONE != eLineStyle)
193*cdf0e10cSrcweir 				{
194*cdf0e10cSrcweir 					bLineUsed = sal_True;
195*cdf0e10cSrcweir 				}
196*cdf0e10cSrcweir 			}
197*cdf0e10cSrcweir 
198*cdf0e10cSrcweir 			if(!bAllFillUsed)
199*cdf0e10cSrcweir 			{
200*cdf0e10cSrcweir 				if(!bSolidFillUsed && XFILL_SOLID == eFillStyle)
201*cdf0e10cSrcweir 				{
202*cdf0e10cSrcweir 					bSolidFillUsed = sal_True;
203*cdf0e10cSrcweir 					bAllFillUsed = (bSolidFillUsed || bGradientFillUsed || bHatchFillUsed || bBitmapFillUsed);
204*cdf0e10cSrcweir 				}
205*cdf0e10cSrcweir 				if(!bGradientFillUsed && XFILL_GRADIENT == eFillStyle)
206*cdf0e10cSrcweir 				{
207*cdf0e10cSrcweir 					bGradientFillUsed = sal_True;
208*cdf0e10cSrcweir 					bAllFillUsed = (bSolidFillUsed || bGradientFillUsed || bHatchFillUsed || bBitmapFillUsed);
209*cdf0e10cSrcweir 				}
210*cdf0e10cSrcweir 				if(!bHatchFillUsed && XFILL_HATCH == eFillStyle)
211*cdf0e10cSrcweir 				{
212*cdf0e10cSrcweir 					bHatchFillUsed = sal_True;
213*cdf0e10cSrcweir 					bAllFillUsed = (bSolidFillUsed || bGradientFillUsed || bHatchFillUsed || bBitmapFillUsed);
214*cdf0e10cSrcweir 				}
215*cdf0e10cSrcweir 				if(!bBitmapFillUsed && XFILL_BITMAP == eFillStyle)
216*cdf0e10cSrcweir 				{
217*cdf0e10cSrcweir 					bBitmapFillUsed = sal_True;
218*cdf0e10cSrcweir 					bAllFillUsed = (bSolidFillUsed || bGradientFillUsed || bHatchFillUsed || bBitmapFillUsed);
219*cdf0e10cSrcweir 				}
220*cdf0e10cSrcweir 			}
221*cdf0e10cSrcweir 		}
222*cdf0e10cSrcweir 
223*cdf0e10cSrcweir 		// translate to shadow coordinates
224*cdf0e10cSrcweir 		pRetval->NbcMove(Size(nXDist, nYDist));
225*cdf0e10cSrcweir 
226*cdf0e10cSrcweir 		// set items as needed
227*cdf0e10cSrcweir 		SfxItemSet aTempSet(rOriginalSet);
228*cdf0e10cSrcweir 
229*cdf0e10cSrcweir 		// SJ: #40108# :-(  if a SvxWritingModeItem (Top->Bottom) is set the text object
230*cdf0e10cSrcweir 		// is creating a paraobject, but paraobjects can not be created without model. So
231*cdf0e10cSrcweir 		// we are preventing the crash by setting the writing mode always left to right,
232*cdf0e10cSrcweir 		// this is not bad since our shadow geometry does not contain text.
233*cdf0e10cSrcweir         aTempSet.Put( SvxWritingModeItem( com::sun::star::text::WritingMode_LR_TB, SDRATTR_TEXTDIRECTION ) );
234*cdf0e10cSrcweir 
235*cdf0e10cSrcweir 		// no shadow
236*cdf0e10cSrcweir 		aTempSet.Put(SdrShadowItem(sal_False));
237*cdf0e10cSrcweir 		aTempSet.Put(SdrShadowXDistItem(0L));
238*cdf0e10cSrcweir 		aTempSet.Put(SdrShadowYDistItem(0L));
239*cdf0e10cSrcweir 
240*cdf0e10cSrcweir 		// line color and transparence like shadow
241*cdf0e10cSrcweir 		if(bLineUsed)
242*cdf0e10cSrcweir 		{
243*cdf0e10cSrcweir 			aTempSet.Put(XLineColorItem(String(), aShadowColor));
244*cdf0e10cSrcweir 			aTempSet.Put(XLineTransparenceItem(nShadowTransparence));
245*cdf0e10cSrcweir 		}
246*cdf0e10cSrcweir 
247*cdf0e10cSrcweir 		// fill color and transparence like shadow
248*cdf0e10cSrcweir 		if(bSolidFillUsed)
249*cdf0e10cSrcweir 		{
250*cdf0e10cSrcweir 			aTempSet.Put(XFillColorItem(String(), aShadowColor));
251*cdf0e10cSrcweir 			aTempSet.Put(XFillTransparenceItem(nShadowTransparence));
252*cdf0e10cSrcweir 		}
253*cdf0e10cSrcweir 
254*cdf0e10cSrcweir 		// gradient and transparence like shadow
255*cdf0e10cSrcweir 		if(bGradientFillUsed)
256*cdf0e10cSrcweir 		{
257*cdf0e10cSrcweir 			XGradient aGradient(((XFillGradientItem&)(rOriginalSet.Get(XATTR_FILLGRADIENT))).GetGradientValue());
258*cdf0e10cSrcweir 			sal_uInt8 nStartLuminance(aGradient.GetStartColor().GetLuminance());
259*cdf0e10cSrcweir 			sal_uInt8 nEndLuminance(aGradient.GetEndColor().GetLuminance());
260*cdf0e10cSrcweir 
261*cdf0e10cSrcweir 			if(aGradient.GetStartIntens() != 100)
262*cdf0e10cSrcweir 			{
263*cdf0e10cSrcweir 				nStartLuminance = (sal_uInt8)(nStartLuminance * ((double)aGradient.GetStartIntens() / 100.0));
264*cdf0e10cSrcweir 			}
265*cdf0e10cSrcweir 
266*cdf0e10cSrcweir 			if(aGradient.GetEndIntens() != 100)
267*cdf0e10cSrcweir 			{
268*cdf0e10cSrcweir 				nEndLuminance = (sal_uInt8)(nEndLuminance * ((double)aGradient.GetEndIntens() / 100.0));
269*cdf0e10cSrcweir 			}
270*cdf0e10cSrcweir 
271*cdf0e10cSrcweir             ::Color aStartColor(
272*cdf0e10cSrcweir 				(sal_uInt8)((nStartLuminance * aShadowColor.GetRed()) / 256),
273*cdf0e10cSrcweir 				(sal_uInt8)((nStartLuminance * aShadowColor.GetGreen()) / 256),
274*cdf0e10cSrcweir 				(sal_uInt8)((nStartLuminance * aShadowColor.GetBlue()) / 256));
275*cdf0e10cSrcweir 
276*cdf0e10cSrcweir             ::Color aEndColor(
277*cdf0e10cSrcweir 				(sal_uInt8)((nEndLuminance * aShadowColor.GetRed()) / 256),
278*cdf0e10cSrcweir 				(sal_uInt8)((nEndLuminance * aShadowColor.GetGreen()) / 256),
279*cdf0e10cSrcweir 				(sal_uInt8)((nEndLuminance * aShadowColor.GetBlue()) / 256));
280*cdf0e10cSrcweir 
281*cdf0e10cSrcweir 			aGradient.SetStartColor(aStartColor);
282*cdf0e10cSrcweir 			aGradient.SetEndColor(aEndColor);
283*cdf0e10cSrcweir 			aTempSet.Put(XFillGradientItem(aTempSet.GetPool(), aGradient));
284*cdf0e10cSrcweir 			aTempSet.Put(XFillTransparenceItem(nShadowTransparence));
285*cdf0e10cSrcweir 		}
286*cdf0e10cSrcweir 
287*cdf0e10cSrcweir 		// hatch and transparence like shadow
288*cdf0e10cSrcweir 		if(bHatchFillUsed)
289*cdf0e10cSrcweir 		{
290*cdf0e10cSrcweir 			XHatch aHatch(((XFillHatchItem&)(rOriginalSet.Get(XATTR_FILLHATCH))).GetHatchValue());
291*cdf0e10cSrcweir 			aHatch.SetColor(aShadowColor);
292*cdf0e10cSrcweir 			aTempSet.Put(XFillHatchItem(aTempSet.GetPool(), aHatch));
293*cdf0e10cSrcweir 			aTempSet.Put(XFillTransparenceItem(nShadowTransparence));
294*cdf0e10cSrcweir 		}
295*cdf0e10cSrcweir 
296*cdf0e10cSrcweir 		// bitmap and transparence like shadow
297*cdf0e10cSrcweir 		if(bBitmapFillUsed)
298*cdf0e10cSrcweir 		{
299*cdf0e10cSrcweir 			XOBitmap aFillBitmap(((XFillBitmapItem&)(rOriginalSet.Get(XATTR_FILLBITMAP))).GetBitmapValue());
300*cdf0e10cSrcweir 			Bitmap aSourceBitmap(aFillBitmap.GetBitmap());
301*cdf0e10cSrcweir 			BitmapReadAccess* pReadAccess = aSourceBitmap.AcquireReadAccess();
302*cdf0e10cSrcweir 
303*cdf0e10cSrcweir 			if(!aSourceBitmap.IsEmpty())
304*cdf0e10cSrcweir 			{
305*cdf0e10cSrcweir 				if(pReadAccess)
306*cdf0e10cSrcweir 				{
307*cdf0e10cSrcweir 					Bitmap aDestBitmap(aSourceBitmap.GetSizePixel(), 24L);
308*cdf0e10cSrcweir 					BitmapWriteAccess* pWriteAccess = aDestBitmap.AcquireWriteAccess();
309*cdf0e10cSrcweir 
310*cdf0e10cSrcweir 					if(pWriteAccess)
311*cdf0e10cSrcweir 					{
312*cdf0e10cSrcweir 						for(sal_Int32 y(0L); y < pReadAccess->Height(); y++)
313*cdf0e10cSrcweir 						{
314*cdf0e10cSrcweir 							for(sal_Int32 x(0L); x < pReadAccess->Width(); x++)
315*cdf0e10cSrcweir 							{
316*cdf0e10cSrcweir 								sal_uInt16 nLuminance((sal_uInt16)pReadAccess->GetLuminance(y, x) + 1);
317*cdf0e10cSrcweir 								const BitmapColor aDestColor(
318*cdf0e10cSrcweir 									(sal_uInt8)((nLuminance * (sal_uInt16)aShadowColor.GetRed()) >> 8L),
319*cdf0e10cSrcweir 									(sal_uInt8)((nLuminance * (sal_uInt16)aShadowColor.GetGreen()) >> 8L),
320*cdf0e10cSrcweir 									(sal_uInt8)((nLuminance * (sal_uInt16)aShadowColor.GetBlue()) >> 8L));
321*cdf0e10cSrcweir 								pWriteAccess->SetPixel(y, x, aDestColor);
322*cdf0e10cSrcweir 							}
323*cdf0e10cSrcweir 						}
324*cdf0e10cSrcweir 
325*cdf0e10cSrcweir 						aDestBitmap.ReleaseAccess(pWriteAccess);
326*cdf0e10cSrcweir 						aFillBitmap.SetBitmap(aDestBitmap);
327*cdf0e10cSrcweir 					}
328*cdf0e10cSrcweir 
329*cdf0e10cSrcweir 					aSourceBitmap.ReleaseAccess(pReadAccess);
330*cdf0e10cSrcweir 				}
331*cdf0e10cSrcweir 			}
332*cdf0e10cSrcweir 
333*cdf0e10cSrcweir 			aTempSet.Put(XFillBitmapItem(aTempSet.GetPool(), aFillBitmap));
334*cdf0e10cSrcweir 			aTempSet.Put(XFillTransparenceItem(nShadowTransparence));
335*cdf0e10cSrcweir 		}
336*cdf0e10cSrcweir 
337*cdf0e10cSrcweir 		// set attributes and paint shadow object
338*cdf0e10cSrcweir 		pRetval->SetMergedItemSet( aTempSet );
339*cdf0e10cSrcweir 	}
340*cdf0e10cSrcweir 	return pRetval;
341*cdf0e10cSrcweir }
342*cdf0e10cSrcweir 
343*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
344*cdf0e10cSrcweir 
345*cdf0e10cSrcweir Reference< XCustomShapeEngine > SdrObjCustomShape::GetCustomShapeEngine( const SdrObjCustomShape* pCustomShape )
346*cdf0e10cSrcweir {
347*cdf0e10cSrcweir 	Reference< XCustomShapeEngine > xCustomShapeEngine;
348*cdf0e10cSrcweir 	String aEngine(((SdrCustomShapeEngineItem&)pCustomShape->GetMergedItem( SDRATTR_CUSTOMSHAPE_ENGINE )).GetValue());
349*cdf0e10cSrcweir 	if ( !aEngine.Len() )
350*cdf0e10cSrcweir 		aEngine = String( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.drawing.EnhancedCustomShapeEngine" ) );
351*cdf0e10cSrcweir 
352*cdf0e10cSrcweir 	Reference< XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() );
353*cdf0e10cSrcweir 
354*cdf0e10cSrcweir 	Reference< XShape > aXShape = GetXShapeForSdrObject( (SdrObjCustomShape*)pCustomShape );
355*cdf0e10cSrcweir 	if ( aXShape.is() )
356*cdf0e10cSrcweir 	{
357*cdf0e10cSrcweir 		if ( aEngine.Len() && xFactory.is() )
358*cdf0e10cSrcweir 		{
359*cdf0e10cSrcweir 			Sequence< Any > aArgument( 1 );
360*cdf0e10cSrcweir 			Sequence< PropertyValue > aPropValues( 1 );
361*cdf0e10cSrcweir 			aPropValues[ 0 ].Name = rtl::OUString::createFromAscii( "CustomShape" );
362*cdf0e10cSrcweir 			aPropValues[ 0 ].Value <<= aXShape;
363*cdf0e10cSrcweir 			aArgument[ 0 ] <<= aPropValues;
364*cdf0e10cSrcweir 			Reference< XInterface > xInterface( xFactory->createInstanceWithArguments( aEngine, aArgument ) );
365*cdf0e10cSrcweir 			if ( xInterface.is() )
366*cdf0e10cSrcweir 				xCustomShapeEngine = Reference< XCustomShapeEngine >( xInterface, UNO_QUERY );
367*cdf0e10cSrcweir 		}
368*cdf0e10cSrcweir 	}
369*cdf0e10cSrcweir 	return xCustomShapeEngine;
370*cdf0e10cSrcweir }
371*cdf0e10cSrcweir const SdrObject* SdrObjCustomShape::GetSdrObjectFromCustomShape() const
372*cdf0e10cSrcweir {
373*cdf0e10cSrcweir 	if ( !mXRenderedCustomShape.is() )
374*cdf0e10cSrcweir 	{
375*cdf0e10cSrcweir 		Reference< XCustomShapeEngine > xCustomShapeEngine( GetCustomShapeEngine( this ) );
376*cdf0e10cSrcweir 		if ( xCustomShapeEngine.is() )
377*cdf0e10cSrcweir 			((SdrObjCustomShape*)this)->mXRenderedCustomShape = xCustomShapeEngine->render();
378*cdf0e10cSrcweir 	}
379*cdf0e10cSrcweir 	SdrObject* pRenderedCustomShape = mXRenderedCustomShape.is()
380*cdf0e10cSrcweir 				? GetSdrObjectFromXShape( mXRenderedCustomShape )
381*cdf0e10cSrcweir 				: NULL;
382*cdf0e10cSrcweir 	return pRenderedCustomShape;
383*cdf0e10cSrcweir }
384*cdf0e10cSrcweir 
385*cdf0e10cSrcweir // #i37011# Shadow geometry creation
386*cdf0e10cSrcweir const SdrObject* SdrObjCustomShape::GetSdrObjectShadowFromCustomShape() const
387*cdf0e10cSrcweir {
388*cdf0e10cSrcweir 	if(!mpLastShadowGeometry)
389*cdf0e10cSrcweir 	{
390*cdf0e10cSrcweir 		const SdrObject* pSdrObject = GetSdrObjectFromCustomShape();
391*cdf0e10cSrcweir 		if(pSdrObject)
392*cdf0e10cSrcweir 		{
393*cdf0e10cSrcweir 			const SfxItemSet& rOriginalSet = GetObjectItemSet();
394*cdf0e10cSrcweir 			const sal_Bool bShadow(((SdrShadowItem&)rOriginalSet.Get( SDRATTR_SHADOW )).GetValue());
395*cdf0e10cSrcweir 
396*cdf0e10cSrcweir 			if(bShadow)
397*cdf0e10cSrcweir 			{
398*cdf0e10cSrcweir 				// create a clone with all attributes changed to shadow attributes
399*cdf0e10cSrcweir 				// and translation executed, too.
400*cdf0e10cSrcweir 				((SdrObjCustomShape*)this)->mpLastShadowGeometry = ImpCreateShadowObjectClone(*pSdrObject, rOriginalSet);
401*cdf0e10cSrcweir 			}
402*cdf0e10cSrcweir 		}
403*cdf0e10cSrcweir 	}
404*cdf0e10cSrcweir 
405*cdf0e10cSrcweir 	return mpLastShadowGeometry;
406*cdf0e10cSrcweir }
407*cdf0e10cSrcweir 
408*cdf0e10cSrcweir sal_Bool SdrObjCustomShape::IsTextPath() const
409*cdf0e10cSrcweir {
410*cdf0e10cSrcweir 	const rtl::OUString	sTextPath( RTL_CONSTASCII_USTRINGPARAM ( "TextPath" ) );
411*cdf0e10cSrcweir 	sal_Bool bTextPathOn = sal_False;
412*cdf0e10cSrcweir 	SdrCustomShapeGeometryItem& rGeometryItem = (SdrCustomShapeGeometryItem&)GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY );
413*cdf0e10cSrcweir 	Any* pAny = rGeometryItem.GetPropertyValueByName( sTextPath, sTextPath );
414*cdf0e10cSrcweir 	if ( pAny )
415*cdf0e10cSrcweir 		*pAny >>= bTextPathOn;
416*cdf0e10cSrcweir 	return bTextPathOn;
417*cdf0e10cSrcweir }
418*cdf0e10cSrcweir 
419*cdf0e10cSrcweir sal_Bool SdrObjCustomShape::UseNoFillStyle() const
420*cdf0e10cSrcweir {
421*cdf0e10cSrcweir 	sal_Bool bRet = sal_False;
422*cdf0e10cSrcweir 	rtl::OUString sShapeType;
423*cdf0e10cSrcweir 	const rtl::OUString	sType( RTL_CONSTASCII_USTRINGPARAM ( "Type" ) );
424*cdf0e10cSrcweir 	SdrCustomShapeGeometryItem& rGeometryItem( (SdrCustomShapeGeometryItem&)GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) );
425*cdf0e10cSrcweir 	Any* pAny = rGeometryItem.GetPropertyValueByName( sType );
426*cdf0e10cSrcweir 	if ( pAny )
427*cdf0e10cSrcweir 		*pAny >>= sShapeType;
428*cdf0e10cSrcweir 	bRet = IsCustomShapeFilledByDefault( EnhancedCustomShapeTypeNames::Get( sType ) ) == 0;
429*cdf0e10cSrcweir 
430*cdf0e10cSrcweir 	return bRet;
431*cdf0e10cSrcweir }
432*cdf0e10cSrcweir 
433*cdf0e10cSrcweir sal_Bool SdrObjCustomShape::IsMirroredX() const
434*cdf0e10cSrcweir {
435*cdf0e10cSrcweir 	sal_Bool bMirroredX = sal_False;
436*cdf0e10cSrcweir 	SdrCustomShapeGeometryItem aGeometryItem( (SdrCustomShapeGeometryItem&)GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) );
437*cdf0e10cSrcweir 	const rtl::OUString	sMirroredX( RTL_CONSTASCII_USTRINGPARAM ( "MirroredX" ) );
438*cdf0e10cSrcweir 	com::sun::star::uno::Any* pAny = aGeometryItem.GetPropertyValueByName( sMirroredX );
439*cdf0e10cSrcweir 	if ( pAny )
440*cdf0e10cSrcweir 		*pAny >>= bMirroredX;
441*cdf0e10cSrcweir 	return bMirroredX;
442*cdf0e10cSrcweir }
443*cdf0e10cSrcweir sal_Bool SdrObjCustomShape::IsMirroredY() const
444*cdf0e10cSrcweir {
445*cdf0e10cSrcweir 	sal_Bool bMirroredY = sal_False;
446*cdf0e10cSrcweir 	SdrCustomShapeGeometryItem aGeometryItem( (SdrCustomShapeGeometryItem&)GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) );
447*cdf0e10cSrcweir 	const rtl::OUString	sMirroredY( RTL_CONSTASCII_USTRINGPARAM ( "MirroredY" ) );
448*cdf0e10cSrcweir 	com::sun::star::uno::Any* pAny = aGeometryItem.GetPropertyValueByName( sMirroredY );
449*cdf0e10cSrcweir 	if ( pAny )
450*cdf0e10cSrcweir 		*pAny >>= bMirroredY;
451*cdf0e10cSrcweir 	return bMirroredY;
452*cdf0e10cSrcweir }
453*cdf0e10cSrcweir void SdrObjCustomShape::SetMirroredX( const sal_Bool bMirrorX )
454*cdf0e10cSrcweir {
455*cdf0e10cSrcweir 	SdrCustomShapeGeometryItem aGeometryItem( (SdrCustomShapeGeometryItem&)GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) );
456*cdf0e10cSrcweir 	const rtl::OUString	sMirroredX( RTL_CONSTASCII_USTRINGPARAM ( "MirroredX" ) );
457*cdf0e10cSrcweir 	//com::sun::star::uno::Any* pAny = aGeometryItem.GetPropertyValueByName( sMirroredX );
458*cdf0e10cSrcweir 	PropertyValue aPropVal;
459*cdf0e10cSrcweir 	aPropVal.Name = sMirroredX;
460*cdf0e10cSrcweir 	aPropVal.Value <<= bMirrorX;
461*cdf0e10cSrcweir 	aGeometryItem.SetPropertyValue( aPropVal );
462*cdf0e10cSrcweir 	SetMergedItem( aGeometryItem );
463*cdf0e10cSrcweir }
464*cdf0e10cSrcweir void SdrObjCustomShape::SetMirroredY( const sal_Bool bMirrorY )
465*cdf0e10cSrcweir {
466*cdf0e10cSrcweir 	SdrCustomShapeGeometryItem aGeometryItem( (SdrCustomShapeGeometryItem&)GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) );
467*cdf0e10cSrcweir 	const rtl::OUString	sMirroredY( RTL_CONSTASCII_USTRINGPARAM ( "MirroredY" ) );
468*cdf0e10cSrcweir 	//com::sun::star::uno::Any* pAny = aGeometryItem.GetPropertyValueByName( sMirroredY );
469*cdf0e10cSrcweir 	PropertyValue aPropVal;
470*cdf0e10cSrcweir 	aPropVal.Name = sMirroredY;
471*cdf0e10cSrcweir 	aPropVal.Value <<= bMirrorY;
472*cdf0e10cSrcweir 	aGeometryItem.SetPropertyValue( aPropVal );
473*cdf0e10cSrcweir 	SetMergedItem( aGeometryItem );
474*cdf0e10cSrcweir }
475*cdf0e10cSrcweir 
476*cdf0e10cSrcweir double SdrObjCustomShape::GetObjectRotation() const
477*cdf0e10cSrcweir {
478*cdf0e10cSrcweir 	return fObjectRotation;
479*cdf0e10cSrcweir }
480*cdf0e10cSrcweir 
481*cdf0e10cSrcweir double SdrObjCustomShape::GetExtraTextRotation() const
482*cdf0e10cSrcweir {
483*cdf0e10cSrcweir 	const com::sun::star::uno::Any* pAny;
484*cdf0e10cSrcweir 	SdrCustomShapeGeometryItem& rGeometryItem = (SdrCustomShapeGeometryItem&)GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY );
485*cdf0e10cSrcweir 	const rtl::OUString sTextRotateAngle( RTL_CONSTASCII_USTRINGPARAM ( "TextRotateAngle" ) );
486*cdf0e10cSrcweir 	pAny = rGeometryItem.GetPropertyValueByName( sTextRotateAngle );
487*cdf0e10cSrcweir 	double fExtraTextRotateAngle = 0.0;
488*cdf0e10cSrcweir 	if ( pAny )
489*cdf0e10cSrcweir 		*pAny >>= fExtraTextRotateAngle;
490*cdf0e10cSrcweir 	return fExtraTextRotateAngle;
491*cdf0e10cSrcweir }
492*cdf0e10cSrcweir sal_Bool SdrObjCustomShape::GetTextBounds( Rectangle& rTextBound ) const
493*cdf0e10cSrcweir {
494*cdf0e10cSrcweir 	sal_Bool bRet = sal_False;
495*cdf0e10cSrcweir 	Reference< XCustomShapeEngine > xCustomShapeEngine( GetCustomShapeEngine( this ) );	// a candidate for being cached
496*cdf0e10cSrcweir 	if ( xCustomShapeEngine.is() )
497*cdf0e10cSrcweir 	{
498*cdf0e10cSrcweir 		awt::Rectangle aR( xCustomShapeEngine->getTextBounds() );
499*cdf0e10cSrcweir 		if ( aR.Width || aR.Height )
500*cdf0e10cSrcweir 		{
501*cdf0e10cSrcweir 			rTextBound = Rectangle( Point( aR.X, aR.Y ), Size( aR.Width, aR.Height ) );
502*cdf0e10cSrcweir 			bRet = sal_True;
503*cdf0e10cSrcweir 		}
504*cdf0e10cSrcweir 	}
505*cdf0e10cSrcweir 	return bRet;
506*cdf0e10cSrcweir }
507*cdf0e10cSrcweir basegfx::B2DPolyPolygon SdrObjCustomShape::GetLineGeometry( const SdrObjCustomShape* pCustomShape, const sal_Bool bBezierAllowed )
508*cdf0e10cSrcweir {
509*cdf0e10cSrcweir 	basegfx::B2DPolyPolygon aRetval;
510*cdf0e10cSrcweir 	sal_Bool bRet = sal_False;
511*cdf0e10cSrcweir 	Reference< XCustomShapeEngine > xCustomShapeEngine( GetCustomShapeEngine( pCustomShape ) );
512*cdf0e10cSrcweir 	if ( xCustomShapeEngine.is() )
513*cdf0e10cSrcweir 	{
514*cdf0e10cSrcweir 		com::sun::star::drawing::PolyPolygonBezierCoords aBezierCoords = xCustomShapeEngine->getLineGeometry();
515*cdf0e10cSrcweir 		try
516*cdf0e10cSrcweir 		{
517*cdf0e10cSrcweir 			aRetval = SvxConvertPolyPolygonBezierToB2DPolyPolygon( &aBezierCoords );
518*cdf0e10cSrcweir 			if ( !bBezierAllowed && aRetval.areControlPointsUsed())
519*cdf0e10cSrcweir 			{
520*cdf0e10cSrcweir 				aRetval = basegfx::tools::adaptiveSubdivideByAngle(aRetval);
521*cdf0e10cSrcweir 			}
522*cdf0e10cSrcweir 			bRet = sal_True;
523*cdf0e10cSrcweir 		}
524*cdf0e10cSrcweir 		catch ( const com::sun::star::lang::IllegalArgumentException )
525*cdf0e10cSrcweir 		{
526*cdf0e10cSrcweir 		}
527*cdf0e10cSrcweir 	}
528*cdf0e10cSrcweir 	return aRetval;
529*cdf0e10cSrcweir }
530*cdf0e10cSrcweir 
531*cdf0e10cSrcweir std::vector< SdrCustomShapeInteraction > SdrObjCustomShape::GetInteractionHandles( const SdrObjCustomShape* pCustomShape ) const
532*cdf0e10cSrcweir {
533*cdf0e10cSrcweir 	std::vector< SdrCustomShapeInteraction > xRet;
534*cdf0e10cSrcweir 	try
535*cdf0e10cSrcweir 	{
536*cdf0e10cSrcweir 		Reference< XCustomShapeEngine > xCustomShapeEngine( GetCustomShapeEngine( pCustomShape ) );
537*cdf0e10cSrcweir 		if ( xCustomShapeEngine.is() )
538*cdf0e10cSrcweir 		{
539*cdf0e10cSrcweir 			int i;
540*cdf0e10cSrcweir 			Sequence< Reference< XCustomShapeHandle > > xInteractionHandles( xCustomShapeEngine->getInteraction() );
541*cdf0e10cSrcweir 			for ( i = 0; i < xInteractionHandles.getLength(); i++ )
542*cdf0e10cSrcweir 			{
543*cdf0e10cSrcweir 				if ( xInteractionHandles[ i ].is() )
544*cdf0e10cSrcweir 				{
545*cdf0e10cSrcweir 					SdrCustomShapeInteraction aSdrCustomShapeInteraction;
546*cdf0e10cSrcweir 					aSdrCustomShapeInteraction.xInteraction = xInteractionHandles[ i ];
547*cdf0e10cSrcweir 					aSdrCustomShapeInteraction.aPosition = xInteractionHandles[ i ]->getPosition();
548*cdf0e10cSrcweir 
549*cdf0e10cSrcweir 					sal_Int32 nMode = 0;
550*cdf0e10cSrcweir 					switch( ImpGetCustomShapeType( *this ) )
551*cdf0e10cSrcweir 					{
552*cdf0e10cSrcweir 						case mso_sptAccentBorderCallout90 :		// 2 ortho
553*cdf0e10cSrcweir 						{
554*cdf0e10cSrcweir 							if ( !i )
555*cdf0e10cSrcweir 								nMode |= CUSTOMSHAPE_HANDLE_RESIZE_FIXED | CUSTOMSHAPE_HANDLE_CREATE_FIXED;
556*cdf0e10cSrcweir 							else if ( i == 1)
557*cdf0e10cSrcweir 								nMode |= CUSTOMSHAPE_HANDLE_RESIZE_ABSOLUTE_X | CUSTOMSHAPE_HANDLE_RESIZE_ABSOLUTE_Y | CUSTOMSHAPE_HANDLE_MOVE_SHAPE | CUSTOMSHAPE_HANDLE_ORTHO4;
558*cdf0e10cSrcweir 						}
559*cdf0e10cSrcweir 						break;
560*cdf0e10cSrcweir 
561*cdf0e10cSrcweir 						case mso_sptWedgeRectCallout :
562*cdf0e10cSrcweir 						case mso_sptWedgeRRectCallout :
563*cdf0e10cSrcweir 						case mso_sptCloudCallout :
564*cdf0e10cSrcweir 						case mso_sptWedgeEllipseCallout :
565*cdf0e10cSrcweir 						{
566*cdf0e10cSrcweir 							if ( !i )
567*cdf0e10cSrcweir 								nMode |= CUSTOMSHAPE_HANDLE_RESIZE_FIXED;
568*cdf0e10cSrcweir 						}
569*cdf0e10cSrcweir 						break;
570*cdf0e10cSrcweir 
571*cdf0e10cSrcweir 						case mso_sptBorderCallout1 :			// 2 diag
572*cdf0e10cSrcweir 						{
573*cdf0e10cSrcweir 							if ( !i )
574*cdf0e10cSrcweir 								nMode |= CUSTOMSHAPE_HANDLE_RESIZE_FIXED | CUSTOMSHAPE_HANDLE_CREATE_FIXED;
575*cdf0e10cSrcweir 							else if ( i == 1 )
576*cdf0e10cSrcweir 								nMode |= CUSTOMSHAPE_HANDLE_RESIZE_ABSOLUTE_X | CUSTOMSHAPE_HANDLE_RESIZE_ABSOLUTE_Y | CUSTOMSHAPE_HANDLE_MOVE_SHAPE;
577*cdf0e10cSrcweir 						}
578*cdf0e10cSrcweir 						break;
579*cdf0e10cSrcweir 						case mso_sptBorderCallout2 :			// 3
580*cdf0e10cSrcweir 						{
581*cdf0e10cSrcweir 							if ( !i )
582*cdf0e10cSrcweir 								nMode |= CUSTOMSHAPE_HANDLE_RESIZE_FIXED | CUSTOMSHAPE_HANDLE_CREATE_FIXED;
583*cdf0e10cSrcweir 							else if ( i == 2 )
584*cdf0e10cSrcweir 								nMode |= CUSTOMSHAPE_HANDLE_RESIZE_ABSOLUTE_X | CUSTOMSHAPE_HANDLE_RESIZE_ABSOLUTE_Y | CUSTOMSHAPE_HANDLE_MOVE_SHAPE;
585*cdf0e10cSrcweir 						}
586*cdf0e10cSrcweir 						break;
587*cdf0e10cSrcweir 						case mso_sptCallout90 :
588*cdf0e10cSrcweir 						case mso_sptAccentCallout90 :
589*cdf0e10cSrcweir 						case mso_sptBorderCallout90 :
590*cdf0e10cSrcweir 						case mso_sptCallout1 :
591*cdf0e10cSrcweir 						case mso_sptCallout2 :
592*cdf0e10cSrcweir 						case mso_sptCallout3 :
593*cdf0e10cSrcweir 						case mso_sptAccentCallout1 :
594*cdf0e10cSrcweir 						case mso_sptAccentCallout2 :
595*cdf0e10cSrcweir 						case mso_sptAccentCallout3 :
596*cdf0e10cSrcweir 						case mso_sptBorderCallout3 :
597*cdf0e10cSrcweir 						case mso_sptAccentBorderCallout1 :
598*cdf0e10cSrcweir 						case mso_sptAccentBorderCallout2 :
599*cdf0e10cSrcweir 						case mso_sptAccentBorderCallout3 :
600*cdf0e10cSrcweir 						{
601*cdf0e10cSrcweir 							if ( !i )
602*cdf0e10cSrcweir 								nMode |= CUSTOMSHAPE_HANDLE_RESIZE_FIXED | CUSTOMSHAPE_HANDLE_CREATE_FIXED;
603*cdf0e10cSrcweir 						}
604*cdf0e10cSrcweir 						break;
605*cdf0e10cSrcweir 						default: break;
606*cdf0e10cSrcweir 					}
607*cdf0e10cSrcweir 					aSdrCustomShapeInteraction.nMode = nMode;
608*cdf0e10cSrcweir 					xRet.push_back( aSdrCustomShapeInteraction );
609*cdf0e10cSrcweir 				}
610*cdf0e10cSrcweir 			}
611*cdf0e10cSrcweir 		}
612*cdf0e10cSrcweir 	}
613*cdf0e10cSrcweir 	catch( const uno::RuntimeException& )
614*cdf0e10cSrcweir 	{
615*cdf0e10cSrcweir 	}
616*cdf0e10cSrcweir 	return xRet;
617*cdf0e10cSrcweir }
618*cdf0e10cSrcweir 
619*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
620*cdf0e10cSrcweir // BaseProperties section
621*cdf0e10cSrcweir #define	DEFAULT_MINIMUM_SIGNED_COMPARE	((sal_Int32)0x80000000)
622*cdf0e10cSrcweir #define	DEFAULT_MAXIMUM_SIGNED_COMPARE	((sal_Int32)0x7fffffff)
623*cdf0e10cSrcweir 
624*cdf0e10cSrcweir sdr::properties::BaseProperties* SdrObjCustomShape::CreateObjectSpecificProperties()
625*cdf0e10cSrcweir {
626*cdf0e10cSrcweir 	return new sdr::properties::CustomShapeProperties(*this);
627*cdf0e10cSrcweir }
628*cdf0e10cSrcweir 
629*cdf0e10cSrcweir TYPEINIT1(SdrObjCustomShape,SdrTextObj);
630*cdf0e10cSrcweir SdrObjCustomShape::SdrObjCustomShape() :
631*cdf0e10cSrcweir 	SdrTextObj(),
632*cdf0e10cSrcweir 	fObjectRotation( 0.0 ),
633*cdf0e10cSrcweir 	mpLastShadowGeometry(0L)
634*cdf0e10cSrcweir {
635*cdf0e10cSrcweir 	bTextFrame = sal_True;
636*cdf0e10cSrcweir }
637*cdf0e10cSrcweir 
638*cdf0e10cSrcweir SdrObjCustomShape::~SdrObjCustomShape()
639*cdf0e10cSrcweir {
640*cdf0e10cSrcweir 	// delete buffered display geometry
641*cdf0e10cSrcweir 	InvalidateRenderGeometry();
642*cdf0e10cSrcweir }
643*cdf0e10cSrcweir 
644*cdf0e10cSrcweir void SdrObjCustomShape::MergeDefaultAttributes( const rtl::OUString* pType )
645*cdf0e10cSrcweir {
646*cdf0e10cSrcweir 	PropertyValue aPropVal;
647*cdf0e10cSrcweir 	rtl::OUString sShapeType;
648*cdf0e10cSrcweir 	const rtl::OUString	sType( RTL_CONSTASCII_USTRINGPARAM ( "Type" ) );
649*cdf0e10cSrcweir 	SdrCustomShapeGeometryItem aGeometryItem( (SdrCustomShapeGeometryItem&)GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) );
650*cdf0e10cSrcweir 	if ( pType && pType->getLength() )
651*cdf0e10cSrcweir 	{
652*cdf0e10cSrcweir 		sal_Int32 nType = pType->toInt32();
653*cdf0e10cSrcweir 		if ( nType )
654*cdf0e10cSrcweir 			sShapeType = EnhancedCustomShapeTypeNames::Get( static_cast< MSO_SPT >( nType ) );
655*cdf0e10cSrcweir 		else
656*cdf0e10cSrcweir 			sShapeType = *pType;
657*cdf0e10cSrcweir 
658*cdf0e10cSrcweir 		aPropVal.Name = sType;
659*cdf0e10cSrcweir 		aPropVal.Value <<= sShapeType;
660*cdf0e10cSrcweir 		aGeometryItem.SetPropertyValue( aPropVal );
661*cdf0e10cSrcweir 	}
662*cdf0e10cSrcweir 	else
663*cdf0e10cSrcweir 	{
664*cdf0e10cSrcweir 		Any *pAny = aGeometryItem.GetPropertyValueByName( sType );
665*cdf0e10cSrcweir 		if ( pAny )
666*cdf0e10cSrcweir 			*pAny >>= sShapeType;
667*cdf0e10cSrcweir 	}
668*cdf0e10cSrcweir 	MSO_SPT eSpType = EnhancedCustomShapeTypeNames::Get( sShapeType );
669*cdf0e10cSrcweir 
670*cdf0e10cSrcweir 	const sal_Int32* pDefData = NULL;
671*cdf0e10cSrcweir 	const mso_CustomShape* pDefCustomShape = GetCustomShapeContent( eSpType );
672*cdf0e10cSrcweir 	if ( pDefCustomShape )
673*cdf0e10cSrcweir 		pDefData = pDefCustomShape->pDefData;
674*cdf0e10cSrcweir 
675*cdf0e10cSrcweir 	com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeAdjustmentValue > seqAdjustmentValues;
676*cdf0e10cSrcweir 
677*cdf0e10cSrcweir 	//////////////////////
678*cdf0e10cSrcweir 	// AdjustmentValues //
679*cdf0e10cSrcweir 	//////////////////////
680*cdf0e10cSrcweir 	const rtl::OUString	sAdjustmentValues( RTL_CONSTASCII_USTRINGPARAM ( "AdjustmentValues" ) );
681*cdf0e10cSrcweir 	const Any* pAny = ((SdrCustomShapeGeometryItem&)aGeometryItem).GetPropertyValueByName( sAdjustmentValues );
682*cdf0e10cSrcweir 	if ( pAny )
683*cdf0e10cSrcweir 		*pAny >>= seqAdjustmentValues;
684*cdf0e10cSrcweir 	if ( pDefCustomShape && pDefData )	// now check if we have to default some adjustment values
685*cdf0e10cSrcweir 	{
686*cdf0e10cSrcweir 		// first check if there are adjustment values are to be appended
687*cdf0e10cSrcweir 		sal_Int32 i, nAdjustmentValues = seqAdjustmentValues.getLength();
688*cdf0e10cSrcweir 		sal_Int32 nAdjustmentDefaults = *pDefData++;
689*cdf0e10cSrcweir 		if ( nAdjustmentDefaults > nAdjustmentValues )
690*cdf0e10cSrcweir 		{
691*cdf0e10cSrcweir 			seqAdjustmentValues.realloc( nAdjustmentDefaults );
692*cdf0e10cSrcweir 			for ( i = nAdjustmentValues; i < nAdjustmentDefaults; i++ )
693*cdf0e10cSrcweir 			{
694*cdf0e10cSrcweir 				seqAdjustmentValues[ i ].Value <<= pDefData[ i ];
695*cdf0e10cSrcweir 				seqAdjustmentValues[ i ].State = com::sun::star::beans::PropertyState_DIRECT_VALUE;	// com::sun::star::beans::PropertyState_DEFAULT_VALUE;
696*cdf0e10cSrcweir 			}
697*cdf0e10cSrcweir 		}
698*cdf0e10cSrcweir 		// check if there are defaulted adjustment values that should be filled the hard coded defaults (pDefValue)
699*cdf0e10cSrcweir 		sal_Int32 nCount = nAdjustmentValues > nAdjustmentDefaults ? nAdjustmentDefaults : nAdjustmentValues;
700*cdf0e10cSrcweir 		for ( i = 0; i < nCount; i++ )
701*cdf0e10cSrcweir 		{
702*cdf0e10cSrcweir 			if ( seqAdjustmentValues[ i ].State != com::sun::star::beans::PropertyState_DIRECT_VALUE )
703*cdf0e10cSrcweir 			{
704*cdf0e10cSrcweir 				seqAdjustmentValues[ i ].Value <<= pDefData[ i ];
705*cdf0e10cSrcweir 				seqAdjustmentValues[ i ].State = com::sun::star::beans::PropertyState_DIRECT_VALUE;
706*cdf0e10cSrcweir 			}
707*cdf0e10cSrcweir 		}
708*cdf0e10cSrcweir 	}
709*cdf0e10cSrcweir 	aPropVal.Name = sAdjustmentValues;
710*cdf0e10cSrcweir 	aPropVal.Value <<= seqAdjustmentValues;
711*cdf0e10cSrcweir 	aGeometryItem.SetPropertyValue( aPropVal );
712*cdf0e10cSrcweir 
713*cdf0e10cSrcweir 	///////////////
714*cdf0e10cSrcweir 	// Coordsize //
715*cdf0e10cSrcweir 	///////////////
716*cdf0e10cSrcweir 	const rtl::OUString	sViewBox( RTL_CONSTASCII_USTRINGPARAM ( "ViewBox" ) );
717*cdf0e10cSrcweir 	const Any* pViewBox = ((SdrCustomShapeGeometryItem&)aGeometryItem).GetPropertyValueByName( sViewBox );
718*cdf0e10cSrcweir 	com::sun::star::awt::Rectangle aViewBox;
719*cdf0e10cSrcweir 	if ( !pViewBox || !(*pViewBox >>= aViewBox ) )
720*cdf0e10cSrcweir 	{
721*cdf0e10cSrcweir 		if ( pDefCustomShape )
722*cdf0e10cSrcweir 		{
723*cdf0e10cSrcweir 			aViewBox.X = 0;
724*cdf0e10cSrcweir 			aViewBox.Y = 0;
725*cdf0e10cSrcweir 			aViewBox.Width = pDefCustomShape->nCoordWidth;
726*cdf0e10cSrcweir 			aViewBox.Height= pDefCustomShape->nCoordHeight;
727*cdf0e10cSrcweir 			aPropVal.Name = sViewBox;
728*cdf0e10cSrcweir 			aPropVal.Value <<= aViewBox;
729*cdf0e10cSrcweir 			aGeometryItem.SetPropertyValue( aPropVal );
730*cdf0e10cSrcweir 		}
731*cdf0e10cSrcweir 	}
732*cdf0e10cSrcweir 
733*cdf0e10cSrcweir 	const rtl::OUString	sPath( RTL_CONSTASCII_USTRINGPARAM ( "Path" ) );
734*cdf0e10cSrcweir 
735*cdf0e10cSrcweir 	//////////////////////
736*cdf0e10cSrcweir 	// Path/Coordinates //
737*cdf0e10cSrcweir 	//////////////////////
738*cdf0e10cSrcweir 	const rtl::OUString	sCoordinates( RTL_CONSTASCII_USTRINGPARAM ( "Coordinates" ) );
739*cdf0e10cSrcweir 	pAny = ((SdrCustomShapeGeometryItem&)aGeometryItem).GetPropertyValueByName( sPath, sCoordinates );
740*cdf0e10cSrcweir 	if ( !pAny && pDefCustomShape && pDefCustomShape->nVertices && pDefCustomShape->pVertices )
741*cdf0e10cSrcweir 	{
742*cdf0e10cSrcweir 		com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeParameterPair> seqCoordinates;
743*cdf0e10cSrcweir 
744*cdf0e10cSrcweir 		sal_Int32 i, nCount = pDefCustomShape->nVertices;
745*cdf0e10cSrcweir 		seqCoordinates.realloc( nCount );
746*cdf0e10cSrcweir 		for ( i = 0; i < nCount; i++ )
747*cdf0e10cSrcweir 		{
748*cdf0e10cSrcweir 			EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( seqCoordinates[ i ].First, pDefCustomShape->pVertices[ i ].nValA );
749*cdf0e10cSrcweir 			EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( seqCoordinates[ i ].Second, pDefCustomShape->pVertices[ i ].nValB );
750*cdf0e10cSrcweir 		}
751*cdf0e10cSrcweir 		aPropVal.Name = sCoordinates;
752*cdf0e10cSrcweir 		aPropVal.Value <<= seqCoordinates;
753*cdf0e10cSrcweir 		aGeometryItem.SetPropertyValue( sPath, aPropVal );
754*cdf0e10cSrcweir 	}
755*cdf0e10cSrcweir 
756*cdf0e10cSrcweir 	/////////////////////
757*cdf0e10cSrcweir 	// Path/GluePoints //
758*cdf0e10cSrcweir 	/////////////////////
759*cdf0e10cSrcweir 	const rtl::OUString	sGluePoints( RTL_CONSTASCII_USTRINGPARAM ( "GluePoints" ) );
760*cdf0e10cSrcweir 	pAny = ((SdrCustomShapeGeometryItem&)aGeometryItem).GetPropertyValueByName( sPath, sGluePoints );
761*cdf0e10cSrcweir 	if ( !pAny && pDefCustomShape && pDefCustomShape->nGluePoints && pDefCustomShape->pGluePoints )
762*cdf0e10cSrcweir 	{
763*cdf0e10cSrcweir 		com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeParameterPair> seqGluePoints;
764*cdf0e10cSrcweir 		sal_Int32 i, nCount = pDefCustomShape->nGluePoints;
765*cdf0e10cSrcweir 		seqGluePoints.realloc( nCount );
766*cdf0e10cSrcweir 		for ( i = 0; i < nCount; i++ )
767*cdf0e10cSrcweir 		{
768*cdf0e10cSrcweir 			EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( seqGluePoints[ i ].First, pDefCustomShape->pGluePoints[ i ].nValA );
769*cdf0e10cSrcweir 			EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( seqGluePoints[ i ].Second, pDefCustomShape->pGluePoints[ i ].nValB );
770*cdf0e10cSrcweir 		}
771*cdf0e10cSrcweir 		aPropVal.Name = sGluePoints;
772*cdf0e10cSrcweir 		aPropVal.Value <<= seqGluePoints;
773*cdf0e10cSrcweir 		aGeometryItem.SetPropertyValue( sPath, aPropVal );
774*cdf0e10cSrcweir 	}
775*cdf0e10cSrcweir 
776*cdf0e10cSrcweir 	///////////////////
777*cdf0e10cSrcweir 	// Path/Segments //
778*cdf0e10cSrcweir 	///////////////////
779*cdf0e10cSrcweir 	const rtl::OUString	sSegments( RTL_CONSTASCII_USTRINGPARAM ( "Segments" ) );
780*cdf0e10cSrcweir 	pAny = ((SdrCustomShapeGeometryItem&)aGeometryItem).GetPropertyValueByName( sPath, sSegments );
781*cdf0e10cSrcweir 	if ( !pAny && pDefCustomShape && pDefCustomShape->nElements && pDefCustomShape->pElements )
782*cdf0e10cSrcweir 	{
783*cdf0e10cSrcweir 		com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeSegment > seqSegments;
784*cdf0e10cSrcweir 
785*cdf0e10cSrcweir 		sal_Int32 i, nCount = pDefCustomShape->nElements;
786*cdf0e10cSrcweir 		seqSegments.realloc( nCount );
787*cdf0e10cSrcweir 		for ( i = 0; i < nCount; i++ )
788*cdf0e10cSrcweir 		{
789*cdf0e10cSrcweir 			EnhancedCustomShapeSegment& rSegInfo = seqSegments[ i ];
790*cdf0e10cSrcweir 			sal_uInt16 nSDat = pDefCustomShape->pElements[ i ];
791*cdf0e10cSrcweir 			switch( nSDat >> 8 )
792*cdf0e10cSrcweir 			{
793*cdf0e10cSrcweir 				case 0x00 :
794*cdf0e10cSrcweir 				{
795*cdf0e10cSrcweir 					rSegInfo.Command = EnhancedCustomShapeSegmentCommand::LINETO;
796*cdf0e10cSrcweir 					rSegInfo.Count   = nSDat & 0xff;
797*cdf0e10cSrcweir 					if ( !rSegInfo.Count )
798*cdf0e10cSrcweir 						rSegInfo.Count = 1;
799*cdf0e10cSrcweir 				}
800*cdf0e10cSrcweir 				break;
801*cdf0e10cSrcweir 				case 0x20 :
802*cdf0e10cSrcweir 				{
803*cdf0e10cSrcweir 					rSegInfo.Command = EnhancedCustomShapeSegmentCommand::CURVETO;
804*cdf0e10cSrcweir 					rSegInfo.Count   = nSDat & 0xff;
805*cdf0e10cSrcweir 					if ( !rSegInfo.Count )
806*cdf0e10cSrcweir 						rSegInfo.Count = 1;
807*cdf0e10cSrcweir 				}
808*cdf0e10cSrcweir 				break;
809*cdf0e10cSrcweir 				case 0x40 :
810*cdf0e10cSrcweir 				{
811*cdf0e10cSrcweir 					rSegInfo.Command = EnhancedCustomShapeSegmentCommand::MOVETO;
812*cdf0e10cSrcweir 					rSegInfo.Count   = nSDat & 0xff;
813*cdf0e10cSrcweir 					if ( !rSegInfo.Count )
814*cdf0e10cSrcweir 						rSegInfo.Count = 1;
815*cdf0e10cSrcweir 				}
816*cdf0e10cSrcweir 				break;
817*cdf0e10cSrcweir 				case 0x60 :
818*cdf0e10cSrcweir 				{
819*cdf0e10cSrcweir 					rSegInfo.Command = EnhancedCustomShapeSegmentCommand::CLOSESUBPATH;
820*cdf0e10cSrcweir 					rSegInfo.Count   = 0;
821*cdf0e10cSrcweir 				}
822*cdf0e10cSrcweir 				break;
823*cdf0e10cSrcweir 				case 0x80 :
824*cdf0e10cSrcweir 				{
825*cdf0e10cSrcweir 					rSegInfo.Command = EnhancedCustomShapeSegmentCommand::ENDSUBPATH;
826*cdf0e10cSrcweir 					rSegInfo.Count   = 0;
827*cdf0e10cSrcweir 				}
828*cdf0e10cSrcweir 				break;
829*cdf0e10cSrcweir 				case 0xa1 :
830*cdf0e10cSrcweir 				{
831*cdf0e10cSrcweir 					rSegInfo.Command = EnhancedCustomShapeSegmentCommand::ANGLEELLIPSETO;
832*cdf0e10cSrcweir 					rSegInfo.Count   = ( nSDat & 0xff ) / 3;
833*cdf0e10cSrcweir 				}
834*cdf0e10cSrcweir 				break;
835*cdf0e10cSrcweir 				case 0xa2 :
836*cdf0e10cSrcweir 				{
837*cdf0e10cSrcweir 					rSegInfo.Command = EnhancedCustomShapeSegmentCommand::ANGLEELLIPSE;
838*cdf0e10cSrcweir 					rSegInfo.Count   = ( nSDat & 0xff ) / 3;
839*cdf0e10cSrcweir 				}
840*cdf0e10cSrcweir 				break;
841*cdf0e10cSrcweir 				case 0xa3 :
842*cdf0e10cSrcweir 				{
843*cdf0e10cSrcweir 					rSegInfo.Command = EnhancedCustomShapeSegmentCommand::ARCTO;
844*cdf0e10cSrcweir 					rSegInfo.Count   = ( nSDat & 0xff ) >> 2;
845*cdf0e10cSrcweir 				}
846*cdf0e10cSrcweir 				break;
847*cdf0e10cSrcweir 				case 0xa4 :
848*cdf0e10cSrcweir 				{
849*cdf0e10cSrcweir 					rSegInfo.Command = EnhancedCustomShapeSegmentCommand::ARC;
850*cdf0e10cSrcweir 					rSegInfo.Count   = ( nSDat & 0xff ) >> 2;
851*cdf0e10cSrcweir 				}
852*cdf0e10cSrcweir 				break;
853*cdf0e10cSrcweir 				case 0xa5 :
854*cdf0e10cSrcweir 				{
855*cdf0e10cSrcweir 					rSegInfo.Command = EnhancedCustomShapeSegmentCommand::CLOCKWISEARCTO;
856*cdf0e10cSrcweir 					rSegInfo.Count   = ( nSDat & 0xff ) >> 2;
857*cdf0e10cSrcweir 				}
858*cdf0e10cSrcweir 				break;
859*cdf0e10cSrcweir 				case 0xa6 :
860*cdf0e10cSrcweir 				{
861*cdf0e10cSrcweir 					rSegInfo.Command = EnhancedCustomShapeSegmentCommand::CLOCKWISEARC;
862*cdf0e10cSrcweir 					rSegInfo.Count   = ( nSDat & 0xff ) >> 2;
863*cdf0e10cSrcweir 				}
864*cdf0e10cSrcweir 				break;
865*cdf0e10cSrcweir 				case 0xa7 :
866*cdf0e10cSrcweir 				{
867*cdf0e10cSrcweir 					rSegInfo.Command = EnhancedCustomShapeSegmentCommand::ELLIPTICALQUADRANTX;
868*cdf0e10cSrcweir 					rSegInfo.Count   = nSDat & 0xff;
869*cdf0e10cSrcweir 				}
870*cdf0e10cSrcweir 				break;
871*cdf0e10cSrcweir 				case 0xa8 :
872*cdf0e10cSrcweir 				{
873*cdf0e10cSrcweir 					rSegInfo.Command = EnhancedCustomShapeSegmentCommand::ELLIPTICALQUADRANTY;
874*cdf0e10cSrcweir 					rSegInfo.Count   = nSDat & 0xff;
875*cdf0e10cSrcweir 				}
876*cdf0e10cSrcweir 				break;
877*cdf0e10cSrcweir 				case 0xaa :
878*cdf0e10cSrcweir 				{
879*cdf0e10cSrcweir 					rSegInfo.Command = EnhancedCustomShapeSegmentCommand::NOFILL;
880*cdf0e10cSrcweir 					rSegInfo.Count   = 0;
881*cdf0e10cSrcweir 				}
882*cdf0e10cSrcweir 				break;
883*cdf0e10cSrcweir 				case 0xab :
884*cdf0e10cSrcweir 				{
885*cdf0e10cSrcweir 					rSegInfo.Command = EnhancedCustomShapeSegmentCommand::NOSTROKE;
886*cdf0e10cSrcweir 					rSegInfo.Count   = 0;
887*cdf0e10cSrcweir 				}
888*cdf0e10cSrcweir 				break;
889*cdf0e10cSrcweir 				default:
890*cdf0e10cSrcweir 				case 0xf8 :
891*cdf0e10cSrcweir 				{
892*cdf0e10cSrcweir 					rSegInfo.Command = EnhancedCustomShapeSegmentCommand::UNKNOWN;
893*cdf0e10cSrcweir 					rSegInfo.Count   = nSDat;
894*cdf0e10cSrcweir 				}
895*cdf0e10cSrcweir 				break;
896*cdf0e10cSrcweir 			}
897*cdf0e10cSrcweir 		}
898*cdf0e10cSrcweir 		aPropVal.Name = sSegments;
899*cdf0e10cSrcweir 		aPropVal.Value <<= seqSegments;
900*cdf0e10cSrcweir 		aGeometryItem.SetPropertyValue( sPath, aPropVal );
901*cdf0e10cSrcweir 	}
902*cdf0e10cSrcweir 
903*cdf0e10cSrcweir 	///////////////////
904*cdf0e10cSrcweir 	// Path/StretchX //
905*cdf0e10cSrcweir 	///////////////////
906*cdf0e10cSrcweir 	const rtl::OUString	sStretchX( RTL_CONSTASCII_USTRINGPARAM ( "StretchX" ) );
907*cdf0e10cSrcweir 	pAny = ((SdrCustomShapeGeometryItem&)aGeometryItem).GetPropertyValueByName( sPath, sStretchX );
908*cdf0e10cSrcweir 	if ( !pAny && pDefCustomShape )
909*cdf0e10cSrcweir 	{
910*cdf0e10cSrcweir 		sal_Int32 nXRef = pDefCustomShape->nXRef;
911*cdf0e10cSrcweir 		if ( ( nXRef != DEFAULT_MINIMUM_SIGNED_COMPARE ) )
912*cdf0e10cSrcweir 		{
913*cdf0e10cSrcweir 			aPropVal.Name = sStretchX;
914*cdf0e10cSrcweir 			aPropVal.Value <<= nXRef;
915*cdf0e10cSrcweir 			aGeometryItem.SetPropertyValue( sPath, aPropVal );
916*cdf0e10cSrcweir 		}
917*cdf0e10cSrcweir 	}
918*cdf0e10cSrcweir 
919*cdf0e10cSrcweir 	///////////////////
920*cdf0e10cSrcweir 	// Path/StretchY //
921*cdf0e10cSrcweir 	///////////////////
922*cdf0e10cSrcweir 	const rtl::OUString	sStretchY( RTL_CONSTASCII_USTRINGPARAM ( "StretchY" ) );
923*cdf0e10cSrcweir 	pAny = ((SdrCustomShapeGeometryItem&)aGeometryItem).GetPropertyValueByName( sPath, sStretchY );
924*cdf0e10cSrcweir 	if ( !pAny && pDefCustomShape )
925*cdf0e10cSrcweir 	{
926*cdf0e10cSrcweir 		sal_Int32 nYRef = pDefCustomShape->nYRef;
927*cdf0e10cSrcweir 		if ( ( nYRef != DEFAULT_MINIMUM_SIGNED_COMPARE ) )
928*cdf0e10cSrcweir 		{
929*cdf0e10cSrcweir 			aPropVal.Name = sStretchY;
930*cdf0e10cSrcweir 			aPropVal.Value <<= nYRef;
931*cdf0e10cSrcweir 			aGeometryItem.SetPropertyValue( sPath, aPropVal );
932*cdf0e10cSrcweir 		}
933*cdf0e10cSrcweir 	}
934*cdf0e10cSrcweir 
935*cdf0e10cSrcweir 	/////////////////////
936*cdf0e10cSrcweir 	// Path/TextFrames //
937*cdf0e10cSrcweir 	/////////////////////
938*cdf0e10cSrcweir 	const rtl::OUString	sTextFrames( RTL_CONSTASCII_USTRINGPARAM ( "TextFrames" ) );
939*cdf0e10cSrcweir 	pAny = ((SdrCustomShapeGeometryItem&)aGeometryItem).GetPropertyValueByName( sPath, sTextFrames );
940*cdf0e10cSrcweir 	if ( !pAny && pDefCustomShape && pDefCustomShape->nTextRect && pDefCustomShape->pTextRect )
941*cdf0e10cSrcweir 	{
942*cdf0e10cSrcweir 		com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeTextFrame > seqTextFrames;
943*cdf0e10cSrcweir 
944*cdf0e10cSrcweir 		sal_Int32 i, nCount = pDefCustomShape->nTextRect;
945*cdf0e10cSrcweir 		seqTextFrames.realloc( nCount );
946*cdf0e10cSrcweir 		const SvxMSDffTextRectangles* pRectangles = pDefCustomShape->pTextRect;
947*cdf0e10cSrcweir 		for ( i = 0; i < nCount; i++, pRectangles++ )
948*cdf0e10cSrcweir 		{
949*cdf0e10cSrcweir 			EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( seqTextFrames[ i ].TopLeft.First,	  pRectangles->nPairA.nValA );
950*cdf0e10cSrcweir 			EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( seqTextFrames[ i ].TopLeft.Second,	  pRectangles->nPairA.nValB );
951*cdf0e10cSrcweir 			EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( seqTextFrames[ i ].BottomRight.First,  pRectangles->nPairB.nValA );
952*cdf0e10cSrcweir 			EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( seqTextFrames[ i ].BottomRight.Second, pRectangles->nPairB.nValB );
953*cdf0e10cSrcweir 		}
954*cdf0e10cSrcweir 		aPropVal.Name = sTextFrames;
955*cdf0e10cSrcweir 		aPropVal.Value <<= seqTextFrames;
956*cdf0e10cSrcweir 		aGeometryItem.SetPropertyValue( sPath, aPropVal );
957*cdf0e10cSrcweir 	}
958*cdf0e10cSrcweir 
959*cdf0e10cSrcweir 	///////////////
960*cdf0e10cSrcweir 	// Equations //
961*cdf0e10cSrcweir 	///////////////
962*cdf0e10cSrcweir 	const rtl::OUString	sEquations( RTL_CONSTASCII_USTRINGPARAM( "Equations" ) );
963*cdf0e10cSrcweir 	pAny = ((SdrCustomShapeGeometryItem&)aGeometryItem).GetPropertyValueByName( sEquations );
964*cdf0e10cSrcweir 	if ( !pAny && pDefCustomShape && pDefCustomShape->nCalculation && pDefCustomShape->pCalculation )
965*cdf0e10cSrcweir 	{
966*cdf0e10cSrcweir 		com::sun::star::uno::Sequence< rtl::OUString > seqEquations;
967*cdf0e10cSrcweir 
968*cdf0e10cSrcweir 		sal_Int32 i, nCount = pDefCustomShape->nCalculation;
969*cdf0e10cSrcweir 		seqEquations.realloc( nCount );
970*cdf0e10cSrcweir 		const SvxMSDffCalculationData* pData = pDefCustomShape->pCalculation;
971*cdf0e10cSrcweir 		for ( i = 0; i < nCount; i++, pData++ )
972*cdf0e10cSrcweir 			seqEquations[ i ] = EnhancedCustomShape2d::GetEquation( pData->nFlags, pData->nVal[ 0 ], pData->nVal[ 1 ], pData->nVal[ 2 ] );
973*cdf0e10cSrcweir 		aPropVal.Name = sEquations;
974*cdf0e10cSrcweir 		aPropVal.Value <<= seqEquations;
975*cdf0e10cSrcweir 		aGeometryItem.SetPropertyValue( aPropVal );
976*cdf0e10cSrcweir 	}
977*cdf0e10cSrcweir 
978*cdf0e10cSrcweir 	/////////////
979*cdf0e10cSrcweir 	// Handles //
980*cdf0e10cSrcweir 	/////////////
981*cdf0e10cSrcweir 	const rtl::OUString	sHandles( RTL_CONSTASCII_USTRINGPARAM( "Handles" ) );
982*cdf0e10cSrcweir 	pAny = ((SdrCustomShapeGeometryItem&)aGeometryItem).GetPropertyValueByName( sHandles );
983*cdf0e10cSrcweir 	if ( !pAny && pDefCustomShape && pDefCustomShape->nHandles && pDefCustomShape->pHandles )
984*cdf0e10cSrcweir 	{
985*cdf0e10cSrcweir 		com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValues > seqHandles;
986*cdf0e10cSrcweir 
987*cdf0e10cSrcweir 		sal_Int32 i, n, nCount = pDefCustomShape->nHandles;
988*cdf0e10cSrcweir 		const SvxMSDffHandle* pData = pDefCustomShape->pHandles;
989*cdf0e10cSrcweir 		seqHandles.realloc( nCount );
990*cdf0e10cSrcweir 		for ( i = 0; i < nCount; i++, pData++ )
991*cdf0e10cSrcweir 		{
992*cdf0e10cSrcweir 			sal_Int32 nPropertiesNeeded = 1;	// position is always needed
993*cdf0e10cSrcweir 			sal_Int32 nFlags = pData->nFlags;
994*cdf0e10cSrcweir 			if ( nFlags & MSDFF_HANDLE_FLAGS_MIRRORED_X )
995*cdf0e10cSrcweir 				nPropertiesNeeded++;
996*cdf0e10cSrcweir 			if ( nFlags & MSDFF_HANDLE_FLAGS_MIRRORED_Y )
997*cdf0e10cSrcweir 				nPropertiesNeeded++;
998*cdf0e10cSrcweir 			if ( nFlags & MSDFF_HANDLE_FLAGS_SWITCHED )
999*cdf0e10cSrcweir 				nPropertiesNeeded++;
1000*cdf0e10cSrcweir 			if ( nFlags & MSDFF_HANDLE_FLAGS_POLAR )
1001*cdf0e10cSrcweir 			{
1002*cdf0e10cSrcweir 				nPropertiesNeeded++;
1003*cdf0e10cSrcweir 				if ( nFlags & MSDFF_HANDLE_FLAGS_RADIUS_RANGE )
1004*cdf0e10cSrcweir 				{
1005*cdf0e10cSrcweir 					if ( pData->nRangeXMin != DEFAULT_MINIMUM_SIGNED_COMPARE )
1006*cdf0e10cSrcweir 						nPropertiesNeeded++;
1007*cdf0e10cSrcweir 					if ( pData->nRangeXMax != DEFAULT_MAXIMUM_SIGNED_COMPARE )
1008*cdf0e10cSrcweir 						nPropertiesNeeded++;
1009*cdf0e10cSrcweir 				}
1010*cdf0e10cSrcweir 			}
1011*cdf0e10cSrcweir 			else if ( nFlags & MSDFF_HANDLE_FLAGS_RANGE )
1012*cdf0e10cSrcweir 			{
1013*cdf0e10cSrcweir 				if ( pData->nRangeXMin != DEFAULT_MINIMUM_SIGNED_COMPARE )
1014*cdf0e10cSrcweir 					nPropertiesNeeded++;
1015*cdf0e10cSrcweir 				if ( pData->nRangeXMax != DEFAULT_MAXIMUM_SIGNED_COMPARE )
1016*cdf0e10cSrcweir 					nPropertiesNeeded++;
1017*cdf0e10cSrcweir 				if ( pData->nRangeYMin != DEFAULT_MINIMUM_SIGNED_COMPARE )
1018*cdf0e10cSrcweir 					nPropertiesNeeded++;
1019*cdf0e10cSrcweir 				if ( pData->nRangeYMax != DEFAULT_MAXIMUM_SIGNED_COMPARE )
1020*cdf0e10cSrcweir 					nPropertiesNeeded++;
1021*cdf0e10cSrcweir 			}
1022*cdf0e10cSrcweir 
1023*cdf0e10cSrcweir 			n = 0;
1024*cdf0e10cSrcweir 			com::sun::star::beans::PropertyValues& rPropValues = seqHandles[ i ];
1025*cdf0e10cSrcweir 			rPropValues.realloc( nPropertiesNeeded );
1026*cdf0e10cSrcweir 
1027*cdf0e10cSrcweir 			// POSITION
1028*cdf0e10cSrcweir 			{
1029*cdf0e10cSrcweir 				const rtl::OUString	sPosition( RTL_CONSTASCII_USTRINGPARAM ( "Position" ) );
1030*cdf0e10cSrcweir 				::com::sun::star::drawing::EnhancedCustomShapeParameterPair aPosition;
1031*cdf0e10cSrcweir 				EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aPosition.First, pData->nPositionX, sal_True, sal_True );
1032*cdf0e10cSrcweir 				EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aPosition.Second, pData->nPositionY, sal_True, sal_False );
1033*cdf0e10cSrcweir 				rPropValues[ n ].Name = sPosition;
1034*cdf0e10cSrcweir 				rPropValues[ n++ ].Value <<= aPosition;
1035*cdf0e10cSrcweir 			}
1036*cdf0e10cSrcweir 			if ( nFlags & MSDFF_HANDLE_FLAGS_MIRRORED_X )
1037*cdf0e10cSrcweir 			{
1038*cdf0e10cSrcweir 				const rtl::OUString	sMirroredX( RTL_CONSTASCII_USTRINGPARAM ( "MirroredX" ) );
1039*cdf0e10cSrcweir 				sal_Bool bMirroredX = sal_True;
1040*cdf0e10cSrcweir 				rPropValues[ n ].Name = sMirroredX;
1041*cdf0e10cSrcweir 				rPropValues[ n++ ].Value <<= bMirroredX;
1042*cdf0e10cSrcweir 			}
1043*cdf0e10cSrcweir 			if ( nFlags & MSDFF_HANDLE_FLAGS_MIRRORED_Y )
1044*cdf0e10cSrcweir 			{
1045*cdf0e10cSrcweir 				const rtl::OUString	sMirroredY( RTL_CONSTASCII_USTRINGPARAM ( "MirroredY" ) );
1046*cdf0e10cSrcweir 				sal_Bool bMirroredY = sal_True;
1047*cdf0e10cSrcweir 				rPropValues[ n ].Name = sMirroredY;
1048*cdf0e10cSrcweir 				rPropValues[ n++ ].Value <<= bMirroredY;
1049*cdf0e10cSrcweir 			}
1050*cdf0e10cSrcweir 			if ( nFlags & MSDFF_HANDLE_FLAGS_SWITCHED )
1051*cdf0e10cSrcweir 			{
1052*cdf0e10cSrcweir 				const rtl::OUString	sSwitched( RTL_CONSTASCII_USTRINGPARAM ( "Switched" ) );
1053*cdf0e10cSrcweir 				sal_Bool bSwitched = sal_True;
1054*cdf0e10cSrcweir 				rPropValues[ n ].Name = sSwitched;
1055*cdf0e10cSrcweir 				rPropValues[ n++ ].Value <<= bSwitched;
1056*cdf0e10cSrcweir 			}
1057*cdf0e10cSrcweir 			if ( nFlags & MSDFF_HANDLE_FLAGS_POLAR )
1058*cdf0e10cSrcweir 			{
1059*cdf0e10cSrcweir 				const rtl::OUString	sPolar( RTL_CONSTASCII_USTRINGPARAM ( "Polar" ) );
1060*cdf0e10cSrcweir 				::com::sun::star::drawing::EnhancedCustomShapeParameterPair aCenter;
1061*cdf0e10cSrcweir 				EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aCenter.First,  pData->nCenterX,
1062*cdf0e10cSrcweir 					( nFlags & MSDFF_HANDLE_FLAGS_CENTER_X_IS_SPECIAL ) != 0, sal_True  );
1063*cdf0e10cSrcweir 				EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aCenter.Second, pData->nCenterY,
1064*cdf0e10cSrcweir 					( nFlags & MSDFF_HANDLE_FLAGS_CENTER_Y_IS_SPECIAL ) != 0, sal_False );
1065*cdf0e10cSrcweir 				rPropValues[ n ].Name = sPolar;
1066*cdf0e10cSrcweir 				rPropValues[ n++ ].Value <<= aCenter;
1067*cdf0e10cSrcweir 				if ( nFlags & MSDFF_HANDLE_FLAGS_RADIUS_RANGE )
1068*cdf0e10cSrcweir 				{
1069*cdf0e10cSrcweir 					if ( pData->nRangeXMin != DEFAULT_MINIMUM_SIGNED_COMPARE )
1070*cdf0e10cSrcweir 					{
1071*cdf0e10cSrcweir 						const rtl::OUString	sRadiusRangeMinimum( RTL_CONSTASCII_USTRINGPARAM ( "RadiusRangeMinimum" ) );
1072*cdf0e10cSrcweir 						::com::sun::star::drawing::EnhancedCustomShapeParameter aRadiusRangeMinimum;
1073*cdf0e10cSrcweir 						EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aRadiusRangeMinimum, pData->nRangeXMin,
1074*cdf0e10cSrcweir 							( nFlags & MSDFF_HANDLE_FLAGS_RANGE_X_MIN_IS_SPECIAL ) != 0, sal_True  );
1075*cdf0e10cSrcweir 						rPropValues[ n ].Name = sRadiusRangeMinimum;
1076*cdf0e10cSrcweir 						rPropValues[ n++ ].Value <<= aRadiusRangeMinimum;
1077*cdf0e10cSrcweir 					}
1078*cdf0e10cSrcweir 					if ( pData->nRangeXMax != DEFAULT_MAXIMUM_SIGNED_COMPARE )
1079*cdf0e10cSrcweir 					{
1080*cdf0e10cSrcweir 						const rtl::OUString	sRadiusRangeMaximum( RTL_CONSTASCII_USTRINGPARAM ( "RadiusRangeMaximum" ) );
1081*cdf0e10cSrcweir 						::com::sun::star::drawing::EnhancedCustomShapeParameter aRadiusRangeMaximum;
1082*cdf0e10cSrcweir 						EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aRadiusRangeMaximum, pData->nRangeXMax,
1083*cdf0e10cSrcweir 							( nFlags & MSDFF_HANDLE_FLAGS_RANGE_X_MAX_IS_SPECIAL ) != 0, sal_False );
1084*cdf0e10cSrcweir 						rPropValues[ n ].Name = sRadiusRangeMaximum;
1085*cdf0e10cSrcweir 						rPropValues[ n++ ].Value <<= aRadiusRangeMaximum;
1086*cdf0e10cSrcweir 					}
1087*cdf0e10cSrcweir 				}
1088*cdf0e10cSrcweir 			}
1089*cdf0e10cSrcweir 			else if ( nFlags & MSDFF_HANDLE_FLAGS_RANGE )
1090*cdf0e10cSrcweir 			{
1091*cdf0e10cSrcweir 				if ( pData->nRangeXMin != DEFAULT_MINIMUM_SIGNED_COMPARE )
1092*cdf0e10cSrcweir 				{
1093*cdf0e10cSrcweir 					const rtl::OUString	sRangeXMinimum( RTL_CONSTASCII_USTRINGPARAM ( "RangeXMinimum" ) );
1094*cdf0e10cSrcweir 					::com::sun::star::drawing::EnhancedCustomShapeParameter aRangeXMinimum;
1095*cdf0e10cSrcweir 					EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aRangeXMinimum, pData->nRangeXMin,
1096*cdf0e10cSrcweir 						( nFlags & MSDFF_HANDLE_FLAGS_RANGE_X_MIN_IS_SPECIAL ) != 0, sal_True  );
1097*cdf0e10cSrcweir 					rPropValues[ n ].Name = sRangeXMinimum;
1098*cdf0e10cSrcweir 					rPropValues[ n++ ].Value <<= aRangeXMinimum;
1099*cdf0e10cSrcweir 				}
1100*cdf0e10cSrcweir 				if ( pData->nRangeXMax != DEFAULT_MAXIMUM_SIGNED_COMPARE )
1101*cdf0e10cSrcweir 				{
1102*cdf0e10cSrcweir 					const rtl::OUString	sRangeXMaximum( RTL_CONSTASCII_USTRINGPARAM ( "RangeXMaximum" ) );
1103*cdf0e10cSrcweir 					::com::sun::star::drawing::EnhancedCustomShapeParameter aRangeXMaximum;
1104*cdf0e10cSrcweir 					EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aRangeXMaximum, pData->nRangeXMax,
1105*cdf0e10cSrcweir 						( nFlags & MSDFF_HANDLE_FLAGS_RANGE_X_MAX_IS_SPECIAL ) != 0, sal_False );
1106*cdf0e10cSrcweir 					rPropValues[ n ].Name = sRangeXMaximum;
1107*cdf0e10cSrcweir 					rPropValues[ n++ ].Value <<= aRangeXMaximum;
1108*cdf0e10cSrcweir 				}
1109*cdf0e10cSrcweir 				if ( pData->nRangeYMin != DEFAULT_MINIMUM_SIGNED_COMPARE )
1110*cdf0e10cSrcweir 				{
1111*cdf0e10cSrcweir 					const rtl::OUString	sRangeYMinimum( RTL_CONSTASCII_USTRINGPARAM ( "RangeYMinimum" ) );
1112*cdf0e10cSrcweir 					::com::sun::star::drawing::EnhancedCustomShapeParameter aRangeYMinimum;
1113*cdf0e10cSrcweir 					EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aRangeYMinimum, pData->nRangeYMin,
1114*cdf0e10cSrcweir 						( nFlags & MSDFF_HANDLE_FLAGS_RANGE_Y_MIN_IS_SPECIAL ) != 0, sal_True );
1115*cdf0e10cSrcweir 					rPropValues[ n ].Name = sRangeYMinimum;
1116*cdf0e10cSrcweir 					rPropValues[ n++ ].Value <<= aRangeYMinimum;
1117*cdf0e10cSrcweir 				}
1118*cdf0e10cSrcweir 				if ( pData->nRangeYMax != DEFAULT_MAXIMUM_SIGNED_COMPARE )
1119*cdf0e10cSrcweir 				{
1120*cdf0e10cSrcweir 					const rtl::OUString	sRangeYMaximum( RTL_CONSTASCII_USTRINGPARAM ( "RangeYMaximum" ) );
1121*cdf0e10cSrcweir 					::com::sun::star::drawing::EnhancedCustomShapeParameter aRangeYMaximum;
1122*cdf0e10cSrcweir 					EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aRangeYMaximum, pData->nRangeYMax,
1123*cdf0e10cSrcweir 						( nFlags & MSDFF_HANDLE_FLAGS_RANGE_Y_MAX_IS_SPECIAL ) != 0, sal_False );
1124*cdf0e10cSrcweir 					rPropValues[ n ].Name = sRangeYMaximum;
1125*cdf0e10cSrcweir 					rPropValues[ n++ ].Value <<= aRangeYMaximum;
1126*cdf0e10cSrcweir 				}
1127*cdf0e10cSrcweir 			}
1128*cdf0e10cSrcweir 		}
1129*cdf0e10cSrcweir 		aPropVal.Name = sHandles;
1130*cdf0e10cSrcweir 		aPropVal.Value <<= seqHandles;
1131*cdf0e10cSrcweir 		aGeometryItem.SetPropertyValue( aPropVal );
1132*cdf0e10cSrcweir 	}
1133*cdf0e10cSrcweir 	SetMergedItem( aGeometryItem );
1134*cdf0e10cSrcweir }
1135*cdf0e10cSrcweir 
1136*cdf0e10cSrcweir sal_Bool SdrObjCustomShape::IsDefaultGeometry( const DefaultType eDefaultType ) const
1137*cdf0e10cSrcweir {
1138*cdf0e10cSrcweir 	sal_Bool bIsDefaultGeometry = sal_False;
1139*cdf0e10cSrcweir 
1140*cdf0e10cSrcweir 	PropertyValue aPropVal;
1141*cdf0e10cSrcweir 	rtl::OUString sShapeType;
1142*cdf0e10cSrcweir 	const rtl::OUString	sType( RTL_CONSTASCII_USTRINGPARAM ( "Type" ) );
1143*cdf0e10cSrcweir 	SdrCustomShapeGeometryItem aGeometryItem( (SdrCustomShapeGeometryItem&)GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) );
1144*cdf0e10cSrcweir 
1145*cdf0e10cSrcweir 	Any *pAny = aGeometryItem.GetPropertyValueByName( sType );
1146*cdf0e10cSrcweir 	if ( pAny )
1147*cdf0e10cSrcweir 		*pAny >>= sShapeType;
1148*cdf0e10cSrcweir 
1149*cdf0e10cSrcweir 	MSO_SPT eSpType = EnhancedCustomShapeTypeNames::Get( sShapeType );
1150*cdf0e10cSrcweir 
1151*cdf0e10cSrcweir 	const mso_CustomShape* pDefCustomShape = GetCustomShapeContent( eSpType );
1152*cdf0e10cSrcweir 	const rtl::OUString	sPath( RTL_CONSTASCII_USTRINGPARAM ( "Path" ) );
1153*cdf0e10cSrcweir 	switch( eDefaultType )
1154*cdf0e10cSrcweir 	{
1155*cdf0e10cSrcweir 		case DEFAULT_VIEWBOX :
1156*cdf0e10cSrcweir 		{
1157*cdf0e10cSrcweir 			const rtl::OUString	sViewBox( RTL_CONSTASCII_USTRINGPARAM ( "ViewBox" ) );
1158*cdf0e10cSrcweir 			const Any* pViewBox = ((SdrCustomShapeGeometryItem&)aGeometryItem).GetPropertyValueByName( sViewBox );
1159*cdf0e10cSrcweir 			com::sun::star::awt::Rectangle aViewBox;
1160*cdf0e10cSrcweir 			if ( pViewBox && ( *pViewBox >>= aViewBox ) )
1161*cdf0e10cSrcweir 			{
1162*cdf0e10cSrcweir 				if ( ( aViewBox.Width == pDefCustomShape->nCoordWidth )
1163*cdf0e10cSrcweir 					&& ( aViewBox.Height == pDefCustomShape->nCoordHeight ) )
1164*cdf0e10cSrcweir 					bIsDefaultGeometry = sal_True;
1165*cdf0e10cSrcweir 			}
1166*cdf0e10cSrcweir 		}
1167*cdf0e10cSrcweir 		break;
1168*cdf0e10cSrcweir 
1169*cdf0e10cSrcweir 		case DEFAULT_PATH :
1170*cdf0e10cSrcweir 		{
1171*cdf0e10cSrcweir 			const rtl::OUString	sCoordinates( RTL_CONSTASCII_USTRINGPARAM ( "Coordinates" ) );
1172*cdf0e10cSrcweir 			pAny = ((SdrCustomShapeGeometryItem&)aGeometryItem).GetPropertyValueByName( sPath, sCoordinates );
1173*cdf0e10cSrcweir 			if ( pAny && pDefCustomShape && pDefCustomShape->nVertices && pDefCustomShape->pVertices )
1174*cdf0e10cSrcweir 			{
1175*cdf0e10cSrcweir 				com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeParameterPair> seqCoordinates1, seqCoordinates2;
1176*cdf0e10cSrcweir 				if ( *pAny >>= seqCoordinates1 )
1177*cdf0e10cSrcweir 				{
1178*cdf0e10cSrcweir 					sal_Int32 i, nCount = pDefCustomShape->nVertices;
1179*cdf0e10cSrcweir 					seqCoordinates2.realloc( nCount );
1180*cdf0e10cSrcweir 					for ( i = 0; i < nCount; i++ )
1181*cdf0e10cSrcweir 					{
1182*cdf0e10cSrcweir 						EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( seqCoordinates2[ i ].First, pDefCustomShape->pVertices[ i ].nValA );
1183*cdf0e10cSrcweir 						EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( seqCoordinates2[ i ].Second, pDefCustomShape->pVertices[ i ].nValB );
1184*cdf0e10cSrcweir 					}
1185*cdf0e10cSrcweir 					if ( seqCoordinates1 == seqCoordinates2 )
1186*cdf0e10cSrcweir 						bIsDefaultGeometry = sal_True;
1187*cdf0e10cSrcweir 				}
1188*cdf0e10cSrcweir 			}
1189*cdf0e10cSrcweir 			else if ( pDefCustomShape && ( ( pDefCustomShape->nVertices == 0 ) || ( pDefCustomShape->pVertices == 0 ) ) )
1190*cdf0e10cSrcweir 				bIsDefaultGeometry = sal_True;
1191*cdf0e10cSrcweir 		}
1192*cdf0e10cSrcweir 		break;
1193*cdf0e10cSrcweir 
1194*cdf0e10cSrcweir 		case DEFAULT_GLUEPOINTS :
1195*cdf0e10cSrcweir 		{
1196*cdf0e10cSrcweir 			const rtl::OUString	sGluePoints( RTL_CONSTASCII_USTRINGPARAM ( "GluePoints" ) );
1197*cdf0e10cSrcweir 			pAny = ((SdrCustomShapeGeometryItem&)aGeometryItem).GetPropertyValueByName( sPath, sGluePoints );
1198*cdf0e10cSrcweir 			if ( pAny && pDefCustomShape && pDefCustomShape->nGluePoints && pDefCustomShape->pGluePoints )
1199*cdf0e10cSrcweir 			{
1200*cdf0e10cSrcweir 				com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeParameterPair> seqGluePoints1, seqGluePoints2;
1201*cdf0e10cSrcweir 				if ( *pAny >>= seqGluePoints1 )
1202*cdf0e10cSrcweir 				{
1203*cdf0e10cSrcweir 					sal_Int32 i, nCount = pDefCustomShape->nGluePoints;
1204*cdf0e10cSrcweir 					seqGluePoints2.realloc( nCount );
1205*cdf0e10cSrcweir 					for ( i = 0; i < nCount; i++ )
1206*cdf0e10cSrcweir 					{
1207*cdf0e10cSrcweir 						EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( seqGluePoints2[ i ].First, pDefCustomShape->pGluePoints[ i ].nValA );
1208*cdf0e10cSrcweir 						EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( seqGluePoints2[ i ].Second, pDefCustomShape->pGluePoints[ i ].nValB );
1209*cdf0e10cSrcweir 					}
1210*cdf0e10cSrcweir 					if ( seqGluePoints1 == seqGluePoints2 )
1211*cdf0e10cSrcweir 						bIsDefaultGeometry = sal_True;
1212*cdf0e10cSrcweir 				}
1213*cdf0e10cSrcweir 			}
1214*cdf0e10cSrcweir 			else if ( pDefCustomShape && ( pDefCustomShape->nGluePoints == 0 ) )
1215*cdf0e10cSrcweir 				bIsDefaultGeometry = sal_True;
1216*cdf0e10cSrcweir 		}
1217*cdf0e10cSrcweir 		break;
1218*cdf0e10cSrcweir 
1219*cdf0e10cSrcweir 		case DEFAULT_SEGMENTS :
1220*cdf0e10cSrcweir 		{
1221*cdf0e10cSrcweir 			///////////////////
1222*cdf0e10cSrcweir 			// Path/Segments //
1223*cdf0e10cSrcweir 			///////////////////
1224*cdf0e10cSrcweir 			const rtl::OUString	sSegments( RTL_CONSTASCII_USTRINGPARAM ( "Segments" ) );
1225*cdf0e10cSrcweir 			pAny = ((SdrCustomShapeGeometryItem&)aGeometryItem).GetPropertyValueByName( sPath, sSegments );
1226*cdf0e10cSrcweir 			if ( pAny )
1227*cdf0e10cSrcweir 			{
1228*cdf0e10cSrcweir 				com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeSegment > seqSegments1, seqSegments2;
1229*cdf0e10cSrcweir 				if ( *pAny >>= seqSegments1 )
1230*cdf0e10cSrcweir 				{
1231*cdf0e10cSrcweir 					if ( pDefCustomShape && pDefCustomShape->nElements && pDefCustomShape->pElements )
1232*cdf0e10cSrcweir 					{
1233*cdf0e10cSrcweir 						sal_Int32 i, nCount = pDefCustomShape->nElements;
1234*cdf0e10cSrcweir 						if ( nCount )
1235*cdf0e10cSrcweir 						{
1236*cdf0e10cSrcweir 							seqSegments2.realloc( nCount );
1237*cdf0e10cSrcweir 							for ( i = 0; i < nCount; i++ )
1238*cdf0e10cSrcweir 							{
1239*cdf0e10cSrcweir 								EnhancedCustomShapeSegment& rSegInfo = seqSegments2[ i ];
1240*cdf0e10cSrcweir 								sal_uInt16 nSDat = pDefCustomShape->pElements[ i ];
1241*cdf0e10cSrcweir 								switch( nSDat >> 8 )
1242*cdf0e10cSrcweir 								{
1243*cdf0e10cSrcweir 									case 0x00 :
1244*cdf0e10cSrcweir 									{
1245*cdf0e10cSrcweir 										rSegInfo.Command = EnhancedCustomShapeSegmentCommand::LINETO;
1246*cdf0e10cSrcweir 										rSegInfo.Count   = nSDat & 0xff;
1247*cdf0e10cSrcweir 										if ( !rSegInfo.Count )
1248*cdf0e10cSrcweir 											rSegInfo.Count = 1;
1249*cdf0e10cSrcweir 									}
1250*cdf0e10cSrcweir 									break;
1251*cdf0e10cSrcweir 									case 0x20 :
1252*cdf0e10cSrcweir 									{
1253*cdf0e10cSrcweir 										rSegInfo.Command = EnhancedCustomShapeSegmentCommand::CURVETO;
1254*cdf0e10cSrcweir 										rSegInfo.Count   = nSDat & 0xff;
1255*cdf0e10cSrcweir 										if ( !rSegInfo.Count )
1256*cdf0e10cSrcweir 											rSegInfo.Count = 1;
1257*cdf0e10cSrcweir 									}
1258*cdf0e10cSrcweir 									break;
1259*cdf0e10cSrcweir 									case 0x40 :
1260*cdf0e10cSrcweir 									{
1261*cdf0e10cSrcweir 										rSegInfo.Command = EnhancedCustomShapeSegmentCommand::MOVETO;
1262*cdf0e10cSrcweir 										rSegInfo.Count   = nSDat & 0xff;
1263*cdf0e10cSrcweir 										if ( !rSegInfo.Count )
1264*cdf0e10cSrcweir 											rSegInfo.Count = 1;
1265*cdf0e10cSrcweir 									}
1266*cdf0e10cSrcweir 									break;
1267*cdf0e10cSrcweir 									case 0x60 :
1268*cdf0e10cSrcweir 									{
1269*cdf0e10cSrcweir 										rSegInfo.Command = EnhancedCustomShapeSegmentCommand::CLOSESUBPATH;
1270*cdf0e10cSrcweir 										rSegInfo.Count   = 0;
1271*cdf0e10cSrcweir 									}
1272*cdf0e10cSrcweir 									break;
1273*cdf0e10cSrcweir 									case 0x80 :
1274*cdf0e10cSrcweir 									{
1275*cdf0e10cSrcweir 										rSegInfo.Command = EnhancedCustomShapeSegmentCommand::ENDSUBPATH;
1276*cdf0e10cSrcweir 										rSegInfo.Count   = 0;
1277*cdf0e10cSrcweir 									}
1278*cdf0e10cSrcweir 									break;
1279*cdf0e10cSrcweir 									case 0xa1 :
1280*cdf0e10cSrcweir 									{
1281*cdf0e10cSrcweir 										rSegInfo.Command = EnhancedCustomShapeSegmentCommand::ANGLEELLIPSETO;
1282*cdf0e10cSrcweir 										rSegInfo.Count   = ( nSDat & 0xff ) / 3;
1283*cdf0e10cSrcweir 									}
1284*cdf0e10cSrcweir 									break;
1285*cdf0e10cSrcweir 									case 0xa2 :
1286*cdf0e10cSrcweir 									{
1287*cdf0e10cSrcweir 										rSegInfo.Command = EnhancedCustomShapeSegmentCommand::ANGLEELLIPSE;
1288*cdf0e10cSrcweir 										rSegInfo.Count   = ( nSDat & 0xff ) / 3;
1289*cdf0e10cSrcweir 									}
1290*cdf0e10cSrcweir 									break;
1291*cdf0e10cSrcweir 									case 0xa3 :
1292*cdf0e10cSrcweir 									{
1293*cdf0e10cSrcweir 										rSegInfo.Command = EnhancedCustomShapeSegmentCommand::ARCTO;
1294*cdf0e10cSrcweir 										rSegInfo.Count   = ( nSDat & 0xff ) >> 2;
1295*cdf0e10cSrcweir 									}
1296*cdf0e10cSrcweir 									break;
1297*cdf0e10cSrcweir 									case 0xa4 :
1298*cdf0e10cSrcweir 									{
1299*cdf0e10cSrcweir 										rSegInfo.Command = EnhancedCustomShapeSegmentCommand::ARC;
1300*cdf0e10cSrcweir 										rSegInfo.Count   = ( nSDat & 0xff ) >> 2;
1301*cdf0e10cSrcweir 									}
1302*cdf0e10cSrcweir 									break;
1303*cdf0e10cSrcweir 									case 0xa5 :
1304*cdf0e10cSrcweir 									{
1305*cdf0e10cSrcweir 										rSegInfo.Command = EnhancedCustomShapeSegmentCommand::CLOCKWISEARCTO;
1306*cdf0e10cSrcweir 										rSegInfo.Count   = ( nSDat & 0xff ) >> 2;
1307*cdf0e10cSrcweir 									}
1308*cdf0e10cSrcweir 									break;
1309*cdf0e10cSrcweir 									case 0xa6 :
1310*cdf0e10cSrcweir 									{
1311*cdf0e10cSrcweir 										rSegInfo.Command = EnhancedCustomShapeSegmentCommand::CLOCKWISEARC;
1312*cdf0e10cSrcweir 										rSegInfo.Count   = ( nSDat & 0xff ) >> 2;
1313*cdf0e10cSrcweir 									}
1314*cdf0e10cSrcweir 									break;
1315*cdf0e10cSrcweir 									case 0xa7 :
1316*cdf0e10cSrcweir 									{
1317*cdf0e10cSrcweir 										rSegInfo.Command = EnhancedCustomShapeSegmentCommand::ELLIPTICALQUADRANTX;
1318*cdf0e10cSrcweir 										rSegInfo.Count   = nSDat & 0xff;
1319*cdf0e10cSrcweir 									}
1320*cdf0e10cSrcweir 									break;
1321*cdf0e10cSrcweir 									case 0xa8 :
1322*cdf0e10cSrcweir 									{
1323*cdf0e10cSrcweir 										rSegInfo.Command = EnhancedCustomShapeSegmentCommand::ELLIPTICALQUADRANTY;
1324*cdf0e10cSrcweir 										rSegInfo.Count   = nSDat & 0xff;
1325*cdf0e10cSrcweir 									}
1326*cdf0e10cSrcweir 									break;
1327*cdf0e10cSrcweir 									case 0xaa :
1328*cdf0e10cSrcweir 									{
1329*cdf0e10cSrcweir 										rSegInfo.Command = EnhancedCustomShapeSegmentCommand::NOFILL;
1330*cdf0e10cSrcweir 										rSegInfo.Count   = 0;
1331*cdf0e10cSrcweir 									}
1332*cdf0e10cSrcweir 									break;
1333*cdf0e10cSrcweir 									case 0xab :
1334*cdf0e10cSrcweir 									{
1335*cdf0e10cSrcweir 										rSegInfo.Command = EnhancedCustomShapeSegmentCommand::NOSTROKE;
1336*cdf0e10cSrcweir 										rSegInfo.Count   = 0;
1337*cdf0e10cSrcweir 									}
1338*cdf0e10cSrcweir 									break;
1339*cdf0e10cSrcweir 									default:
1340*cdf0e10cSrcweir 									case 0xf8 :
1341*cdf0e10cSrcweir 									{
1342*cdf0e10cSrcweir 										rSegInfo.Command = EnhancedCustomShapeSegmentCommand::UNKNOWN;
1343*cdf0e10cSrcweir 										rSegInfo.Count   = nSDat;
1344*cdf0e10cSrcweir 									}
1345*cdf0e10cSrcweir 									break;
1346*cdf0e10cSrcweir 								}
1347*cdf0e10cSrcweir 							}
1348*cdf0e10cSrcweir 							if ( seqSegments1 == seqSegments2 )
1349*cdf0e10cSrcweir 								bIsDefaultGeometry = sal_True;
1350*cdf0e10cSrcweir 						}
1351*cdf0e10cSrcweir 					}
1352*cdf0e10cSrcweir 					else
1353*cdf0e10cSrcweir 					{
1354*cdf0e10cSrcweir 						// check if its the default segment description	( M L Z N )
1355*cdf0e10cSrcweir 						if ( seqSegments1.getLength() == 4 )
1356*cdf0e10cSrcweir 						{
1357*cdf0e10cSrcweir 							if ( ( seqSegments1[ 0 ].Command == EnhancedCustomShapeSegmentCommand::MOVETO )
1358*cdf0e10cSrcweir 								&& ( seqSegments1[ 1 ].Command == EnhancedCustomShapeSegmentCommand::LINETO )
1359*cdf0e10cSrcweir 								&& ( seqSegments1[ 2 ].Command == EnhancedCustomShapeSegmentCommand::CLOSESUBPATH )
1360*cdf0e10cSrcweir 								&& ( seqSegments1[ 3 ].Command == EnhancedCustomShapeSegmentCommand::ENDSUBPATH ) )
1361*cdf0e10cSrcweir 								bIsDefaultGeometry = sal_True;
1362*cdf0e10cSrcweir 						}
1363*cdf0e10cSrcweir 					}
1364*cdf0e10cSrcweir 				}
1365*cdf0e10cSrcweir 			}
1366*cdf0e10cSrcweir 			else if ( pDefCustomShape && ( ( pDefCustomShape->nElements == 0 ) || ( pDefCustomShape->pElements == 0 ) ) )
1367*cdf0e10cSrcweir 				bIsDefaultGeometry = sal_True;
1368*cdf0e10cSrcweir 		}
1369*cdf0e10cSrcweir 		break;
1370*cdf0e10cSrcweir 
1371*cdf0e10cSrcweir 		case DEFAULT_STRETCHX :
1372*cdf0e10cSrcweir 		{
1373*cdf0e10cSrcweir 			const rtl::OUString	sStretchX( RTL_CONSTASCII_USTRINGPARAM ( "StretchX" ) );
1374*cdf0e10cSrcweir 			pAny = ((SdrCustomShapeGeometryItem&)aGeometryItem).GetPropertyValueByName( sPath, sStretchX );
1375*cdf0e10cSrcweir 			if ( pAny && pDefCustomShape )
1376*cdf0e10cSrcweir 			{
1377*cdf0e10cSrcweir 				sal_Int32 nStretchX = 0;
1378*cdf0e10cSrcweir 				if ( *pAny >>= nStretchX )
1379*cdf0e10cSrcweir 				{
1380*cdf0e10cSrcweir 					if ( pDefCustomShape->nXRef == nStretchX )
1381*cdf0e10cSrcweir 						bIsDefaultGeometry = sal_True;
1382*cdf0e10cSrcweir 				}
1383*cdf0e10cSrcweir 			}
1384*cdf0e10cSrcweir 			else if ( pDefCustomShape && ( pDefCustomShape->nXRef == DEFAULT_MINIMUM_SIGNED_COMPARE ) )
1385*cdf0e10cSrcweir 				bIsDefaultGeometry = sal_True;
1386*cdf0e10cSrcweir 		}
1387*cdf0e10cSrcweir 		break;
1388*cdf0e10cSrcweir 
1389*cdf0e10cSrcweir 		case DEFAULT_STRETCHY :
1390*cdf0e10cSrcweir 		{
1391*cdf0e10cSrcweir 			const rtl::OUString	sStretchY( RTL_CONSTASCII_USTRINGPARAM ( "StretchY" ) );
1392*cdf0e10cSrcweir 			pAny = ((SdrCustomShapeGeometryItem&)aGeometryItem).GetPropertyValueByName( sPath, sStretchY );
1393*cdf0e10cSrcweir 			if ( pAny && pDefCustomShape )
1394*cdf0e10cSrcweir 			{
1395*cdf0e10cSrcweir 				sal_Int32 nStretchY = 0;
1396*cdf0e10cSrcweir 				if ( *pAny >>= nStretchY )
1397*cdf0e10cSrcweir 				{
1398*cdf0e10cSrcweir 					if ( pDefCustomShape->nYRef == nStretchY )
1399*cdf0e10cSrcweir 						bIsDefaultGeometry = sal_True;
1400*cdf0e10cSrcweir 				}
1401*cdf0e10cSrcweir 			}
1402*cdf0e10cSrcweir 			else if ( pDefCustomShape && ( pDefCustomShape->nYRef == DEFAULT_MINIMUM_SIGNED_COMPARE ) )
1403*cdf0e10cSrcweir 				bIsDefaultGeometry = sal_True;
1404*cdf0e10cSrcweir 		}
1405*cdf0e10cSrcweir 		break;
1406*cdf0e10cSrcweir 
1407*cdf0e10cSrcweir 		case DEFAULT_EQUATIONS :
1408*cdf0e10cSrcweir 		{
1409*cdf0e10cSrcweir 			const rtl::OUString	sEquations( RTL_CONSTASCII_USTRINGPARAM( "Equations" ) );
1410*cdf0e10cSrcweir 			pAny = ((SdrCustomShapeGeometryItem&)aGeometryItem).GetPropertyValueByName( sEquations );
1411*cdf0e10cSrcweir 			if ( pAny && pDefCustomShape && pDefCustomShape->nCalculation && pDefCustomShape->pCalculation )
1412*cdf0e10cSrcweir 			{
1413*cdf0e10cSrcweir 				com::sun::star::uno::Sequence< rtl::OUString > seqEquations1, seqEquations2;
1414*cdf0e10cSrcweir 				if ( *pAny >>= seqEquations1 )
1415*cdf0e10cSrcweir 				{
1416*cdf0e10cSrcweir 					sal_Int32 i, nCount = pDefCustomShape->nCalculation;
1417*cdf0e10cSrcweir 					seqEquations2.realloc( nCount );
1418*cdf0e10cSrcweir 
1419*cdf0e10cSrcweir 					const SvxMSDffCalculationData* pData = pDefCustomShape->pCalculation;
1420*cdf0e10cSrcweir 					for ( i = 0; i < nCount; i++, pData++ )
1421*cdf0e10cSrcweir 						seqEquations2[ i ] = EnhancedCustomShape2d::GetEquation( pData->nFlags, pData->nVal[ 0 ], pData->nVal[ 1 ], pData->nVal[ 2 ] );
1422*cdf0e10cSrcweir 
1423*cdf0e10cSrcweir 					if ( seqEquations1 == seqEquations2 )
1424*cdf0e10cSrcweir 						bIsDefaultGeometry = sal_True;
1425*cdf0e10cSrcweir 				}
1426*cdf0e10cSrcweir 			}
1427*cdf0e10cSrcweir 			else if ( pDefCustomShape && ( ( pDefCustomShape->nCalculation == 0 ) || ( pDefCustomShape->pCalculation == 0 ) ) )
1428*cdf0e10cSrcweir 				bIsDefaultGeometry = sal_True;
1429*cdf0e10cSrcweir 		}
1430*cdf0e10cSrcweir 		break;
1431*cdf0e10cSrcweir 
1432*cdf0e10cSrcweir 		case DEFAULT_TEXTFRAMES :
1433*cdf0e10cSrcweir 		{
1434*cdf0e10cSrcweir 			const rtl::OUString	sTextFrames( RTL_CONSTASCII_USTRINGPARAM( "TextFrames" ) );
1435*cdf0e10cSrcweir 			pAny = ((SdrCustomShapeGeometryItem&)aGeometryItem).GetPropertyValueByName( sPath, sTextFrames );
1436*cdf0e10cSrcweir 			if ( pAny && pDefCustomShape && pDefCustomShape->nTextRect && pDefCustomShape->pTextRect )
1437*cdf0e10cSrcweir 			{
1438*cdf0e10cSrcweir 				com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeTextFrame > seqTextFrames1, seqTextFrames2;
1439*cdf0e10cSrcweir 				if ( *pAny >>= seqTextFrames1 )
1440*cdf0e10cSrcweir 				{
1441*cdf0e10cSrcweir 					sal_Int32 i, nCount = pDefCustomShape->nTextRect;
1442*cdf0e10cSrcweir 					seqTextFrames2.realloc( nCount );
1443*cdf0e10cSrcweir 					const SvxMSDffTextRectangles* pRectangles = pDefCustomShape->pTextRect;
1444*cdf0e10cSrcweir 					for ( i = 0; i < nCount; i++, pRectangles++ )
1445*cdf0e10cSrcweir 					{
1446*cdf0e10cSrcweir 						EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( seqTextFrames2[ i ].TopLeft.First,	  pRectangles->nPairA.nValA );
1447*cdf0e10cSrcweir 						EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( seqTextFrames2[ i ].TopLeft.Second,	  pRectangles->nPairA.nValB );
1448*cdf0e10cSrcweir 						EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( seqTextFrames2[ i ].BottomRight.First,  pRectangles->nPairB.nValA );
1449*cdf0e10cSrcweir 						EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( seqTextFrames2[ i ].BottomRight.Second, pRectangles->nPairB.nValB );
1450*cdf0e10cSrcweir 					}
1451*cdf0e10cSrcweir 					if ( seqTextFrames1 == seqTextFrames2 )
1452*cdf0e10cSrcweir 						bIsDefaultGeometry = sal_True;
1453*cdf0e10cSrcweir 				}
1454*cdf0e10cSrcweir 			}
1455*cdf0e10cSrcweir 			else if ( pDefCustomShape && ( ( pDefCustomShape->nTextRect == 0 ) || ( pDefCustomShape->pTextRect == 0 ) ) )
1456*cdf0e10cSrcweir 				bIsDefaultGeometry = sal_True;
1457*cdf0e10cSrcweir 		}
1458*cdf0e10cSrcweir 		break;
1459*cdf0e10cSrcweir 
1460*cdf0e10cSrcweir 		case DEFAULT_HANDLES :
1461*cdf0e10cSrcweir 		{
1462*cdf0e10cSrcweir 			const rtl::OUString	sHandles( RTL_CONSTASCII_USTRINGPARAM( "Handles" ) );
1463*cdf0e10cSrcweir 			pAny = ((SdrCustomShapeGeometryItem&)aGeometryItem).GetPropertyValueByName( sHandles );
1464*cdf0e10cSrcweir 			if ( pAny && pDefCustomShape && pDefCustomShape->nHandles && pDefCustomShape->pHandles )
1465*cdf0e10cSrcweir 			{
1466*cdf0e10cSrcweir 				com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValues > seqHandles1, seqHandles2;
1467*cdf0e10cSrcweir 				if ( *pAny >>= seqHandles1 )
1468*cdf0e10cSrcweir 				{
1469*cdf0e10cSrcweir 					sal_Int32 i, n, nCount = pDefCustomShape->nHandles;
1470*cdf0e10cSrcweir 					const SvxMSDffHandle* pData = pDefCustomShape->pHandles;
1471*cdf0e10cSrcweir 					seqHandles2.realloc( nCount );
1472*cdf0e10cSrcweir 					for ( i = 0; i < nCount; i++, pData++ )
1473*cdf0e10cSrcweir 					{
1474*cdf0e10cSrcweir 						sal_Int32 nPropertiesNeeded = 1;	// position is always needed
1475*cdf0e10cSrcweir 						sal_Int32 nFlags = pData->nFlags;
1476*cdf0e10cSrcweir 						if ( nFlags & MSDFF_HANDLE_FLAGS_MIRRORED_X )
1477*cdf0e10cSrcweir 							nPropertiesNeeded++;
1478*cdf0e10cSrcweir 						if ( nFlags & MSDFF_HANDLE_FLAGS_MIRRORED_Y )
1479*cdf0e10cSrcweir 							nPropertiesNeeded++;
1480*cdf0e10cSrcweir 						if ( nFlags & MSDFF_HANDLE_FLAGS_SWITCHED )
1481*cdf0e10cSrcweir 							nPropertiesNeeded++;
1482*cdf0e10cSrcweir 						if ( nFlags & MSDFF_HANDLE_FLAGS_POLAR )
1483*cdf0e10cSrcweir 						{
1484*cdf0e10cSrcweir 							nPropertiesNeeded++;
1485*cdf0e10cSrcweir 							if ( nFlags & MSDFF_HANDLE_FLAGS_RADIUS_RANGE )
1486*cdf0e10cSrcweir 							{
1487*cdf0e10cSrcweir 								if ( pData->nRangeXMin != DEFAULT_MINIMUM_SIGNED_COMPARE )
1488*cdf0e10cSrcweir 									nPropertiesNeeded++;
1489*cdf0e10cSrcweir 								if ( pData->nRangeXMax != DEFAULT_MAXIMUM_SIGNED_COMPARE )
1490*cdf0e10cSrcweir 									nPropertiesNeeded++;
1491*cdf0e10cSrcweir 							}
1492*cdf0e10cSrcweir 						}
1493*cdf0e10cSrcweir 						else if ( nFlags & MSDFF_HANDLE_FLAGS_RANGE )
1494*cdf0e10cSrcweir 						{
1495*cdf0e10cSrcweir 							if ( pData->nRangeXMin != DEFAULT_MINIMUM_SIGNED_COMPARE )
1496*cdf0e10cSrcweir 								nPropertiesNeeded++;
1497*cdf0e10cSrcweir 							if ( pData->nRangeXMax != DEFAULT_MAXIMUM_SIGNED_COMPARE )
1498*cdf0e10cSrcweir 								nPropertiesNeeded++;
1499*cdf0e10cSrcweir 							if ( pData->nRangeYMin != DEFAULT_MINIMUM_SIGNED_COMPARE )
1500*cdf0e10cSrcweir 								nPropertiesNeeded++;
1501*cdf0e10cSrcweir 							if ( pData->nRangeYMax != DEFAULT_MAXIMUM_SIGNED_COMPARE )
1502*cdf0e10cSrcweir 								nPropertiesNeeded++;
1503*cdf0e10cSrcweir 						}
1504*cdf0e10cSrcweir 
1505*cdf0e10cSrcweir 						n = 0;
1506*cdf0e10cSrcweir 						com::sun::star::beans::PropertyValues& rPropValues = seqHandles2[ i ];
1507*cdf0e10cSrcweir 						rPropValues.realloc( nPropertiesNeeded );
1508*cdf0e10cSrcweir 
1509*cdf0e10cSrcweir 						// POSITION
1510*cdf0e10cSrcweir 						{
1511*cdf0e10cSrcweir 							const rtl::OUString	sPosition( RTL_CONSTASCII_USTRINGPARAM ( "Position" ) );
1512*cdf0e10cSrcweir 							::com::sun::star::drawing::EnhancedCustomShapeParameterPair aPosition;
1513*cdf0e10cSrcweir 							EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aPosition.First, pData->nPositionX, sal_True, sal_True );
1514*cdf0e10cSrcweir 							EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aPosition.Second, pData->nPositionY, sal_True, sal_False );
1515*cdf0e10cSrcweir 							rPropValues[ n ].Name = sPosition;
1516*cdf0e10cSrcweir 							rPropValues[ n++ ].Value <<= aPosition;
1517*cdf0e10cSrcweir 						}
1518*cdf0e10cSrcweir 						if ( nFlags & MSDFF_HANDLE_FLAGS_MIRRORED_X )
1519*cdf0e10cSrcweir 						{
1520*cdf0e10cSrcweir 							const rtl::OUString	sMirroredX( RTL_CONSTASCII_USTRINGPARAM ( "MirroredX" ) );
1521*cdf0e10cSrcweir 							sal_Bool bMirroredX = sal_True;
1522*cdf0e10cSrcweir 							rPropValues[ n ].Name = sMirroredX;
1523*cdf0e10cSrcweir 							rPropValues[ n++ ].Value <<= bMirroredX;
1524*cdf0e10cSrcweir 						}
1525*cdf0e10cSrcweir 						if ( nFlags & MSDFF_HANDLE_FLAGS_MIRRORED_Y )
1526*cdf0e10cSrcweir 						{
1527*cdf0e10cSrcweir 							const rtl::OUString	sMirroredY( RTL_CONSTASCII_USTRINGPARAM ( "MirroredY" ) );
1528*cdf0e10cSrcweir 							sal_Bool bMirroredY = sal_True;
1529*cdf0e10cSrcweir 							rPropValues[ n ].Name = sMirroredY;
1530*cdf0e10cSrcweir 							rPropValues[ n++ ].Value <<= bMirroredY;
1531*cdf0e10cSrcweir 						}
1532*cdf0e10cSrcweir 						if ( nFlags & MSDFF_HANDLE_FLAGS_SWITCHED )
1533*cdf0e10cSrcweir 						{
1534*cdf0e10cSrcweir 							const rtl::OUString	sSwitched( RTL_CONSTASCII_USTRINGPARAM ( "Switched" ) );
1535*cdf0e10cSrcweir 							sal_Bool bSwitched = sal_True;
1536*cdf0e10cSrcweir 							rPropValues[ n ].Name = sSwitched;
1537*cdf0e10cSrcweir 							rPropValues[ n++ ].Value <<= bSwitched;
1538*cdf0e10cSrcweir 						}
1539*cdf0e10cSrcweir 						if ( nFlags & MSDFF_HANDLE_FLAGS_POLAR )
1540*cdf0e10cSrcweir 						{
1541*cdf0e10cSrcweir 							const rtl::OUString	sPolar( RTL_CONSTASCII_USTRINGPARAM ( "Polar" ) );
1542*cdf0e10cSrcweir 							::com::sun::star::drawing::EnhancedCustomShapeParameterPair aCenter;
1543*cdf0e10cSrcweir 							EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aCenter.First,  pData->nCenterX,
1544*cdf0e10cSrcweir 								( nFlags & MSDFF_HANDLE_FLAGS_CENTER_X_IS_SPECIAL ) != 0, sal_True  );
1545*cdf0e10cSrcweir 							EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aCenter.Second, pData->nCenterY,
1546*cdf0e10cSrcweir 								( nFlags & MSDFF_HANDLE_FLAGS_CENTER_Y_IS_SPECIAL ) != 0, sal_False );
1547*cdf0e10cSrcweir 							rPropValues[ n ].Name = sPolar;
1548*cdf0e10cSrcweir 							rPropValues[ n++ ].Value <<= aCenter;
1549*cdf0e10cSrcweir 							if ( nFlags & MSDFF_HANDLE_FLAGS_RADIUS_RANGE )
1550*cdf0e10cSrcweir 							{
1551*cdf0e10cSrcweir 								if ( pData->nRangeXMin != DEFAULT_MINIMUM_SIGNED_COMPARE )
1552*cdf0e10cSrcweir 								{
1553*cdf0e10cSrcweir 									const rtl::OUString	sRadiusRangeMinimum( RTL_CONSTASCII_USTRINGPARAM ( "RadiusRangeMinimum" ) );
1554*cdf0e10cSrcweir 									::com::sun::star::drawing::EnhancedCustomShapeParameter aRadiusRangeMinimum;
1555*cdf0e10cSrcweir 									EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aRadiusRangeMinimum, pData->nRangeXMin,
1556*cdf0e10cSrcweir 										( nFlags & MSDFF_HANDLE_FLAGS_RANGE_X_MIN_IS_SPECIAL ) != 0, sal_True  );
1557*cdf0e10cSrcweir 									rPropValues[ n ].Name = sRadiusRangeMinimum;
1558*cdf0e10cSrcweir 									rPropValues[ n++ ].Value <<= aRadiusRangeMinimum;
1559*cdf0e10cSrcweir 								}
1560*cdf0e10cSrcweir 								if ( pData->nRangeXMax != DEFAULT_MAXIMUM_SIGNED_COMPARE )
1561*cdf0e10cSrcweir 								{
1562*cdf0e10cSrcweir 									const rtl::OUString	sRadiusRangeMaximum( RTL_CONSTASCII_USTRINGPARAM ( "RadiusRangeMaximum" ) );
1563*cdf0e10cSrcweir 									::com::sun::star::drawing::EnhancedCustomShapeParameter aRadiusRangeMaximum;
1564*cdf0e10cSrcweir 									EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aRadiusRangeMaximum, pData->nRangeXMax,
1565*cdf0e10cSrcweir 										( nFlags & MSDFF_HANDLE_FLAGS_RANGE_X_MAX_IS_SPECIAL ) != 0, sal_False );
1566*cdf0e10cSrcweir 									rPropValues[ n ].Name = sRadiusRangeMaximum;
1567*cdf0e10cSrcweir 									rPropValues[ n++ ].Value <<= aRadiusRangeMaximum;
1568*cdf0e10cSrcweir 								}
1569*cdf0e10cSrcweir 							}
1570*cdf0e10cSrcweir 						}
1571*cdf0e10cSrcweir 						else if ( nFlags & MSDFF_HANDLE_FLAGS_RANGE )
1572*cdf0e10cSrcweir 						{
1573*cdf0e10cSrcweir 							if ( pData->nRangeXMin != DEFAULT_MINIMUM_SIGNED_COMPARE )
1574*cdf0e10cSrcweir 							{
1575*cdf0e10cSrcweir 								const rtl::OUString	sRangeXMinimum( RTL_CONSTASCII_USTRINGPARAM ( "RangeXMinimum" ) );
1576*cdf0e10cSrcweir 								::com::sun::star::drawing::EnhancedCustomShapeParameter aRangeXMinimum;
1577*cdf0e10cSrcweir 								EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aRangeXMinimum, pData->nRangeXMin,
1578*cdf0e10cSrcweir 									( nFlags & MSDFF_HANDLE_FLAGS_RANGE_X_MIN_IS_SPECIAL ) != 0, sal_True  );
1579*cdf0e10cSrcweir 								rPropValues[ n ].Name = sRangeXMinimum;
1580*cdf0e10cSrcweir 								rPropValues[ n++ ].Value <<= aRangeXMinimum;
1581*cdf0e10cSrcweir 							}
1582*cdf0e10cSrcweir 							if ( pData->nRangeXMax != DEFAULT_MAXIMUM_SIGNED_COMPARE )
1583*cdf0e10cSrcweir 							{
1584*cdf0e10cSrcweir 								const rtl::OUString	sRangeXMaximum( RTL_CONSTASCII_USTRINGPARAM ( "RangeXMaximum" ) );
1585*cdf0e10cSrcweir 								::com::sun::star::drawing::EnhancedCustomShapeParameter aRangeXMaximum;
1586*cdf0e10cSrcweir 								EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aRangeXMaximum, pData->nRangeXMax,
1587*cdf0e10cSrcweir 									( nFlags & MSDFF_HANDLE_FLAGS_RANGE_X_MAX_IS_SPECIAL ) != 0, sal_False );
1588*cdf0e10cSrcweir 								rPropValues[ n ].Name = sRangeXMaximum;
1589*cdf0e10cSrcweir 								rPropValues[ n++ ].Value <<= aRangeXMaximum;
1590*cdf0e10cSrcweir 							}
1591*cdf0e10cSrcweir 							if ( pData->nRangeYMin != DEFAULT_MINIMUM_SIGNED_COMPARE )
1592*cdf0e10cSrcweir 							{
1593*cdf0e10cSrcweir 								const rtl::OUString	sRangeYMinimum( RTL_CONSTASCII_USTRINGPARAM ( "RangeYMinimum" ) );
1594*cdf0e10cSrcweir 								::com::sun::star::drawing::EnhancedCustomShapeParameter aRangeYMinimum;
1595*cdf0e10cSrcweir 								EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aRangeYMinimum, pData->nRangeYMin,
1596*cdf0e10cSrcweir 									( nFlags & MSDFF_HANDLE_FLAGS_RANGE_Y_MIN_IS_SPECIAL ) != 0, sal_True );
1597*cdf0e10cSrcweir 								rPropValues[ n ].Name = sRangeYMinimum;
1598*cdf0e10cSrcweir 								rPropValues[ n++ ].Value <<= aRangeYMinimum;
1599*cdf0e10cSrcweir 							}
1600*cdf0e10cSrcweir 							if ( pData->nRangeYMax != DEFAULT_MAXIMUM_SIGNED_COMPARE )
1601*cdf0e10cSrcweir 							{
1602*cdf0e10cSrcweir 								const rtl::OUString	sRangeYMaximum( RTL_CONSTASCII_USTRINGPARAM ( "RangeYMaximum" ) );
1603*cdf0e10cSrcweir 								::com::sun::star::drawing::EnhancedCustomShapeParameter aRangeYMaximum;
1604*cdf0e10cSrcweir 								EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aRangeYMaximum, pData->nRangeYMax,
1605*cdf0e10cSrcweir 									( nFlags & MSDFF_HANDLE_FLAGS_RANGE_Y_MAX_IS_SPECIAL ) != 0, sal_False );
1606*cdf0e10cSrcweir 								rPropValues[ n ].Name = sRangeYMaximum;
1607*cdf0e10cSrcweir 								rPropValues[ n++ ].Value <<= aRangeYMaximum;
1608*cdf0e10cSrcweir 							}
1609*cdf0e10cSrcweir 						}
1610*cdf0e10cSrcweir 					}
1611*cdf0e10cSrcweir 					if ( seqHandles1 == seqHandles2 )
1612*cdf0e10cSrcweir 						bIsDefaultGeometry = sal_True;
1613*cdf0e10cSrcweir 				}
1614*cdf0e10cSrcweir 			}
1615*cdf0e10cSrcweir 			else if ( pDefCustomShape && ( ( pDefCustomShape->nHandles == 0 ) || ( pDefCustomShape->pHandles == 0 ) ) )
1616*cdf0e10cSrcweir 				bIsDefaultGeometry = sal_True;
1617*cdf0e10cSrcweir 		}
1618*cdf0e10cSrcweir 		break;
1619*cdf0e10cSrcweir 	}
1620*cdf0e10cSrcweir 	return bIsDefaultGeometry;
1621*cdf0e10cSrcweir }
1622*cdf0e10cSrcweir 
1623*cdf0e10cSrcweir void SdrObjCustomShape::TakeObjInfo(SdrObjTransformInfoRec& rInfo) const
1624*cdf0e10cSrcweir {
1625*cdf0e10cSrcweir 	rInfo.bResizeFreeAllowed=fObjectRotation == 0.0;
1626*cdf0e10cSrcweir 	rInfo.bResizePropAllowed=sal_True;
1627*cdf0e10cSrcweir 	rInfo.bRotateFreeAllowed=sal_True;
1628*cdf0e10cSrcweir 	rInfo.bRotate90Allowed  =sal_True;
1629*cdf0e10cSrcweir 	rInfo.bMirrorFreeAllowed=sal_True;
1630*cdf0e10cSrcweir 	rInfo.bMirror45Allowed  =sal_True;
1631*cdf0e10cSrcweir 	rInfo.bMirror90Allowed  =sal_True;
1632*cdf0e10cSrcweir 	rInfo.bTransparenceAllowed = sal_False;
1633*cdf0e10cSrcweir 	rInfo.bGradientAllowed = sal_False;
1634*cdf0e10cSrcweir 	rInfo.bShearAllowed     =sal_True;
1635*cdf0e10cSrcweir 	rInfo.bEdgeRadiusAllowed=sal_False;
1636*cdf0e10cSrcweir 	rInfo.bNoContortion     =sal_True;
1637*cdf0e10cSrcweir 
1638*cdf0e10cSrcweir 	// #i37011#
1639*cdf0e10cSrcweir 	if ( mXRenderedCustomShape.is() )
1640*cdf0e10cSrcweir 	{
1641*cdf0e10cSrcweir 		const SdrObject* pRenderedCustomShape = GetSdrObjectFromXShape( mXRenderedCustomShape );
1642*cdf0e10cSrcweir 		if ( pRenderedCustomShape )
1643*cdf0e10cSrcweir 		{
1644*cdf0e10cSrcweir 			// #i37262#
1645*cdf0e10cSrcweir 			// Iterate self over the contained objects, since there are combinations of
1646*cdf0e10cSrcweir 			// polygon and curve objects. In that case, aInfo.bCanConvToPath and
1647*cdf0e10cSrcweir 			// aInfo.bCanConvToPoly would be false. What is needed here is an or, not an and.
1648*cdf0e10cSrcweir 			SdrObjListIter aIterator(*pRenderedCustomShape);
1649*cdf0e10cSrcweir 			while(aIterator.IsMore())
1650*cdf0e10cSrcweir 			{
1651*cdf0e10cSrcweir 				SdrObject* pCandidate = aIterator.Next();
1652*cdf0e10cSrcweir 				SdrObjTransformInfoRec aInfo;
1653*cdf0e10cSrcweir 				pCandidate->TakeObjInfo(aInfo);
1654*cdf0e10cSrcweir 
1655*cdf0e10cSrcweir 				// set path and poly conversion if one is possible since
1656*cdf0e10cSrcweir 				// this object will first be broken
1657*cdf0e10cSrcweir 				const sal_Bool bCanConvToPathOrPoly(aInfo.bCanConvToPath || aInfo.bCanConvToPoly);
1658*cdf0e10cSrcweir 				if(rInfo.bCanConvToPath != bCanConvToPathOrPoly)
1659*cdf0e10cSrcweir 				{
1660*cdf0e10cSrcweir 					rInfo.bCanConvToPath = bCanConvToPathOrPoly;
1661*cdf0e10cSrcweir 				}
1662*cdf0e10cSrcweir 
1663*cdf0e10cSrcweir 				if(rInfo.bCanConvToPoly != bCanConvToPathOrPoly)
1664*cdf0e10cSrcweir 				{
1665*cdf0e10cSrcweir 					rInfo.bCanConvToPoly = bCanConvToPathOrPoly;
1666*cdf0e10cSrcweir 				}
1667*cdf0e10cSrcweir 
1668*cdf0e10cSrcweir 				if(rInfo.bCanConvToContour != aInfo.bCanConvToContour)
1669*cdf0e10cSrcweir 				{
1670*cdf0e10cSrcweir 					rInfo.bCanConvToContour = aInfo.bCanConvToContour;
1671*cdf0e10cSrcweir 				}
1672*cdf0e10cSrcweir 			}
1673*cdf0e10cSrcweir 		}
1674*cdf0e10cSrcweir 	}
1675*cdf0e10cSrcweir }
1676*cdf0e10cSrcweir 
1677*cdf0e10cSrcweir void SdrObjCustomShape::SetModel(SdrModel* pNewModel)
1678*cdf0e10cSrcweir {
1679*cdf0e10cSrcweir 	SdrTextObj::SetModel(pNewModel);
1680*cdf0e10cSrcweir 	mXRenderedCustomShape.clear();
1681*cdf0e10cSrcweir }
1682*cdf0e10cSrcweir 
1683*cdf0e10cSrcweir sal_uInt16 SdrObjCustomShape::GetObjIdentifier() const
1684*cdf0e10cSrcweir {
1685*cdf0e10cSrcweir 	return sal_uInt16(OBJ_CUSTOMSHAPE);
1686*cdf0e10cSrcweir }
1687*cdf0e10cSrcweir 
1688*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
1689*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
1690*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
1691*cdf0e10cSrcweir 
1692*cdf0e10cSrcweir void SdrObjCustomShape::RecalcSnapRect()
1693*cdf0e10cSrcweir {
1694*cdf0e10cSrcweir 	SdrTextObj::RecalcSnapRect();
1695*cdf0e10cSrcweir }
1696*cdf0e10cSrcweir const Rectangle& SdrObjCustomShape::GetSnapRect() const
1697*cdf0e10cSrcweir {
1698*cdf0e10cSrcweir 	return SdrTextObj::GetSnapRect();
1699*cdf0e10cSrcweir }
1700*cdf0e10cSrcweir const Rectangle& SdrObjCustomShape::GetCurrentBoundRect() const
1701*cdf0e10cSrcweir {
1702*cdf0e10cSrcweir 	return SdrTextObj::GetCurrentBoundRect();
1703*cdf0e10cSrcweir }
1704*cdf0e10cSrcweir const Rectangle& SdrObjCustomShape::GetLogicRect() const
1705*cdf0e10cSrcweir {
1706*cdf0e10cSrcweir 	return SdrTextObj::GetLogicRect();
1707*cdf0e10cSrcweir }
1708*cdf0e10cSrcweir void SdrObjCustomShape::NbcSetSnapRect( const Rectangle& rRect )
1709*cdf0e10cSrcweir {
1710*cdf0e10cSrcweir 	aRect=rRect;
1711*cdf0e10cSrcweir 	ImpJustifyRect(aRect);
1712*cdf0e10cSrcweir 	InvalidateRenderGeometry();
1713*cdf0e10cSrcweir 	Rectangle aTextBound( aRect );
1714*cdf0e10cSrcweir 	if ( GetTextBounds( aTextBound ) )
1715*cdf0e10cSrcweir 	{
1716*cdf0e10cSrcweir 		if ( pModel==NULL || !pModel->IsPasteResize() )
1717*cdf0e10cSrcweir 		{
1718*cdf0e10cSrcweir 			long nHDist=GetTextLeftDistance()+GetTextRightDistance();
1719*cdf0e10cSrcweir 			long nVDist=GetTextUpperDistance()+GetTextLowerDistance();
1720*cdf0e10cSrcweir 			long nTWdt=aTextBound.GetWidth ()-1-nHDist; if (nTWdt<0) nTWdt=0;
1721*cdf0e10cSrcweir 			long nTHgt=aTextBound.GetHeight()-1-nVDist; if (nTHgt<0) nTHgt=0;
1722*cdf0e10cSrcweir 			if ( IsAutoGrowWidth() )
1723*cdf0e10cSrcweir 				NbcSetMinTextFrameWidth( nTWdt );
1724*cdf0e10cSrcweir 			if ( IsAutoGrowHeight() )
1725*cdf0e10cSrcweir 				NbcSetMinTextFrameHeight( nTHgt );
1726*cdf0e10cSrcweir 			NbcAdjustTextFrameWidthAndHeight();
1727*cdf0e10cSrcweir 		}
1728*cdf0e10cSrcweir 	}
1729*cdf0e10cSrcweir 	ImpCheckShear();
1730*cdf0e10cSrcweir 	SetRectsDirty();
1731*cdf0e10cSrcweir 	SetChanged();
1732*cdf0e10cSrcweir }
1733*cdf0e10cSrcweir void SdrObjCustomShape::SetSnapRect( const Rectangle& rRect )
1734*cdf0e10cSrcweir {
1735*cdf0e10cSrcweir 	Rectangle aBoundRect0;
1736*cdf0e10cSrcweir 	if ( pUserCall )
1737*cdf0e10cSrcweir 		aBoundRect0 = GetLastBoundRect();
1738*cdf0e10cSrcweir 	NbcSetSnapRect( rRect );
1739*cdf0e10cSrcweir 	BroadcastObjectChange();
1740*cdf0e10cSrcweir 	SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
1741*cdf0e10cSrcweir }
1742*cdf0e10cSrcweir void SdrObjCustomShape::NbcSetLogicRect( const Rectangle& rRect )
1743*cdf0e10cSrcweir {
1744*cdf0e10cSrcweir 	aRect = rRect;
1745*cdf0e10cSrcweir 	ImpJustifyRect( aRect );
1746*cdf0e10cSrcweir 	InvalidateRenderGeometry();
1747*cdf0e10cSrcweir 	Rectangle aTextBound( aRect );
1748*cdf0e10cSrcweir 	if ( GetTextBounds( aTextBound ) )
1749*cdf0e10cSrcweir 	{
1750*cdf0e10cSrcweir 		long nHDist=GetTextLeftDistance()+GetTextRightDistance();
1751*cdf0e10cSrcweir 		long nVDist=GetTextUpperDistance()+GetTextLowerDistance();
1752*cdf0e10cSrcweir 
1753*cdf0e10cSrcweir 		long nTWdt=aTextBound.GetWidth()-1-nHDist; if (nTWdt<0) nTWdt=0;
1754*cdf0e10cSrcweir 		long nTHgt=aTextBound.GetHeight()-1-nVDist; if (nTHgt<0) nTHgt=0;
1755*cdf0e10cSrcweir 		if ( IsAutoGrowWidth() )
1756*cdf0e10cSrcweir 			NbcSetMinTextFrameWidth( nTWdt );
1757*cdf0e10cSrcweir 		if ( IsAutoGrowHeight() )
1758*cdf0e10cSrcweir 			NbcSetMinTextFrameHeight( nTHgt );
1759*cdf0e10cSrcweir 		NbcAdjustTextFrameWidthAndHeight();
1760*cdf0e10cSrcweir 	}
1761*cdf0e10cSrcweir 	SetRectsDirty();
1762*cdf0e10cSrcweir 	SetChanged();
1763*cdf0e10cSrcweir }
1764*cdf0e10cSrcweir void SdrObjCustomShape::SetLogicRect( const Rectangle& rRect )
1765*cdf0e10cSrcweir {
1766*cdf0e10cSrcweir 	Rectangle aBoundRect0;
1767*cdf0e10cSrcweir 	if ( pUserCall )
1768*cdf0e10cSrcweir 		aBoundRect0 = GetLastBoundRect();
1769*cdf0e10cSrcweir 	NbcSetLogicRect(rRect);
1770*cdf0e10cSrcweir 	BroadcastObjectChange();
1771*cdf0e10cSrcweir 	SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
1772*cdf0e10cSrcweir }
1773*cdf0e10cSrcweir void SdrObjCustomShape::Move( const Size& rSiz )
1774*cdf0e10cSrcweir {
1775*cdf0e10cSrcweir 	if ( rSiz.Width() || rSiz.Height() )
1776*cdf0e10cSrcweir 	{
1777*cdf0e10cSrcweir 		Rectangle aBoundRect0;
1778*cdf0e10cSrcweir 		if ( pUserCall )
1779*cdf0e10cSrcweir 			aBoundRect0 = GetLastBoundRect();
1780*cdf0e10cSrcweir 		// #110094#-14 SendRepaintBroadcast();
1781*cdf0e10cSrcweir 		NbcMove(rSiz);
1782*cdf0e10cSrcweir 		SetChanged();
1783*cdf0e10cSrcweir 		BroadcastObjectChange();
1784*cdf0e10cSrcweir 		SendUserCall(SDRUSERCALL_MOVEONLY,aBoundRect0);
1785*cdf0e10cSrcweir 	}
1786*cdf0e10cSrcweir }
1787*cdf0e10cSrcweir void SdrObjCustomShape::NbcMove( const Size& rSiz )
1788*cdf0e10cSrcweir {
1789*cdf0e10cSrcweir 	SdrTextObj::NbcMove( rSiz );
1790*cdf0e10cSrcweir 	if ( mXRenderedCustomShape.is() )
1791*cdf0e10cSrcweir 	{
1792*cdf0e10cSrcweir 		SdrObject* pRenderedCustomShape = GetSdrObjectFromXShape( mXRenderedCustomShape );
1793*cdf0e10cSrcweir 		if ( pRenderedCustomShape )
1794*cdf0e10cSrcweir         {
1795*cdf0e10cSrcweir             // #i97149# the visualisation shape needs to be informed
1796*cdf0e10cSrcweir             // about change, too
1797*cdf0e10cSrcweir             pRenderedCustomShape->ActionChanged();
1798*cdf0e10cSrcweir 			pRenderedCustomShape->NbcMove( rSiz );
1799*cdf0e10cSrcweir         }
1800*cdf0e10cSrcweir 	}
1801*cdf0e10cSrcweir 
1802*cdf0e10cSrcweir 	// #i37011# adapt geometry shadow
1803*cdf0e10cSrcweir 	if(mpLastShadowGeometry)
1804*cdf0e10cSrcweir 	{
1805*cdf0e10cSrcweir 		mpLastShadowGeometry->NbcMove( rSiz );
1806*cdf0e10cSrcweir 	}
1807*cdf0e10cSrcweir }
1808*cdf0e10cSrcweir void SdrObjCustomShape::Resize( const Point& rRef, const Fraction& xFact, const Fraction& yFact )
1809*cdf0e10cSrcweir {
1810*cdf0e10cSrcweir 	SdrTextObj::Resize( rRef, xFact, yFact );
1811*cdf0e10cSrcweir }
1812*cdf0e10cSrcweir 
1813*cdf0e10cSrcweir void SdrObjCustomShape::NbcResize( const Point& rRef, const Fraction& rxFact, const Fraction& ryFact )
1814*cdf0e10cSrcweir {
1815*cdf0e10cSrcweir 	Fraction xFact( rxFact );
1816*cdf0e10cSrcweir 	Fraction yFact( ryFact );
1817*cdf0e10cSrcweir 
1818*cdf0e10cSrcweir 	// taking care of handles that should not been changed
1819*cdf0e10cSrcweir 	Rectangle aOld( aRect );
1820*cdf0e10cSrcweir 	std::vector< SdrCustomShapeInteraction > aInteractionHandles( GetInteractionHandles( this ) );
1821*cdf0e10cSrcweir 
1822*cdf0e10cSrcweir 	SdrTextObj::NbcResize( rRef, xFact, yFact );
1823*cdf0e10cSrcweir 
1824*cdf0e10cSrcweir 	if ( ( xFact.GetNumerator() != xFact.GetDenominator() )
1825*cdf0e10cSrcweir 		|| ( yFact.GetNumerator()!= yFact.GetDenominator() ) )
1826*cdf0e10cSrcweir 	{
1827*cdf0e10cSrcweir 		if ( ( ( xFact.GetNumerator() < 0 ) && ( xFact.GetDenominator() > 0 ) ) ||
1828*cdf0e10cSrcweir 			( ( xFact.GetNumerator() > 0 ) && ( xFact.GetDenominator() < 0 ) ) )
1829*cdf0e10cSrcweir 		{
1830*cdf0e10cSrcweir 			SetMirroredX( IsMirroredX() == sal_False );
1831*cdf0e10cSrcweir 		}
1832*cdf0e10cSrcweir 		if ( ( ( yFact.GetNumerator() < 0 ) && ( yFact.GetDenominator() > 0 ) ) ||
1833*cdf0e10cSrcweir 			( ( yFact.GetNumerator() > 0 ) && ( yFact.GetDenominator() < 0 ) ) )
1834*cdf0e10cSrcweir 		{
1835*cdf0e10cSrcweir 			SetMirroredY( IsMirroredY() == sal_False );
1836*cdf0e10cSrcweir 		}
1837*cdf0e10cSrcweir 	}
1838*cdf0e10cSrcweir 
1839*cdf0e10cSrcweir 	std::vector< SdrCustomShapeInteraction >::iterator aIter( aInteractionHandles.begin() );
1840*cdf0e10cSrcweir 	while ( aIter != aInteractionHandles.end() )
1841*cdf0e10cSrcweir 	{
1842*cdf0e10cSrcweir 		try
1843*cdf0e10cSrcweir 		{
1844*cdf0e10cSrcweir 			if ( aIter->nMode & CUSTOMSHAPE_HANDLE_RESIZE_FIXED )
1845*cdf0e10cSrcweir 				aIter->xInteraction->setControllerPosition( aIter->aPosition );
1846*cdf0e10cSrcweir 			if ( aIter->nMode & CUSTOMSHAPE_HANDLE_RESIZE_ABSOLUTE_X )
1847*cdf0e10cSrcweir 			{
1848*cdf0e10cSrcweir 				sal_Int32 nX = ( aIter->aPosition.X - aOld.Left() ) + aRect.Left();
1849*cdf0e10cSrcweir 				aIter->xInteraction->setControllerPosition( com::sun::star::awt::Point( nX, aIter->xInteraction->getPosition().Y ) );
1850*cdf0e10cSrcweir 			}
1851*cdf0e10cSrcweir 			if ( aIter->nMode & CUSTOMSHAPE_HANDLE_RESIZE_ABSOLUTE_Y )
1852*cdf0e10cSrcweir 			{
1853*cdf0e10cSrcweir 				sal_Int32 nY = ( aIter->aPosition.Y - aOld.Top() ) + aRect.Top();
1854*cdf0e10cSrcweir 				aIter->xInteraction->setControllerPosition( com::sun::star::awt::Point( aIter->xInteraction->getPosition().X, nY ) );
1855*cdf0e10cSrcweir 			}
1856*cdf0e10cSrcweir 		}
1857*cdf0e10cSrcweir 		catch ( const uno::RuntimeException& )
1858*cdf0e10cSrcweir 		{
1859*cdf0e10cSrcweir 		}
1860*cdf0e10cSrcweir 		aIter++;
1861*cdf0e10cSrcweir 	}
1862*cdf0e10cSrcweir 	InvalidateRenderGeometry();
1863*cdf0e10cSrcweir }
1864*cdf0e10cSrcweir void SdrObjCustomShape::NbcRotate( const Point& rRef, long nWink, double sn, double cs )
1865*cdf0e10cSrcweir {
1866*cdf0e10cSrcweir 	sal_Bool bMirroredX = IsMirroredX();
1867*cdf0e10cSrcweir 	sal_Bool bMirroredY = IsMirroredY();
1868*cdf0e10cSrcweir 
1869*cdf0e10cSrcweir 	fObjectRotation = fmod( fObjectRotation, 360.0 );
1870*cdf0e10cSrcweir 	if ( fObjectRotation < 0 )
1871*cdf0e10cSrcweir 		fObjectRotation = 360 + fObjectRotation;
1872*cdf0e10cSrcweir 
1873*cdf0e10cSrcweir 	// the rotation angle for ashapes is stored in fObjectRotation, this rotation
1874*cdf0e10cSrcweir 	// has to be applied to the text object (which is internally using aGeo.nWink).
1875*cdf0e10cSrcweir 	SdrTextObj::NbcRotate( aRect.TopLeft(), -aGeo.nDrehWink,		// retrieving the unrotated text object
1876*cdf0e10cSrcweir 							sin( (-aGeo.nDrehWink) * F_PI18000 ),
1877*cdf0e10cSrcweir 							cos( (-aGeo.nDrehWink) * F_PI18000 ) );
1878*cdf0e10cSrcweir 	aGeo.nDrehWink = 0;												// resetting aGeo data
1879*cdf0e10cSrcweir 	aGeo.RecalcSinCos();
1880*cdf0e10cSrcweir 
1881*cdf0e10cSrcweir 	long nW = (long)( fObjectRotation * 100 );						// applying our object rotation
1882*cdf0e10cSrcweir 	if ( bMirroredX )
1883*cdf0e10cSrcweir 		nW = 36000 - nW;
1884*cdf0e10cSrcweir 	if ( bMirroredY )
1885*cdf0e10cSrcweir 		nW = 18000 - nW;
1886*cdf0e10cSrcweir 	nW = nW % 36000;
1887*cdf0e10cSrcweir 	if ( nW < 0 )
1888*cdf0e10cSrcweir 		nW = 36000 + nW;
1889*cdf0e10cSrcweir 	SdrTextObj::NbcRotate( aRect.TopLeft(), nW,						// applying text rotation
1890*cdf0e10cSrcweir 							sin( nW * F_PI18000 ),
1891*cdf0e10cSrcweir 							cos( nW * F_PI18000 ) );
1892*cdf0e10cSrcweir 
1893*cdf0e10cSrcweir 	int nSwap = 0;
1894*cdf0e10cSrcweir 	if ( bMirroredX )
1895*cdf0e10cSrcweir 		nSwap ^= 1;
1896*cdf0e10cSrcweir 	if ( bMirroredY )
1897*cdf0e10cSrcweir 		nSwap ^= 1;
1898*cdf0e10cSrcweir 
1899*cdf0e10cSrcweir 	double fWink = nWink;													// updating to our new object rotation
1900*cdf0e10cSrcweir 	fWink /= 100.0;
1901*cdf0e10cSrcweir 	fObjectRotation = fmod( nSwap ? fObjectRotation - fWink : fObjectRotation + fWink, 360.0 );
1902*cdf0e10cSrcweir 	if ( fObjectRotation < 0 )
1903*cdf0e10cSrcweir 		fObjectRotation = 360 + fObjectRotation;
1904*cdf0e10cSrcweir 
1905*cdf0e10cSrcweir 	SdrTextObj::NbcRotate( rRef, nWink, sn, cs );							// applying text rotation
1906*cdf0e10cSrcweir 	InvalidateRenderGeometry();
1907*cdf0e10cSrcweir }
1908*cdf0e10cSrcweir 
1909*cdf0e10cSrcweir void SdrObjCustomShape::NbcMirror( const Point& rRef1, const Point& rRef2 )
1910*cdf0e10cSrcweir {
1911*cdf0e10cSrcweir 	// storing horizontal and vertical flipping without modifying the rotate angle
1912*cdf0e10cSrcweir 
1913*cdf0e10cSrcweir 	sal_Bool bHorz = sal_False;
1914*cdf0e10cSrcweir 	sal_Bool bVert = sal_False;
1915*cdf0e10cSrcweir 	if ( rRef1.X() == rRef2.X() )
1916*cdf0e10cSrcweir 		bHorz = sal_True;
1917*cdf0e10cSrcweir 	if ( rRef1.Y() == rRef2.Y() )
1918*cdf0e10cSrcweir 		bVert = sal_True;
1919*cdf0e10cSrcweir 	if ( !bHorz && !bVert )
1920*cdf0e10cSrcweir 		bHorz = bVert = sal_True;
1921*cdf0e10cSrcweir 
1922*cdf0e10cSrcweir 	if ( bHorz || bVert )
1923*cdf0e10cSrcweir 	{
1924*cdf0e10cSrcweir 		SdrCustomShapeGeometryItem aGeometryItem( (SdrCustomShapeGeometryItem&)GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) );
1925*cdf0e10cSrcweir 
1926*cdf0e10cSrcweir 		/////////////////
1927*cdf0e10cSrcweir 		// "MirroredX" //
1928*cdf0e10cSrcweir 		/////////////////
1929*cdf0e10cSrcweir 		if ( bHorz )
1930*cdf0e10cSrcweir 		{
1931*cdf0e10cSrcweir 			const rtl::OUString	sMirroredX( RTL_CONSTASCII_USTRINGPARAM ( "MirroredX" ) );
1932*cdf0e10cSrcweir 			com::sun::star::uno::Any* pAny = aGeometryItem.GetPropertyValueByName( sMirroredX );
1933*cdf0e10cSrcweir 			if ( pAny )
1934*cdf0e10cSrcweir 			{
1935*cdf0e10cSrcweir 				sal_Bool bFlip = sal_Bool();
1936*cdf0e10cSrcweir 				if ( *pAny >>= bFlip )
1937*cdf0e10cSrcweir 				{
1938*cdf0e10cSrcweir 					if ( bFlip )
1939*cdf0e10cSrcweir 						bHorz = sal_False;
1940*cdf0e10cSrcweir 				}
1941*cdf0e10cSrcweir 			}
1942*cdf0e10cSrcweir 			PropertyValue aPropVal;
1943*cdf0e10cSrcweir 			aPropVal.Name = sMirroredX;
1944*cdf0e10cSrcweir 			aPropVal.Value <<= bHorz;
1945*cdf0e10cSrcweir 			aGeometryItem.SetPropertyValue( aPropVal );
1946*cdf0e10cSrcweir 		}
1947*cdf0e10cSrcweir 
1948*cdf0e10cSrcweir 		/////////////////
1949*cdf0e10cSrcweir 		// "MirroredY" //
1950*cdf0e10cSrcweir 		/////////////////
1951*cdf0e10cSrcweir 		if ( bVert )
1952*cdf0e10cSrcweir 		{
1953*cdf0e10cSrcweir 			const rtl::OUString	sMirroredY( RTL_CONSTASCII_USTRINGPARAM ( "MirroredY" ) );
1954*cdf0e10cSrcweir 			com::sun::star::uno::Any* pAny = aGeometryItem.GetPropertyValueByName( sMirroredY );
1955*cdf0e10cSrcweir 			if ( pAny )
1956*cdf0e10cSrcweir 			{
1957*cdf0e10cSrcweir 				sal_Bool bFlip = sal_Bool();
1958*cdf0e10cSrcweir 				if ( *pAny >>= bFlip )
1959*cdf0e10cSrcweir 				{
1960*cdf0e10cSrcweir 					if ( bFlip )
1961*cdf0e10cSrcweir 						bVert = sal_False;
1962*cdf0e10cSrcweir 				}
1963*cdf0e10cSrcweir 			}
1964*cdf0e10cSrcweir 			PropertyValue aPropVal;
1965*cdf0e10cSrcweir 			aPropVal.Name = sMirroredY;
1966*cdf0e10cSrcweir 			aPropVal.Value <<= bVert;
1967*cdf0e10cSrcweir 			aGeometryItem.SetPropertyValue( aPropVal );
1968*cdf0e10cSrcweir 		}
1969*cdf0e10cSrcweir 		SetMergedItem( aGeometryItem );
1970*cdf0e10cSrcweir 	}
1971*cdf0e10cSrcweir 	SdrTextObj::NbcMirror( rRef1, rRef2 );
1972*cdf0e10cSrcweir 	InvalidateRenderGeometry();
1973*cdf0e10cSrcweir }
1974*cdf0e10cSrcweir 
1975*cdf0e10cSrcweir void SdrObjCustomShape::Shear( const Point& rRef, long nWink, double tn, FASTBOOL bVShear )
1976*cdf0e10cSrcweir {
1977*cdf0e10cSrcweir 	SdrTextObj::Shear( rRef, nWink, tn, bVShear );
1978*cdf0e10cSrcweir 	InvalidateRenderGeometry();
1979*cdf0e10cSrcweir }
1980*cdf0e10cSrcweir void SdrObjCustomShape::NbcShear( const Point& rRef, long nWink, double tn, FASTBOOL bVShear )
1981*cdf0e10cSrcweir {
1982*cdf0e10cSrcweir 	long nDrehWink = aGeo.nDrehWink;
1983*cdf0e10cSrcweir 	if ( nDrehWink )
1984*cdf0e10cSrcweir 	{
1985*cdf0e10cSrcweir 		aGeo.nDrehWink = -nDrehWink;
1986*cdf0e10cSrcweir 		aGeo.RecalcSinCos();
1987*cdf0e10cSrcweir 		NbcRotate( rRef, aGeo.nDrehWink, aGeo.nSin, aGeo.nCos );
1988*cdf0e10cSrcweir 	}
1989*cdf0e10cSrcweir 	SdrTextObj::NbcShear(rRef,nWink,tn,bVShear);
1990*cdf0e10cSrcweir 	if ( nDrehWink )
1991*cdf0e10cSrcweir 	{
1992*cdf0e10cSrcweir 		aGeo.nDrehWink = nDrehWink;
1993*cdf0e10cSrcweir 		aGeo.RecalcSinCos();
1994*cdf0e10cSrcweir 		Rotate( rRef, aGeo.nDrehWink, aGeo.nSin, aGeo.nCos );
1995*cdf0e10cSrcweir 	}
1996*cdf0e10cSrcweir 	InvalidateRenderGeometry();
1997*cdf0e10cSrcweir }
1998*cdf0e10cSrcweir 
1999*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
2000*cdf0e10cSrcweir 
2001*cdf0e10cSrcweir SdrGluePoint SdrObjCustomShape::GetVertexGluePoint(sal_uInt16 nPosNum) const
2002*cdf0e10cSrcweir {
2003*cdf0e10cSrcweir 	sal_Int32 nWdt = ImpGetLineWdt(); // #i25616# ((XLineWidthItem&)(GetObjectItem(XATTR_LINEWIDTH))).GetValue();
2004*cdf0e10cSrcweir 
2005*cdf0e10cSrcweir 	// #i25616#
2006*cdf0e10cSrcweir 	if(!LineIsOutsideGeometry())
2007*cdf0e10cSrcweir 	{
2008*cdf0e10cSrcweir 		nWdt++;
2009*cdf0e10cSrcweir 		nWdt /= 2;
2010*cdf0e10cSrcweir 	}
2011*cdf0e10cSrcweir 
2012*cdf0e10cSrcweir 	Point aPt;
2013*cdf0e10cSrcweir 	switch (nPosNum) {
2014*cdf0e10cSrcweir 		case 0: aPt=aRect.TopCenter();    aPt.Y()-=nWdt; break;
2015*cdf0e10cSrcweir 		case 1: aPt=aRect.RightCenter();  aPt.X()+=nWdt; break;
2016*cdf0e10cSrcweir 		case 2: aPt=aRect.BottomCenter(); aPt.Y()+=nWdt; break;
2017*cdf0e10cSrcweir 		case 3: aPt=aRect.LeftCenter();   aPt.X()-=nWdt; break;
2018*cdf0e10cSrcweir 	}
2019*cdf0e10cSrcweir 	if (aGeo.nShearWink!=0) ShearPoint(aPt,aRect.TopLeft(),aGeo.nTan);
2020*cdf0e10cSrcweir 	if (aGeo.nDrehWink!=0) RotatePoint(aPt,aRect.TopLeft(),aGeo.nSin,aGeo.nCos);
2021*cdf0e10cSrcweir 	aPt-=GetSnapRect().Center();
2022*cdf0e10cSrcweir 	SdrGluePoint aGP(aPt);
2023*cdf0e10cSrcweir 	aGP.SetPercent(sal_False);
2024*cdf0e10cSrcweir 	return aGP;
2025*cdf0e10cSrcweir }
2026*cdf0e10cSrcweir 
2027*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
2028*cdf0e10cSrcweir 
2029*cdf0e10cSrcweir // #i38892#
2030*cdf0e10cSrcweir void SdrObjCustomShape::ImpCheckCustomGluePointsAreAdded()
2031*cdf0e10cSrcweir {
2032*cdf0e10cSrcweir 	const SdrObject* pSdrObject = GetSdrObjectFromCustomShape();
2033*cdf0e10cSrcweir 
2034*cdf0e10cSrcweir 	if(pSdrObject)
2035*cdf0e10cSrcweir 	{
2036*cdf0e10cSrcweir 		const SdrGluePointList* pSource = pSdrObject->GetGluePointList();
2037*cdf0e10cSrcweir 
2038*cdf0e10cSrcweir 		if(pSource && pSource->GetCount())
2039*cdf0e10cSrcweir 		{
2040*cdf0e10cSrcweir 			if(!SdrTextObj::GetGluePointList())
2041*cdf0e10cSrcweir 			{
2042*cdf0e10cSrcweir 				SdrTextObj::ForceGluePointList();
2043*cdf0e10cSrcweir 			}
2044*cdf0e10cSrcweir 
2045*cdf0e10cSrcweir 			const SdrGluePointList* pList = SdrTextObj::GetGluePointList();
2046*cdf0e10cSrcweir 
2047*cdf0e10cSrcweir 			if(pList)
2048*cdf0e10cSrcweir 			{
2049*cdf0e10cSrcweir 				SdrGluePointList aNewList;
2050*cdf0e10cSrcweir 				sal_uInt16 a;
2051*cdf0e10cSrcweir 
2052*cdf0e10cSrcweir 				for(a = 0; a < pSource->GetCount(); a++)
2053*cdf0e10cSrcweir 				{
2054*cdf0e10cSrcweir 					SdrGluePoint aCopy((*pSource)[a]);
2055*cdf0e10cSrcweir 					aCopy.SetUserDefined(sal_False);
2056*cdf0e10cSrcweir 					aNewList.Insert(aCopy);
2057*cdf0e10cSrcweir 				}
2058*cdf0e10cSrcweir 
2059*cdf0e10cSrcweir 				sal_Bool bMirroredX = IsMirroredX();
2060*cdf0e10cSrcweir 				sal_Bool bMirroredY = IsMirroredY();
2061*cdf0e10cSrcweir 
2062*cdf0e10cSrcweir 				long nShearWink = aGeo.nShearWink;
2063*cdf0e10cSrcweir 				double fTan = aGeo.nTan;
2064*cdf0e10cSrcweir 
2065*cdf0e10cSrcweir 				if ( aGeo.nDrehWink || nShearWink || bMirroredX || bMirroredY )
2066*cdf0e10cSrcweir 				{
2067*cdf0e10cSrcweir 					Polygon aPoly( aRect );
2068*cdf0e10cSrcweir 					if( nShearWink )
2069*cdf0e10cSrcweir 					{
2070*cdf0e10cSrcweir 						sal_uInt16 nPointCount=aPoly.GetSize();
2071*cdf0e10cSrcweir 						for (sal_uInt16 i=0; i<nPointCount; i++)
2072*cdf0e10cSrcweir 							ShearPoint(aPoly[i],aRect.Center(), fTan, sal_False );
2073*cdf0e10cSrcweir 					}
2074*cdf0e10cSrcweir 					if ( aGeo.nDrehWink )
2075*cdf0e10cSrcweir 						aPoly.Rotate( aRect.Center(), aGeo.nDrehWink / 10 );
2076*cdf0e10cSrcweir 
2077*cdf0e10cSrcweir 					Rectangle aBoundRect( aPoly.GetBoundRect() );
2078*cdf0e10cSrcweir 					sal_Int32 nXDiff = aBoundRect.Left() - aRect.Left();
2079*cdf0e10cSrcweir 					sal_Int32 nYDiff = aBoundRect.Top() - aRect.Top();
2080*cdf0e10cSrcweir 
2081*cdf0e10cSrcweir 					if (nShearWink&&((bMirroredX&&!bMirroredY)||(bMirroredY&&!bMirroredX)))
2082*cdf0e10cSrcweir 					{
2083*cdf0e10cSrcweir 						nShearWink = -nShearWink;
2084*cdf0e10cSrcweir 						fTan = -fTan;
2085*cdf0e10cSrcweir 					}
2086*cdf0e10cSrcweir 
2087*cdf0e10cSrcweir 					Point aRef( aRect.GetWidth() / 2, aRect.GetHeight() / 2 );
2088*cdf0e10cSrcweir 					for ( a = 0; a < aNewList.GetCount(); a++ )
2089*cdf0e10cSrcweir 					{
2090*cdf0e10cSrcweir 						SdrGluePoint& rPoint = aNewList[ a ];
2091*cdf0e10cSrcweir 						Point aGlue( rPoint.GetPos() );
2092*cdf0e10cSrcweir 						if ( nShearWink )
2093*cdf0e10cSrcweir 							ShearPoint( aGlue, aRef, fTan );
2094*cdf0e10cSrcweir 
2095*cdf0e10cSrcweir 						RotatePoint( aGlue, aRef, sin( fObjectRotation * F_PI180 ), cos( fObjectRotation * F_PI180 ) );
2096*cdf0e10cSrcweir 						if ( bMirroredX )
2097*cdf0e10cSrcweir 							aGlue.X() = aRect.GetWidth() - aGlue.X();
2098*cdf0e10cSrcweir 						if ( bMirroredY )
2099*cdf0e10cSrcweir 							aGlue.Y() = aRect.GetHeight() - aGlue.Y();
2100*cdf0e10cSrcweir 						aGlue.X() -= nXDiff;
2101*cdf0e10cSrcweir 						aGlue.Y() -= nYDiff;
2102*cdf0e10cSrcweir 						rPoint.SetPos( aGlue );
2103*cdf0e10cSrcweir 					}
2104*cdf0e10cSrcweir 				}
2105*cdf0e10cSrcweir 
2106*cdf0e10cSrcweir 				for(a = 0; a < pList->GetCount(); a++)
2107*cdf0e10cSrcweir 				{
2108*cdf0e10cSrcweir 					const SdrGluePoint& rCandidate = (*pList)[a];
2109*cdf0e10cSrcweir 
2110*cdf0e10cSrcweir 					if(rCandidate.IsUserDefined())
2111*cdf0e10cSrcweir 					{
2112*cdf0e10cSrcweir 						aNewList.Insert(rCandidate);
2113*cdf0e10cSrcweir 					}
2114*cdf0e10cSrcweir 				}
2115*cdf0e10cSrcweir 
2116*cdf0e10cSrcweir 				// copy new list to local. This is NOT very convenient behaviour, the local
2117*cdf0e10cSrcweir 				// GluePointList should not be set, but be delivered by using GetGluePointList(),
2118*cdf0e10cSrcweir 				// maybe on demand. Since the local object is changed here, this is assumed to
2119*cdf0e10cSrcweir 				// be a result of GetGluePointList and thus the list is copied
2120*cdf0e10cSrcweir 				if(pPlusData)
2121*cdf0e10cSrcweir 				{
2122*cdf0e10cSrcweir 					*pPlusData->pGluePoints = aNewList;
2123*cdf0e10cSrcweir 				}
2124*cdf0e10cSrcweir 			}
2125*cdf0e10cSrcweir 		}
2126*cdf0e10cSrcweir 	}
2127*cdf0e10cSrcweir }
2128*cdf0e10cSrcweir 
2129*cdf0e10cSrcweir // #i38892#
2130*cdf0e10cSrcweir const SdrGluePointList* SdrObjCustomShape::GetGluePointList() const
2131*cdf0e10cSrcweir {
2132*cdf0e10cSrcweir 	((SdrObjCustomShape*)this)->ImpCheckCustomGluePointsAreAdded();
2133*cdf0e10cSrcweir 	return SdrTextObj::GetGluePointList();
2134*cdf0e10cSrcweir }
2135*cdf0e10cSrcweir 
2136*cdf0e10cSrcweir // #i38892#
2137*cdf0e10cSrcweir //SdrGluePointList* SdrObjCustomShape::GetGluePointList()
2138*cdf0e10cSrcweir //{
2139*cdf0e10cSrcweir //	ImpCheckCustomGluePointsAreAdded();
2140*cdf0e10cSrcweir //	return SdrTextObj::GetGluePointList();
2141*cdf0e10cSrcweir //}
2142*cdf0e10cSrcweir 
2143*cdf0e10cSrcweir // #i38892#
2144*cdf0e10cSrcweir SdrGluePointList* SdrObjCustomShape::ForceGluePointList()
2145*cdf0e10cSrcweir {
2146*cdf0e10cSrcweir 	if(SdrTextObj::ForceGluePointList())
2147*cdf0e10cSrcweir 	{
2148*cdf0e10cSrcweir 		ImpCheckCustomGluePointsAreAdded();
2149*cdf0e10cSrcweir 		return SdrTextObj::ForceGluePointList();
2150*cdf0e10cSrcweir 	}
2151*cdf0e10cSrcweir 	else
2152*cdf0e10cSrcweir 	{
2153*cdf0e10cSrcweir 		return 0L;
2154*cdf0e10cSrcweir 	}
2155*cdf0e10cSrcweir }
2156*cdf0e10cSrcweir 
2157*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
2158*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
2159*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
2160*cdf0e10cSrcweir 
2161*cdf0e10cSrcweir sal_uInt32 SdrObjCustomShape::GetHdlCount() const
2162*cdf0e10cSrcweir {
2163*cdf0e10cSrcweir 	const sal_uInt32 nBasicHdlCount(SdrTextObj::GetHdlCount());
2164*cdf0e10cSrcweir 	std::vector< SdrCustomShapeInteraction > aInteractionHandles( GetInteractionHandles( this ) );
2165*cdf0e10cSrcweir 	return ( aInteractionHandles.size() + nBasicHdlCount );
2166*cdf0e10cSrcweir }
2167*cdf0e10cSrcweir 
2168*cdf0e10cSrcweir SdrHdl* SdrObjCustomShape::GetHdl( sal_uInt32 nHdlNum ) const
2169*cdf0e10cSrcweir {
2170*cdf0e10cSrcweir 	SdrHdl* pH = NULL;
2171*cdf0e10cSrcweir 	const sal_uInt32 nBasicHdlCount(SdrTextObj::GetHdlCount());
2172*cdf0e10cSrcweir 
2173*cdf0e10cSrcweir 	if ( nHdlNum < nBasicHdlCount )
2174*cdf0e10cSrcweir 		pH = SdrTextObj::GetHdl( nHdlNum );
2175*cdf0e10cSrcweir 	else
2176*cdf0e10cSrcweir 	{
2177*cdf0e10cSrcweir 		std::vector< SdrCustomShapeInteraction > aInteractionHandles( GetInteractionHandles( this ) );
2178*cdf0e10cSrcweir 		const sal_uInt32 nCustomShapeHdlNum(nHdlNum - nBasicHdlCount);
2179*cdf0e10cSrcweir 
2180*cdf0e10cSrcweir 		if ( nCustomShapeHdlNum < aInteractionHandles.size() )
2181*cdf0e10cSrcweir 		{
2182*cdf0e10cSrcweir 			if ( aInteractionHandles[ nCustomShapeHdlNum ].xInteraction.is() )
2183*cdf0e10cSrcweir 			{
2184*cdf0e10cSrcweir 				try
2185*cdf0e10cSrcweir 				{
2186*cdf0e10cSrcweir 					com::sun::star::awt::Point aPosition( aInteractionHandles[ nCustomShapeHdlNum ].xInteraction->getPosition() );
2187*cdf0e10cSrcweir 					pH = new SdrHdl( Point( aPosition.X, aPosition.Y ), HDL_CUSTOMSHAPE1 );
2188*cdf0e10cSrcweir 					pH->SetPointNum( nCustomShapeHdlNum );
2189*cdf0e10cSrcweir 					pH->SetObj( (SdrObject*)this );
2190*cdf0e10cSrcweir 				}
2191*cdf0e10cSrcweir 				catch ( const uno::RuntimeException& )
2192*cdf0e10cSrcweir 				{
2193*cdf0e10cSrcweir 				}
2194*cdf0e10cSrcweir 			}
2195*cdf0e10cSrcweir 		}
2196*cdf0e10cSrcweir 	}
2197*cdf0e10cSrcweir 	return pH;
2198*cdf0e10cSrcweir }
2199*cdf0e10cSrcweir 
2200*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
2201*cdf0e10cSrcweir 
2202*cdf0e10cSrcweir bool SdrObjCustomShape::hasSpecialDrag() const
2203*cdf0e10cSrcweir {
2204*cdf0e10cSrcweir 	return true;
2205*cdf0e10cSrcweir }
2206*cdf0e10cSrcweir 
2207*cdf0e10cSrcweir bool SdrObjCustomShape::beginSpecialDrag(SdrDragStat& rDrag) const
2208*cdf0e10cSrcweir {
2209*cdf0e10cSrcweir 	const SdrHdl* pHdl = rDrag.GetHdl();
2210*cdf0e10cSrcweir 
2211*cdf0e10cSrcweir     if(pHdl && HDL_CUSTOMSHAPE1 == pHdl->GetKind())
2212*cdf0e10cSrcweir 	{
2213*cdf0e10cSrcweir 		rDrag.SetEndDragChangesAttributes(true);
2214*cdf0e10cSrcweir 		rDrag.SetNoSnap(true);
2215*cdf0e10cSrcweir 	}
2216*cdf0e10cSrcweir 	else
2217*cdf0e10cSrcweir 	{
2218*cdf0e10cSrcweir 		const SdrHdl* pHdl2 = rDrag.GetHdl();
2219*cdf0e10cSrcweir 		const SdrHdlKind eHdl((pHdl2 == NULL) ? HDL_MOVE : pHdl2->GetKind());
2220*cdf0e10cSrcweir 
2221*cdf0e10cSrcweir         switch( eHdl )
2222*cdf0e10cSrcweir 		{
2223*cdf0e10cSrcweir 			case HDL_UPLFT :
2224*cdf0e10cSrcweir 			case HDL_UPPER :
2225*cdf0e10cSrcweir 			case HDL_UPRGT :
2226*cdf0e10cSrcweir 			case HDL_LEFT  :
2227*cdf0e10cSrcweir 			case HDL_RIGHT :
2228*cdf0e10cSrcweir 			case HDL_LWLFT :
2229*cdf0e10cSrcweir 			case HDL_LOWER :
2230*cdf0e10cSrcweir 			case HDL_LWRGT :
2231*cdf0e10cSrcweir 			case HDL_MOVE  :
2232*cdf0e10cSrcweir 			{
2233*cdf0e10cSrcweir     			break;
2234*cdf0e10cSrcweir 			}
2235*cdf0e10cSrcweir 			default:
2236*cdf0e10cSrcweir             {
2237*cdf0e10cSrcweir 				return false;
2238*cdf0e10cSrcweir             }
2239*cdf0e10cSrcweir 		}
2240*cdf0e10cSrcweir 	}
2241*cdf0e10cSrcweir 
2242*cdf0e10cSrcweir     return true;
2243*cdf0e10cSrcweir }
2244*cdf0e10cSrcweir 
2245*cdf0e10cSrcweir void SdrObjCustomShape::DragResizeCustomShape( const Rectangle& rNewRect, SdrObjCustomShape* pObj ) const
2246*cdf0e10cSrcweir {
2247*cdf0e10cSrcweir 	Rectangle	aOld( pObj->aRect );
2248*cdf0e10cSrcweir 	sal_Bool	bOldMirroredX( pObj->IsMirroredX() );
2249*cdf0e10cSrcweir 	sal_Bool	bOldMirroredY( pObj->IsMirroredY() );
2250*cdf0e10cSrcweir 
2251*cdf0e10cSrcweir 	Rectangle aNewRect( rNewRect );
2252*cdf0e10cSrcweir 	aNewRect.Justify();
2253*cdf0e10cSrcweir 
2254*cdf0e10cSrcweir 	std::vector< SdrCustomShapeInteraction > aInteractionHandles( GetInteractionHandles( pObj ) );
2255*cdf0e10cSrcweir 
2256*cdf0e10cSrcweir 	GeoStat aGeoStat( pObj->GetGeoStat() );
2257*cdf0e10cSrcweir 	if ( aNewRect.TopLeft()!= pObj->aRect.TopLeft() &&
2258*cdf0e10cSrcweir 		( pObj->aGeo.nDrehWink || pObj->aGeo.nShearWink ) )
2259*cdf0e10cSrcweir 	{
2260*cdf0e10cSrcweir 		Point aNewPos( aNewRect.TopLeft() );
2261*cdf0e10cSrcweir 		if ( pObj->aGeo.nShearWink ) ShearPoint( aNewPos, aOld.TopLeft(), aGeoStat.nTan );
2262*cdf0e10cSrcweir 		if ( pObj->aGeo.nDrehWink )  RotatePoint(aNewPos, aOld.TopLeft(), aGeoStat.nSin, aGeoStat.nCos );
2263*cdf0e10cSrcweir 		aNewRect.SetPos( aNewPos );
2264*cdf0e10cSrcweir 	}
2265*cdf0e10cSrcweir 	if ( aNewRect != pObj->aRect )
2266*cdf0e10cSrcweir 	{
2267*cdf0e10cSrcweir 		pObj->SetLogicRect( aNewRect );
2268*cdf0e10cSrcweir 		pObj->InvalidateRenderGeometry();
2269*cdf0e10cSrcweir 
2270*cdf0e10cSrcweir 		if ( rNewRect.Left() > rNewRect.Right() )
2271*cdf0e10cSrcweir 		{
2272*cdf0e10cSrcweir 			Point aTop( ( pObj->GetSnapRect().Left() + pObj->GetSnapRect().Right() ) >> 1, pObj->GetSnapRect().Top() );
2273*cdf0e10cSrcweir 			Point aBottom( aTop.X(), aTop.Y() + 1000 );
2274*cdf0e10cSrcweir 			pObj->NbcMirror( aTop, aBottom );
2275*cdf0e10cSrcweir 		}
2276*cdf0e10cSrcweir 		if ( rNewRect.Top() > rNewRect.Bottom() )
2277*cdf0e10cSrcweir 		{
2278*cdf0e10cSrcweir 			Point aLeft( pObj->GetSnapRect().Left(), ( pObj->GetSnapRect().Top() + pObj->GetSnapRect().Bottom() ) >> 1 );
2279*cdf0e10cSrcweir 			Point aRight( aLeft.X() + 1000, aLeft.Y() );
2280*cdf0e10cSrcweir 			pObj->NbcMirror( aLeft, aRight );
2281*cdf0e10cSrcweir 		}
2282*cdf0e10cSrcweir 
2283*cdf0e10cSrcweir 		std::vector< SdrCustomShapeInteraction >::iterator aIter( aInteractionHandles.begin() );
2284*cdf0e10cSrcweir 		while ( aIter != aInteractionHandles.end() )
2285*cdf0e10cSrcweir 		{
2286*cdf0e10cSrcweir 			try
2287*cdf0e10cSrcweir 			{
2288*cdf0e10cSrcweir 				if ( aIter->nMode & CUSTOMSHAPE_HANDLE_RESIZE_FIXED )
2289*cdf0e10cSrcweir 					aIter->xInteraction->setControllerPosition( aIter->aPosition );
2290*cdf0e10cSrcweir 				if ( aIter->nMode & CUSTOMSHAPE_HANDLE_RESIZE_ABSOLUTE_X )
2291*cdf0e10cSrcweir 				{
2292*cdf0e10cSrcweir 					sal_Int32 nX;
2293*cdf0e10cSrcweir 					if ( bOldMirroredX )
2294*cdf0e10cSrcweir 					{
2295*cdf0e10cSrcweir 						nX = ( aIter->aPosition.X - aOld.Right() );
2296*cdf0e10cSrcweir 						if ( rNewRect.Left() > rNewRect.Right() )
2297*cdf0e10cSrcweir 							nX = pObj->aRect.Left() - nX;
2298*cdf0e10cSrcweir 						else
2299*cdf0e10cSrcweir 							nX += pObj->aRect.Right();
2300*cdf0e10cSrcweir 					}
2301*cdf0e10cSrcweir 					else
2302*cdf0e10cSrcweir 					{
2303*cdf0e10cSrcweir 						nX = ( aIter->aPosition.X - aOld.Left() );
2304*cdf0e10cSrcweir 						if ( rNewRect.Left() > rNewRect.Right() )
2305*cdf0e10cSrcweir 							nX = pObj->aRect.Right() - nX;
2306*cdf0e10cSrcweir 						else
2307*cdf0e10cSrcweir 							nX += pObj->aRect.Left();
2308*cdf0e10cSrcweir 					}
2309*cdf0e10cSrcweir 					aIter->xInteraction->setControllerPosition( com::sun::star::awt::Point( nX, aIter->xInteraction->getPosition().Y ) );
2310*cdf0e10cSrcweir 				}
2311*cdf0e10cSrcweir 				if ( aIter->nMode & CUSTOMSHAPE_HANDLE_RESIZE_ABSOLUTE_Y )
2312*cdf0e10cSrcweir 				{
2313*cdf0e10cSrcweir 					sal_Int32 nY;
2314*cdf0e10cSrcweir 					if ( bOldMirroredY )
2315*cdf0e10cSrcweir 					{
2316*cdf0e10cSrcweir 						nY = ( aIter->aPosition.Y - aOld.Bottom() );
2317*cdf0e10cSrcweir 						if ( rNewRect.Top() > rNewRect.Bottom() )
2318*cdf0e10cSrcweir 							nY = pObj->aRect.Top() - nY;
2319*cdf0e10cSrcweir 						else
2320*cdf0e10cSrcweir 							nY += pObj->aRect.Bottom();
2321*cdf0e10cSrcweir 					}
2322*cdf0e10cSrcweir 					else
2323*cdf0e10cSrcweir 					{
2324*cdf0e10cSrcweir 						nY = ( aIter->aPosition.Y - aOld.Top() );
2325*cdf0e10cSrcweir 						if ( rNewRect.Top() > rNewRect.Bottom() )
2326*cdf0e10cSrcweir 							nY = pObj->aRect.Bottom() - nY;
2327*cdf0e10cSrcweir 						else
2328*cdf0e10cSrcweir 							nY += pObj->aRect.Top();
2329*cdf0e10cSrcweir 					}
2330*cdf0e10cSrcweir 					aIter->xInteraction->setControllerPosition( com::sun::star::awt::Point( aIter->xInteraction->getPosition().X, nY ) );
2331*cdf0e10cSrcweir 				}
2332*cdf0e10cSrcweir 			}
2333*cdf0e10cSrcweir 			catch ( const uno::RuntimeException& )
2334*cdf0e10cSrcweir 			{
2335*cdf0e10cSrcweir 			}
2336*cdf0e10cSrcweir 			aIter++;
2337*cdf0e10cSrcweir 		}
2338*cdf0e10cSrcweir 	}
2339*cdf0e10cSrcweir }
2340*cdf0e10cSrcweir 
2341*cdf0e10cSrcweir void SdrObjCustomShape::DragMoveCustomShapeHdl( const Point aDestination, const sal_uInt16 nCustomShapeHdlNum, SdrObjCustomShape* pObj ) const
2342*cdf0e10cSrcweir {
2343*cdf0e10cSrcweir 	std::vector< SdrCustomShapeInteraction > aInteractionHandles( GetInteractionHandles( pObj ) );
2344*cdf0e10cSrcweir 	if ( nCustomShapeHdlNum < aInteractionHandles.size() )
2345*cdf0e10cSrcweir 	{
2346*cdf0e10cSrcweir 		SdrCustomShapeInteraction aInteractionHandle( aInteractionHandles[ nCustomShapeHdlNum ] );
2347*cdf0e10cSrcweir 		if ( aInteractionHandle.xInteraction.is() )
2348*cdf0e10cSrcweir 		{
2349*cdf0e10cSrcweir 			try
2350*cdf0e10cSrcweir 			{
2351*cdf0e10cSrcweir 				com::sun::star::awt::Point aPt( aDestination.X(), aDestination.Y() );
2352*cdf0e10cSrcweir 				if ( aInteractionHandle.nMode & CUSTOMSHAPE_HANDLE_MOVE_SHAPE )
2353*cdf0e10cSrcweir 				{
2354*cdf0e10cSrcweir 					sal_Int32 nXDiff = aPt.X - aInteractionHandle.aPosition.X;
2355*cdf0e10cSrcweir 					sal_Int32 nYDiff = aPt.Y - aInteractionHandle.aPosition.Y;
2356*cdf0e10cSrcweir 
2357*cdf0e10cSrcweir 					pObj->aRect.Move( nXDiff, nYDiff );
2358*cdf0e10cSrcweir 					pObj->aOutRect.Move( nXDiff, nYDiff );
2359*cdf0e10cSrcweir 					pObj->maSnapRect.Move( nXDiff, nYDiff );
2360*cdf0e10cSrcweir 					pObj->SetRectsDirty(sal_True);
2361*cdf0e10cSrcweir 					pObj->InvalidateRenderGeometry();
2362*cdf0e10cSrcweir 
2363*cdf0e10cSrcweir 					std::vector< SdrCustomShapeInteraction >::iterator aIter( aInteractionHandles.begin() );
2364*cdf0e10cSrcweir 					while ( aIter != aInteractionHandles.end() )
2365*cdf0e10cSrcweir 					{
2366*cdf0e10cSrcweir 						if ( aIter->nMode & CUSTOMSHAPE_HANDLE_RESIZE_FIXED )
2367*cdf0e10cSrcweir 						{
2368*cdf0e10cSrcweir 							if ( aIter->xInteraction.is() )
2369*cdf0e10cSrcweir 								aIter->xInteraction->setControllerPosition( aIter->aPosition );
2370*cdf0e10cSrcweir 						}
2371*cdf0e10cSrcweir 						aIter++;
2372*cdf0e10cSrcweir 					}
2373*cdf0e10cSrcweir 				}
2374*cdf0e10cSrcweir 				aInteractionHandle.xInteraction->setControllerPosition( aPt );
2375*cdf0e10cSrcweir 			}
2376*cdf0e10cSrcweir 			catch ( const uno::RuntimeException& )
2377*cdf0e10cSrcweir 			{
2378*cdf0e10cSrcweir 			}
2379*cdf0e10cSrcweir 		}
2380*cdf0e10cSrcweir 	}
2381*cdf0e10cSrcweir }
2382*cdf0e10cSrcweir 
2383*cdf0e10cSrcweir bool SdrObjCustomShape::applySpecialDrag(SdrDragStat& rDrag)
2384*cdf0e10cSrcweir {
2385*cdf0e10cSrcweir 	const SdrHdl* pHdl = rDrag.GetHdl();
2386*cdf0e10cSrcweir 	const SdrHdlKind eHdl((pHdl == NULL) ? HDL_MOVE : pHdl->GetKind());
2387*cdf0e10cSrcweir 
2388*cdf0e10cSrcweir     switch(eHdl)
2389*cdf0e10cSrcweir 	{
2390*cdf0e10cSrcweir 		case HDL_CUSTOMSHAPE1 :
2391*cdf0e10cSrcweir 		{
2392*cdf0e10cSrcweir 			rDrag.SetEndDragChangesGeoAndAttributes(true);
2393*cdf0e10cSrcweir 		    DragMoveCustomShapeHdl( rDrag.GetNow(), (sal_uInt16)pHdl->GetPointNum(), this );
2394*cdf0e10cSrcweir 		    SetRectsDirty();
2395*cdf0e10cSrcweir 		    InvalidateRenderGeometry();
2396*cdf0e10cSrcweir 		    SetChanged();
2397*cdf0e10cSrcweir             break;
2398*cdf0e10cSrcweir 		}
2399*cdf0e10cSrcweir 
2400*cdf0e10cSrcweir 		case HDL_UPLFT :
2401*cdf0e10cSrcweir 		case HDL_UPPER :
2402*cdf0e10cSrcweir 		case HDL_UPRGT :
2403*cdf0e10cSrcweir 		case HDL_LEFT  :
2404*cdf0e10cSrcweir 		case HDL_RIGHT :
2405*cdf0e10cSrcweir 		case HDL_LWLFT :
2406*cdf0e10cSrcweir 		case HDL_LOWER :
2407*cdf0e10cSrcweir 		case HDL_LWRGT :
2408*cdf0e10cSrcweir 		{
2409*cdf0e10cSrcweir 			DragResizeCustomShape(ImpDragCalcRect(rDrag), this);
2410*cdf0e10cSrcweir 			break;
2411*cdf0e10cSrcweir 		}
2412*cdf0e10cSrcweir 		case HDL_MOVE :
2413*cdf0e10cSrcweir 		{
2414*cdf0e10cSrcweir 			Move(Size(rDrag.GetDX(), rDrag.GetDY()));
2415*cdf0e10cSrcweir 			break;
2416*cdf0e10cSrcweir 		}
2417*cdf0e10cSrcweir 		default: break;
2418*cdf0e10cSrcweir 	}
2419*cdf0e10cSrcweir 
2420*cdf0e10cSrcweir     return true;
2421*cdf0e10cSrcweir }
2422*cdf0e10cSrcweir 
2423*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
2424*cdf0e10cSrcweir 
2425*cdf0e10cSrcweir void SdrObjCustomShape::DragCreateObject( SdrDragStat& rStat )
2426*cdf0e10cSrcweir {
2427*cdf0e10cSrcweir 	Rectangle aRect1;
2428*cdf0e10cSrcweir 	rStat.TakeCreateRect( aRect1 );
2429*cdf0e10cSrcweir 
2430*cdf0e10cSrcweir 	std::vector< SdrCustomShapeInteraction > aInteractionHandles( GetInteractionHandles( this ) );
2431*cdf0e10cSrcweir 
2432*cdf0e10cSrcweir 	sal_uInt32 nDefaultObjectSizeWidth = 3000;		// default width from SDOptions ?
2433*cdf0e10cSrcweir 	sal_uInt32 nDefaultObjectSizeHeight= 3000;
2434*cdf0e10cSrcweir 
2435*cdf0e10cSrcweir 	if ( ImpVerticalSwitch( *this ) )
2436*cdf0e10cSrcweir 	{
2437*cdf0e10cSrcweir 		SetMirroredX( aRect1.Left() > aRect1.Right() );
2438*cdf0e10cSrcweir 
2439*cdf0e10cSrcweir 		aRect1 = Rectangle( rStat.GetNow(), Size( nDefaultObjectSizeWidth, nDefaultObjectSizeHeight ) );
2440*cdf0e10cSrcweir 		// subtracting the horizontal difference of the latest handle from shape position
2441*cdf0e10cSrcweir 		if ( !aInteractionHandles.empty() )
2442*cdf0e10cSrcweir 		{
2443*cdf0e10cSrcweir 			sal_Int32 nHandlePos = aInteractionHandles[ aInteractionHandles.size() - 1 ].xInteraction->getPosition().X;
2444*cdf0e10cSrcweir 			aRect1.Move( aRect.Left() - nHandlePos, 0 );
2445*cdf0e10cSrcweir 		}
2446*cdf0e10cSrcweir 	}
2447*cdf0e10cSrcweir 	ImpJustifyRect( aRect1 );
2448*cdf0e10cSrcweir 	rStat.SetActionRect( aRect1 );
2449*cdf0e10cSrcweir 	aRect = aRect1;
2450*cdf0e10cSrcweir 	SetRectsDirty();
2451*cdf0e10cSrcweir 
2452*cdf0e10cSrcweir 	std::vector< SdrCustomShapeInteraction >::iterator aIter( aInteractionHandles.begin() );
2453*cdf0e10cSrcweir 	while ( aIter != aInteractionHandles.end() )
2454*cdf0e10cSrcweir 	{
2455*cdf0e10cSrcweir 		try
2456*cdf0e10cSrcweir 		{
2457*cdf0e10cSrcweir 			if ( aIter->nMode & CUSTOMSHAPE_HANDLE_CREATE_FIXED )
2458*cdf0e10cSrcweir 				aIter->xInteraction->setControllerPosition( awt::Point( rStat.GetStart().X(), rStat.GetStart().Y() ) );
2459*cdf0e10cSrcweir 		}
2460*cdf0e10cSrcweir 		catch ( const uno::RuntimeException& )
2461*cdf0e10cSrcweir 		{
2462*cdf0e10cSrcweir 		}
2463*cdf0e10cSrcweir 		aIter++;
2464*cdf0e10cSrcweir 	}
2465*cdf0e10cSrcweir 
2466*cdf0e10cSrcweir 	SetBoundRectDirty();
2467*cdf0e10cSrcweir 	bSnapRectDirty=sal_True;
2468*cdf0e10cSrcweir }
2469*cdf0e10cSrcweir 
2470*cdf0e10cSrcweir FASTBOOL SdrObjCustomShape::BegCreate( SdrDragStat& rDrag )
2471*cdf0e10cSrcweir {
2472*cdf0e10cSrcweir 	return SdrTextObj::BegCreate( rDrag );
2473*cdf0e10cSrcweir }
2474*cdf0e10cSrcweir 
2475*cdf0e10cSrcweir FASTBOOL SdrObjCustomShape::MovCreate(SdrDragStat& rStat)
2476*cdf0e10cSrcweir {
2477*cdf0e10cSrcweir 	SdrView* pView = rStat.GetView();		// #i37448#
2478*cdf0e10cSrcweir 	if( pView && pView->IsSolidDragging() )
2479*cdf0e10cSrcweir 	{
2480*cdf0e10cSrcweir 		InvalidateRenderGeometry();
2481*cdf0e10cSrcweir 	}
2482*cdf0e10cSrcweir 	DragCreateObject( rStat );
2483*cdf0e10cSrcweir 	SetRectsDirty();
2484*cdf0e10cSrcweir 	return sal_True;
2485*cdf0e10cSrcweir }
2486*cdf0e10cSrcweir 
2487*cdf0e10cSrcweir FASTBOOL SdrObjCustomShape::EndCreate( SdrDragStat& rStat, SdrCreateCmd eCmd )
2488*cdf0e10cSrcweir {
2489*cdf0e10cSrcweir 	DragCreateObject( rStat );
2490*cdf0e10cSrcweir 
2491*cdf0e10cSrcweir 	if ( bTextFrame )
2492*cdf0e10cSrcweir 	{
2493*cdf0e10cSrcweir 		if ( IsAutoGrowHeight() )
2494*cdf0e10cSrcweir 		{
2495*cdf0e10cSrcweir 			// MinTextHeight
2496*cdf0e10cSrcweir 			long nHgt=aRect.GetHeight()-1;
2497*cdf0e10cSrcweir 			if (nHgt==1) nHgt=0;
2498*cdf0e10cSrcweir 			NbcSetMinTextFrameHeight( nHgt );
2499*cdf0e10cSrcweir 		}
2500*cdf0e10cSrcweir 		if ( IsAutoGrowWidth() )
2501*cdf0e10cSrcweir 		{
2502*cdf0e10cSrcweir 			// MinTextWidth
2503*cdf0e10cSrcweir 			long nWdt=aRect.GetWidth()-1;
2504*cdf0e10cSrcweir 			if (nWdt==1) nWdt=0;
2505*cdf0e10cSrcweir 			NbcSetMinTextFrameWidth( nWdt );
2506*cdf0e10cSrcweir 		}
2507*cdf0e10cSrcweir 		// Textrahmen neu berechnen
2508*cdf0e10cSrcweir 		NbcAdjustTextFrameWidthAndHeight();
2509*cdf0e10cSrcweir 	}
2510*cdf0e10cSrcweir 	SetRectsDirty();
2511*cdf0e10cSrcweir 	return ( eCmd == SDRCREATE_FORCEEND || rStat.GetPointAnz() >= 2 );
2512*cdf0e10cSrcweir }
2513*cdf0e10cSrcweir 
2514*cdf0e10cSrcweir basegfx::B2DPolyPolygon SdrObjCustomShape::TakeCreatePoly(const SdrDragStat& /*rDrag*/) const
2515*cdf0e10cSrcweir {
2516*cdf0e10cSrcweir 	return GetLineGeometry( this, sal_False );
2517*cdf0e10cSrcweir }
2518*cdf0e10cSrcweir 
2519*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
2520*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
2521*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
2522*cdf0e10cSrcweir 
2523*cdf0e10cSrcweir // in context with the SdrObjCustomShape the SdrTextAutoGrowHeightItem == true -> Resize Shape to fit text,
2524*cdf0e10cSrcweir //									   the SdrTextAutoGrowWidthItem  == true -> Word wrap text in Shape
2525*cdf0e10cSrcweir FASTBOOL SdrObjCustomShape::IsAutoGrowHeight() const
2526*cdf0e10cSrcweir {
2527*cdf0e10cSrcweir 	const SfxItemSet& rSet = GetMergedItemSet();
2528*cdf0e10cSrcweir 	FASTBOOL bIsAutoGrowHeight = ((SdrTextAutoGrowHeightItem&)(rSet.Get(SDRATTR_TEXT_AUTOGROWHEIGHT))).GetValue();
2529*cdf0e10cSrcweir 	if ( bIsAutoGrowHeight && IsVerticalWriting() )
2530*cdf0e10cSrcweir 		bIsAutoGrowHeight = ((SdrTextWordWrapItem&)(rSet.Get(SDRATTR_TEXT_WORDWRAP))).GetValue() == sal_False;
2531*cdf0e10cSrcweir 	return bIsAutoGrowHeight;
2532*cdf0e10cSrcweir }
2533*cdf0e10cSrcweir FASTBOOL SdrObjCustomShape::IsAutoGrowWidth() const
2534*cdf0e10cSrcweir {
2535*cdf0e10cSrcweir 	const SfxItemSet& rSet = GetMergedItemSet();
2536*cdf0e10cSrcweir 	FASTBOOL bIsAutoGrowWidth = ((SdrTextAutoGrowHeightItem&)(rSet.Get(SDRATTR_TEXT_AUTOGROWHEIGHT))).GetValue();
2537*cdf0e10cSrcweir 	if ( bIsAutoGrowWidth && !IsVerticalWriting() )
2538*cdf0e10cSrcweir 		bIsAutoGrowWidth = ((SdrTextWordWrapItem&)(rSet.Get(SDRATTR_TEXT_WORDWRAP))).GetValue() == sal_False;
2539*cdf0e10cSrcweir 	return bIsAutoGrowWidth;
2540*cdf0e10cSrcweir }
2541*cdf0e10cSrcweir 
2542*cdf0e10cSrcweir /* The following method is identical to the SdrTextObj::SetVerticalWriting method, the only difference
2543*cdf0e10cSrcweir    is that the SdrAutoGrowWidthItem and SdrAutoGrowHeightItem are not exchanged if the vertical writing
2544*cdf0e10cSrcweir    mode has been changed */
2545*cdf0e10cSrcweir 
2546*cdf0e10cSrcweir void SdrObjCustomShape::SetVerticalWriting( sal_Bool bVertical )
2547*cdf0e10cSrcweir {
2548*cdf0e10cSrcweir 	ForceOutlinerParaObject();
2549*cdf0e10cSrcweir 
2550*cdf0e10cSrcweir 	OutlinerParaObject* pOutlinerParaObject = GetOutlinerParaObject();
2551*cdf0e10cSrcweir 
2552*cdf0e10cSrcweir 	DBG_ASSERT( pOutlinerParaObject, "SdrTextObj::SetVerticalWriting() without OutlinerParaObject!" );
2553*cdf0e10cSrcweir 
2554*cdf0e10cSrcweir 	if( pOutlinerParaObject )
2555*cdf0e10cSrcweir 	{
2556*cdf0e10cSrcweir 		if(pOutlinerParaObject->IsVertical() != (bool)bVertical)
2557*cdf0e10cSrcweir 		{
2558*cdf0e10cSrcweir 			// get item settings
2559*cdf0e10cSrcweir 			const SfxItemSet& rSet = GetObjectItemSet();
2560*cdf0e10cSrcweir 
2561*cdf0e10cSrcweir 			// #103516# Also exchange hor/ver adjust items
2562*cdf0e10cSrcweir 			SdrTextHorzAdjust eHorz = ((SdrTextHorzAdjustItem&)(rSet.Get(SDRATTR_TEXT_HORZADJUST))).GetValue();
2563*cdf0e10cSrcweir 			SdrTextVertAdjust eVert = ((SdrTextVertAdjustItem&)(rSet.Get(SDRATTR_TEXT_VERTADJUST))).GetValue();
2564*cdf0e10cSrcweir 
2565*cdf0e10cSrcweir 			// rescue object size
2566*cdf0e10cSrcweir 			Rectangle aObjectRect = GetSnapRect();
2567*cdf0e10cSrcweir 
2568*cdf0e10cSrcweir 			// prepare ItemSet to set exchanged width and height items
2569*cdf0e10cSrcweir 			SfxItemSet aNewSet(*rSet.GetPool(),
2570*cdf0e10cSrcweir 				SDRATTR_TEXT_AUTOGROWHEIGHT, SDRATTR_TEXT_AUTOGROWHEIGHT,
2571*cdf0e10cSrcweir 				// #103516# Expanded item ranges to also support hor and ver adjust.
2572*cdf0e10cSrcweir 				SDRATTR_TEXT_VERTADJUST, SDRATTR_TEXT_VERTADJUST,
2573*cdf0e10cSrcweir 				SDRATTR_TEXT_AUTOGROWWIDTH, SDRATTR_TEXT_HORZADJUST,
2574*cdf0e10cSrcweir 				0, 0);
2575*cdf0e10cSrcweir 
2576*cdf0e10cSrcweir 			aNewSet.Put(rSet);
2577*cdf0e10cSrcweir 
2578*cdf0e10cSrcweir 			// #103516# Exchange horz and vert adjusts
2579*cdf0e10cSrcweir 			switch(eVert)
2580*cdf0e10cSrcweir 			{
2581*cdf0e10cSrcweir 				case SDRTEXTVERTADJUST_TOP: aNewSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT)); break;
2582*cdf0e10cSrcweir 				case SDRTEXTVERTADJUST_CENTER: aNewSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_CENTER)); break;
2583*cdf0e10cSrcweir 				case SDRTEXTVERTADJUST_BOTTOM: aNewSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_LEFT)); break;
2584*cdf0e10cSrcweir 				case SDRTEXTVERTADJUST_BLOCK: aNewSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_BLOCK)); break;
2585*cdf0e10cSrcweir 			}
2586*cdf0e10cSrcweir 			switch(eHorz)
2587*cdf0e10cSrcweir 			{
2588*cdf0e10cSrcweir 				case SDRTEXTHORZADJUST_LEFT: aNewSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_BOTTOM)); break;
2589*cdf0e10cSrcweir 				case SDRTEXTHORZADJUST_CENTER: aNewSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_CENTER)); break;
2590*cdf0e10cSrcweir 				case SDRTEXTHORZADJUST_RIGHT: aNewSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_TOP)); break;
2591*cdf0e10cSrcweir 				case SDRTEXTHORZADJUST_BLOCK: aNewSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_BLOCK)); break;
2592*cdf0e10cSrcweir 			}
2593*cdf0e10cSrcweir 
2594*cdf0e10cSrcweir 			SetObjectItemSet( aNewSet );
2595*cdf0e10cSrcweir 			pOutlinerParaObject = GetOutlinerParaObject();
2596*cdf0e10cSrcweir 			if ( pOutlinerParaObject )
2597*cdf0e10cSrcweir 				pOutlinerParaObject->SetVertical(bVertical);
2598*cdf0e10cSrcweir 
2599*cdf0e10cSrcweir 			// restore object size
2600*cdf0e10cSrcweir 			SetSnapRect(aObjectRect);
2601*cdf0e10cSrcweir 		}
2602*cdf0e10cSrcweir 	}
2603*cdf0e10cSrcweir }
2604*cdf0e10cSrcweir FASTBOOL SdrObjCustomShape::AdjustTextFrameWidthAndHeight(Rectangle& rR, FASTBOOL bHgt, FASTBOOL bWdt) const
2605*cdf0e10cSrcweir {
2606*cdf0e10cSrcweir  	if ( pModel && HasText() && !rR.IsEmpty() )
2607*cdf0e10cSrcweir 	{
2608*cdf0e10cSrcweir 		FASTBOOL bWdtGrow=bWdt && IsAutoGrowWidth();
2609*cdf0e10cSrcweir 		FASTBOOL bHgtGrow=bHgt && IsAutoGrowHeight();
2610*cdf0e10cSrcweir 		if ( bWdtGrow || bHgtGrow )
2611*cdf0e10cSrcweir 		{
2612*cdf0e10cSrcweir 			Rectangle aR0(rR);
2613*cdf0e10cSrcweir 			long nHgt=0,nMinHgt=0,nMaxHgt=0;
2614*cdf0e10cSrcweir 			long nWdt=0,nMinWdt=0,nMaxWdt=0;
2615*cdf0e10cSrcweir 			Size aSiz(rR.GetSize()); aSiz.Width()--; aSiz.Height()--;
2616*cdf0e10cSrcweir 			Size aMaxSiz(100000,100000);
2617*cdf0e10cSrcweir 			Size aTmpSiz(pModel->GetMaxObjSize());
2618*cdf0e10cSrcweir 			if (aTmpSiz.Width()!=0) aMaxSiz.Width()=aTmpSiz.Width();
2619*cdf0e10cSrcweir 			if (aTmpSiz.Height()!=0) aMaxSiz.Height()=aTmpSiz.Height();
2620*cdf0e10cSrcweir 			if (bWdtGrow)
2621*cdf0e10cSrcweir 			{
2622*cdf0e10cSrcweir 				nMinWdt=GetMinTextFrameWidth();
2623*cdf0e10cSrcweir 				nMaxWdt=GetMaxTextFrameWidth();
2624*cdf0e10cSrcweir 				if (nMaxWdt==0 || nMaxWdt>aMaxSiz.Width()) nMaxWdt=aMaxSiz.Width();
2625*cdf0e10cSrcweir 				if (nMinWdt<=0) nMinWdt=1;
2626*cdf0e10cSrcweir 				aSiz.Width()=nMaxWdt;
2627*cdf0e10cSrcweir 			}
2628*cdf0e10cSrcweir 			if (bHgtGrow)
2629*cdf0e10cSrcweir 			{
2630*cdf0e10cSrcweir 				nMinHgt=GetMinTextFrameHeight();
2631*cdf0e10cSrcweir 				nMaxHgt=GetMaxTextFrameHeight();
2632*cdf0e10cSrcweir 				if (nMaxHgt==0 || nMaxHgt>aMaxSiz.Height()) nMaxHgt=aMaxSiz.Height();
2633*cdf0e10cSrcweir 				if (nMinHgt<=0) nMinHgt=1;
2634*cdf0e10cSrcweir 				aSiz.Height()=nMaxHgt;
2635*cdf0e10cSrcweir 			}
2636*cdf0e10cSrcweir 			long nHDist=GetTextLeftDistance()+GetTextRightDistance();
2637*cdf0e10cSrcweir 			long nVDist=GetTextUpperDistance()+GetTextLowerDistance();
2638*cdf0e10cSrcweir 			aSiz.Width()-=nHDist;
2639*cdf0e10cSrcweir 			aSiz.Height()-=nVDist;
2640*cdf0e10cSrcweir 			if ( aSiz.Width() < 2 )
2641*cdf0e10cSrcweir 				aSiz.Width() = 2;   // Mindestgroesse 2
2642*cdf0e10cSrcweir 			if ( aSiz.Height() < 2 )
2643*cdf0e10cSrcweir 				aSiz.Height() = 2; // Mindestgroesse 2
2644*cdf0e10cSrcweir 
2645*cdf0e10cSrcweir 			if(pEdtOutl)
2646*cdf0e10cSrcweir 			{
2647*cdf0e10cSrcweir 				pEdtOutl->SetMaxAutoPaperSize( aSiz );
2648*cdf0e10cSrcweir 				if (bWdtGrow)
2649*cdf0e10cSrcweir 				{
2650*cdf0e10cSrcweir 					Size aSiz2(pEdtOutl->CalcTextSize());
2651*cdf0e10cSrcweir 					nWdt=aSiz2.Width()+1; // lieber etwas Tolleranz
2652*cdf0e10cSrcweir 					if (bHgtGrow) nHgt=aSiz2.Height()+1; // lieber etwas Tolleranz
2653*cdf0e10cSrcweir 				} else
2654*cdf0e10cSrcweir 				{
2655*cdf0e10cSrcweir 					nHgt=pEdtOutl->GetTextHeight()+1; // lieber etwas Tolleranz
2656*cdf0e10cSrcweir 				}
2657*cdf0e10cSrcweir 			}
2658*cdf0e10cSrcweir 			else
2659*cdf0e10cSrcweir 			{
2660*cdf0e10cSrcweir 				Outliner& rOutliner=ImpGetDrawOutliner();
2661*cdf0e10cSrcweir 				rOutliner.SetPaperSize(aSiz);
2662*cdf0e10cSrcweir 				rOutliner.SetUpdateMode(sal_True);
2663*cdf0e10cSrcweir 				// !!! hier sollte ich wohl auch noch mal die Optimierung mit
2664*cdf0e10cSrcweir 				// bPortionInfoChecked usw einbauen
2665*cdf0e10cSrcweir 				OutlinerParaObject* pOutlinerParaObject = GetOutlinerParaObject();
2666*cdf0e10cSrcweir 				if( pOutlinerParaObject != NULL )
2667*cdf0e10cSrcweir 				{
2668*cdf0e10cSrcweir 					rOutliner.SetText(*pOutlinerParaObject);
2669*cdf0e10cSrcweir 					rOutliner.SetFixedCellHeight(((const SdrTextFixedCellHeightItem&)GetMergedItem(SDRATTR_TEXT_USEFIXEDCELLHEIGHT)).GetValue());
2670*cdf0e10cSrcweir 				}
2671*cdf0e10cSrcweir 				if ( bWdtGrow )
2672*cdf0e10cSrcweir 				{
2673*cdf0e10cSrcweir 					Size aSiz2(rOutliner.CalcTextSize());
2674*cdf0e10cSrcweir 					nWdt=aSiz2.Width()+1; // lieber etwas Tolleranz
2675*cdf0e10cSrcweir 					if ( bHgtGrow )
2676*cdf0e10cSrcweir 						nHgt=aSiz2.Height()+1; // lieber etwas Tolleranz
2677*cdf0e10cSrcweir 				}
2678*cdf0e10cSrcweir 				else
2679*cdf0e10cSrcweir 					nHgt = rOutliner.GetTextHeight()+1; // lieber etwas Tolleranz
2680*cdf0e10cSrcweir 				rOutliner.Clear();
2681*cdf0e10cSrcweir 			}
2682*cdf0e10cSrcweir 			if ( nWdt < nMinWdt )
2683*cdf0e10cSrcweir 				nWdt = nMinWdt;
2684*cdf0e10cSrcweir 			if ( nWdt > nMaxWdt )
2685*cdf0e10cSrcweir 				nWdt = nMaxWdt;
2686*cdf0e10cSrcweir 			nWdt += nHDist;
2687*cdf0e10cSrcweir 			if ( nWdt < 1 )
2688*cdf0e10cSrcweir 				nWdt = 1; // nHDist kann auch negativ sein
2689*cdf0e10cSrcweir 			if ( nHgt < nMinHgt )
2690*cdf0e10cSrcweir 				nHgt = nMinHgt;
2691*cdf0e10cSrcweir 			if ( nHgt > nMaxHgt )
2692*cdf0e10cSrcweir 				nHgt = nMaxHgt;
2693*cdf0e10cSrcweir 			nHgt+=nVDist;
2694*cdf0e10cSrcweir 			if ( nHgt < 1 )
2695*cdf0e10cSrcweir 				nHgt = 1; // nVDist kann auch negativ sein
2696*cdf0e10cSrcweir 			long nWdtGrow = nWdt-(rR.Right()-rR.Left());
2697*cdf0e10cSrcweir 			long nHgtGrow = nHgt-(rR.Bottom()-rR.Top());
2698*cdf0e10cSrcweir 			if ( nWdtGrow == 0 )
2699*cdf0e10cSrcweir 				bWdtGrow = sal_False;
2700*cdf0e10cSrcweir 			if ( nHgtGrow == 0 )
2701*cdf0e10cSrcweir 				bHgtGrow=sal_False;
2702*cdf0e10cSrcweir 			if ( bWdtGrow || bHgtGrow )
2703*cdf0e10cSrcweir 			{
2704*cdf0e10cSrcweir 				if ( bWdtGrow )
2705*cdf0e10cSrcweir 				{
2706*cdf0e10cSrcweir 					SdrTextHorzAdjust eHAdj=GetTextHorizontalAdjust();
2707*cdf0e10cSrcweir 					if ( eHAdj == SDRTEXTHORZADJUST_LEFT )
2708*cdf0e10cSrcweir 						rR.Right()+=nWdtGrow;
2709*cdf0e10cSrcweir 					else if ( eHAdj == SDRTEXTHORZADJUST_RIGHT )
2710*cdf0e10cSrcweir 						rR.Left()-=nWdtGrow;
2711*cdf0e10cSrcweir 					else
2712*cdf0e10cSrcweir 					{
2713*cdf0e10cSrcweir 						long nWdtGrow2=nWdtGrow/2;
2714*cdf0e10cSrcweir 						rR.Left()-=nWdtGrow2;
2715*cdf0e10cSrcweir 						rR.Right()=rR.Left()+nWdt;
2716*cdf0e10cSrcweir 					}
2717*cdf0e10cSrcweir 				}
2718*cdf0e10cSrcweir 				if ( bHgtGrow )
2719*cdf0e10cSrcweir 				{
2720*cdf0e10cSrcweir 					SdrTextVertAdjust eVAdj=GetTextVerticalAdjust();
2721*cdf0e10cSrcweir 					if ( eVAdj == SDRTEXTVERTADJUST_TOP )
2722*cdf0e10cSrcweir 						rR.Bottom()+=nHgtGrow;
2723*cdf0e10cSrcweir 					else if ( eVAdj == SDRTEXTVERTADJUST_BOTTOM )
2724*cdf0e10cSrcweir 						rR.Top()-=nHgtGrow;
2725*cdf0e10cSrcweir 					else
2726*cdf0e10cSrcweir 					{
2727*cdf0e10cSrcweir 						long nHgtGrow2=nHgtGrow/2;
2728*cdf0e10cSrcweir 						rR.Top()-=nHgtGrow2;
2729*cdf0e10cSrcweir 						rR.Bottom()=rR.Top()+nHgt;
2730*cdf0e10cSrcweir 					}
2731*cdf0e10cSrcweir 				}
2732*cdf0e10cSrcweir 				if ( aGeo.nDrehWink )
2733*cdf0e10cSrcweir 				{
2734*cdf0e10cSrcweir 					Point aD1(rR.TopLeft());
2735*cdf0e10cSrcweir 					aD1-=aR0.TopLeft();
2736*cdf0e10cSrcweir 					Point aD2(aD1);
2737*cdf0e10cSrcweir 					RotatePoint(aD2,Point(),aGeo.nSin,aGeo.nCos);
2738*cdf0e10cSrcweir 					aD2-=aD1;
2739*cdf0e10cSrcweir 					rR.Move(aD2.X(),aD2.Y());
2740*cdf0e10cSrcweir 				}
2741*cdf0e10cSrcweir 				return sal_True;
2742*cdf0e10cSrcweir 			}
2743*cdf0e10cSrcweir 		}
2744*cdf0e10cSrcweir 	}
2745*cdf0e10cSrcweir 	return sal_False;
2746*cdf0e10cSrcweir }
2747*cdf0e10cSrcweir 
2748*cdf0e10cSrcweir Rectangle SdrObjCustomShape::ImpCalculateTextFrame( const FASTBOOL bHgt, const FASTBOOL bWdt )
2749*cdf0e10cSrcweir {
2750*cdf0e10cSrcweir 	Rectangle aReturnValue;
2751*cdf0e10cSrcweir 
2752*cdf0e10cSrcweir 	Rectangle aOldTextRect( aRect );		// <- initial text rectangle
2753*cdf0e10cSrcweir 
2754*cdf0e10cSrcweir 	Rectangle aNewTextRect( aRect );		// <- new text rectangle returned from the custom shape renderer,
2755*cdf0e10cSrcweir 	GetTextBounds( aNewTextRect );			//    it depends to the current logical shape size
2756*cdf0e10cSrcweir 
2757*cdf0e10cSrcweir 	Rectangle aAdjustedTextRect( aNewTextRect );							// <- new text rectangle is being tested by AdjustTextFrameWidthAndHeight to ensure
2758*cdf0e10cSrcweir 	if ( AdjustTextFrameWidthAndHeight( aAdjustedTextRect, bHgt, bWdt ) )	//    that the new text rectangle is matching the current text size from the outliner
2759*cdf0e10cSrcweir 	{
2760*cdf0e10cSrcweir 		if ( ( aAdjustedTextRect != aNewTextRect ) && ( aOldTextRect != aAdjustedTextRect ) )
2761*cdf0e10cSrcweir 		{
2762*cdf0e10cSrcweir 			aReturnValue = aRect;
2763*cdf0e10cSrcweir 			double fXScale = (double)aOldTextRect.GetWidth() / (double)aNewTextRect.GetWidth();
2764*cdf0e10cSrcweir 			double fYScale = (double)aOldTextRect.GetHeight() / (double)aNewTextRect.GetHeight();
2765*cdf0e10cSrcweir 			double fRightDiff = (double)( aAdjustedTextRect.Right() - aNewTextRect.Right() ) * fXScale;
2766*cdf0e10cSrcweir 			double fLeftDiff  = (double)( aAdjustedTextRect.Left()  - aNewTextRect.Left()  ) * fXScale;
2767*cdf0e10cSrcweir 			double fTopDiff   = (double)( aAdjustedTextRect.Top()   - aNewTextRect.Top()   ) * fYScale;
2768*cdf0e10cSrcweir 			double fBottomDiff= (double)( aAdjustedTextRect.Bottom()- aNewTextRect.Bottom()) * fYScale;
2769*cdf0e10cSrcweir 			aReturnValue.Left() += (sal_Int32)fLeftDiff;
2770*cdf0e10cSrcweir 			aReturnValue.Right() += (sal_Int32)fRightDiff;
2771*cdf0e10cSrcweir 			aReturnValue.Top() += (sal_Int32)fTopDiff;
2772*cdf0e10cSrcweir 			aReturnValue.Bottom() += (sal_Int32)fBottomDiff;
2773*cdf0e10cSrcweir 		}
2774*cdf0e10cSrcweir 	}
2775*cdf0e10cSrcweir 	return aReturnValue;
2776*cdf0e10cSrcweir }
2777*cdf0e10cSrcweir 
2778*cdf0e10cSrcweir FASTBOOL SdrObjCustomShape::NbcAdjustTextFrameWidthAndHeight(FASTBOOL bHgt, FASTBOOL bWdt)
2779*cdf0e10cSrcweir {
2780*cdf0e10cSrcweir 	Rectangle aNewTextRect = ImpCalculateTextFrame( bHgt, bWdt );
2781*cdf0e10cSrcweir 	sal_Bool bRet = !aNewTextRect.IsEmpty() && ( aNewTextRect != aRect );
2782*cdf0e10cSrcweir 	if ( bRet )
2783*cdf0e10cSrcweir 	{
2784*cdf0e10cSrcweir 		// taking care of handles that should not been changed
2785*cdf0e10cSrcweir 		std::vector< SdrCustomShapeInteraction > aInteractionHandles( GetInteractionHandles( this ) );
2786*cdf0e10cSrcweir 
2787*cdf0e10cSrcweir 		aRect = aNewTextRect;
2788*cdf0e10cSrcweir 		SetRectsDirty();
2789*cdf0e10cSrcweir 		SetChanged();
2790*cdf0e10cSrcweir 
2791*cdf0e10cSrcweir 		std::vector< SdrCustomShapeInteraction >::iterator aIter( aInteractionHandles.begin() );
2792*cdf0e10cSrcweir 		while ( aIter != aInteractionHandles.end() )
2793*cdf0e10cSrcweir 		{
2794*cdf0e10cSrcweir 			try
2795*cdf0e10cSrcweir 			{
2796*cdf0e10cSrcweir 				if ( aIter->nMode & CUSTOMSHAPE_HANDLE_RESIZE_FIXED )
2797*cdf0e10cSrcweir 					aIter->xInteraction->setControllerPosition( aIter->aPosition );
2798*cdf0e10cSrcweir 			}
2799*cdf0e10cSrcweir 			catch ( const uno::RuntimeException& )
2800*cdf0e10cSrcweir 			{
2801*cdf0e10cSrcweir 			}
2802*cdf0e10cSrcweir 			aIter++;
2803*cdf0e10cSrcweir 		}
2804*cdf0e10cSrcweir 		InvalidateRenderGeometry();
2805*cdf0e10cSrcweir 	}
2806*cdf0e10cSrcweir 	return bRet;
2807*cdf0e10cSrcweir }
2808*cdf0e10cSrcweir FASTBOOL SdrObjCustomShape::AdjustTextFrameWidthAndHeight(FASTBOOL bHgt, FASTBOOL bWdt)
2809*cdf0e10cSrcweir {
2810*cdf0e10cSrcweir 	Rectangle aNewTextRect = ImpCalculateTextFrame( bHgt, bWdt );
2811*cdf0e10cSrcweir 	sal_Bool bRet = !aNewTextRect.IsEmpty() && ( aNewTextRect != aRect );
2812*cdf0e10cSrcweir 	if ( bRet )
2813*cdf0e10cSrcweir 	{
2814*cdf0e10cSrcweir 		Rectangle aBoundRect0;
2815*cdf0e10cSrcweir 		if ( pUserCall )
2816*cdf0e10cSrcweir 			aBoundRect0 = GetCurrentBoundRect();
2817*cdf0e10cSrcweir 
2818*cdf0e10cSrcweir 		// taking care of handles that should not been changed
2819*cdf0e10cSrcweir 		std::vector< SdrCustomShapeInteraction > aInteractionHandles( GetInteractionHandles( this ) );
2820*cdf0e10cSrcweir 
2821*cdf0e10cSrcweir //		SendRepaintBroadcast();
2822*cdf0e10cSrcweir 		aRect = aNewTextRect;
2823*cdf0e10cSrcweir 		SetRectsDirty();
2824*cdf0e10cSrcweir 
2825*cdf0e10cSrcweir 		std::vector< SdrCustomShapeInteraction >::iterator aIter( aInteractionHandles.begin() );
2826*cdf0e10cSrcweir 		while ( aIter != aInteractionHandles.end() )
2827*cdf0e10cSrcweir 		{
2828*cdf0e10cSrcweir 			try
2829*cdf0e10cSrcweir 			{
2830*cdf0e10cSrcweir 				if ( aIter->nMode & CUSTOMSHAPE_HANDLE_RESIZE_FIXED )
2831*cdf0e10cSrcweir 					aIter->xInteraction->setControllerPosition( aIter->aPosition );
2832*cdf0e10cSrcweir 			}
2833*cdf0e10cSrcweir 			catch ( const uno::RuntimeException& )
2834*cdf0e10cSrcweir 			{
2835*cdf0e10cSrcweir 			}
2836*cdf0e10cSrcweir 			aIter++;
2837*cdf0e10cSrcweir 		}
2838*cdf0e10cSrcweir 
2839*cdf0e10cSrcweir 		InvalidateRenderGeometry();
2840*cdf0e10cSrcweir 		SetChanged();
2841*cdf0e10cSrcweir //		SendRepaintBroadcast();
2842*cdf0e10cSrcweir 		BroadcastObjectChange();
2843*cdf0e10cSrcweir 		SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
2844*cdf0e10cSrcweir 	}
2845*cdf0e10cSrcweir 	return bRet;
2846*cdf0e10cSrcweir }
2847*cdf0e10cSrcweir sal_Bool SdrObjCustomShape::BegTextEdit( SdrOutliner& rOutl )
2848*cdf0e10cSrcweir {
2849*cdf0e10cSrcweir 	return SdrTextObj::BegTextEdit( rOutl );
2850*cdf0e10cSrcweir }
2851*cdf0e10cSrcweir void SdrObjCustomShape::TakeTextEditArea(Size* pPaperMin, Size* pPaperMax, Rectangle* pViewInit, Rectangle* pViewMin) const
2852*cdf0e10cSrcweir {
2853*cdf0e10cSrcweir 	Size aPaperMin,aPaperMax;
2854*cdf0e10cSrcweir 	Rectangle aViewInit;
2855*cdf0e10cSrcweir 	TakeTextAnchorRect( aViewInit );
2856*cdf0e10cSrcweir 	if ( aGeo.nDrehWink )
2857*cdf0e10cSrcweir 	{
2858*cdf0e10cSrcweir 		Point aCenter(aViewInit.Center());
2859*cdf0e10cSrcweir 		aCenter-=aViewInit.TopLeft();
2860*cdf0e10cSrcweir 		Point aCenter0(aCenter);
2861*cdf0e10cSrcweir 		RotatePoint(aCenter,Point(),aGeo.nSin,aGeo.nCos);
2862*cdf0e10cSrcweir 		aCenter-=aCenter0;
2863*cdf0e10cSrcweir 		aViewInit.Move(aCenter.X(),aCenter.Y());
2864*cdf0e10cSrcweir 	}
2865*cdf0e10cSrcweir 	Size aAnkSiz(aViewInit.GetSize());
2866*cdf0e10cSrcweir 	aAnkSiz.Width()--; aAnkSiz.Height()--; // weil GetSize() ein draufaddiert
2867*cdf0e10cSrcweir 	Size aMaxSiz(1000000,1000000);
2868*cdf0e10cSrcweir 	if (pModel!=NULL) {
2869*cdf0e10cSrcweir 		Size aTmpSiz(pModel->GetMaxObjSize());
2870*cdf0e10cSrcweir 		if (aTmpSiz.Width()!=0) aMaxSiz.Width()=aTmpSiz.Width();
2871*cdf0e10cSrcweir 		if (aTmpSiz.Height()!=0) aMaxSiz.Height()=aTmpSiz.Height();
2872*cdf0e10cSrcweir 	}
2873*cdf0e10cSrcweir 	SdrTextHorzAdjust eHAdj(GetTextHorizontalAdjust());
2874*cdf0e10cSrcweir 	SdrTextVertAdjust eVAdj(GetTextVerticalAdjust());
2875*cdf0e10cSrcweir 
2876*cdf0e10cSrcweir 	long nMinWdt = GetMinTextFrameWidth();
2877*cdf0e10cSrcweir 	long nMinHgt = GetMinTextFrameHeight();
2878*cdf0e10cSrcweir 	long nMaxWdt = GetMaxTextFrameWidth();
2879*cdf0e10cSrcweir 	long nMaxHgt = GetMaxTextFrameHeight();
2880*cdf0e10cSrcweir 	if (nMinWdt<1) nMinWdt=1;
2881*cdf0e10cSrcweir 	if (nMinHgt<1) nMinHgt=1;
2882*cdf0e10cSrcweir 	if ( nMaxWdt == 0 || nMaxWdt > aMaxSiz.Width() )
2883*cdf0e10cSrcweir 		nMaxWdt = aMaxSiz.Width();
2884*cdf0e10cSrcweir 	if ( nMaxHgt == 0 || nMaxHgt > aMaxSiz.Height() )
2885*cdf0e10cSrcweir 		nMaxHgt=aMaxSiz.Height();
2886*cdf0e10cSrcweir 
2887*cdf0e10cSrcweir 	if (((SdrTextWordWrapItem&)(GetMergedItem(SDRATTR_TEXT_WORDWRAP))).GetValue())
2888*cdf0e10cSrcweir 	{
2889*cdf0e10cSrcweir 		if ( IsVerticalWriting() )
2890*cdf0e10cSrcweir 		{
2891*cdf0e10cSrcweir 			nMaxHgt = aAnkSiz.Height();
2892*cdf0e10cSrcweir 			nMinHgt = nMaxHgt;
2893*cdf0e10cSrcweir 		}
2894*cdf0e10cSrcweir 		else
2895*cdf0e10cSrcweir 		{
2896*cdf0e10cSrcweir 			nMaxWdt = aAnkSiz.Width();
2897*cdf0e10cSrcweir 			nMinWdt = nMaxWdt;
2898*cdf0e10cSrcweir 		}
2899*cdf0e10cSrcweir 	}
2900*cdf0e10cSrcweir 	aPaperMax.Width()=nMaxWdt;
2901*cdf0e10cSrcweir 	aPaperMax.Height()=nMaxHgt;
2902*cdf0e10cSrcweir 
2903*cdf0e10cSrcweir 	aPaperMin.Width()=nMinWdt;
2904*cdf0e10cSrcweir 	aPaperMin.Height()=nMinHgt;
2905*cdf0e10cSrcweir 
2906*cdf0e10cSrcweir 	if ( pViewMin )
2907*cdf0e10cSrcweir 	{
2908*cdf0e10cSrcweir 		*pViewMin = aViewInit;
2909*cdf0e10cSrcweir 
2910*cdf0e10cSrcweir 		long nXFree = aAnkSiz.Width() - aPaperMin.Width();
2911*cdf0e10cSrcweir 		if ( eHAdj == SDRTEXTHORZADJUST_LEFT )
2912*cdf0e10cSrcweir 			pViewMin->Right() -= nXFree;
2913*cdf0e10cSrcweir 		else if ( eHAdj == SDRTEXTHORZADJUST_RIGHT )
2914*cdf0e10cSrcweir 			pViewMin->Left() += nXFree;
2915*cdf0e10cSrcweir 		else { pViewMin->Left() += nXFree / 2; pViewMin->Right() = pViewMin->Left() + aPaperMin.Width(); }
2916*cdf0e10cSrcweir 
2917*cdf0e10cSrcweir 		long nYFree = aAnkSiz.Height() - aPaperMin.Height();
2918*cdf0e10cSrcweir 		if ( eVAdj == SDRTEXTVERTADJUST_TOP )
2919*cdf0e10cSrcweir 			pViewMin->Bottom() -= nYFree;
2920*cdf0e10cSrcweir 		else if ( eVAdj == SDRTEXTVERTADJUST_BOTTOM )
2921*cdf0e10cSrcweir 			pViewMin->Top() += nYFree;
2922*cdf0e10cSrcweir 		else { pViewMin->Top() += nYFree / 2; pViewMin->Bottom() = pViewMin->Top() + aPaperMin.Height(); }
2923*cdf0e10cSrcweir 	}
2924*cdf0e10cSrcweir 
2925*cdf0e10cSrcweir 	if( IsVerticalWriting() )
2926*cdf0e10cSrcweir 		aPaperMin.Width() = 0;
2927*cdf0e10cSrcweir 	else
2928*cdf0e10cSrcweir 		aPaperMin.Height() = 0; // #33102#
2929*cdf0e10cSrcweir 
2930*cdf0e10cSrcweir 	if( eHAdj != SDRTEXTHORZADJUST_BLOCK )
2931*cdf0e10cSrcweir 		aPaperMin.Width()=0;
2932*cdf0e10cSrcweir 
2933*cdf0e10cSrcweir 	// #103516# For complete ver adjust support, set paper min height to 0, here.
2934*cdf0e10cSrcweir 	if(SDRTEXTVERTADJUST_BLOCK != eVAdj )
2935*cdf0e10cSrcweir 		aPaperMin.Height() = 0;
2936*cdf0e10cSrcweir 
2937*cdf0e10cSrcweir 	if (pPaperMin!=NULL) *pPaperMin=aPaperMin;
2938*cdf0e10cSrcweir 	if (pPaperMax!=NULL) *pPaperMax=aPaperMax;
2939*cdf0e10cSrcweir 	if (pViewInit!=NULL) *pViewInit=aViewInit;
2940*cdf0e10cSrcweir }
2941*cdf0e10cSrcweir void SdrObjCustomShape::EndTextEdit( SdrOutliner& rOutl )
2942*cdf0e10cSrcweir {
2943*cdf0e10cSrcweir 	SdrTextObj::EndTextEdit( rOutl );
2944*cdf0e10cSrcweir 	InvalidateRenderGeometry();
2945*cdf0e10cSrcweir }
2946*cdf0e10cSrcweir void SdrObjCustomShape::TakeTextAnchorRect( Rectangle& rAnchorRect ) const
2947*cdf0e10cSrcweir {
2948*cdf0e10cSrcweir 	if ( GetTextBounds( rAnchorRect ) )
2949*cdf0e10cSrcweir 	{
2950*cdf0e10cSrcweir 		Point aRotateRef( maSnapRect.Center() );
2951*cdf0e10cSrcweir 		rAnchorRect.Left()   += GetTextLeftDistance();
2952*cdf0e10cSrcweir 		rAnchorRect.Top()    += GetTextUpperDistance();
2953*cdf0e10cSrcweir 		rAnchorRect.Right()  -= GetTextRightDistance();
2954*cdf0e10cSrcweir 		rAnchorRect.Bottom() -= GetTextLowerDistance();
2955*cdf0e10cSrcweir 		ImpJustifyRect( rAnchorRect );
2956*cdf0e10cSrcweir 
2957*cdf0e10cSrcweir 		if ( rAnchorRect.GetWidth() < 2 )
2958*cdf0e10cSrcweir 			rAnchorRect.Right() = rAnchorRect.Left() + 1;	// minimal width is 2
2959*cdf0e10cSrcweir 		if ( rAnchorRect.GetHeight() < 2 )
2960*cdf0e10cSrcweir 			rAnchorRect.Bottom() = rAnchorRect.Top() + 1;	// minimal height is 2
2961*cdf0e10cSrcweir 		if ( aGeo.nDrehWink )
2962*cdf0e10cSrcweir 		{
2963*cdf0e10cSrcweir 			Point aP( rAnchorRect.TopLeft() );
2964*cdf0e10cSrcweir 			RotatePoint( aP, aRotateRef, aGeo.nSin, aGeo. nCos );
2965*cdf0e10cSrcweir 			rAnchorRect.SetPos( aP );
2966*cdf0e10cSrcweir 		}
2967*cdf0e10cSrcweir 	}
2968*cdf0e10cSrcweir 	else
2969*cdf0e10cSrcweir 		SdrTextObj::TakeTextAnchorRect( rAnchorRect );
2970*cdf0e10cSrcweir }
2971*cdf0e10cSrcweir void SdrObjCustomShape::TakeTextRect( SdrOutliner& rOutliner, Rectangle& rTextRect, FASTBOOL bNoEditText,
2972*cdf0e10cSrcweir 	                           Rectangle* pAnchorRect, sal_Bool /*bLineWidth*/) const
2973*cdf0e10cSrcweir {
2974*cdf0e10cSrcweir 	Rectangle aAnkRect; // Rect innerhalb dem geankert wird
2975*cdf0e10cSrcweir 	TakeTextAnchorRect(aAnkRect);
2976*cdf0e10cSrcweir 	SdrTextVertAdjust eVAdj=GetTextVerticalAdjust();
2977*cdf0e10cSrcweir 	SdrTextHorzAdjust eHAdj=GetTextHorizontalAdjust();
2978*cdf0e10cSrcweir 	sal_uIntPtr nStat0=rOutliner.GetControlWord();
2979*cdf0e10cSrcweir 	Size aNullSize;
2980*cdf0e10cSrcweir 
2981*cdf0e10cSrcweir 	rOutliner.SetControlWord(nStat0|EE_CNTRL_AUTOPAGESIZE);
2982*cdf0e10cSrcweir 	rOutliner.SetMinAutoPaperSize(aNullSize);
2983*cdf0e10cSrcweir 	sal_Int32 nMaxAutoPaperWidth = 1000000;
2984*cdf0e10cSrcweir 	sal_Int32 nMaxAutoPaperHeight= 1000000;
2985*cdf0e10cSrcweir 
2986*cdf0e10cSrcweir 	long nAnkWdt=aAnkRect.GetWidth();
2987*cdf0e10cSrcweir 	long nAnkHgt=aAnkRect.GetHeight();
2988*cdf0e10cSrcweir 
2989*cdf0e10cSrcweir 	if (((SdrTextWordWrapItem&)(GetMergedItem(SDRATTR_TEXT_WORDWRAP))).GetValue())
2990*cdf0e10cSrcweir 	{
2991*cdf0e10cSrcweir 		if ( IsVerticalWriting() )
2992*cdf0e10cSrcweir 			nMaxAutoPaperHeight = nAnkHgt;
2993*cdf0e10cSrcweir 		else
2994*cdf0e10cSrcweir 			nMaxAutoPaperWidth = nAnkWdt;
2995*cdf0e10cSrcweir 	}
2996*cdf0e10cSrcweir 	if(SDRTEXTHORZADJUST_BLOCK == eHAdj && !IsVerticalWriting())
2997*cdf0e10cSrcweir 	{
2998*cdf0e10cSrcweir 		rOutliner.SetMinAutoPaperSize(Size(nAnkWdt, 0));
2999*cdf0e10cSrcweir 	}
3000*cdf0e10cSrcweir 
3001*cdf0e10cSrcweir 	if(SDRTEXTVERTADJUST_BLOCK == eVAdj && IsVerticalWriting())
3002*cdf0e10cSrcweir 	{
3003*cdf0e10cSrcweir 		rOutliner.SetMinAutoPaperSize(Size(0, nAnkHgt));
3004*cdf0e10cSrcweir 	}
3005*cdf0e10cSrcweir 	rOutliner.SetMaxAutoPaperSize( Size( nMaxAutoPaperWidth, nMaxAutoPaperHeight ) );
3006*cdf0e10cSrcweir 	rOutliner.SetPaperSize( aNullSize );
3007*cdf0e10cSrcweir 
3008*cdf0e10cSrcweir 	// Text in den Outliner stecken - ggf. den aus dem EditOutliner
3009*cdf0e10cSrcweir 	OutlinerParaObject* pPara= GetOutlinerParaObject();
3010*cdf0e10cSrcweir 	if (pEdtOutl && !bNoEditText)
3011*cdf0e10cSrcweir 		pPara=pEdtOutl->CreateParaObject();
3012*cdf0e10cSrcweir 
3013*cdf0e10cSrcweir 	if (pPara)
3014*cdf0e10cSrcweir 	{
3015*cdf0e10cSrcweir 		sal_Bool bHitTest = sal_False;
3016*cdf0e10cSrcweir 		if( pModel )
3017*cdf0e10cSrcweir 			bHitTest = &pModel->GetHitTestOutliner() == &rOutliner;
3018*cdf0e10cSrcweir 
3019*cdf0e10cSrcweir 		const SdrTextObj* pTestObj = rOutliner.GetTextObj();
3020*cdf0e10cSrcweir 		if( !pTestObj || !bHitTest || pTestObj != this ||
3021*cdf0e10cSrcweir 		    pTestObj->GetOutlinerParaObject() != GetOutlinerParaObject() )
3022*cdf0e10cSrcweir 		{
3023*cdf0e10cSrcweir 			if( bHitTest )
3024*cdf0e10cSrcweir 				rOutliner.SetTextObj( this );
3025*cdf0e10cSrcweir 
3026*cdf0e10cSrcweir 			rOutliner.SetUpdateMode(sal_True);
3027*cdf0e10cSrcweir 			rOutliner.SetText(*pPara);
3028*cdf0e10cSrcweir 		}
3029*cdf0e10cSrcweir 	}
3030*cdf0e10cSrcweir 	else
3031*cdf0e10cSrcweir 	{
3032*cdf0e10cSrcweir 		rOutliner.SetTextObj( NULL );
3033*cdf0e10cSrcweir 	}
3034*cdf0e10cSrcweir 	if (pEdtOutl && !bNoEditText && pPara)
3035*cdf0e10cSrcweir 		delete pPara;
3036*cdf0e10cSrcweir 
3037*cdf0e10cSrcweir 	rOutliner.SetUpdateMode(sal_True);
3038*cdf0e10cSrcweir 	rOutliner.SetControlWord(nStat0);
3039*cdf0e10cSrcweir 
3040*cdf0e10cSrcweir 	SdrText* pText = getActiveText();
3041*cdf0e10cSrcweir 	if( pText )
3042*cdf0e10cSrcweir 		pText->CheckPortionInfo( rOutliner );
3043*cdf0e10cSrcweir 
3044*cdf0e10cSrcweir 	Point aTextPos(aAnkRect.TopLeft());
3045*cdf0e10cSrcweir 	Size aTextSiz(rOutliner.GetPaperSize()); // GetPaperSize() hat etwas Toleranz drauf, oder?
3046*cdf0e10cSrcweir 
3047*cdf0e10cSrcweir 	// #106653#
3048*cdf0e10cSrcweir 	// For draw objects containing text correct hor/ver alignment if text is bigger
3049*cdf0e10cSrcweir 	// than the object itself. Without that correction, the text would always be
3050*cdf0e10cSrcweir 		// formatted to the left edge (or top edge when vertical) of the draw object.
3051*cdf0e10cSrcweir 
3052*cdf0e10cSrcweir 	if( !IsTextFrame() )
3053*cdf0e10cSrcweir 	{
3054*cdf0e10cSrcweir 		if(aAnkRect.GetWidth() < aTextSiz.Width() && !IsVerticalWriting())
3055*cdf0e10cSrcweir 		{
3056*cdf0e10cSrcweir 			// #110129#
3057*cdf0e10cSrcweir 			// Horizontal case here. Correct only if eHAdj == SDRTEXTHORZADJUST_BLOCK,
3058*cdf0e10cSrcweir 			// else the alignment is wanted.
3059*cdf0e10cSrcweir 			if(SDRTEXTHORZADJUST_BLOCK == eHAdj)
3060*cdf0e10cSrcweir 			{
3061*cdf0e10cSrcweir 				eHAdj = SDRTEXTHORZADJUST_CENTER;
3062*cdf0e10cSrcweir 			}
3063*cdf0e10cSrcweir 		}
3064*cdf0e10cSrcweir 
3065*cdf0e10cSrcweir 		if(aAnkRect.GetHeight() < aTextSiz.Height() && IsVerticalWriting())
3066*cdf0e10cSrcweir 		{
3067*cdf0e10cSrcweir 			// #110129#
3068*cdf0e10cSrcweir 			// Vertical case here. Correct only if eHAdj == SDRTEXTVERTADJUST_BLOCK,
3069*cdf0e10cSrcweir 			// else the alignment is wanted.
3070*cdf0e10cSrcweir 			if(SDRTEXTVERTADJUST_BLOCK == eVAdj)
3071*cdf0e10cSrcweir 			{
3072*cdf0e10cSrcweir 				eVAdj = SDRTEXTVERTADJUST_CENTER;
3073*cdf0e10cSrcweir 			}
3074*cdf0e10cSrcweir 		}
3075*cdf0e10cSrcweir 	}
3076*cdf0e10cSrcweir 
3077*cdf0e10cSrcweir 	if (eHAdj==SDRTEXTHORZADJUST_CENTER || eHAdj==SDRTEXTHORZADJUST_RIGHT)
3078*cdf0e10cSrcweir 	{
3079*cdf0e10cSrcweir 		long nFreeWdt=aAnkRect.GetWidth()-aTextSiz.Width();
3080*cdf0e10cSrcweir 		if (eHAdj==SDRTEXTHORZADJUST_CENTER)
3081*cdf0e10cSrcweir 			aTextPos.X()+=nFreeWdt/2;
3082*cdf0e10cSrcweir 		if (eHAdj==SDRTEXTHORZADJUST_RIGHT)
3083*cdf0e10cSrcweir 			aTextPos.X()+=nFreeWdt;
3084*cdf0e10cSrcweir 	}
3085*cdf0e10cSrcweir 	if (eVAdj==SDRTEXTVERTADJUST_CENTER || eVAdj==SDRTEXTVERTADJUST_BOTTOM)
3086*cdf0e10cSrcweir 	{
3087*cdf0e10cSrcweir 		long nFreeHgt=aAnkRect.GetHeight()-aTextSiz.Height();
3088*cdf0e10cSrcweir 		if (eVAdj==SDRTEXTVERTADJUST_CENTER)
3089*cdf0e10cSrcweir 			aTextPos.Y()+=nFreeHgt/2;
3090*cdf0e10cSrcweir 		if (eVAdj==SDRTEXTVERTADJUST_BOTTOM)
3091*cdf0e10cSrcweir 			aTextPos.Y()+=nFreeHgt;
3092*cdf0e10cSrcweir 	}
3093*cdf0e10cSrcweir 	if (aGeo.nDrehWink!=0)
3094*cdf0e10cSrcweir 		RotatePoint(aTextPos,aAnkRect.TopLeft(),aGeo.nSin,aGeo.nCos);
3095*cdf0e10cSrcweir 
3096*cdf0e10cSrcweir 	if (pAnchorRect)
3097*cdf0e10cSrcweir 		*pAnchorRect=aAnkRect;
3098*cdf0e10cSrcweir 
3099*cdf0e10cSrcweir 	// rTextRect ist bei ContourFrame in einigen Faellen nicht korrekt
3100*cdf0e10cSrcweir 	rTextRect=Rectangle(aTextPos,aTextSiz);
3101*cdf0e10cSrcweir }
3102*cdf0e10cSrcweir 
3103*cdf0e10cSrcweir void SdrObjCustomShape::NbcSetOutlinerParaObject(OutlinerParaObject* pTextObject)
3104*cdf0e10cSrcweir {
3105*cdf0e10cSrcweir 	SdrTextObj::NbcSetOutlinerParaObject( pTextObject );
3106*cdf0e10cSrcweir 	SetBoundRectDirty();
3107*cdf0e10cSrcweir 	SetRectsDirty(sal_True);
3108*cdf0e10cSrcweir 	InvalidateRenderGeometry();
3109*cdf0e10cSrcweir }
3110*cdf0e10cSrcweir 
3111*cdf0e10cSrcweir void SdrObjCustomShape::operator=(const SdrObject& rObj)
3112*cdf0e10cSrcweir {
3113*cdf0e10cSrcweir 	SdrTextObj::operator=( rObj );
3114*cdf0e10cSrcweir 	aName =((SdrObjCustomShape&)rObj).aName;
3115*cdf0e10cSrcweir 	fObjectRotation = ((SdrObjCustomShape&)rObj).fObjectRotation;
3116*cdf0e10cSrcweir 	InvalidateRenderGeometry();
3117*cdf0e10cSrcweir }
3118*cdf0e10cSrcweir 
3119*cdf0e10cSrcweir 
3120*cdf0e10cSrcweir void SdrObjCustomShape::TakeObjNameSingul(XubString& rName) const
3121*cdf0e10cSrcweir {
3122*cdf0e10cSrcweir 	rName = ImpGetResStr(STR_ObjNameSingulCUSTOMSHAPE);
3123*cdf0e10cSrcweir 	String aNm( GetName() );
3124*cdf0e10cSrcweir 	if( aNm.Len() )
3125*cdf0e10cSrcweir 	{
3126*cdf0e10cSrcweir 		rName += sal_Unicode(' ');
3127*cdf0e10cSrcweir 		rName += sal_Unicode('\'');
3128*cdf0e10cSrcweir 		rName += aNm;
3129*cdf0e10cSrcweir 		rName += sal_Unicode('\'');
3130*cdf0e10cSrcweir 	}
3131*cdf0e10cSrcweir }
3132*cdf0e10cSrcweir 
3133*cdf0e10cSrcweir void SdrObjCustomShape::TakeObjNamePlural(XubString& rName) const
3134*cdf0e10cSrcweir {
3135*cdf0e10cSrcweir 	rName=ImpGetResStr(STR_ObjNamePluralCUSTOMSHAPE);
3136*cdf0e10cSrcweir }
3137*cdf0e10cSrcweir 
3138*cdf0e10cSrcweir basegfx::B2DPolyPolygon SdrObjCustomShape::TakeXorPoly() const
3139*cdf0e10cSrcweir {
3140*cdf0e10cSrcweir 	return GetLineGeometry( (SdrObjCustomShape*)this, sal_False );
3141*cdf0e10cSrcweir }
3142*cdf0e10cSrcweir 
3143*cdf0e10cSrcweir basegfx::B2DPolyPolygon SdrObjCustomShape::TakeContour() const
3144*cdf0e10cSrcweir {
3145*cdf0e10cSrcweir 	const SdrObject* pSdrObject = GetSdrObjectFromCustomShape();
3146*cdf0e10cSrcweir 	if ( pSdrObject )
3147*cdf0e10cSrcweir 		return pSdrObject->TakeContour();
3148*cdf0e10cSrcweir 	return basegfx::B2DPolyPolygon();
3149*cdf0e10cSrcweir }
3150*cdf0e10cSrcweir 
3151*cdf0e10cSrcweir SdrObject* SdrObjCustomShape::DoConvertToPolyObj(sal_Bool bBezier) const
3152*cdf0e10cSrcweir {
3153*cdf0e10cSrcweir 	// #i37011#
3154*cdf0e10cSrcweir 	SdrObject* pRetval = 0L;
3155*cdf0e10cSrcweir 	SdrObject* pRenderedCustomShape = 0L;
3156*cdf0e10cSrcweir 
3157*cdf0e10cSrcweir 	if ( !mXRenderedCustomShape.is() )
3158*cdf0e10cSrcweir 	{
3159*cdf0e10cSrcweir 		// force CustomShape
3160*cdf0e10cSrcweir 		((SdrObjCustomShape*)this)->GetSdrObjectFromCustomShape();
3161*cdf0e10cSrcweir 	}
3162*cdf0e10cSrcweir 
3163*cdf0e10cSrcweir 	if ( mXRenderedCustomShape.is() )
3164*cdf0e10cSrcweir 	{
3165*cdf0e10cSrcweir 		pRenderedCustomShape = GetSdrObjectFromXShape( mXRenderedCustomShape );
3166*cdf0e10cSrcweir 	}
3167*cdf0e10cSrcweir 
3168*cdf0e10cSrcweir 	if ( pRenderedCustomShape )
3169*cdf0e10cSrcweir 	{
3170*cdf0e10cSrcweir 		SdrObject* pCandidate = pRenderedCustomShape->Clone();
3171*cdf0e10cSrcweir 		DBG_ASSERT(pCandidate, "SdrObjCustomShape::DoConvertToPolyObj: Could not clone SdrObject (!)");
3172*cdf0e10cSrcweir 		pCandidate->SetModel(GetModel());
3173*cdf0e10cSrcweir 		pRetval = pCandidate->DoConvertToPolyObj(bBezier);
3174*cdf0e10cSrcweir 		SdrObject::Free( pCandidate );
3175*cdf0e10cSrcweir 
3176*cdf0e10cSrcweir 		if(pRetval)
3177*cdf0e10cSrcweir 		{
3178*cdf0e10cSrcweir 			const sal_Bool bShadow(((SdrShadowItem&)GetMergedItem(SDRATTR_SHADOW)).GetValue());
3179*cdf0e10cSrcweir 			if(bShadow)
3180*cdf0e10cSrcweir 			{
3181*cdf0e10cSrcweir 				pRetval->SetMergedItem(SdrShadowItem(sal_True));
3182*cdf0e10cSrcweir 			}
3183*cdf0e10cSrcweir 		}
3184*cdf0e10cSrcweir 
3185*cdf0e10cSrcweir 		if(HasText() && !IsTextPath())
3186*cdf0e10cSrcweir 		{
3187*cdf0e10cSrcweir 			pRetval = ImpConvertAddText(pRetval, bBezier);
3188*cdf0e10cSrcweir 		}
3189*cdf0e10cSrcweir 	}
3190*cdf0e10cSrcweir 
3191*cdf0e10cSrcweir 	return pRetval;
3192*cdf0e10cSrcweir }
3193*cdf0e10cSrcweir 
3194*cdf0e10cSrcweir void SdrObjCustomShape::NbcSetStyleSheet( SfxStyleSheet* pNewStyleSheet, sal_Bool bDontRemoveHardAttr )
3195*cdf0e10cSrcweir {
3196*cdf0e10cSrcweir 	// #i40944#
3197*cdf0e10cSrcweir 	InvalidateRenderGeometry();
3198*cdf0e10cSrcweir 	SdrObject::NbcSetStyleSheet( pNewStyleSheet, bDontRemoveHardAttr );
3199*cdf0e10cSrcweir }
3200*cdf0e10cSrcweir 
3201*cdf0e10cSrcweir void SdrObjCustomShape::SetPage( SdrPage* pNewPage )
3202*cdf0e10cSrcweir {
3203*cdf0e10cSrcweir 	SdrTextObj::SetPage( pNewPage );
3204*cdf0e10cSrcweir 
3205*cdf0e10cSrcweir 	if( pNewPage )
3206*cdf0e10cSrcweir 	{
3207*cdf0e10cSrcweir 		// invalidating rectangles by SetRectsDirty is not sufficient,
3208*cdf0e10cSrcweir 		// AdjustTextFrameWidthAndHeight() also has to be made, both
3209*cdf0e10cSrcweir 		// actions are done by NbcSetSnapRect
3210*cdf0e10cSrcweir 		Rectangle aTmp( aRect );	//creating temporary rectangle #i61108#
3211*cdf0e10cSrcweir 		NbcSetSnapRect( aTmp );
3212*cdf0e10cSrcweir 	}
3213*cdf0e10cSrcweir }
3214*cdf0e10cSrcweir 
3215*cdf0e10cSrcweir SdrObjGeoData* SdrObjCustomShape::NewGeoData() const
3216*cdf0e10cSrcweir {
3217*cdf0e10cSrcweir 	return new SdrAShapeObjGeoData;
3218*cdf0e10cSrcweir }
3219*cdf0e10cSrcweir 
3220*cdf0e10cSrcweir void SdrObjCustomShape::SaveGeoData(SdrObjGeoData& rGeo) const
3221*cdf0e10cSrcweir {
3222*cdf0e10cSrcweir 	SdrTextObj::SaveGeoData( rGeo );
3223*cdf0e10cSrcweir 	SdrAShapeObjGeoData& rAGeo=(SdrAShapeObjGeoData&)rGeo;
3224*cdf0e10cSrcweir 	rAGeo.fObjectRotation = fObjectRotation;
3225*cdf0e10cSrcweir 	rAGeo.bMirroredX = IsMirroredX();
3226*cdf0e10cSrcweir 	rAGeo.bMirroredY = IsMirroredY();
3227*cdf0e10cSrcweir 
3228*cdf0e10cSrcweir 	const rtl::OUString	sAdjustmentValues( RTL_CONSTASCII_USTRINGPARAM ( "AdjustmentValues" ) );
3229*cdf0e10cSrcweir 	Any* pAny( ( (SdrCustomShapeGeometryItem&)GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) ).GetPropertyValueByName( sAdjustmentValues ) );
3230*cdf0e10cSrcweir 	if ( pAny )
3231*cdf0e10cSrcweir 		*pAny >>= rAGeo.aAdjustmentSeq;
3232*cdf0e10cSrcweir }
3233*cdf0e10cSrcweir 
3234*cdf0e10cSrcweir void SdrObjCustomShape::RestGeoData(const SdrObjGeoData& rGeo)
3235*cdf0e10cSrcweir {
3236*cdf0e10cSrcweir 	SdrTextObj::RestGeoData( rGeo );
3237*cdf0e10cSrcweir 	SdrAShapeObjGeoData& rAGeo=(SdrAShapeObjGeoData&)rGeo;
3238*cdf0e10cSrcweir 	fObjectRotation = rAGeo.fObjectRotation;
3239*cdf0e10cSrcweir 	SetMirroredX( rAGeo.bMirroredX );
3240*cdf0e10cSrcweir 	SetMirroredY( rAGeo.bMirroredY );
3241*cdf0e10cSrcweir 
3242*cdf0e10cSrcweir 	SdrCustomShapeGeometryItem rGeometryItem = (SdrCustomShapeGeometryItem&)GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY );
3243*cdf0e10cSrcweir 	const rtl::OUString	sAdjustmentValues( RTL_CONSTASCII_USTRINGPARAM ( "AdjustmentValues" ) );
3244*cdf0e10cSrcweir 	PropertyValue aPropVal;
3245*cdf0e10cSrcweir 	aPropVal.Name = sAdjustmentValues;
3246*cdf0e10cSrcweir 	aPropVal.Value <<= rAGeo.aAdjustmentSeq;
3247*cdf0e10cSrcweir 	rGeometryItem.SetPropertyValue( aPropVal );
3248*cdf0e10cSrcweir 	SetMergedItem( rGeometryItem );
3249*cdf0e10cSrcweir 
3250*cdf0e10cSrcweir 	InvalidateRenderGeometry();
3251*cdf0e10cSrcweir }
3252*cdf0e10cSrcweir 
3253*cdf0e10cSrcweir void SdrObjCustomShape::TRSetBaseGeometry(const basegfx::B2DHomMatrix& rMatrix, const basegfx::B2DPolyPolygon& /*rPolyPolygon*/)
3254*cdf0e10cSrcweir {
3255*cdf0e10cSrcweir 	// break up matrix
3256*cdf0e10cSrcweir 	basegfx::B2DTuple aScale;
3257*cdf0e10cSrcweir 	basegfx::B2DTuple aTranslate;
3258*cdf0e10cSrcweir 	double fRotate, fShearX;
3259*cdf0e10cSrcweir 	rMatrix.decompose(aScale, aTranslate, fRotate, fShearX);
3260*cdf0e10cSrcweir 
3261*cdf0e10cSrcweir 	// #i75086# Old DrawingLayer (GeoStat and geometry) does not support holding negative scalings
3262*cdf0e10cSrcweir 	// in X and Y which equal a 180 degree rotation. Recognize it and react accordingly
3263*cdf0e10cSrcweir 	if(basegfx::fTools::less(aScale.getX(), 0.0) && basegfx::fTools::less(aScale.getY(), 0.0))
3264*cdf0e10cSrcweir 	{
3265*cdf0e10cSrcweir 		aScale.setX(fabs(aScale.getX()));
3266*cdf0e10cSrcweir 		aScale.setY(fabs(aScale.getY()));
3267*cdf0e10cSrcweir 		fRotate = fmod(fRotate + F_PI, F_2PI);
3268*cdf0e10cSrcweir 	}
3269*cdf0e10cSrcweir 
3270*cdf0e10cSrcweir 	// reset object shear and rotations
3271*cdf0e10cSrcweir 	aGeo.nDrehWink = 0;
3272*cdf0e10cSrcweir 	aGeo.RecalcSinCos();
3273*cdf0e10cSrcweir 	aGeo.nShearWink = 0;
3274*cdf0e10cSrcweir 	aGeo.RecalcTan();
3275*cdf0e10cSrcweir 
3276*cdf0e10cSrcweir 	// force metric to pool metric
3277*cdf0e10cSrcweir 	SfxMapUnit eMapUnit = GetObjectItemSet().GetPool()->GetMetric(0);
3278*cdf0e10cSrcweir 	if(eMapUnit != SFX_MAPUNIT_100TH_MM)
3279*cdf0e10cSrcweir 	{
3280*cdf0e10cSrcweir 		switch(eMapUnit)
3281*cdf0e10cSrcweir 		{
3282*cdf0e10cSrcweir 			case SFX_MAPUNIT_TWIP :
3283*cdf0e10cSrcweir 			{
3284*cdf0e10cSrcweir 				// position
3285*cdf0e10cSrcweir 				aTranslate.setX(ImplMMToTwips(aTranslate.getX()));
3286*cdf0e10cSrcweir 				aTranslate.setY(ImplMMToTwips(aTranslate.getY()));
3287*cdf0e10cSrcweir 
3288*cdf0e10cSrcweir 				// size
3289*cdf0e10cSrcweir 				aScale.setX(ImplMMToTwips(aScale.getX()));
3290*cdf0e10cSrcweir 				aScale.setY(ImplMMToTwips(aScale.getY()));
3291*cdf0e10cSrcweir 
3292*cdf0e10cSrcweir 				break;
3293*cdf0e10cSrcweir 			}
3294*cdf0e10cSrcweir 			default:
3295*cdf0e10cSrcweir 			{
3296*cdf0e10cSrcweir 				DBG_ERROR("TRSetBaseGeometry: Missing unit translation to PoolMetric!");
3297*cdf0e10cSrcweir 			}
3298*cdf0e10cSrcweir 		}
3299*cdf0e10cSrcweir 	}
3300*cdf0e10cSrcweir 
3301*cdf0e10cSrcweir 	// if anchor is used, make position relative to it
3302*cdf0e10cSrcweir 	if( pModel && pModel->IsWriter() )
3303*cdf0e10cSrcweir 	{
3304*cdf0e10cSrcweir 		if(GetAnchorPos().X() || GetAnchorPos().Y())
3305*cdf0e10cSrcweir 		{
3306*cdf0e10cSrcweir 			aTranslate += basegfx::B2DTuple(GetAnchorPos().X(), GetAnchorPos().Y());
3307*cdf0e10cSrcweir 		}
3308*cdf0e10cSrcweir 	}
3309*cdf0e10cSrcweir 
3310*cdf0e10cSrcweir 	// build and set BaseRect (use scale)
3311*cdf0e10cSrcweir 	Point aPoint = Point();
3312*cdf0e10cSrcweir 	Size aSize(FRound(aScale.getX()), FRound(aScale.getY()));
3313*cdf0e10cSrcweir 	Rectangle aBaseRect(aPoint, aSize);
3314*cdf0e10cSrcweir 	SetSnapRect(aBaseRect);
3315*cdf0e10cSrcweir 
3316*cdf0e10cSrcweir 	// shear?
3317*cdf0e10cSrcweir 	if(!basegfx::fTools::equalZero(fShearX))
3318*cdf0e10cSrcweir 	{
3319*cdf0e10cSrcweir 		GeoStat aGeoStat;
3320*cdf0e10cSrcweir 		aGeoStat.nShearWink = FRound((atan(fShearX) / F_PI180) * 100.0);
3321*cdf0e10cSrcweir 		aGeoStat.RecalcTan();
3322*cdf0e10cSrcweir 		Shear(Point(), aGeoStat.nShearWink, aGeoStat.nTan, sal_False);
3323*cdf0e10cSrcweir 	}
3324*cdf0e10cSrcweir 
3325*cdf0e10cSrcweir 	// rotation?
3326*cdf0e10cSrcweir     if(!basegfx::fTools::equalZero(fRotate))
3327*cdf0e10cSrcweir 	{
3328*cdf0e10cSrcweir 		GeoStat aGeoStat;
3329*cdf0e10cSrcweir 
3330*cdf0e10cSrcweir         // #i78696#
3331*cdf0e10cSrcweir         // fRotate is mathematically correct, but aGeoStat.nDrehWink is
3332*cdf0e10cSrcweir         // mirrored -> mirror value here
3333*cdf0e10cSrcweir 		aGeoStat.nDrehWink = NormAngle360(FRound(-fRotate / F_PI18000));
3334*cdf0e10cSrcweir 		aGeoStat.RecalcSinCos();
3335*cdf0e10cSrcweir 		Rotate(Point(), aGeoStat.nDrehWink, aGeoStat.nSin, aGeoStat.nCos);
3336*cdf0e10cSrcweir 	}
3337*cdf0e10cSrcweir 
3338*cdf0e10cSrcweir 	// translate?
3339*cdf0e10cSrcweir     if(!aTranslate.equalZero())
3340*cdf0e10cSrcweir 	{
3341*cdf0e10cSrcweir 		Move(Size(FRound(aTranslate.getX()), FRound(aTranslate.getY())));
3342*cdf0e10cSrcweir 	}
3343*cdf0e10cSrcweir }
3344*cdf0e10cSrcweir 
3345*cdf0e10cSrcweir // taking fObjectRotation instead of aGeo.nWink
3346*cdf0e10cSrcweir sal_Bool SdrObjCustomShape::TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, basegfx::B2DPolyPolygon& /*rPolyPolygon*/) const
3347*cdf0e10cSrcweir {
3348*cdf0e10cSrcweir 	// get turn and shear
3349*cdf0e10cSrcweir //	double fRotate = (aGeo.nDrehWink / 100.0) * F_PI180;
3350*cdf0e10cSrcweir 	double fRotate = fObjectRotation * F_PI180;
3351*cdf0e10cSrcweir 	double fShearX = (aGeo.nShearWink / 100.0) * F_PI180;
3352*cdf0e10cSrcweir 
3353*cdf0e10cSrcweir 	// get aRect, this is the unrotated snaprect
3354*cdf0e10cSrcweir 	Rectangle aRectangle(aRect);
3355*cdf0e10cSrcweir 
3356*cdf0e10cSrcweir 	sal_Bool bMirroredX = IsMirroredX();
3357*cdf0e10cSrcweir 	sal_Bool bMirroredY = IsMirroredY();
3358*cdf0e10cSrcweir 	if ( bMirroredX || bMirroredY )
3359*cdf0e10cSrcweir 	{	// we have to retrieve the unmirrored rect
3360*cdf0e10cSrcweir 
3361*cdf0e10cSrcweir 		GeoStat aNewGeo( aGeo );
3362*cdf0e10cSrcweir 
3363*cdf0e10cSrcweir 		if ( bMirroredX )
3364*cdf0e10cSrcweir 		{
3365*cdf0e10cSrcweir 			Polygon aPol( Rect2Poly( aRect, aNewGeo ) );
3366*cdf0e10cSrcweir 			Rectangle aBoundRect( aPol.GetBoundRect() );
3367*cdf0e10cSrcweir 
3368*cdf0e10cSrcweir 			Point aRef1( ( aBoundRect.Left() + aBoundRect.Right() ) >> 1, aBoundRect.Top() );
3369*cdf0e10cSrcweir 			Point aRef2( aRef1.X(), aRef1.Y() + 1000 );
3370*cdf0e10cSrcweir 			sal_uInt16 i;
3371*cdf0e10cSrcweir 			sal_uInt16 nPntAnz=aPol.GetSize();
3372*cdf0e10cSrcweir 			for (i=0; i<nPntAnz; i++)
3373*cdf0e10cSrcweir 			{
3374*cdf0e10cSrcweir 				MirrorPoint(aPol[i],aRef1,aRef2);
3375*cdf0e10cSrcweir 			}
3376*cdf0e10cSrcweir 			// Polygon wenden und etwas schieben
3377*cdf0e10cSrcweir 			Polygon aPol0(aPol);
3378*cdf0e10cSrcweir 			aPol[0]=aPol0[1];
3379*cdf0e10cSrcweir 			aPol[1]=aPol0[0];
3380*cdf0e10cSrcweir 			aPol[2]=aPol0[3];
3381*cdf0e10cSrcweir 			aPol[3]=aPol0[2];
3382*cdf0e10cSrcweir 			aPol[4]=aPol0[1];
3383*cdf0e10cSrcweir 			Poly2Rect(aPol,aRectangle,aNewGeo);
3384*cdf0e10cSrcweir 		}
3385*cdf0e10cSrcweir 		if ( bMirroredY )
3386*cdf0e10cSrcweir 		{
3387*cdf0e10cSrcweir 			Polygon aPol( Rect2Poly( aRectangle, aNewGeo ) );
3388*cdf0e10cSrcweir 			Rectangle aBoundRect( aPol.GetBoundRect() );
3389*cdf0e10cSrcweir 
3390*cdf0e10cSrcweir 			Point aRef1( aBoundRect.Left(), ( aBoundRect.Top() + aBoundRect.Bottom() ) >> 1 );
3391*cdf0e10cSrcweir 			Point aRef2( aRef1.X() + 1000, aRef1.Y() );
3392*cdf0e10cSrcweir 			sal_uInt16 i;
3393*cdf0e10cSrcweir 			sal_uInt16 nPntAnz=aPol.GetSize();
3394*cdf0e10cSrcweir 			for (i=0; i<nPntAnz; i++)
3395*cdf0e10cSrcweir 			{
3396*cdf0e10cSrcweir 				MirrorPoint(aPol[i],aRef1,aRef2);
3397*cdf0e10cSrcweir 			}
3398*cdf0e10cSrcweir 			// Polygon wenden und etwas schieben
3399*cdf0e10cSrcweir 			Polygon aPol0(aPol);
3400*cdf0e10cSrcweir 			aPol[0]=aPol0[1];
3401*cdf0e10cSrcweir 			aPol[1]=aPol0[0];
3402*cdf0e10cSrcweir 			aPol[2]=aPol0[3];
3403*cdf0e10cSrcweir 			aPol[3]=aPol0[2];
3404*cdf0e10cSrcweir 			aPol[4]=aPol0[1];
3405*cdf0e10cSrcweir 			Poly2Rect(aPol,aRectangle,aNewGeo);
3406*cdf0e10cSrcweir 		}
3407*cdf0e10cSrcweir 	}
3408*cdf0e10cSrcweir 
3409*cdf0e10cSrcweir 	// fill other values
3410*cdf0e10cSrcweir 	basegfx::B2DTuple aScale(aRectangle.GetWidth(), aRectangle.GetHeight());
3411*cdf0e10cSrcweir 	basegfx::B2DTuple aTranslate(aRectangle.Left(), aRectangle.Top());
3412*cdf0e10cSrcweir 
3413*cdf0e10cSrcweir 	// position maybe relative to anchorpos, convert
3414*cdf0e10cSrcweir 	if( pModel && pModel->IsWriter() )
3415*cdf0e10cSrcweir 	{
3416*cdf0e10cSrcweir 		if(GetAnchorPos().X() || GetAnchorPos().Y())
3417*cdf0e10cSrcweir 		{
3418*cdf0e10cSrcweir 			aTranslate -= basegfx::B2DTuple(GetAnchorPos().X(), GetAnchorPos().Y());
3419*cdf0e10cSrcweir 		}
3420*cdf0e10cSrcweir 	}
3421*cdf0e10cSrcweir 
3422*cdf0e10cSrcweir 	// force MapUnit to 100th mm
3423*cdf0e10cSrcweir 	SfxMapUnit eMapUnit = GetObjectItemSet().GetPool()->GetMetric(0);
3424*cdf0e10cSrcweir 	if(eMapUnit != SFX_MAPUNIT_100TH_MM)
3425*cdf0e10cSrcweir 	{
3426*cdf0e10cSrcweir 		switch(eMapUnit)
3427*cdf0e10cSrcweir 		{
3428*cdf0e10cSrcweir 			case SFX_MAPUNIT_TWIP :
3429*cdf0e10cSrcweir 			{
3430*cdf0e10cSrcweir 				// postion
3431*cdf0e10cSrcweir 				aTranslate.setX(ImplTwipsToMM(aTranslate.getX()));
3432*cdf0e10cSrcweir 				aTranslate.setY(ImplTwipsToMM(aTranslate.getY()));
3433*cdf0e10cSrcweir 
3434*cdf0e10cSrcweir 				// size
3435*cdf0e10cSrcweir 				aScale.setX(ImplTwipsToMM(aScale.getX()));
3436*cdf0e10cSrcweir 				aScale.setY(ImplTwipsToMM(aScale.getY()));
3437*cdf0e10cSrcweir 
3438*cdf0e10cSrcweir 				break;
3439*cdf0e10cSrcweir 			}
3440*cdf0e10cSrcweir 			default:
3441*cdf0e10cSrcweir 			{
3442*cdf0e10cSrcweir 				DBG_ERROR("TRGetBaseGeometry: Missing unit translation to 100th mm!");
3443*cdf0e10cSrcweir 			}
3444*cdf0e10cSrcweir 		}
3445*cdf0e10cSrcweir 	}
3446*cdf0e10cSrcweir 
3447*cdf0e10cSrcweir 	// build matrix
3448*cdf0e10cSrcweir 	rMatrix = basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix(
3449*cdf0e10cSrcweir 		aScale,
3450*cdf0e10cSrcweir 		basegfx::fTools::equalZero(fShearX) ? 0.0 : tan(fShearX),
3451*cdf0e10cSrcweir 		basegfx::fTools::equalZero(fRotate) ? 0.0 : -fRotate,
3452*cdf0e10cSrcweir 		aTranslate);
3453*cdf0e10cSrcweir 
3454*cdf0e10cSrcweir 	return sal_False;
3455*cdf0e10cSrcweir }
3456*cdf0e10cSrcweir 
3457*cdf0e10cSrcweir sdr::contact::ViewContact* SdrObjCustomShape::CreateObjectSpecificViewContact()
3458*cdf0e10cSrcweir {
3459*cdf0e10cSrcweir 	return new sdr::contact::ViewContactOfSdrObjCustomShape(*this);
3460*cdf0e10cSrcweir }
3461*cdf0e10cSrcweir 
3462*cdf0e10cSrcweir // #i33136#
3463*cdf0e10cSrcweir bool SdrObjCustomShape::doConstructOrthogonal(const ::rtl::OUString& rName)
3464*cdf0e10cSrcweir {
3465*cdf0e10cSrcweir 	bool bRetval(false);
3466*cdf0e10cSrcweir 	static ::rtl::OUString Imps_sNameASOrtho_quadrat( RTL_CONSTASCII_USTRINGPARAM( "quadrat" ) );
3467*cdf0e10cSrcweir 	static ::rtl::OUString Imps_sNameASOrtho_round_quadrat( RTL_CONSTASCII_USTRINGPARAM( "round-quadrat" ) );
3468*cdf0e10cSrcweir 	static ::rtl::OUString Imps_sNameASOrtho_circle( RTL_CONSTASCII_USTRINGPARAM( "circle" ) );
3469*cdf0e10cSrcweir 	static ::rtl::OUString Imps_sNameASOrtho_circle_pie( RTL_CONSTASCII_USTRINGPARAM( "circle-pie" ) );
3470*cdf0e10cSrcweir 	static ::rtl::OUString Imps_sNameASOrtho_ring( RTL_CONSTASCII_USTRINGPARAM( "ring" ) );
3471*cdf0e10cSrcweir 
3472*cdf0e10cSrcweir 	if(Imps_sNameASOrtho_quadrat.equalsIgnoreAsciiCase(rName))
3473*cdf0e10cSrcweir 	{
3474*cdf0e10cSrcweir 		bRetval = true;
3475*cdf0e10cSrcweir 	}
3476*cdf0e10cSrcweir 	else if(Imps_sNameASOrtho_round_quadrat.equalsIgnoreAsciiCase(rName))
3477*cdf0e10cSrcweir 	{
3478*cdf0e10cSrcweir 		bRetval = true;
3479*cdf0e10cSrcweir 	}
3480*cdf0e10cSrcweir 	else if(Imps_sNameASOrtho_circle.equalsIgnoreAsciiCase(rName))
3481*cdf0e10cSrcweir 	{
3482*cdf0e10cSrcweir 		bRetval = true;
3483*cdf0e10cSrcweir 	}
3484*cdf0e10cSrcweir 	else if(Imps_sNameASOrtho_circle_pie.equalsIgnoreAsciiCase(rName))
3485*cdf0e10cSrcweir 	{
3486*cdf0e10cSrcweir 		bRetval = true;
3487*cdf0e10cSrcweir 	}
3488*cdf0e10cSrcweir 	else if(Imps_sNameASOrtho_ring.equalsIgnoreAsciiCase(rName))
3489*cdf0e10cSrcweir 	{
3490*cdf0e10cSrcweir 		bRetval = true;
3491*cdf0e10cSrcweir 	}
3492*cdf0e10cSrcweir 
3493*cdf0e10cSrcweir 	return bRetval;
3494*cdf0e10cSrcweir }
3495*cdf0e10cSrcweir 
3496*cdf0e10cSrcweir // #i37011# centralize throw-away of render geometry
3497*cdf0e10cSrcweir void SdrObjCustomShape::InvalidateRenderGeometry()
3498*cdf0e10cSrcweir {
3499*cdf0e10cSrcweir 	mXRenderedCustomShape = 0L;
3500*cdf0e10cSrcweir     SdrObject::Free( mpLastShadowGeometry );
3501*cdf0e10cSrcweir 	mpLastShadowGeometry = 0L;
3502*cdf0e10cSrcweir }
3503*cdf0e10cSrcweir 
3504*cdf0e10cSrcweir // eof
3505