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