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