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