xref: /AOO41X/main/svx/source/svdraw/svdoashp.cxx (revision 40a852fb367ec96149da0dd7bb314eceacfdbe28)
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 		{
29570d3707aSArmin Le Grand             GraphicObject aGraphicObject(((XFillBitmapItem&)(rOriginalSet.Get(XATTR_FILLBITMAP))).GetGraphicObject());
29670d3707aSArmin Le Grand             const BitmapEx aBitmapEx(aGraphicObject.GetGraphic().GetBitmapEx());
29770d3707aSArmin Le Grand 			Bitmap aBitmap(aBitmapEx.GetBitmap());
298cdf0e10cSrcweir 
29970d3707aSArmin Le Grand 			if(!aBitmap.IsEmpty())
300cdf0e10cSrcweir 			{
30170d3707aSArmin Le Grand     			BitmapReadAccess* pReadAccess = aBitmap.AcquireReadAccess();
30270d3707aSArmin Le Grand 
303cdf0e10cSrcweir                 if(pReadAccess)
304cdf0e10cSrcweir 				{
30570d3707aSArmin 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 
32670d3707aSArmin Le Grand 					aBitmap.ReleaseAccess(pReadAccess);
32770d3707aSArmin Le Grand 
32870d3707aSArmin Le Grand                     if(aBitmapEx.IsTransparent())
32970d3707aSArmin Le Grand                     {
33070d3707aSArmin Le Grand                         if(aBitmapEx.IsAlpha())
33170d3707aSArmin Le Grand                         {
33270d3707aSArmin Le Grand                             aGraphicObject.SetGraphic(Graphic(BitmapEx(aDestBitmap, aBitmapEx.GetAlpha())));
33370d3707aSArmin Le Grand                         }
33470d3707aSArmin Le Grand                         else
33570d3707aSArmin Le Grand                         {
33670d3707aSArmin Le Grand                             aGraphicObject.SetGraphic(Graphic(BitmapEx(aDestBitmap, aBitmapEx.GetMask())));
33770d3707aSArmin Le Grand                         }
33870d3707aSArmin Le Grand                     }
33970d3707aSArmin Le Grand                     else
34070d3707aSArmin Le Grand                     {
34170d3707aSArmin Le Grand                         aGraphicObject.SetGraphic(Graphic(aDestBitmap));
34270d3707aSArmin Le Grand                     }
343cdf0e10cSrcweir 				}
344cdf0e10cSrcweir 			}
345cdf0e10cSrcweir 
34670d3707aSArmin 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 {
64817e8bc19SArmin Le Grand 	bClosedObj = true; // custom shapes may be filled
649cdf0e10cSrcweir 	bTextFrame = sal_True;
650cdf0e10cSrcweir }
651cdf0e10cSrcweir 
652cdf0e10cSrcweir SdrObjCustomShape::~SdrObjCustomShape()
653cdf0e10cSrcweir {
654cdf0e10cSrcweir 	// delete buffered display geometry
655cdf0e10cSrcweir 	InvalidateRenderGeometry();
656cdf0e10cSrcweir }
657cdf0e10cSrcweir 
658cdf0e10cSrcweir void SdrObjCustomShape::MergeDefaultAttributes( const rtl::OUString* pType )
659cdf0e10cSrcweir {
660cdf0e10cSrcweir 	PropertyValue aPropVal;
661cdf0e10cSrcweir 	rtl::OUString sShapeType;
662cdf0e10cSrcweir 	const rtl::OUString	sType( RTL_CONSTASCII_USTRINGPARAM ( "Type" ) );
663cdf0e10cSrcweir 	SdrCustomShapeGeometryItem aGeometryItem( (SdrCustomShapeGeometryItem&)GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) );
664cdf0e10cSrcweir 	if ( pType && pType->getLength() )
665cdf0e10cSrcweir 	{
666cdf0e10cSrcweir 		sal_Int32 nType = pType->toInt32();
667cdf0e10cSrcweir 		if ( nType )
668cdf0e10cSrcweir 			sShapeType = EnhancedCustomShapeTypeNames::Get( static_cast< MSO_SPT >( nType ) );
669cdf0e10cSrcweir 		else
670cdf0e10cSrcweir 			sShapeType = *pType;
671cdf0e10cSrcweir 
672cdf0e10cSrcweir 		aPropVal.Name = sType;
673cdf0e10cSrcweir 		aPropVal.Value <<= sShapeType;
674cdf0e10cSrcweir 		aGeometryItem.SetPropertyValue( aPropVal );
675cdf0e10cSrcweir 	}
676cdf0e10cSrcweir 	else
677cdf0e10cSrcweir 	{
678cdf0e10cSrcweir 		Any *pAny = aGeometryItem.GetPropertyValueByName( sType );
679cdf0e10cSrcweir 		if ( pAny )
680cdf0e10cSrcweir 			*pAny >>= sShapeType;
681cdf0e10cSrcweir 	}
682cdf0e10cSrcweir 	MSO_SPT eSpType = EnhancedCustomShapeTypeNames::Get( sShapeType );
683cdf0e10cSrcweir 
684cdf0e10cSrcweir 	const sal_Int32* pDefData = NULL;
685cdf0e10cSrcweir 	const mso_CustomShape* pDefCustomShape = GetCustomShapeContent( eSpType );
686cdf0e10cSrcweir 	if ( pDefCustomShape )
687cdf0e10cSrcweir 		pDefData = pDefCustomShape->pDefData;
688cdf0e10cSrcweir 
689cdf0e10cSrcweir 	com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeAdjustmentValue > seqAdjustmentValues;
690cdf0e10cSrcweir 
691cdf0e10cSrcweir 	//////////////////////
692cdf0e10cSrcweir 	// AdjustmentValues //
693cdf0e10cSrcweir 	//////////////////////
694cdf0e10cSrcweir 	const rtl::OUString	sAdjustmentValues( RTL_CONSTASCII_USTRINGPARAM ( "AdjustmentValues" ) );
695cdf0e10cSrcweir 	const Any* pAny = ((SdrCustomShapeGeometryItem&)aGeometryItem).GetPropertyValueByName( sAdjustmentValues );
696cdf0e10cSrcweir 	if ( pAny )
697cdf0e10cSrcweir 		*pAny >>= seqAdjustmentValues;
698cdf0e10cSrcweir 	if ( pDefCustomShape && pDefData )	// now check if we have to default some adjustment values
699cdf0e10cSrcweir 	{
700cdf0e10cSrcweir 		// first check if there are adjustment values are to be appended
701cdf0e10cSrcweir 		sal_Int32 i, nAdjustmentValues = seqAdjustmentValues.getLength();
702cdf0e10cSrcweir 		sal_Int32 nAdjustmentDefaults = *pDefData++;
703cdf0e10cSrcweir 		if ( nAdjustmentDefaults > nAdjustmentValues )
704cdf0e10cSrcweir 		{
705cdf0e10cSrcweir 			seqAdjustmentValues.realloc( nAdjustmentDefaults );
706cdf0e10cSrcweir 			for ( i = nAdjustmentValues; i < nAdjustmentDefaults; i++ )
707cdf0e10cSrcweir 			{
708cdf0e10cSrcweir 				seqAdjustmentValues[ i ].Value <<= pDefData[ i ];
709cdf0e10cSrcweir 				seqAdjustmentValues[ i ].State = com::sun::star::beans::PropertyState_DIRECT_VALUE;	// com::sun::star::beans::PropertyState_DEFAULT_VALUE;
710cdf0e10cSrcweir 			}
711cdf0e10cSrcweir 		}
712cdf0e10cSrcweir 		// check if there are defaulted adjustment values that should be filled the hard coded defaults (pDefValue)
713cdf0e10cSrcweir 		sal_Int32 nCount = nAdjustmentValues > nAdjustmentDefaults ? nAdjustmentDefaults : nAdjustmentValues;
714cdf0e10cSrcweir 		for ( i = 0; i < nCount; i++ )
715cdf0e10cSrcweir 		{
716cdf0e10cSrcweir 			if ( seqAdjustmentValues[ i ].State != com::sun::star::beans::PropertyState_DIRECT_VALUE )
717cdf0e10cSrcweir 			{
718cdf0e10cSrcweir 				seqAdjustmentValues[ i ].Value <<= pDefData[ i ];
719cdf0e10cSrcweir 				seqAdjustmentValues[ i ].State = com::sun::star::beans::PropertyState_DIRECT_VALUE;
720cdf0e10cSrcweir 			}
721cdf0e10cSrcweir 		}
722cdf0e10cSrcweir 	}
723cdf0e10cSrcweir 	aPropVal.Name = sAdjustmentValues;
724cdf0e10cSrcweir 	aPropVal.Value <<= seqAdjustmentValues;
725cdf0e10cSrcweir 	aGeometryItem.SetPropertyValue( aPropVal );
726cdf0e10cSrcweir 
727cdf0e10cSrcweir 	///////////////
728cdf0e10cSrcweir 	// Coordsize //
729cdf0e10cSrcweir 	///////////////
730cdf0e10cSrcweir 	const rtl::OUString	sViewBox( RTL_CONSTASCII_USTRINGPARAM ( "ViewBox" ) );
731cdf0e10cSrcweir 	const Any* pViewBox = ((SdrCustomShapeGeometryItem&)aGeometryItem).GetPropertyValueByName( sViewBox );
732cdf0e10cSrcweir 	com::sun::star::awt::Rectangle aViewBox;
733cdf0e10cSrcweir 	if ( !pViewBox || !(*pViewBox >>= aViewBox ) )
734cdf0e10cSrcweir 	{
735cdf0e10cSrcweir 		if ( pDefCustomShape )
736cdf0e10cSrcweir 		{
737cdf0e10cSrcweir 			aViewBox.X = 0;
738cdf0e10cSrcweir 			aViewBox.Y = 0;
739cdf0e10cSrcweir 			aViewBox.Width = pDefCustomShape->nCoordWidth;
740cdf0e10cSrcweir 			aViewBox.Height= pDefCustomShape->nCoordHeight;
741cdf0e10cSrcweir 			aPropVal.Name = sViewBox;
742cdf0e10cSrcweir 			aPropVal.Value <<= aViewBox;
743cdf0e10cSrcweir 			aGeometryItem.SetPropertyValue( aPropVal );
744cdf0e10cSrcweir 		}
745cdf0e10cSrcweir 	}
746cdf0e10cSrcweir 
747cdf0e10cSrcweir 	const rtl::OUString	sPath( RTL_CONSTASCII_USTRINGPARAM ( "Path" ) );
748cdf0e10cSrcweir 
749cdf0e10cSrcweir 	//////////////////////
750cdf0e10cSrcweir 	// Path/Coordinates //
751cdf0e10cSrcweir 	//////////////////////
752cdf0e10cSrcweir 	const rtl::OUString	sCoordinates( RTL_CONSTASCII_USTRINGPARAM ( "Coordinates" ) );
753cdf0e10cSrcweir 	pAny = ((SdrCustomShapeGeometryItem&)aGeometryItem).GetPropertyValueByName( sPath, sCoordinates );
754cdf0e10cSrcweir 	if ( !pAny && pDefCustomShape && pDefCustomShape->nVertices && pDefCustomShape->pVertices )
755cdf0e10cSrcweir 	{
756cdf0e10cSrcweir 		com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeParameterPair> seqCoordinates;
757cdf0e10cSrcweir 
758cdf0e10cSrcweir 		sal_Int32 i, nCount = pDefCustomShape->nVertices;
759cdf0e10cSrcweir 		seqCoordinates.realloc( nCount );
760cdf0e10cSrcweir 		for ( i = 0; i < nCount; i++ )
761cdf0e10cSrcweir 		{
762cdf0e10cSrcweir 			EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( seqCoordinates[ i ].First, pDefCustomShape->pVertices[ i ].nValA );
763cdf0e10cSrcweir 			EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( seqCoordinates[ i ].Second, pDefCustomShape->pVertices[ i ].nValB );
764cdf0e10cSrcweir 		}
765cdf0e10cSrcweir 		aPropVal.Name = sCoordinates;
766cdf0e10cSrcweir 		aPropVal.Value <<= seqCoordinates;
767cdf0e10cSrcweir 		aGeometryItem.SetPropertyValue( sPath, aPropVal );
768cdf0e10cSrcweir 	}
769cdf0e10cSrcweir 
770cdf0e10cSrcweir 	/////////////////////
771cdf0e10cSrcweir 	// Path/GluePoints //
772cdf0e10cSrcweir 	/////////////////////
773cdf0e10cSrcweir 	const rtl::OUString	sGluePoints( RTL_CONSTASCII_USTRINGPARAM ( "GluePoints" ) );
774cdf0e10cSrcweir 	pAny = ((SdrCustomShapeGeometryItem&)aGeometryItem).GetPropertyValueByName( sPath, sGluePoints );
775cdf0e10cSrcweir 	if ( !pAny && pDefCustomShape && pDefCustomShape->nGluePoints && pDefCustomShape->pGluePoints )
776cdf0e10cSrcweir 	{
777cdf0e10cSrcweir 		com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeParameterPair> seqGluePoints;
778cdf0e10cSrcweir 		sal_Int32 i, nCount = pDefCustomShape->nGluePoints;
779cdf0e10cSrcweir 		seqGluePoints.realloc( nCount );
780cdf0e10cSrcweir 		for ( i = 0; i < nCount; i++ )
781cdf0e10cSrcweir 		{
782cdf0e10cSrcweir 			EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( seqGluePoints[ i ].First, pDefCustomShape->pGluePoints[ i ].nValA );
783cdf0e10cSrcweir 			EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( seqGluePoints[ i ].Second, pDefCustomShape->pGluePoints[ i ].nValB );
784cdf0e10cSrcweir 		}
785cdf0e10cSrcweir 		aPropVal.Name = sGluePoints;
786cdf0e10cSrcweir 		aPropVal.Value <<= seqGluePoints;
787cdf0e10cSrcweir 		aGeometryItem.SetPropertyValue( sPath, aPropVal );
788cdf0e10cSrcweir 	}
789cdf0e10cSrcweir 
790cdf0e10cSrcweir 	///////////////////
791cdf0e10cSrcweir 	// Path/Segments //
792cdf0e10cSrcweir 	///////////////////
793cdf0e10cSrcweir 	const rtl::OUString	sSegments( RTL_CONSTASCII_USTRINGPARAM ( "Segments" ) );
794cdf0e10cSrcweir 	pAny = ((SdrCustomShapeGeometryItem&)aGeometryItem).GetPropertyValueByName( sPath, sSegments );
795cdf0e10cSrcweir 	if ( !pAny && pDefCustomShape && pDefCustomShape->nElements && pDefCustomShape->pElements )
796cdf0e10cSrcweir 	{
797cdf0e10cSrcweir 		com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeSegment > seqSegments;
798cdf0e10cSrcweir 
799cdf0e10cSrcweir 		sal_Int32 i, nCount = pDefCustomShape->nElements;
800cdf0e10cSrcweir 		seqSegments.realloc( nCount );
801cdf0e10cSrcweir 		for ( i = 0; i < nCount; i++ )
802cdf0e10cSrcweir 		{
803cdf0e10cSrcweir 			EnhancedCustomShapeSegment& rSegInfo = seqSegments[ i ];
804cdf0e10cSrcweir 			sal_uInt16 nSDat = pDefCustomShape->pElements[ i ];
805cdf0e10cSrcweir 			switch( nSDat >> 8 )
806cdf0e10cSrcweir 			{
807cdf0e10cSrcweir 				case 0x00 :
808cdf0e10cSrcweir 				{
809cdf0e10cSrcweir 					rSegInfo.Command = EnhancedCustomShapeSegmentCommand::LINETO;
810cdf0e10cSrcweir 					rSegInfo.Count   = nSDat & 0xff;
811cdf0e10cSrcweir 					if ( !rSegInfo.Count )
812cdf0e10cSrcweir 						rSegInfo.Count = 1;
813cdf0e10cSrcweir 				}
814cdf0e10cSrcweir 				break;
815cdf0e10cSrcweir 				case 0x20 :
816cdf0e10cSrcweir 				{
817cdf0e10cSrcweir 					rSegInfo.Command = EnhancedCustomShapeSegmentCommand::CURVETO;
818cdf0e10cSrcweir 					rSegInfo.Count   = nSDat & 0xff;
819cdf0e10cSrcweir 					if ( !rSegInfo.Count )
820cdf0e10cSrcweir 						rSegInfo.Count = 1;
821cdf0e10cSrcweir 				}
822cdf0e10cSrcweir 				break;
823cdf0e10cSrcweir 				case 0x40 :
824cdf0e10cSrcweir 				{
825cdf0e10cSrcweir 					rSegInfo.Command = EnhancedCustomShapeSegmentCommand::MOVETO;
826cdf0e10cSrcweir 					rSegInfo.Count   = nSDat & 0xff;
827cdf0e10cSrcweir 					if ( !rSegInfo.Count )
828cdf0e10cSrcweir 						rSegInfo.Count = 1;
829cdf0e10cSrcweir 				}
830cdf0e10cSrcweir 				break;
831cdf0e10cSrcweir 				case 0x60 :
832cdf0e10cSrcweir 				{
833cdf0e10cSrcweir 					rSegInfo.Command = EnhancedCustomShapeSegmentCommand::CLOSESUBPATH;
834cdf0e10cSrcweir 					rSegInfo.Count   = 0;
835cdf0e10cSrcweir 				}
836cdf0e10cSrcweir 				break;
837cdf0e10cSrcweir 				case 0x80 :
838cdf0e10cSrcweir 				{
839cdf0e10cSrcweir 					rSegInfo.Command = EnhancedCustomShapeSegmentCommand::ENDSUBPATH;
840cdf0e10cSrcweir 					rSegInfo.Count   = 0;
841cdf0e10cSrcweir 				}
842cdf0e10cSrcweir 				break;
843cdf0e10cSrcweir 				case 0xa1 :
844cdf0e10cSrcweir 				{
845cdf0e10cSrcweir 					rSegInfo.Command = EnhancedCustomShapeSegmentCommand::ANGLEELLIPSETO;
846cdf0e10cSrcweir 					rSegInfo.Count   = ( nSDat & 0xff ) / 3;
847cdf0e10cSrcweir 				}
848cdf0e10cSrcweir 				break;
849cdf0e10cSrcweir 				case 0xa2 :
850cdf0e10cSrcweir 				{
851cdf0e10cSrcweir 					rSegInfo.Command = EnhancedCustomShapeSegmentCommand::ANGLEELLIPSE;
852cdf0e10cSrcweir 					rSegInfo.Count   = ( nSDat & 0xff ) / 3;
853cdf0e10cSrcweir 				}
854cdf0e10cSrcweir 				break;
855cdf0e10cSrcweir 				case 0xa3 :
856cdf0e10cSrcweir 				{
857cdf0e10cSrcweir 					rSegInfo.Command = EnhancedCustomShapeSegmentCommand::ARCTO;
858cdf0e10cSrcweir 					rSegInfo.Count   = ( nSDat & 0xff ) >> 2;
859cdf0e10cSrcweir 				}
860cdf0e10cSrcweir 				break;
861cdf0e10cSrcweir 				case 0xa4 :
862cdf0e10cSrcweir 				{
863cdf0e10cSrcweir 					rSegInfo.Command = EnhancedCustomShapeSegmentCommand::ARC;
864cdf0e10cSrcweir 					rSegInfo.Count   = ( nSDat & 0xff ) >> 2;
865cdf0e10cSrcweir 				}
866cdf0e10cSrcweir 				break;
867cdf0e10cSrcweir 				case 0xa5 :
868cdf0e10cSrcweir 				{
869cdf0e10cSrcweir 					rSegInfo.Command = EnhancedCustomShapeSegmentCommand::CLOCKWISEARCTO;
870cdf0e10cSrcweir 					rSegInfo.Count   = ( nSDat & 0xff ) >> 2;
871cdf0e10cSrcweir 				}
872cdf0e10cSrcweir 				break;
873cdf0e10cSrcweir 				case 0xa6 :
874cdf0e10cSrcweir 				{
875cdf0e10cSrcweir 					rSegInfo.Command = EnhancedCustomShapeSegmentCommand::CLOCKWISEARC;
876cdf0e10cSrcweir 					rSegInfo.Count   = ( nSDat & 0xff ) >> 2;
877cdf0e10cSrcweir 				}
878cdf0e10cSrcweir 				break;
879cdf0e10cSrcweir 				case 0xa7 :
880cdf0e10cSrcweir 				{
881cdf0e10cSrcweir 					rSegInfo.Command = EnhancedCustomShapeSegmentCommand::ELLIPTICALQUADRANTX;
882cdf0e10cSrcweir 					rSegInfo.Count   = nSDat & 0xff;
883cdf0e10cSrcweir 				}
884cdf0e10cSrcweir 				break;
885cdf0e10cSrcweir 				case 0xa8 :
886cdf0e10cSrcweir 				{
887cdf0e10cSrcweir 					rSegInfo.Command = EnhancedCustomShapeSegmentCommand::ELLIPTICALQUADRANTY;
888cdf0e10cSrcweir 					rSegInfo.Count   = nSDat & 0xff;
889cdf0e10cSrcweir 				}
890cdf0e10cSrcweir 				break;
891cdf0e10cSrcweir 				case 0xaa :
892cdf0e10cSrcweir 				{
893cdf0e10cSrcweir 					rSegInfo.Command = EnhancedCustomShapeSegmentCommand::NOFILL;
894cdf0e10cSrcweir 					rSegInfo.Count   = 0;
895cdf0e10cSrcweir 				}
896cdf0e10cSrcweir 				break;
897cdf0e10cSrcweir 				case 0xab :
898cdf0e10cSrcweir 				{
899cdf0e10cSrcweir 					rSegInfo.Command = EnhancedCustomShapeSegmentCommand::NOSTROKE;
900cdf0e10cSrcweir 					rSegInfo.Count   = 0;
901cdf0e10cSrcweir 				}
902cdf0e10cSrcweir 				break;
903cdf0e10cSrcweir 				default:
904cdf0e10cSrcweir 				case 0xf8 :
905cdf0e10cSrcweir 				{
906cdf0e10cSrcweir 					rSegInfo.Command = EnhancedCustomShapeSegmentCommand::UNKNOWN;
907cdf0e10cSrcweir 					rSegInfo.Count   = nSDat;
908cdf0e10cSrcweir 				}
909cdf0e10cSrcweir 				break;
910cdf0e10cSrcweir 			}
911cdf0e10cSrcweir 		}
912cdf0e10cSrcweir 		aPropVal.Name = sSegments;
913cdf0e10cSrcweir 		aPropVal.Value <<= seqSegments;
914cdf0e10cSrcweir 		aGeometryItem.SetPropertyValue( sPath, aPropVal );
915cdf0e10cSrcweir 	}
916cdf0e10cSrcweir 
917cdf0e10cSrcweir 	///////////////////
918cdf0e10cSrcweir 	// Path/StretchX //
919cdf0e10cSrcweir 	///////////////////
920cdf0e10cSrcweir 	const rtl::OUString	sStretchX( RTL_CONSTASCII_USTRINGPARAM ( "StretchX" ) );
921cdf0e10cSrcweir 	pAny = ((SdrCustomShapeGeometryItem&)aGeometryItem).GetPropertyValueByName( sPath, sStretchX );
922cdf0e10cSrcweir 	if ( !pAny && pDefCustomShape )
923cdf0e10cSrcweir 	{
924cdf0e10cSrcweir 		sal_Int32 nXRef = pDefCustomShape->nXRef;
925cdf0e10cSrcweir 		if ( ( nXRef != DEFAULT_MINIMUM_SIGNED_COMPARE ) )
926cdf0e10cSrcweir 		{
927cdf0e10cSrcweir 			aPropVal.Name = sStretchX;
928cdf0e10cSrcweir 			aPropVal.Value <<= nXRef;
929cdf0e10cSrcweir 			aGeometryItem.SetPropertyValue( sPath, aPropVal );
930cdf0e10cSrcweir 		}
931cdf0e10cSrcweir 	}
932cdf0e10cSrcweir 
933cdf0e10cSrcweir 	///////////////////
934cdf0e10cSrcweir 	// Path/StretchY //
935cdf0e10cSrcweir 	///////////////////
936cdf0e10cSrcweir 	const rtl::OUString	sStretchY( RTL_CONSTASCII_USTRINGPARAM ( "StretchY" ) );
937cdf0e10cSrcweir 	pAny = ((SdrCustomShapeGeometryItem&)aGeometryItem).GetPropertyValueByName( sPath, sStretchY );
938cdf0e10cSrcweir 	if ( !pAny && pDefCustomShape )
939cdf0e10cSrcweir 	{
940cdf0e10cSrcweir 		sal_Int32 nYRef = pDefCustomShape->nYRef;
941cdf0e10cSrcweir 		if ( ( nYRef != DEFAULT_MINIMUM_SIGNED_COMPARE ) )
942cdf0e10cSrcweir 		{
943cdf0e10cSrcweir 			aPropVal.Name = sStretchY;
944cdf0e10cSrcweir 			aPropVal.Value <<= nYRef;
945cdf0e10cSrcweir 			aGeometryItem.SetPropertyValue( sPath, aPropVal );
946cdf0e10cSrcweir 		}
947cdf0e10cSrcweir 	}
948cdf0e10cSrcweir 
949cdf0e10cSrcweir 	/////////////////////
950cdf0e10cSrcweir 	// Path/TextFrames //
951cdf0e10cSrcweir 	/////////////////////
952cdf0e10cSrcweir 	const rtl::OUString	sTextFrames( RTL_CONSTASCII_USTRINGPARAM ( "TextFrames" ) );
953cdf0e10cSrcweir 	pAny = ((SdrCustomShapeGeometryItem&)aGeometryItem).GetPropertyValueByName( sPath, sTextFrames );
954cdf0e10cSrcweir 	if ( !pAny && pDefCustomShape && pDefCustomShape->nTextRect && pDefCustomShape->pTextRect )
955cdf0e10cSrcweir 	{
956cdf0e10cSrcweir 		com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeTextFrame > seqTextFrames;
957cdf0e10cSrcweir 
958cdf0e10cSrcweir 		sal_Int32 i, nCount = pDefCustomShape->nTextRect;
959cdf0e10cSrcweir 		seqTextFrames.realloc( nCount );
960cdf0e10cSrcweir 		const SvxMSDffTextRectangles* pRectangles = pDefCustomShape->pTextRect;
961cdf0e10cSrcweir 		for ( i = 0; i < nCount; i++, pRectangles++ )
962cdf0e10cSrcweir 		{
963cdf0e10cSrcweir 			EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( seqTextFrames[ i ].TopLeft.First,	  pRectangles->nPairA.nValA );
964cdf0e10cSrcweir 			EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( seqTextFrames[ i ].TopLeft.Second,	  pRectangles->nPairA.nValB );
965cdf0e10cSrcweir 			EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( seqTextFrames[ i ].BottomRight.First,  pRectangles->nPairB.nValA );
966cdf0e10cSrcweir 			EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( seqTextFrames[ i ].BottomRight.Second, pRectangles->nPairB.nValB );
967cdf0e10cSrcweir 		}
968cdf0e10cSrcweir 		aPropVal.Name = sTextFrames;
969cdf0e10cSrcweir 		aPropVal.Value <<= seqTextFrames;
970cdf0e10cSrcweir 		aGeometryItem.SetPropertyValue( sPath, aPropVal );
971cdf0e10cSrcweir 	}
972cdf0e10cSrcweir 
973cdf0e10cSrcweir 	///////////////
974cdf0e10cSrcweir 	// Equations //
975cdf0e10cSrcweir 	///////////////
976cdf0e10cSrcweir 	const rtl::OUString	sEquations( RTL_CONSTASCII_USTRINGPARAM( "Equations" ) );
977cdf0e10cSrcweir 	pAny = ((SdrCustomShapeGeometryItem&)aGeometryItem).GetPropertyValueByName( sEquations );
978cdf0e10cSrcweir 	if ( !pAny && pDefCustomShape && pDefCustomShape->nCalculation && pDefCustomShape->pCalculation )
979cdf0e10cSrcweir 	{
980cdf0e10cSrcweir 		com::sun::star::uno::Sequence< rtl::OUString > seqEquations;
981cdf0e10cSrcweir 
982cdf0e10cSrcweir 		sal_Int32 i, nCount = pDefCustomShape->nCalculation;
983cdf0e10cSrcweir 		seqEquations.realloc( nCount );
984cdf0e10cSrcweir 		const SvxMSDffCalculationData* pData = pDefCustomShape->pCalculation;
985cdf0e10cSrcweir 		for ( i = 0; i < nCount; i++, pData++ )
986cdf0e10cSrcweir 			seqEquations[ i ] = EnhancedCustomShape2d::GetEquation( pData->nFlags, pData->nVal[ 0 ], pData->nVal[ 1 ], pData->nVal[ 2 ] );
987cdf0e10cSrcweir 		aPropVal.Name = sEquations;
988cdf0e10cSrcweir 		aPropVal.Value <<= seqEquations;
989cdf0e10cSrcweir 		aGeometryItem.SetPropertyValue( aPropVal );
990cdf0e10cSrcweir 	}
991cdf0e10cSrcweir 
992cdf0e10cSrcweir 	/////////////
993cdf0e10cSrcweir 	// Handles //
994cdf0e10cSrcweir 	/////////////
995cdf0e10cSrcweir 	const rtl::OUString	sHandles( RTL_CONSTASCII_USTRINGPARAM( "Handles" ) );
996cdf0e10cSrcweir 	pAny = ((SdrCustomShapeGeometryItem&)aGeometryItem).GetPropertyValueByName( sHandles );
997cdf0e10cSrcweir 	if ( !pAny && pDefCustomShape && pDefCustomShape->nHandles && pDefCustomShape->pHandles )
998cdf0e10cSrcweir 	{
999cdf0e10cSrcweir 		com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValues > seqHandles;
1000cdf0e10cSrcweir 
1001cdf0e10cSrcweir 		sal_Int32 i, n, nCount = pDefCustomShape->nHandles;
1002cdf0e10cSrcweir 		const SvxMSDffHandle* pData = pDefCustomShape->pHandles;
1003cdf0e10cSrcweir 		seqHandles.realloc( nCount );
1004cdf0e10cSrcweir 		for ( i = 0; i < nCount; i++, pData++ )
1005cdf0e10cSrcweir 		{
1006cdf0e10cSrcweir 			sal_Int32 nPropertiesNeeded = 1;	// position is always needed
1007cdf0e10cSrcweir 			sal_Int32 nFlags = pData->nFlags;
1008cdf0e10cSrcweir 			if ( nFlags & MSDFF_HANDLE_FLAGS_MIRRORED_X )
1009cdf0e10cSrcweir 				nPropertiesNeeded++;
1010cdf0e10cSrcweir 			if ( nFlags & MSDFF_HANDLE_FLAGS_MIRRORED_Y )
1011cdf0e10cSrcweir 				nPropertiesNeeded++;
1012cdf0e10cSrcweir 			if ( nFlags & MSDFF_HANDLE_FLAGS_SWITCHED )
1013cdf0e10cSrcweir 				nPropertiesNeeded++;
1014cdf0e10cSrcweir 			if ( nFlags & MSDFF_HANDLE_FLAGS_POLAR )
1015cdf0e10cSrcweir 			{
1016cdf0e10cSrcweir 				nPropertiesNeeded++;
1017cdf0e10cSrcweir 				if ( nFlags & MSDFF_HANDLE_FLAGS_RADIUS_RANGE )
1018cdf0e10cSrcweir 				{
1019cdf0e10cSrcweir 					if ( pData->nRangeXMin != DEFAULT_MINIMUM_SIGNED_COMPARE )
1020cdf0e10cSrcweir 						nPropertiesNeeded++;
1021cdf0e10cSrcweir 					if ( pData->nRangeXMax != DEFAULT_MAXIMUM_SIGNED_COMPARE )
1022cdf0e10cSrcweir 						nPropertiesNeeded++;
1023cdf0e10cSrcweir 				}
1024cdf0e10cSrcweir 			}
1025cdf0e10cSrcweir 			else if ( nFlags & MSDFF_HANDLE_FLAGS_RANGE )
1026cdf0e10cSrcweir 			{
1027cdf0e10cSrcweir 				if ( pData->nRangeXMin != DEFAULT_MINIMUM_SIGNED_COMPARE )
1028cdf0e10cSrcweir 					nPropertiesNeeded++;
1029cdf0e10cSrcweir 				if ( pData->nRangeXMax != DEFAULT_MAXIMUM_SIGNED_COMPARE )
1030cdf0e10cSrcweir 					nPropertiesNeeded++;
1031cdf0e10cSrcweir 				if ( pData->nRangeYMin != DEFAULT_MINIMUM_SIGNED_COMPARE )
1032cdf0e10cSrcweir 					nPropertiesNeeded++;
1033cdf0e10cSrcweir 				if ( pData->nRangeYMax != DEFAULT_MAXIMUM_SIGNED_COMPARE )
1034cdf0e10cSrcweir 					nPropertiesNeeded++;
1035cdf0e10cSrcweir 			}
1036cdf0e10cSrcweir 
1037cdf0e10cSrcweir 			n = 0;
1038cdf0e10cSrcweir 			com::sun::star::beans::PropertyValues& rPropValues = seqHandles[ i ];
1039cdf0e10cSrcweir 			rPropValues.realloc( nPropertiesNeeded );
1040cdf0e10cSrcweir 
1041cdf0e10cSrcweir 			// POSITION
1042cdf0e10cSrcweir 			{
1043cdf0e10cSrcweir 				const rtl::OUString	sPosition( RTL_CONSTASCII_USTRINGPARAM ( "Position" ) );
1044cdf0e10cSrcweir 				::com::sun::star::drawing::EnhancedCustomShapeParameterPair aPosition;
1045cdf0e10cSrcweir 				EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aPosition.First, pData->nPositionX, sal_True, sal_True );
1046cdf0e10cSrcweir 				EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aPosition.Second, pData->nPositionY, sal_True, sal_False );
1047cdf0e10cSrcweir 				rPropValues[ n ].Name = sPosition;
1048cdf0e10cSrcweir 				rPropValues[ n++ ].Value <<= aPosition;
1049cdf0e10cSrcweir 			}
1050cdf0e10cSrcweir 			if ( nFlags & MSDFF_HANDLE_FLAGS_MIRRORED_X )
1051cdf0e10cSrcweir 			{
1052cdf0e10cSrcweir 				const rtl::OUString	sMirroredX( RTL_CONSTASCII_USTRINGPARAM ( "MirroredX" ) );
1053cdf0e10cSrcweir 				sal_Bool bMirroredX = sal_True;
1054cdf0e10cSrcweir 				rPropValues[ n ].Name = sMirroredX;
1055cdf0e10cSrcweir 				rPropValues[ n++ ].Value <<= bMirroredX;
1056cdf0e10cSrcweir 			}
1057cdf0e10cSrcweir 			if ( nFlags & MSDFF_HANDLE_FLAGS_MIRRORED_Y )
1058cdf0e10cSrcweir 			{
1059cdf0e10cSrcweir 				const rtl::OUString	sMirroredY( RTL_CONSTASCII_USTRINGPARAM ( "MirroredY" ) );
1060cdf0e10cSrcweir 				sal_Bool bMirroredY = sal_True;
1061cdf0e10cSrcweir 				rPropValues[ n ].Name = sMirroredY;
1062cdf0e10cSrcweir 				rPropValues[ n++ ].Value <<= bMirroredY;
1063cdf0e10cSrcweir 			}
1064cdf0e10cSrcweir 			if ( nFlags & MSDFF_HANDLE_FLAGS_SWITCHED )
1065cdf0e10cSrcweir 			{
1066cdf0e10cSrcweir 				const rtl::OUString	sSwitched( RTL_CONSTASCII_USTRINGPARAM ( "Switched" ) );
1067cdf0e10cSrcweir 				sal_Bool bSwitched = sal_True;
1068cdf0e10cSrcweir 				rPropValues[ n ].Name = sSwitched;
1069cdf0e10cSrcweir 				rPropValues[ n++ ].Value <<= bSwitched;
1070cdf0e10cSrcweir 			}
1071cdf0e10cSrcweir 			if ( nFlags & MSDFF_HANDLE_FLAGS_POLAR )
1072cdf0e10cSrcweir 			{
1073cdf0e10cSrcweir 				const rtl::OUString	sPolar( RTL_CONSTASCII_USTRINGPARAM ( "Polar" ) );
1074cdf0e10cSrcweir 				::com::sun::star::drawing::EnhancedCustomShapeParameterPair aCenter;
1075cdf0e10cSrcweir 				EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aCenter.First,  pData->nCenterX,
1076cdf0e10cSrcweir 					( nFlags & MSDFF_HANDLE_FLAGS_CENTER_X_IS_SPECIAL ) != 0, sal_True  );
1077cdf0e10cSrcweir 				EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aCenter.Second, pData->nCenterY,
1078cdf0e10cSrcweir 					( nFlags & MSDFF_HANDLE_FLAGS_CENTER_Y_IS_SPECIAL ) != 0, sal_False );
1079cdf0e10cSrcweir 				rPropValues[ n ].Name = sPolar;
1080cdf0e10cSrcweir 				rPropValues[ n++ ].Value <<= aCenter;
1081cdf0e10cSrcweir 				if ( nFlags & MSDFF_HANDLE_FLAGS_RADIUS_RANGE )
1082cdf0e10cSrcweir 				{
1083cdf0e10cSrcweir 					if ( pData->nRangeXMin != DEFAULT_MINIMUM_SIGNED_COMPARE )
1084cdf0e10cSrcweir 					{
1085cdf0e10cSrcweir 						const rtl::OUString	sRadiusRangeMinimum( RTL_CONSTASCII_USTRINGPARAM ( "RadiusRangeMinimum" ) );
1086cdf0e10cSrcweir 						::com::sun::star::drawing::EnhancedCustomShapeParameter aRadiusRangeMinimum;
1087cdf0e10cSrcweir 						EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aRadiusRangeMinimum, pData->nRangeXMin,
1088cdf0e10cSrcweir 							( nFlags & MSDFF_HANDLE_FLAGS_RANGE_X_MIN_IS_SPECIAL ) != 0, sal_True  );
1089cdf0e10cSrcweir 						rPropValues[ n ].Name = sRadiusRangeMinimum;
1090cdf0e10cSrcweir 						rPropValues[ n++ ].Value <<= aRadiusRangeMinimum;
1091cdf0e10cSrcweir 					}
1092cdf0e10cSrcweir 					if ( pData->nRangeXMax != DEFAULT_MAXIMUM_SIGNED_COMPARE )
1093cdf0e10cSrcweir 					{
1094cdf0e10cSrcweir 						const rtl::OUString	sRadiusRangeMaximum( RTL_CONSTASCII_USTRINGPARAM ( "RadiusRangeMaximum" ) );
1095cdf0e10cSrcweir 						::com::sun::star::drawing::EnhancedCustomShapeParameter aRadiusRangeMaximum;
1096cdf0e10cSrcweir 						EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aRadiusRangeMaximum, pData->nRangeXMax,
1097cdf0e10cSrcweir 							( nFlags & MSDFF_HANDLE_FLAGS_RANGE_X_MAX_IS_SPECIAL ) != 0, sal_False );
1098cdf0e10cSrcweir 						rPropValues[ n ].Name = sRadiusRangeMaximum;
1099cdf0e10cSrcweir 						rPropValues[ n++ ].Value <<= aRadiusRangeMaximum;
1100cdf0e10cSrcweir 					}
1101cdf0e10cSrcweir 				}
1102cdf0e10cSrcweir 			}
1103cdf0e10cSrcweir 			else if ( nFlags & MSDFF_HANDLE_FLAGS_RANGE )
1104cdf0e10cSrcweir 			{
1105cdf0e10cSrcweir 				if ( pData->nRangeXMin != DEFAULT_MINIMUM_SIGNED_COMPARE )
1106cdf0e10cSrcweir 				{
1107cdf0e10cSrcweir 					const rtl::OUString	sRangeXMinimum( RTL_CONSTASCII_USTRINGPARAM ( "RangeXMinimum" ) );
1108cdf0e10cSrcweir 					::com::sun::star::drawing::EnhancedCustomShapeParameter aRangeXMinimum;
1109cdf0e10cSrcweir 					EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aRangeXMinimum, pData->nRangeXMin,
1110cdf0e10cSrcweir 						( nFlags & MSDFF_HANDLE_FLAGS_RANGE_X_MIN_IS_SPECIAL ) != 0, sal_True  );
1111cdf0e10cSrcweir 					rPropValues[ n ].Name = sRangeXMinimum;
1112cdf0e10cSrcweir 					rPropValues[ n++ ].Value <<= aRangeXMinimum;
1113cdf0e10cSrcweir 				}
1114cdf0e10cSrcweir 				if ( pData->nRangeXMax != DEFAULT_MAXIMUM_SIGNED_COMPARE )
1115cdf0e10cSrcweir 				{
1116cdf0e10cSrcweir 					const rtl::OUString	sRangeXMaximum( RTL_CONSTASCII_USTRINGPARAM ( "RangeXMaximum" ) );
1117cdf0e10cSrcweir 					::com::sun::star::drawing::EnhancedCustomShapeParameter aRangeXMaximum;
1118cdf0e10cSrcweir 					EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aRangeXMaximum, pData->nRangeXMax,
1119cdf0e10cSrcweir 						( nFlags & MSDFF_HANDLE_FLAGS_RANGE_X_MAX_IS_SPECIAL ) != 0, sal_False );
1120cdf0e10cSrcweir 					rPropValues[ n ].Name = sRangeXMaximum;
1121cdf0e10cSrcweir 					rPropValues[ n++ ].Value <<= aRangeXMaximum;
1122cdf0e10cSrcweir 				}
1123cdf0e10cSrcweir 				if ( pData->nRangeYMin != DEFAULT_MINIMUM_SIGNED_COMPARE )
1124cdf0e10cSrcweir 				{
1125cdf0e10cSrcweir 					const rtl::OUString	sRangeYMinimum( RTL_CONSTASCII_USTRINGPARAM ( "RangeYMinimum" ) );
1126cdf0e10cSrcweir 					::com::sun::star::drawing::EnhancedCustomShapeParameter aRangeYMinimum;
1127cdf0e10cSrcweir 					EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aRangeYMinimum, pData->nRangeYMin,
1128cdf0e10cSrcweir 						( nFlags & MSDFF_HANDLE_FLAGS_RANGE_Y_MIN_IS_SPECIAL ) != 0, sal_True );
1129cdf0e10cSrcweir 					rPropValues[ n ].Name = sRangeYMinimum;
1130cdf0e10cSrcweir 					rPropValues[ n++ ].Value <<= aRangeYMinimum;
1131cdf0e10cSrcweir 				}
1132cdf0e10cSrcweir 				if ( pData->nRangeYMax != DEFAULT_MAXIMUM_SIGNED_COMPARE )
1133cdf0e10cSrcweir 				{
1134cdf0e10cSrcweir 					const rtl::OUString	sRangeYMaximum( RTL_CONSTASCII_USTRINGPARAM ( "RangeYMaximum" ) );
1135cdf0e10cSrcweir 					::com::sun::star::drawing::EnhancedCustomShapeParameter aRangeYMaximum;
1136cdf0e10cSrcweir 					EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aRangeYMaximum, pData->nRangeYMax,
1137cdf0e10cSrcweir 						( nFlags & MSDFF_HANDLE_FLAGS_RANGE_Y_MAX_IS_SPECIAL ) != 0, sal_False );
1138cdf0e10cSrcweir 					rPropValues[ n ].Name = sRangeYMaximum;
1139cdf0e10cSrcweir 					rPropValues[ n++ ].Value <<= aRangeYMaximum;
1140cdf0e10cSrcweir 				}
1141cdf0e10cSrcweir 			}
1142cdf0e10cSrcweir 		}
1143cdf0e10cSrcweir 		aPropVal.Name = sHandles;
1144cdf0e10cSrcweir 		aPropVal.Value <<= seqHandles;
1145cdf0e10cSrcweir 		aGeometryItem.SetPropertyValue( aPropVal );
1146cdf0e10cSrcweir 	}
1147cdf0e10cSrcweir 	SetMergedItem( aGeometryItem );
1148cdf0e10cSrcweir }
1149cdf0e10cSrcweir 
1150cdf0e10cSrcweir sal_Bool SdrObjCustomShape::IsDefaultGeometry( const DefaultType eDefaultType ) const
1151cdf0e10cSrcweir {
1152cdf0e10cSrcweir 	sal_Bool bIsDefaultGeometry = sal_False;
1153cdf0e10cSrcweir 
1154cdf0e10cSrcweir 	PropertyValue aPropVal;
1155cdf0e10cSrcweir 	rtl::OUString sShapeType;
1156cdf0e10cSrcweir 	const rtl::OUString	sType( RTL_CONSTASCII_USTRINGPARAM ( "Type" ) );
1157cdf0e10cSrcweir 	SdrCustomShapeGeometryItem aGeometryItem( (SdrCustomShapeGeometryItem&)GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) );
1158cdf0e10cSrcweir 
1159cdf0e10cSrcweir 	Any *pAny = aGeometryItem.GetPropertyValueByName( sType );
1160cdf0e10cSrcweir 	if ( pAny )
1161cdf0e10cSrcweir 		*pAny >>= sShapeType;
1162cdf0e10cSrcweir 
1163cdf0e10cSrcweir 	MSO_SPT eSpType = EnhancedCustomShapeTypeNames::Get( sShapeType );
1164cdf0e10cSrcweir 
1165cdf0e10cSrcweir 	const mso_CustomShape* pDefCustomShape = GetCustomShapeContent( eSpType );
1166cdf0e10cSrcweir 	const rtl::OUString	sPath( RTL_CONSTASCII_USTRINGPARAM ( "Path" ) );
1167cdf0e10cSrcweir 	switch( eDefaultType )
1168cdf0e10cSrcweir 	{
1169cdf0e10cSrcweir 		case DEFAULT_VIEWBOX :
1170cdf0e10cSrcweir 		{
1171cdf0e10cSrcweir 			const rtl::OUString	sViewBox( RTL_CONSTASCII_USTRINGPARAM ( "ViewBox" ) );
1172cdf0e10cSrcweir 			const Any* pViewBox = ((SdrCustomShapeGeometryItem&)aGeometryItem).GetPropertyValueByName( sViewBox );
1173cdf0e10cSrcweir 			com::sun::star::awt::Rectangle aViewBox;
1174cdf0e10cSrcweir 			if ( pViewBox && ( *pViewBox >>= aViewBox ) )
1175cdf0e10cSrcweir 			{
1176cdf0e10cSrcweir 				if ( ( aViewBox.Width == pDefCustomShape->nCoordWidth )
1177cdf0e10cSrcweir 					&& ( aViewBox.Height == pDefCustomShape->nCoordHeight ) )
1178cdf0e10cSrcweir 					bIsDefaultGeometry = sal_True;
1179cdf0e10cSrcweir 			}
1180cdf0e10cSrcweir 		}
1181cdf0e10cSrcweir 		break;
1182cdf0e10cSrcweir 
1183cdf0e10cSrcweir 		case DEFAULT_PATH :
1184cdf0e10cSrcweir 		{
1185cdf0e10cSrcweir 			const rtl::OUString	sCoordinates( RTL_CONSTASCII_USTRINGPARAM ( "Coordinates" ) );
1186cdf0e10cSrcweir 			pAny = ((SdrCustomShapeGeometryItem&)aGeometryItem).GetPropertyValueByName( sPath, sCoordinates );
1187cdf0e10cSrcweir 			if ( pAny && pDefCustomShape && pDefCustomShape->nVertices && pDefCustomShape->pVertices )
1188cdf0e10cSrcweir 			{
1189cdf0e10cSrcweir 				com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeParameterPair> seqCoordinates1, seqCoordinates2;
1190cdf0e10cSrcweir 				if ( *pAny >>= seqCoordinates1 )
1191cdf0e10cSrcweir 				{
1192cdf0e10cSrcweir 					sal_Int32 i, nCount = pDefCustomShape->nVertices;
1193cdf0e10cSrcweir 					seqCoordinates2.realloc( nCount );
1194cdf0e10cSrcweir 					for ( i = 0; i < nCount; i++ )
1195cdf0e10cSrcweir 					{
1196cdf0e10cSrcweir 						EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( seqCoordinates2[ i ].First, pDefCustomShape->pVertices[ i ].nValA );
1197cdf0e10cSrcweir 						EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( seqCoordinates2[ i ].Second, pDefCustomShape->pVertices[ i ].nValB );
1198cdf0e10cSrcweir 					}
1199cdf0e10cSrcweir 					if ( seqCoordinates1 == seqCoordinates2 )
1200cdf0e10cSrcweir 						bIsDefaultGeometry = sal_True;
1201cdf0e10cSrcweir 				}
1202cdf0e10cSrcweir 			}
1203cdf0e10cSrcweir 			else if ( pDefCustomShape && ( ( pDefCustomShape->nVertices == 0 ) || ( pDefCustomShape->pVertices == 0 ) ) )
1204cdf0e10cSrcweir 				bIsDefaultGeometry = sal_True;
1205cdf0e10cSrcweir 		}
1206cdf0e10cSrcweir 		break;
1207cdf0e10cSrcweir 
1208cdf0e10cSrcweir 		case DEFAULT_GLUEPOINTS :
1209cdf0e10cSrcweir 		{
1210cdf0e10cSrcweir 			const rtl::OUString	sGluePoints( RTL_CONSTASCII_USTRINGPARAM ( "GluePoints" ) );
1211cdf0e10cSrcweir 			pAny = ((SdrCustomShapeGeometryItem&)aGeometryItem).GetPropertyValueByName( sPath, sGluePoints );
1212cdf0e10cSrcweir 			if ( pAny && pDefCustomShape && pDefCustomShape->nGluePoints && pDefCustomShape->pGluePoints )
1213cdf0e10cSrcweir 			{
1214cdf0e10cSrcweir 				com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeParameterPair> seqGluePoints1, seqGluePoints2;
1215cdf0e10cSrcweir 				if ( *pAny >>= seqGluePoints1 )
1216cdf0e10cSrcweir 				{
1217cdf0e10cSrcweir 					sal_Int32 i, nCount = pDefCustomShape->nGluePoints;
1218cdf0e10cSrcweir 					seqGluePoints2.realloc( nCount );
1219cdf0e10cSrcweir 					for ( i = 0; i < nCount; i++ )
1220cdf0e10cSrcweir 					{
1221cdf0e10cSrcweir 						EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( seqGluePoints2[ i ].First, pDefCustomShape->pGluePoints[ i ].nValA );
1222cdf0e10cSrcweir 						EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( seqGluePoints2[ i ].Second, pDefCustomShape->pGluePoints[ i ].nValB );
1223cdf0e10cSrcweir 					}
1224cdf0e10cSrcweir 					if ( seqGluePoints1 == seqGluePoints2 )
1225cdf0e10cSrcweir 						bIsDefaultGeometry = sal_True;
1226cdf0e10cSrcweir 				}
1227cdf0e10cSrcweir 			}
1228cdf0e10cSrcweir 			else if ( pDefCustomShape && ( pDefCustomShape->nGluePoints == 0 ) )
1229cdf0e10cSrcweir 				bIsDefaultGeometry = sal_True;
1230cdf0e10cSrcweir 		}
1231cdf0e10cSrcweir 		break;
1232cdf0e10cSrcweir 
1233cdf0e10cSrcweir 		case DEFAULT_SEGMENTS :
1234cdf0e10cSrcweir 		{
1235cdf0e10cSrcweir 			///////////////////
1236cdf0e10cSrcweir 			// Path/Segments //
1237cdf0e10cSrcweir 			///////////////////
1238cdf0e10cSrcweir 			const rtl::OUString	sSegments( RTL_CONSTASCII_USTRINGPARAM ( "Segments" ) );
1239cdf0e10cSrcweir 			pAny = ((SdrCustomShapeGeometryItem&)aGeometryItem).GetPropertyValueByName( sPath, sSegments );
1240cdf0e10cSrcweir 			if ( pAny )
1241cdf0e10cSrcweir 			{
1242cdf0e10cSrcweir 				com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeSegment > seqSegments1, seqSegments2;
1243cdf0e10cSrcweir 				if ( *pAny >>= seqSegments1 )
1244cdf0e10cSrcweir 				{
1245cdf0e10cSrcweir 					if ( pDefCustomShape && pDefCustomShape->nElements && pDefCustomShape->pElements )
1246cdf0e10cSrcweir 					{
1247cdf0e10cSrcweir 						sal_Int32 i, nCount = pDefCustomShape->nElements;
1248cdf0e10cSrcweir 						if ( nCount )
1249cdf0e10cSrcweir 						{
1250cdf0e10cSrcweir 							seqSegments2.realloc( nCount );
1251cdf0e10cSrcweir 							for ( i = 0; i < nCount; i++ )
1252cdf0e10cSrcweir 							{
1253cdf0e10cSrcweir 								EnhancedCustomShapeSegment& rSegInfo = seqSegments2[ i ];
1254cdf0e10cSrcweir 								sal_uInt16 nSDat = pDefCustomShape->pElements[ i ];
1255cdf0e10cSrcweir 								switch( nSDat >> 8 )
1256cdf0e10cSrcweir 								{
1257cdf0e10cSrcweir 									case 0x00 :
1258cdf0e10cSrcweir 									{
1259cdf0e10cSrcweir 										rSegInfo.Command = EnhancedCustomShapeSegmentCommand::LINETO;
1260cdf0e10cSrcweir 										rSegInfo.Count   = nSDat & 0xff;
1261cdf0e10cSrcweir 										if ( !rSegInfo.Count )
1262cdf0e10cSrcweir 											rSegInfo.Count = 1;
1263cdf0e10cSrcweir 									}
1264cdf0e10cSrcweir 									break;
1265cdf0e10cSrcweir 									case 0x20 :
1266cdf0e10cSrcweir 									{
1267cdf0e10cSrcweir 										rSegInfo.Command = EnhancedCustomShapeSegmentCommand::CURVETO;
1268cdf0e10cSrcweir 										rSegInfo.Count   = nSDat & 0xff;
1269cdf0e10cSrcweir 										if ( !rSegInfo.Count )
1270cdf0e10cSrcweir 											rSegInfo.Count = 1;
1271cdf0e10cSrcweir 									}
1272cdf0e10cSrcweir 									break;
1273cdf0e10cSrcweir 									case 0x40 :
1274cdf0e10cSrcweir 									{
1275cdf0e10cSrcweir 										rSegInfo.Command = EnhancedCustomShapeSegmentCommand::MOVETO;
1276cdf0e10cSrcweir 										rSegInfo.Count   = nSDat & 0xff;
1277cdf0e10cSrcweir 										if ( !rSegInfo.Count )
1278cdf0e10cSrcweir 											rSegInfo.Count = 1;
1279cdf0e10cSrcweir 									}
1280cdf0e10cSrcweir 									break;
1281cdf0e10cSrcweir 									case 0x60 :
1282cdf0e10cSrcweir 									{
1283cdf0e10cSrcweir 										rSegInfo.Command = EnhancedCustomShapeSegmentCommand::CLOSESUBPATH;
1284cdf0e10cSrcweir 										rSegInfo.Count   = 0;
1285cdf0e10cSrcweir 									}
1286cdf0e10cSrcweir 									break;
1287cdf0e10cSrcweir 									case 0x80 :
1288cdf0e10cSrcweir 									{
1289cdf0e10cSrcweir 										rSegInfo.Command = EnhancedCustomShapeSegmentCommand::ENDSUBPATH;
1290cdf0e10cSrcweir 										rSegInfo.Count   = 0;
1291cdf0e10cSrcweir 									}
1292cdf0e10cSrcweir 									break;
1293cdf0e10cSrcweir 									case 0xa1 :
1294cdf0e10cSrcweir 									{
1295cdf0e10cSrcweir 										rSegInfo.Command = EnhancedCustomShapeSegmentCommand::ANGLEELLIPSETO;
1296cdf0e10cSrcweir 										rSegInfo.Count   = ( nSDat & 0xff ) / 3;
1297cdf0e10cSrcweir 									}
1298cdf0e10cSrcweir 									break;
1299cdf0e10cSrcweir 									case 0xa2 :
1300cdf0e10cSrcweir 									{
1301cdf0e10cSrcweir 										rSegInfo.Command = EnhancedCustomShapeSegmentCommand::ANGLEELLIPSE;
1302cdf0e10cSrcweir 										rSegInfo.Count   = ( nSDat & 0xff ) / 3;
1303cdf0e10cSrcweir 									}
1304cdf0e10cSrcweir 									break;
1305cdf0e10cSrcweir 									case 0xa3 :
1306cdf0e10cSrcweir 									{
1307cdf0e10cSrcweir 										rSegInfo.Command = EnhancedCustomShapeSegmentCommand::ARCTO;
1308cdf0e10cSrcweir 										rSegInfo.Count   = ( nSDat & 0xff ) >> 2;
1309cdf0e10cSrcweir 									}
1310cdf0e10cSrcweir 									break;
1311cdf0e10cSrcweir 									case 0xa4 :
1312cdf0e10cSrcweir 									{
1313cdf0e10cSrcweir 										rSegInfo.Command = EnhancedCustomShapeSegmentCommand::ARC;
1314cdf0e10cSrcweir 										rSegInfo.Count   = ( nSDat & 0xff ) >> 2;
1315cdf0e10cSrcweir 									}
1316cdf0e10cSrcweir 									break;
1317cdf0e10cSrcweir 									case 0xa5 :
1318cdf0e10cSrcweir 									{
1319cdf0e10cSrcweir 										rSegInfo.Command = EnhancedCustomShapeSegmentCommand::CLOCKWISEARCTO;
1320cdf0e10cSrcweir 										rSegInfo.Count   = ( nSDat & 0xff ) >> 2;
1321cdf0e10cSrcweir 									}
1322cdf0e10cSrcweir 									break;
1323cdf0e10cSrcweir 									case 0xa6 :
1324cdf0e10cSrcweir 									{
1325cdf0e10cSrcweir 										rSegInfo.Command = EnhancedCustomShapeSegmentCommand::CLOCKWISEARC;
1326cdf0e10cSrcweir 										rSegInfo.Count   = ( nSDat & 0xff ) >> 2;
1327cdf0e10cSrcweir 									}
1328cdf0e10cSrcweir 									break;
1329cdf0e10cSrcweir 									case 0xa7 :
1330cdf0e10cSrcweir 									{
1331cdf0e10cSrcweir 										rSegInfo.Command = EnhancedCustomShapeSegmentCommand::ELLIPTICALQUADRANTX;
1332cdf0e10cSrcweir 										rSegInfo.Count   = nSDat & 0xff;
1333cdf0e10cSrcweir 									}
1334cdf0e10cSrcweir 									break;
1335cdf0e10cSrcweir 									case 0xa8 :
1336cdf0e10cSrcweir 									{
1337cdf0e10cSrcweir 										rSegInfo.Command = EnhancedCustomShapeSegmentCommand::ELLIPTICALQUADRANTY;
1338cdf0e10cSrcweir 										rSegInfo.Count   = nSDat & 0xff;
1339cdf0e10cSrcweir 									}
1340cdf0e10cSrcweir 									break;
1341cdf0e10cSrcweir 									case 0xaa :
1342cdf0e10cSrcweir 									{
1343cdf0e10cSrcweir 										rSegInfo.Command = EnhancedCustomShapeSegmentCommand::NOFILL;
1344cdf0e10cSrcweir 										rSegInfo.Count   = 0;
1345cdf0e10cSrcweir 									}
1346cdf0e10cSrcweir 									break;
1347cdf0e10cSrcweir 									case 0xab :
1348cdf0e10cSrcweir 									{
1349cdf0e10cSrcweir 										rSegInfo.Command = EnhancedCustomShapeSegmentCommand::NOSTROKE;
1350cdf0e10cSrcweir 										rSegInfo.Count   = 0;
1351cdf0e10cSrcweir 									}
1352cdf0e10cSrcweir 									break;
1353cdf0e10cSrcweir 									default:
1354cdf0e10cSrcweir 									case 0xf8 :
1355cdf0e10cSrcweir 									{
1356cdf0e10cSrcweir 										rSegInfo.Command = EnhancedCustomShapeSegmentCommand::UNKNOWN;
1357cdf0e10cSrcweir 										rSegInfo.Count   = nSDat;
1358cdf0e10cSrcweir 									}
1359cdf0e10cSrcweir 									break;
1360cdf0e10cSrcweir 								}
1361cdf0e10cSrcweir 							}
1362cdf0e10cSrcweir 							if ( seqSegments1 == seqSegments2 )
1363cdf0e10cSrcweir 								bIsDefaultGeometry = sal_True;
1364cdf0e10cSrcweir 						}
1365cdf0e10cSrcweir 					}
1366cdf0e10cSrcweir 					else
1367cdf0e10cSrcweir 					{
1368cdf0e10cSrcweir 						// check if its the default segment description	( M L Z N )
1369cdf0e10cSrcweir 						if ( seqSegments1.getLength() == 4 )
1370cdf0e10cSrcweir 						{
1371cdf0e10cSrcweir 							if ( ( seqSegments1[ 0 ].Command == EnhancedCustomShapeSegmentCommand::MOVETO )
1372cdf0e10cSrcweir 								&& ( seqSegments1[ 1 ].Command == EnhancedCustomShapeSegmentCommand::LINETO )
1373cdf0e10cSrcweir 								&& ( seqSegments1[ 2 ].Command == EnhancedCustomShapeSegmentCommand::CLOSESUBPATH )
1374cdf0e10cSrcweir 								&& ( seqSegments1[ 3 ].Command == EnhancedCustomShapeSegmentCommand::ENDSUBPATH ) )
1375cdf0e10cSrcweir 								bIsDefaultGeometry = sal_True;
1376cdf0e10cSrcweir 						}
1377cdf0e10cSrcweir 					}
1378cdf0e10cSrcweir 				}
1379cdf0e10cSrcweir 			}
1380cdf0e10cSrcweir 			else if ( pDefCustomShape && ( ( pDefCustomShape->nElements == 0 ) || ( pDefCustomShape->pElements == 0 ) ) )
1381cdf0e10cSrcweir 				bIsDefaultGeometry = sal_True;
1382cdf0e10cSrcweir 		}
1383cdf0e10cSrcweir 		break;
1384cdf0e10cSrcweir 
1385cdf0e10cSrcweir 		case DEFAULT_STRETCHX :
1386cdf0e10cSrcweir 		{
1387cdf0e10cSrcweir 			const rtl::OUString	sStretchX( RTL_CONSTASCII_USTRINGPARAM ( "StretchX" ) );
1388cdf0e10cSrcweir 			pAny = ((SdrCustomShapeGeometryItem&)aGeometryItem).GetPropertyValueByName( sPath, sStretchX );
1389cdf0e10cSrcweir 			if ( pAny && pDefCustomShape )
1390cdf0e10cSrcweir 			{
1391cdf0e10cSrcweir 				sal_Int32 nStretchX = 0;
1392cdf0e10cSrcweir 				if ( *pAny >>= nStretchX )
1393cdf0e10cSrcweir 				{
1394cdf0e10cSrcweir 					if ( pDefCustomShape->nXRef == nStretchX )
1395cdf0e10cSrcweir 						bIsDefaultGeometry = sal_True;
1396cdf0e10cSrcweir 				}
1397cdf0e10cSrcweir 			}
1398cdf0e10cSrcweir 			else if ( pDefCustomShape && ( pDefCustomShape->nXRef == DEFAULT_MINIMUM_SIGNED_COMPARE ) )
1399cdf0e10cSrcweir 				bIsDefaultGeometry = sal_True;
1400cdf0e10cSrcweir 		}
1401cdf0e10cSrcweir 		break;
1402cdf0e10cSrcweir 
1403cdf0e10cSrcweir 		case DEFAULT_STRETCHY :
1404cdf0e10cSrcweir 		{
1405cdf0e10cSrcweir 			const rtl::OUString	sStretchY( RTL_CONSTASCII_USTRINGPARAM ( "StretchY" ) );
1406cdf0e10cSrcweir 			pAny = ((SdrCustomShapeGeometryItem&)aGeometryItem).GetPropertyValueByName( sPath, sStretchY );
1407cdf0e10cSrcweir 			if ( pAny && pDefCustomShape )
1408cdf0e10cSrcweir 			{
1409cdf0e10cSrcweir 				sal_Int32 nStretchY = 0;
1410cdf0e10cSrcweir 				if ( *pAny >>= nStretchY )
1411cdf0e10cSrcweir 				{
1412cdf0e10cSrcweir 					if ( pDefCustomShape->nYRef == nStretchY )
1413cdf0e10cSrcweir 						bIsDefaultGeometry = sal_True;
1414cdf0e10cSrcweir 				}
1415cdf0e10cSrcweir 			}
1416cdf0e10cSrcweir 			else if ( pDefCustomShape && ( pDefCustomShape->nYRef == DEFAULT_MINIMUM_SIGNED_COMPARE ) )
1417cdf0e10cSrcweir 				bIsDefaultGeometry = sal_True;
1418cdf0e10cSrcweir 		}
1419cdf0e10cSrcweir 		break;
1420cdf0e10cSrcweir 
1421cdf0e10cSrcweir 		case DEFAULT_EQUATIONS :
1422cdf0e10cSrcweir 		{
1423cdf0e10cSrcweir 			const rtl::OUString	sEquations( RTL_CONSTASCII_USTRINGPARAM( "Equations" ) );
1424cdf0e10cSrcweir 			pAny = ((SdrCustomShapeGeometryItem&)aGeometryItem).GetPropertyValueByName( sEquations );
1425cdf0e10cSrcweir 			if ( pAny && pDefCustomShape && pDefCustomShape->nCalculation && pDefCustomShape->pCalculation )
1426cdf0e10cSrcweir 			{
1427cdf0e10cSrcweir 				com::sun::star::uno::Sequence< rtl::OUString > seqEquations1, seqEquations2;
1428cdf0e10cSrcweir 				if ( *pAny >>= seqEquations1 )
1429cdf0e10cSrcweir 				{
1430cdf0e10cSrcweir 					sal_Int32 i, nCount = pDefCustomShape->nCalculation;
1431cdf0e10cSrcweir 					seqEquations2.realloc( nCount );
1432cdf0e10cSrcweir 
1433cdf0e10cSrcweir 					const SvxMSDffCalculationData* pData = pDefCustomShape->pCalculation;
1434cdf0e10cSrcweir 					for ( i = 0; i < nCount; i++, pData++ )
1435cdf0e10cSrcweir 						seqEquations2[ i ] = EnhancedCustomShape2d::GetEquation( pData->nFlags, pData->nVal[ 0 ], pData->nVal[ 1 ], pData->nVal[ 2 ] );
1436cdf0e10cSrcweir 
1437cdf0e10cSrcweir 					if ( seqEquations1 == seqEquations2 )
1438cdf0e10cSrcweir 						bIsDefaultGeometry = sal_True;
1439cdf0e10cSrcweir 				}
1440cdf0e10cSrcweir 			}
1441cdf0e10cSrcweir 			else if ( pDefCustomShape && ( ( pDefCustomShape->nCalculation == 0 ) || ( pDefCustomShape->pCalculation == 0 ) ) )
1442cdf0e10cSrcweir 				bIsDefaultGeometry = sal_True;
1443cdf0e10cSrcweir 		}
1444cdf0e10cSrcweir 		break;
1445cdf0e10cSrcweir 
1446cdf0e10cSrcweir 		case DEFAULT_TEXTFRAMES :
1447cdf0e10cSrcweir 		{
1448cdf0e10cSrcweir 			const rtl::OUString	sTextFrames( RTL_CONSTASCII_USTRINGPARAM( "TextFrames" ) );
1449cdf0e10cSrcweir 			pAny = ((SdrCustomShapeGeometryItem&)aGeometryItem).GetPropertyValueByName( sPath, sTextFrames );
1450cdf0e10cSrcweir 			if ( pAny && pDefCustomShape && pDefCustomShape->nTextRect && pDefCustomShape->pTextRect )
1451cdf0e10cSrcweir 			{
1452cdf0e10cSrcweir 				com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeTextFrame > seqTextFrames1, seqTextFrames2;
1453cdf0e10cSrcweir 				if ( *pAny >>= seqTextFrames1 )
1454cdf0e10cSrcweir 				{
1455cdf0e10cSrcweir 					sal_Int32 i, nCount = pDefCustomShape->nTextRect;
1456cdf0e10cSrcweir 					seqTextFrames2.realloc( nCount );
1457cdf0e10cSrcweir 					const SvxMSDffTextRectangles* pRectangles = pDefCustomShape->pTextRect;
1458cdf0e10cSrcweir 					for ( i = 0; i < nCount; i++, pRectangles++ )
1459cdf0e10cSrcweir 					{
1460cdf0e10cSrcweir 						EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( seqTextFrames2[ i ].TopLeft.First,	  pRectangles->nPairA.nValA );
1461cdf0e10cSrcweir 						EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( seqTextFrames2[ i ].TopLeft.Second,	  pRectangles->nPairA.nValB );
1462cdf0e10cSrcweir 						EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( seqTextFrames2[ i ].BottomRight.First,  pRectangles->nPairB.nValA );
1463cdf0e10cSrcweir 						EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( seqTextFrames2[ i ].BottomRight.Second, pRectangles->nPairB.nValB );
1464cdf0e10cSrcweir 					}
1465cdf0e10cSrcweir 					if ( seqTextFrames1 == seqTextFrames2 )
1466cdf0e10cSrcweir 						bIsDefaultGeometry = sal_True;
1467cdf0e10cSrcweir 				}
1468cdf0e10cSrcweir 			}
1469cdf0e10cSrcweir 			else if ( pDefCustomShape && ( ( pDefCustomShape->nTextRect == 0 ) || ( pDefCustomShape->pTextRect == 0 ) ) )
1470cdf0e10cSrcweir 				bIsDefaultGeometry = sal_True;
1471cdf0e10cSrcweir 		}
1472cdf0e10cSrcweir 		break;
1473cdf0e10cSrcweir 
1474cdf0e10cSrcweir 		case DEFAULT_HANDLES :
1475cdf0e10cSrcweir 		{
1476cdf0e10cSrcweir 			const rtl::OUString	sHandles( RTL_CONSTASCII_USTRINGPARAM( "Handles" ) );
1477cdf0e10cSrcweir 			pAny = ((SdrCustomShapeGeometryItem&)aGeometryItem).GetPropertyValueByName( sHandles );
1478cdf0e10cSrcweir 			if ( pAny && pDefCustomShape && pDefCustomShape->nHandles && pDefCustomShape->pHandles )
1479cdf0e10cSrcweir 			{
1480cdf0e10cSrcweir 				com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValues > seqHandles1, seqHandles2;
1481cdf0e10cSrcweir 				if ( *pAny >>= seqHandles1 )
1482cdf0e10cSrcweir 				{
1483cdf0e10cSrcweir 					sal_Int32 i, n, nCount = pDefCustomShape->nHandles;
1484cdf0e10cSrcweir 					const SvxMSDffHandle* pData = pDefCustomShape->pHandles;
1485cdf0e10cSrcweir 					seqHandles2.realloc( nCount );
1486cdf0e10cSrcweir 					for ( i = 0; i < nCount; i++, pData++ )
1487cdf0e10cSrcweir 					{
1488cdf0e10cSrcweir 						sal_Int32 nPropertiesNeeded = 1;	// position is always needed
1489cdf0e10cSrcweir 						sal_Int32 nFlags = pData->nFlags;
1490cdf0e10cSrcweir 						if ( nFlags & MSDFF_HANDLE_FLAGS_MIRRORED_X )
1491cdf0e10cSrcweir 							nPropertiesNeeded++;
1492cdf0e10cSrcweir 						if ( nFlags & MSDFF_HANDLE_FLAGS_MIRRORED_Y )
1493cdf0e10cSrcweir 							nPropertiesNeeded++;
1494cdf0e10cSrcweir 						if ( nFlags & MSDFF_HANDLE_FLAGS_SWITCHED )
1495cdf0e10cSrcweir 							nPropertiesNeeded++;
1496cdf0e10cSrcweir 						if ( nFlags & MSDFF_HANDLE_FLAGS_POLAR )
1497cdf0e10cSrcweir 						{
1498cdf0e10cSrcweir 							nPropertiesNeeded++;
1499cdf0e10cSrcweir 							if ( nFlags & MSDFF_HANDLE_FLAGS_RADIUS_RANGE )
1500cdf0e10cSrcweir 							{
1501cdf0e10cSrcweir 								if ( pData->nRangeXMin != DEFAULT_MINIMUM_SIGNED_COMPARE )
1502cdf0e10cSrcweir 									nPropertiesNeeded++;
1503cdf0e10cSrcweir 								if ( pData->nRangeXMax != DEFAULT_MAXIMUM_SIGNED_COMPARE )
1504cdf0e10cSrcweir 									nPropertiesNeeded++;
1505cdf0e10cSrcweir 							}
1506cdf0e10cSrcweir 						}
1507cdf0e10cSrcweir 						else if ( nFlags & MSDFF_HANDLE_FLAGS_RANGE )
1508cdf0e10cSrcweir 						{
1509cdf0e10cSrcweir 							if ( pData->nRangeXMin != DEFAULT_MINIMUM_SIGNED_COMPARE )
1510cdf0e10cSrcweir 								nPropertiesNeeded++;
1511cdf0e10cSrcweir 							if ( pData->nRangeXMax != DEFAULT_MAXIMUM_SIGNED_COMPARE )
1512cdf0e10cSrcweir 								nPropertiesNeeded++;
1513cdf0e10cSrcweir 							if ( pData->nRangeYMin != DEFAULT_MINIMUM_SIGNED_COMPARE )
1514cdf0e10cSrcweir 								nPropertiesNeeded++;
1515cdf0e10cSrcweir 							if ( pData->nRangeYMax != DEFAULT_MAXIMUM_SIGNED_COMPARE )
1516cdf0e10cSrcweir 								nPropertiesNeeded++;
1517cdf0e10cSrcweir 						}
1518cdf0e10cSrcweir 
1519cdf0e10cSrcweir 						n = 0;
1520cdf0e10cSrcweir 						com::sun::star::beans::PropertyValues& rPropValues = seqHandles2[ i ];
1521cdf0e10cSrcweir 						rPropValues.realloc( nPropertiesNeeded );
1522cdf0e10cSrcweir 
1523cdf0e10cSrcweir 						// POSITION
1524cdf0e10cSrcweir 						{
1525cdf0e10cSrcweir 							const rtl::OUString	sPosition( RTL_CONSTASCII_USTRINGPARAM ( "Position" ) );
1526cdf0e10cSrcweir 							::com::sun::star::drawing::EnhancedCustomShapeParameterPair aPosition;
1527cdf0e10cSrcweir 							EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aPosition.First, pData->nPositionX, sal_True, sal_True );
1528cdf0e10cSrcweir 							EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aPosition.Second, pData->nPositionY, sal_True, sal_False );
1529cdf0e10cSrcweir 							rPropValues[ n ].Name = sPosition;
1530cdf0e10cSrcweir 							rPropValues[ n++ ].Value <<= aPosition;
1531cdf0e10cSrcweir 						}
1532cdf0e10cSrcweir 						if ( nFlags & MSDFF_HANDLE_FLAGS_MIRRORED_X )
1533cdf0e10cSrcweir 						{
1534cdf0e10cSrcweir 							const rtl::OUString	sMirroredX( RTL_CONSTASCII_USTRINGPARAM ( "MirroredX" ) );
1535cdf0e10cSrcweir 							sal_Bool bMirroredX = sal_True;
1536cdf0e10cSrcweir 							rPropValues[ n ].Name = sMirroredX;
1537cdf0e10cSrcweir 							rPropValues[ n++ ].Value <<= bMirroredX;
1538cdf0e10cSrcweir 						}
1539cdf0e10cSrcweir 						if ( nFlags & MSDFF_HANDLE_FLAGS_MIRRORED_Y )
1540cdf0e10cSrcweir 						{
1541cdf0e10cSrcweir 							const rtl::OUString	sMirroredY( RTL_CONSTASCII_USTRINGPARAM ( "MirroredY" ) );
1542cdf0e10cSrcweir 							sal_Bool bMirroredY = sal_True;
1543cdf0e10cSrcweir 							rPropValues[ n ].Name = sMirroredY;
1544cdf0e10cSrcweir 							rPropValues[ n++ ].Value <<= bMirroredY;
1545cdf0e10cSrcweir 						}
1546cdf0e10cSrcweir 						if ( nFlags & MSDFF_HANDLE_FLAGS_SWITCHED )
1547cdf0e10cSrcweir 						{
1548cdf0e10cSrcweir 							const rtl::OUString	sSwitched( RTL_CONSTASCII_USTRINGPARAM ( "Switched" ) );
1549cdf0e10cSrcweir 							sal_Bool bSwitched = sal_True;
1550cdf0e10cSrcweir 							rPropValues[ n ].Name = sSwitched;
1551cdf0e10cSrcweir 							rPropValues[ n++ ].Value <<= bSwitched;
1552cdf0e10cSrcweir 						}
1553cdf0e10cSrcweir 						if ( nFlags & MSDFF_HANDLE_FLAGS_POLAR )
1554cdf0e10cSrcweir 						{
1555cdf0e10cSrcweir 							const rtl::OUString	sPolar( RTL_CONSTASCII_USTRINGPARAM ( "Polar" ) );
1556cdf0e10cSrcweir 							::com::sun::star::drawing::EnhancedCustomShapeParameterPair aCenter;
1557cdf0e10cSrcweir 							EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aCenter.First,  pData->nCenterX,
1558cdf0e10cSrcweir 								( nFlags & MSDFF_HANDLE_FLAGS_CENTER_X_IS_SPECIAL ) != 0, sal_True  );
1559cdf0e10cSrcweir 							EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aCenter.Second, pData->nCenterY,
1560cdf0e10cSrcweir 								( nFlags & MSDFF_HANDLE_FLAGS_CENTER_Y_IS_SPECIAL ) != 0, sal_False );
1561cdf0e10cSrcweir 							rPropValues[ n ].Name = sPolar;
1562cdf0e10cSrcweir 							rPropValues[ n++ ].Value <<= aCenter;
1563cdf0e10cSrcweir 							if ( nFlags & MSDFF_HANDLE_FLAGS_RADIUS_RANGE )
1564cdf0e10cSrcweir 							{
1565cdf0e10cSrcweir 								if ( pData->nRangeXMin != DEFAULT_MINIMUM_SIGNED_COMPARE )
1566cdf0e10cSrcweir 								{
1567cdf0e10cSrcweir 									const rtl::OUString	sRadiusRangeMinimum( RTL_CONSTASCII_USTRINGPARAM ( "RadiusRangeMinimum" ) );
1568cdf0e10cSrcweir 									::com::sun::star::drawing::EnhancedCustomShapeParameter aRadiusRangeMinimum;
1569cdf0e10cSrcweir 									EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aRadiusRangeMinimum, pData->nRangeXMin,
1570cdf0e10cSrcweir 										( nFlags & MSDFF_HANDLE_FLAGS_RANGE_X_MIN_IS_SPECIAL ) != 0, sal_True  );
1571cdf0e10cSrcweir 									rPropValues[ n ].Name = sRadiusRangeMinimum;
1572cdf0e10cSrcweir 									rPropValues[ n++ ].Value <<= aRadiusRangeMinimum;
1573cdf0e10cSrcweir 								}
1574cdf0e10cSrcweir 								if ( pData->nRangeXMax != DEFAULT_MAXIMUM_SIGNED_COMPARE )
1575cdf0e10cSrcweir 								{
1576cdf0e10cSrcweir 									const rtl::OUString	sRadiusRangeMaximum( RTL_CONSTASCII_USTRINGPARAM ( "RadiusRangeMaximum" ) );
1577cdf0e10cSrcweir 									::com::sun::star::drawing::EnhancedCustomShapeParameter aRadiusRangeMaximum;
1578cdf0e10cSrcweir 									EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aRadiusRangeMaximum, pData->nRangeXMax,
1579cdf0e10cSrcweir 										( nFlags & MSDFF_HANDLE_FLAGS_RANGE_X_MAX_IS_SPECIAL ) != 0, sal_False );
1580cdf0e10cSrcweir 									rPropValues[ n ].Name = sRadiusRangeMaximum;
1581cdf0e10cSrcweir 									rPropValues[ n++ ].Value <<= aRadiusRangeMaximum;
1582cdf0e10cSrcweir 								}
1583cdf0e10cSrcweir 							}
1584cdf0e10cSrcweir 						}
1585cdf0e10cSrcweir 						else if ( nFlags & MSDFF_HANDLE_FLAGS_RANGE )
1586cdf0e10cSrcweir 						{
1587cdf0e10cSrcweir 							if ( pData->nRangeXMin != DEFAULT_MINIMUM_SIGNED_COMPARE )
1588cdf0e10cSrcweir 							{
1589cdf0e10cSrcweir 								const rtl::OUString	sRangeXMinimum( RTL_CONSTASCII_USTRINGPARAM ( "RangeXMinimum" ) );
1590cdf0e10cSrcweir 								::com::sun::star::drawing::EnhancedCustomShapeParameter aRangeXMinimum;
1591cdf0e10cSrcweir 								EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aRangeXMinimum, pData->nRangeXMin,
1592cdf0e10cSrcweir 									( nFlags & MSDFF_HANDLE_FLAGS_RANGE_X_MIN_IS_SPECIAL ) != 0, sal_True  );
1593cdf0e10cSrcweir 								rPropValues[ n ].Name = sRangeXMinimum;
1594cdf0e10cSrcweir 								rPropValues[ n++ ].Value <<= aRangeXMinimum;
1595cdf0e10cSrcweir 							}
1596cdf0e10cSrcweir 							if ( pData->nRangeXMax != DEFAULT_MAXIMUM_SIGNED_COMPARE )
1597cdf0e10cSrcweir 							{
1598cdf0e10cSrcweir 								const rtl::OUString	sRangeXMaximum( RTL_CONSTASCII_USTRINGPARAM ( "RangeXMaximum" ) );
1599cdf0e10cSrcweir 								::com::sun::star::drawing::EnhancedCustomShapeParameter aRangeXMaximum;
1600cdf0e10cSrcweir 								EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aRangeXMaximum, pData->nRangeXMax,
1601cdf0e10cSrcweir 									( nFlags & MSDFF_HANDLE_FLAGS_RANGE_X_MAX_IS_SPECIAL ) != 0, sal_False );
1602cdf0e10cSrcweir 								rPropValues[ n ].Name = sRangeXMaximum;
1603cdf0e10cSrcweir 								rPropValues[ n++ ].Value <<= aRangeXMaximum;
1604cdf0e10cSrcweir 							}
1605cdf0e10cSrcweir 							if ( pData->nRangeYMin != DEFAULT_MINIMUM_SIGNED_COMPARE )
1606cdf0e10cSrcweir 							{
1607cdf0e10cSrcweir 								const rtl::OUString	sRangeYMinimum( RTL_CONSTASCII_USTRINGPARAM ( "RangeYMinimum" ) );
1608cdf0e10cSrcweir 								::com::sun::star::drawing::EnhancedCustomShapeParameter aRangeYMinimum;
1609cdf0e10cSrcweir 								EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aRangeYMinimum, pData->nRangeYMin,
1610cdf0e10cSrcweir 									( nFlags & MSDFF_HANDLE_FLAGS_RANGE_Y_MIN_IS_SPECIAL ) != 0, sal_True );
1611cdf0e10cSrcweir 								rPropValues[ n ].Name = sRangeYMinimum;
1612cdf0e10cSrcweir 								rPropValues[ n++ ].Value <<= aRangeYMinimum;
1613cdf0e10cSrcweir 							}
1614cdf0e10cSrcweir 							if ( pData->nRangeYMax != DEFAULT_MAXIMUM_SIGNED_COMPARE )
1615cdf0e10cSrcweir 							{
1616cdf0e10cSrcweir 								const rtl::OUString	sRangeYMaximum( RTL_CONSTASCII_USTRINGPARAM ( "RangeYMaximum" ) );
1617cdf0e10cSrcweir 								::com::sun::star::drawing::EnhancedCustomShapeParameter aRangeYMaximum;
1618cdf0e10cSrcweir 								EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aRangeYMaximum, pData->nRangeYMax,
1619cdf0e10cSrcweir 									( nFlags & MSDFF_HANDLE_FLAGS_RANGE_Y_MAX_IS_SPECIAL ) != 0, sal_False );
1620cdf0e10cSrcweir 								rPropValues[ n ].Name = sRangeYMaximum;
1621cdf0e10cSrcweir 								rPropValues[ n++ ].Value <<= aRangeYMaximum;
1622cdf0e10cSrcweir 							}
1623cdf0e10cSrcweir 						}
1624cdf0e10cSrcweir 					}
1625cdf0e10cSrcweir 					if ( seqHandles1 == seqHandles2 )
1626cdf0e10cSrcweir 						bIsDefaultGeometry = sal_True;
1627cdf0e10cSrcweir 				}
1628cdf0e10cSrcweir 			}
1629cdf0e10cSrcweir 			else if ( pDefCustomShape && ( ( pDefCustomShape->nHandles == 0 ) || ( pDefCustomShape->pHandles == 0 ) ) )
1630cdf0e10cSrcweir 				bIsDefaultGeometry = sal_True;
1631cdf0e10cSrcweir 		}
1632cdf0e10cSrcweir 		break;
1633cdf0e10cSrcweir 	}
1634cdf0e10cSrcweir 	return bIsDefaultGeometry;
1635cdf0e10cSrcweir }
1636cdf0e10cSrcweir 
1637cdf0e10cSrcweir void SdrObjCustomShape::TakeObjInfo(SdrObjTransformInfoRec& rInfo) const
1638cdf0e10cSrcweir {
1639cdf0e10cSrcweir 	rInfo.bResizeFreeAllowed=fObjectRotation == 0.0;
1640cdf0e10cSrcweir 	rInfo.bResizePropAllowed=sal_True;
1641cdf0e10cSrcweir 	rInfo.bRotateFreeAllowed=sal_True;
1642cdf0e10cSrcweir 	rInfo.bRotate90Allowed  =sal_True;
1643cdf0e10cSrcweir 	rInfo.bMirrorFreeAllowed=sal_True;
1644cdf0e10cSrcweir 	rInfo.bMirror45Allowed  =sal_True;
1645cdf0e10cSrcweir 	rInfo.bMirror90Allowed  =sal_True;
1646cdf0e10cSrcweir 	rInfo.bTransparenceAllowed = sal_False;
1647cdf0e10cSrcweir 	rInfo.bGradientAllowed = sal_False;
1648cdf0e10cSrcweir 	rInfo.bShearAllowed     =sal_True;
1649cdf0e10cSrcweir 	rInfo.bEdgeRadiusAllowed=sal_False;
1650cdf0e10cSrcweir 	rInfo.bNoContortion     =sal_True;
1651cdf0e10cSrcweir 
1652cdf0e10cSrcweir 	// #i37011#
1653cdf0e10cSrcweir 	if ( mXRenderedCustomShape.is() )
1654cdf0e10cSrcweir 	{
1655cdf0e10cSrcweir 		const SdrObject* pRenderedCustomShape = GetSdrObjectFromXShape( mXRenderedCustomShape );
1656cdf0e10cSrcweir 		if ( pRenderedCustomShape )
1657cdf0e10cSrcweir 		{
1658cdf0e10cSrcweir 			// #i37262#
1659cdf0e10cSrcweir 			// Iterate self over the contained objects, since there are combinations of
1660cdf0e10cSrcweir 			// polygon and curve objects. In that case, aInfo.bCanConvToPath and
1661cdf0e10cSrcweir 			// aInfo.bCanConvToPoly would be false. What is needed here is an or, not an and.
1662cdf0e10cSrcweir 			SdrObjListIter aIterator(*pRenderedCustomShape);
1663cdf0e10cSrcweir 			while(aIterator.IsMore())
1664cdf0e10cSrcweir 			{
1665cdf0e10cSrcweir 				SdrObject* pCandidate = aIterator.Next();
1666cdf0e10cSrcweir 				SdrObjTransformInfoRec aInfo;
1667cdf0e10cSrcweir 				pCandidate->TakeObjInfo(aInfo);
1668cdf0e10cSrcweir 
1669cdf0e10cSrcweir 				// set path and poly conversion if one is possible since
1670cdf0e10cSrcweir 				// this object will first be broken
1671cdf0e10cSrcweir 				const sal_Bool bCanConvToPathOrPoly(aInfo.bCanConvToPath || aInfo.bCanConvToPoly);
1672cdf0e10cSrcweir 				if(rInfo.bCanConvToPath != bCanConvToPathOrPoly)
1673cdf0e10cSrcweir 				{
1674cdf0e10cSrcweir 					rInfo.bCanConvToPath = bCanConvToPathOrPoly;
1675cdf0e10cSrcweir 				}
1676cdf0e10cSrcweir 
1677cdf0e10cSrcweir 				if(rInfo.bCanConvToPoly != bCanConvToPathOrPoly)
1678cdf0e10cSrcweir 				{
1679cdf0e10cSrcweir 					rInfo.bCanConvToPoly = bCanConvToPathOrPoly;
1680cdf0e10cSrcweir 				}
1681cdf0e10cSrcweir 
1682cdf0e10cSrcweir 				if(rInfo.bCanConvToContour != aInfo.bCanConvToContour)
1683cdf0e10cSrcweir 				{
1684cdf0e10cSrcweir 					rInfo.bCanConvToContour = aInfo.bCanConvToContour;
1685cdf0e10cSrcweir 				}
1686cdf0e10cSrcweir 			}
1687cdf0e10cSrcweir 		}
1688cdf0e10cSrcweir 	}
1689cdf0e10cSrcweir }
1690cdf0e10cSrcweir 
1691cdf0e10cSrcweir void SdrObjCustomShape::SetModel(SdrModel* pNewModel)
1692cdf0e10cSrcweir {
1693cdf0e10cSrcweir 	SdrTextObj::SetModel(pNewModel);
1694cdf0e10cSrcweir 	mXRenderedCustomShape.clear();
1695cdf0e10cSrcweir }
1696cdf0e10cSrcweir 
1697cdf0e10cSrcweir sal_uInt16 SdrObjCustomShape::GetObjIdentifier() const
1698cdf0e10cSrcweir {
1699cdf0e10cSrcweir 	return sal_uInt16(OBJ_CUSTOMSHAPE);
1700cdf0e10cSrcweir }
1701cdf0e10cSrcweir 
1702cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
1703cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
1704cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
1705cdf0e10cSrcweir 
1706cdf0e10cSrcweir void SdrObjCustomShape::RecalcSnapRect()
1707cdf0e10cSrcweir {
1708cdf0e10cSrcweir 	SdrTextObj::RecalcSnapRect();
1709cdf0e10cSrcweir }
1710cdf0e10cSrcweir const Rectangle& SdrObjCustomShape::GetSnapRect() const
1711cdf0e10cSrcweir {
1712cdf0e10cSrcweir 	return SdrTextObj::GetSnapRect();
1713cdf0e10cSrcweir }
1714cdf0e10cSrcweir const Rectangle& SdrObjCustomShape::GetCurrentBoundRect() const
1715cdf0e10cSrcweir {
1716cdf0e10cSrcweir 	return SdrTextObj::GetCurrentBoundRect();
1717cdf0e10cSrcweir }
1718cdf0e10cSrcweir const Rectangle& SdrObjCustomShape::GetLogicRect() const
1719cdf0e10cSrcweir {
1720cdf0e10cSrcweir 	return SdrTextObj::GetLogicRect();
1721cdf0e10cSrcweir }
1722cdf0e10cSrcweir void SdrObjCustomShape::NbcSetSnapRect( const Rectangle& rRect )
1723cdf0e10cSrcweir {
1724cdf0e10cSrcweir 	aRect=rRect;
1725cdf0e10cSrcweir 	ImpJustifyRect(aRect);
1726cdf0e10cSrcweir 	InvalidateRenderGeometry();
1727cdf0e10cSrcweir 	Rectangle aTextBound( aRect );
1728cdf0e10cSrcweir 	if ( GetTextBounds( aTextBound ) )
1729cdf0e10cSrcweir 	{
1730cdf0e10cSrcweir 		if ( pModel==NULL || !pModel->IsPasteResize() )
1731cdf0e10cSrcweir 		{
1732cdf0e10cSrcweir 			long nHDist=GetTextLeftDistance()+GetTextRightDistance();
1733cdf0e10cSrcweir 			long nVDist=GetTextUpperDistance()+GetTextLowerDistance();
1734cdf0e10cSrcweir 			long nTWdt=aTextBound.GetWidth ()-1-nHDist; if (nTWdt<0) nTWdt=0;
1735cdf0e10cSrcweir 			long nTHgt=aTextBound.GetHeight()-1-nVDist; if (nTHgt<0) nTHgt=0;
1736cdf0e10cSrcweir 			if ( IsAutoGrowWidth() )
1737cdf0e10cSrcweir 				NbcSetMinTextFrameWidth( nTWdt );
1738cdf0e10cSrcweir 			if ( IsAutoGrowHeight() )
1739cdf0e10cSrcweir 				NbcSetMinTextFrameHeight( nTHgt );
1740cdf0e10cSrcweir 			NbcAdjustTextFrameWidthAndHeight();
1741cdf0e10cSrcweir 		}
1742cdf0e10cSrcweir 	}
1743cdf0e10cSrcweir 	ImpCheckShear();
1744cdf0e10cSrcweir 	SetRectsDirty();
1745cdf0e10cSrcweir 	SetChanged();
1746cdf0e10cSrcweir }
1747cdf0e10cSrcweir void SdrObjCustomShape::SetSnapRect( const Rectangle& rRect )
1748cdf0e10cSrcweir {
1749cdf0e10cSrcweir 	Rectangle aBoundRect0;
1750cdf0e10cSrcweir 	if ( pUserCall )
1751cdf0e10cSrcweir 		aBoundRect0 = GetLastBoundRect();
1752cdf0e10cSrcweir 	NbcSetSnapRect( rRect );
1753cdf0e10cSrcweir 	BroadcastObjectChange();
1754cdf0e10cSrcweir 	SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
1755cdf0e10cSrcweir }
1756cdf0e10cSrcweir void SdrObjCustomShape::NbcSetLogicRect( const Rectangle& rRect )
1757cdf0e10cSrcweir {
1758cdf0e10cSrcweir 	aRect = rRect;
1759cdf0e10cSrcweir 	ImpJustifyRect( aRect );
1760cdf0e10cSrcweir 	InvalidateRenderGeometry();
1761cdf0e10cSrcweir 	Rectangle aTextBound( aRect );
1762cdf0e10cSrcweir 	if ( GetTextBounds( aTextBound ) )
1763cdf0e10cSrcweir 	{
1764cdf0e10cSrcweir 		long nHDist=GetTextLeftDistance()+GetTextRightDistance();
1765cdf0e10cSrcweir 		long nVDist=GetTextUpperDistance()+GetTextLowerDistance();
1766cdf0e10cSrcweir 
1767cdf0e10cSrcweir 		long nTWdt=aTextBound.GetWidth()-1-nHDist; if (nTWdt<0) nTWdt=0;
1768cdf0e10cSrcweir 		long nTHgt=aTextBound.GetHeight()-1-nVDist; if (nTHgt<0) nTHgt=0;
1769cdf0e10cSrcweir 		if ( IsAutoGrowWidth() )
1770cdf0e10cSrcweir 			NbcSetMinTextFrameWidth( nTWdt );
1771cdf0e10cSrcweir 		if ( IsAutoGrowHeight() )
1772cdf0e10cSrcweir 			NbcSetMinTextFrameHeight( nTHgt );
1773cdf0e10cSrcweir 		NbcAdjustTextFrameWidthAndHeight();
1774cdf0e10cSrcweir 	}
1775cdf0e10cSrcweir 	SetRectsDirty();
1776cdf0e10cSrcweir 	SetChanged();
1777cdf0e10cSrcweir }
1778cdf0e10cSrcweir void SdrObjCustomShape::SetLogicRect( const Rectangle& rRect )
1779cdf0e10cSrcweir {
1780cdf0e10cSrcweir 	Rectangle aBoundRect0;
1781cdf0e10cSrcweir 	if ( pUserCall )
1782cdf0e10cSrcweir 		aBoundRect0 = GetLastBoundRect();
1783cdf0e10cSrcweir 	NbcSetLogicRect(rRect);
1784cdf0e10cSrcweir 	BroadcastObjectChange();
1785cdf0e10cSrcweir 	SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
1786cdf0e10cSrcweir }
1787cdf0e10cSrcweir void SdrObjCustomShape::Move( const Size& rSiz )
1788cdf0e10cSrcweir {
1789cdf0e10cSrcweir 	if ( rSiz.Width() || rSiz.Height() )
1790cdf0e10cSrcweir 	{
1791cdf0e10cSrcweir 		Rectangle aBoundRect0;
1792cdf0e10cSrcweir 		if ( pUserCall )
1793cdf0e10cSrcweir 			aBoundRect0 = GetLastBoundRect();
1794cdf0e10cSrcweir 		// #110094#-14 SendRepaintBroadcast();
1795cdf0e10cSrcweir 		NbcMove(rSiz);
1796cdf0e10cSrcweir 		SetChanged();
1797cdf0e10cSrcweir 		BroadcastObjectChange();
1798cdf0e10cSrcweir 		SendUserCall(SDRUSERCALL_MOVEONLY,aBoundRect0);
1799cdf0e10cSrcweir 	}
1800cdf0e10cSrcweir }
1801cdf0e10cSrcweir void SdrObjCustomShape::NbcMove( const Size& rSiz )
1802cdf0e10cSrcweir {
1803cdf0e10cSrcweir 	SdrTextObj::NbcMove( rSiz );
1804cdf0e10cSrcweir 	if ( mXRenderedCustomShape.is() )
1805cdf0e10cSrcweir 	{
1806cdf0e10cSrcweir 		SdrObject* pRenderedCustomShape = GetSdrObjectFromXShape( mXRenderedCustomShape );
1807cdf0e10cSrcweir 		if ( pRenderedCustomShape )
1808cdf0e10cSrcweir         {
1809cdf0e10cSrcweir             // #i97149# the visualisation shape needs to be informed
1810cdf0e10cSrcweir             // about change, too
1811cdf0e10cSrcweir             pRenderedCustomShape->ActionChanged();
1812cdf0e10cSrcweir 			pRenderedCustomShape->NbcMove( rSiz );
1813cdf0e10cSrcweir         }
1814cdf0e10cSrcweir 	}
1815cdf0e10cSrcweir 
1816cdf0e10cSrcweir 	// #i37011# adapt geometry shadow
1817cdf0e10cSrcweir 	if(mpLastShadowGeometry)
1818cdf0e10cSrcweir 	{
1819cdf0e10cSrcweir 		mpLastShadowGeometry->NbcMove( rSiz );
1820cdf0e10cSrcweir 	}
1821cdf0e10cSrcweir }
1822cdf0e10cSrcweir void SdrObjCustomShape::Resize( const Point& rRef, const Fraction& xFact, const Fraction& yFact )
1823cdf0e10cSrcweir {
1824cdf0e10cSrcweir 	SdrTextObj::Resize( rRef, xFact, yFact );
1825cdf0e10cSrcweir }
1826cdf0e10cSrcweir 
1827cdf0e10cSrcweir void SdrObjCustomShape::NbcResize( const Point& rRef, const Fraction& rxFact, const Fraction& ryFact )
1828cdf0e10cSrcweir {
1829cdf0e10cSrcweir 	Fraction xFact( rxFact );
1830cdf0e10cSrcweir 	Fraction yFact( ryFact );
1831cdf0e10cSrcweir 
1832cdf0e10cSrcweir 	// taking care of handles that should not been changed
1833cdf0e10cSrcweir 	Rectangle aOld( aRect );
1834cdf0e10cSrcweir 	std::vector< SdrCustomShapeInteraction > aInteractionHandles( GetInteractionHandles( this ) );
1835cdf0e10cSrcweir 
1836cdf0e10cSrcweir 	SdrTextObj::NbcResize( rRef, xFact, yFact );
1837cdf0e10cSrcweir 
1838cdf0e10cSrcweir 	if ( ( xFact.GetNumerator() != xFact.GetDenominator() )
1839cdf0e10cSrcweir 		|| ( yFact.GetNumerator()!= yFact.GetDenominator() ) )
1840cdf0e10cSrcweir 	{
1841cdf0e10cSrcweir 		if ( ( ( xFact.GetNumerator() < 0 ) && ( xFact.GetDenominator() > 0 ) ) ||
1842cdf0e10cSrcweir 			( ( xFact.GetNumerator() > 0 ) && ( xFact.GetDenominator() < 0 ) ) )
1843cdf0e10cSrcweir 		{
1844cdf0e10cSrcweir 			SetMirroredX( IsMirroredX() == sal_False );
1845cdf0e10cSrcweir 		}
1846cdf0e10cSrcweir 		if ( ( ( yFact.GetNumerator() < 0 ) && ( yFact.GetDenominator() > 0 ) ) ||
1847cdf0e10cSrcweir 			( ( yFact.GetNumerator() > 0 ) && ( yFact.GetDenominator() < 0 ) ) )
1848cdf0e10cSrcweir 		{
1849cdf0e10cSrcweir 			SetMirroredY( IsMirroredY() == sal_False );
1850cdf0e10cSrcweir 		}
1851cdf0e10cSrcweir 	}
1852cdf0e10cSrcweir 
1853cdf0e10cSrcweir 	std::vector< SdrCustomShapeInteraction >::iterator aIter( aInteractionHandles.begin() );
1854cdf0e10cSrcweir 	while ( aIter != aInteractionHandles.end() )
1855cdf0e10cSrcweir 	{
1856cdf0e10cSrcweir 		try
1857cdf0e10cSrcweir 		{
1858cdf0e10cSrcweir 			if ( aIter->nMode & CUSTOMSHAPE_HANDLE_RESIZE_FIXED )
1859cdf0e10cSrcweir 				aIter->xInteraction->setControllerPosition( aIter->aPosition );
1860cdf0e10cSrcweir 			if ( aIter->nMode & CUSTOMSHAPE_HANDLE_RESIZE_ABSOLUTE_X )
1861cdf0e10cSrcweir 			{
1862cdf0e10cSrcweir 				sal_Int32 nX = ( aIter->aPosition.X - aOld.Left() ) + aRect.Left();
1863cdf0e10cSrcweir 				aIter->xInteraction->setControllerPosition( com::sun::star::awt::Point( nX, aIter->xInteraction->getPosition().Y ) );
1864cdf0e10cSrcweir 			}
1865cdf0e10cSrcweir 			if ( aIter->nMode & CUSTOMSHAPE_HANDLE_RESIZE_ABSOLUTE_Y )
1866cdf0e10cSrcweir 			{
1867cdf0e10cSrcweir 				sal_Int32 nY = ( aIter->aPosition.Y - aOld.Top() ) + aRect.Top();
1868cdf0e10cSrcweir 				aIter->xInteraction->setControllerPosition( com::sun::star::awt::Point( aIter->xInteraction->getPosition().X, nY ) );
1869cdf0e10cSrcweir 			}
1870cdf0e10cSrcweir 		}
1871cdf0e10cSrcweir 		catch ( const uno::RuntimeException& )
1872cdf0e10cSrcweir 		{
1873cdf0e10cSrcweir 		}
1874cdf0e10cSrcweir 		aIter++;
1875cdf0e10cSrcweir 	}
1876cdf0e10cSrcweir 	InvalidateRenderGeometry();
1877cdf0e10cSrcweir }
1878cdf0e10cSrcweir void SdrObjCustomShape::NbcRotate( const Point& rRef, long nWink, double sn, double cs )
1879cdf0e10cSrcweir {
1880cdf0e10cSrcweir 	sal_Bool bMirroredX = IsMirroredX();
1881cdf0e10cSrcweir 	sal_Bool bMirroredY = IsMirroredY();
1882cdf0e10cSrcweir 
1883cdf0e10cSrcweir 	fObjectRotation = fmod( fObjectRotation, 360.0 );
1884cdf0e10cSrcweir 	if ( fObjectRotation < 0 )
1885cdf0e10cSrcweir 		fObjectRotation = 360 + fObjectRotation;
1886cdf0e10cSrcweir 
1887cdf0e10cSrcweir 	// the rotation angle for ashapes is stored in fObjectRotation, this rotation
1888cdf0e10cSrcweir 	// has to be applied to the text object (which is internally using aGeo.nWink).
1889cdf0e10cSrcweir 	SdrTextObj::NbcRotate( aRect.TopLeft(), -aGeo.nDrehWink,		// retrieving the unrotated text object
1890cdf0e10cSrcweir 							sin( (-aGeo.nDrehWink) * F_PI18000 ),
1891cdf0e10cSrcweir 							cos( (-aGeo.nDrehWink) * F_PI18000 ) );
1892cdf0e10cSrcweir 	aGeo.nDrehWink = 0;												// resetting aGeo data
1893cdf0e10cSrcweir 	aGeo.RecalcSinCos();
1894cdf0e10cSrcweir 
1895cdf0e10cSrcweir 	long nW = (long)( fObjectRotation * 100 );						// applying our object rotation
1896cdf0e10cSrcweir 	if ( bMirroredX )
1897cdf0e10cSrcweir 		nW = 36000 - nW;
1898cdf0e10cSrcweir 	if ( bMirroredY )
1899cdf0e10cSrcweir 		nW = 18000 - nW;
1900cdf0e10cSrcweir 	nW = nW % 36000;
1901cdf0e10cSrcweir 	if ( nW < 0 )
1902cdf0e10cSrcweir 		nW = 36000 + nW;
1903cdf0e10cSrcweir 	SdrTextObj::NbcRotate( aRect.TopLeft(), nW,						// applying text rotation
1904cdf0e10cSrcweir 							sin( nW * F_PI18000 ),
1905cdf0e10cSrcweir 							cos( nW * F_PI18000 ) );
1906cdf0e10cSrcweir 
1907cdf0e10cSrcweir 	int nSwap = 0;
1908cdf0e10cSrcweir 	if ( bMirroredX )
1909cdf0e10cSrcweir 		nSwap ^= 1;
1910cdf0e10cSrcweir 	if ( bMirroredY )
1911cdf0e10cSrcweir 		nSwap ^= 1;
1912cdf0e10cSrcweir 
1913cdf0e10cSrcweir 	double fWink = nWink;													// updating to our new object rotation
1914cdf0e10cSrcweir 	fWink /= 100.0;
1915cdf0e10cSrcweir 	fObjectRotation = fmod( nSwap ? fObjectRotation - fWink : fObjectRotation + fWink, 360.0 );
1916cdf0e10cSrcweir 	if ( fObjectRotation < 0 )
1917cdf0e10cSrcweir 		fObjectRotation = 360 + fObjectRotation;
1918cdf0e10cSrcweir 
1919cdf0e10cSrcweir 	SdrTextObj::NbcRotate( rRef, nWink, sn, cs );							// applying text rotation
1920cdf0e10cSrcweir 	InvalidateRenderGeometry();
1921cdf0e10cSrcweir }
1922cdf0e10cSrcweir 
1923cdf0e10cSrcweir void SdrObjCustomShape::NbcMirror( const Point& rRef1, const Point& rRef2 )
1924cdf0e10cSrcweir {
19254334f1b5SArmin Le Grand     // TTTT: Fix for old mirroring, can be removed again in aw080
1926cdf0e10cSrcweir     // storing horizontal and vertical flipping without modifying the rotate angle
19274334f1b5SArmin Le Grand     // decompose other flipping to rotation and MirrorX.
19284334f1b5SArmin Le Grand     long ndx = rRef2.X()-rRef1.X();
19294334f1b5SArmin Le Grand     long ndy = rRef2.Y()-rRef1.Y();
1930cdf0e10cSrcweir 
19314334f1b5SArmin Le Grand     if(!ndx) // MirroredX
1932cdf0e10cSrcweir     {
19334334f1b5SArmin Le Grand          SetMirroredX(!IsMirroredX());
1934cdf0e10cSrcweir          SdrTextObj::NbcMirror( rRef1, rRef2 );
19354334f1b5SArmin Le Grand     }
19364334f1b5SArmin Le Grand     else
19374334f1b5SArmin Le Grand     {
19384334f1b5SArmin Le Grand         if(!ndy)  // MirroredY
19394334f1b5SArmin Le Grand         {
19404334f1b5SArmin Le Grand             SetMirroredY(!IsMirroredY());
19414334f1b5SArmin Le Grand             SdrTextObj::NbcMirror( rRef1, rRef2 );
19424334f1b5SArmin Le Grand         }
19434334f1b5SArmin Le Grand         else // neither horizontal nor vertical
19444334f1b5SArmin Le Grand         {
19454334f1b5SArmin Le Grand             SetMirroredX(!IsMirroredX());
19464334f1b5SArmin Le Grand 
19474334f1b5SArmin Le Grand             // call parent
19484334f1b5SArmin Le Grand             SdrTextObj::NbcMirror( rRef1, rRef2 );
19494334f1b5SArmin Le Grand 
19504334f1b5SArmin Le Grand             // update fObjectRotation
19514334f1b5SArmin Le Grand             long nTextObjRotation = aGeo.nDrehWink;
19524334f1b5SArmin Le Grand             double fWink = nTextObjRotation;
19534334f1b5SArmin Le Grand 
19544334f1b5SArmin Le Grand             fWink /= 100.0;
19554334f1b5SArmin Le Grand 
19564334f1b5SArmin Le Grand             bool bSingleFlip = (IsMirroredX()!= IsMirroredY());
19574334f1b5SArmin Le Grand 
19584334f1b5SArmin Le Grand             fObjectRotation = fmod( bSingleFlip ? -fWink : fWink, 360.0 );
19594334f1b5SArmin Le Grand 
19604334f1b5SArmin Le Grand             if ( fObjectRotation < 0 )
19614334f1b5SArmin Le Grand             {
19624334f1b5SArmin Le Grand                 fObjectRotation = 360.0 + fObjectRotation;
19634334f1b5SArmin Le Grand             }
19644334f1b5SArmin Le Grand          }
19654334f1b5SArmin Le Grand     }
19664334f1b5SArmin Le Grand 
1967cdf0e10cSrcweir     InvalidateRenderGeometry();
1968cdf0e10cSrcweir }
1969cdf0e10cSrcweir 
1970cdf0e10cSrcweir void SdrObjCustomShape::Shear( const Point& rRef, long nWink, double tn, FASTBOOL bVShear )
1971cdf0e10cSrcweir {
1972cdf0e10cSrcweir 	SdrTextObj::Shear( rRef, nWink, tn, bVShear );
1973cdf0e10cSrcweir 	InvalidateRenderGeometry();
1974cdf0e10cSrcweir }
1975cdf0e10cSrcweir void SdrObjCustomShape::NbcShear( const Point& rRef, long nWink, double tn, FASTBOOL bVShear )
1976cdf0e10cSrcweir {
19774334f1b5SArmin Le Grand     // TTTT: Fix for old mirroring, can be removed again in aw080
1978cdf0e10cSrcweir      SdrTextObj::NbcShear(rRef,nWink,tn,bVShear);
19794334f1b5SArmin Le Grand 
19804334f1b5SArmin Le Grand     // updating fObjectRotation
19814334f1b5SArmin Le Grand     long nTextObjRotation = aGeo.nDrehWink;
19824334f1b5SArmin Le Grand     double fWink = nTextObjRotation;
19834334f1b5SArmin Le Grand 
19844334f1b5SArmin Le Grand     fWink /= 100.0;
19854334f1b5SArmin Le Grand 
19864334f1b5SArmin Le Grand     bool bSingleFlip = (IsMirroredX()!= IsMirroredY());
19874334f1b5SArmin Le Grand 
19884334f1b5SArmin Le Grand     fObjectRotation = fmod( bSingleFlip ? -fWink : fWink, 360.0 );
19894334f1b5SArmin Le Grand 
19904334f1b5SArmin Le Grand     if ( fObjectRotation < 0 )
1991cdf0e10cSrcweir     {
19924334f1b5SArmin Le Grand         fObjectRotation = 360.0 + fObjectRotation;
1993cdf0e10cSrcweir     }
19944334f1b5SArmin Le Grand 
1995cdf0e10cSrcweir     InvalidateRenderGeometry();
1996cdf0e10cSrcweir }
1997cdf0e10cSrcweir 
1998cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
1999cdf0e10cSrcweir 
2000cdf0e10cSrcweir SdrGluePoint SdrObjCustomShape::GetVertexGluePoint(sal_uInt16 nPosNum) const
2001cdf0e10cSrcweir {
2002cdf0e10cSrcweir 	sal_Int32 nWdt = ImpGetLineWdt(); // #i25616# ((XLineWidthItem&)(GetObjectItem(XATTR_LINEWIDTH))).GetValue();
2003cdf0e10cSrcweir 
2004cdf0e10cSrcweir 	// #i25616#
2005cdf0e10cSrcweir 	if(!LineIsOutsideGeometry())
2006cdf0e10cSrcweir 	{
2007cdf0e10cSrcweir 		nWdt++;
2008cdf0e10cSrcweir 		nWdt /= 2;
2009cdf0e10cSrcweir 	}
2010cdf0e10cSrcweir 
2011cdf0e10cSrcweir 	Point aPt;
2012cdf0e10cSrcweir 	switch (nPosNum) {
2013cdf0e10cSrcweir 		case 0: aPt=aRect.TopCenter();    aPt.Y()-=nWdt; break;
2014cdf0e10cSrcweir 		case 1: aPt=aRect.RightCenter();  aPt.X()+=nWdt; break;
2015cdf0e10cSrcweir 		case 2: aPt=aRect.BottomCenter(); aPt.Y()+=nWdt; break;
2016cdf0e10cSrcweir 		case 3: aPt=aRect.LeftCenter();   aPt.X()-=nWdt; break;
2017cdf0e10cSrcweir 	}
2018cdf0e10cSrcweir 	if (aGeo.nShearWink!=0) ShearPoint(aPt,aRect.TopLeft(),aGeo.nTan);
2019cdf0e10cSrcweir 	if (aGeo.nDrehWink!=0) RotatePoint(aPt,aRect.TopLeft(),aGeo.nSin,aGeo.nCos);
2020cdf0e10cSrcweir 	aPt-=GetSnapRect().Center();
2021cdf0e10cSrcweir 	SdrGluePoint aGP(aPt);
2022cdf0e10cSrcweir 	aGP.SetPercent(sal_False);
2023cdf0e10cSrcweir 	return aGP;
2024cdf0e10cSrcweir }
2025cdf0e10cSrcweir 
2026cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
2027cdf0e10cSrcweir 
2028cdf0e10cSrcweir // #i38892#
2029cdf0e10cSrcweir void SdrObjCustomShape::ImpCheckCustomGluePointsAreAdded()
2030cdf0e10cSrcweir {
2031cdf0e10cSrcweir 	const SdrObject* pSdrObject = GetSdrObjectFromCustomShape();
2032cdf0e10cSrcweir 
2033cdf0e10cSrcweir 	if(pSdrObject)
2034cdf0e10cSrcweir 	{
2035cdf0e10cSrcweir 		const SdrGluePointList* pSource = pSdrObject->GetGluePointList();
2036cdf0e10cSrcweir 
2037cdf0e10cSrcweir 		if(pSource && pSource->GetCount())
2038cdf0e10cSrcweir 		{
2039cdf0e10cSrcweir 			if(!SdrTextObj::GetGluePointList())
2040cdf0e10cSrcweir 			{
2041cdf0e10cSrcweir 				SdrTextObj::ForceGluePointList();
2042cdf0e10cSrcweir 			}
2043cdf0e10cSrcweir 
2044cdf0e10cSrcweir 			const SdrGluePointList* pList = SdrTextObj::GetGluePointList();
2045cdf0e10cSrcweir 
2046cdf0e10cSrcweir 			if(pList)
2047cdf0e10cSrcweir 			{
2048cdf0e10cSrcweir 				SdrGluePointList aNewList;
2049cdf0e10cSrcweir 				sal_uInt16 a;
2050cdf0e10cSrcweir 
2051cdf0e10cSrcweir 				for(a = 0; a < pSource->GetCount(); a++)
2052cdf0e10cSrcweir 				{
2053cdf0e10cSrcweir 					SdrGluePoint aCopy((*pSource)[a]);
2054cdf0e10cSrcweir 					aCopy.SetUserDefined(sal_False);
2055cdf0e10cSrcweir 					aNewList.Insert(aCopy);
2056cdf0e10cSrcweir 				}
2057cdf0e10cSrcweir 
2058cdf0e10cSrcweir 				sal_Bool bMirroredX = IsMirroredX();
2059cdf0e10cSrcweir 				sal_Bool bMirroredY = IsMirroredY();
2060cdf0e10cSrcweir 
2061cdf0e10cSrcweir 				long nShearWink = aGeo.nShearWink;
2062cdf0e10cSrcweir 				double fTan = aGeo.nTan;
2063cdf0e10cSrcweir 
2064cdf0e10cSrcweir 				if ( aGeo.nDrehWink || nShearWink || bMirroredX || bMirroredY )
2065cdf0e10cSrcweir 				{
2066cdf0e10cSrcweir 					Polygon aPoly( aRect );
2067cdf0e10cSrcweir 					if( nShearWink )
2068cdf0e10cSrcweir 					{
2069cdf0e10cSrcweir 						sal_uInt16 nPointCount=aPoly.GetSize();
2070cdf0e10cSrcweir 						for (sal_uInt16 i=0; i<nPointCount; i++)
2071cdf0e10cSrcweir 							ShearPoint(aPoly[i],aRect.Center(), fTan, sal_False );
2072cdf0e10cSrcweir 					}
2073cdf0e10cSrcweir 					if ( aGeo.nDrehWink )
2074cdf0e10cSrcweir 						aPoly.Rotate( aRect.Center(), aGeo.nDrehWink / 10 );
2075cdf0e10cSrcweir 
2076cdf0e10cSrcweir 					Rectangle aBoundRect( aPoly.GetBoundRect() );
2077cdf0e10cSrcweir 					sal_Int32 nXDiff = aBoundRect.Left() - aRect.Left();
2078cdf0e10cSrcweir 					sal_Int32 nYDiff = aBoundRect.Top() - aRect.Top();
2079cdf0e10cSrcweir 
2080cdf0e10cSrcweir 					if (nShearWink&&((bMirroredX&&!bMirroredY)||(bMirroredY&&!bMirroredX)))
2081cdf0e10cSrcweir 					{
2082cdf0e10cSrcweir 						nShearWink = -nShearWink;
2083cdf0e10cSrcweir 						fTan = -fTan;
2084cdf0e10cSrcweir 					}
2085cdf0e10cSrcweir 
2086cdf0e10cSrcweir 					Point aRef( aRect.GetWidth() / 2, aRect.GetHeight() / 2 );
2087cdf0e10cSrcweir 					for ( a = 0; a < aNewList.GetCount(); a++ )
2088cdf0e10cSrcweir 					{
2089cdf0e10cSrcweir 						SdrGluePoint& rPoint = aNewList[ a ];
2090cdf0e10cSrcweir 						Point aGlue( rPoint.GetPos() );
2091cdf0e10cSrcweir 						if ( nShearWink )
2092cdf0e10cSrcweir 							ShearPoint( aGlue, aRef, fTan );
2093cdf0e10cSrcweir 
2094cdf0e10cSrcweir 						RotatePoint( aGlue, aRef, sin( fObjectRotation * F_PI180 ), cos( fObjectRotation * F_PI180 ) );
2095cdf0e10cSrcweir 						if ( bMirroredX )
2096cdf0e10cSrcweir 							aGlue.X() = aRect.GetWidth() - aGlue.X();
2097cdf0e10cSrcweir 						if ( bMirroredY )
2098cdf0e10cSrcweir 							aGlue.Y() = aRect.GetHeight() - aGlue.Y();
2099cdf0e10cSrcweir 						aGlue.X() -= nXDiff;
2100cdf0e10cSrcweir 						aGlue.Y() -= nYDiff;
2101cdf0e10cSrcweir 						rPoint.SetPos( aGlue );
2102cdf0e10cSrcweir 					}
2103cdf0e10cSrcweir 				}
2104cdf0e10cSrcweir 
2105cdf0e10cSrcweir 				for(a = 0; a < pList->GetCount(); a++)
2106cdf0e10cSrcweir 				{
2107cdf0e10cSrcweir 					const SdrGluePoint& rCandidate = (*pList)[a];
2108cdf0e10cSrcweir 
2109cdf0e10cSrcweir 					if(rCandidate.IsUserDefined())
2110cdf0e10cSrcweir 					{
2111cdf0e10cSrcweir 						aNewList.Insert(rCandidate);
2112cdf0e10cSrcweir 					}
2113cdf0e10cSrcweir 				}
2114cdf0e10cSrcweir 
2115cdf0e10cSrcweir 				// copy new list to local. This is NOT very convenient behaviour, the local
2116cdf0e10cSrcweir 				// GluePointList should not be set, but be delivered by using GetGluePointList(),
2117cdf0e10cSrcweir 				// maybe on demand. Since the local object is changed here, this is assumed to
2118cdf0e10cSrcweir 				// be a result of GetGluePointList and thus the list is copied
2119cdf0e10cSrcweir 				if(pPlusData)
2120cdf0e10cSrcweir 				{
2121cdf0e10cSrcweir 					*pPlusData->pGluePoints = aNewList;
2122cdf0e10cSrcweir 				}
2123cdf0e10cSrcweir 			}
2124cdf0e10cSrcweir 		}
2125cdf0e10cSrcweir 	}
2126cdf0e10cSrcweir }
2127cdf0e10cSrcweir 
2128cdf0e10cSrcweir // #i38892#
2129cdf0e10cSrcweir const SdrGluePointList* SdrObjCustomShape::GetGluePointList() const
2130cdf0e10cSrcweir {
2131cdf0e10cSrcweir 	((SdrObjCustomShape*)this)->ImpCheckCustomGluePointsAreAdded();
2132cdf0e10cSrcweir 	return SdrTextObj::GetGluePointList();
2133cdf0e10cSrcweir }
2134cdf0e10cSrcweir 
2135cdf0e10cSrcweir // #i38892#
2136cdf0e10cSrcweir //SdrGluePointList* SdrObjCustomShape::GetGluePointList()
2137cdf0e10cSrcweir //{
2138cdf0e10cSrcweir //	ImpCheckCustomGluePointsAreAdded();
2139cdf0e10cSrcweir //	return SdrTextObj::GetGluePointList();
2140cdf0e10cSrcweir //}
2141cdf0e10cSrcweir 
2142cdf0e10cSrcweir // #i38892#
2143cdf0e10cSrcweir SdrGluePointList* SdrObjCustomShape::ForceGluePointList()
2144cdf0e10cSrcweir {
2145cdf0e10cSrcweir 	if(SdrTextObj::ForceGluePointList())
2146cdf0e10cSrcweir 	{
2147cdf0e10cSrcweir 		ImpCheckCustomGluePointsAreAdded();
2148cdf0e10cSrcweir 		return SdrTextObj::ForceGluePointList();
2149cdf0e10cSrcweir 	}
2150cdf0e10cSrcweir 	else
2151cdf0e10cSrcweir 	{
2152cdf0e10cSrcweir 		return 0L;
2153cdf0e10cSrcweir 	}
2154cdf0e10cSrcweir }
2155cdf0e10cSrcweir 
2156cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
2157cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
2158cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
2159cdf0e10cSrcweir 
2160cdf0e10cSrcweir sal_uInt32 SdrObjCustomShape::GetHdlCount() const
2161cdf0e10cSrcweir {
2162cdf0e10cSrcweir 	const sal_uInt32 nBasicHdlCount(SdrTextObj::GetHdlCount());
2163cdf0e10cSrcweir 	std::vector< SdrCustomShapeInteraction > aInteractionHandles( GetInteractionHandles( this ) );
2164cdf0e10cSrcweir 	return ( aInteractionHandles.size() + nBasicHdlCount );
2165cdf0e10cSrcweir }
2166cdf0e10cSrcweir 
2167cdf0e10cSrcweir SdrHdl* SdrObjCustomShape::GetHdl( sal_uInt32 nHdlNum ) const
2168cdf0e10cSrcweir {
2169cdf0e10cSrcweir 	SdrHdl* pH = NULL;
2170cdf0e10cSrcweir 	const sal_uInt32 nBasicHdlCount(SdrTextObj::GetHdlCount());
2171cdf0e10cSrcweir 
2172cdf0e10cSrcweir 	if ( nHdlNum < nBasicHdlCount )
2173cdf0e10cSrcweir 		pH = SdrTextObj::GetHdl( nHdlNum );
2174cdf0e10cSrcweir 	else
2175cdf0e10cSrcweir 	{
2176cdf0e10cSrcweir 		std::vector< SdrCustomShapeInteraction > aInteractionHandles( GetInteractionHandles( this ) );
2177cdf0e10cSrcweir 		const sal_uInt32 nCustomShapeHdlNum(nHdlNum - nBasicHdlCount);
2178cdf0e10cSrcweir 
2179cdf0e10cSrcweir 		if ( nCustomShapeHdlNum < aInteractionHandles.size() )
2180cdf0e10cSrcweir 		{
2181cdf0e10cSrcweir 			if ( aInteractionHandles[ nCustomShapeHdlNum ].xInteraction.is() )
2182cdf0e10cSrcweir 			{
2183cdf0e10cSrcweir 				try
2184cdf0e10cSrcweir 				{
2185cdf0e10cSrcweir 					com::sun::star::awt::Point aPosition( aInteractionHandles[ nCustomShapeHdlNum ].xInteraction->getPosition() );
2186cdf0e10cSrcweir 					pH = new SdrHdl( Point( aPosition.X, aPosition.Y ), HDL_CUSTOMSHAPE1 );
2187cdf0e10cSrcweir 					pH->SetPointNum( nCustomShapeHdlNum );
2188cdf0e10cSrcweir 					pH->SetObj( (SdrObject*)this );
2189cdf0e10cSrcweir 				}
2190cdf0e10cSrcweir 				catch ( const uno::RuntimeException& )
2191cdf0e10cSrcweir 				{
2192cdf0e10cSrcweir 				}
2193cdf0e10cSrcweir 			}
2194cdf0e10cSrcweir 		}
2195cdf0e10cSrcweir 	}
2196cdf0e10cSrcweir 	return pH;
2197cdf0e10cSrcweir }
2198cdf0e10cSrcweir 
2199cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
2200cdf0e10cSrcweir 
2201cdf0e10cSrcweir bool SdrObjCustomShape::hasSpecialDrag() const
2202cdf0e10cSrcweir {
2203cdf0e10cSrcweir 	return true;
2204cdf0e10cSrcweir }
2205cdf0e10cSrcweir 
2206cdf0e10cSrcweir bool SdrObjCustomShape::beginSpecialDrag(SdrDragStat& rDrag) const
2207cdf0e10cSrcweir {
2208cdf0e10cSrcweir 	const SdrHdl* pHdl = rDrag.GetHdl();
2209cdf0e10cSrcweir 
2210cdf0e10cSrcweir     if(pHdl && HDL_CUSTOMSHAPE1 == pHdl->GetKind())
2211cdf0e10cSrcweir 	{
2212cdf0e10cSrcweir 		rDrag.SetEndDragChangesAttributes(true);
2213cdf0e10cSrcweir 		rDrag.SetNoSnap(true);
2214cdf0e10cSrcweir 	}
2215cdf0e10cSrcweir 	else
2216cdf0e10cSrcweir 	{
2217cdf0e10cSrcweir 		const SdrHdl* pHdl2 = rDrag.GetHdl();
2218cdf0e10cSrcweir 		const SdrHdlKind eHdl((pHdl2 == NULL) ? HDL_MOVE : pHdl2->GetKind());
2219cdf0e10cSrcweir 
2220cdf0e10cSrcweir         switch( eHdl )
2221cdf0e10cSrcweir 		{
2222cdf0e10cSrcweir 			case HDL_UPLFT :
2223cdf0e10cSrcweir 			case HDL_UPPER :
2224cdf0e10cSrcweir 			case HDL_UPRGT :
2225cdf0e10cSrcweir 			case HDL_LEFT  :
2226cdf0e10cSrcweir 			case HDL_RIGHT :
2227cdf0e10cSrcweir 			case HDL_LWLFT :
2228cdf0e10cSrcweir 			case HDL_LOWER :
2229cdf0e10cSrcweir 			case HDL_LWRGT :
2230cdf0e10cSrcweir 			case HDL_MOVE  :
2231cdf0e10cSrcweir 			{
2232cdf0e10cSrcweir     			break;
2233cdf0e10cSrcweir 			}
2234cdf0e10cSrcweir 			default:
2235cdf0e10cSrcweir             {
2236cdf0e10cSrcweir 				return false;
2237cdf0e10cSrcweir             }
2238cdf0e10cSrcweir 		}
2239cdf0e10cSrcweir 	}
2240cdf0e10cSrcweir 
2241cdf0e10cSrcweir     return true;
2242cdf0e10cSrcweir }
2243cdf0e10cSrcweir 
2244cdf0e10cSrcweir void SdrObjCustomShape::DragResizeCustomShape( const Rectangle& rNewRect, SdrObjCustomShape* pObj ) const
2245cdf0e10cSrcweir {
2246cdf0e10cSrcweir 	Rectangle	aOld( pObj->aRect );
2247cdf0e10cSrcweir 	sal_Bool	bOldMirroredX( pObj->IsMirroredX() );
2248cdf0e10cSrcweir 	sal_Bool	bOldMirroredY( pObj->IsMirroredY() );
2249cdf0e10cSrcweir 
2250cdf0e10cSrcweir 	Rectangle aNewRect( rNewRect );
2251cdf0e10cSrcweir 	aNewRect.Justify();
2252cdf0e10cSrcweir 
2253cdf0e10cSrcweir 	std::vector< SdrCustomShapeInteraction > aInteractionHandles( GetInteractionHandles( pObj ) );
2254cdf0e10cSrcweir 
2255cdf0e10cSrcweir 	GeoStat aGeoStat( pObj->GetGeoStat() );
2256cdf0e10cSrcweir 	if ( aNewRect.TopLeft()!= pObj->aRect.TopLeft() &&
2257cdf0e10cSrcweir 		( pObj->aGeo.nDrehWink || pObj->aGeo.nShearWink ) )
2258cdf0e10cSrcweir 	{
2259cdf0e10cSrcweir 		Point aNewPos( aNewRect.TopLeft() );
2260cdf0e10cSrcweir 		if ( pObj->aGeo.nShearWink ) ShearPoint( aNewPos, aOld.TopLeft(), aGeoStat.nTan );
2261cdf0e10cSrcweir 		if ( pObj->aGeo.nDrehWink )  RotatePoint(aNewPos, aOld.TopLeft(), aGeoStat.nSin, aGeoStat.nCos );
2262cdf0e10cSrcweir 		aNewRect.SetPos( aNewPos );
2263cdf0e10cSrcweir 	}
2264cdf0e10cSrcweir 	if ( aNewRect != pObj->aRect )
2265cdf0e10cSrcweir 	{
2266cdf0e10cSrcweir 		pObj->SetLogicRect( aNewRect );
2267cdf0e10cSrcweir 		pObj->InvalidateRenderGeometry();
2268cdf0e10cSrcweir 
2269cdf0e10cSrcweir 		if ( rNewRect.Left() > rNewRect.Right() )
2270cdf0e10cSrcweir 		{
2271cdf0e10cSrcweir 			Point aTop( ( pObj->GetSnapRect().Left() + pObj->GetSnapRect().Right() ) >> 1, pObj->GetSnapRect().Top() );
2272cdf0e10cSrcweir 			Point aBottom( aTop.X(), aTop.Y() + 1000 );
2273cdf0e10cSrcweir 			pObj->NbcMirror( aTop, aBottom );
2274cdf0e10cSrcweir 		}
2275cdf0e10cSrcweir 		if ( rNewRect.Top() > rNewRect.Bottom() )
2276cdf0e10cSrcweir 		{
2277cdf0e10cSrcweir 			Point aLeft( pObj->GetSnapRect().Left(), ( pObj->GetSnapRect().Top() + pObj->GetSnapRect().Bottom() ) >> 1 );
2278cdf0e10cSrcweir 			Point aRight( aLeft.X() + 1000, aLeft.Y() );
2279cdf0e10cSrcweir 			pObj->NbcMirror( aLeft, aRight );
2280cdf0e10cSrcweir 		}
2281cdf0e10cSrcweir 
2282cdf0e10cSrcweir 		std::vector< SdrCustomShapeInteraction >::iterator aIter( aInteractionHandles.begin() );
2283cdf0e10cSrcweir 		while ( aIter != aInteractionHandles.end() )
2284cdf0e10cSrcweir 		{
2285cdf0e10cSrcweir 			try
2286cdf0e10cSrcweir 			{
2287cdf0e10cSrcweir 				if ( aIter->nMode & CUSTOMSHAPE_HANDLE_RESIZE_FIXED )
2288cdf0e10cSrcweir 					aIter->xInteraction->setControllerPosition( aIter->aPosition );
2289cdf0e10cSrcweir 				if ( aIter->nMode & CUSTOMSHAPE_HANDLE_RESIZE_ABSOLUTE_X )
2290cdf0e10cSrcweir 				{
2291cdf0e10cSrcweir 					sal_Int32 nX;
2292cdf0e10cSrcweir 					if ( bOldMirroredX )
2293cdf0e10cSrcweir 					{
2294cdf0e10cSrcweir 						nX = ( aIter->aPosition.X - aOld.Right() );
2295cdf0e10cSrcweir 						if ( rNewRect.Left() > rNewRect.Right() )
2296cdf0e10cSrcweir 							nX = pObj->aRect.Left() - nX;
2297cdf0e10cSrcweir 						else
2298cdf0e10cSrcweir 							nX += pObj->aRect.Right();
2299cdf0e10cSrcweir 					}
2300cdf0e10cSrcweir 					else
2301cdf0e10cSrcweir 					{
2302cdf0e10cSrcweir 						nX = ( aIter->aPosition.X - aOld.Left() );
2303cdf0e10cSrcweir 						if ( rNewRect.Left() > rNewRect.Right() )
2304cdf0e10cSrcweir 							nX = pObj->aRect.Right() - nX;
2305cdf0e10cSrcweir 						else
2306cdf0e10cSrcweir 							nX += pObj->aRect.Left();
2307cdf0e10cSrcweir 					}
2308cdf0e10cSrcweir 					aIter->xInteraction->setControllerPosition( com::sun::star::awt::Point( nX, aIter->xInteraction->getPosition().Y ) );
2309cdf0e10cSrcweir 				}
2310cdf0e10cSrcweir 				if ( aIter->nMode & CUSTOMSHAPE_HANDLE_RESIZE_ABSOLUTE_Y )
2311cdf0e10cSrcweir 				{
2312cdf0e10cSrcweir 					sal_Int32 nY;
2313cdf0e10cSrcweir 					if ( bOldMirroredY )
2314cdf0e10cSrcweir 					{
2315cdf0e10cSrcweir 						nY = ( aIter->aPosition.Y - aOld.Bottom() );
2316cdf0e10cSrcweir 						if ( rNewRect.Top() > rNewRect.Bottom() )
2317cdf0e10cSrcweir 							nY = pObj->aRect.Top() - nY;
2318cdf0e10cSrcweir 						else
2319cdf0e10cSrcweir 							nY += pObj->aRect.Bottom();
2320cdf0e10cSrcweir 					}
2321cdf0e10cSrcweir 					else
2322cdf0e10cSrcweir 					{
2323cdf0e10cSrcweir 						nY = ( aIter->aPosition.Y - aOld.Top() );
2324cdf0e10cSrcweir 						if ( rNewRect.Top() > rNewRect.Bottom() )
2325cdf0e10cSrcweir 							nY = pObj->aRect.Bottom() - nY;
2326cdf0e10cSrcweir 						else
2327cdf0e10cSrcweir 							nY += pObj->aRect.Top();
2328cdf0e10cSrcweir 					}
2329cdf0e10cSrcweir 					aIter->xInteraction->setControllerPosition( com::sun::star::awt::Point( aIter->xInteraction->getPosition().X, nY ) );
2330cdf0e10cSrcweir 				}
2331cdf0e10cSrcweir 			}
2332cdf0e10cSrcweir 			catch ( const uno::RuntimeException& )
2333cdf0e10cSrcweir 			{
2334cdf0e10cSrcweir 			}
2335cdf0e10cSrcweir 			aIter++;
2336cdf0e10cSrcweir 		}
2337cdf0e10cSrcweir 	}
2338cdf0e10cSrcweir }
2339cdf0e10cSrcweir 
2340cdf0e10cSrcweir void SdrObjCustomShape::DragMoveCustomShapeHdl( const Point aDestination, const sal_uInt16 nCustomShapeHdlNum, SdrObjCustomShape* pObj ) const
2341cdf0e10cSrcweir {
2342cdf0e10cSrcweir 	std::vector< SdrCustomShapeInteraction > aInteractionHandles( GetInteractionHandles( pObj ) );
2343cdf0e10cSrcweir 	if ( nCustomShapeHdlNum < aInteractionHandles.size() )
2344cdf0e10cSrcweir 	{
2345cdf0e10cSrcweir 		SdrCustomShapeInteraction aInteractionHandle( aInteractionHandles[ nCustomShapeHdlNum ] );
2346cdf0e10cSrcweir 		if ( aInteractionHandle.xInteraction.is() )
2347cdf0e10cSrcweir 		{
2348cdf0e10cSrcweir 			try
2349cdf0e10cSrcweir 			{
2350cdf0e10cSrcweir 				com::sun::star::awt::Point aPt( aDestination.X(), aDestination.Y() );
2351cdf0e10cSrcweir 				if ( aInteractionHandle.nMode & CUSTOMSHAPE_HANDLE_MOVE_SHAPE )
2352cdf0e10cSrcweir 				{
2353cdf0e10cSrcweir 					sal_Int32 nXDiff = aPt.X - aInteractionHandle.aPosition.X;
2354cdf0e10cSrcweir 					sal_Int32 nYDiff = aPt.Y - aInteractionHandle.aPosition.Y;
2355cdf0e10cSrcweir 
2356cdf0e10cSrcweir 					pObj->aRect.Move( nXDiff, nYDiff );
2357cdf0e10cSrcweir 					pObj->aOutRect.Move( nXDiff, nYDiff );
2358cdf0e10cSrcweir 					pObj->maSnapRect.Move( nXDiff, nYDiff );
2359cdf0e10cSrcweir 					pObj->SetRectsDirty(sal_True);
2360cdf0e10cSrcweir 					pObj->InvalidateRenderGeometry();
2361cdf0e10cSrcweir 
2362cdf0e10cSrcweir 					std::vector< SdrCustomShapeInteraction >::iterator aIter( aInteractionHandles.begin() );
2363cdf0e10cSrcweir 					while ( aIter != aInteractionHandles.end() )
2364cdf0e10cSrcweir 					{
2365cdf0e10cSrcweir 						if ( aIter->nMode & CUSTOMSHAPE_HANDLE_RESIZE_FIXED )
2366cdf0e10cSrcweir 						{
2367cdf0e10cSrcweir 							if ( aIter->xInteraction.is() )
2368cdf0e10cSrcweir 								aIter->xInteraction->setControllerPosition( aIter->aPosition );
2369cdf0e10cSrcweir 						}
2370cdf0e10cSrcweir 						aIter++;
2371cdf0e10cSrcweir 					}
2372cdf0e10cSrcweir 				}
2373cdf0e10cSrcweir 				aInteractionHandle.xInteraction->setControllerPosition( aPt );
2374cdf0e10cSrcweir 			}
2375cdf0e10cSrcweir 			catch ( const uno::RuntimeException& )
2376cdf0e10cSrcweir 			{
2377cdf0e10cSrcweir 			}
2378cdf0e10cSrcweir 		}
2379cdf0e10cSrcweir 	}
2380cdf0e10cSrcweir }
2381cdf0e10cSrcweir 
2382cdf0e10cSrcweir bool SdrObjCustomShape::applySpecialDrag(SdrDragStat& rDrag)
2383cdf0e10cSrcweir {
2384cdf0e10cSrcweir 	const SdrHdl* pHdl = rDrag.GetHdl();
2385cdf0e10cSrcweir 	const SdrHdlKind eHdl((pHdl == NULL) ? HDL_MOVE : pHdl->GetKind());
2386cdf0e10cSrcweir 
2387cdf0e10cSrcweir     switch(eHdl)
2388cdf0e10cSrcweir 	{
2389cdf0e10cSrcweir 		case HDL_CUSTOMSHAPE1 :
2390cdf0e10cSrcweir 		{
2391cdf0e10cSrcweir 			rDrag.SetEndDragChangesGeoAndAttributes(true);
2392cdf0e10cSrcweir 		    DragMoveCustomShapeHdl( rDrag.GetNow(), (sal_uInt16)pHdl->GetPointNum(), this );
2393cdf0e10cSrcweir 		    SetRectsDirty();
2394cdf0e10cSrcweir 		    InvalidateRenderGeometry();
2395cdf0e10cSrcweir 		    SetChanged();
2396cdf0e10cSrcweir             break;
2397cdf0e10cSrcweir 		}
2398cdf0e10cSrcweir 
2399cdf0e10cSrcweir 		case HDL_UPLFT :
2400cdf0e10cSrcweir 		case HDL_UPPER :
2401cdf0e10cSrcweir 		case HDL_UPRGT :
2402cdf0e10cSrcweir 		case HDL_LEFT  :
2403cdf0e10cSrcweir 		case HDL_RIGHT :
2404cdf0e10cSrcweir 		case HDL_LWLFT :
2405cdf0e10cSrcweir 		case HDL_LOWER :
2406cdf0e10cSrcweir 		case HDL_LWRGT :
2407cdf0e10cSrcweir 		{
2408cdf0e10cSrcweir 			DragResizeCustomShape(ImpDragCalcRect(rDrag), this);
2409cdf0e10cSrcweir 			break;
2410cdf0e10cSrcweir 		}
2411cdf0e10cSrcweir 		case HDL_MOVE :
2412cdf0e10cSrcweir 		{
2413cdf0e10cSrcweir 			Move(Size(rDrag.GetDX(), rDrag.GetDY()));
2414cdf0e10cSrcweir 			break;
2415cdf0e10cSrcweir 		}
2416cdf0e10cSrcweir 		default: break;
2417cdf0e10cSrcweir 	}
2418cdf0e10cSrcweir 
2419cdf0e10cSrcweir     return true;
2420cdf0e10cSrcweir }
2421cdf0e10cSrcweir 
2422cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
2423cdf0e10cSrcweir 
2424cdf0e10cSrcweir void SdrObjCustomShape::DragCreateObject( SdrDragStat& rStat )
2425cdf0e10cSrcweir {
2426cdf0e10cSrcweir 	Rectangle aRect1;
2427cdf0e10cSrcweir 	rStat.TakeCreateRect( aRect1 );
2428cdf0e10cSrcweir 
2429cdf0e10cSrcweir 	std::vector< SdrCustomShapeInteraction > aInteractionHandles( GetInteractionHandles( this ) );
2430cdf0e10cSrcweir 
2431cdf0e10cSrcweir 	sal_uInt32 nDefaultObjectSizeWidth = 3000;		// default width from SDOptions ?
2432cdf0e10cSrcweir 	sal_uInt32 nDefaultObjectSizeHeight= 3000;
2433cdf0e10cSrcweir 
2434cdf0e10cSrcweir 	if ( ImpVerticalSwitch( *this ) )
2435cdf0e10cSrcweir 	{
2436cdf0e10cSrcweir 		SetMirroredX( aRect1.Left() > aRect1.Right() );
2437cdf0e10cSrcweir 
2438cdf0e10cSrcweir 		aRect1 = Rectangle( rStat.GetNow(), Size( nDefaultObjectSizeWidth, nDefaultObjectSizeHeight ) );
2439cdf0e10cSrcweir 		// subtracting the horizontal difference of the latest handle from shape position
2440cdf0e10cSrcweir 		if ( !aInteractionHandles.empty() )
2441cdf0e10cSrcweir 		{
2442cdf0e10cSrcweir 			sal_Int32 nHandlePos = aInteractionHandles[ aInteractionHandles.size() - 1 ].xInteraction->getPosition().X;
2443cdf0e10cSrcweir 			aRect1.Move( aRect.Left() - nHandlePos, 0 );
2444cdf0e10cSrcweir 		}
2445cdf0e10cSrcweir 	}
2446cdf0e10cSrcweir 	ImpJustifyRect( aRect1 );
2447cdf0e10cSrcweir 	rStat.SetActionRect( aRect1 );
2448cdf0e10cSrcweir 	aRect = aRect1;
2449cdf0e10cSrcweir 	SetRectsDirty();
2450cdf0e10cSrcweir 
2451cdf0e10cSrcweir 	std::vector< SdrCustomShapeInteraction >::iterator aIter( aInteractionHandles.begin() );
2452cdf0e10cSrcweir 	while ( aIter != aInteractionHandles.end() )
2453cdf0e10cSrcweir 	{
2454cdf0e10cSrcweir 		try
2455cdf0e10cSrcweir 		{
2456cdf0e10cSrcweir 			if ( aIter->nMode & CUSTOMSHAPE_HANDLE_CREATE_FIXED )
2457cdf0e10cSrcweir 				aIter->xInteraction->setControllerPosition( awt::Point( rStat.GetStart().X(), rStat.GetStart().Y() ) );
2458cdf0e10cSrcweir 		}
2459cdf0e10cSrcweir 		catch ( const uno::RuntimeException& )
2460cdf0e10cSrcweir 		{
2461cdf0e10cSrcweir 		}
2462cdf0e10cSrcweir 		aIter++;
2463cdf0e10cSrcweir 	}
2464cdf0e10cSrcweir 
2465cdf0e10cSrcweir 	SetBoundRectDirty();
2466cdf0e10cSrcweir 	bSnapRectDirty=sal_True;
2467cdf0e10cSrcweir }
2468cdf0e10cSrcweir 
2469cdf0e10cSrcweir FASTBOOL SdrObjCustomShape::BegCreate( SdrDragStat& rDrag )
2470cdf0e10cSrcweir {
2471cdf0e10cSrcweir 	return SdrTextObj::BegCreate( rDrag );
2472cdf0e10cSrcweir }
2473cdf0e10cSrcweir 
2474cdf0e10cSrcweir FASTBOOL SdrObjCustomShape::MovCreate(SdrDragStat& rStat)
2475cdf0e10cSrcweir {
2476cdf0e10cSrcweir 	SdrView* pView = rStat.GetView();		// #i37448#
2477cdf0e10cSrcweir 	if( pView && pView->IsSolidDragging() )
2478cdf0e10cSrcweir 	{
2479cdf0e10cSrcweir 		InvalidateRenderGeometry();
2480cdf0e10cSrcweir 	}
2481cdf0e10cSrcweir 	DragCreateObject( rStat );
2482cdf0e10cSrcweir 	SetRectsDirty();
2483cdf0e10cSrcweir 	return sal_True;
2484cdf0e10cSrcweir }
2485cdf0e10cSrcweir 
2486cdf0e10cSrcweir FASTBOOL SdrObjCustomShape::EndCreate( SdrDragStat& rStat, SdrCreateCmd eCmd )
2487cdf0e10cSrcweir {
2488cdf0e10cSrcweir 	DragCreateObject( rStat );
2489cdf0e10cSrcweir 
2490cdf0e10cSrcweir 	if ( bTextFrame )
2491cdf0e10cSrcweir 	{
2492cdf0e10cSrcweir 		if ( IsAutoGrowHeight() )
2493cdf0e10cSrcweir 		{
2494cdf0e10cSrcweir 			// MinTextHeight
2495cdf0e10cSrcweir 			long nHgt=aRect.GetHeight()-1;
2496cdf0e10cSrcweir 			if (nHgt==1) nHgt=0;
2497cdf0e10cSrcweir 			NbcSetMinTextFrameHeight( nHgt );
2498cdf0e10cSrcweir 		}
2499cdf0e10cSrcweir 		if ( IsAutoGrowWidth() )
2500cdf0e10cSrcweir 		{
2501cdf0e10cSrcweir 			// MinTextWidth
2502cdf0e10cSrcweir 			long nWdt=aRect.GetWidth()-1;
2503cdf0e10cSrcweir 			if (nWdt==1) nWdt=0;
2504cdf0e10cSrcweir 			NbcSetMinTextFrameWidth( nWdt );
2505cdf0e10cSrcweir 		}
2506cdf0e10cSrcweir 		// Textrahmen neu berechnen
2507cdf0e10cSrcweir 		NbcAdjustTextFrameWidthAndHeight();
2508cdf0e10cSrcweir 	}
2509cdf0e10cSrcweir 	SetRectsDirty();
2510cdf0e10cSrcweir 	return ( eCmd == SDRCREATE_FORCEEND || rStat.GetPointAnz() >= 2 );
2511cdf0e10cSrcweir }
2512cdf0e10cSrcweir 
2513cdf0e10cSrcweir basegfx::B2DPolyPolygon SdrObjCustomShape::TakeCreatePoly(const SdrDragStat& /*rDrag*/) const
2514cdf0e10cSrcweir {
2515cdf0e10cSrcweir 	return GetLineGeometry( this, sal_False );
2516cdf0e10cSrcweir }
2517cdf0e10cSrcweir 
2518cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
2519cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
2520cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
2521cdf0e10cSrcweir 
2522cdf0e10cSrcweir // in context with the SdrObjCustomShape the SdrTextAutoGrowHeightItem == true -> Resize Shape to fit text,
2523cdf0e10cSrcweir //									   the SdrTextAutoGrowWidthItem  == true -> Word wrap text in Shape
2524cdf0e10cSrcweir FASTBOOL SdrObjCustomShape::IsAutoGrowHeight() const
2525cdf0e10cSrcweir {
2526cdf0e10cSrcweir 	const SfxItemSet& rSet = GetMergedItemSet();
2527cdf0e10cSrcweir 	FASTBOOL bIsAutoGrowHeight = ((SdrTextAutoGrowHeightItem&)(rSet.Get(SDRATTR_TEXT_AUTOGROWHEIGHT))).GetValue();
2528cdf0e10cSrcweir 	if ( bIsAutoGrowHeight && IsVerticalWriting() )
2529cdf0e10cSrcweir 		bIsAutoGrowHeight = ((SdrTextWordWrapItem&)(rSet.Get(SDRATTR_TEXT_WORDWRAP))).GetValue() == sal_False;
2530cdf0e10cSrcweir 	return bIsAutoGrowHeight;
2531cdf0e10cSrcweir }
2532cdf0e10cSrcweir FASTBOOL SdrObjCustomShape::IsAutoGrowWidth() const
2533cdf0e10cSrcweir {
2534cdf0e10cSrcweir 	const SfxItemSet& rSet = GetMergedItemSet();
2535cdf0e10cSrcweir 	FASTBOOL bIsAutoGrowWidth = ((SdrTextAutoGrowHeightItem&)(rSet.Get(SDRATTR_TEXT_AUTOGROWHEIGHT))).GetValue();
2536cdf0e10cSrcweir 	if ( bIsAutoGrowWidth && !IsVerticalWriting() )
2537cdf0e10cSrcweir 		bIsAutoGrowWidth = ((SdrTextWordWrapItem&)(rSet.Get(SDRATTR_TEXT_WORDWRAP))).GetValue() == sal_False;
2538cdf0e10cSrcweir 	return bIsAutoGrowWidth;
2539cdf0e10cSrcweir }
2540cdf0e10cSrcweir 
2541cdf0e10cSrcweir /* The following method is identical to the SdrTextObj::SetVerticalWriting method, the only difference
2542cdf0e10cSrcweir    is that the SdrAutoGrowWidthItem and SdrAutoGrowHeightItem are not exchanged if the vertical writing
2543cdf0e10cSrcweir    mode has been changed */
2544cdf0e10cSrcweir 
2545cdf0e10cSrcweir void SdrObjCustomShape::SetVerticalWriting( sal_Bool bVertical )
2546cdf0e10cSrcweir {
2547cdf0e10cSrcweir 	ForceOutlinerParaObject();
2548cdf0e10cSrcweir 
2549cdf0e10cSrcweir 	OutlinerParaObject* pOutlinerParaObject = GetOutlinerParaObject();
2550cdf0e10cSrcweir 
2551cdf0e10cSrcweir 	DBG_ASSERT( pOutlinerParaObject, "SdrTextObj::SetVerticalWriting() without OutlinerParaObject!" );
2552cdf0e10cSrcweir 
2553cdf0e10cSrcweir 	if( pOutlinerParaObject )
2554cdf0e10cSrcweir 	{
2555cdf0e10cSrcweir 		if(pOutlinerParaObject->IsVertical() != (bool)bVertical)
2556cdf0e10cSrcweir 		{
2557cdf0e10cSrcweir 			// get item settings
2558cdf0e10cSrcweir 			const SfxItemSet& rSet = GetObjectItemSet();
2559cdf0e10cSrcweir 
2560cdf0e10cSrcweir 			// #103516# Also exchange hor/ver adjust items
2561cdf0e10cSrcweir 			SdrTextHorzAdjust eHorz = ((SdrTextHorzAdjustItem&)(rSet.Get(SDRATTR_TEXT_HORZADJUST))).GetValue();
2562cdf0e10cSrcweir 			SdrTextVertAdjust eVert = ((SdrTextVertAdjustItem&)(rSet.Get(SDRATTR_TEXT_VERTADJUST))).GetValue();
2563cdf0e10cSrcweir 
2564cdf0e10cSrcweir 			// rescue object size
2565cdf0e10cSrcweir 			Rectangle aObjectRect = GetSnapRect();
2566cdf0e10cSrcweir 
2567cdf0e10cSrcweir 			// prepare ItemSet to set exchanged width and height items
2568cdf0e10cSrcweir 			SfxItemSet aNewSet(*rSet.GetPool(),
2569cdf0e10cSrcweir 				SDRATTR_TEXT_AUTOGROWHEIGHT, SDRATTR_TEXT_AUTOGROWHEIGHT,
2570cdf0e10cSrcweir 				// #103516# Expanded item ranges to also support hor and ver adjust.
2571cdf0e10cSrcweir 				SDRATTR_TEXT_VERTADJUST, SDRATTR_TEXT_VERTADJUST,
2572cdf0e10cSrcweir 				SDRATTR_TEXT_AUTOGROWWIDTH, SDRATTR_TEXT_HORZADJUST,
2573cdf0e10cSrcweir 				0, 0);
2574cdf0e10cSrcweir 
2575cdf0e10cSrcweir 			aNewSet.Put(rSet);
2576cdf0e10cSrcweir 
2577cdf0e10cSrcweir 			// #103516# Exchange horz and vert adjusts
2578cdf0e10cSrcweir 			switch(eVert)
2579cdf0e10cSrcweir 			{
2580cdf0e10cSrcweir 				case SDRTEXTVERTADJUST_TOP: aNewSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT)); break;
2581cdf0e10cSrcweir 				case SDRTEXTVERTADJUST_CENTER: aNewSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_CENTER)); break;
2582cdf0e10cSrcweir 				case SDRTEXTVERTADJUST_BOTTOM: aNewSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_LEFT)); break;
2583cdf0e10cSrcweir 				case SDRTEXTVERTADJUST_BLOCK: aNewSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_BLOCK)); break;
2584cdf0e10cSrcweir 			}
2585cdf0e10cSrcweir 			switch(eHorz)
2586cdf0e10cSrcweir 			{
2587cdf0e10cSrcweir 				case SDRTEXTHORZADJUST_LEFT: aNewSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_BOTTOM)); break;
2588cdf0e10cSrcweir 				case SDRTEXTHORZADJUST_CENTER: aNewSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_CENTER)); break;
2589cdf0e10cSrcweir 				case SDRTEXTHORZADJUST_RIGHT: aNewSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_TOP)); break;
2590cdf0e10cSrcweir 				case SDRTEXTHORZADJUST_BLOCK: aNewSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_BLOCK)); break;
2591cdf0e10cSrcweir 			}
2592cdf0e10cSrcweir 
2593cdf0e10cSrcweir 			SetObjectItemSet( aNewSet );
2594cdf0e10cSrcweir 			pOutlinerParaObject = GetOutlinerParaObject();
2595cdf0e10cSrcweir 			if ( pOutlinerParaObject )
2596cdf0e10cSrcweir 				pOutlinerParaObject->SetVertical(bVertical);
2597cdf0e10cSrcweir 
2598cdf0e10cSrcweir 			// restore object size
2599cdf0e10cSrcweir 			SetSnapRect(aObjectRect);
2600cdf0e10cSrcweir 		}
2601cdf0e10cSrcweir 	}
2602cdf0e10cSrcweir }
2603cdf0e10cSrcweir FASTBOOL SdrObjCustomShape::AdjustTextFrameWidthAndHeight(Rectangle& rR, FASTBOOL bHgt, FASTBOOL bWdt) const
2604cdf0e10cSrcweir {
2605cdf0e10cSrcweir  	if ( pModel && HasText() && !rR.IsEmpty() )
2606cdf0e10cSrcweir 	{
2607cdf0e10cSrcweir 		FASTBOOL bWdtGrow=bWdt && IsAutoGrowWidth();
2608cdf0e10cSrcweir 		FASTBOOL bHgtGrow=bHgt && IsAutoGrowHeight();
2609cdf0e10cSrcweir 		if ( bWdtGrow || bHgtGrow )
2610cdf0e10cSrcweir 		{
2611cdf0e10cSrcweir 			Rectangle aR0(rR);
2612cdf0e10cSrcweir 			long nHgt=0,nMinHgt=0,nMaxHgt=0;
2613cdf0e10cSrcweir 			long nWdt=0,nMinWdt=0,nMaxWdt=0;
2614cdf0e10cSrcweir 			Size aSiz(rR.GetSize()); aSiz.Width()--; aSiz.Height()--;
2615cdf0e10cSrcweir 			Size aMaxSiz(100000,100000);
2616cdf0e10cSrcweir 			Size aTmpSiz(pModel->GetMaxObjSize());
2617cdf0e10cSrcweir 			if (aTmpSiz.Width()!=0) aMaxSiz.Width()=aTmpSiz.Width();
2618cdf0e10cSrcweir 			if (aTmpSiz.Height()!=0) aMaxSiz.Height()=aTmpSiz.Height();
2619cdf0e10cSrcweir 			if (bWdtGrow)
2620cdf0e10cSrcweir 			{
2621cdf0e10cSrcweir 				nMinWdt=GetMinTextFrameWidth();
2622cdf0e10cSrcweir 				nMaxWdt=GetMaxTextFrameWidth();
2623cdf0e10cSrcweir 				if (nMaxWdt==0 || nMaxWdt>aMaxSiz.Width()) nMaxWdt=aMaxSiz.Width();
2624cdf0e10cSrcweir 				if (nMinWdt<=0) nMinWdt=1;
2625cdf0e10cSrcweir 				aSiz.Width()=nMaxWdt;
2626cdf0e10cSrcweir 			}
2627cdf0e10cSrcweir 			if (bHgtGrow)
2628cdf0e10cSrcweir 			{
2629cdf0e10cSrcweir 				nMinHgt=GetMinTextFrameHeight();
2630cdf0e10cSrcweir 				nMaxHgt=GetMaxTextFrameHeight();
2631cdf0e10cSrcweir 				if (nMaxHgt==0 || nMaxHgt>aMaxSiz.Height()) nMaxHgt=aMaxSiz.Height();
2632cdf0e10cSrcweir 				if (nMinHgt<=0) nMinHgt=1;
2633cdf0e10cSrcweir 				aSiz.Height()=nMaxHgt;
2634cdf0e10cSrcweir 			}
2635cdf0e10cSrcweir 			long nHDist=GetTextLeftDistance()+GetTextRightDistance();
2636cdf0e10cSrcweir 			long nVDist=GetTextUpperDistance()+GetTextLowerDistance();
2637cdf0e10cSrcweir 			aSiz.Width()-=nHDist;
2638cdf0e10cSrcweir 			aSiz.Height()-=nVDist;
2639cdf0e10cSrcweir 			if ( aSiz.Width() < 2 )
2640cdf0e10cSrcweir 				aSiz.Width() = 2;   // Mindestgroesse 2
2641cdf0e10cSrcweir 			if ( aSiz.Height() < 2 )
2642cdf0e10cSrcweir 				aSiz.Height() = 2; // Mindestgroesse 2
2643cdf0e10cSrcweir 
2644cdf0e10cSrcweir 			if(pEdtOutl)
2645cdf0e10cSrcweir 			{
2646cdf0e10cSrcweir 				pEdtOutl->SetMaxAutoPaperSize( aSiz );
2647cdf0e10cSrcweir 				if (bWdtGrow)
2648cdf0e10cSrcweir 				{
2649cdf0e10cSrcweir 					Size aSiz2(pEdtOutl->CalcTextSize());
2650cdf0e10cSrcweir 					nWdt=aSiz2.Width()+1; // lieber etwas Tolleranz
2651cdf0e10cSrcweir 					if (bHgtGrow) nHgt=aSiz2.Height()+1; // lieber etwas Tolleranz
2652cdf0e10cSrcweir 				} else
2653cdf0e10cSrcweir 				{
2654cdf0e10cSrcweir 					nHgt=pEdtOutl->GetTextHeight()+1; // lieber etwas Tolleranz
2655cdf0e10cSrcweir 				}
2656cdf0e10cSrcweir 			}
2657cdf0e10cSrcweir 			else
2658cdf0e10cSrcweir 			{
2659cdf0e10cSrcweir 				Outliner& rOutliner=ImpGetDrawOutliner();
2660cdf0e10cSrcweir 				rOutliner.SetPaperSize(aSiz);
2661cdf0e10cSrcweir 				rOutliner.SetUpdateMode(sal_True);
2662cdf0e10cSrcweir 				// !!! hier sollte ich wohl auch noch mal die Optimierung mit
2663cdf0e10cSrcweir 				// bPortionInfoChecked usw einbauen
2664cdf0e10cSrcweir 				OutlinerParaObject* pOutlinerParaObject = GetOutlinerParaObject();
2665cdf0e10cSrcweir 				if( pOutlinerParaObject != NULL )
2666cdf0e10cSrcweir 				{
2667cdf0e10cSrcweir 					rOutliner.SetText(*pOutlinerParaObject);
2668cdf0e10cSrcweir 					rOutliner.SetFixedCellHeight(((const SdrTextFixedCellHeightItem&)GetMergedItem(SDRATTR_TEXT_USEFIXEDCELLHEIGHT)).GetValue());
2669cdf0e10cSrcweir 				}
2670cdf0e10cSrcweir 				if ( bWdtGrow )
2671cdf0e10cSrcweir 				{
2672cdf0e10cSrcweir 					Size aSiz2(rOutliner.CalcTextSize());
2673cdf0e10cSrcweir 					nWdt=aSiz2.Width()+1; // lieber etwas Tolleranz
2674cdf0e10cSrcweir 					if ( bHgtGrow )
2675cdf0e10cSrcweir 						nHgt=aSiz2.Height()+1; // lieber etwas Tolleranz
2676cdf0e10cSrcweir 				}
2677cdf0e10cSrcweir 				else
2678cdf0e10cSrcweir 					nHgt = rOutliner.GetTextHeight()+1; // lieber etwas Tolleranz
2679cdf0e10cSrcweir 				rOutliner.Clear();
2680cdf0e10cSrcweir 			}
2681cdf0e10cSrcweir 			if ( nWdt < nMinWdt )
2682cdf0e10cSrcweir 				nWdt = nMinWdt;
2683cdf0e10cSrcweir 			if ( nWdt > nMaxWdt )
2684cdf0e10cSrcweir 				nWdt = nMaxWdt;
2685cdf0e10cSrcweir 			nWdt += nHDist;
2686cdf0e10cSrcweir 			if ( nWdt < 1 )
2687cdf0e10cSrcweir 				nWdt = 1; // nHDist kann auch negativ sein
2688cdf0e10cSrcweir 			if ( nHgt < nMinHgt )
2689cdf0e10cSrcweir 				nHgt = nMinHgt;
2690cdf0e10cSrcweir 			if ( nHgt > nMaxHgt )
2691cdf0e10cSrcweir 				nHgt = nMaxHgt;
2692cdf0e10cSrcweir 			nHgt+=nVDist;
2693cdf0e10cSrcweir 			if ( nHgt < 1 )
2694cdf0e10cSrcweir 				nHgt = 1; // nVDist kann auch negativ sein
2695cdf0e10cSrcweir 			long nWdtGrow = nWdt-(rR.Right()-rR.Left());
2696cdf0e10cSrcweir 			long nHgtGrow = nHgt-(rR.Bottom()-rR.Top());
2697cdf0e10cSrcweir 			if ( nWdtGrow == 0 )
2698cdf0e10cSrcweir 				bWdtGrow = sal_False;
2699cdf0e10cSrcweir 			if ( nHgtGrow == 0 )
2700cdf0e10cSrcweir 				bHgtGrow=sal_False;
2701cdf0e10cSrcweir 			if ( bWdtGrow || bHgtGrow )
2702cdf0e10cSrcweir 			{
2703cdf0e10cSrcweir 				if ( bWdtGrow )
2704cdf0e10cSrcweir 				{
2705cdf0e10cSrcweir 					SdrTextHorzAdjust eHAdj=GetTextHorizontalAdjust();
2706cdf0e10cSrcweir 					if ( eHAdj == SDRTEXTHORZADJUST_LEFT )
2707cdf0e10cSrcweir 						rR.Right()+=nWdtGrow;
2708cdf0e10cSrcweir 					else if ( eHAdj == SDRTEXTHORZADJUST_RIGHT )
2709cdf0e10cSrcweir 						rR.Left()-=nWdtGrow;
2710cdf0e10cSrcweir 					else
2711cdf0e10cSrcweir 					{
2712cdf0e10cSrcweir 						long nWdtGrow2=nWdtGrow/2;
2713cdf0e10cSrcweir 						rR.Left()-=nWdtGrow2;
2714cdf0e10cSrcweir 						rR.Right()=rR.Left()+nWdt;
2715cdf0e10cSrcweir 					}
2716cdf0e10cSrcweir 				}
2717cdf0e10cSrcweir 				if ( bHgtGrow )
2718cdf0e10cSrcweir 				{
2719cdf0e10cSrcweir 					SdrTextVertAdjust eVAdj=GetTextVerticalAdjust();
2720cdf0e10cSrcweir 					if ( eVAdj == SDRTEXTVERTADJUST_TOP )
2721cdf0e10cSrcweir 						rR.Bottom()+=nHgtGrow;
2722cdf0e10cSrcweir 					else if ( eVAdj == SDRTEXTVERTADJUST_BOTTOM )
2723cdf0e10cSrcweir 						rR.Top()-=nHgtGrow;
2724cdf0e10cSrcweir 					else
2725cdf0e10cSrcweir 					{
2726cdf0e10cSrcweir 						long nHgtGrow2=nHgtGrow/2;
2727cdf0e10cSrcweir 						rR.Top()-=nHgtGrow2;
2728cdf0e10cSrcweir 						rR.Bottom()=rR.Top()+nHgt;
2729cdf0e10cSrcweir 					}
2730cdf0e10cSrcweir 				}
2731cdf0e10cSrcweir 				if ( aGeo.nDrehWink )
2732cdf0e10cSrcweir 				{
2733cdf0e10cSrcweir 					Point aD1(rR.TopLeft());
2734cdf0e10cSrcweir 					aD1-=aR0.TopLeft();
2735cdf0e10cSrcweir 					Point aD2(aD1);
2736cdf0e10cSrcweir 					RotatePoint(aD2,Point(),aGeo.nSin,aGeo.nCos);
2737cdf0e10cSrcweir 					aD2-=aD1;
2738cdf0e10cSrcweir 					rR.Move(aD2.X(),aD2.Y());
2739cdf0e10cSrcweir 				}
2740cdf0e10cSrcweir 				return sal_True;
2741cdf0e10cSrcweir 			}
2742cdf0e10cSrcweir 		}
2743cdf0e10cSrcweir 	}
2744cdf0e10cSrcweir 	return sal_False;
2745cdf0e10cSrcweir }
2746cdf0e10cSrcweir 
2747cdf0e10cSrcweir Rectangle SdrObjCustomShape::ImpCalculateTextFrame( const FASTBOOL bHgt, const FASTBOOL bWdt )
2748cdf0e10cSrcweir {
2749cdf0e10cSrcweir 	Rectangle aReturnValue;
2750cdf0e10cSrcweir 
2751cdf0e10cSrcweir 	Rectangle aOldTextRect( aRect );		// <- initial text rectangle
2752cdf0e10cSrcweir 
2753cdf0e10cSrcweir 	Rectangle aNewTextRect( aRect );		// <- new text rectangle returned from the custom shape renderer,
2754cdf0e10cSrcweir 	GetTextBounds( aNewTextRect );			//    it depends to the current logical shape size
2755cdf0e10cSrcweir 
2756cdf0e10cSrcweir 	Rectangle aAdjustedTextRect( aNewTextRect );							// <- new text rectangle is being tested by AdjustTextFrameWidthAndHeight to ensure
2757cdf0e10cSrcweir 	if ( AdjustTextFrameWidthAndHeight( aAdjustedTextRect, bHgt, bWdt ) )	//    that the new text rectangle is matching the current text size from the outliner
2758cdf0e10cSrcweir 	{
2759cdf0e10cSrcweir 		if ( ( aAdjustedTextRect != aNewTextRect ) && ( aOldTextRect != aAdjustedTextRect ) )
2760cdf0e10cSrcweir 		{
2761cdf0e10cSrcweir 			aReturnValue = aRect;
2762cdf0e10cSrcweir 			double fXScale = (double)aOldTextRect.GetWidth() / (double)aNewTextRect.GetWidth();
2763cdf0e10cSrcweir 			double fYScale = (double)aOldTextRect.GetHeight() / (double)aNewTextRect.GetHeight();
2764cdf0e10cSrcweir 			double fRightDiff = (double)( aAdjustedTextRect.Right() - aNewTextRect.Right() ) * fXScale;
2765cdf0e10cSrcweir 			double fLeftDiff  = (double)( aAdjustedTextRect.Left()  - aNewTextRect.Left()  ) * fXScale;
2766cdf0e10cSrcweir 			double fTopDiff   = (double)( aAdjustedTextRect.Top()   - aNewTextRect.Top()   ) * fYScale;
2767cdf0e10cSrcweir 			double fBottomDiff= (double)( aAdjustedTextRect.Bottom()- aNewTextRect.Bottom()) * fYScale;
2768cdf0e10cSrcweir 			aReturnValue.Left() += (sal_Int32)fLeftDiff;
2769cdf0e10cSrcweir 			aReturnValue.Right() += (sal_Int32)fRightDiff;
2770cdf0e10cSrcweir 			aReturnValue.Top() += (sal_Int32)fTopDiff;
2771cdf0e10cSrcweir 			aReturnValue.Bottom() += (sal_Int32)fBottomDiff;
2772cdf0e10cSrcweir 		}
2773cdf0e10cSrcweir 	}
2774cdf0e10cSrcweir 	return aReturnValue;
2775cdf0e10cSrcweir }
2776cdf0e10cSrcweir 
2777cdf0e10cSrcweir FASTBOOL SdrObjCustomShape::NbcAdjustTextFrameWidthAndHeight(FASTBOOL bHgt, FASTBOOL bWdt)
2778cdf0e10cSrcweir {
2779cdf0e10cSrcweir 	Rectangle aNewTextRect = ImpCalculateTextFrame( bHgt, bWdt );
2780cdf0e10cSrcweir 	sal_Bool bRet = !aNewTextRect.IsEmpty() && ( aNewTextRect != aRect );
2781cdf0e10cSrcweir 	if ( bRet )
2782cdf0e10cSrcweir 	{
2783cdf0e10cSrcweir 		// taking care of handles that should not been changed
2784cdf0e10cSrcweir 		std::vector< SdrCustomShapeInteraction > aInteractionHandles( GetInteractionHandles( this ) );
2785cdf0e10cSrcweir 
2786cdf0e10cSrcweir 		aRect = aNewTextRect;
2787cdf0e10cSrcweir 		SetRectsDirty();
2788cdf0e10cSrcweir 		SetChanged();
2789cdf0e10cSrcweir 
2790cdf0e10cSrcweir 		std::vector< SdrCustomShapeInteraction >::iterator aIter( aInteractionHandles.begin() );
2791cdf0e10cSrcweir 		while ( aIter != aInteractionHandles.end() )
2792cdf0e10cSrcweir 		{
2793cdf0e10cSrcweir 			try
2794cdf0e10cSrcweir 			{
2795cdf0e10cSrcweir 				if ( aIter->nMode & CUSTOMSHAPE_HANDLE_RESIZE_FIXED )
2796cdf0e10cSrcweir 					aIter->xInteraction->setControllerPosition( aIter->aPosition );
2797cdf0e10cSrcweir 			}
2798cdf0e10cSrcweir 			catch ( const uno::RuntimeException& )
2799cdf0e10cSrcweir 			{
2800cdf0e10cSrcweir 			}
2801cdf0e10cSrcweir 			aIter++;
2802cdf0e10cSrcweir 		}
2803cdf0e10cSrcweir 		InvalidateRenderGeometry();
2804cdf0e10cSrcweir 	}
2805cdf0e10cSrcweir 	return bRet;
2806cdf0e10cSrcweir }
2807cdf0e10cSrcweir FASTBOOL SdrObjCustomShape::AdjustTextFrameWidthAndHeight(FASTBOOL bHgt, FASTBOOL bWdt)
2808cdf0e10cSrcweir {
2809cdf0e10cSrcweir 	Rectangle aNewTextRect = ImpCalculateTextFrame( bHgt, bWdt );
2810cdf0e10cSrcweir 	sal_Bool bRet = !aNewTextRect.IsEmpty() && ( aNewTextRect != aRect );
2811cdf0e10cSrcweir 	if ( bRet )
2812cdf0e10cSrcweir 	{
2813cdf0e10cSrcweir 		Rectangle aBoundRect0;
2814cdf0e10cSrcweir 		if ( pUserCall )
2815cdf0e10cSrcweir 			aBoundRect0 = GetCurrentBoundRect();
2816cdf0e10cSrcweir 
2817cdf0e10cSrcweir 		// taking care of handles that should not been changed
2818cdf0e10cSrcweir 		std::vector< SdrCustomShapeInteraction > aInteractionHandles( GetInteractionHandles( this ) );
2819cdf0e10cSrcweir 
2820cdf0e10cSrcweir //		SendRepaintBroadcast();
2821cdf0e10cSrcweir 		aRect = aNewTextRect;
2822cdf0e10cSrcweir 		SetRectsDirty();
2823cdf0e10cSrcweir 
2824cdf0e10cSrcweir 		std::vector< SdrCustomShapeInteraction >::iterator aIter( aInteractionHandles.begin() );
2825cdf0e10cSrcweir 		while ( aIter != aInteractionHandles.end() )
2826cdf0e10cSrcweir 		{
2827cdf0e10cSrcweir 			try
2828cdf0e10cSrcweir 			{
2829cdf0e10cSrcweir 				if ( aIter->nMode & CUSTOMSHAPE_HANDLE_RESIZE_FIXED )
2830cdf0e10cSrcweir 					aIter->xInteraction->setControllerPosition( aIter->aPosition );
2831cdf0e10cSrcweir 			}
2832cdf0e10cSrcweir 			catch ( const uno::RuntimeException& )
2833cdf0e10cSrcweir 			{
2834cdf0e10cSrcweir 			}
2835cdf0e10cSrcweir 			aIter++;
2836cdf0e10cSrcweir 		}
2837cdf0e10cSrcweir 
2838cdf0e10cSrcweir 		InvalidateRenderGeometry();
2839cdf0e10cSrcweir 		SetChanged();
2840cdf0e10cSrcweir //		SendRepaintBroadcast();
2841cdf0e10cSrcweir 		BroadcastObjectChange();
2842cdf0e10cSrcweir 		SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
2843cdf0e10cSrcweir 	}
2844cdf0e10cSrcweir 	return bRet;
2845cdf0e10cSrcweir }
2846cdf0e10cSrcweir sal_Bool SdrObjCustomShape::BegTextEdit( SdrOutliner& rOutl )
2847cdf0e10cSrcweir {
2848cdf0e10cSrcweir 	return SdrTextObj::BegTextEdit( rOutl );
2849cdf0e10cSrcweir }
2850cdf0e10cSrcweir void SdrObjCustomShape::TakeTextEditArea(Size* pPaperMin, Size* pPaperMax, Rectangle* pViewInit, Rectangle* pViewMin) const
2851cdf0e10cSrcweir {
2852cdf0e10cSrcweir 	Size aPaperMin,aPaperMax;
2853cdf0e10cSrcweir 	Rectangle aViewInit;
2854cdf0e10cSrcweir 	TakeTextAnchorRect( aViewInit );
2855cdf0e10cSrcweir 	if ( aGeo.nDrehWink )
2856cdf0e10cSrcweir 	{
2857cdf0e10cSrcweir 		Point aCenter(aViewInit.Center());
2858cdf0e10cSrcweir 		aCenter-=aViewInit.TopLeft();
2859cdf0e10cSrcweir 		Point aCenter0(aCenter);
2860cdf0e10cSrcweir 		RotatePoint(aCenter,Point(),aGeo.nSin,aGeo.nCos);
2861cdf0e10cSrcweir 		aCenter-=aCenter0;
2862cdf0e10cSrcweir 		aViewInit.Move(aCenter.X(),aCenter.Y());
2863cdf0e10cSrcweir 	}
2864cdf0e10cSrcweir 	Size aAnkSiz(aViewInit.GetSize());
2865cdf0e10cSrcweir 	aAnkSiz.Width()--; aAnkSiz.Height()--; // weil GetSize() ein draufaddiert
2866cdf0e10cSrcweir 	Size aMaxSiz(1000000,1000000);
2867cdf0e10cSrcweir 	if (pModel!=NULL) {
2868cdf0e10cSrcweir 		Size aTmpSiz(pModel->GetMaxObjSize());
2869cdf0e10cSrcweir 		if (aTmpSiz.Width()!=0) aMaxSiz.Width()=aTmpSiz.Width();
2870cdf0e10cSrcweir 		if (aTmpSiz.Height()!=0) aMaxSiz.Height()=aTmpSiz.Height();
2871cdf0e10cSrcweir 	}
2872cdf0e10cSrcweir 	SdrTextHorzAdjust eHAdj(GetTextHorizontalAdjust());
2873cdf0e10cSrcweir 	SdrTextVertAdjust eVAdj(GetTextVerticalAdjust());
2874cdf0e10cSrcweir 
2875cdf0e10cSrcweir 	long nMinWdt = GetMinTextFrameWidth();
2876cdf0e10cSrcweir 	long nMinHgt = GetMinTextFrameHeight();
2877cdf0e10cSrcweir 	long nMaxWdt = GetMaxTextFrameWidth();
2878cdf0e10cSrcweir 	long nMaxHgt = GetMaxTextFrameHeight();
2879cdf0e10cSrcweir 	if (nMinWdt<1) nMinWdt=1;
2880cdf0e10cSrcweir 	if (nMinHgt<1) nMinHgt=1;
2881cdf0e10cSrcweir 	if ( nMaxWdt == 0 || nMaxWdt > aMaxSiz.Width() )
2882cdf0e10cSrcweir 		nMaxWdt = aMaxSiz.Width();
2883cdf0e10cSrcweir 	if ( nMaxHgt == 0 || nMaxHgt > aMaxSiz.Height() )
2884cdf0e10cSrcweir 		nMaxHgt=aMaxSiz.Height();
2885cdf0e10cSrcweir 
2886cdf0e10cSrcweir 	if (((SdrTextWordWrapItem&)(GetMergedItem(SDRATTR_TEXT_WORDWRAP))).GetValue())
2887cdf0e10cSrcweir 	{
2888cdf0e10cSrcweir 		if ( IsVerticalWriting() )
2889cdf0e10cSrcweir 		{
2890cdf0e10cSrcweir 			nMaxHgt = aAnkSiz.Height();
2891cdf0e10cSrcweir 			nMinHgt = nMaxHgt;
2892cdf0e10cSrcweir 		}
2893cdf0e10cSrcweir 		else
2894cdf0e10cSrcweir 		{
2895cdf0e10cSrcweir 			nMaxWdt = aAnkSiz.Width();
2896cdf0e10cSrcweir 			nMinWdt = nMaxWdt;
2897cdf0e10cSrcweir 		}
2898cdf0e10cSrcweir 	}
2899cdf0e10cSrcweir 	aPaperMax.Width()=nMaxWdt;
2900cdf0e10cSrcweir 	aPaperMax.Height()=nMaxHgt;
2901cdf0e10cSrcweir 
2902cdf0e10cSrcweir 	aPaperMin.Width()=nMinWdt;
2903cdf0e10cSrcweir 	aPaperMin.Height()=nMinHgt;
2904cdf0e10cSrcweir 
2905cdf0e10cSrcweir 	if ( pViewMin )
2906cdf0e10cSrcweir 	{
2907cdf0e10cSrcweir 		*pViewMin = aViewInit;
2908cdf0e10cSrcweir 
2909cdf0e10cSrcweir 		long nXFree = aAnkSiz.Width() - aPaperMin.Width();
2910cdf0e10cSrcweir 		if ( eHAdj == SDRTEXTHORZADJUST_LEFT )
2911cdf0e10cSrcweir 			pViewMin->Right() -= nXFree;
2912cdf0e10cSrcweir 		else if ( eHAdj == SDRTEXTHORZADJUST_RIGHT )
2913cdf0e10cSrcweir 			pViewMin->Left() += nXFree;
2914cdf0e10cSrcweir 		else { pViewMin->Left() += nXFree / 2; pViewMin->Right() = pViewMin->Left() + aPaperMin.Width(); }
2915cdf0e10cSrcweir 
2916cdf0e10cSrcweir 		long nYFree = aAnkSiz.Height() - aPaperMin.Height();
2917cdf0e10cSrcweir 		if ( eVAdj == SDRTEXTVERTADJUST_TOP )
2918cdf0e10cSrcweir 			pViewMin->Bottom() -= nYFree;
2919cdf0e10cSrcweir 		else if ( eVAdj == SDRTEXTVERTADJUST_BOTTOM )
2920cdf0e10cSrcweir 			pViewMin->Top() += nYFree;
2921cdf0e10cSrcweir 		else { pViewMin->Top() += nYFree / 2; pViewMin->Bottom() = pViewMin->Top() + aPaperMin.Height(); }
2922cdf0e10cSrcweir 	}
2923cdf0e10cSrcweir 
2924cdf0e10cSrcweir 	if( IsVerticalWriting() )
2925cdf0e10cSrcweir 		aPaperMin.Width() = 0;
2926cdf0e10cSrcweir 	else
2927cdf0e10cSrcweir 		aPaperMin.Height() = 0; // #33102#
2928cdf0e10cSrcweir 
2929cdf0e10cSrcweir 	if( eHAdj != SDRTEXTHORZADJUST_BLOCK )
2930cdf0e10cSrcweir 		aPaperMin.Width()=0;
2931cdf0e10cSrcweir 
2932cdf0e10cSrcweir 	// #103516# For complete ver adjust support, set paper min height to 0, here.
2933cdf0e10cSrcweir 	if(SDRTEXTVERTADJUST_BLOCK != eVAdj )
2934cdf0e10cSrcweir 		aPaperMin.Height() = 0;
2935cdf0e10cSrcweir 
2936cdf0e10cSrcweir 	if (pPaperMin!=NULL) *pPaperMin=aPaperMin;
2937cdf0e10cSrcweir 	if (pPaperMax!=NULL) *pPaperMax=aPaperMax;
2938cdf0e10cSrcweir 	if (pViewInit!=NULL) *pViewInit=aViewInit;
2939cdf0e10cSrcweir }
2940cdf0e10cSrcweir void SdrObjCustomShape::EndTextEdit( SdrOutliner& rOutl )
2941cdf0e10cSrcweir {
2942cdf0e10cSrcweir 	SdrTextObj::EndTextEdit( rOutl );
2943cdf0e10cSrcweir 	InvalidateRenderGeometry();
2944cdf0e10cSrcweir }
2945cdf0e10cSrcweir void SdrObjCustomShape::TakeTextAnchorRect( Rectangle& rAnchorRect ) const
2946cdf0e10cSrcweir {
2947cdf0e10cSrcweir 	if ( GetTextBounds( rAnchorRect ) )
2948cdf0e10cSrcweir 	{
2949cdf0e10cSrcweir 		Point aRotateRef( maSnapRect.Center() );
2950cdf0e10cSrcweir 		rAnchorRect.Left()   += GetTextLeftDistance();
2951cdf0e10cSrcweir 		rAnchorRect.Top()    += GetTextUpperDistance();
2952cdf0e10cSrcweir 		rAnchorRect.Right()  -= GetTextRightDistance();
2953cdf0e10cSrcweir 		rAnchorRect.Bottom() -= GetTextLowerDistance();
2954cdf0e10cSrcweir 		ImpJustifyRect( rAnchorRect );
2955cdf0e10cSrcweir 
2956cdf0e10cSrcweir 		if ( rAnchorRect.GetWidth() < 2 )
2957cdf0e10cSrcweir 			rAnchorRect.Right() = rAnchorRect.Left() + 1;	// minimal width is 2
2958cdf0e10cSrcweir 		if ( rAnchorRect.GetHeight() < 2 )
2959cdf0e10cSrcweir 			rAnchorRect.Bottom() = rAnchorRect.Top() + 1;	// minimal height is 2
2960cdf0e10cSrcweir 		if ( aGeo.nDrehWink )
2961cdf0e10cSrcweir 		{
2962cdf0e10cSrcweir 			Point aP( rAnchorRect.TopLeft() );
2963cdf0e10cSrcweir 			RotatePoint( aP, aRotateRef, aGeo.nSin, aGeo. nCos );
2964cdf0e10cSrcweir 			rAnchorRect.SetPos( aP );
2965cdf0e10cSrcweir 		}
2966cdf0e10cSrcweir 	}
2967cdf0e10cSrcweir 	else
2968cdf0e10cSrcweir 		SdrTextObj::TakeTextAnchorRect( rAnchorRect );
2969cdf0e10cSrcweir }
2970cdf0e10cSrcweir void SdrObjCustomShape::TakeTextRect( SdrOutliner& rOutliner, Rectangle& rTextRect, FASTBOOL bNoEditText,
2971cdf0e10cSrcweir 	                           Rectangle* pAnchorRect, sal_Bool /*bLineWidth*/) const
2972cdf0e10cSrcweir {
2973cdf0e10cSrcweir 	Rectangle aAnkRect; // Rect innerhalb dem geankert wird
2974cdf0e10cSrcweir 	TakeTextAnchorRect(aAnkRect);
2975cdf0e10cSrcweir 	SdrTextVertAdjust eVAdj=GetTextVerticalAdjust();
2976cdf0e10cSrcweir 	SdrTextHorzAdjust eHAdj=GetTextHorizontalAdjust();
2977cdf0e10cSrcweir 	sal_uIntPtr nStat0=rOutliner.GetControlWord();
2978cdf0e10cSrcweir 	Size aNullSize;
2979cdf0e10cSrcweir 
2980cdf0e10cSrcweir 	rOutliner.SetControlWord(nStat0|EE_CNTRL_AUTOPAGESIZE);
2981cdf0e10cSrcweir 	rOutliner.SetMinAutoPaperSize(aNullSize);
2982cdf0e10cSrcweir 	sal_Int32 nMaxAutoPaperWidth = 1000000;
2983cdf0e10cSrcweir 	sal_Int32 nMaxAutoPaperHeight= 1000000;
2984cdf0e10cSrcweir 
2985cdf0e10cSrcweir 	long nAnkWdt=aAnkRect.GetWidth();
2986cdf0e10cSrcweir 	long nAnkHgt=aAnkRect.GetHeight();
2987cdf0e10cSrcweir 
2988cdf0e10cSrcweir 	if (((SdrTextWordWrapItem&)(GetMergedItem(SDRATTR_TEXT_WORDWRAP))).GetValue())
2989cdf0e10cSrcweir 	{
2990cdf0e10cSrcweir 		if ( IsVerticalWriting() )
2991cdf0e10cSrcweir 			nMaxAutoPaperHeight = nAnkHgt;
2992cdf0e10cSrcweir 		else
2993cdf0e10cSrcweir 			nMaxAutoPaperWidth = nAnkWdt;
2994cdf0e10cSrcweir 	}
2995cdf0e10cSrcweir 	if(SDRTEXTHORZADJUST_BLOCK == eHAdj && !IsVerticalWriting())
2996cdf0e10cSrcweir 	{
2997cdf0e10cSrcweir 		rOutliner.SetMinAutoPaperSize(Size(nAnkWdt, 0));
2998cdf0e10cSrcweir 	}
2999cdf0e10cSrcweir 
3000cdf0e10cSrcweir 	if(SDRTEXTVERTADJUST_BLOCK == eVAdj && IsVerticalWriting())
3001cdf0e10cSrcweir 	{
3002cdf0e10cSrcweir 		rOutliner.SetMinAutoPaperSize(Size(0, nAnkHgt));
3003cdf0e10cSrcweir 	}
3004cdf0e10cSrcweir 	rOutliner.SetMaxAutoPaperSize( Size( nMaxAutoPaperWidth, nMaxAutoPaperHeight ) );
3005cdf0e10cSrcweir 	rOutliner.SetPaperSize( aNullSize );
3006cdf0e10cSrcweir 
3007cdf0e10cSrcweir 	// Text in den Outliner stecken - ggf. den aus dem EditOutliner
3008cdf0e10cSrcweir 	OutlinerParaObject* pPara= GetOutlinerParaObject();
3009cdf0e10cSrcweir 	if (pEdtOutl && !bNoEditText)
3010cdf0e10cSrcweir 		pPara=pEdtOutl->CreateParaObject();
3011cdf0e10cSrcweir 
3012cdf0e10cSrcweir 	if (pPara)
3013cdf0e10cSrcweir 	{
3014cdf0e10cSrcweir 		sal_Bool bHitTest = sal_False;
3015cdf0e10cSrcweir 		if( pModel )
3016cdf0e10cSrcweir 			bHitTest = &pModel->GetHitTestOutliner() == &rOutliner;
3017cdf0e10cSrcweir 
3018cdf0e10cSrcweir 		const SdrTextObj* pTestObj = rOutliner.GetTextObj();
3019cdf0e10cSrcweir 		if( !pTestObj || !bHitTest || pTestObj != this ||
3020cdf0e10cSrcweir 		    pTestObj->GetOutlinerParaObject() != GetOutlinerParaObject() )
3021cdf0e10cSrcweir 		{
3022cdf0e10cSrcweir 			if( bHitTest )
3023cdf0e10cSrcweir 				rOutliner.SetTextObj( this );
3024cdf0e10cSrcweir 
3025cdf0e10cSrcweir 			rOutliner.SetUpdateMode(sal_True);
3026cdf0e10cSrcweir 			rOutliner.SetText(*pPara);
3027cdf0e10cSrcweir 		}
3028cdf0e10cSrcweir 	}
3029cdf0e10cSrcweir 	else
3030cdf0e10cSrcweir 	{
3031cdf0e10cSrcweir 		rOutliner.SetTextObj( NULL );
3032cdf0e10cSrcweir 	}
3033cdf0e10cSrcweir 	if (pEdtOutl && !bNoEditText && pPara)
3034cdf0e10cSrcweir 		delete pPara;
3035cdf0e10cSrcweir 
3036cdf0e10cSrcweir 	rOutliner.SetUpdateMode(sal_True);
3037cdf0e10cSrcweir 	rOutliner.SetControlWord(nStat0);
3038cdf0e10cSrcweir 
3039cdf0e10cSrcweir 	SdrText* pText = getActiveText();
3040cdf0e10cSrcweir 	if( pText )
3041cdf0e10cSrcweir 		pText->CheckPortionInfo( rOutliner );
3042cdf0e10cSrcweir 
3043cdf0e10cSrcweir 	Point aTextPos(aAnkRect.TopLeft());
3044cdf0e10cSrcweir 	Size aTextSiz(rOutliner.GetPaperSize()); // GetPaperSize() hat etwas Toleranz drauf, oder?
3045cdf0e10cSrcweir 
3046cdf0e10cSrcweir 	// #106653#
3047cdf0e10cSrcweir 	// For draw objects containing text correct hor/ver alignment if text is bigger
3048cdf0e10cSrcweir 	// than the object itself. Without that correction, the text would always be
3049cdf0e10cSrcweir 		// formatted to the left edge (or top edge when vertical) of the draw object.
3050cdf0e10cSrcweir 
3051cdf0e10cSrcweir 	if( !IsTextFrame() )
3052cdf0e10cSrcweir 	{
3053cdf0e10cSrcweir 		if(aAnkRect.GetWidth() < aTextSiz.Width() && !IsVerticalWriting())
3054cdf0e10cSrcweir 		{
3055cdf0e10cSrcweir 			// #110129#
3056cdf0e10cSrcweir 			// Horizontal case here. Correct only if eHAdj == SDRTEXTHORZADJUST_BLOCK,
3057cdf0e10cSrcweir 			// else the alignment is wanted.
3058cdf0e10cSrcweir 			if(SDRTEXTHORZADJUST_BLOCK == eHAdj)
3059cdf0e10cSrcweir 			{
3060cdf0e10cSrcweir 				eHAdj = SDRTEXTHORZADJUST_CENTER;
3061cdf0e10cSrcweir 			}
3062cdf0e10cSrcweir 		}
3063cdf0e10cSrcweir 
3064cdf0e10cSrcweir 		if(aAnkRect.GetHeight() < aTextSiz.Height() && IsVerticalWriting())
3065cdf0e10cSrcweir 		{
3066cdf0e10cSrcweir 			// #110129#
3067cdf0e10cSrcweir 			// Vertical case here. Correct only if eHAdj == SDRTEXTVERTADJUST_BLOCK,
3068cdf0e10cSrcweir 			// else the alignment is wanted.
3069cdf0e10cSrcweir 			if(SDRTEXTVERTADJUST_BLOCK == eVAdj)
3070cdf0e10cSrcweir 			{
3071cdf0e10cSrcweir 				eVAdj = SDRTEXTVERTADJUST_CENTER;
3072cdf0e10cSrcweir 			}
3073cdf0e10cSrcweir 		}
3074cdf0e10cSrcweir 	}
3075cdf0e10cSrcweir 
3076cdf0e10cSrcweir 	if (eHAdj==SDRTEXTHORZADJUST_CENTER || eHAdj==SDRTEXTHORZADJUST_RIGHT)
3077cdf0e10cSrcweir 	{
3078cdf0e10cSrcweir 		long nFreeWdt=aAnkRect.GetWidth()-aTextSiz.Width();
3079cdf0e10cSrcweir 		if (eHAdj==SDRTEXTHORZADJUST_CENTER)
3080cdf0e10cSrcweir 			aTextPos.X()+=nFreeWdt/2;
3081cdf0e10cSrcweir 		if (eHAdj==SDRTEXTHORZADJUST_RIGHT)
3082cdf0e10cSrcweir 			aTextPos.X()+=nFreeWdt;
3083cdf0e10cSrcweir 	}
3084cdf0e10cSrcweir 	if (eVAdj==SDRTEXTVERTADJUST_CENTER || eVAdj==SDRTEXTVERTADJUST_BOTTOM)
3085cdf0e10cSrcweir 	{
3086cdf0e10cSrcweir 		long nFreeHgt=aAnkRect.GetHeight()-aTextSiz.Height();
3087cdf0e10cSrcweir 		if (eVAdj==SDRTEXTVERTADJUST_CENTER)
3088cdf0e10cSrcweir 			aTextPos.Y()+=nFreeHgt/2;
3089cdf0e10cSrcweir 		if (eVAdj==SDRTEXTVERTADJUST_BOTTOM)
3090cdf0e10cSrcweir 			aTextPos.Y()+=nFreeHgt;
3091cdf0e10cSrcweir 	}
3092cdf0e10cSrcweir 	if (aGeo.nDrehWink!=0)
3093cdf0e10cSrcweir 		RotatePoint(aTextPos,aAnkRect.TopLeft(),aGeo.nSin,aGeo.nCos);
3094cdf0e10cSrcweir 
3095cdf0e10cSrcweir 	if (pAnchorRect)
3096cdf0e10cSrcweir 		*pAnchorRect=aAnkRect;
3097cdf0e10cSrcweir 
3098cdf0e10cSrcweir 	// rTextRect ist bei ContourFrame in einigen Faellen nicht korrekt
3099cdf0e10cSrcweir 	rTextRect=Rectangle(aTextPos,aTextSiz);
3100cdf0e10cSrcweir }
3101cdf0e10cSrcweir 
3102cdf0e10cSrcweir void SdrObjCustomShape::NbcSetOutlinerParaObject(OutlinerParaObject* pTextObject)
3103cdf0e10cSrcweir {
3104cdf0e10cSrcweir 	SdrTextObj::NbcSetOutlinerParaObject( pTextObject );
3105cdf0e10cSrcweir 	SetBoundRectDirty();
3106cdf0e10cSrcweir 	SetRectsDirty(sal_True);
3107cdf0e10cSrcweir 	InvalidateRenderGeometry();
3108cdf0e10cSrcweir }
3109cdf0e10cSrcweir 
3110cdf0e10cSrcweir void SdrObjCustomShape::operator=(const SdrObject& rObj)
3111cdf0e10cSrcweir {
3112cdf0e10cSrcweir 	SdrTextObj::operator=( rObj );
3113cdf0e10cSrcweir 	aName =((SdrObjCustomShape&)rObj).aName;
3114cdf0e10cSrcweir 	fObjectRotation = ((SdrObjCustomShape&)rObj).fObjectRotation;
3115cdf0e10cSrcweir 	InvalidateRenderGeometry();
3116cdf0e10cSrcweir }
3117cdf0e10cSrcweir 
3118cdf0e10cSrcweir 
3119cdf0e10cSrcweir void SdrObjCustomShape::TakeObjNameSingul(XubString& rName) const
3120cdf0e10cSrcweir {
3121cdf0e10cSrcweir 	rName = ImpGetResStr(STR_ObjNameSingulCUSTOMSHAPE);
3122cdf0e10cSrcweir 	String aNm( GetName() );
3123cdf0e10cSrcweir 	if( aNm.Len() )
3124cdf0e10cSrcweir 	{
3125cdf0e10cSrcweir 		rName += sal_Unicode(' ');
3126cdf0e10cSrcweir 		rName += sal_Unicode('\'');
3127cdf0e10cSrcweir 		rName += aNm;
3128cdf0e10cSrcweir 		rName += sal_Unicode('\'');
3129cdf0e10cSrcweir 	}
3130cdf0e10cSrcweir }
3131cdf0e10cSrcweir 
3132cdf0e10cSrcweir void SdrObjCustomShape::TakeObjNamePlural(XubString& rName) const
3133cdf0e10cSrcweir {
3134cdf0e10cSrcweir 	rName=ImpGetResStr(STR_ObjNamePluralCUSTOMSHAPE);
3135cdf0e10cSrcweir }
3136cdf0e10cSrcweir 
3137cdf0e10cSrcweir basegfx::B2DPolyPolygon SdrObjCustomShape::TakeXorPoly() const
3138cdf0e10cSrcweir {
3139cdf0e10cSrcweir 	return GetLineGeometry( (SdrObjCustomShape*)this, sal_False );
3140cdf0e10cSrcweir }
3141cdf0e10cSrcweir 
3142cdf0e10cSrcweir basegfx::B2DPolyPolygon SdrObjCustomShape::TakeContour() const
3143cdf0e10cSrcweir {
3144cdf0e10cSrcweir 	const SdrObject* pSdrObject = GetSdrObjectFromCustomShape();
3145cdf0e10cSrcweir 	if ( pSdrObject )
3146cdf0e10cSrcweir 		return pSdrObject->TakeContour();
3147cdf0e10cSrcweir 	return basegfx::B2DPolyPolygon();
3148cdf0e10cSrcweir }
3149cdf0e10cSrcweir 
3150a5258243SPedro Giffuni SdrObject* SdrObjCustomShape::DoConvertToPolyObj(sal_Bool bBezier, bool bAddText) const
3151cdf0e10cSrcweir {
3152cdf0e10cSrcweir 	// #i37011#
3153cdf0e10cSrcweir 	SdrObject* pRetval = 0L;
3154cdf0e10cSrcweir 	SdrObject* pRenderedCustomShape = 0L;
3155cdf0e10cSrcweir 
3156cdf0e10cSrcweir 	if ( !mXRenderedCustomShape.is() )
3157cdf0e10cSrcweir 	{
3158cdf0e10cSrcweir 		// force CustomShape
3159cdf0e10cSrcweir 		((SdrObjCustomShape*)this)->GetSdrObjectFromCustomShape();
3160cdf0e10cSrcweir 	}
3161cdf0e10cSrcweir 
3162cdf0e10cSrcweir 	if ( mXRenderedCustomShape.is() )
3163cdf0e10cSrcweir 	{
3164cdf0e10cSrcweir 		pRenderedCustomShape = GetSdrObjectFromXShape( mXRenderedCustomShape );
3165cdf0e10cSrcweir 	}
3166cdf0e10cSrcweir 
3167cdf0e10cSrcweir 	if ( pRenderedCustomShape )
3168cdf0e10cSrcweir 	{
3169cdf0e10cSrcweir 		SdrObject* pCandidate = pRenderedCustomShape->Clone();
3170cdf0e10cSrcweir 		DBG_ASSERT(pCandidate, "SdrObjCustomShape::DoConvertToPolyObj: Could not clone SdrObject (!)");
3171cdf0e10cSrcweir 		pCandidate->SetModel(GetModel());
3172a5258243SPedro Giffuni 		pRetval = pCandidate->DoConvertToPolyObj(bBezier, bAddText);
3173cdf0e10cSrcweir 		SdrObject::Free( pCandidate );
3174cdf0e10cSrcweir 
3175cdf0e10cSrcweir 		if(pRetval)
3176cdf0e10cSrcweir 		{
3177cdf0e10cSrcweir 			const sal_Bool bShadow(((SdrShadowItem&)GetMergedItem(SDRATTR_SHADOW)).GetValue());
3178cdf0e10cSrcweir 			if(bShadow)
3179cdf0e10cSrcweir 			{
3180cdf0e10cSrcweir 				pRetval->SetMergedItem(SdrShadowItem(sal_True));
3181cdf0e10cSrcweir 			}
3182cdf0e10cSrcweir 		}
3183cdf0e10cSrcweir 
3184a5258243SPedro Giffuni 		if(bAddText && HasText() && !IsTextPath())
3185cdf0e10cSrcweir 		{
3186cdf0e10cSrcweir 			pRetval = ImpConvertAddText(pRetval, bBezier);
3187cdf0e10cSrcweir 		}
3188cdf0e10cSrcweir 	}
3189cdf0e10cSrcweir 
3190cdf0e10cSrcweir 	return pRetval;
3191cdf0e10cSrcweir }
3192cdf0e10cSrcweir 
3193cdf0e10cSrcweir void SdrObjCustomShape::NbcSetStyleSheet( SfxStyleSheet* pNewStyleSheet, sal_Bool bDontRemoveHardAttr )
3194cdf0e10cSrcweir {
3195cdf0e10cSrcweir 	// #i40944#
3196cdf0e10cSrcweir 	InvalidateRenderGeometry();
3197cdf0e10cSrcweir 	SdrObject::NbcSetStyleSheet( pNewStyleSheet, bDontRemoveHardAttr );
3198cdf0e10cSrcweir }
3199cdf0e10cSrcweir 
3200cdf0e10cSrcweir void SdrObjCustomShape::SetPage( SdrPage* pNewPage )
3201cdf0e10cSrcweir {
3202cdf0e10cSrcweir 	SdrTextObj::SetPage( pNewPage );
3203cdf0e10cSrcweir 
3204cdf0e10cSrcweir 	if( pNewPage )
3205cdf0e10cSrcweir 	{
3206cdf0e10cSrcweir 		// invalidating rectangles by SetRectsDirty is not sufficient,
3207cdf0e10cSrcweir 		// AdjustTextFrameWidthAndHeight() also has to be made, both
3208cdf0e10cSrcweir 		// actions are done by NbcSetSnapRect
3209cdf0e10cSrcweir 		Rectangle aTmp( aRect );	//creating temporary rectangle #i61108#
3210cdf0e10cSrcweir 		NbcSetSnapRect( aTmp );
3211cdf0e10cSrcweir 	}
3212cdf0e10cSrcweir }
3213cdf0e10cSrcweir 
3214cdf0e10cSrcweir SdrObjGeoData* SdrObjCustomShape::NewGeoData() const
3215cdf0e10cSrcweir {
3216cdf0e10cSrcweir 	return new SdrAShapeObjGeoData;
3217cdf0e10cSrcweir }
3218cdf0e10cSrcweir 
3219cdf0e10cSrcweir void SdrObjCustomShape::SaveGeoData(SdrObjGeoData& rGeo) const
3220cdf0e10cSrcweir {
3221cdf0e10cSrcweir 	SdrTextObj::SaveGeoData( rGeo );
3222cdf0e10cSrcweir 	SdrAShapeObjGeoData& rAGeo=(SdrAShapeObjGeoData&)rGeo;
3223cdf0e10cSrcweir 	rAGeo.fObjectRotation = fObjectRotation;
3224cdf0e10cSrcweir 	rAGeo.bMirroredX = IsMirroredX();
3225cdf0e10cSrcweir 	rAGeo.bMirroredY = IsMirroredY();
3226cdf0e10cSrcweir 
3227cdf0e10cSrcweir 	const rtl::OUString	sAdjustmentValues( RTL_CONSTASCII_USTRINGPARAM ( "AdjustmentValues" ) );
3228cdf0e10cSrcweir 	Any* pAny( ( (SdrCustomShapeGeometryItem&)GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) ).GetPropertyValueByName( sAdjustmentValues ) );
3229cdf0e10cSrcweir 	if ( pAny )
3230cdf0e10cSrcweir 		*pAny >>= rAGeo.aAdjustmentSeq;
3231cdf0e10cSrcweir }
3232cdf0e10cSrcweir 
3233cdf0e10cSrcweir void SdrObjCustomShape::RestGeoData(const SdrObjGeoData& rGeo)
3234cdf0e10cSrcweir {
3235cdf0e10cSrcweir 	SdrTextObj::RestGeoData( rGeo );
3236cdf0e10cSrcweir 	SdrAShapeObjGeoData& rAGeo=(SdrAShapeObjGeoData&)rGeo;
3237cdf0e10cSrcweir 	fObjectRotation = rAGeo.fObjectRotation;
3238cdf0e10cSrcweir 	SetMirroredX( rAGeo.bMirroredX );
3239cdf0e10cSrcweir 	SetMirroredY( rAGeo.bMirroredY );
3240cdf0e10cSrcweir 
3241cdf0e10cSrcweir 	SdrCustomShapeGeometryItem rGeometryItem = (SdrCustomShapeGeometryItem&)GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY );
3242cdf0e10cSrcweir 	const rtl::OUString	sAdjustmentValues( RTL_CONSTASCII_USTRINGPARAM ( "AdjustmentValues" ) );
3243cdf0e10cSrcweir 	PropertyValue aPropVal;
3244cdf0e10cSrcweir 	aPropVal.Name = sAdjustmentValues;
3245cdf0e10cSrcweir 	aPropVal.Value <<= rAGeo.aAdjustmentSeq;
3246cdf0e10cSrcweir 	rGeometryItem.SetPropertyValue( aPropVal );
3247cdf0e10cSrcweir 	SetMergedItem( rGeometryItem );
3248cdf0e10cSrcweir 
3249cdf0e10cSrcweir 	InvalidateRenderGeometry();
3250cdf0e10cSrcweir }
3251cdf0e10cSrcweir 
3252cdf0e10cSrcweir void SdrObjCustomShape::TRSetBaseGeometry(const basegfx::B2DHomMatrix& rMatrix, const basegfx::B2DPolyPolygon& /*rPolyPolygon*/)
3253cdf0e10cSrcweir {
3254cdf0e10cSrcweir 	// break up matrix
3255cdf0e10cSrcweir 	basegfx::B2DTuple aScale;
3256cdf0e10cSrcweir 	basegfx::B2DTuple aTranslate;
3257cdf0e10cSrcweir 	double fRotate, fShearX;
3258cdf0e10cSrcweir 	rMatrix.decompose(aScale, aTranslate, fRotate, fShearX);
3259cdf0e10cSrcweir 
3260cdf0e10cSrcweir 	// #i75086# Old DrawingLayer (GeoStat and geometry) does not support holding negative scalings
3261cdf0e10cSrcweir 	// in X and Y which equal a 180 degree rotation. Recognize it and react accordingly
32628be9f9d1SArmin Le Grand     const bool bMirrorX(basegfx::fTools::less(aScale.getX(), 0.0));
32638be9f9d1SArmin Le Grand     const bool bMirrorY(basegfx::fTools::less(aScale.getY(), 0.0));
32648be9f9d1SArmin Le Grand 
32658be9f9d1SArmin Le Grand 	if(bMirrorX && bMirrorY)
3266cdf0e10cSrcweir 	{
3267cdf0e10cSrcweir 		aScale.setX(fabs(aScale.getX()));
3268cdf0e10cSrcweir 		aScale.setY(fabs(aScale.getY()));
3269cdf0e10cSrcweir 		fRotate = fmod(fRotate + F_PI, F_2PI);
3270cdf0e10cSrcweir 	}
32718be9f9d1SArmin Le Grand     else if(bMirrorX || bMirrorY)
32728be9f9d1SArmin Le Grand     {
32738be9f9d1SArmin Le Grand         basegfx::B2DHomMatrix aNew;
32748be9f9d1SArmin Le Grand 
32758be9f9d1SArmin Le Grand         // create pre-multiplied matrix without mirroring
32768be9f9d1SArmin Le Grand         aNew.translate(-0.5, -0.5);
32778be9f9d1SArmin Le Grand         aNew.scale(bMirrorX ? -1.0 : 1.0, bMirrorY ? -1.0 : 1.0);
32788be9f9d1SArmin Le Grand         aNew.translate(0.5, 0.5);
32798be9f9d1SArmin Le Grand         aNew = rMatrix * aNew;
32808be9f9d1SArmin Le Grand 
32818be9f9d1SArmin Le Grand         // decompose to get corrected, mirror-free values
32828be9f9d1SArmin Le Grand         aNew.decompose(aScale, aTranslate, fRotate, fShearX);
32838be9f9d1SArmin Le Grand 
32848be9f9d1SArmin Le Grand         // apply mirroring to CustomShapeGeometry
32858be9f9d1SArmin Le Grand         if((bool)IsMirroredX() != bMirrorX)
32868be9f9d1SArmin Le Grand         {
32878be9f9d1SArmin Le Grand             SetMirroredX(bMirrorX);
32888be9f9d1SArmin Le Grand         }
32898be9f9d1SArmin Le Grand 
32908be9f9d1SArmin Le Grand         if((bool)IsMirroredY() != bMirrorY)
32918be9f9d1SArmin Le Grand         {
32928be9f9d1SArmin Le Grand             SetMirroredY(bMirrorY);
32938be9f9d1SArmin Le Grand         }
32948be9f9d1SArmin Le Grand     }
3295cdf0e10cSrcweir 
3296cdf0e10cSrcweir 	// reset object shear and rotations
3297cdf0e10cSrcweir 	aGeo.nDrehWink = 0;
3298cdf0e10cSrcweir 	aGeo.RecalcSinCos();
3299cdf0e10cSrcweir 	aGeo.nShearWink = 0;
3300cdf0e10cSrcweir 	aGeo.RecalcTan();
3301cdf0e10cSrcweir 
3302cdf0e10cSrcweir 	// force metric to pool metric
3303cdf0e10cSrcweir 	SfxMapUnit eMapUnit = GetObjectItemSet().GetPool()->GetMetric(0);
3304cdf0e10cSrcweir 	if(eMapUnit != SFX_MAPUNIT_100TH_MM)
3305cdf0e10cSrcweir 	{
3306cdf0e10cSrcweir 		switch(eMapUnit)
3307cdf0e10cSrcweir 		{
3308cdf0e10cSrcweir 			case SFX_MAPUNIT_TWIP :
3309cdf0e10cSrcweir 			{
3310cdf0e10cSrcweir 				// position
3311cdf0e10cSrcweir 				aTranslate.setX(ImplMMToTwips(aTranslate.getX()));
3312cdf0e10cSrcweir 				aTranslate.setY(ImplMMToTwips(aTranslate.getY()));
3313cdf0e10cSrcweir 
3314cdf0e10cSrcweir 				// size
3315cdf0e10cSrcweir 				aScale.setX(ImplMMToTwips(aScale.getX()));
3316cdf0e10cSrcweir 				aScale.setY(ImplMMToTwips(aScale.getY()));
3317cdf0e10cSrcweir 
3318cdf0e10cSrcweir 				break;
3319cdf0e10cSrcweir 			}
3320cdf0e10cSrcweir 			default:
3321cdf0e10cSrcweir 			{
3322cdf0e10cSrcweir 				DBG_ERROR("TRSetBaseGeometry: Missing unit translation to PoolMetric!");
3323cdf0e10cSrcweir 			}
3324cdf0e10cSrcweir 		}
3325cdf0e10cSrcweir 	}
3326cdf0e10cSrcweir 
3327cdf0e10cSrcweir 	// if anchor is used, make position relative to it
3328cdf0e10cSrcweir 	if( pModel && pModel->IsWriter() )
3329cdf0e10cSrcweir 	{
3330cdf0e10cSrcweir 		if(GetAnchorPos().X() || GetAnchorPos().Y())
3331cdf0e10cSrcweir 		{
3332cdf0e10cSrcweir 			aTranslate += basegfx::B2DTuple(GetAnchorPos().X(), GetAnchorPos().Y());
3333cdf0e10cSrcweir 		}
3334cdf0e10cSrcweir 	}
3335cdf0e10cSrcweir 
3336cdf0e10cSrcweir 	// build and set BaseRect (use scale)
3337cdf0e10cSrcweir 	Point aPoint = Point();
3338cdf0e10cSrcweir 	Size aSize(FRound(aScale.getX()), FRound(aScale.getY()));
3339cdf0e10cSrcweir 	Rectangle aBaseRect(aPoint, aSize);
3340cdf0e10cSrcweir 	SetSnapRect(aBaseRect);
3341cdf0e10cSrcweir 
3342cdf0e10cSrcweir 	// shear?
3343cdf0e10cSrcweir 	if(!basegfx::fTools::equalZero(fShearX))
3344cdf0e10cSrcweir 	{
3345cdf0e10cSrcweir 		GeoStat aGeoStat;
3346*40a852fbSArmin Le Grand         // #121932# do *not* forget to invert shearX(!)
3347*40a852fbSArmin Le Grand 		aGeoStat.nShearWink = FRound((atan(-fShearX) / F_PI180) * 100.0);
3348cdf0e10cSrcweir 		aGeoStat.RecalcTan();
3349cdf0e10cSrcweir 		Shear(Point(), aGeoStat.nShearWink, aGeoStat.nTan, sal_False);
3350cdf0e10cSrcweir 	}
3351cdf0e10cSrcweir 
3352cdf0e10cSrcweir 	// rotation?
3353cdf0e10cSrcweir     if(!basegfx::fTools::equalZero(fRotate))
3354cdf0e10cSrcweir 	{
3355cdf0e10cSrcweir 		GeoStat aGeoStat;
3356cdf0e10cSrcweir 
3357cdf0e10cSrcweir         // #i78696#
3358cdf0e10cSrcweir         // fRotate is mathematically correct, but aGeoStat.nDrehWink is
3359cdf0e10cSrcweir         // mirrored -> mirror value here
3360cdf0e10cSrcweir 		aGeoStat.nDrehWink = NormAngle360(FRound(-fRotate / F_PI18000));
3361cdf0e10cSrcweir 		aGeoStat.RecalcSinCos();
3362cdf0e10cSrcweir 		Rotate(Point(), aGeoStat.nDrehWink, aGeoStat.nSin, aGeoStat.nCos);
3363cdf0e10cSrcweir 	}
3364cdf0e10cSrcweir 
3365cdf0e10cSrcweir 	// translate?
3366cdf0e10cSrcweir     if(!aTranslate.equalZero())
3367cdf0e10cSrcweir 	{
3368cdf0e10cSrcweir 		Move(Size(FRound(aTranslate.getX()), FRound(aTranslate.getY())));
3369cdf0e10cSrcweir 	}
3370cdf0e10cSrcweir }
3371cdf0e10cSrcweir 
3372cdf0e10cSrcweir // taking fObjectRotation instead of aGeo.nWink
3373cdf0e10cSrcweir sal_Bool SdrObjCustomShape::TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, basegfx::B2DPolyPolygon& /*rPolyPolygon*/) const
3374cdf0e10cSrcweir {
3375cdf0e10cSrcweir 	// get turn and shear
3376cdf0e10cSrcweir //	double fRotate = (aGeo.nDrehWink / 100.0) * F_PI180;
3377cdf0e10cSrcweir 	double fRotate = fObjectRotation * F_PI180;
3378cdf0e10cSrcweir 	double fShearX = (aGeo.nShearWink / 100.0) * F_PI180;
3379cdf0e10cSrcweir 
3380cdf0e10cSrcweir 	// get aRect, this is the unrotated snaprect
3381cdf0e10cSrcweir 	Rectangle aRectangle(aRect);
3382cdf0e10cSrcweir 
3383cdf0e10cSrcweir 	sal_Bool bMirroredX = IsMirroredX();
3384cdf0e10cSrcweir 	sal_Bool bMirroredY = IsMirroredY();
3385cdf0e10cSrcweir 	if ( bMirroredX || bMirroredY )
3386cdf0e10cSrcweir 	{	// we have to retrieve the unmirrored rect
3387cdf0e10cSrcweir 
3388cdf0e10cSrcweir 		GeoStat aNewGeo( aGeo );
3389cdf0e10cSrcweir 
3390cdf0e10cSrcweir 		if ( bMirroredX )
3391cdf0e10cSrcweir 		{
3392cdf0e10cSrcweir 			Polygon aPol( Rect2Poly( aRect, aNewGeo ) );
3393cdf0e10cSrcweir 			Rectangle aBoundRect( aPol.GetBoundRect() );
3394cdf0e10cSrcweir 
3395cdf0e10cSrcweir 			Point aRef1( ( aBoundRect.Left() + aBoundRect.Right() ) >> 1, aBoundRect.Top() );
3396cdf0e10cSrcweir 			Point aRef2( aRef1.X(), aRef1.Y() + 1000 );
3397cdf0e10cSrcweir 			sal_uInt16 i;
3398cdf0e10cSrcweir 			sal_uInt16 nPntAnz=aPol.GetSize();
3399cdf0e10cSrcweir 			for (i=0; i<nPntAnz; i++)
3400cdf0e10cSrcweir 			{
3401cdf0e10cSrcweir 				MirrorPoint(aPol[i],aRef1,aRef2);
3402cdf0e10cSrcweir 			}
3403cdf0e10cSrcweir 			// Polygon wenden und etwas schieben
3404cdf0e10cSrcweir 			Polygon aPol0(aPol);
3405cdf0e10cSrcweir 			aPol[0]=aPol0[1];
3406cdf0e10cSrcweir 			aPol[1]=aPol0[0];
3407cdf0e10cSrcweir 			aPol[2]=aPol0[3];
3408cdf0e10cSrcweir 			aPol[3]=aPol0[2];
3409cdf0e10cSrcweir 			aPol[4]=aPol0[1];
3410cdf0e10cSrcweir 			Poly2Rect(aPol,aRectangle,aNewGeo);
3411cdf0e10cSrcweir 		}
3412cdf0e10cSrcweir 		if ( bMirroredY )
3413cdf0e10cSrcweir 		{
3414cdf0e10cSrcweir 			Polygon aPol( Rect2Poly( aRectangle, aNewGeo ) );
3415cdf0e10cSrcweir 			Rectangle aBoundRect( aPol.GetBoundRect() );
3416cdf0e10cSrcweir 
3417cdf0e10cSrcweir 			Point aRef1( aBoundRect.Left(), ( aBoundRect.Top() + aBoundRect.Bottom() ) >> 1 );
3418cdf0e10cSrcweir 			Point aRef2( aRef1.X() + 1000, aRef1.Y() );
3419cdf0e10cSrcweir 			sal_uInt16 i;
3420cdf0e10cSrcweir 			sal_uInt16 nPntAnz=aPol.GetSize();
3421cdf0e10cSrcweir 			for (i=0; i<nPntAnz; i++)
3422cdf0e10cSrcweir 			{
3423cdf0e10cSrcweir 				MirrorPoint(aPol[i],aRef1,aRef2);
3424cdf0e10cSrcweir 			}
3425cdf0e10cSrcweir 			// Polygon wenden und etwas schieben
3426cdf0e10cSrcweir 			Polygon aPol0(aPol);
3427*40a852fbSArmin Le Grand 			aPol[0]=aPol0[1]; // This was WRONG for vertical (!)
3428*40a852fbSArmin Le Grand 			aPol[1]=aPol0[0]; // #121932# Despite my own coment above
3429*40a852fbSArmin Le Grand 			aPol[2]=aPol0[3]; // it was *not* wrong even when the reordering
3430*40a852fbSArmin Le Grand 			aPol[3]=aPol0[2]; // *seems* to be specific for X-Mirrorings. Oh
3431*40a852fbSArmin Le Grand 			aPol[4]=aPol0[1]; // will I be happy when this old stuff is |gone| with aw080 (!)
3432cdf0e10cSrcweir 			Poly2Rect(aPol,aRectangle,aNewGeo);
3433cdf0e10cSrcweir 		}
3434cdf0e10cSrcweir 	}
3435cdf0e10cSrcweir 
3436cdf0e10cSrcweir 	// fill other values
3437cdf0e10cSrcweir 	basegfx::B2DTuple aScale(aRectangle.GetWidth(), aRectangle.GetHeight());
3438cdf0e10cSrcweir 	basegfx::B2DTuple aTranslate(aRectangle.Left(), aRectangle.Top());
3439cdf0e10cSrcweir 
3440cdf0e10cSrcweir 	// position maybe relative to anchorpos, convert
3441cdf0e10cSrcweir 	if( pModel && pModel->IsWriter() )
3442cdf0e10cSrcweir 	{
3443cdf0e10cSrcweir 		if(GetAnchorPos().X() || GetAnchorPos().Y())
3444cdf0e10cSrcweir 		{
3445cdf0e10cSrcweir 			aTranslate -= basegfx::B2DTuple(GetAnchorPos().X(), GetAnchorPos().Y());
3446cdf0e10cSrcweir 		}
3447cdf0e10cSrcweir 	}
3448cdf0e10cSrcweir 
3449cdf0e10cSrcweir 	// force MapUnit to 100th mm
3450cdf0e10cSrcweir 	SfxMapUnit eMapUnit = GetObjectItemSet().GetPool()->GetMetric(0);
3451cdf0e10cSrcweir 	if(eMapUnit != SFX_MAPUNIT_100TH_MM)
3452cdf0e10cSrcweir 	{
3453cdf0e10cSrcweir 		switch(eMapUnit)
3454cdf0e10cSrcweir 		{
3455cdf0e10cSrcweir 			case SFX_MAPUNIT_TWIP :
3456cdf0e10cSrcweir 			{
3457cdf0e10cSrcweir 				// postion
3458cdf0e10cSrcweir 				aTranslate.setX(ImplTwipsToMM(aTranslate.getX()));
3459cdf0e10cSrcweir 				aTranslate.setY(ImplTwipsToMM(aTranslate.getY()));
3460cdf0e10cSrcweir 
3461cdf0e10cSrcweir 				// size
3462cdf0e10cSrcweir 				aScale.setX(ImplTwipsToMM(aScale.getX()));
3463cdf0e10cSrcweir 				aScale.setY(ImplTwipsToMM(aScale.getY()));
3464cdf0e10cSrcweir 
3465cdf0e10cSrcweir 				break;
3466cdf0e10cSrcweir 			}
3467cdf0e10cSrcweir 			default:
3468cdf0e10cSrcweir 			{
3469cdf0e10cSrcweir 				DBG_ERROR("TRGetBaseGeometry: Missing unit translation to 100th mm!");
3470cdf0e10cSrcweir 			}
3471cdf0e10cSrcweir 		}
3472cdf0e10cSrcweir 	}
3473cdf0e10cSrcweir 
3474cdf0e10cSrcweir 	// build matrix
3475cdf0e10cSrcweir 	rMatrix = basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix(
3476cdf0e10cSrcweir 		aScale,
3477cdf0e10cSrcweir 		basegfx::fTools::equalZero(fShearX) ? 0.0 : tan(fShearX),
3478cdf0e10cSrcweir 		basegfx::fTools::equalZero(fRotate) ? 0.0 : -fRotate,
3479cdf0e10cSrcweir 		aTranslate);
3480cdf0e10cSrcweir 
3481cdf0e10cSrcweir 	return sal_False;
3482cdf0e10cSrcweir }
3483cdf0e10cSrcweir 
3484cdf0e10cSrcweir sdr::contact::ViewContact* SdrObjCustomShape::CreateObjectSpecificViewContact()
3485cdf0e10cSrcweir {
3486cdf0e10cSrcweir 	return new sdr::contact::ViewContactOfSdrObjCustomShape(*this);
3487cdf0e10cSrcweir }
3488cdf0e10cSrcweir 
3489cdf0e10cSrcweir // #i33136#
3490cdf0e10cSrcweir bool SdrObjCustomShape::doConstructOrthogonal(const ::rtl::OUString& rName)
3491cdf0e10cSrcweir {
3492cdf0e10cSrcweir 	bool bRetval(false);
3493cdf0e10cSrcweir 	static ::rtl::OUString Imps_sNameASOrtho_quadrat( RTL_CONSTASCII_USTRINGPARAM( "quadrat" ) );
3494cdf0e10cSrcweir 	static ::rtl::OUString Imps_sNameASOrtho_round_quadrat( RTL_CONSTASCII_USTRINGPARAM( "round-quadrat" ) );
3495cdf0e10cSrcweir 	static ::rtl::OUString Imps_sNameASOrtho_circle( RTL_CONSTASCII_USTRINGPARAM( "circle" ) );
3496cdf0e10cSrcweir 	static ::rtl::OUString Imps_sNameASOrtho_circle_pie( RTL_CONSTASCII_USTRINGPARAM( "circle-pie" ) );
3497cdf0e10cSrcweir 	static ::rtl::OUString Imps_sNameASOrtho_ring( RTL_CONSTASCII_USTRINGPARAM( "ring" ) );
3498cdf0e10cSrcweir 
3499cdf0e10cSrcweir 	if(Imps_sNameASOrtho_quadrat.equalsIgnoreAsciiCase(rName))
3500cdf0e10cSrcweir 	{
3501cdf0e10cSrcweir 		bRetval = true;
3502cdf0e10cSrcweir 	}
3503cdf0e10cSrcweir 	else if(Imps_sNameASOrtho_round_quadrat.equalsIgnoreAsciiCase(rName))
3504cdf0e10cSrcweir 	{
3505cdf0e10cSrcweir 		bRetval = true;
3506cdf0e10cSrcweir 	}
3507cdf0e10cSrcweir 	else if(Imps_sNameASOrtho_circle.equalsIgnoreAsciiCase(rName))
3508cdf0e10cSrcweir 	{
3509cdf0e10cSrcweir 		bRetval = true;
3510cdf0e10cSrcweir 	}
3511cdf0e10cSrcweir 	else if(Imps_sNameASOrtho_circle_pie.equalsIgnoreAsciiCase(rName))
3512cdf0e10cSrcweir 	{
3513cdf0e10cSrcweir 		bRetval = true;
3514cdf0e10cSrcweir 	}
3515cdf0e10cSrcweir 	else if(Imps_sNameASOrtho_ring.equalsIgnoreAsciiCase(rName))
3516cdf0e10cSrcweir 	{
3517cdf0e10cSrcweir 		bRetval = true;
3518cdf0e10cSrcweir 	}
3519cdf0e10cSrcweir 
3520cdf0e10cSrcweir 	return bRetval;
3521cdf0e10cSrcweir }
3522cdf0e10cSrcweir 
3523cdf0e10cSrcweir // #i37011# centralize throw-away of render geometry
3524cdf0e10cSrcweir void SdrObjCustomShape::InvalidateRenderGeometry()
3525cdf0e10cSrcweir {
3526cdf0e10cSrcweir 	mXRenderedCustomShape = 0L;
3527cdf0e10cSrcweir     SdrObject::Free( mpLastShadowGeometry );
3528cdf0e10cSrcweir 	mpLastShadowGeometry = 0L;
3529cdf0e10cSrcweir }
3530cdf0e10cSrcweir 
3531cdf0e10cSrcweir // eof
3532