xref: /trunk/main/svx/source/svdraw/svdobj.cxx (revision 1cd65da9)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_svx.hxx"
26 #include <com/sun/star/lang/XComponent.hpp>
27 
28 #define _USE_MATH_DEFINES
29 #include <math.h>
30 #include <vcl/metaact.hxx>   // fuer TakeContour
31 #include <vcl/cvtsvm.hxx>
32 #include <tools/line.hxx>
33 #include <tools/bigint.hxx>
34 #include <tools/diagnose_ex.h>
35 #include <vector>
36 #include <svx/svdobj.hxx>
37 #include <svx/xpoly.hxx>
38 #include <svx/svdetc.hxx>
39 #include <svx/svdtrans.hxx>
40 #include <svx/svdhdl.hxx>
41 #include <svx/svddrag.hxx>
42 #include <svx/svdmodel.hxx>
43 #include <svx/svdpage.hxx>
44 #include <svx/svdovirt.hxx>  // Fuer Add/Del Ref
45 #include <svx/svdview.hxx>   // fuer Dragging (Ortho abfragen)
46 #include "svx/svdglob.hxx"   // StringCache
47 #include <svx/svdstr.hrc>    // Objektname
48 #include <svx/svdogrp.hxx>   // Factory
49 #include <svx/svdopath.hxx>  // Factory
50 #include <svx/svdoedge.hxx>  // Factory
51 #include <svx/svdorect.hxx>  // Factory
52 #include <svx/svdocirc.hxx>  // Factory
53 #include <svx/svdotext.hxx>  // Factory
54 #include <svx/svdomeas.hxx>  // Factory
55 #include <svx/svdograf.hxx>  // Factory
56 #include <svx/svdoole2.hxx>  // Factory
57 #include <svx/svdocapt.hxx>  // Factory
58 #include <svx/svdopage.hxx>  // Factory
59 #include <svx/svdouno.hxx>   // Factory
60 #include <svx/svdattrx.hxx> // NotPersistItems
61 #include <svx/svdoashp.hxx>
62 #include <svx/svdomedia.hxx>
63 #include <svx/xlnwtit.hxx>
64 #include <svx/xlnstwit.hxx>
65 #include <svx/xlnedwit.hxx>
66 #include <svx/xlnstit.hxx>
67 #include <svx/xlnedit.hxx>
68 #include <svx/xlnstcit.hxx>
69 #include <svx/xlnedcit.hxx>
70 #include <svx/xlndsit.hxx>
71 #include <svx/xlnclit.hxx>
72 #include <svx/xflclit.hxx>
73 #include <svx/svditer.hxx>
74 #include <svx/xlntrit.hxx>
75 #include <svx/xfltrit.hxx>
76 #include <svx/xfltrit.hxx>
77 #include <svx/xflftrit.hxx>
78 #include "svx/xlinjoit.hxx"
79 #include <svx/unopage.hxx>
80 #include <editeng/eeitem.hxx>
81 #include <svx/xenum.hxx>
82 #include <svx/xgrad.hxx>
83 #include <svx/xhatch.hxx>
84 #include <svx/xflhtit.hxx>
85 #include <svx/xbtmpit.hxx>
86 #include <svx/svdpool.hxx>
87 #include <editeng/editeng.hxx>
88 #include <vcl/salbtype.hxx>		// FRound
89 #include <svl/whiter.hxx>
90 
91 // #97849#
92 #include <svx/fmmodel.hxx>
93 #include <sfx2/objsh.hxx>
94 #include <sfx2/objface.hxx>
95 #include "svdoimp.hxx"
96 #include <vcl/graphictools.hxx>
97 #include <svtools/colorcfg.hxx>
98 #include <svx/sdr/properties/emptyproperties.hxx>
99 #include <svx/sdr/contact/viewcontactofsdrobj.hxx>
100 #include <svx/sdr/contact/viewcontactofgraphic.hxx>
101 #include <svx/sdr/contact/objectcontactofobjlistpainter.hxx>
102 #include <svx/sdr/contact/displayinfo.hxx>
103 #include <basegfx/polygon/b2dpolygon.hxx>
104 #include <basegfx/polygon/b2dpolygontools.hxx>
105 #include <basegfx/matrix/b2dhommatrix.hxx>
106 #include <basegfx/polygon/b2dpolypolygontools.hxx>
107 #include <basegfx/range/b2drange.hxx>
108 #include <svx/unoshape.hxx>
109 #include <vcl/virdev.hxx>
110 #include <basegfx/polygon/b2dpolypolygoncutter.hxx>
111 #include <drawinglayer/processor2d/contourextractor2d.hxx>
112 #include <drawinglayer/processor2d/linegeometryextractor2d.hxx>
113 #include <svx/polysc3d.hxx>
114 #include "svx/svdotable.hxx"
115 #include "svx/shapepropertynotifier.hxx"
116 #include <svx/sdrhittesthelper.hxx>
117 #include <svx/svdundo.hxx>
118 #include <basegfx/matrix/b2dhommatrixtools.hxx>
119 #include <svx/sdrobjectfilter.hxx>
120 
121 using namespace ::com::sun::star;
122 
123 // #104018# replace macros above with type-detecting methods
124 inline double ImplTwipsToMM(double fVal) { return (fVal * (127.0 / 72.0)); }
125 inline double ImplMMToTwips(double fVal) { return (fVal * (72.0 / 127.0)); }
126 
127 ////////////////////////////////////////////////////////////////////////////////////////////////////
128 
129 TYPEINIT0(SdrObjUserCall);
130 
131 SdrObjUserCall::~SdrObjUserCall()
132 {
133 }
134 
135 void SdrObjUserCall::Changed(const SdrObject& /*rObj*/, SdrUserCallType /*eType*/, const Rectangle& /*rOldBoundRect*/)
136 {
137 }
138 
139 ////////////////////////////////////////////////////////////////////////////////////////////////////
140 
141 TYPEINIT0(SdrObjUserData);
142 
143 void SdrObjUserData::operator=(const SdrObjUserData& /*rData*/)    // nicht implementiert
144 {
145 }
146 
147 sal_Bool SdrObjUserData::operator==(const SdrObjUserData& /*rData*/) const // nicht implementiert
148 {
149 	return sal_False;
150 }
151 
152 sal_Bool SdrObjUserData::operator!=(const SdrObjUserData& /*rData*/) const // nicht implementiert
153 {
154 	return sal_False;
155 }
156 
157 SdrObjUserData::~SdrObjUserData()
158 {
159 }
160 
161 FASTBOOL SdrObjUserData::HasMacro(const SdrObject* /*pObj*/) const
162 {
163 	return sal_False;
164 }
165 
166 SdrObject* SdrObjUserData::CheckMacroHit(const SdrObjMacroHitRec& rRec, const SdrObject* pObj) const
167 {
168 	if(pObj)
169     {
170         if(rRec.pPageView)
171         {
172     	    return SdrObjectPrimitiveHit(*pObj, rRec.aPos, rRec.nTol, *rRec.pPageView, rRec.pVisiLayer, false);
173         }
174     }
175 
176 	return 0;
177 }
178 
179 Pointer SdrObjUserData::GetMacroPointer(const SdrObjMacroHitRec& /*rRec*/, const SdrObject* /*pObj*/) const
180 {
181 	return Pointer(POINTER_REFHAND);
182 }
183 
184 void SdrObjUserData::PaintMacro(OutputDevice& rOut, const Rectangle& /*rDirtyRect*/, const SdrObjMacroHitRec& /*rRec*/, const SdrObject* pObj) const
185 {
186 	if(!pObj)
187         return;
188 
189 	const RasterOp eRop(rOut.GetRasterOp());
190 	const basegfx::B2DPolyPolygon aPolyPolygon(pObj->TakeXorPoly());
191 	const sal_uInt32 nCount(aPolyPolygon.count());
192 
193     rOut.SetLineColor(COL_BLACK);
194     rOut.SetFillColor();
195 	rOut.SetRasterOp(ROP_INVERT);
196 
197 	for(sal_uInt32 a(0); a < nCount; a++)
198 	{
199 		rOut.DrawPolyLine(aPolyPolygon.getB2DPolygon(a));
200 	}
201 
202     rOut.SetRasterOp(eRop);
203 }
204 
205 FASTBOOL SdrObjUserData::DoMacro(const SdrObjMacroHitRec& /*rRec*/, SdrObject* /*pObj*/)
206 {
207 	return sal_False;
208 }
209 
210 XubString SdrObjUserData::GetMacroPopupComment(const SdrObjMacroHitRec& /*rRec*/, const SdrObject* /*pObj*/) const
211 {
212 	return String();
213 }
214 
215 void SdrObjUserDataList::Clear()
216 {
217 	sal_uInt16 nAnz=GetUserDataCount();
218 	for (sal_uInt16 i=0; i<nAnz; i++) {
219 		delete GetUserData(i);
220 	}
221 	aList.Clear();
222 }
223 
224 ////////////////////////////////////////////////////////////////////////////////////////////////////
225 
226 DBG_NAME(SdrObjGeoData);
227 
228 SdrObjGeoData::SdrObjGeoData():
229 	pGPL(NULL),
230 	bMovProt(sal_False),
231 	bSizProt(sal_False),
232 	bNoPrint(sal_False),
233 	bClosedObj(sal_False),
234 	mbVisible(true),
235 	mnLayerID(0)
236 {
237 	DBG_CTOR(SdrObjGeoData,NULL);
238 }
239 
240 SdrObjGeoData::~SdrObjGeoData()
241 {
242 	DBG_DTOR(SdrObjGeoData,NULL);
243 	delete pGPL;
244 }
245 
246 ////////////////////////////////////////////////////////////////////////////////////////////////////
247 
248 TYPEINIT0(SdrObjPlusData);
249 
250 SdrObjPlusData::SdrObjPlusData():
251 	pBroadcast(NULL),
252 	pUserDataList(NULL),
253 	pGluePoints(NULL),
254 	pAutoTimer(NULL)
255 {
256 }
257 
258 SdrObjPlusData::~SdrObjPlusData()
259 {
260 	if (pBroadcast   !=NULL) delete pBroadcast;
261 	if (pUserDataList!=NULL) delete pUserDataList;
262 	if (pGluePoints  !=NULL) delete pGluePoints;
263 	if (pAutoTimer   !=NULL) delete pAutoTimer;
264 }
265 
266 SdrObjPlusData* SdrObjPlusData::Clone(SdrObject* pObj1) const
267 {
268 	SdrObjPlusData* pNeuPlusData=new SdrObjPlusData;
269 	if (pUserDataList!=NULL) {
270 		sal_uInt16 nAnz=pUserDataList->GetUserDataCount();
271 		if (nAnz!=0) {
272 			pNeuPlusData->pUserDataList=new SdrObjUserDataList;
273 			for (sal_uInt16 i=0; i<nAnz; i++) {
274 				SdrObjUserData* pNeuUserData=pUserDataList->GetUserData(i)->Clone(pObj1);
275 				if (pNeuUserData!=NULL) {
276 					pNeuPlusData->pUserDataList->InsertUserData(pNeuUserData);
277 				} else {
278 					DBG_ERROR("SdrObjPlusData::Clone(): UserData.Clone() liefert NULL");
279 				}
280 			}
281 		}
282 	}
283 	if (pGluePoints!=NULL) pNeuPlusData->pGluePoints=new SdrGluePointList(*pGluePoints);
284 	// MtfAnimator wird auch nicht mitkopiert
285 
286 	// #i68101#
287 	// copy object name, title and description
288 	pNeuPlusData->aObjName = aObjName;
289 	pNeuPlusData->aObjTitle = aObjTitle;
290 	pNeuPlusData->aObjDescription = aObjDescription;
291 
292 	if (pAutoTimer!=NULL) {
293 		pNeuPlusData->pAutoTimer=new AutoTimer;
294 		// Handler, etc. nicht mitkopieren!
295 	}
296 
297 	// For HTMLName: Do not clone, leave uninitialized (empty string)
298 
299 	return pNeuPlusData;
300 }
301 
302 ////////////////////////////////////////////////////////////////////////////////////////////////////
303 //
304 //   @@@@  @@@@@  @@@@@@ @@@@@  @@@@  @@@@@@
305 //  @@  @@ @@  @@     @@ @@    @@  @@   @@
306 //  @@  @@ @@  @@     @@ @@    @@       @@
307 //  @@  @@ @@@@@      @@ @@@@  @@       @@
308 //  @@  @@ @@  @@     @@ @@    @@       @@
309 //  @@  @@ @@  @@ @@  @@ @@    @@  @@   @@
310 //   @@@@  @@@@@   @@@@  @@@@@  @@@@    @@
311 //
312 ////////////////////////////////////////////////////////////////////////////////////////////////////
313 
314 //////////////////////////////////////////////////////////////////////////////
315 // BaseProperties section
316 
317 sdr::properties::BaseProperties* SdrObject::CreateObjectSpecificProperties()
318 {
319 	return new sdr::properties::EmptyProperties(*this);
320 }
321 
322 sdr::properties::BaseProperties& SdrObject::GetProperties() const
323 {
324 	if(!mpProperties)
325 	{
326 		const_cast< SdrObject* >(this)->mpProperties =
327             const_cast< SdrObject* >(this)->CreateObjectSpecificProperties();
328 	}
329 
330 	return *mpProperties;
331 }
332 
333 //////////////////////////////////////////////////////////////////////////////
334 // ObjectUser section
335 
336 void SdrObject::AddObjectUser(sdr::ObjectUser& rNewUser)
337 {
338 	maObjectUsers.push_back(&rNewUser);
339 }
340 
341 void SdrObject::RemoveObjectUser(sdr::ObjectUser& rOldUser)
342 {
343 	const ::sdr::ObjectUserVector::iterator aFindResult = ::std::find(maObjectUsers.begin(), maObjectUsers.end(), &rOldUser);
344 	if(aFindResult != maObjectUsers.end())
345 	{
346 		maObjectUsers.erase(aFindResult);
347 	}
348 }
349 
350 //////////////////////////////////////////////////////////////////////////////
351 // #110094# DrawContact section
352 
353 sdr::contact::ViewContact* SdrObject::CreateObjectSpecificViewContact()
354 {
355 	return new sdr::contact::ViewContactOfSdrObj(*this);
356 }
357 
358 sdr::contact::ViewContact& SdrObject::GetViewContact() const
359 {
360 	if(!mpViewContact)
361 	{
362 		const_cast< SdrObject* >(this)->mpViewContact =
363             const_cast< SdrObject* >(this)->CreateObjectSpecificViewContact();
364 	}
365 
366 	return *mpViewContact;
367 }
368 
369 // DrawContact support: Methods for handling Object changes
370 void SdrObject::ActionChanged() const
371 {
372     // Do necessary ViewContact actions
373 	GetViewContact().ActionChanged();
374 }
375 
376 //////////////////////////////////////////////////////////////////////////////
377 
378 void SdrObject::SetBoundRectDirty()
379 {
380 	aOutRect = Rectangle();
381 }
382 
383 //////////////////////////////////////////////////////////////////////////////
384 
385 DBG_NAME(SdrObject);
386 TYPEINIT1(SdrObject,SfxListener);
387 
388 SdrObject::SdrObject()
389     :mpProperties(0L)
390     ,mpViewContact(0L)
391     ,pObjList(NULL)
392     ,pPage(NULL)
393     ,pModel(NULL)
394     ,pUserCall(NULL)
395     ,pPlusData(NULL)
396     ,nOrdNum(0)
397     ,mnNavigationPosition(SAL_MAX_UINT32)
398     ,mnLayerID(0)
399     ,mpSvxShape( NULL )
400     ,maWeakUnoShape()
401 {
402 	DBG_CTOR(SdrObject,NULL);
403 	bVirtObj         =sal_False;
404 	bSnapRectDirty   =sal_True;
405 	bNetLock         =sal_False;
406 	bInserted        =sal_False;
407 	bGrouped         =sal_False;
408 	bMovProt         =sal_False;
409 	bSizProt         =sal_False;
410 	bNoPrint         =sal_False;
411 	bEmptyPresObj    =sal_False;
412 	bNotVisibleAsMaster=sal_False;
413 	bClosedObj       =sal_False;
414 	mbVisible		 = true;
415 
416 	// #i25616#
417 	mbLineIsOutsideGeometry = sal_False;
418 
419 	// #i25616#
420 	mbSupportTextIndentingOnLineWidthChange = sal_False;
421 
422 	//#110094#-1
423 	//bWriterFlyFrame  =sal_False;
424 
425 	bNotMasterCachable=sal_False;
426 	bIsEdge=sal_False;
427 	bIs3DObj=sal_False;
428 	bMarkProt=sal_False;
429 	bIsUnoObj=sal_False;
430 }
431 
432 SdrObject::~SdrObject()
433 {
434 	// tell all the registered ObjectUsers that the page is in destruction
435 	::sdr::ObjectUserVector aListCopy(maObjectUsers.begin(), maObjectUsers.end());
436 	for(::sdr::ObjectUserVector::iterator aIterator = aListCopy.begin(); aIterator != aListCopy.end(); aIterator++)
437 	{
438 		sdr::ObjectUser* pObjectUser = *aIterator;
439 		DBG_ASSERT(pObjectUser, "SdrObject::~SdrObject: corrupt ObjectUser list (!)");
440 		pObjectUser->ObjectInDestruction(*this);
441 	}
442 
443 	// Clear the vector. This means that user do not need to call RemoveObjectUser()
444 	// when they get called from ObjectInDestruction().
445 	maObjectUsers.clear();
446 
447     try
448     {
449         SvxShape* pSvxShape = getSvxShape();
450         if ( pSvxShape )
451         {
452             OSL_ENSURE(!pSvxShape->HasSdrObjectOwnership(),"Please check where this call come from and replace it with SdrObject::Free");
453             pSvxShape->InvalidateSdrObject();
454 	        uno::Reference< lang::XComponent > xShapeComp( getWeakUnoShape(), uno::UNO_QUERY_THROW );
455 		    xShapeComp->dispose();
456         }
457     }
458     catch( const uno::Exception& )
459     {
460     	DBG_UNHANDLED_EXCEPTION();
461     }
462 
463 	DBG_DTOR(SdrObject,NULL);
464 	SendUserCall(SDRUSERCALL_DELETE, GetLastBoundRect());
465 	if (pPlusData!=NULL) delete pPlusData;
466 
467 	if(mpProperties)
468 	{
469 		delete mpProperties;
470 		mpProperties = 0L;
471 	}
472 
473 	// #110094#
474 	if(mpViewContact)
475 	{
476 		delete mpViewContact;
477 		mpViewContact = 0L;
478 	}
479 }
480 
481 void SdrObject::Free( SdrObject*& _rpObject )
482 {
483     SdrObject* pObject = _rpObject; _rpObject = NULL;
484     if ( pObject == NULL )
485         // nothing to do
486         return;
487 
488 	SvxShape* pShape = pObject->getSvxShape();
489     if ( pShape && pShape->HasSdrObjectOwnership() )
490         // only the shape is allowed to delete me, and will reset the ownership before doing so
491         return;
492 
493     delete pObject;
494 }
495 
496 SdrObjPlusData* SdrObject::NewPlusData() const
497 {
498 	return new SdrObjPlusData;
499 }
500 
501 void SdrObject::SetRectsDirty(sal_Bool bNotMyself)
502 {
503 	if (!bNotMyself) {
504 		SetBoundRectDirty();
505 		bSnapRectDirty=sal_True;
506 	}
507 	if (pObjList!=NULL) {
508 		pObjList->SetRectsDirty();
509 	}
510 }
511 
512 void SdrObject::SetModel(SdrModel* pNewModel)
513 {
514 	if(pNewModel && pPage)
515 	{
516 		if(pPage->GetModel() != pNewModel)
517 		{
518 			pPage = NULL;
519 		}
520 	}
521 
522 	// update listeners at possible api wrapper object
523 	if( pModel != pNewModel )
524 	{
525 		SvxShape* pShape = getSvxShape();
526 		if( pShape )
527 			pShape->ChangeModel( pNewModel );
528 	}
529 
530 	pModel = pNewModel;
531 }
532 
533 void SdrObject::SetObjList(SdrObjList* pNewObjList)
534 {
535 	pObjList=pNewObjList;
536 }
537 
538 void SdrObject::SetPage(SdrPage* pNewPage)
539 {
540 	pPage=pNewPage;
541 	if (pPage!=NULL) {
542 		SdrModel* pMod=pPage->GetModel();
543 		if (pMod!=pModel && pMod!=NULL) {
544 			SetModel(pMod);
545 		}}
546 }
547 
548 // init global static itempool
549 SdrItemPool* SdrObject::mpGlobalItemPool = NULL;
550 
551 SdrItemPool& SdrObject::GetGlobalDrawObjectItemPool()
552 {
553 	if(!mpGlobalItemPool)
554 	{
555 		mpGlobalItemPool = new SdrItemPool();
556 		SfxItemPool* pGlobalOutlPool = EditEngine::CreatePool();
557 		mpGlobalItemPool->SetSecondaryPool(pGlobalOutlPool);
558 		mpGlobalItemPool->SetDefaultMetric((SfxMapUnit)SdrEngineDefaults::GetMapUnit());
559 		mpGlobalItemPool->FreezeIdRanges();
560 	}
561 
562 	return *mpGlobalItemPool;
563 }
564 
565 void SdrObject::FreeGlobalDrawObjectItemPool()
566 {
567 	// code for deletion of GlobalItemPool
568 	if(mpGlobalItemPool)
569 	{
570 		SfxItemPool* pGlobalOutlPool = mpGlobalItemPool->GetSecondaryPool();
571         SfxItemPool::Free(mpGlobalItemPool);
572         SfxItemPool::Free(pGlobalOutlPool);
573 	}
574 }
575 
576 SdrItemPool* SdrObject::GetObjectItemPool() const
577 {
578 	if(pModel)
579 		return (SdrItemPool*)(&pModel->GetItemPool());
580 
581 	// use a static global default pool
582 	return &SdrObject::GetGlobalDrawObjectItemPool();
583 }
584 
585 sal_uInt32 SdrObject::GetObjInventor()   const
586 {
587 	return SdrInventor;
588 }
589 
590 sal_uInt16 SdrObject::GetObjIdentifier() const
591 {
592 	return sal_uInt16(OBJ_NONE);
593 }
594 
595 void SdrObject::TakeObjInfo(SdrObjTransformInfoRec& rInfo) const
596 {
597 	rInfo.bRotateFreeAllowed=sal_False;
598 	rInfo.bMirrorFreeAllowed=sal_False;
599 	rInfo.bTransparenceAllowed = sal_False;
600 	rInfo.bGradientAllowed = sal_False;
601 	rInfo.bShearAllowed     =sal_False;
602 	rInfo.bEdgeRadiusAllowed=sal_False;
603 	rInfo.bCanConvToPath    =sal_False;
604 	rInfo.bCanConvToPoly    =sal_False;
605 	rInfo.bCanConvToContour = sal_False;
606 	rInfo.bCanConvToPathLineToArea=sal_False;
607 	rInfo.bCanConvToPolyLineToArea=sal_False;
608 }
609 
610 SdrLayerID SdrObject::GetLayer() const
611 {
612 	return mnLayerID;
613 }
614 
615 void SdrObject::getMergedHierarchyLayerSet(SetOfByte& rSet) const
616 {
617 	rSet.Set(GetLayer());
618 	SdrObjList* pOL=GetSubList();
619 	if (pOL!=NULL) {
620 		sal_uIntPtr nObjAnz=pOL->GetObjCount();
621 		for (sal_uIntPtr nObjNum=0; nObjNum<nObjAnz; nObjNum++) {
622 			pOL->GetObj(nObjNum)->getMergedHierarchyLayerSet(rSet);
623 		}
624 	}
625 }
626 
627 void SdrObject::NbcSetLayer(SdrLayerID nLayer)
628 {
629 	if(GetLayer() != nLayer)
630 	{
631 		mnLayerID = nLayer;
632 	}
633 }
634 
635 void SdrObject::SetLayer(SdrLayerID nLayer)
636 {
637 	NbcSetLayer(nLayer);
638 	SetChanged();
639 	BroadcastObjectChange();
640 }
641 
642 void SdrObject::AddListener(SfxListener& rListener)
643 {
644 	ImpForcePlusData();
645 	if (pPlusData->pBroadcast==NULL) pPlusData->pBroadcast=new SfxBroadcaster;
646 	rListener.StartListening(*pPlusData->pBroadcast);
647 }
648 
649 void SdrObject::RemoveListener(SfxListener& rListener)
650 {
651 	if (pPlusData!=NULL && pPlusData->pBroadcast!=NULL) {
652 		rListener.EndListening(*pPlusData->pBroadcast);
653 		if (!pPlusData->pBroadcast->HasListeners()) {
654 			delete pPlusData->pBroadcast;
655 			pPlusData->pBroadcast=NULL;
656 		}
657 	}
658 }
659 
660 void SdrObject::AddReference(SdrVirtObj& rVrtObj)
661 {
662 	AddListener(rVrtObj);
663 }
664 
665 void SdrObject::DelReference(SdrVirtObj& rVrtObj)
666 {
667 	RemoveListener(rVrtObj);
668 }
669 
670 AutoTimer* SdrObject::ForceAutoTimer()
671 {
672 	ImpForcePlusData();
673 	if (pPlusData->pAutoTimer==NULL) pPlusData->pAutoTimer=new AutoTimer;
674 	return pPlusData->pAutoTimer;
675 }
676 
677 FASTBOOL SdrObject::HasRefPoint() const
678 {
679 	return sal_False;
680 }
681 
682 Point SdrObject::GetRefPoint() const
683 {
684 	return GetCurrentBoundRect().Center();
685 }
686 
687 void SdrObject::SetRefPoint(const Point& /*rPnt*/)
688 {
689 }
690 
691 SdrObjList* SdrObject::GetSubList() const
692 {
693 	return NULL;
694 }
695 
696 SdrObject* SdrObject::GetUpGroup() const
697 {
698 	return pObjList!=NULL ? pObjList->GetOwnerObj() : NULL;
699 }
700 
701 void SdrObject::SetName(const String& rStr)
702 {
703 	if(rStr.Len() && !pPlusData)
704 	{
705 		ImpForcePlusData();
706 	}
707 
708 	if(pPlusData && pPlusData->aObjName != rStr)
709 	{
710         // --> OD 2009-07-09 #i73249#
711         // Undo/Redo for setting object's name
712         bool bUndo( false );
713         if ( GetModel() && GetModel()->IsUndoEnabled() )
714         {
715             bUndo = true;
716             SdrUndoAction* pUndoAction =
717                     GetModel()->GetSdrUndoFactory().CreateUndoObjectStrAttr(
718                                                     *this,
719                                                     SdrUndoObjStrAttr::OBJ_NAME,
720                                                     GetName(),
721                                                     rStr );
722             GetModel()->BegUndo( pUndoAction->GetComment() );
723             GetModel()->AddUndo( pUndoAction );
724         }
725         // <--
726         pPlusData->aObjName = rStr;
727         // --> OD 2009-07-09 #i73249#
728         if ( bUndo )
729         {
730             GetModel()->EndUndo();
731         }
732         // <--
733 		SetChanged();
734         BroadcastObjectChange();
735 	}
736 }
737 
738 String SdrObject::GetName() const
739 {
740 	if(pPlusData)
741 	{
742 		return pPlusData->aObjName;
743 	}
744 
745 	return String();
746 }
747 
748 void SdrObject::SetTitle(const String& rStr)
749 {
750 	if(rStr.Len() && !pPlusData)
751 	{
752 		ImpForcePlusData();
753 	}
754 
755 	if(pPlusData && pPlusData->aObjTitle != rStr)
756 	{
757         // --> OD 2009-07-13 #i73249#
758         // Undo/Redo for setting object's title
759         bool bUndo( false );
760         if ( GetModel() && GetModel()->IsUndoEnabled() )
761         {
762             bUndo = true;
763             SdrUndoAction* pUndoAction =
764                     GetModel()->GetSdrUndoFactory().CreateUndoObjectStrAttr(
765                                                     *this,
766                                                     SdrUndoObjStrAttr::OBJ_TITLE,
767                                                     GetTitle(),
768                                                     rStr );
769             GetModel()->BegUndo( pUndoAction->GetComment() );
770             GetModel()->AddUndo( pUndoAction );
771         }
772         // <--
773 		pPlusData->aObjTitle = rStr;
774         // --> OD 2009-07-13 #i73249#
775         if ( bUndo )
776         {
777             GetModel()->EndUndo();
778         }
779         // <--
780 		SetChanged();
781         BroadcastObjectChange();
782 	}
783 }
784 
785 String SdrObject::GetTitle() const
786 {
787 	if(pPlusData)
788 	{
789 		return pPlusData->aObjTitle;
790 	}
791 
792 	return String();
793 }
794 
795 void SdrObject::SetDescription(const String& rStr)
796 {
797 	if(rStr.Len() && !pPlusData)
798 	{
799 		ImpForcePlusData();
800 	}
801 
802 	if(pPlusData && pPlusData->aObjDescription != rStr)
803 	{
804         // --> OD 2009-07-13 #i73249#
805         // Undo/Redo for setting object's description
806         bool bUndo( false );
807         if ( GetModel() && GetModel()->IsUndoEnabled() )
808         {
809             bUndo = true;
810             SdrUndoAction* pUndoAction =
811                     GetModel()->GetSdrUndoFactory().CreateUndoObjectStrAttr(
812                                                     *this,
813                                                     SdrUndoObjStrAttr::OBJ_DESCRIPTION,
814                                                     GetDescription(),
815                                                     rStr );
816             GetModel()->BegUndo( pUndoAction->GetComment() );
817             GetModel()->AddUndo( pUndoAction );
818         }
819         // <--
820 		pPlusData->aObjDescription = rStr;
821         // --> OD 2009-07-13 #i73249#
822         if ( bUndo )
823         {
824             GetModel()->EndUndo();
825         }
826         // <--
827 		SetChanged();
828         BroadcastObjectChange();
829 	}
830 }
831 
832 String SdrObject::GetDescription() const
833 {
834 	if(pPlusData)
835 	{
836 		return pPlusData->aObjDescription;
837 	}
838 
839 	return String();
840 }
841 
842 void SdrObject::SetHTMLName(const String& rStr)
843 {
844 	if(rStr.Len() && !pPlusData)
845 	{
846 		ImpForcePlusData();
847 	}
848 
849 	if(pPlusData && pPlusData->aObjName != rStr)
850 	{
851 		pPlusData->aHTMLName = rStr;
852 		SetChanged();
853 	}
854 }
855 
856 String SdrObject::GetHTMLName() const
857 {
858 	if(pPlusData)
859 	{
860 		return pPlusData->aHTMLName;
861 	}
862 
863 	return String();
864 }
865 
866 sal_uInt32 SdrObject::GetOrdNum() const
867 {
868 	if (pObjList!=NULL) {
869 		if (pObjList->IsObjOrdNumsDirty()) {
870 			pObjList->RecalcObjOrdNums();
871 		}
872 	} else ((SdrObject*)this)->nOrdNum=0;
873 	return nOrdNum;
874 }
875 
876 
877 
878 
879 sal_uInt32 SdrObject::GetNavigationPosition (void)
880 {
881     if (pObjList!=NULL && pObjList->RecalcNavigationPositions())
882     {
883         return mnNavigationPosition;
884     }
885     else
886         return GetOrdNum();
887 }
888 
889 
890 
891 
892 void SdrObject::SetNavigationPosition (const sal_uInt32 nNewPosition)
893 {
894     mnNavigationPosition = nNewPosition;
895 }
896 
897 
898 
899 
900 // #111111#
901 // To make clearer that this method may trigger RecalcBoundRect and thus may be
902 // expensive and somtimes problematic (inside a bigger object change You will get
903 // non-useful BoundRects sometimes) i rename that method from GetBoundRect() to
904 // GetCurrentBoundRect().
905 const Rectangle& SdrObject::GetCurrentBoundRect() const
906 {
907 	if(aOutRect.IsEmpty())
908 	{
909 		const_cast< SdrObject* >(this)->RecalcBoundRect();
910 	}
911 
912 	return aOutRect;
913 }
914 
915 // #111111#
916 // To have a possibility to get the last calculated BoundRect e.g for producing
917 // the first rectangle for repaints (old and new need to be used) without forcing
918 // a RecalcBoundRect (which may be problematical and expensive sometimes) i add here
919 // a new method for accessing the last BoundRect.
920 const Rectangle& SdrObject::GetLastBoundRect() const
921 {
922 	return aOutRect;
923 }
924 
925 void SdrObject::RecalcBoundRect()
926 {
927 	// #i101680# suppress BoundRect calculations on import(s)
928 	if(pModel && pModel->isLocked())
929 		return;
930 
931 	// central new method which will calculate the BoundRect using primitive geometry
932 	if(aOutRect.IsEmpty())
933 	{
934     	const drawinglayer::primitive2d::Primitive2DSequence xPrimitives(GetViewContact().getViewIndependentPrimitive2DSequence());
935 
936 	    if(xPrimitives.hasElements())
937 	    {
938 		    // use neutral ViewInformation and get the range of the primitives
939 		    const drawinglayer::geometry::ViewInformation2D aViewInformation2D;
940     		const basegfx::B2DRange aRange(drawinglayer::primitive2d::getB2DRangeFromPrimitive2DSequence(xPrimitives, aViewInformation2D));
941 
942 		    if(!aRange.isEmpty())
943 		    {
944 			    aOutRect = Rectangle(
945 					    (sal_Int32)floor(aRange.getMinX()), (sal_Int32)floor(aRange.getMinY()),
946 					    (sal_Int32)ceil(aRange.getMaxX()), (sal_Int32)ceil(aRange.getMaxY()));
947                 return;
948 		    }
949         }
950 	}
951 }
952 
953 void SdrObject::BroadcastObjectChange() const
954 {
955 	if( pModel && pModel->isLocked() )
956 		return;
957 
958 	sal_Bool bPlusDataBroadcast(pPlusData && pPlusData->pBroadcast);
959 	sal_Bool bObjectChange(IsInserted() && pModel);
960 
961 	if(bPlusDataBroadcast || bObjectChange)
962 	{
963 		SdrHint aHint(*this);
964 
965 		if(bPlusDataBroadcast)
966 		{
967 			pPlusData->pBroadcast->Broadcast(aHint);
968 		}
969 
970 		if(bObjectChange)
971 		{
972 			pModel->Broadcast(aHint);
973 		}
974 	}
975 }
976 
977 void SdrObject::SetChanged()
978 {
979 	// #110094#-11
980 	// For test purposes, use the new ViewContact for change
981 	// notification now.
982 	ActionChanged();
983 
984 	if(IsInserted() && pModel)
985 	{
986 		pModel->SetChanged();
987 	}
988 }
989 
990 // Tooling for painting a single object to a OutputDevice.
991 sal_Bool SdrObject::SingleObjectPainter(OutputDevice& rOut) const
992 {
993 	sdr::contact::SdrObjectVector aObjectVector;
994 	aObjectVector.push_back(const_cast< SdrObject* >(this));
995 
996 	sdr::contact::ObjectContactOfObjListPainter aPainter(rOut, aObjectVector, GetPage());
997 	sdr::contact::DisplayInfo aDisplayInfo;
998 
999 	// do processing
1000 	aPainter.ProcessDisplay(aDisplayInfo);
1001 
1002 	return sal_True;
1003 }
1004 
1005 sal_Bool SdrObject::LineGeometryUsageIsNecessary() const
1006 {
1007 	XLineStyle eXLS = (XLineStyle)((const XLineStyleItem&)GetMergedItem(XATTR_LINESTYLE)).GetValue();
1008 	return (eXLS != XLINE_NONE);
1009 }
1010 
1011 SdrObject* SdrObject::Clone() const
1012 {
1013 	SdrObject* pObj=SdrObjFactory::MakeNewObject(GetObjInventor(),GetObjIdentifier(),NULL);
1014 	if (pObj!=NULL) {
1015 		pObj->pModel=pModel;
1016 		pObj->pPage=pPage;
1017 		*pObj=*this;
1018 	}
1019 	return pObj;
1020 }
1021 
1022 void SdrObject::operator=(const SdrObject& rObj)
1023 {
1024 	if(mpProperties)
1025 	{
1026 		delete mpProperties;
1027 		mpProperties = 0L;
1028 	}
1029 
1030 	// #110094#
1031 	if(mpViewContact)
1032 	{
1033 		delete mpViewContact;
1034 		mpViewContact = 0L;
1035 	}
1036 
1037 	// The Clone() method uses the local copy constructor from the individual
1038 	// sdr::properties::BaseProperties class. Since the target class maybe for another
1039 	// draw object a SdrObject needs to be provided, as in the nromal constructor.
1040 	mpProperties = &rObj.GetProperties().Clone(*this);
1041 
1042 	pModel  =rObj.pModel;
1043 	aOutRect=rObj.aOutRect;
1044 	mnLayerID = rObj.mnLayerID;
1045 	aAnchor =rObj.aAnchor;
1046 	bVirtObj=rObj.bVirtObj;
1047 	bSizProt=rObj.bSizProt;
1048 	bMovProt=rObj.bMovProt;
1049 	bNoPrint=rObj.bNoPrint;
1050 	mbVisible=rObj.mbVisible;
1051 	bMarkProt=rObj.bMarkProt;
1052 	//EmptyPresObj wird nicht kopiert: nun doch! (25-07-1995, Joe)
1053 	bEmptyPresObj =rObj.bEmptyPresObj;
1054 	//NotVisibleAsMaster wird nicht kopiert: nun doch! (25-07-1995, Joe)
1055 	bNotVisibleAsMaster=rObj.bNotVisibleAsMaster;
1056 	bSnapRectDirty=sal_True; //rObj.bSnapRectDirty;
1057 	bNotMasterCachable=rObj.bNotMasterCachable;
1058 	if (pPlusData!=NULL) { delete pPlusData; pPlusData=NULL; }
1059 	if (rObj.pPlusData!=NULL) {
1060 		pPlusData=rObj.pPlusData->Clone(this);
1061 	}
1062 	if (pPlusData!=NULL && pPlusData->pBroadcast!=NULL) {
1063 		delete pPlusData->pBroadcast; // der Broadcaster wird nicht mitkopiert
1064 		pPlusData->pBroadcast=NULL;
1065 	}
1066 }
1067 
1068 void SdrObject::TakeObjNameSingul(XubString& rName) const
1069 {
1070 	rName=ImpGetResStr(STR_ObjNameSingulNONE);
1071 
1072 	String aName( GetName() );
1073 	if(aName.Len())
1074 	{
1075 		rName += sal_Unicode(' ');
1076 		rName += sal_Unicode('\'');
1077 		rName += aName;
1078 		rName += sal_Unicode('\'');
1079 	}
1080 }
1081 
1082 void SdrObject::TakeObjNamePlural(XubString& rName) const
1083 {
1084 	rName=ImpGetResStr(STR_ObjNamePluralNONE);
1085 }
1086 
1087 void SdrObject::ImpTakeDescriptionStr(sal_uInt16 nStrCacheID, XubString& rStr, sal_uInt16 nVal) const
1088 {
1089 	rStr = ImpGetResStr(nStrCacheID);
1090 
1091 	sal_Char aSearchText1[] = "%1";
1092 	sal_Char aSearchText2[] = "%2";
1093 	xub_StrLen nPos = rStr.SearchAscii(aSearchText1);
1094 
1095 	if(nPos != STRING_NOTFOUND)
1096 	{
1097 		rStr.Erase(nPos, 2);
1098 
1099 		XubString aObjName;
1100 
1101 		TakeObjNameSingul(aObjName);
1102 		rStr.Insert(aObjName, nPos);
1103 	}
1104 
1105 	nPos = rStr.SearchAscii(aSearchText2);
1106 
1107 	if(nPos != STRING_NOTFOUND)
1108 	{
1109 		rStr.Erase(nPos, 2);
1110 		rStr.Insert(UniString::CreateFromInt32(nVal), nPos);
1111 	}
1112 }
1113 
1114 XubString SdrObject::GetWinkStr(long nWink, FASTBOOL bNoDegChar) const
1115 {
1116 	XubString aStr;
1117 	if (pModel!=NULL) {
1118 		pModel->TakeWinkStr(nWink,aStr,bNoDegChar);
1119 	}
1120 	return aStr;
1121 }
1122 
1123 XubString SdrObject::GetMetrStr(long nVal, MapUnit /*eWantMap*/, FASTBOOL bNoUnitChars) const
1124 {
1125 	XubString aStr;
1126 	if (pModel!=NULL) {
1127 		pModel->TakeMetricStr(nVal,aStr,bNoUnitChars);
1128 	}
1129 	return aStr;
1130 }
1131 
1132 basegfx::B2DPolyPolygon SdrObject::TakeXorPoly() const
1133 {
1134 	basegfx::B2DPolyPolygon aRetval;
1135 	const Rectangle aR(GetCurrentBoundRect());
1136 	const basegfx::B2DRange aRange(aR.Left(), aR.Top(), aR.Right(), aR.Bottom());
1137 	aRetval.append(basegfx::tools::createPolygonFromRect(aRange));
1138 
1139 	return aRetval;
1140 }
1141 
1142 basegfx::B2DPolyPolygon SdrObject::TakeContour() const
1143 {
1144 	basegfx::B2DPolyPolygon aRetval;
1145 
1146     // create cloned object without text, but with XLINE_SOLID,
1147     // COL_BLACK as line color and XFILL_NONE
1148 	SdrObject* pClone = Clone();
1149 
1150     if(pClone)
1151     {
1152         const SdrTextObj* pTextObj = dynamic_cast< const SdrTextObj* >(this);
1153 
1154         if(pTextObj)
1155 	    {
1156             // no text and no text animation
1157 		    pClone->SetMergedItem(SdrTextAniKindItem(SDRTEXTANI_NONE));
1158             pClone->SetOutlinerParaObject(0);
1159 	    }
1160 
1161         const SdrEdgeObj* pEdgeObj = dynamic_cast< const SdrEdgeObj* >(this);
1162 
1163         if(pEdgeObj)
1164 	    {
1165             // create connections if connector, will be cleaned up when
1166             // deleting the connector again
1167 		    SdrObject* pLeft = pEdgeObj->GetConnectedNode(sal_True);
1168 		    SdrObject* pRight = pEdgeObj->GetConnectedNode(sal_False);
1169 
1170 		    if(pLeft)
1171 		    {
1172 			    pClone->ConnectToNode(sal_True, pLeft);
1173 		    }
1174 
1175 		    if(pRight)
1176 		    {
1177 			    pClone->ConnectToNode(sal_False, pRight);
1178 		    }
1179 	    }
1180 
1181 	    SfxItemSet aNewSet(*GetObjectItemPool());
1182 
1183         // #i101980# ignore LineWidth; that's what the old implementation
1184         // did. With linewidth, the result may be huge due to fat/thick
1185         // line decompositions
1186     	aNewSet.Put(XLineWidthItem(0));
1187 
1188         // solid black lines and no fill
1189         aNewSet.Put(XLineStyleItem(XLINE_SOLID));
1190 	    aNewSet.Put(XLineColorItem(String(), Color(COL_BLACK)));
1191 	    aNewSet.Put(XFillStyleItem(XFILL_NONE));
1192 	    pClone->SetMergedItemSet(aNewSet);
1193 
1194         // get sequence from clone
1195 	    const sdr::contact::ViewContact& rVC(pClone->GetViewContact());
1196 	    const drawinglayer::primitive2d::Primitive2DSequence xSequence(rVC.getViewIndependentPrimitive2DSequence());
1197 
1198 	    if(xSequence.hasElements())
1199 	    {
1200 		    // use neutral ViewInformation
1201 		    const drawinglayer::geometry::ViewInformation2D aViewInformation2D;
1202 
1203 		    // create extractor, process and get result (with hairlines as opened polygons)
1204 		    drawinglayer::processor2d::ContourExtractor2D aExtractor(aViewInformation2D, false);
1205 		    aExtractor.process(xSequence);
1206             const basegfx::B2DPolyPolygonVector& rResult(aExtractor.getExtractedContour());
1207             const sal_uInt32 nSize(rResult.size());
1208 
1209             // when count is one, it is implied that the object has only it's normal
1210             // contour anyways and TakeCountour() is to return an empty PolyPolygon
1211             // (see old implementation for historical reasons)
1212             if(nSize > 1)
1213             {
1214                 // the topology for contour is correctly a vector of PolyPolygons; for
1215                 // historical reasons cut it back to a single PolyPolygon here
1216                 for(sal_uInt32 a(0); a < nSize; a++)
1217                 {
1218                     aRetval.append(rResult[a]);
1219                 }
1220             }
1221         }
1222 
1223     	delete pClone;
1224     }
1225 
1226 	return aRetval;
1227 }
1228 
1229 sal_uInt32 SdrObject::GetHdlCount() const
1230 {
1231 	return 8L;
1232 }
1233 
1234 SdrHdl* SdrObject::GetHdl(sal_uInt32 nHdlNum) const
1235 {
1236 	SdrHdl* pH=NULL;
1237 	const Rectangle& rR=GetSnapRect();
1238 	switch (nHdlNum) {
1239 		case 0: pH=new SdrHdl(rR.TopLeft(),     HDL_UPLFT); break; // Oben links
1240 		case 1: pH=new SdrHdl(rR.TopCenter(),   HDL_UPPER); break; // Oben
1241 		case 2: pH=new SdrHdl(rR.TopRight(),    HDL_UPRGT); break; // Oben rechts
1242 		case 3: pH=new SdrHdl(rR.LeftCenter(),  HDL_LEFT ); break; // Links
1243 		case 4: pH=new SdrHdl(rR.RightCenter(), HDL_RIGHT); break; // Rechts
1244 		case 5: pH=new SdrHdl(rR.BottomLeft(),  HDL_LWLFT); break; // Unten links
1245 		case 6: pH=new SdrHdl(rR.BottomCenter(),HDL_LOWER); break; // Unten
1246 		case 7: pH=new SdrHdl(rR.BottomRight(), HDL_LWRGT); break; // Unten rechts
1247 	}
1248 	return pH;
1249 }
1250 
1251 sal_uInt32 SdrObject::GetPlusHdlCount(const SdrHdl& /*rHdl*/) const
1252 {
1253 	return 0L;
1254 }
1255 
1256 SdrHdl* SdrObject::GetPlusHdl(const SdrHdl& /*rHdl*/, sal_uInt32 /*nPlNum*/) const
1257 {
1258 	return 0L;
1259 }
1260 
1261 void SdrObject::AddToHdlList(SdrHdlList& rHdlList) const
1262 {
1263 	sal_uInt32 nAnz=GetHdlCount();
1264 	for (sal_uInt32 i=0L; i<nAnz; i++) {
1265 		SdrHdl* pHdl=GetHdl(i);
1266 		if (pHdl!=NULL) {
1267 			rHdlList.AddHdl(pHdl);
1268 		}
1269 	}
1270 }
1271 
1272 Rectangle SdrObject::ImpDragCalcRect(const SdrDragStat& rDrag) const
1273 {
1274 	Rectangle aTmpRect(GetSnapRect());
1275 	Rectangle aRect(aTmpRect);
1276 	const SdrHdl* pHdl=rDrag.GetHdl();
1277 	SdrHdlKind eHdl=pHdl==NULL ? HDL_MOVE : pHdl->GetKind();
1278 	FASTBOOL bEcke=(eHdl==HDL_UPLFT || eHdl==HDL_UPRGT || eHdl==HDL_LWLFT || eHdl==HDL_LWRGT);
1279 	FASTBOOL bOrtho=rDrag.GetView()!=NULL && rDrag.GetView()->IsOrtho();
1280 	FASTBOOL bBigOrtho=bEcke && bOrtho && rDrag.GetView()->IsBigOrtho();
1281 	Point aPos(rDrag.GetNow());
1282 	FASTBOOL bLft=(eHdl==HDL_UPLFT || eHdl==HDL_LEFT  || eHdl==HDL_LWLFT);
1283 	FASTBOOL bRgt=(eHdl==HDL_UPRGT || eHdl==HDL_RIGHT || eHdl==HDL_LWRGT);
1284 	FASTBOOL bTop=(eHdl==HDL_UPRGT || eHdl==HDL_UPPER || eHdl==HDL_UPLFT);
1285 	FASTBOOL bBtm=(eHdl==HDL_LWRGT || eHdl==HDL_LOWER || eHdl==HDL_LWLFT);
1286 	if (bLft) aTmpRect.Left()  =aPos.X();
1287 	if (bRgt) aTmpRect.Right() =aPos.X();
1288 	if (bTop) aTmpRect.Top()   =aPos.Y();
1289 	if (bBtm) aTmpRect.Bottom()=aPos.Y();
1290 	if (bOrtho) { // Ortho
1291 		long nWdt0=aRect.Right() -aRect.Left();
1292 		long nHgt0=aRect.Bottom()-aRect.Top();
1293 		long nXMul=aTmpRect.Right() -aTmpRect.Left();
1294 		long nYMul=aTmpRect.Bottom()-aTmpRect.Top();
1295 		long nXDiv=nWdt0;
1296 		long nYDiv=nHgt0;
1297 		FASTBOOL bXNeg=(nXMul<0)!=(nXDiv<0);
1298 		FASTBOOL bYNeg=(nYMul<0)!=(nYDiv<0);
1299 		nXMul=Abs(nXMul);
1300 		nYMul=Abs(nYMul);
1301 		nXDiv=Abs(nXDiv);
1302 		nYDiv=Abs(nYDiv);
1303 		Fraction aXFact(nXMul,nXDiv); // Fractions zum kuerzen
1304 		Fraction aYFact(nYMul,nYDiv); // und zum vergleichen
1305 		nXMul=aXFact.GetNumerator();
1306 		nYMul=aYFact.GetNumerator();
1307 		nXDiv=aXFact.GetDenominator();
1308 		nYDiv=aYFact.GetDenominator();
1309 		if (bEcke) { // Eckpunkthandles
1310 			FASTBOOL bUseX=(aXFact<aYFact) != bBigOrtho;
1311 			if (bUseX) {
1312 				long nNeed=long(BigInt(nHgt0)*BigInt(nXMul)/BigInt(nXDiv));
1313 				if (bYNeg) nNeed=-nNeed;
1314 				if (bTop) aTmpRect.Top()=aTmpRect.Bottom()-nNeed;
1315 				if (bBtm) aTmpRect.Bottom()=aTmpRect.Top()+nNeed;
1316 			} else {
1317 				long nNeed=long(BigInt(nWdt0)*BigInt(nYMul)/BigInt(nYDiv));
1318 				if (bXNeg) nNeed=-nNeed;
1319 				if (bLft) aTmpRect.Left()=aTmpRect.Right()-nNeed;
1320 				if (bRgt) aTmpRect.Right()=aTmpRect.Left()+nNeed;
1321 			}
1322 		} else { // Scheitelpunkthandles
1323 			if ((bLft || bRgt) && nXDiv!=0) {
1324 				long nHgt0b=aRect.Bottom()-aRect.Top();
1325 				long nNeed=long(BigInt(nHgt0b)*BigInt(nXMul)/BigInt(nXDiv));
1326 				aTmpRect.Top()-=(nNeed-nHgt0b)/2;
1327 				aTmpRect.Bottom()=aTmpRect.Top()+nNeed;
1328 			}
1329 			if ((bTop || bBtm) && nYDiv!=0) {
1330 				long nWdt0b=aRect.Right()-aRect.Left();
1331 				long nNeed=long(BigInt(nWdt0b)*BigInt(nYMul)/BigInt(nYDiv));
1332 				aTmpRect.Left()-=(nNeed-nWdt0b)/2;
1333 				aTmpRect.Right()=aTmpRect.Left()+nNeed;
1334 			}
1335 		}
1336 	}
1337 	aTmpRect.Justify();
1338 	return aTmpRect;
1339 }
1340 
1341 ////////////////////////////////////////////////////////////////////////////////////////////////////
1342 
1343 bool SdrObject::hasSpecialDrag() const
1344 {
1345 	return false;
1346 }
1347 
1348 bool SdrObject::supportsFullDrag() const
1349 {
1350     return true;
1351 }
1352 
1353 SdrObject* SdrObject::getFullDragClone() const
1354 {
1355 	// default uses simple clone
1356 	return Clone();
1357 }
1358 
1359 bool SdrObject::beginSpecialDrag(SdrDragStat& rDrag) const
1360 {
1361     const SdrHdl* pHdl = rDrag.GetHdl();
1362 
1363     SdrHdlKind eHdl = (pHdl == NULL) ? HDL_MOVE : pHdl->GetKind();
1364 
1365     if(eHdl==HDL_UPLFT || eHdl==HDL_UPPER || eHdl==HDL_UPRGT ||
1366 	    eHdl==HDL_LEFT || eHdl==HDL_RIGHT || eHdl==HDL_LWLFT ||
1367         eHdl==HDL_LOWER || eHdl==HDL_LWRGT)
1368     {
1369         return true;
1370     }
1371 
1372     return false;
1373 }
1374 
1375 bool SdrObject::applySpecialDrag(SdrDragStat& rDrag)
1376 {
1377 	Rectangle aNewRect(ImpDragCalcRect(rDrag));
1378 
1379     if(aNewRect != GetSnapRect())
1380     {
1381    		NbcSetSnapRect(aNewRect);
1382 	}
1383 
1384     return true;
1385 }
1386 
1387 String SdrObject::getSpecialDragComment(const SdrDragStat& /*rDrag*/) const
1388 {
1389 	return String();
1390 }
1391 
1392 basegfx::B2DPolyPolygon SdrObject::getSpecialDragPoly(const SdrDragStat& /*rDrag*/) const
1393 {
1394     // default has nothing to add
1395     return basegfx::B2DPolyPolygon();
1396 }
1397 
1398 ////////////////////////////////////////////////////////////////////////////////////////////////////
1399 // Create
1400 FASTBOOL SdrObject::BegCreate(SdrDragStat& rStat)
1401 {
1402 	rStat.SetOrtho4Possible();
1403 	Rectangle aRect1(rStat.GetStart(), rStat.GetNow());
1404 	aRect1.Justify();
1405 	rStat.SetActionRect(aRect1);
1406 	aOutRect = aRect1;
1407 	return sal_True;
1408 }
1409 
1410 FASTBOOL SdrObject::MovCreate(SdrDragStat& rStat)
1411 {
1412 	rStat.TakeCreateRect(aOutRect);
1413 	rStat.SetActionRect(aOutRect);
1414 	aOutRect.Justify();
1415 
1416 	// #i101648# for naked (non-derived) SdrObjects, do not invalidate aOutRect
1417 	// by calling SetBoundRectDirty(); aOutRect IS the geometry for such objects.
1418 	// No derivation implementation calls the parent implementation, so this will
1419 	// cause no further prolems
1420 	//
1421 	// SetBoundRectDirty();
1422 	// bSnapRectDirty=sal_True;
1423 
1424 	return sal_True;
1425 }
1426 
1427 FASTBOOL SdrObject::EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd)
1428 {
1429 	rStat.TakeCreateRect(aOutRect);
1430 	aOutRect.Justify();
1431 
1432 	// #i101648# see description at MovCreate
1433 	//
1434 	// SetRectsDirty();
1435 
1436 	return (eCmd==SDRCREATE_FORCEEND || rStat.GetPointAnz()>=2);
1437 }
1438 
1439 void SdrObject::BrkCreate(SdrDragStat& /*rStat*/)
1440 {
1441 }
1442 
1443 FASTBOOL SdrObject::BckCreate(SdrDragStat& /*rStat*/)
1444 {
1445 	return sal_False;
1446 }
1447 
1448 basegfx::B2DPolyPolygon SdrObject::TakeCreatePoly(const SdrDragStat& rDrag) const
1449 {
1450 	Rectangle aRect1;
1451 	rDrag.TakeCreateRect(aRect1);
1452 	aRect1.Justify();
1453 
1454 	basegfx::B2DPolyPolygon aRetval;
1455 	const basegfx::B2DRange aRange(aRect1.Left(), aRect1.Top(), aRect1.Right(), aRect1.Bottom());
1456 	aRetval.append(basegfx::tools::createPolygonFromRect(aRange));
1457 	return aRetval;
1458 }
1459 
1460 Pointer SdrObject::GetCreatePointer() const
1461 {
1462 	return Pointer(POINTER_CROSS);
1463 }
1464 
1465 // Transformationen
1466 void SdrObject::NbcMove(const Size& rSiz)
1467 {
1468 	MoveRect(aOutRect,rSiz);
1469 	SetRectsDirty();
1470 }
1471 
1472 void SdrObject::NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact)
1473 {
1474 	FASTBOOL bXMirr=(xFact.GetNumerator()<0) != (xFact.GetDenominator()<0);
1475 	FASTBOOL bYMirr=(yFact.GetNumerator()<0) != (yFact.GetDenominator()<0);
1476 	if (bXMirr || bYMirr) {
1477 		Point aRef1(GetSnapRect().Center());
1478 		if (bXMirr) {
1479 			Point aRef2(aRef1);
1480 			aRef2.Y()++;
1481 			NbcMirrorGluePoints(aRef1,aRef2);
1482 		}
1483 		if (bYMirr) {
1484 			Point aRef2(aRef1);
1485 			aRef2.X()++;
1486 			NbcMirrorGluePoints(aRef1,aRef2);
1487 		}
1488 	}
1489 	ResizeRect(aOutRect,rRef,xFact,yFact);
1490 	SetRectsDirty();
1491 }
1492 
1493 void SdrObject::NbcRotate(const Point& rRef, long nWink, double sn, double cs)
1494 {
1495 	SetGlueReallyAbsolute(sal_True);
1496 	aOutRect.Move(-rRef.X(),-rRef.Y());
1497 	Rectangle R(aOutRect);
1498     if (sn==1.0 && cs==0.0) { // 90deg
1499 		aOutRect.Left()  =-R.Bottom();
1500 		aOutRect.Right() =-R.Top();
1501 		aOutRect.Top()   =R.Left();
1502 		aOutRect.Bottom()=R.Right();
1503     } else if (sn==0.0 && cs==-1.0) { // 180deg
1504 		aOutRect.Left()  =-R.Right();
1505 		aOutRect.Right() =-R.Left();
1506 		aOutRect.Top()   =-R.Bottom();
1507 		aOutRect.Bottom()=-R.Top();
1508     } else if (sn==-1.0 && cs==0.0) { // 270deg
1509 		aOutRect.Left()  =R.Top();
1510 		aOutRect.Right() =R.Bottom();
1511 		aOutRect.Top()   =-R.Right();
1512 		aOutRect.Bottom()=-R.Left();
1513 	}
1514 	aOutRect.Move(rRef.X(),rRef.Y());
1515 	aOutRect.Justify(); // Sicherheitshalber
1516 	SetRectsDirty();
1517 	NbcRotateGluePoints(rRef,nWink,sn,cs);
1518 	SetGlueReallyAbsolute(sal_False);
1519 }
1520 
1521 void SdrObject::NbcMirror(const Point& rRef1, const Point& rRef2)
1522 {
1523 	SetGlueReallyAbsolute(sal_True);
1524 	aOutRect.Move(-rRef1.X(),-rRef1.Y());
1525 	Rectangle R(aOutRect);
1526 	long dx=rRef2.X()-rRef1.X();
1527 	long dy=rRef2.Y()-rRef1.Y();
1528 	if (dx==0) {          // Vertikale Achse
1529 		aOutRect.Left() =-R.Right();
1530 		aOutRect.Right()=-R.Left();
1531 	} else if (dy==0) {   // Horizontale Achse
1532 		aOutRect.Top()   =-R.Bottom();
1533 		aOutRect.Bottom()=-R.Top();
1534 	} else if (dx==dy) {  /* 45 Grad Achse \ */
1535 		aOutRect.Left()  =R.Top();
1536 		aOutRect.Right() =R.Bottom();
1537 		aOutRect.Top()   =R.Left();
1538 		aOutRect.Bottom()=R.Right();
1539 	} else if (dx==-dy) { // 45 Grad Achse /
1540 		aOutRect.Left()  =-R.Bottom();
1541 		aOutRect.Right() =-R.Top();
1542 		aOutRect.Top()   =-R.Right();
1543 		aOutRect.Bottom()=-R.Left();
1544 	}
1545 	aOutRect.Move(rRef1.X(),rRef1.Y());
1546 	aOutRect.Justify(); // Sicherheitshalber
1547 	SetRectsDirty();
1548 	NbcMirrorGluePoints(rRef1,rRef2);
1549 	SetGlueReallyAbsolute(sal_False);
1550 }
1551 
1552 void SdrObject::NbcShear(const Point& rRef, long nWink, double tn, FASTBOOL bVShear)
1553 {
1554 	SetGlueReallyAbsolute(sal_True);
1555 	NbcShearGluePoints(rRef,nWink,tn,bVShear);
1556 	SetGlueReallyAbsolute(sal_False);
1557 }
1558 
1559 void SdrObject::Move(const Size& rSiz)
1560 {
1561 	if (rSiz.Width()!=0 || rSiz.Height()!=0) {
1562 		Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
1563 		// #110094#-14 SendRepaintBroadcast();
1564 		NbcMove(rSiz);
1565 		SetChanged();
1566 		BroadcastObjectChange();
1567 		SendUserCall(SDRUSERCALL_MOVEONLY,aBoundRect0);
1568 	}
1569 }
1570 
1571 void SdrObject::Resize(const Point& rRef, const Fraction& xFact, const Fraction& yFact)
1572 {
1573 	if (xFact.GetNumerator()!=xFact.GetDenominator() || yFact.GetNumerator()!=yFact.GetDenominator()) {
1574 		Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
1575 		// #110094#-14 SendRepaintBroadcast();
1576 		NbcResize(rRef,xFact,yFact);
1577 		SetChanged();
1578 		BroadcastObjectChange();
1579 		SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
1580 	}
1581 }
1582 
1583 void SdrObject::Rotate(const Point& rRef, long nWink, double sn, double cs)
1584 {
1585 	if (nWink!=0) {
1586 		Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
1587 		// #110094#-14 SendRepaintBroadcast();
1588 		NbcRotate(rRef,nWink,sn,cs);
1589 		SetChanged();
1590 		BroadcastObjectChange();
1591 		SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
1592 	}
1593 }
1594 
1595 void SdrObject::Mirror(const Point& rRef1, const Point& rRef2)
1596 {
1597 	Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
1598 	// #110094#-14 SendRepaintBroadcast();
1599 	NbcMirror(rRef1,rRef2);
1600 	SetChanged();
1601 	BroadcastObjectChange();
1602 	SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
1603 }
1604 
1605 void SdrObject::Shear(const Point& rRef, long nWink, double tn, FASTBOOL bVShear)
1606 {
1607 	if (nWink!=0) {
1608 		Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
1609 		// #110094#-14 SendRepaintBroadcast();
1610 		NbcShear(rRef,nWink,tn,bVShear);
1611 		SetChanged();
1612 		BroadcastObjectChange();
1613 		SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
1614 	}
1615 }
1616 
1617 void SdrObject::NbcSetRelativePos(const Point& rPnt)
1618 {
1619 	Point aRelPos0(GetSnapRect().TopLeft()-aAnchor);
1620 	Size aSiz(rPnt.X()-aRelPos0.X(),rPnt.Y()-aRelPos0.Y());
1621 	NbcMove(aSiz); // Der ruft auch das SetRectsDirty()
1622 }
1623 
1624 void SdrObject::SetRelativePos(const Point& rPnt)
1625 {
1626 	if (rPnt!=GetRelativePos()) {
1627 		Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
1628 		// #110094#-14 SendRepaintBroadcast();
1629 		NbcSetRelativePos(rPnt);
1630 		SetChanged();
1631 		BroadcastObjectChange();
1632 		SendUserCall(SDRUSERCALL_MOVEONLY,aBoundRect0);
1633 	}
1634 }
1635 
1636 Point SdrObject::GetRelativePos() const
1637 {
1638 	return GetSnapRect().TopLeft()-aAnchor;
1639 }
1640 
1641 void SdrObject::NbcSetAnchorPos(const Point& rPnt)
1642 {
1643 	Size aSiz(rPnt.X()-aAnchor.X(),rPnt.Y()-aAnchor.Y());
1644 	aAnchor=rPnt;
1645 	NbcMove(aSiz); // Der ruft auch das SetRectsDirty()
1646 }
1647 
1648 void SdrObject::SetAnchorPos(const Point& rPnt)
1649 {
1650 	if (rPnt!=aAnchor) {
1651 		Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
1652 		// #110094#-14 SendRepaintBroadcast();
1653 		NbcSetAnchorPos(rPnt);
1654 		SetChanged();
1655 		BroadcastObjectChange();
1656 		SendUserCall(SDRUSERCALL_MOVEONLY,aBoundRect0);
1657 	}
1658 }
1659 
1660 const Point& SdrObject::GetAnchorPos() const
1661 {
1662 	return aAnchor;
1663 }
1664 
1665 void SdrObject::RecalcSnapRect()
1666 {
1667 }
1668 
1669 const Rectangle& SdrObject::GetSnapRect() const
1670 {
1671 	return aOutRect;
1672 }
1673 
1674 void SdrObject::NbcSetSnapRect(const Rectangle& rRect)
1675 {
1676 	aOutRect=rRect;
1677 }
1678 
1679 const Rectangle& SdrObject::GetLogicRect() const
1680 {
1681 	return GetSnapRect();
1682 }
1683 
1684 void SdrObject::NbcSetLogicRect(const Rectangle& rRect)
1685 {
1686 	NbcSetSnapRect(rRect);
1687 }
1688 
1689 void SdrObject::AdjustToMaxRect( const Rectangle& rMaxRect, bool /* bShrinkOnly = false */ )
1690 {
1691 	SetLogicRect( rMaxRect );
1692 }
1693 
1694 void SdrObject::SetSnapRect(const Rectangle& rRect)
1695 {
1696 	Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
1697 	// #110094#-14 SendRepaintBroadcast();
1698 	NbcSetSnapRect(rRect);
1699 	SetChanged();
1700 	BroadcastObjectChange();
1701 	SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
1702 }
1703 
1704 void SdrObject::SetLogicRect(const Rectangle& rRect)
1705 {
1706 	Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
1707 	// #110094#-14 SendRepaintBroadcast();
1708 	NbcSetLogicRect(rRect);
1709 	SetChanged();
1710 	BroadcastObjectChange();
1711 	SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
1712 }
1713 
1714 long SdrObject::GetRotateAngle() const
1715 {
1716 	return 0;
1717 }
1718 
1719 long SdrObject::GetShearAngle(FASTBOOL /*bVertical*/) const
1720 {
1721 	return 0;
1722 }
1723 
1724 sal_uInt32 SdrObject::GetSnapPointCount() const
1725 {
1726 	return GetPointCount();
1727 }
1728 
1729 Point SdrObject::GetSnapPoint(sal_uInt32 i) const
1730 {
1731 	return GetPoint(i);
1732 }
1733 
1734 sal_Bool SdrObject::IsPolyObj() const
1735 {
1736 	return sal_False;
1737 }
1738 
1739 sal_uInt32 SdrObject::GetPointCount() const
1740 {
1741 	return 0L;
1742 }
1743 
1744 Point SdrObject::GetPoint(sal_uInt32 /*i*/) const
1745 {
1746 	return Point();
1747 }
1748 
1749 void SdrObject::SetPoint(const Point& rPnt, sal_uInt32 i)
1750 {
1751 	Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
1752 	// #110094#-14 SendRepaintBroadcast();
1753 	NbcSetPoint(rPnt, i);
1754 	SetChanged();
1755 	BroadcastObjectChange();
1756 	SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
1757 }
1758 
1759 void SdrObject::NbcSetPoint(const Point& /*rPnt*/, sal_uInt32 /*i*/)
1760 {
1761 }
1762 
1763 FASTBOOL SdrObject::HasTextEdit() const
1764 {
1765 	return sal_False;
1766 }
1767 
1768 sal_Bool SdrObject::BegTextEdit(SdrOutliner& /*rOutl*/)
1769 {
1770 	return sal_False;
1771 }
1772 
1773 void SdrObject::EndTextEdit(SdrOutliner& /*rOutl*/)
1774 {
1775 }
1776 
1777 void SdrObject::SetOutlinerParaObject(OutlinerParaObject* pTextObject)
1778 {
1779 	Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
1780 	// #110094#-14 SendRepaintBroadcast();
1781 	NbcSetOutlinerParaObject(pTextObject);
1782 	SetChanged();
1783 	BroadcastObjectChange();
1784 	if (GetCurrentBoundRect()!=aBoundRect0) {
1785 		SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
1786 	}
1787 }
1788 
1789 void SdrObject::NbcSetOutlinerParaObject(OutlinerParaObject* /*pTextObject*/)
1790 {
1791 }
1792 
1793 OutlinerParaObject* SdrObject::GetOutlinerParaObject() const
1794 {
1795 	return NULL;
1796 }
1797 
1798 void SdrObject::NbcReformatText()
1799 {
1800 }
1801 
1802 void SdrObject::ReformatText()
1803 {
1804 	Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
1805 	NbcReformatText();
1806 	SetChanged();
1807 	BroadcastObjectChange();
1808 	if (GetCurrentBoundRect()!=aBoundRect0) {
1809 		SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
1810 	}
1811 }
1812 
1813 void SdrObject::BurnInStyleSheetAttributes()
1814 {
1815 	GetProperties().ForceStyleToHardAttributes();
1816 }
1817 
1818 #define Imp2ndKennung (0x434F4D43)
1819 SdrObjUserData* SdrObject::ImpGetMacroUserData() const
1820 {
1821 	SdrObjUserData* pData=NULL;
1822 	sal_uInt16 nAnz=GetUserDataCount();
1823 	for (sal_uInt16 nNum=nAnz; nNum>0 && pData==NULL;) {
1824 		nNum--;
1825 		pData=GetUserData(nNum);
1826 		if (!pData->HasMacro(this)) pData=NULL;
1827 	}
1828 	return pData;
1829 }
1830 
1831 FASTBOOL SdrObject::HasMacro() const
1832 {
1833 	SdrObjUserData* pData=ImpGetMacroUserData();
1834 	return pData!=NULL ? pData->HasMacro(this) : sal_False;
1835 }
1836 
1837 SdrObject* SdrObject::CheckMacroHit(const SdrObjMacroHitRec& rRec) const
1838 {
1839 	SdrObjUserData* pData = ImpGetMacroUserData();
1840 
1841     if(pData)
1842     {
1843 		return pData->CheckMacroHit(rRec, this);
1844 	}
1845 
1846     if(rRec.pPageView)
1847     {
1848 	    return SdrObjectPrimitiveHit(*this, rRec.aPos, rRec.nTol, *rRec.pPageView, rRec.pVisiLayer, false);
1849     }
1850 
1851 	return 0;
1852 }
1853 
1854 Pointer SdrObject::GetMacroPointer(const SdrObjMacroHitRec& rRec) const
1855 {
1856 	SdrObjUserData* pData=ImpGetMacroUserData();
1857 	if (pData!=NULL) {
1858 		return pData->GetMacroPointer(rRec,this);
1859 	}
1860 	return Pointer(POINTER_REFHAND);
1861 }
1862 
1863 void SdrObject::PaintMacro(OutputDevice& rOut, const Rectangle& rDirtyRect, const SdrObjMacroHitRec& rRec) const
1864 {
1865 	SdrObjUserData* pData=ImpGetMacroUserData();
1866 
1867     if(pData)
1868     {
1869 		pData->PaintMacro(rOut,rDirtyRect,rRec,this);
1870 	}
1871     else
1872     {
1873 	    const RasterOp eRop(rOut.GetRasterOp());
1874 	    const basegfx::B2DPolyPolygon aPolyPolygon(TakeXorPoly());
1875 	    const sal_uInt32 nCount(aPolyPolygon.count());
1876 
1877         rOut.SetLineColor(COL_BLACK);
1878         rOut.SetFillColor();
1879 	    rOut.SetRasterOp(ROP_INVERT);
1880 
1881 	    for(sal_uInt32 a(0); a < nCount; a++)
1882 	    {
1883 		    rOut.DrawPolyLine(aPolyPolygon.getB2DPolygon(a));
1884 	    }
1885 
1886         rOut.SetRasterOp(eRop);
1887 	}
1888 }
1889 
1890 FASTBOOL SdrObject::DoMacro(const SdrObjMacroHitRec& rRec)
1891 {
1892 	SdrObjUserData* pData=ImpGetMacroUserData();
1893 	if (pData!=NULL) {
1894 		return pData->DoMacro(rRec,this);
1895 	}
1896 	return sal_False;
1897 }
1898 
1899 XubString SdrObject::GetMacroPopupComment(const SdrObjMacroHitRec& rRec) const
1900 {
1901 	SdrObjUserData* pData=ImpGetMacroUserData();
1902 	if (pData!=NULL) {
1903 		return pData->GetMacroPopupComment(rRec,this);
1904 	}
1905 	return String();
1906 }
1907 
1908 ////////////////////////////////////////////////////////////////////////////////////////////////////
1909 
1910 SdrObjGeoData* SdrObject::NewGeoData() const
1911 {
1912 	return new SdrObjGeoData;
1913 }
1914 
1915 void SdrObject::SaveGeoData(SdrObjGeoData& rGeo) const
1916 {
1917 	rGeo.aBoundRect    =GetCurrentBoundRect();
1918 	rGeo.aAnchor       =aAnchor       ;
1919 	rGeo.bMovProt      =bMovProt      ;
1920 	rGeo.bSizProt      =bSizProt      ;
1921 	rGeo.bNoPrint      =bNoPrint      ;
1922 	rGeo.mbVisible	   =mbVisible     ;
1923 	rGeo.bClosedObj    =bClosedObj    ;
1924 	rGeo.mnLayerID = mnLayerID;
1925 
1926 	// Benutzerdefinierte Klebepunkte
1927 	if (pPlusData!=NULL && pPlusData->pGluePoints!=NULL) {
1928 		if (rGeo.pGPL!=NULL) {
1929 			*rGeo.pGPL=*pPlusData->pGluePoints;
1930 		} else {
1931 			rGeo.pGPL=new SdrGluePointList(*pPlusData->pGluePoints);
1932 		}
1933 	} else {
1934 		if (rGeo.pGPL!=NULL) {
1935 			delete rGeo.pGPL;
1936 			rGeo.pGPL=NULL;
1937 		}
1938 	}
1939 }
1940 
1941 void SdrObject::RestGeoData(const SdrObjGeoData& rGeo)
1942 {
1943 	SetRectsDirty();
1944 	aOutRect      =rGeo.aBoundRect    ;
1945 	aAnchor       =rGeo.aAnchor       ;
1946 	bMovProt      =rGeo.bMovProt      ;
1947 	bSizProt      =rGeo.bSizProt      ;
1948 	bNoPrint      =rGeo.bNoPrint      ;
1949 	mbVisible     =rGeo.mbVisible     ;
1950 	bClosedObj    =rGeo.bClosedObj    ;
1951 	mnLayerID = rGeo.mnLayerID;
1952 
1953 	// Benutzerdefinierte Klebepunkte
1954 	if (rGeo.pGPL!=NULL) {
1955 		ImpForcePlusData();
1956 		if (pPlusData->pGluePoints!=NULL) {
1957 			*pPlusData->pGluePoints=*rGeo.pGPL;
1958 		} else {
1959 			pPlusData->pGluePoints=new SdrGluePointList(*rGeo.pGPL);
1960 		}
1961 	} else {
1962 		if (pPlusData!=NULL && pPlusData->pGluePoints!=NULL) {
1963 			delete pPlusData->pGluePoints;
1964 			pPlusData->pGluePoints=NULL;
1965 		}
1966 	}
1967 }
1968 
1969 SdrObjGeoData* SdrObject::GetGeoData() const
1970 {
1971 	SdrObjGeoData* pGeo=NewGeoData();
1972 	SaveGeoData(*pGeo);
1973 	return pGeo;
1974 }
1975 
1976 void SdrObject::SetGeoData(const SdrObjGeoData& rGeo)
1977 {
1978 	Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
1979 	RestGeoData(rGeo);
1980 	SetChanged();
1981 	BroadcastObjectChange();
1982 	SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
1983 }
1984 
1985 ////////////////////////////////////////////////////////////////////////////////////////////////////
1986 // ItemSet access
1987 
1988 const SfxItemSet& SdrObject::GetObjectItemSet() const
1989 {
1990 	return GetProperties().GetObjectItemSet();
1991 }
1992 
1993 const SfxItemSet& SdrObject::GetMergedItemSet() const
1994 {
1995 	return GetProperties().GetMergedItemSet();
1996 }
1997 
1998 void SdrObject::SetObjectItem(const SfxPoolItem& rItem)
1999 {
2000 	GetProperties().SetObjectItem(rItem);
2001 }
2002 
2003 void SdrObject::SetMergedItem(const SfxPoolItem& rItem)
2004 {
2005 	GetProperties().SetMergedItem(rItem);
2006 }
2007 
2008 void SdrObject::ClearObjectItem(const sal_uInt16 nWhich)
2009 {
2010 	GetProperties().ClearObjectItem(nWhich);
2011 }
2012 
2013 void SdrObject::ClearMergedItem(const sal_uInt16 nWhich)
2014 {
2015 	GetProperties().ClearMergedItem(nWhich);
2016 }
2017 
2018 void SdrObject::SetObjectItemSet(const SfxItemSet& rSet)
2019 {
2020 	GetProperties().SetObjectItemSet(rSet);
2021 }
2022 
2023 void SdrObject::SetMergedItemSet(const SfxItemSet& rSet, sal_Bool bClearAllItems)
2024 {
2025 	GetProperties().SetMergedItemSet(rSet, bClearAllItems);
2026 }
2027 
2028 const SfxPoolItem& SdrObject::GetObjectItem(const sal_uInt16 nWhich) const
2029 {
2030 	return GetObjectItemSet().Get(nWhich);
2031 }
2032 
2033 const SfxPoolItem& SdrObject::GetMergedItem(const sal_uInt16 nWhich) const
2034 {
2035 	return GetMergedItemSet().Get(nWhich);
2036 }
2037 
2038 void SdrObject::SetMergedItemSetAndBroadcast(const SfxItemSet& rSet, sal_Bool bClearAllItems)
2039 {
2040 	GetProperties().SetMergedItemSetAndBroadcast(rSet, bClearAllItems);
2041 }
2042 
2043 void SdrObject::ApplyNotPersistAttr(const SfxItemSet& rAttr)
2044 {
2045 	Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
2046 	NbcApplyNotPersistAttr(rAttr);
2047 	SetChanged();
2048 	BroadcastObjectChange();
2049 	SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
2050 }
2051 
2052 void SdrObject::NbcApplyNotPersistAttr(const SfxItemSet& rAttr)
2053 {
2054 	const Rectangle& rSnap=GetSnapRect();
2055 	const Rectangle& rLogic=GetLogicRect();
2056 	Point aRef1(rSnap.Center());
2057 	Point aRef2(aRef1); aRef2.Y()++;
2058 	const SfxPoolItem *pPoolItem=NULL;
2059 	if (rAttr.GetItemState(SDRATTR_TRANSFORMREF1X,sal_True,&pPoolItem)==SFX_ITEM_SET) {
2060 		aRef1.X()=((const SdrTransformRef1XItem*)pPoolItem)->GetValue();
2061 	}
2062 	if (rAttr.GetItemState(SDRATTR_TRANSFORMREF1Y,sal_True,&pPoolItem)==SFX_ITEM_SET) {
2063 		aRef1.Y()=((const SdrTransformRef1YItem*)pPoolItem)->GetValue();
2064 	}
2065 	if (rAttr.GetItemState(SDRATTR_TRANSFORMREF2X,sal_True,&pPoolItem)==SFX_ITEM_SET) {
2066 		aRef2.X()=((const SdrTransformRef2XItem*)pPoolItem)->GetValue();
2067 	}
2068 	if (rAttr.GetItemState(SDRATTR_TRANSFORMREF2Y,sal_True,&pPoolItem)==SFX_ITEM_SET) {
2069 		aRef2.Y()=((const SdrTransformRef2YItem*)pPoolItem)->GetValue();
2070 	}
2071 
2072 	Rectangle aNewSnap(rSnap);
2073 	if (rAttr.GetItemState(SDRATTR_MOVEX,sal_True,&pPoolItem)==SFX_ITEM_SET) {
2074 		long n=((const SdrMoveXItem*)pPoolItem)->GetValue();
2075 		aNewSnap.Move(n,0);
2076 	}
2077 	if (rAttr.GetItemState(SDRATTR_MOVEY,sal_True,&pPoolItem)==SFX_ITEM_SET) {
2078 		long n=((const SdrMoveYItem*)pPoolItem)->GetValue();
2079 		aNewSnap.Move(0,n);
2080 	}
2081 	if (rAttr.GetItemState(SDRATTR_ONEPOSITIONX,sal_True,&pPoolItem)==SFX_ITEM_SET) {
2082 		long n=((const SdrOnePositionXItem*)pPoolItem)->GetValue();
2083 		aNewSnap.Move(n-aNewSnap.Left(),0);
2084 	}
2085 	if (rAttr.GetItemState(SDRATTR_ONEPOSITIONY,sal_True,&pPoolItem)==SFX_ITEM_SET) {
2086 		long n=((const SdrOnePositionYItem*)pPoolItem)->GetValue();
2087 		aNewSnap.Move(0,n-aNewSnap.Top());
2088 	}
2089 	if (rAttr.GetItemState(SDRATTR_ONESIZEWIDTH,sal_True,&pPoolItem)==SFX_ITEM_SET) {
2090 		long n=((const SdrOneSizeWidthItem*)pPoolItem)->GetValue();
2091 		aNewSnap.Right()=aNewSnap.Left()+n;
2092 	}
2093 	if (rAttr.GetItemState(SDRATTR_ONESIZEHEIGHT,sal_True,&pPoolItem)==SFX_ITEM_SET) {
2094 		long n=((const SdrOneSizeHeightItem*)pPoolItem)->GetValue();
2095 		aNewSnap.Bottom()=aNewSnap.Top()+n;
2096 	}
2097 	if (aNewSnap!=rSnap) {
2098 		if (aNewSnap.GetSize()==rSnap.GetSize()) {
2099 			NbcMove(Size(aNewSnap.Left()-rSnap.Left(),aNewSnap.Top()-rSnap.Top()));
2100 		} else {
2101 			NbcSetSnapRect(aNewSnap);
2102 		}
2103 	}
2104 
2105 	if (rAttr.GetItemState(SDRATTR_SHEARANGLE,sal_True,&pPoolItem)==SFX_ITEM_SET) {
2106 		long n=((const SdrShearAngleItem*)pPoolItem)->GetValue();
2107 		n-=GetShearAngle();
2108 		if (n!=0) {
2109 			double nTan=tan(n*nPi180);
2110 			NbcShear(aRef1,n,nTan,sal_False);
2111 		}
2112 	}
2113 	if (rAttr.GetItemState(SDRATTR_ROTATEANGLE,sal_True,&pPoolItem)==SFX_ITEM_SET) {
2114 		long n=((const SdrRotateAngleItem*)pPoolItem)->GetValue();
2115 		n-=GetRotateAngle();
2116 		if (n!=0) {
2117 			double nSin=sin(n*nPi180);
2118 			double nCos=cos(n*nPi180);
2119 			NbcRotate(aRef1,n,nSin,nCos);
2120 		}
2121 	}
2122 	if (rAttr.GetItemState(SDRATTR_ROTATEONE,sal_True,&pPoolItem)==SFX_ITEM_SET) {
2123 		long n=((const SdrRotateOneItem*)pPoolItem)->GetValue();
2124 		double nSin=sin(n*nPi180);
2125 		double nCos=cos(n*nPi180);
2126 		NbcRotate(aRef1,n,nSin,nCos);
2127 	}
2128 	if (rAttr.GetItemState(SDRATTR_HORZSHEARONE,sal_True,&pPoolItem)==SFX_ITEM_SET) {
2129 		long n=((const SdrHorzShearOneItem*)pPoolItem)->GetValue();
2130 		double nTan=tan(n*nPi180);
2131 		NbcShear(aRef1,n,nTan,sal_False);
2132 	}
2133 	if (rAttr.GetItemState(SDRATTR_VERTSHEARONE,sal_True,&pPoolItem)==SFX_ITEM_SET) {
2134 		long n=((const SdrVertShearOneItem*)pPoolItem)->GetValue();
2135 		double nTan=tan(n*nPi180);
2136 		NbcShear(aRef1,n,nTan,sal_True);
2137 	}
2138 
2139 	if (rAttr.GetItemState(SDRATTR_OBJMOVEPROTECT,sal_True,&pPoolItem)==SFX_ITEM_SET) {
2140 		bool b=((const SdrObjMoveProtectItem*)pPoolItem)->GetValue();
2141 		SetMoveProtect(b);
2142 	}
2143 	if (rAttr.GetItemState(SDRATTR_OBJSIZEPROTECT,sal_True,&pPoolItem)==SFX_ITEM_SET) {
2144 		bool b=((const SdrObjSizeProtectItem*)pPoolItem)->GetValue();
2145 		SetResizeProtect(b);
2146 	}
2147 
2148 	/* #67368# move protect always sets size protect */
2149 	if( IsMoveProtect() )
2150 		SetResizeProtect( true );
2151 
2152 	if (rAttr.GetItemState(SDRATTR_OBJPRINTABLE,sal_True,&pPoolItem)==SFX_ITEM_SET) {
2153 		bool b=((const SdrObjPrintableItem*)pPoolItem)->GetValue();
2154 		SetPrintable(b);
2155 	}
2156 
2157 	if (rAttr.GetItemState(SDRATTR_OBJVISIBLE,sal_True,&pPoolItem)==SFX_ITEM_SET) {
2158 		bool b=((const SdrObjVisibleItem*)pPoolItem)->GetValue();
2159 		SetVisible(b);
2160 	}
2161 
2162 	SdrLayerID nLayer=SDRLAYER_NOTFOUND;
2163 	if (rAttr.GetItemState(SDRATTR_LAYERID,sal_True,&pPoolItem)==SFX_ITEM_SET) {
2164 		nLayer=((const SdrLayerIdItem*)pPoolItem)->GetValue();
2165 	}
2166 	if (rAttr.GetItemState(SDRATTR_LAYERNAME,sal_True,&pPoolItem)==SFX_ITEM_SET && pModel!=NULL) {
2167 		XubString aLayerName=((const SdrLayerNameItem*)pPoolItem)->GetValue();
2168 		const SdrLayerAdmin* pLayAd=pPage!=NULL ? &pPage->GetLayerAdmin() : pModel!=NULL ? &pModel->GetLayerAdmin() : NULL;
2169 		if (pLayAd!=NULL) {
2170 			const SdrLayer* pLayer=pLayAd->GetLayer(aLayerName, sal_True);
2171 			if (pLayer!=NULL) {
2172 				nLayer=pLayer->GetID();
2173 			}
2174 		}
2175 
2176 	}
2177 	if (nLayer!=SDRLAYER_NOTFOUND) {
2178 		NbcSetLayer(nLayer);
2179 	}
2180 
2181 	if (rAttr.GetItemState(SDRATTR_OBJECTNAME,sal_True,&pPoolItem)==SFX_ITEM_SET) {
2182 		XubString aName=((const SdrObjectNameItem*)pPoolItem)->GetValue();
2183 		SetName(aName);
2184 	}
2185 	Rectangle aNewLogic(rLogic);
2186 	if (rAttr.GetItemState(SDRATTR_LOGICSIZEWIDTH,sal_True,&pPoolItem)==SFX_ITEM_SET) {
2187 		long n=((const SdrLogicSizeWidthItem*)pPoolItem)->GetValue();
2188 		aNewLogic.Right()=aNewLogic.Left()+n;
2189 	}
2190 	if (rAttr.GetItemState(SDRATTR_LOGICSIZEHEIGHT,sal_True,&pPoolItem)==SFX_ITEM_SET) {
2191 		long n=((const SdrLogicSizeHeightItem*)pPoolItem)->GetValue();
2192 		aNewLogic.Bottom()=aNewLogic.Top()+n;
2193 	}
2194 	if (aNewLogic!=rLogic) {
2195 		NbcSetLogicRect(aNewLogic);
2196 	}
2197 	Fraction aResizeX(1,1);
2198 	Fraction aResizeY(1,1);
2199 	if (rAttr.GetItemState(SDRATTR_RESIZEXONE,sal_True,&pPoolItem)==SFX_ITEM_SET) {
2200 		aResizeX*=((const SdrResizeXOneItem*)pPoolItem)->GetValue();
2201 	}
2202 	if (rAttr.GetItemState(SDRATTR_RESIZEYONE,sal_True,&pPoolItem)==SFX_ITEM_SET) {
2203 		aResizeY*=((const SdrResizeYOneItem*)pPoolItem)->GetValue();
2204 	}
2205 	if (aResizeX!=Fraction(1,1) || aResizeY!=Fraction(1,1)) {
2206 		NbcResize(aRef1,aResizeX,aResizeY);
2207 	}
2208 }
2209 
2210 void lcl_SetItem(SfxItemSet& rAttr, FASTBOOL bMerge, const SfxPoolItem& rItem)
2211 {
2212 	if (bMerge) rAttr.MergeValue(rItem,sal_True);
2213 	else rAttr.Put(rItem);
2214 }
2215 
2216 void SdrObject::TakeNotPersistAttr(SfxItemSet& rAttr, FASTBOOL bMerge) const
2217 {
2218 	const Rectangle& rSnap=GetSnapRect();
2219 	const Rectangle& rLogic=GetLogicRect();
2220 	lcl_SetItem(rAttr,bMerge,SdrObjMoveProtectItem(IsMoveProtect()));
2221 	lcl_SetItem(rAttr,bMerge,SdrObjSizeProtectItem(IsResizeProtect()));
2222 	lcl_SetItem(rAttr,bMerge,SdrObjPrintableItem(IsPrintable()));
2223 	lcl_SetItem(rAttr,bMerge,SdrObjVisibleItem(IsVisible()));
2224 	lcl_SetItem(rAttr,bMerge,SdrRotateAngleItem(GetRotateAngle()));
2225 	lcl_SetItem(rAttr,bMerge,SdrShearAngleItem(GetShearAngle()));
2226 	lcl_SetItem(rAttr,bMerge,SdrOneSizeWidthItem(rSnap.GetWidth()-1));
2227 	lcl_SetItem(rAttr,bMerge,SdrOneSizeHeightItem(rSnap.GetHeight()-1));
2228 	lcl_SetItem(rAttr,bMerge,SdrOnePositionXItem(rSnap.Left()));
2229 	lcl_SetItem(rAttr,bMerge,SdrOnePositionYItem(rSnap.Top()));
2230 	if (rLogic.GetWidth()!=rSnap.GetWidth()) {
2231 		lcl_SetItem(rAttr,bMerge,SdrLogicSizeWidthItem(rLogic.GetWidth()-1));
2232 	}
2233 	if (rLogic.GetHeight()!=rSnap.GetHeight()) {
2234 		lcl_SetItem(rAttr,bMerge,SdrLogicSizeHeightItem(rLogic.GetHeight()-1));
2235 	}
2236 	XubString aName(GetName());
2237 
2238 	if(aName.Len())
2239 	{
2240 		lcl_SetItem(rAttr, bMerge, SdrObjectNameItem(aName));
2241 	}
2242 
2243 	lcl_SetItem(rAttr,bMerge,SdrLayerIdItem(GetLayer()));
2244 	const SdrLayerAdmin* pLayAd=pPage!=NULL ? &pPage->GetLayerAdmin() : pModel!=NULL ? &pModel->GetLayerAdmin() : NULL;
2245 	if (pLayAd!=NULL) {
2246 		const SdrLayer* pLayer=pLayAd->GetLayerPerID(GetLayer());
2247 		if (pLayer!=NULL) {
2248 			lcl_SetItem(rAttr,bMerge,SdrLayerNameItem(pLayer->GetName()));
2249 		}
2250 	}
2251 	Point aRef1(rSnap.Center());
2252 	Point aRef2(aRef1); aRef2.Y()++;
2253 	lcl_SetItem(rAttr,bMerge,SdrTransformRef1XItem(aRef1.X()));
2254 	lcl_SetItem(rAttr,bMerge,SdrTransformRef1YItem(aRef1.Y()));
2255 	lcl_SetItem(rAttr,bMerge,SdrTransformRef2XItem(aRef2.X()));
2256 	lcl_SetItem(rAttr,bMerge,SdrTransformRef2YItem(aRef2.Y()));
2257 }
2258 
2259 SfxStyleSheet* SdrObject::GetStyleSheet() const
2260 {
2261 	return GetProperties().GetStyleSheet();
2262 }
2263 
2264 void SdrObject::SetStyleSheet(SfxStyleSheet* pNewStyleSheet, sal_Bool bDontRemoveHardAttr)
2265 {
2266 	Rectangle aBoundRect0;
2267 
2268 	if(pUserCall)
2269 		aBoundRect0 = GetLastBoundRect();
2270 
2271 	// #110094#-14 SendRepaintBroadcast();
2272 	NbcSetStyleSheet(pNewStyleSheet, bDontRemoveHardAttr);
2273 	SetChanged();
2274 	BroadcastObjectChange();
2275 	SendUserCall(SDRUSERCALL_CHGATTR, aBoundRect0);
2276 }
2277 
2278 void SdrObject::NbcSetStyleSheet(SfxStyleSheet* pNewStyleSheet, sal_Bool bDontRemoveHardAttr)
2279 {
2280 	// only allow graphic and presentation styles for shapes
2281 	if( pNewStyleSheet && (pNewStyleSheet->GetFamily() == SFX_STYLE_FAMILY_PARA) && (pNewStyleSheet->GetFamily() == SFX_STYLE_FAMILY_PAGE) )
2282 		return;
2283 
2284 	GetProperties().SetStyleSheet(pNewStyleSheet, bDontRemoveHardAttr);
2285 }
2286 
2287 // Das Broadcasting beim Setzen der Attribute wird vom AttrObj gemanagt
2288 ////////////////////////////////////////////////////////////////////////////////////////////////////
2289 
2290 FASTBOOL SdrObject::IsNode() const
2291 {
2292 	return sal_True;
2293 }
2294 
2295 SdrGluePoint SdrObject::GetVertexGluePoint(sal_uInt16 nPosNum) const
2296 {
2297 	// #i41936# Use SnapRect for default GluePoints
2298 	const Rectangle aR(GetSnapRect());
2299 	Point aPt;
2300 
2301 	switch(nPosNum)
2302 	{
2303 		case 0 : aPt = aR.TopCenter();    break;
2304 		case 1 : aPt = aR.RightCenter();  break;
2305 		case 2 : aPt = aR.BottomCenter(); break;
2306 		case 3 : aPt = aR.LeftCenter();   break;
2307 	}
2308 
2309 	aPt -= aR.Center();
2310 	SdrGluePoint aGP(aPt);
2311 	aGP.SetPercent(sal_False);
2312 
2313 	return aGP;
2314 }
2315 
2316 SdrGluePoint SdrObject::GetCornerGluePoint(sal_uInt16 nPosNum) const
2317 {
2318 	Rectangle aR(GetCurrentBoundRect());
2319 	Point aPt;
2320 	switch (nPosNum) {
2321 		case 0 : aPt=aR.TopLeft();     break;
2322 		case 1 : aPt=aR.TopRight();    break;
2323 		case 2 : aPt=aR.BottomRight(); break;
2324 		case 3 : aPt=aR.BottomLeft();  break;
2325 	}
2326 	aPt-=GetSnapRect().Center();
2327 	SdrGluePoint aGP(aPt);
2328 	aGP.SetPercent(sal_False);
2329 	return aGP;
2330 }
2331 
2332 const SdrGluePointList* SdrObject::GetGluePointList() const
2333 {
2334 	if (pPlusData!=NULL) return pPlusData->pGluePoints;
2335 	return NULL;
2336 }
2337 
2338 //SdrGluePointList* SdrObject::GetGluePointList()
2339 //{
2340 //	if (pPlusData!=NULL) return pPlusData->pGluePoints;
2341 //	return NULL;
2342 //}
2343 
2344 SdrGluePointList* SdrObject::ForceGluePointList()
2345 {
2346 	ImpForcePlusData();
2347 	if (pPlusData->pGluePoints==NULL) {
2348 		pPlusData->pGluePoints=new SdrGluePointList;
2349 	}
2350 	return pPlusData->pGluePoints;
2351 }
2352 
2353 void SdrObject::SetGlueReallyAbsolute(FASTBOOL bOn)
2354 {
2355 	// erst Const-Aufruf um zu sehen, ob
2356 	// ueberhaupt Klebepunkte da sind
2357 	// const-Aufruf erzwingen!
2358 	if (GetGluePointList()!=NULL) {
2359 		SdrGluePointList* pGPL=ForceGluePointList();
2360 		pGPL->SetReallyAbsolute(bOn,*this);
2361 	}
2362 }
2363 
2364 void SdrObject::NbcRotateGluePoints(const Point& rRef, long nWink, double sn, double cs)
2365 {
2366 	// erst Const-Aufruf um zu sehen, ob
2367 	// ueberhaupt Klebepunkte da sind
2368 	// const-Aufruf erzwingen!
2369 	if (GetGluePointList()!=NULL) {
2370 		SdrGluePointList* pGPL=ForceGluePointList();
2371 		pGPL->Rotate(rRef,nWink,sn,cs,this);
2372 	}
2373 }
2374 
2375 void SdrObject::NbcMirrorGluePoints(const Point& rRef1, const Point& rRef2)
2376 {
2377 	// erst Const-Aufruf um zu sehen, ob
2378 	// ueberhaupt Klebepunkte da sind
2379 	// const-Aufruf erzwingen!
2380 	if (GetGluePointList()!=NULL) {
2381 		SdrGluePointList* pGPL=ForceGluePointList();
2382 		pGPL->Mirror(rRef1,rRef2,this);
2383 	}
2384 }
2385 
2386 void SdrObject::NbcShearGluePoints(const Point& rRef, long nWink, double tn, FASTBOOL bVShear)
2387 {
2388 	// erst Const-Aufruf um zu sehen, ob
2389 	// ueberhaupt Klebepunkte da sind
2390 	// const-Aufruf erzwingen!
2391 	if (GetGluePointList()!=NULL) {
2392 		SdrGluePointList* pGPL=ForceGluePointList();
2393 		pGPL->Shear(rRef,nWink,tn,bVShear,this);
2394 	}
2395 }
2396 
2397 FASTBOOL SdrObject::IsEdge() const
2398 {
2399 	return sal_False;
2400 }
2401 
2402 void SdrObject::ConnectToNode(FASTBOOL /*bTail1*/, SdrObject* /*pObj*/)
2403 {
2404 }
2405 
2406 void SdrObject::DisconnectFromNode(FASTBOOL /*bTail1*/)
2407 {
2408 }
2409 
2410 SdrObject* SdrObject::GetConnectedNode(FASTBOOL /*bTail1*/) const
2411 {
2412 	return NULL;
2413 }
2414 
2415 ////////////////////////////////////////////////////////////////////////////////////////////////////
2416 
2417 void extractLineContourFromPrimitive2DSequence(
2418     const drawinglayer::primitive2d::Primitive2DSequence& rxSequence,
2419     basegfx::B2DPolygonVector& rExtractedHairlines,
2420     basegfx::B2DPolyPolygonVector& rExtractedLineFills)
2421 {
2422     rExtractedHairlines.clear();
2423     rExtractedLineFills.clear();
2424 
2425     if(rxSequence.hasElements())
2426     {
2427         // use neutral ViewInformation
2428         const drawinglayer::geometry::ViewInformation2D aViewInformation2D;
2429 
2430         // create extractor, process and get result
2431         drawinglayer::processor2d::LineGeometryExtractor2D aExtractor(aViewInformation2D);
2432         aExtractor.process(rxSequence);
2433 
2434         // copy line results
2435         rExtractedHairlines = aExtractor.getExtractedHairlines();
2436 
2437         // copy fill rsults
2438         rExtractedLineFills = aExtractor.getExtractedLineFills();
2439     }
2440 }
2441 
2442 ////////////////////////////////////////////////////////////////////////////////////////////////////
2443 
2444 SdrObject* SdrObject::ImpConvertToContourObj(SdrObject* pRet, sal_Bool bForceLineDash) const
2445 {
2446 	bool bNoChange(true);
2447 
2448 	if(pRet->LineGeometryUsageIsNecessary())
2449 	{
2450 		basegfx::B2DPolyPolygon aMergedLineFillPolyPolygon;
2451 		basegfx::B2DPolyPolygon aMergedHairlinePolyPolygon;
2452 		const drawinglayer::primitive2d::Primitive2DSequence xSequence(pRet->GetViewContact().getViewIndependentPrimitive2DSequence());
2453 
2454 		if(xSequence.hasElements())
2455 		{
2456             basegfx::B2DPolygonVector aExtractedHairlines;
2457             basegfx::B2DPolyPolygonVector aExtractedLineFills;
2458 
2459             extractLineContourFromPrimitive2DSequence(xSequence, aExtractedHairlines, aExtractedLineFills);
2460 
2461 			if(!aExtractedHairlines.empty())
2462 			{
2463 				// for SdrObject creation, just copy all to a single Hairline-PolyPolygon
2464 				for(sal_uInt32 a(0); a < aExtractedHairlines.size(); a++)
2465 				{
2466 					aMergedHairlinePolyPolygon.append(aExtractedHairlines[a]);
2467 				}
2468 			}
2469 
2470 			// check for fill rsults
2471 			if(!aExtractedLineFills.empty())
2472 			{
2473 				// merge to a single PolyPolygon (OR)
2474 				aMergedLineFillPolyPolygon = basegfx::tools::mergeToSinglePolyPolygon(aExtractedLineFills);
2475 			}
2476 		}
2477 
2478 		if(aMergedLineFillPolyPolygon.count() || (bForceLineDash && aMergedHairlinePolyPolygon.count()))
2479 		{
2480 			SfxItemSet aSet(pRet->GetMergedItemSet());
2481 			XFillStyle eOldFillStyle = ((const XFillStyleItem&)(aSet.Get(XATTR_FILLSTYLE))).GetValue();
2482 			SdrPathObj* aLinePolygonPart = NULL;
2483 			SdrPathObj* aLineHairlinePart = NULL;
2484 			bool bBuildGroup(false);
2485 
2486 			if(aMergedLineFillPolyPolygon.count())
2487 			{
2488                 // create SdrObject for filled line geometry
2489 				aLinePolygonPart = new SdrPathObj(OBJ_PATHFILL, aMergedLineFillPolyPolygon);
2490 				aLinePolygonPart->SetModel(pRet->GetModel());
2491 
2492                 // correct item properties
2493 				aSet.Put(XLineWidthItem(0L));
2494 				aSet.Put(XLineStyleItem(XLINE_NONE));
2495 				Color aColorLine = ((const XLineColorItem&)(aSet.Get(XATTR_LINECOLOR))).GetColorValue();
2496 				sal_uInt16 nTransLine = ((const XLineTransparenceItem&)(aSet.Get(XATTR_LINETRANSPARENCE))).GetValue();
2497 				aSet.Put(XFillColorItem(XubString(), aColorLine));
2498 				aSet.Put(XFillStyleItem(XFILL_SOLID));
2499 				aSet.Put(XFillTransparenceItem(nTransLine));
2500 
2501 				aLinePolygonPart->SetMergedItemSet(aSet);
2502 			}
2503 
2504 			if(aMergedHairlinePolyPolygon.count())
2505 			{
2506                 // create SdrObject for hairline geometry
2507 				// OBJ_PATHLINE is necessary here, not OBJ_PATHFILL. This is intended
2508 				// to get a non-filled object. If the poly is closed, the PathObj takes care for
2509 				// the correct closed state.
2510 				aLineHairlinePart = new SdrPathObj(OBJ_PATHLINE, aMergedHairlinePolyPolygon);
2511 				aLineHairlinePart->SetModel(pRet->GetModel());
2512 
2513 				aSet.Put(XLineWidthItem(0L));
2514 				aSet.Put(XFillStyleItem(XFILL_NONE));
2515 				aSet.Put(XLineStyleItem(XLINE_SOLID));
2516 
2517 				// it is also necessary to switch off line start and ends here
2518 				aSet.Put(XLineStartWidthItem(0));
2519 				aSet.Put(XLineEndWidthItem(0));
2520 
2521 				aLineHairlinePart->SetMergedItemSet(aSet);
2522 
2523 				if(aLinePolygonPart)
2524                 {
2525 					bBuildGroup = true;
2526                 }
2527 			}
2528 
2529 			// check if original geometry should be added (e.g. filled and closed)
2530 			bool bAddOriginalGeometry(false);
2531 			SdrPathObj* pPath = PTR_CAST(SdrPathObj, pRet);
2532 
2533             if(pPath && pPath->IsClosed())
2534 			{
2535 				if(eOldFillStyle != XFILL_NONE)
2536 				{
2537 					// #107600# use new boolean here
2538 					bAddOriginalGeometry = true;
2539 				}
2540 			}
2541 
2542 			// do we need a group?
2543 			if(bBuildGroup || bAddOriginalGeometry)
2544 			{
2545 				SdrObject* pGroup = new SdrObjGroup;
2546 				pGroup->SetModel(pRet->GetModel());
2547 
2548 				if(bAddOriginalGeometry)
2549 				{
2550 					// Add a clone of the original geometry.
2551 					aSet.ClearItem();
2552 					aSet.Put(pRet->GetMergedItemSet());
2553 					aSet.Put(XLineStyleItem(XLINE_NONE));
2554 					aSet.Put(XLineWidthItem(0L));
2555 
2556 					SdrObject* pClone = pRet->Clone();
2557 
2558 					pClone->SetModel(pRet->GetModel());
2559 					pClone->SetMergedItemSet(aSet);
2560 
2561 					pGroup->GetSubList()->NbcInsertObject(pClone);
2562 				}
2563 
2564 				if(aLinePolygonPart)
2565 				{
2566 					pGroup->GetSubList()->NbcInsertObject(aLinePolygonPart);
2567 				}
2568 
2569 				if(aLineHairlinePart)
2570 				{
2571 					pGroup->GetSubList()->NbcInsertObject(aLineHairlinePart);
2572 				}
2573 
2574 				pRet = pGroup;
2575 
2576 				// be more careful with the state describing bool
2577 				bNoChange = false;
2578 			}
2579 			else
2580 			{
2581 				if(aLinePolygonPart)
2582 				{
2583 					pRet = aLinePolygonPart;
2584 					// be more careful with the state describing bool
2585 					bNoChange = false;
2586 				}
2587 				else if(aLineHairlinePart)
2588 				{
2589 					pRet = aLineHairlinePart;
2590 					// be more careful with the state describing bool
2591 					bNoChange = false;
2592 				}
2593 			}
2594 		}
2595 	}
2596 
2597 	if(bNoChange)
2598 	{
2599         // due to current method usage, create and return a clone when nothing has changed
2600 		SdrObject* pClone = pRet->Clone();
2601 		pClone->SetModel(pRet->GetModel());
2602 		pRet = pClone;
2603 	}
2604 
2605 	return pRet;
2606 }
2607 
2608 // convert this path object to contour object, even when it is a group
2609 SdrObject* SdrObject::ConvertToContourObj(SdrObject* pRet, sal_Bool bForceLineDash) const
2610 {
2611 	if(pRet->ISA(SdrObjGroup))
2612 	{
2613 		SdrObjList* pObjList2 = pRet->GetSubList();
2614 		SdrObject* pGroup = new SdrObjGroup;
2615 		pGroup->SetModel(pRet->GetModel());
2616 
2617 		for(sal_uInt32 a=0;a<pObjList2->GetObjCount();a++)
2618 		{
2619 			SdrObject* pIterObj = pObjList2->GetObj(a);
2620 			pGroup->GetSubList()->NbcInsertObject(ConvertToContourObj(pIterObj, bForceLineDash));
2621 		}
2622 
2623 		pRet = pGroup;
2624 	}
2625 	else
2626 	{
2627         if(pRet && pRet->ISA(SdrPathObj))
2628         {
2629             SdrPathObj* pPathObj = (SdrPathObj*)pRet;
2630 
2631             // bezier geometry got created, even for straight edges since the given
2632             // object is a result of DoConvertToPolyObj. For conversion to contour
2633             // this is not really needed and can be reduced again AFAP
2634             pPathObj->SetPathPoly(basegfx::tools::simplifyCurveSegments(pPathObj->GetPathPoly()));
2635         }
2636 
2637 		pRet = ImpConvertToContourObj(pRet, bForceLineDash);
2638 	}
2639 
2640 	// #i73441# preserve LayerID
2641 	if(pRet && pRet->GetLayer() != GetLayer())
2642 	{
2643 		pRet->SetLayer(GetLayer());
2644 	}
2645 
2646 	return pRet;
2647 }
2648 
2649 ////////////////////////////////////////////////////////////////////////////////////////////////////
2650 
2651 SdrObject* SdrObject::ConvertToPolyObj(sal_Bool bBezier, sal_Bool bLineToArea) const
2652 {
2653 	SdrObject* pRet = DoConvertToPolyObj(bBezier, true);
2654 
2655 	if(pRet && bLineToArea)
2656 	{
2657 		SdrObject* pNewRet = ConvertToContourObj(pRet);
2658 		delete pRet;
2659 		pRet = pNewRet;
2660 	}
2661 
2662 	// #i73441# preserve LayerID
2663 	if(pRet && pRet->GetLayer() != GetLayer())
2664 	{
2665 		pRet->SetLayer(GetLayer());
2666 	}
2667 
2668 	return pRet;
2669 }
2670 
2671 ////////////////////////////////////////////////////////////////////////////////////////////////////
2672 
2673 SdrObject* SdrObject::DoConvertToPolyObj(sal_Bool /*bBezier*/, bool /*bAddText*/) const
2674 {
2675 	return NULL;
2676 }
2677 
2678 ////////////////////////////////////////////////////////////////////////////////////////////////////
2679 
2680 void SdrObject::SetInserted(sal_Bool bIns)
2681 {
2682 	if (bIns!=IsInserted()) {
2683 		bInserted=bIns;
2684 		Rectangle aBoundRect0(GetLastBoundRect());
2685 		if (bIns) SendUserCall(SDRUSERCALL_INSERTED,aBoundRect0);
2686 		else SendUserCall(SDRUSERCALL_REMOVED,aBoundRect0);
2687 
2688 		if (pPlusData!=NULL && pPlusData->pBroadcast!=NULL) { // #42522#
2689 			SdrHint aHint(*this);
2690 			aHint.SetKind(bIns?HINT_OBJINSERTED:HINT_OBJREMOVED);
2691 			pPlusData->pBroadcast->Broadcast(aHint);
2692 		}
2693 	}
2694 }
2695 
2696 void SdrObject::SetMoveProtect(sal_Bool bProt)
2697 {
2698 	if(IsMoveProtect() != bProt)
2699 	{
2700 		// #i77187# secured and simplified
2701 		bMovProt = bProt;
2702 		SetChanged();
2703 		BroadcastObjectChange();
2704 	}
2705 }
2706 
2707 void SdrObject::SetResizeProtect(sal_Bool bProt)
2708 {
2709 	if(IsResizeProtect() != bProt)
2710 	{
2711 		// #i77187# secured and simplified
2712 		bSizProt = bProt;
2713 		SetChanged();
2714 		BroadcastObjectChange();
2715 	}
2716 }
2717 
2718 void SdrObject::SetPrintable(sal_Bool bPrn)
2719 {
2720 	if( bPrn == bNoPrint )
2721 	{
2722 		bNoPrint=!bPrn;
2723 		SetChanged();
2724 		if (IsInserted() && pModel!=NULL)
2725 		{
2726 			SdrHint aHint(*this);
2727 			pModel->Broadcast(aHint);
2728 		}
2729 	}
2730 }
2731 
2732 void SdrObject::SetVisible(sal_Bool bVisible)
2733 {
2734 	if( bVisible != mbVisible )
2735 	{
2736 		mbVisible = bVisible;
2737 		SetChanged();
2738 		if (IsInserted() && pModel!=NULL)
2739 		{
2740 			SdrHint aHint(*this);
2741 			pModel->Broadcast(aHint);
2742 		}
2743 	}
2744 }
2745 
2746 ////////////////////////////////////////////////////////////////////////////////////////////////////
2747 
2748 sal_uInt16 SdrObject::GetUserDataCount() const
2749 {
2750 	if (pPlusData==NULL || pPlusData->pUserDataList==NULL) return 0;
2751 	return pPlusData->pUserDataList->GetUserDataCount();
2752 }
2753 
2754 SdrObjUserData* SdrObject::GetUserData(sal_uInt16 nNum) const
2755 {
2756 	if (pPlusData==NULL || pPlusData->pUserDataList==NULL) return NULL;
2757 	return pPlusData->pUserDataList->GetUserData(nNum);
2758 }
2759 
2760 void SdrObject::InsertUserData(SdrObjUserData* pData, sal_uInt16 nPos)
2761 {
2762 	if (pData!=NULL) {
2763 		ImpForcePlusData();
2764 		if (pPlusData->pUserDataList==NULL) pPlusData->pUserDataList=new SdrObjUserDataList;
2765 		pPlusData->pUserDataList->InsertUserData(pData,nPos);
2766 	} else {
2767 		DBG_ERROR("SdrObject::InsertUserData(): pData ist NULL-Pointer");
2768 	}
2769 }
2770 
2771 void SdrObject::DeleteUserData(sal_uInt16 nNum)
2772 {
2773 	sal_uInt16 nAnz=GetUserDataCount();
2774 	if (nNum<nAnz) {
2775 		pPlusData->pUserDataList->DeleteUserData(nNum);
2776 		if (nAnz==1)  {
2777 			delete pPlusData->pUserDataList;
2778 			pPlusData->pUserDataList=NULL;
2779 		}
2780 	} else {
2781 		DBG_ERROR("SdrObject::DeleteUserData(): ungueltiger Index");
2782 	}
2783 }
2784 
2785 void SdrObject::SendUserCall(SdrUserCallType eUserCall, const Rectangle& rBoundRect) const
2786 {
2787 	SdrObjGroup* pGroup = NULL;
2788 
2789 	if( pObjList && pObjList->GetListKind() == SDROBJLIST_GROUPOBJ )
2790 		pGroup = (SdrObjGroup*) pObjList->GetOwnerObj();
2791 
2792 	if ( pUserCall )
2793 	{
2794 		// UserCall ausfuehren
2795 		pUserCall->Changed( *this, eUserCall, rBoundRect );
2796 	}
2797 
2798 	while( pGroup )
2799 	{
2800 		// Gruppe benachrichtigen
2801 		if( pGroup->GetUserCall() )
2802 		{
2803 			SdrUserCallType eChildUserType = SDRUSERCALL_CHILD_CHGATTR;
2804 
2805 			switch( eUserCall )
2806 			{
2807 				case SDRUSERCALL_MOVEONLY:
2808 					eChildUserType = SDRUSERCALL_CHILD_MOVEONLY;
2809 				break;
2810 
2811 				case SDRUSERCALL_RESIZE:
2812 					eChildUserType = SDRUSERCALL_CHILD_RESIZE;
2813 				break;
2814 
2815 				case SDRUSERCALL_CHGATTR:
2816 					eChildUserType = SDRUSERCALL_CHILD_CHGATTR;
2817 				break;
2818 
2819 				case SDRUSERCALL_DELETE:
2820 					eChildUserType = SDRUSERCALL_CHILD_DELETE;
2821 				break;
2822 
2823 				case SDRUSERCALL_COPY:
2824 					eChildUserType = SDRUSERCALL_CHILD_COPY;
2825 				break;
2826 
2827 				case SDRUSERCALL_INSERTED:
2828 					eChildUserType = SDRUSERCALL_CHILD_INSERTED;
2829 				break;
2830 
2831 				case SDRUSERCALL_REMOVED:
2832 					eChildUserType = SDRUSERCALL_CHILD_REMOVED;
2833 				break;
2834 
2835 				default: break;
2836 			}
2837 
2838 			pGroup->GetUserCall()->Changed( *this, eChildUserType, rBoundRect );
2839 		}
2840 
2841 		if( pGroup->GetObjList()                                       &&
2842 			pGroup->GetObjList()->GetListKind() == SDROBJLIST_GROUPOBJ &&
2843 			pGroup != (SdrObjGroup*) pObjList->GetOwnerObj() )
2844 			pGroup = (SdrObjGroup*) pObjList->GetOwnerObj();
2845 		else
2846 			pGroup = NULL;
2847 	}
2848 
2849     // notify our UNO shape listeners
2850     switch ( eUserCall )
2851     {
2852     case SDRUSERCALL_RESIZE:
2853         notifyShapePropertyChange( ::svx::eShapeSize );
2854         // fall through - RESIZE might also imply a change of the position
2855     case SDRUSERCALL_MOVEONLY:
2856         notifyShapePropertyChange( ::svx::eShapePosition );
2857         break;
2858     default:
2859         // not interested in
2860         break;
2861     }
2862 }
2863 
2864 // ItemPool fuer dieses Objekt wechseln
2865 void SdrObject::MigrateItemPool(SfxItemPool* pSrcPool, SfxItemPool* pDestPool, SdrModel* pNewModel)
2866 {
2867 	if(pSrcPool && pDestPool && (pSrcPool != pDestPool))
2868 	{
2869 		GetProperties().MoveToItemPool(pSrcPool, pDestPool, pNewModel);
2870 	}
2871 }
2872 
2873 sal_Bool SdrObject::IsTransparent( sal_Bool /*bCheckForAlphaChannel*/) const
2874 {
2875 	bool bRet = false;
2876 
2877 	if( IsGroupObject() )
2878 	{
2879 		SdrObjListIter aIter( *GetSubList(), IM_DEEPNOGROUPS );
2880 
2881 		for( SdrObject*	pO = aIter.Next(); pO && !bRet; pO = aIter.Next() )
2882 		{
2883 			const SfxItemSet& rAttr = pO->GetMergedItemSet();
2884 
2885 			if( ( ( (const XFillTransparenceItem&) rAttr.Get( XATTR_FILLTRANSPARENCE ) ).GetValue() ||
2886 				  ( (const XLineTransparenceItem&) rAttr.Get( XATTR_LINETRANSPARENCE ) ).GetValue()	) ||
2887 				( ( rAttr.GetItemState( XATTR_FILLFLOATTRANSPARENCE ) == SFX_ITEM_SET ) &&
2888 				  ( (const XFillFloatTransparenceItem&) rAttr.Get( XATTR_FILLFLOATTRANSPARENCE ) ).IsEnabled() ) )
2889 			{
2890 				bRet = sal_True;
2891 			}
2892 			else if( pO->ISA( SdrGrafObj ) )
2893 			{
2894 				SdrGrafObj* pGrafObj = (SdrGrafObj*) pO;
2895 				if( ( (const SdrGrafTransparenceItem&) rAttr.Get( SDRATTR_GRAFTRANSPARENCE ) ).GetValue() ||
2896                     ( pGrafObj->GetGraphicType() == GRAPHIC_BITMAP && pGrafObj->GetGraphic().GetBitmapEx().IsAlpha() ) )
2897 				{
2898 					bRet = sal_True;
2899 				}
2900 			}
2901 		}
2902 	}
2903 	else
2904 	{
2905 		const SfxItemSet& rAttr = GetMergedItemSet();
2906 
2907 		if( ( ( (const XFillTransparenceItem&) rAttr.Get( XATTR_FILLTRANSPARENCE ) ).GetValue() ||
2908 			  ( (const XLineTransparenceItem&) rAttr.Get( XATTR_LINETRANSPARENCE ) ).GetValue()	) ||
2909 			( ( rAttr.GetItemState( XATTR_FILLFLOATTRANSPARENCE ) == SFX_ITEM_SET ) &&
2910 			  ( (const XFillFloatTransparenceItem&) rAttr.Get( XATTR_FILLFLOATTRANSPARENCE ) ).IsEnabled() ) )
2911 		{
2912 			bRet = sal_True;
2913 		}
2914 		else if( ISA( SdrGrafObj ) )
2915 		{
2916 			SdrGrafObj* pGrafObj = (SdrGrafObj*) this;
2917 
2918 			// #i25616#
2919 			bRet = pGrafObj->IsObjectTransparent();
2920 		}
2921 	}
2922 
2923 	return bRet;
2924 }
2925 
2926 void SdrObject::impl_setUnoShape( const uno::Reference< uno::XInterface >& _rxUnoShape )
2927 {
2928 	maWeakUnoShape = _rxUnoShape;
2929 	mpSvxShape = SvxShape::getImplementation( _rxUnoShape );
2930 //    OSL_ENSURE( mpSvxShape || !_rxUnoShape.is(),
2931 //        "SdrObject::setUnoShape: not sure it's a good idea to have an XShape which is not implemented by SvxShape ..." );
2932 }
2933 
2934 /** only for internal use! */
2935 SvxShape* SdrObject::getSvxShape()
2936 {
2937     DBG_TESTSOLARMUTEX();
2938         // retrieving the impl pointer and subsequently using it is not thread-safe, of course, so it needs to be
2939         // guarded by the SolarMutex
2940 
2941     uno::Reference< uno::XInterface > xShape( maWeakUnoShape );
2942 #if OSL_DEBUG_LEVE > 0
2943     OSL_ENSURE( !( !xShape.is() && mpSvxShape ),
2944         "SdrObject::getSvxShape: still having IMPL-Pointer to dead object!" );
2945 #endif
2946     //#113608#, make sure mpSvxShape is always synchronized with maWeakUnoShape
2947     if ( mpSvxShape && !xShape.is() )
2948         mpSvxShape = NULL;
2949 
2950 	return mpSvxShape;
2951 }
2952 
2953 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SdrObject::getUnoShape()
2954 {
2955 	// try weak reference first
2956 	uno::Reference< uno::XInterface > xShape( getWeakUnoShape() );
2957 	if( !xShape.is() )
2958 	{
2959         OSL_ENSURE( mpSvxShape == NULL, "SdrObject::getUnoShape: XShape already dead, but still an IMPL pointer!" );
2960 		if ( pPage )
2961 		{
2962 			uno::Reference< uno::XInterface > xPage( pPage->getUnoPage() );
2963 			if( xPage.is() )
2964 			{
2965 				SvxDrawPage* pDrawPage = SvxDrawPage::getImplementation(xPage);
2966 				if( pDrawPage )
2967 				{
2968 					// create one
2969                     xShape = pDrawPage->_CreateShape( this );
2970                     impl_setUnoShape( xShape );
2971 				}
2972 			}
2973 		}
2974 		else
2975 		{
2976 			mpSvxShape = SvxDrawPage::CreateShapeByTypeAndInventor( GetObjIdentifier(), GetObjInventor(), this, NULL );
2977 			maWeakUnoShape = xShape = static_cast< ::cppu::OWeakObject* >( mpSvxShape );
2978 		}
2979 	}
2980 
2981 	return xShape;
2982 }
2983 
2984 ::svx::PropertyChangeNotifier& SdrObject::getShapePropertyChangeNotifier()
2985 {
2986     DBG_TESTSOLARMUTEX();
2987 
2988     SvxShape* pSvxShape = getSvxShape();
2989     ENSURE_OR_THROW( pSvxShape, "no SvxShape, yet!" );
2990     return pSvxShape->getShapePropertyChangeNotifier();
2991 }
2992 
2993 void SdrObject::notifyShapePropertyChange( const ::svx::ShapeProperty _eProperty ) const
2994 {
2995     DBG_TESTSOLARMUTEX();
2996 
2997     SvxShape* pSvxShape = const_cast< SdrObject* >( this )->getSvxShape();
2998     if ( pSvxShape )
2999         return pSvxShape->getShapePropertyChangeNotifier().notifyPropertyChange( _eProperty );
3000 }
3001 
3002 ////////////////////////////////////////////////////////////////////////////////////////////////////
3003 //
3004 // transformation interface for StarOfficeAPI. This implements support for
3005 // homogen 3x3 matrices containing the transformation of the SdrObject. At the
3006 // moment it contains a shearX, rotation and translation, but for setting all linear
3007 // transforms like Scale, ShearX, ShearY, Rotate and Translate are supported.
3008 //
3009 ////////////////////////////////////////////////////////////////////////////////////////////////////
3010 // gets base transformation and rectangle of object. If it's an SdrPathObj it fills the PolyPolygon
3011 // with the base geometry and returns TRUE. Otherwise it returns FALSE.
3012 sal_Bool SdrObject::TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, basegfx::B2DPolyPolygon& /*rPolyPolygon*/) const
3013 {
3014 	// any kind of SdrObject, just use SnapRect
3015 	Rectangle aRectangle(GetSnapRect());
3016 
3017 	// convert to transformation values
3018 	basegfx::B2DTuple aScale(aRectangle.GetWidth(), aRectangle.GetHeight());
3019 	basegfx::B2DTuple aTranslate(aRectangle.Left(), aRectangle.Top());
3020 
3021 	// position maybe relative to anchorpos, convert
3022 	if( pModel && pModel->IsWriter() )
3023 	{
3024 		if(GetAnchorPos().X() || GetAnchorPos().Y())
3025 		{
3026 			aTranslate -= basegfx::B2DTuple(GetAnchorPos().X(), GetAnchorPos().Y());
3027 		}
3028 	}
3029 
3030 	// force MapUnit to 100th mm
3031 	SfxMapUnit eMapUnit = GetObjectItemSet().GetPool()->GetMetric(0);
3032 	if(eMapUnit != SFX_MAPUNIT_100TH_MM)
3033 	{
3034 		switch(eMapUnit)
3035 		{
3036 			case SFX_MAPUNIT_TWIP :
3037 			{
3038 				// postion
3039 				aTranslate.setX(ImplTwipsToMM(aTranslate.getX()));
3040 				aTranslate.setY(ImplTwipsToMM(aTranslate.getY()));
3041 
3042 				// size
3043 				aScale.setX(ImplTwipsToMM(aScale.getX()));
3044 				aScale.setY(ImplTwipsToMM(aScale.getY()));
3045 
3046 				break;
3047 			}
3048 			default:
3049 			{
3050 				DBG_ERROR("TRGetBaseGeometry: Missing unit translation to 100th mm!");
3051 			}
3052 		}
3053 	}
3054 
3055 	// build matrix
3056 	rMatrix = basegfx::tools::createScaleTranslateB2DHomMatrix(aScale, aTranslate);
3057 
3058 	return sal_False;
3059 }
3060 
3061 // sets the base geometry of the object using infos contained in the homogen 3x3 matrix.
3062 // If it's an SdrPathObj it will use the provided geometry information. The Polygon has
3063 // to use (0,0) as upper left and will be scaled to the given size in the matrix.
3064 void SdrObject::TRSetBaseGeometry(const basegfx::B2DHomMatrix& rMatrix, const basegfx::B2DPolyPolygon& /*rPolyPolygon*/)
3065 {
3066 	// break up matrix
3067 	basegfx::B2DTuple aScale;
3068 	basegfx::B2DTuple aTranslate;
3069 	double fRotate, fShearX;
3070 	rMatrix.decompose(aScale, aTranslate, fRotate, fShearX);
3071 
3072 	// #i75086# Old DrawingLayer (GeoStat and geometry) does not support holding negative scalings
3073 	// in X and Y which equal a 180 degree rotation. Recognize it and react accordingly
3074 	if(basegfx::fTools::less(aScale.getX(), 0.0) && basegfx::fTools::less(aScale.getY(), 0.0))
3075 	{
3076 		aScale.setX(fabs(aScale.getX()));
3077 		aScale.setY(fabs(aScale.getY()));
3078 		fRotate = fmod(fRotate + F_PI, F_2PI);
3079 	}
3080 
3081 	// force metric to pool metric
3082 	SfxMapUnit eMapUnit = GetObjectItemSet().GetPool()->GetMetric(0);
3083 	if(eMapUnit != SFX_MAPUNIT_100TH_MM)
3084 	{
3085 		switch(eMapUnit)
3086 		{
3087 			case SFX_MAPUNIT_TWIP :
3088 			{
3089 				// position
3090 				aTranslate.setX(ImplMMToTwips(aTranslate.getX()));
3091 				aTranslate.setY(ImplMMToTwips(aTranslate.getY()));
3092 
3093 				// size
3094 				aScale.setX(ImplMMToTwips(aScale.getX()));
3095 				aScale.setY(ImplMMToTwips(aScale.getY()));
3096 
3097 				break;
3098 			}
3099 			default:
3100 			{
3101 				DBG_ERROR("TRSetBaseGeometry: Missing unit translation to PoolMetric!");
3102 			}
3103 		}
3104 	}
3105 
3106 	// if anchor is used, make position relative to it
3107 	if( pModel && pModel->IsWriter() )
3108 	{
3109 		if(GetAnchorPos().X() || GetAnchorPos().Y())
3110 		{
3111 			aTranslate += basegfx::B2DTuple(GetAnchorPos().X(), GetAnchorPos().Y());
3112 		}
3113 	}
3114 
3115 	// build BaseRect
3116 	Point aPoint(FRound(aTranslate.getX()), FRound(aTranslate.getY()));
3117 	Rectangle aBaseRect(aPoint, Size(FRound(aScale.getX()), FRound(aScale.getY())));
3118 
3119 	// set BaseRect
3120 	SetSnapRect(aBaseRect);
3121 }
3122 
3123 // #116168#
3124 // Give info if object is in destruction
3125 sal_Bool SdrObject::IsInDestruction() const
3126 {
3127 	if(pModel)
3128 		return pModel->IsInDestruction();
3129 	return sal_False;
3130 }
3131 
3132 // return if fill is != XFILL_NONE
3133 bool SdrObject::HasFillStyle() const
3134 {
3135 	return (((const XFillStyleItem&)GetObjectItem(XATTR_FILLSTYLE)).GetValue() != XFILL_NONE);
3136 }
3137 
3138 bool SdrObject::HasLineStyle() const
3139 {
3140 	return (((const XLineStyleItem&)GetObjectItem(XATTR_LINESTYLE)).GetValue() != XLINE_NONE);
3141 }
3142 
3143 
3144 // #i52224#
3145 // on import of OLE object from MS documents the BLIP size might be retrieved,
3146 // the following four methods are used to control it;
3147 // usually this data makes no sence after the import is finished, since the object
3148 // might be resized
3149 
3150 Rectangle SdrObject::GetBLIPSizeRectangle() const
3151 {
3152 	return maBLIPSizeRectangle;
3153 }
3154 
3155 void SdrObject::SetBLIPSizeRectangle( const Rectangle& aRect )
3156 {
3157 	maBLIPSizeRectangle = aRect;
3158 }
3159 
3160 void SdrObject::SetContextWritingMode( const sal_Int16 /*_nContextWritingMode*/ )
3161 {
3162     // this base class does not support different writing modes, so ignore the call
3163 }
3164 
3165 ////////////////////////////////////////////////////////////////////////////////////////////////////
3166 //
3167 //   @@@@  @@@@@  @@@@@@  @@@@@  @@@@   @@@@  @@@@@@  @@@@  @@@@@  @@  @@
3168 //  @@  @@ @@  @@     @@  @@    @@  @@ @@  @@   @@   @@  @@ @@  @@ @@  @@
3169 //  @@  @@ @@  @@     @@  @@    @@  @@ @@       @@   @@  @@ @@  @@ @@  @@
3170 //  @@  @@ @@@@@      @@  @@@@  @@@@@@ @@       @@   @@  @@ @@@@@   @@@@
3171 //  @@  @@ @@  @@     @@  @@    @@  @@ @@       @@   @@  @@ @@  @@   @@
3172 //  @@  @@ @@  @@ @@  @@  @@    @@  @@ @@  @@   @@   @@  @@ @@  @@   @@
3173 //   @@@@  @@@@@   @@@@   @@    @@  @@  @@@@    @@    @@@@  @@  @@   @@
3174 //
3175 ////////////////////////////////////////////////////////////////////////////////////////////////////
3176 
3177 SdrObjFactory::SdrObjFactory(sal_uInt32 nInvent, sal_uInt16 nIdent, SdrPage* pNewPage, SdrModel* pNewModel)
3178 {
3179 	nInventor=nInvent;
3180 	nIdentifier=nIdent;
3181 	pNewObj=NULL;
3182 	pPage=pNewPage;
3183 	pModel=pNewModel;
3184 	pObj=NULL;
3185 	pNewData=NULL;
3186 }
3187 
3188 SdrObjFactory::SdrObjFactory(sal_uInt32 nInvent, sal_uInt16 nIdent, SdrObject* pObj1)
3189 {
3190 	nInventor=nInvent;
3191 	nIdentifier=nIdent;
3192 	pNewObj=NULL;
3193 	pPage=NULL;
3194 	pModel=NULL;
3195 	pObj=pObj1;
3196 	pNewData=NULL;
3197 }
3198 
3199 SdrObject* SdrObjFactory::MakeNewObject(sal_uInt32 nInvent, sal_uInt16 nIdent, SdrPage* pPage, SdrModel* pModel)
3200 {
3201 	if(pModel == NULL && pPage != NULL)
3202 		pModel = pPage->GetModel();
3203 	SdrObject* pObj = NULL;
3204 
3205 	if(nInvent == SdrInventor)
3206 	{
3207 		switch (nIdent)
3208 		{
3209 			case sal_uInt16(OBJ_NONE       ): pObj=new SdrObject;                   break;
3210 			case sal_uInt16(OBJ_GRUP       ): pObj=new SdrObjGroup;                 break;
3211 			case sal_uInt16(OBJ_LINE       ): pObj=new SdrPathObj(OBJ_LINE       ); break;
3212 			case sal_uInt16(OBJ_POLY       ): pObj=new SdrPathObj(OBJ_POLY       ); break;
3213 			case sal_uInt16(OBJ_PLIN       ): pObj=new SdrPathObj(OBJ_PLIN       ); break;
3214 			case sal_uInt16(OBJ_PATHLINE   ): pObj=new SdrPathObj(OBJ_PATHLINE   ); break;
3215 			case sal_uInt16(OBJ_PATHFILL   ): pObj=new SdrPathObj(OBJ_PATHFILL   ); break;
3216 			case sal_uInt16(OBJ_FREELINE   ): pObj=new SdrPathObj(OBJ_FREELINE   ); break;
3217 			case sal_uInt16(OBJ_FREEFILL   ): pObj=new SdrPathObj(OBJ_FREEFILL   ); break;
3218 			case sal_uInt16(OBJ_PATHPOLY   ): pObj=new SdrPathObj(OBJ_POLY       ); break;
3219 			case sal_uInt16(OBJ_PATHPLIN   ): pObj=new SdrPathObj(OBJ_PLIN       ); break;
3220 			case sal_uInt16(OBJ_EDGE       ): pObj=new SdrEdgeObj;                  break;
3221 			case sal_uInt16(OBJ_RECT       ): pObj=new SdrRectObj;                  break;
3222 			case sal_uInt16(OBJ_CIRC       ): pObj=new SdrCircObj(OBJ_CIRC       ); break;
3223 			case sal_uInt16(OBJ_SECT       ): pObj=new SdrCircObj(OBJ_SECT       ); break;
3224 			case sal_uInt16(OBJ_CARC       ): pObj=new SdrCircObj(OBJ_CARC       ); break;
3225 			case sal_uInt16(OBJ_CCUT       ): pObj=new SdrCircObj(OBJ_CCUT       ); break;
3226 			case sal_uInt16(OBJ_TEXT       ): pObj=new SdrRectObj(OBJ_TEXT       ); break;
3227 			case sal_uInt16(OBJ_TEXTEXT    ): pObj=new SdrRectObj(OBJ_TEXTEXT    ); break;
3228 			case sal_uInt16(OBJ_TITLETEXT  ): pObj=new SdrRectObj(OBJ_TITLETEXT  ); break;
3229 			case sal_uInt16(OBJ_OUTLINETEXT): pObj=new SdrRectObj(OBJ_OUTLINETEXT); break;
3230 			case sal_uInt16(OBJ_MEASURE    ): pObj=new SdrMeasureObj;               break;
3231 			case sal_uInt16(OBJ_GRAF       ): pObj=new SdrGrafObj;                  break;
3232 			case sal_uInt16(OBJ_OLE2       ): pObj=new SdrOle2Obj;                  break;
3233 			case sal_uInt16(OBJ_FRAME      ): pObj=new SdrOle2Obj(sal_True);            break;
3234 			case sal_uInt16(OBJ_CAPTION    ): pObj=new SdrCaptionObj;               break;
3235 			case sal_uInt16(OBJ_PAGE       ): pObj=new SdrPageObj;                  break;
3236 			case sal_uInt16(OBJ_UNO        ): pObj=new SdrUnoObj(String());			break;
3237 			case sal_uInt16(OBJ_CUSTOMSHAPE  ): pObj=new SdrObjCustomShape();       break;
3238 			case sal_uInt16(OBJ_MEDIA 	   ): pObj=new SdrMediaObj();           	break;
3239 			case sal_uInt16(OBJ_TABLE	   ): pObj=new ::sdr::table::SdrTableObj(pModel);	break;
3240 		}
3241 	}
3242 
3243 	if(pObj == NULL)
3244 	{
3245 		SdrObjFactory* pFact=new SdrObjFactory(nInvent,nIdent,pPage,pModel);
3246 		SdrLinkList& rLL=ImpGetUserMakeObjHdl();
3247 		unsigned nAnz=rLL.GetLinkCount();
3248 		unsigned i=0;
3249 		while (i<nAnz && pObj==NULL) {
3250 			rLL.GetLink(i).Call((void*)pFact);
3251 			pObj=pFact->pNewObj;
3252 			i++;
3253 		}
3254 		delete pFact;
3255 	}
3256 
3257 	if(pObj == NULL)
3258 	{
3259 		// Na wenn's denn keiner will ...
3260 	}
3261 
3262 	if(pObj != NULL)
3263 	{
3264 		if(pPage != NULL)
3265 			pObj->SetPage(pPage);
3266 		else if(pModel != NULL)
3267 			pObj->SetModel(pModel);
3268 	}
3269 
3270 	return pObj;
3271 }
3272 
3273 SdrObjUserData* SdrObjFactory::MakeNewObjUserData(sal_uInt32 nInvent, sal_uInt16 nIdent, SdrObject* pObj1)
3274 {
3275 	SdrObjUserData* pData=NULL;
3276 	if (nInvent==SdrInventor) {
3277 		switch (nIdent)
3278 		{
3279 			case sal_uInt16(SDRUSERDATA_OBJTEXTLINK) : pData=new ImpSdrObjTextLinkUserData((SdrTextObj*)pObj1); break;
3280 		}
3281 	}
3282 	if (pData==NULL) {
3283 		SdrObjFactory aFact(nInvent,nIdent,pObj1);
3284 		SdrLinkList& rLL=ImpGetUserMakeObjUserDataHdl();
3285 		unsigned nAnz=rLL.GetLinkCount();
3286 		unsigned i=0;
3287 		while (i<nAnz && pData==NULL) {
3288 			rLL.GetLink(i).Call((void*)&aFact);
3289 			pData=aFact.pNewData;
3290 			i++;
3291 		}
3292 	}
3293 	return pData;
3294 }
3295 
3296 void SdrObjFactory::InsertMakeObjectHdl(const Link& rLink)
3297 {
3298 	SdrLinkList& rLL=ImpGetUserMakeObjHdl();
3299 	rLL.InsertLink(rLink);
3300 }
3301 
3302 void SdrObjFactory::RemoveMakeObjectHdl(const Link& rLink)
3303 {
3304 	SdrLinkList& rLL=ImpGetUserMakeObjHdl();
3305 	rLL.RemoveLink(rLink);
3306 }
3307 
3308 void SdrObjFactory::InsertMakeUserDataHdl(const Link& rLink)
3309 {
3310 	SdrLinkList& rLL=ImpGetUserMakeObjUserDataHdl();
3311 	rLL.InsertLink(rLink);
3312 }
3313 
3314 void SdrObjFactory::RemoveMakeUserDataHdl(const Link& rLink)
3315 {
3316 	SdrLinkList& rLL=ImpGetUserMakeObjUserDataHdl();
3317 	rLL.RemoveLink(rLink);
3318 }
3319 
3320 namespace svx
3321 {
3322     ISdrObjectFilter::~ISdrObjectFilter()
3323     {
3324     }
3325 }
3326 
3327 // eof
3328