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