xref: /trunk/main/svx/source/svdraw/svdobj.cxx (revision 300d4866)
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
ImplTwipsToMM(double fVal)124 inline double ImplTwipsToMM(double fVal) { return (fVal * (127.0 / 72.0)); }
ImplMMToTwips(double fVal)125 inline double ImplMMToTwips(double fVal) { return (fVal * (72.0 / 127.0)); }
126 
127 ////////////////////////////////////////////////////////////////////////////////////////////////////
128 
129 TYPEINIT0(SdrObjUserCall);
130 
~SdrObjUserCall()131 SdrObjUserCall::~SdrObjUserCall()
132 {
133 }
134 
Changed(const SdrObject &,SdrUserCallType,const Rectangle &)135 void SdrObjUserCall::Changed(const SdrObject& /*rObj*/, SdrUserCallType /*eType*/, const Rectangle& /*rOldBoundRect*/)
136 {
137 }
138 
139 ////////////////////////////////////////////////////////////////////////////////////////////////////
140 
141 TYPEINIT0(SdrObjUserData);
142 
operator =(const SdrObjUserData &)143 void SdrObjUserData::operator=(const SdrObjUserData& /*rData*/)    // nicht implementiert
144 {
145 }
146 
operator ==(const SdrObjUserData &) const147 sal_Bool SdrObjUserData::operator==(const SdrObjUserData& /*rData*/) const // nicht implementiert
148 {
149 	return sal_False;
150 }
151 
operator !=(const SdrObjUserData &) const152 sal_Bool SdrObjUserData::operator!=(const SdrObjUserData& /*rData*/) const // nicht implementiert
153 {
154 	return sal_False;
155 }
156 
~SdrObjUserData()157 SdrObjUserData::~SdrObjUserData()
158 {
159 }
160 
HasMacro(const SdrObject *) const161 FASTBOOL SdrObjUserData::HasMacro(const SdrObject* /*pObj*/) const
162 {
163 	return sal_False;
164 }
165 
CheckMacroHit(const SdrObjMacroHitRec & rRec,const SdrObject * pObj) const166 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 
GetMacroPointer(const SdrObjMacroHitRec &,const SdrObject *) const179 Pointer SdrObjUserData::GetMacroPointer(const SdrObjMacroHitRec& /*rRec*/, const SdrObject* /*pObj*/) const
180 {
181 	return Pointer(POINTER_REFHAND);
182 }
183 
PaintMacro(OutputDevice & rOut,const Rectangle &,const SdrObjMacroHitRec &,const SdrObject * pObj) const184 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 
DoMacro(const SdrObjMacroHitRec &,SdrObject *)205 FASTBOOL SdrObjUserData::DoMacro(const SdrObjMacroHitRec& /*rRec*/, SdrObject* /*pObj*/)
206 {
207 	return sal_False;
208 }
209 
GetMacroPopupComment(const SdrObjMacroHitRec &,const SdrObject *) const210 XubString SdrObjUserData::GetMacroPopupComment(const SdrObjMacroHitRec& /*rRec*/, const SdrObject* /*pObj*/) const
211 {
212 	return String();
213 }
214 
Clear()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 
SdrObjGeoData()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 
~SdrObjGeoData()240 SdrObjGeoData::~SdrObjGeoData()
241 {
242 	DBG_DTOR(SdrObjGeoData,NULL);
243 	delete pGPL;
244 }
245 
246 ////////////////////////////////////////////////////////////////////////////////////////////////////
247 
248 TYPEINIT0(SdrObjPlusData);
249 
SdrObjPlusData()250 SdrObjPlusData::SdrObjPlusData():
251 	pBroadcast(NULL),
252 	pUserDataList(NULL),
253 	pGluePoints(NULL),
254 	pAutoTimer(NULL)
255 {
256 }
257 
~SdrObjPlusData()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 
Clone(SdrObject * pObj1) const266 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 
CreateObjectSpecificProperties()317 sdr::properties::BaseProperties* SdrObject::CreateObjectSpecificProperties()
318 {
319 	return new sdr::properties::EmptyProperties(*this);
320 }
321 
GetProperties() const322 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 
AddObjectUser(sdr::ObjectUser & rNewUser)336 void SdrObject::AddObjectUser(sdr::ObjectUser& rNewUser)
337 {
338 	maObjectUsers.push_back(&rNewUser);
339 }
340 
RemoveObjectUser(sdr::ObjectUser & rOldUser)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 
CreateObjectSpecificViewContact()353 sdr::contact::ViewContact* SdrObject::CreateObjectSpecificViewContact()
354 {
355 	return new sdr::contact::ViewContactOfSdrObj(*this);
356 }
357 
GetViewContact() const358 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
ActionChanged() const370 void SdrObject::ActionChanged() const
371 {
372     // Do necessary ViewContact actions
373 	GetViewContact().ActionChanged();
374 }
375 
376 //////////////////////////////////////////////////////////////////////////////
377 
SetBoundRectDirty()378 void SdrObject::SetBoundRectDirty()
379 {
380 	aOutRect = Rectangle();
381 }
382 
383 //////////////////////////////////////////////////////////////////////////////
384 
385 DBG_NAME(SdrObject);
386 TYPEINIT1(SdrObject,SfxListener);
387 
SdrObject()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 
~SdrObject()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 
Free(SdrObject * & _rpObject)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 
NewPlusData() const496 SdrObjPlusData* SdrObject::NewPlusData() const
497 {
498 	return new SdrObjPlusData;
499 }
500 
SetRectsDirty(sal_Bool bNotMyself)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 
SetModel(SdrModel * pNewModel)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 
SetObjList(SdrObjList * pNewObjList)533 void SdrObject::SetObjList(SdrObjList* pNewObjList)
534 {
535 	pObjList=pNewObjList;
536 }
537 
SetPage(SdrPage * pNewPage)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 
GetGlobalDrawObjectItemPool()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 
FreeGlobalDrawObjectItemPool()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 
GetObjectItemPool() const576 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 
GetObjInventor() const585 sal_uInt32 SdrObject::GetObjInventor()   const
586 {
587 	return SdrInventor;
588 }
589 
GetObjIdentifier() const590 sal_uInt16 SdrObject::GetObjIdentifier() const
591 {
592 	return sal_uInt16(OBJ_NONE);
593 }
594 
TakeObjInfo(SdrObjTransformInfoRec & rInfo) const595 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 
GetLayer() const610 SdrLayerID SdrObject::GetLayer() const
611 {
612 	return mnLayerID;
613 }
614 
getMergedHierarchyLayerSet(SetOfByte & rSet) const615 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 
NbcSetLayer(SdrLayerID nLayer)627 void SdrObject::NbcSetLayer(SdrLayerID nLayer)
628 {
629 	if(GetLayer() != nLayer)
630 	{
631 		mnLayerID = nLayer;
632 	}
633 }
634 
SetLayer(SdrLayerID nLayer)635 void SdrObject::SetLayer(SdrLayerID nLayer)
636 {
637 	NbcSetLayer(nLayer);
638 	SetChanged();
639 	BroadcastObjectChange();
640 }
641 
AddListener(SfxListener & rListener)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 
RemoveListener(SfxListener & rListener)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 
AddReference(SdrVirtObj & rVrtObj)660 void SdrObject::AddReference(SdrVirtObj& rVrtObj)
661 {
662 	AddListener(rVrtObj);
663 }
664 
DelReference(SdrVirtObj & rVrtObj)665 void SdrObject::DelReference(SdrVirtObj& rVrtObj)
666 {
667 	RemoveListener(rVrtObj);
668 }
669 
ForceAutoTimer()670 AutoTimer* SdrObject::ForceAutoTimer()
671 {
672 	ImpForcePlusData();
673 	if (pPlusData->pAutoTimer==NULL) pPlusData->pAutoTimer=new AutoTimer;
674 	return pPlusData->pAutoTimer;
675 }
676 
HasRefPoint() const677 FASTBOOL SdrObject::HasRefPoint() const
678 {
679 	return sal_False;
680 }
681 
GetRefPoint() const682 Point SdrObject::GetRefPoint() const
683 {
684 	return GetCurrentBoundRect().Center();
685 }
686 
SetRefPoint(const Point &)687 void SdrObject::SetRefPoint(const Point& /*rPnt*/)
688 {
689 }
690 
GetSubList() const691 SdrObjList* SdrObject::GetSubList() const
692 {
693 	return NULL;
694 }
695 
GetUpGroup() const696 SdrObject* SdrObject::GetUpGroup() const
697 {
698 	return pObjList!=NULL ? pObjList->GetOwnerObj() : NULL;
699 }
700 
SetName(const String & rStr)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 
GetName() const738 String SdrObject::GetName() const
739 {
740 	if(pPlusData)
741 	{
742 		return pPlusData->aObjName;
743 	}
744 
745 	return String();
746 }
747 
SetTitle(const String & rStr)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 
GetTitle() const785 String SdrObject::GetTitle() const
786 {
787 	if(pPlusData)
788 	{
789 		return pPlusData->aObjTitle;
790 	}
791 
792 	return String();
793 }
794 
SetDescription(const String & rStr)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 
GetDescription() const832 String SdrObject::GetDescription() const
833 {
834 	if(pPlusData)
835 	{
836 		return pPlusData->aObjDescription;
837 	}
838 
839 	return String();
840 }
841 
SetHTMLName(const String & rStr)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 
GetHTMLName() const856 String SdrObject::GetHTMLName() const
857 {
858 	if(pPlusData)
859 	{
860 		return pPlusData->aHTMLName;
861 	}
862 
863 	return String();
864 }
865 
GetOrdNum() const866 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 
GetNavigationPosition(void)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 
SetNavigationPosition(const sal_uInt32 nNewPosition)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 sometimes problematic (inside a bigger object change You will get
903 // non-useful BoundRects sometimes) i rename that method from GetBoundRect() to
904 // GetCurrentBoundRect().
GetCurrentBoundRect() const905 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.
GetLastBoundRect() const920 const Rectangle& SdrObject::GetLastBoundRect() const
921 {
922 	return aOutRect;
923 }
924 
RecalcBoundRect()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 
BroadcastObjectChange() const953 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 
SetChanged()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.
SingleObjectPainter(OutputDevice & rOut) const991 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 
LineGeometryUsageIsNecessary() const1005 sal_Bool SdrObject::LineGeometryUsageIsNecessary() const
1006 {
1007 	XLineStyle eXLS = (XLineStyle)((const XLineStyleItem&)GetMergedItem(XATTR_LINESTYLE)).GetValue();
1008 	return (eXLS != XLINE_NONE);
1009 }
1010 
Clone() const1011 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 
operator =(const SdrObject & rObj)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 
TakeObjNameSingul(XubString & rName) const1068 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 
TakeObjNamePlural(XubString & rName) const1082 void SdrObject::TakeObjNamePlural(XubString& rName) const
1083 {
1084 	rName=ImpGetResStr(STR_ObjNamePluralNONE);
1085 }
1086 
ImpTakeDescriptionStr(sal_uInt16 nStrCacheID,XubString & rStr,sal_uInt16 nVal) const1087 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 
GetWinkStr(long nWink,FASTBOOL bNoDegChar) const1114 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 
GetMetrStr(long nVal,MapUnit,FASTBOOL bNoUnitChars) const1123 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 
TakeXorPoly() const1132 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 
TakeContour() const1142 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 
GetHdlCount() const1229 sal_uInt32 SdrObject::GetHdlCount() const
1230 {
1231 	return 8L;
1232 }
1233 
GetHdl(sal_uInt32 nHdlNum) const1234 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 
GetPlusHdlCount(const SdrHdl &) const1251 sal_uInt32 SdrObject::GetPlusHdlCount(const SdrHdl& /*rHdl*/) const
1252 {
1253 	return 0L;
1254 }
1255 
GetPlusHdl(const SdrHdl &,sal_uInt32) const1256 SdrHdl* SdrObject::GetPlusHdl(const SdrHdl& /*rHdl*/, sal_uInt32 /*nPlNum*/) const
1257 {
1258 	return 0L;
1259 }
1260 
AddToHdlList(SdrHdlList & rHdlList) const1261 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 
ImpDragCalcRect(const SdrDragStat & rDrag) const1272 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 
hasSpecialDrag() const1343 bool SdrObject::hasSpecialDrag() const
1344 {
1345 	return false;
1346 }
1347 
supportsFullDrag() const1348 bool SdrObject::supportsFullDrag() const
1349 {
1350     return true;
1351 }
1352 
getFullDragClone() const1353 SdrObject* SdrObject::getFullDragClone() const
1354 {
1355 	// default uses simple clone
1356 	return Clone();
1357 }
1358 
beginSpecialDrag(SdrDragStat & rDrag) const1359 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 
applySpecialDrag(SdrDragStat & rDrag)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 
getSpecialDragComment(const SdrDragStat &) const1387 String SdrObject::getSpecialDragComment(const SdrDragStat& /*rDrag*/) const
1388 {
1389 	return String();
1390 }
1391 
getSpecialDragPoly(const SdrDragStat &) const1392 basegfx::B2DPolyPolygon SdrObject::getSpecialDragPoly(const SdrDragStat& /*rDrag*/) const
1393 {
1394     // default has nothing to add
1395     return basegfx::B2DPolyPolygon();
1396 }
1397 
1398 ////////////////////////////////////////////////////////////////////////////////////////////////////
1399 // Create
BegCreate(SdrDragStat & rStat)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 
MovCreate(SdrDragStat & rStat)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 
EndCreate(SdrDragStat & rStat,SdrCreateCmd eCmd)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 
BrkCreate(SdrDragStat &)1439 void SdrObject::BrkCreate(SdrDragStat& /*rStat*/)
1440 {
1441 }
1442 
BckCreate(SdrDragStat &)1443 FASTBOOL SdrObject::BckCreate(SdrDragStat& /*rStat*/)
1444 {
1445 	return sal_False;
1446 }
1447 
TakeCreatePoly(const SdrDragStat & rDrag) const1448 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 
GetCreatePointer() const1460 Pointer SdrObject::GetCreatePointer() const
1461 {
1462 	return Pointer(POINTER_CROSS);
1463 }
1464 
1465 // Transformationen
NbcMove(const Size & rSiz)1466 void SdrObject::NbcMove(const Size& rSiz)
1467 {
1468 	MoveRect(aOutRect,rSiz);
1469 	SetRectsDirty();
1470 }
1471 
NbcResize(const Point & rRef,const Fraction & xFact,const Fraction & yFact)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 
NbcRotate(const Point & rRef,long nWink,double sn,double cs)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 
NbcMirror(const Point & rRef1,const Point & rRef2)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 
NbcShear(const Point & rRef,long nWink,double tn,FASTBOOL bVShear)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 
Move(const Size & rSiz)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 
Resize(const Point & rRef,const Fraction & xFact,const Fraction & yFact)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 
Rotate(const Point & rRef,long nWink,double sn,double cs)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 
Mirror(const Point & rRef1,const Point & rRef2)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 
Shear(const Point & rRef,long nWink,double tn,FASTBOOL bVShear)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 
NbcSetRelativePos(const Point & rPnt)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 
SetRelativePos(const Point & rPnt)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 
GetRelativePos() const1636 Point SdrObject::GetRelativePos() const
1637 {
1638 	return GetSnapRect().TopLeft()-aAnchor;
1639 }
1640 
NbcSetAnchorPos(const Point & rPnt)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 
SetAnchorPos(const Point & rPnt)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 
GetAnchorPos() const1660 const Point& SdrObject::GetAnchorPos() const
1661 {
1662 	return aAnchor;
1663 }
1664 
RecalcSnapRect()1665 void SdrObject::RecalcSnapRect()
1666 {
1667 }
1668 
GetSnapRect() const1669 const Rectangle& SdrObject::GetSnapRect() const
1670 {
1671 	return aOutRect;
1672 }
1673 
NbcSetSnapRect(const Rectangle & rRect)1674 void SdrObject::NbcSetSnapRect(const Rectangle& rRect)
1675 {
1676 	aOutRect=rRect;
1677 }
1678 
GetLogicRect() const1679 const Rectangle& SdrObject::GetLogicRect() const
1680 {
1681 	return GetSnapRect();
1682 }
1683 
NbcSetLogicRect(const Rectangle & rRect)1684 void SdrObject::NbcSetLogicRect(const Rectangle& rRect)
1685 {
1686 	NbcSetSnapRect(rRect);
1687 }
1688 
AdjustToMaxRect(const Rectangle & rMaxRect,bool)1689 void SdrObject::AdjustToMaxRect( const Rectangle& rMaxRect, bool /* bShrinkOnly = false */ )
1690 {
1691 	SetLogicRect( rMaxRect );
1692 }
1693 
SetSnapRect(const Rectangle & rRect)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 
SetLogicRect(const Rectangle & rRect)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 
GetRotateAngle() const1714 long SdrObject::GetRotateAngle() const
1715 {
1716 	return 0;
1717 }
1718 
GetShearAngle(FASTBOOL) const1719 long SdrObject::GetShearAngle(FASTBOOL /*bVertical*/) const
1720 {
1721 	return 0;
1722 }
1723 
GetSnapPointCount() const1724 sal_uInt32 SdrObject::GetSnapPointCount() const
1725 {
1726 	return GetPointCount();
1727 }
1728 
GetSnapPoint(sal_uInt32 i) const1729 Point SdrObject::GetSnapPoint(sal_uInt32 i) const
1730 {
1731 	return GetPoint(i);
1732 }
1733 
IsPolyObj() const1734 sal_Bool SdrObject::IsPolyObj() const
1735 {
1736 	return sal_False;
1737 }
1738 
GetPointCount() const1739 sal_uInt32 SdrObject::GetPointCount() const
1740 {
1741 	return 0L;
1742 }
1743 
GetPoint(sal_uInt32) const1744 Point SdrObject::GetPoint(sal_uInt32 /*i*/) const
1745 {
1746 	return Point();
1747 }
1748 
SetPoint(const Point & rPnt,sal_uInt32 i)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 
NbcSetPoint(const Point &,sal_uInt32)1759 void SdrObject::NbcSetPoint(const Point& /*rPnt*/, sal_uInt32 /*i*/)
1760 {
1761 }
1762 
HasTextEdit() const1763 FASTBOOL SdrObject::HasTextEdit() const
1764 {
1765 	return sal_False;
1766 }
1767 
BegTextEdit(SdrOutliner &)1768 sal_Bool SdrObject::BegTextEdit(SdrOutliner& /*rOutl*/)
1769 {
1770 	return sal_False;
1771 }
1772 
EndTextEdit(SdrOutliner &)1773 void SdrObject::EndTextEdit(SdrOutliner& /*rOutl*/)
1774 {
1775 }
1776 
SetOutlinerParaObject(OutlinerParaObject * pTextObject)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 
NbcSetOutlinerParaObject(OutlinerParaObject *)1789 void SdrObject::NbcSetOutlinerParaObject(OutlinerParaObject* /*pTextObject*/)
1790 {
1791 }
1792 
GetOutlinerParaObject() const1793 OutlinerParaObject* SdrObject::GetOutlinerParaObject() const
1794 {
1795 	return NULL;
1796 }
1797 
NbcReformatText()1798 void SdrObject::NbcReformatText()
1799 {
1800 }
1801 
ReformatText()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 
BurnInStyleSheetAttributes()1813 void SdrObject::BurnInStyleSheetAttributes()
1814 {
1815 	GetProperties().ForceStyleToHardAttributes();
1816 }
1817 
1818 #define Imp2ndKennung (0x434F4D43)
ImpGetMacroUserData() const1819 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 
HasMacro() const1831 FASTBOOL SdrObject::HasMacro() const
1832 {
1833 	SdrObjUserData* pData=ImpGetMacroUserData();
1834 	return pData!=NULL ? pData->HasMacro(this) : sal_False;
1835 }
1836 
CheckMacroHit(const SdrObjMacroHitRec & rRec) const1837 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 
GetMacroPointer(const SdrObjMacroHitRec & rRec) const1854 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 
PaintMacro(OutputDevice & rOut,const Rectangle & rDirtyRect,const SdrObjMacroHitRec & rRec) const1863 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 
DoMacro(const SdrObjMacroHitRec & rRec)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 
GetMacroPopupComment(const SdrObjMacroHitRec & rRec) const1899 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 
NewGeoData() const1910 SdrObjGeoData* SdrObject::NewGeoData() const
1911 {
1912 	return new SdrObjGeoData;
1913 }
1914 
SaveGeoData(SdrObjGeoData & rGeo) const1915 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 
RestGeoData(const SdrObjGeoData & rGeo)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 
GetGeoData() const1969 SdrObjGeoData* SdrObject::GetGeoData() const
1970 {
1971 	SdrObjGeoData* pGeo=NewGeoData();
1972 	SaveGeoData(*pGeo);
1973 	return pGeo;
1974 }
1975 
SetGeoData(const SdrObjGeoData & rGeo)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 
GetObjectItemSet() const1988 const SfxItemSet& SdrObject::GetObjectItemSet() const
1989 {
1990 	return GetProperties().GetObjectItemSet();
1991 }
1992 
GetMergedItemSet() const1993 const SfxItemSet& SdrObject::GetMergedItemSet() const
1994 {
1995 	return GetProperties().GetMergedItemSet();
1996 }
1997 
SetObjectItem(const SfxPoolItem & rItem)1998 void SdrObject::SetObjectItem(const SfxPoolItem& rItem)
1999 {
2000 	GetProperties().SetObjectItem(rItem);
2001 }
2002 
SetMergedItem(const SfxPoolItem & rItem)2003 void SdrObject::SetMergedItem(const SfxPoolItem& rItem)
2004 {
2005 	GetProperties().SetMergedItem(rItem);
2006 }
2007 
ClearObjectItem(const sal_uInt16 nWhich)2008 void SdrObject::ClearObjectItem(const sal_uInt16 nWhich)
2009 {
2010 	GetProperties().ClearObjectItem(nWhich);
2011 }
2012 
ClearMergedItem(const sal_uInt16 nWhich)2013 void SdrObject::ClearMergedItem(const sal_uInt16 nWhich)
2014 {
2015 	GetProperties().ClearMergedItem(nWhich);
2016 }
2017 
SetObjectItemSet(const SfxItemSet & rSet)2018 void SdrObject::SetObjectItemSet(const SfxItemSet& rSet)
2019 {
2020 	GetProperties().SetObjectItemSet(rSet);
2021 }
2022 
SetMergedItemSet(const SfxItemSet & rSet,sal_Bool bClearAllItems)2023 void SdrObject::SetMergedItemSet(const SfxItemSet& rSet, sal_Bool bClearAllItems)
2024 {
2025 	GetProperties().SetMergedItemSet(rSet, bClearAllItems);
2026 }
2027 
GetObjectItem(const sal_uInt16 nWhich) const2028 const SfxPoolItem& SdrObject::GetObjectItem(const sal_uInt16 nWhich) const
2029 {
2030 	return GetObjectItemSet().Get(nWhich);
2031 }
2032 
GetObjectMapUnit() const2033 SfxMapUnit SdrObject::GetObjectMapUnit() const
2034 {
2035     SfxMapUnit aRetval(SFX_MAPUNIT_100TH_MM);
2036     SdrItemPool* pPool = GetObjectItemPool();
2037 
2038     if(pPool)
2039     {
2040         aRetval = pPool->GetMetric(0);
2041     }
2042     else
2043     {
2044         OSL_ENSURE(pPool, "SdrObjects always need a pool (!)");
2045     }
2046 
2047     return aRetval;
2048 }
2049 
GetMergedItem(const sal_uInt16 nWhich) const2050 const SfxPoolItem& SdrObject::GetMergedItem(const sal_uInt16 nWhich) const
2051 {
2052 	return GetMergedItemSet().Get(nWhich);
2053 }
2054 
SetMergedItemSetAndBroadcast(const SfxItemSet & rSet,sal_Bool bClearAllItems)2055 void SdrObject::SetMergedItemSetAndBroadcast(const SfxItemSet& rSet, sal_Bool bClearAllItems)
2056 {
2057 	GetProperties().SetMergedItemSetAndBroadcast(rSet, bClearAllItems);
2058 }
2059 
ApplyNotPersistAttr(const SfxItemSet & rAttr)2060 void SdrObject::ApplyNotPersistAttr(const SfxItemSet& rAttr)
2061 {
2062 	Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
2063 	NbcApplyNotPersistAttr(rAttr);
2064 	SetChanged();
2065 	BroadcastObjectChange();
2066 	SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
2067 }
2068 
NbcApplyNotPersistAttr(const SfxItemSet & rAttr)2069 void SdrObject::NbcApplyNotPersistAttr(const SfxItemSet& rAttr)
2070 {
2071 	const Rectangle& rSnap=GetSnapRect();
2072 	const Rectangle& rLogic=GetLogicRect();
2073 	Point aRef1(rSnap.Center());
2074 	Point aRef2(aRef1); aRef2.Y()++;
2075 	const SfxPoolItem *pPoolItem=NULL;
2076 	if (rAttr.GetItemState(SDRATTR_TRANSFORMREF1X,sal_True,&pPoolItem)==SFX_ITEM_SET) {
2077 		aRef1.X()=((const SdrTransformRef1XItem*)pPoolItem)->GetValue();
2078 	}
2079 	if (rAttr.GetItemState(SDRATTR_TRANSFORMREF1Y,sal_True,&pPoolItem)==SFX_ITEM_SET) {
2080 		aRef1.Y()=((const SdrTransformRef1YItem*)pPoolItem)->GetValue();
2081 	}
2082 	if (rAttr.GetItemState(SDRATTR_TRANSFORMREF2X,sal_True,&pPoolItem)==SFX_ITEM_SET) {
2083 		aRef2.X()=((const SdrTransformRef2XItem*)pPoolItem)->GetValue();
2084 	}
2085 	if (rAttr.GetItemState(SDRATTR_TRANSFORMREF2Y,sal_True,&pPoolItem)==SFX_ITEM_SET) {
2086 		aRef2.Y()=((const SdrTransformRef2YItem*)pPoolItem)->GetValue();
2087 	}
2088 
2089 	Rectangle aNewSnap(rSnap);
2090 	if (rAttr.GetItemState(SDRATTR_MOVEX,sal_True,&pPoolItem)==SFX_ITEM_SET) {
2091 		long n=((const SdrMoveXItem*)pPoolItem)->GetValue();
2092 		aNewSnap.Move(n,0);
2093 	}
2094 	if (rAttr.GetItemState(SDRATTR_MOVEY,sal_True,&pPoolItem)==SFX_ITEM_SET) {
2095 		long n=((const SdrMoveYItem*)pPoolItem)->GetValue();
2096 		aNewSnap.Move(0,n);
2097 	}
2098 	if (rAttr.GetItemState(SDRATTR_ONEPOSITIONX,sal_True,&pPoolItem)==SFX_ITEM_SET) {
2099 		long n=((const SdrOnePositionXItem*)pPoolItem)->GetValue();
2100 		aNewSnap.Move(n-aNewSnap.Left(),0);
2101 	}
2102 	if (rAttr.GetItemState(SDRATTR_ONEPOSITIONY,sal_True,&pPoolItem)==SFX_ITEM_SET) {
2103 		long n=((const SdrOnePositionYItem*)pPoolItem)->GetValue();
2104 		aNewSnap.Move(0,n-aNewSnap.Top());
2105 	}
2106 	if (rAttr.GetItemState(SDRATTR_ONESIZEWIDTH,sal_True,&pPoolItem)==SFX_ITEM_SET) {
2107 		long n=((const SdrOneSizeWidthItem*)pPoolItem)->GetValue();
2108 		aNewSnap.Right()=aNewSnap.Left()+n;
2109 	}
2110 	if (rAttr.GetItemState(SDRATTR_ONESIZEHEIGHT,sal_True,&pPoolItem)==SFX_ITEM_SET) {
2111 		long n=((const SdrOneSizeHeightItem*)pPoolItem)->GetValue();
2112 		aNewSnap.Bottom()=aNewSnap.Top()+n;
2113 	}
2114 	if (aNewSnap!=rSnap) {
2115 		if (aNewSnap.GetSize()==rSnap.GetSize()) {
2116 			NbcMove(Size(aNewSnap.Left()-rSnap.Left(),aNewSnap.Top()-rSnap.Top()));
2117 		} else {
2118 			NbcSetSnapRect(aNewSnap);
2119 		}
2120 	}
2121 
2122 	if (rAttr.GetItemState(SDRATTR_SHEARANGLE,sal_True,&pPoolItem)==SFX_ITEM_SET) {
2123 		long n=((const SdrShearAngleItem*)pPoolItem)->GetValue();
2124 		n-=GetShearAngle();
2125 		if (n!=0) {
2126 			double nTan=tan(n*nPi180);
2127 			NbcShear(aRef1,n,nTan,sal_False);
2128 		}
2129 	}
2130 	if (rAttr.GetItemState(SDRATTR_ROTATEANGLE,sal_True,&pPoolItem)==SFX_ITEM_SET) {
2131 		long n=((const SdrRotateAngleItem*)pPoolItem)->GetValue();
2132 		n-=GetRotateAngle();
2133 		if (n!=0) {
2134 			double nSin=sin(n*nPi180);
2135 			double nCos=cos(n*nPi180);
2136 			NbcRotate(aRef1,n,nSin,nCos);
2137 		}
2138 	}
2139 	if (rAttr.GetItemState(SDRATTR_ROTATEONE,sal_True,&pPoolItem)==SFX_ITEM_SET) {
2140 		long n=((const SdrRotateOneItem*)pPoolItem)->GetValue();
2141 		double nSin=sin(n*nPi180);
2142 		double nCos=cos(n*nPi180);
2143 		NbcRotate(aRef1,n,nSin,nCos);
2144 	}
2145 	if (rAttr.GetItemState(SDRATTR_HORZSHEARONE,sal_True,&pPoolItem)==SFX_ITEM_SET) {
2146 		long n=((const SdrHorzShearOneItem*)pPoolItem)->GetValue();
2147 		double nTan=tan(n*nPi180);
2148 		NbcShear(aRef1,n,nTan,sal_False);
2149 	}
2150 	if (rAttr.GetItemState(SDRATTR_VERTSHEARONE,sal_True,&pPoolItem)==SFX_ITEM_SET) {
2151 		long n=((const SdrVertShearOneItem*)pPoolItem)->GetValue();
2152 		double nTan=tan(n*nPi180);
2153 		NbcShear(aRef1,n,nTan,sal_True);
2154 	}
2155 
2156 	if (rAttr.GetItemState(SDRATTR_OBJMOVEPROTECT,sal_True,&pPoolItem)==SFX_ITEM_SET) {
2157 		bool b=((const SdrObjMoveProtectItem*)pPoolItem)->GetValue();
2158 		SetMoveProtect(b);
2159 	}
2160 	if (rAttr.GetItemState(SDRATTR_OBJSIZEPROTECT,sal_True,&pPoolItem)==SFX_ITEM_SET) {
2161 		bool b=((const SdrObjSizeProtectItem*)pPoolItem)->GetValue();
2162 		SetResizeProtect(b);
2163 	}
2164 
2165 	/* #67368# move protect always sets size protect */
2166 	if( IsMoveProtect() )
2167 		SetResizeProtect( true );
2168 
2169 	if (rAttr.GetItemState(SDRATTR_OBJPRINTABLE,sal_True,&pPoolItem)==SFX_ITEM_SET) {
2170 		bool b=((const SdrObjPrintableItem*)pPoolItem)->GetValue();
2171 		SetPrintable(b);
2172 	}
2173 
2174 	if (rAttr.GetItemState(SDRATTR_OBJVISIBLE,sal_True,&pPoolItem)==SFX_ITEM_SET) {
2175 		bool b=((const SdrObjVisibleItem*)pPoolItem)->GetValue();
2176 		SetVisible(b);
2177 	}
2178 
2179 	SdrLayerID nLayer=SDRLAYER_NOTFOUND;
2180 	if (rAttr.GetItemState(SDRATTR_LAYERID,sal_True,&pPoolItem)==SFX_ITEM_SET) {
2181 		nLayer=((const SdrLayerIdItem*)pPoolItem)->GetValue();
2182 	}
2183 	if (rAttr.GetItemState(SDRATTR_LAYERNAME,sal_True,&pPoolItem)==SFX_ITEM_SET && pModel!=NULL) {
2184 		XubString aLayerName=((const SdrLayerNameItem*)pPoolItem)->GetValue();
2185 		const SdrLayerAdmin* pLayAd=pPage!=NULL ? &pPage->GetLayerAdmin() : pModel!=NULL ? &pModel->GetLayerAdmin() : NULL;
2186 		if (pLayAd!=NULL) {
2187 			const SdrLayer* pLayer=pLayAd->GetLayer(aLayerName, sal_True);
2188 			if (pLayer!=NULL) {
2189 				nLayer=pLayer->GetID();
2190 			}
2191 		}
2192 
2193 	}
2194 	if (nLayer!=SDRLAYER_NOTFOUND) {
2195 		NbcSetLayer(nLayer);
2196 	}
2197 
2198 	if (rAttr.GetItemState(SDRATTR_OBJECTNAME,sal_True,&pPoolItem)==SFX_ITEM_SET) {
2199 		XubString aName=((const SdrObjectNameItem*)pPoolItem)->GetValue();
2200 		SetName(aName);
2201 	}
2202 	Rectangle aNewLogic(rLogic);
2203 	if (rAttr.GetItemState(SDRATTR_LOGICSIZEWIDTH,sal_True,&pPoolItem)==SFX_ITEM_SET) {
2204 		long n=((const SdrLogicSizeWidthItem*)pPoolItem)->GetValue();
2205 		aNewLogic.Right()=aNewLogic.Left()+n;
2206 	}
2207 	if (rAttr.GetItemState(SDRATTR_LOGICSIZEHEIGHT,sal_True,&pPoolItem)==SFX_ITEM_SET) {
2208 		long n=((const SdrLogicSizeHeightItem*)pPoolItem)->GetValue();
2209 		aNewLogic.Bottom()=aNewLogic.Top()+n;
2210 	}
2211 	if (aNewLogic!=rLogic) {
2212 		NbcSetLogicRect(aNewLogic);
2213 	}
2214 	Fraction aResizeX(1,1);
2215 	Fraction aResizeY(1,1);
2216 	if (rAttr.GetItemState(SDRATTR_RESIZEXONE,sal_True,&pPoolItem)==SFX_ITEM_SET) {
2217 		aResizeX*=((const SdrResizeXOneItem*)pPoolItem)->GetValue();
2218 	}
2219 	if (rAttr.GetItemState(SDRATTR_RESIZEYONE,sal_True,&pPoolItem)==SFX_ITEM_SET) {
2220 		aResizeY*=((const SdrResizeYOneItem*)pPoolItem)->GetValue();
2221 	}
2222 	if (aResizeX!=Fraction(1,1) || aResizeY!=Fraction(1,1)) {
2223 		NbcResize(aRef1,aResizeX,aResizeY);
2224 	}
2225 }
2226 
lcl_SetItem(SfxItemSet & rAttr,FASTBOOL bMerge,const SfxPoolItem & rItem)2227 void lcl_SetItem(SfxItemSet& rAttr, FASTBOOL bMerge, const SfxPoolItem& rItem)
2228 {
2229 	if (bMerge) rAttr.MergeValue(rItem,sal_True);
2230 	else rAttr.Put(rItem);
2231 }
2232 
TakeNotPersistAttr(SfxItemSet & rAttr,FASTBOOL bMerge) const2233 void SdrObject::TakeNotPersistAttr(SfxItemSet& rAttr, FASTBOOL bMerge) const
2234 {
2235 	const Rectangle& rSnap=GetSnapRect();
2236 	const Rectangle& rLogic=GetLogicRect();
2237 	lcl_SetItem(rAttr,bMerge,SdrObjMoveProtectItem(IsMoveProtect()));
2238 	lcl_SetItem(rAttr,bMerge,SdrObjSizeProtectItem(IsResizeProtect()));
2239 	lcl_SetItem(rAttr,bMerge,SdrObjPrintableItem(IsPrintable()));
2240 	lcl_SetItem(rAttr,bMerge,SdrObjVisibleItem(IsVisible()));
2241 	lcl_SetItem(rAttr,bMerge,SdrRotateAngleItem(GetRotateAngle()));
2242 	lcl_SetItem(rAttr,bMerge,SdrShearAngleItem(GetShearAngle()));
2243 	lcl_SetItem(rAttr,bMerge,SdrOneSizeWidthItem(rSnap.GetWidth()-1));
2244 	lcl_SetItem(rAttr,bMerge,SdrOneSizeHeightItem(rSnap.GetHeight()-1));
2245 	lcl_SetItem(rAttr,bMerge,SdrOnePositionXItem(rSnap.Left()));
2246 	lcl_SetItem(rAttr,bMerge,SdrOnePositionYItem(rSnap.Top()));
2247 	if (rLogic.GetWidth()!=rSnap.GetWidth()) {
2248 		lcl_SetItem(rAttr,bMerge,SdrLogicSizeWidthItem(rLogic.GetWidth()-1));
2249 	}
2250 	if (rLogic.GetHeight()!=rSnap.GetHeight()) {
2251 		lcl_SetItem(rAttr,bMerge,SdrLogicSizeHeightItem(rLogic.GetHeight()-1));
2252 	}
2253 	XubString aName(GetName());
2254 
2255 	if(aName.Len())
2256 	{
2257 		lcl_SetItem(rAttr, bMerge, SdrObjectNameItem(aName));
2258 	}
2259 
2260 	lcl_SetItem(rAttr,bMerge,SdrLayerIdItem(GetLayer()));
2261 	const SdrLayerAdmin* pLayAd=pPage!=NULL ? &pPage->GetLayerAdmin() : pModel!=NULL ? &pModel->GetLayerAdmin() : NULL;
2262 	if (pLayAd!=NULL) {
2263 		const SdrLayer* pLayer=pLayAd->GetLayerPerID(GetLayer());
2264 		if (pLayer!=NULL) {
2265 			lcl_SetItem(rAttr,bMerge,SdrLayerNameItem(pLayer->GetName()));
2266 		}
2267 	}
2268 	Point aRef1(rSnap.Center());
2269 	Point aRef2(aRef1); aRef2.Y()++;
2270 	lcl_SetItem(rAttr,bMerge,SdrTransformRef1XItem(aRef1.X()));
2271 	lcl_SetItem(rAttr,bMerge,SdrTransformRef1YItem(aRef1.Y()));
2272 	lcl_SetItem(rAttr,bMerge,SdrTransformRef2XItem(aRef2.X()));
2273 	lcl_SetItem(rAttr,bMerge,SdrTransformRef2YItem(aRef2.Y()));
2274 }
2275 
GetStyleSheet() const2276 SfxStyleSheet* SdrObject::GetStyleSheet() const
2277 {
2278 	return GetProperties().GetStyleSheet();
2279 }
2280 
SetStyleSheet(SfxStyleSheet * pNewStyleSheet,sal_Bool bDontRemoveHardAttr)2281 void SdrObject::SetStyleSheet(SfxStyleSheet* pNewStyleSheet, sal_Bool bDontRemoveHardAttr)
2282 {
2283 	Rectangle aBoundRect0;
2284 
2285 	if(pUserCall)
2286 		aBoundRect0 = GetLastBoundRect();
2287 
2288 	// #110094#-14 SendRepaintBroadcast();
2289 	NbcSetStyleSheet(pNewStyleSheet, bDontRemoveHardAttr);
2290 	SetChanged();
2291 	BroadcastObjectChange();
2292 	SendUserCall(SDRUSERCALL_CHGATTR, aBoundRect0);
2293 }
2294 
NbcSetStyleSheet(SfxStyleSheet * pNewStyleSheet,sal_Bool bDontRemoveHardAttr)2295 void SdrObject::NbcSetStyleSheet(SfxStyleSheet* pNewStyleSheet, sal_Bool bDontRemoveHardAttr)
2296 {
2297 	// only allow graphic and presentation styles for shapes
2298 	if( pNewStyleSheet && (pNewStyleSheet->GetFamily() == SFX_STYLE_FAMILY_PARA) && (pNewStyleSheet->GetFamily() == SFX_STYLE_FAMILY_PAGE) )
2299 		return;
2300 
2301 	GetProperties().SetStyleSheet(pNewStyleSheet, bDontRemoveHardAttr);
2302 }
2303 
2304 // Das Broadcasting beim Setzen der Attribute wird vom AttrObj gemanagt
2305 ////////////////////////////////////////////////////////////////////////////////////////////////////
2306 
IsNode() const2307 FASTBOOL SdrObject::IsNode() const
2308 {
2309 	return sal_True;
2310 }
2311 
GetVertexGluePoint(sal_uInt16 nPosNum) const2312 SdrGluePoint SdrObject::GetVertexGluePoint(sal_uInt16 nPosNum) const
2313 {
2314 	// #i41936# Use SnapRect for default GluePoints
2315 	const Rectangle aR(GetSnapRect());
2316 	Point aPt;
2317 
2318 	switch(nPosNum)
2319 	{
2320 		case 0 : aPt = aR.TopCenter();    break;
2321 		case 1 : aPt = aR.RightCenter();  break;
2322 		case 2 : aPt = aR.BottomCenter(); break;
2323 		case 3 : aPt = aR.LeftCenter();   break;
2324 	}
2325 
2326 	aPt -= aR.Center();
2327 	SdrGluePoint aGP(aPt);
2328 	aGP.SetPercent(sal_False);
2329 
2330 	return aGP;
2331 }
2332 
GetCornerGluePoint(sal_uInt16 nPosNum) const2333 SdrGluePoint SdrObject::GetCornerGluePoint(sal_uInt16 nPosNum) const
2334 {
2335 	Rectangle aR(GetCurrentBoundRect());
2336 	Point aPt;
2337 	switch (nPosNum) {
2338 		case 0 : aPt=aR.TopLeft();     break;
2339 		case 1 : aPt=aR.TopRight();    break;
2340 		case 2 : aPt=aR.BottomRight(); break;
2341 		case 3 : aPt=aR.BottomLeft();  break;
2342 	}
2343 	aPt-=GetSnapRect().Center();
2344 	SdrGluePoint aGP(aPt);
2345 	aGP.SetPercent(sal_False);
2346 	return aGP;
2347 }
2348 
GetGluePointList() const2349 const SdrGluePointList* SdrObject::GetGluePointList() const
2350 {
2351 	if (pPlusData!=NULL) return pPlusData->pGluePoints;
2352 	return NULL;
2353 }
2354 
2355 //SdrGluePointList* SdrObject::GetGluePointList()
2356 //{
2357 //	if (pPlusData!=NULL) return pPlusData->pGluePoints;
2358 //	return NULL;
2359 //}
2360 
ForceGluePointList()2361 SdrGluePointList* SdrObject::ForceGluePointList()
2362 {
2363 	ImpForcePlusData();
2364 	if (pPlusData->pGluePoints==NULL) {
2365 		pPlusData->pGluePoints=new SdrGluePointList;
2366 	}
2367 	return pPlusData->pGluePoints;
2368 }
2369 
SetGlueReallyAbsolute(FASTBOOL bOn)2370 void SdrObject::SetGlueReallyAbsolute(FASTBOOL bOn)
2371 {
2372 	// erst Const-Aufruf um zu sehen, ob
2373 	// ueberhaupt Klebepunkte da sind
2374 	// const-Aufruf erzwingen!
2375 	if (GetGluePointList()!=NULL) {
2376 		SdrGluePointList* pGPL=ForceGluePointList();
2377 		pGPL->SetReallyAbsolute(bOn,*this);
2378 	}
2379 }
2380 
NbcRotateGluePoints(const Point & rRef,long nWink,double sn,double cs)2381 void SdrObject::NbcRotateGluePoints(const Point& rRef, long nWink, double sn, double cs)
2382 {
2383 	// erst Const-Aufruf um zu sehen, ob
2384 	// ueberhaupt Klebepunkte da sind
2385 	// const-Aufruf erzwingen!
2386 	if (GetGluePointList()!=NULL) {
2387 		SdrGluePointList* pGPL=ForceGluePointList();
2388 		pGPL->Rotate(rRef,nWink,sn,cs,this);
2389 	}
2390 }
2391 
NbcMirrorGluePoints(const Point & rRef1,const Point & rRef2)2392 void SdrObject::NbcMirrorGluePoints(const Point& rRef1, const Point& rRef2)
2393 {
2394 	// erst Const-Aufruf um zu sehen, ob
2395 	// ueberhaupt Klebepunkte da sind
2396 	// const-Aufruf erzwingen!
2397 	if (GetGluePointList()!=NULL) {
2398 		SdrGluePointList* pGPL=ForceGluePointList();
2399 		pGPL->Mirror(rRef1,rRef2,this);
2400 	}
2401 }
2402 
NbcShearGluePoints(const Point & rRef,long nWink,double tn,FASTBOOL bVShear)2403 void SdrObject::NbcShearGluePoints(const Point& rRef, long nWink, double tn, FASTBOOL bVShear)
2404 {
2405 	// erst Const-Aufruf um zu sehen, ob
2406 	// ueberhaupt Klebepunkte da sind
2407 	// const-Aufruf erzwingen!
2408 	if (GetGluePointList()!=NULL) {
2409 		SdrGluePointList* pGPL=ForceGluePointList();
2410 		pGPL->Shear(rRef,nWink,tn,bVShear,this);
2411 	}
2412 }
2413 
IsEdge() const2414 FASTBOOL SdrObject::IsEdge() const
2415 {
2416 	return sal_False;
2417 }
2418 
ConnectToNode(FASTBOOL,SdrObject *)2419 void SdrObject::ConnectToNode(FASTBOOL /*bTail1*/, SdrObject* /*pObj*/)
2420 {
2421 }
2422 
DisconnectFromNode(FASTBOOL)2423 void SdrObject::DisconnectFromNode(FASTBOOL /*bTail1*/)
2424 {
2425 }
2426 
GetConnectedNode(FASTBOOL) const2427 SdrObject* SdrObject::GetConnectedNode(FASTBOOL /*bTail1*/) const
2428 {
2429 	return NULL;
2430 }
2431 
2432 ////////////////////////////////////////////////////////////////////////////////////////////////////
2433 
extractLineContourFromPrimitive2DSequence(const drawinglayer::primitive2d::Primitive2DSequence & rxSequence,basegfx::B2DPolygonVector & rExtractedHairlines,basegfx::B2DPolyPolygonVector & rExtractedLineFills)2434 void extractLineContourFromPrimitive2DSequence(
2435     const drawinglayer::primitive2d::Primitive2DSequence& rxSequence,
2436     basegfx::B2DPolygonVector& rExtractedHairlines,
2437     basegfx::B2DPolyPolygonVector& rExtractedLineFills)
2438 {
2439     rExtractedHairlines.clear();
2440     rExtractedLineFills.clear();
2441 
2442     if(rxSequence.hasElements())
2443     {
2444         // use neutral ViewInformation
2445         const drawinglayer::geometry::ViewInformation2D aViewInformation2D;
2446 
2447         // create extractor, process and get result
2448         drawinglayer::processor2d::LineGeometryExtractor2D aExtractor(aViewInformation2D);
2449         aExtractor.process(rxSequence);
2450 
2451         // copy line results
2452         rExtractedHairlines = aExtractor.getExtractedHairlines();
2453 
2454         // copy fill rsults
2455         rExtractedLineFills = aExtractor.getExtractedLineFills();
2456     }
2457 }
2458 
2459 ////////////////////////////////////////////////////////////////////////////////////////////////////
2460 
ImpConvertToContourObj(SdrObject * pRet,sal_Bool bForceLineDash) const2461 SdrObject* SdrObject::ImpConvertToContourObj(SdrObject* pRet, sal_Bool bForceLineDash) const
2462 {
2463 	bool bNoChange(true);
2464 
2465 	if(pRet->LineGeometryUsageIsNecessary())
2466 	{
2467 		basegfx::B2DPolyPolygon aMergedLineFillPolyPolygon;
2468 		basegfx::B2DPolyPolygon aMergedHairlinePolyPolygon;
2469 		const drawinglayer::primitive2d::Primitive2DSequence xSequence(pRet->GetViewContact().getViewIndependentPrimitive2DSequence());
2470 
2471 		if(xSequence.hasElements())
2472 		{
2473             basegfx::B2DPolygonVector aExtractedHairlines;
2474             basegfx::B2DPolyPolygonVector aExtractedLineFills;
2475 
2476             extractLineContourFromPrimitive2DSequence(xSequence, aExtractedHairlines, aExtractedLineFills);
2477 
2478 			if(!aExtractedHairlines.empty())
2479 			{
2480 				// for SdrObject creation, just copy all to a single Hairline-PolyPolygon
2481 				for(sal_uInt32 a(0); a < aExtractedHairlines.size(); a++)
2482 				{
2483 					aMergedHairlinePolyPolygon.append(aExtractedHairlines[a]);
2484 				}
2485 			}
2486 
2487 			// check for fill rsults
2488 			if(!aExtractedLineFills.empty())
2489 			{
2490 				// merge to a single PolyPolygon (OR)
2491 				aMergedLineFillPolyPolygon = basegfx::tools::mergeToSinglePolyPolygon(aExtractedLineFills);
2492 			}
2493 		}
2494 
2495 		if(aMergedLineFillPolyPolygon.count() || (bForceLineDash && aMergedHairlinePolyPolygon.count()))
2496 		{
2497 			SfxItemSet aSet(pRet->GetMergedItemSet());
2498 			XFillStyle eOldFillStyle = ((const XFillStyleItem&)(aSet.Get(XATTR_FILLSTYLE))).GetValue();
2499 			SdrPathObj* aLinePolygonPart = NULL;
2500 			SdrPathObj* aLineHairlinePart = NULL;
2501 			bool bBuildGroup(false);
2502 
2503 			if(aMergedLineFillPolyPolygon.count())
2504 			{
2505                 // create SdrObject for filled line geometry
2506 				aLinePolygonPart = new SdrPathObj(OBJ_PATHFILL, aMergedLineFillPolyPolygon);
2507 				aLinePolygonPart->SetModel(pRet->GetModel());
2508 
2509                 // correct item properties
2510 				aSet.Put(XLineWidthItem(0L));
2511 				aSet.Put(XLineStyleItem(XLINE_NONE));
2512 				Color aColorLine = ((const XLineColorItem&)(aSet.Get(XATTR_LINECOLOR))).GetColorValue();
2513 				sal_uInt16 nTransLine = ((const XLineTransparenceItem&)(aSet.Get(XATTR_LINETRANSPARENCE))).GetValue();
2514 				aSet.Put(XFillColorItem(XubString(), aColorLine));
2515 				aSet.Put(XFillStyleItem(XFILL_SOLID));
2516 				aSet.Put(XFillTransparenceItem(nTransLine));
2517 
2518 				aLinePolygonPart->SetMergedItemSet(aSet);
2519 			}
2520 
2521 			if(aMergedHairlinePolyPolygon.count())
2522 			{
2523                 // create SdrObject for hairline geometry
2524 				// OBJ_PATHLINE is necessary here, not OBJ_PATHFILL. This is intended
2525 				// to get a non-filled object. If the poly is closed, the PathObj takes care for
2526 				// the correct closed state.
2527 				aLineHairlinePart = new SdrPathObj(OBJ_PATHLINE, aMergedHairlinePolyPolygon);
2528 				aLineHairlinePart->SetModel(pRet->GetModel());
2529 
2530 				aSet.Put(XLineWidthItem(0L));
2531 				aSet.Put(XFillStyleItem(XFILL_NONE));
2532 				aSet.Put(XLineStyleItem(XLINE_SOLID));
2533 
2534 				// it is also necessary to switch off line start and ends here
2535 				aSet.Put(XLineStartWidthItem(0));
2536 				aSet.Put(XLineEndWidthItem(0));
2537 
2538 				aLineHairlinePart->SetMergedItemSet(aSet);
2539 
2540 				if(aLinePolygonPart)
2541                 {
2542 					bBuildGroup = true;
2543                 }
2544 			}
2545 
2546 			// check if original geometry should be added (e.g. filled and closed)
2547 			bool bAddOriginalGeometry(false);
2548 			SdrPathObj* pPath = PTR_CAST(SdrPathObj, pRet);
2549 
2550             if(pPath && pPath->IsClosed())
2551 			{
2552 				if(eOldFillStyle != XFILL_NONE)
2553 				{
2554 					// #107600# use new boolean here
2555 					bAddOriginalGeometry = true;
2556 				}
2557 			}
2558 
2559 			// do we need a group?
2560 			if(bBuildGroup || bAddOriginalGeometry)
2561 			{
2562 				SdrObject* pGroup = new SdrObjGroup;
2563 				pGroup->SetModel(pRet->GetModel());
2564 
2565 				if(bAddOriginalGeometry)
2566 				{
2567 					// Add a clone of the original geometry.
2568 					aSet.ClearItem();
2569 					aSet.Put(pRet->GetMergedItemSet());
2570 					aSet.Put(XLineStyleItem(XLINE_NONE));
2571 					aSet.Put(XLineWidthItem(0L));
2572 
2573 					SdrObject* pClone = pRet->Clone();
2574 
2575 					pClone->SetModel(pRet->GetModel());
2576 					pClone->SetMergedItemSet(aSet);
2577 
2578 					pGroup->GetSubList()->NbcInsertObject(pClone);
2579 				}
2580 
2581 				if(aLinePolygonPart)
2582 				{
2583 					pGroup->GetSubList()->NbcInsertObject(aLinePolygonPart);
2584 				}
2585 
2586 				if(aLineHairlinePart)
2587 				{
2588 					pGroup->GetSubList()->NbcInsertObject(aLineHairlinePart);
2589 				}
2590 
2591 				pRet = pGroup;
2592 
2593 				// be more careful with the state describing bool
2594 				bNoChange = false;
2595 			}
2596 			else
2597 			{
2598 				if(aLinePolygonPart)
2599 				{
2600 					pRet = aLinePolygonPart;
2601 					// be more careful with the state describing bool
2602 					bNoChange = false;
2603 				}
2604 				else if(aLineHairlinePart)
2605 				{
2606 					pRet = aLineHairlinePart;
2607 					// be more careful with the state describing bool
2608 					bNoChange = false;
2609 				}
2610 			}
2611 		}
2612 	}
2613 
2614 	if(bNoChange)
2615 	{
2616         // due to current method usage, create and return a clone when nothing has changed
2617 		SdrObject* pClone = pRet->Clone();
2618 		pClone->SetModel(pRet->GetModel());
2619 		pRet = pClone;
2620 	}
2621 
2622 	return pRet;
2623 }
2624 
2625 // convert this path object to contour object, even when it is a group
ConvertToContourObj(SdrObject * pRet,sal_Bool bForceLineDash) const2626 SdrObject* SdrObject::ConvertToContourObj(SdrObject* pRet, sal_Bool bForceLineDash) const
2627 {
2628 	if(pRet->ISA(SdrObjGroup))
2629 	{
2630 		SdrObjList* pObjList2 = pRet->GetSubList();
2631 		SdrObject* pGroup = new SdrObjGroup;
2632 		pGroup->SetModel(pRet->GetModel());
2633 
2634 		for(sal_uInt32 a=0;a<pObjList2->GetObjCount();a++)
2635 		{
2636 			SdrObject* pIterObj = pObjList2->GetObj(a);
2637 			pGroup->GetSubList()->NbcInsertObject(ConvertToContourObj(pIterObj, bForceLineDash));
2638 		}
2639 
2640 		pRet = pGroup;
2641 	}
2642 	else
2643 	{
2644         if(pRet && pRet->ISA(SdrPathObj))
2645         {
2646             SdrPathObj* pPathObj = (SdrPathObj*)pRet;
2647 
2648             // bezier geometry got created, even for straight edges since the given
2649             // object is a result of DoConvertToPolyObj. For conversion to contour
2650             // this is not really needed and can be reduced again AFAP
2651             pPathObj->SetPathPoly(basegfx::tools::simplifyCurveSegments(pPathObj->GetPathPoly()));
2652         }
2653 
2654 		pRet = ImpConvertToContourObj(pRet, bForceLineDash);
2655 	}
2656 
2657 	// #i73441# preserve LayerID
2658 	if(pRet && pRet->GetLayer() != GetLayer())
2659 	{
2660 		pRet->SetLayer(GetLayer());
2661 	}
2662 
2663 	return pRet;
2664 }
2665 
2666 ////////////////////////////////////////////////////////////////////////////////////////////////////
2667 
ConvertToPolyObj(sal_Bool bBezier,sal_Bool bLineToArea) const2668 SdrObject* SdrObject::ConvertToPolyObj(sal_Bool bBezier, sal_Bool bLineToArea) const
2669 {
2670 	SdrObject* pRet = DoConvertToPolyObj(bBezier, true);
2671 
2672 	if(pRet && bLineToArea)
2673 	{
2674 		SdrObject* pNewRet = ConvertToContourObj(pRet);
2675 		delete pRet;
2676 		pRet = pNewRet;
2677 	}
2678 
2679 	// #i73441# preserve LayerID
2680 	if(pRet && pRet->GetLayer() != GetLayer())
2681 	{
2682 		pRet->SetLayer(GetLayer());
2683 	}
2684 
2685 	return pRet;
2686 }
2687 
2688 ////////////////////////////////////////////////////////////////////////////////////////////////////
2689 
DoConvertToPolyObj(sal_Bool,bool) const2690 SdrObject* SdrObject::DoConvertToPolyObj(sal_Bool /*bBezier*/, bool /*bAddText*/) const
2691 {
2692 	return NULL;
2693 }
2694 
2695 ////////////////////////////////////////////////////////////////////////////////////////////////////
2696 
SetInserted(sal_Bool bIns)2697 void SdrObject::SetInserted(sal_Bool bIns)
2698 {
2699 	if (bIns!=IsInserted()) {
2700 		bInserted=bIns;
2701 		Rectangle aBoundRect0(GetLastBoundRect());
2702 		if (bIns) SendUserCall(SDRUSERCALL_INSERTED,aBoundRect0);
2703 		else SendUserCall(SDRUSERCALL_REMOVED,aBoundRect0);
2704 
2705 		if (pPlusData!=NULL && pPlusData->pBroadcast!=NULL) { // #42522#
2706 			SdrHint aHint(*this);
2707 			aHint.SetKind(bIns?HINT_OBJINSERTED:HINT_OBJREMOVED);
2708 			pPlusData->pBroadcast->Broadcast(aHint);
2709 		}
2710 	}
2711 }
2712 
SetMoveProtect(sal_Bool bProt)2713 void SdrObject::SetMoveProtect(sal_Bool bProt)
2714 {
2715 	if(IsMoveProtect() != bProt)
2716 	{
2717 		// #i77187# secured and simplified
2718 		bMovProt = bProt;
2719 		SetChanged();
2720 		BroadcastObjectChange();
2721 	}
2722 }
2723 
SetResizeProtect(sal_Bool bProt)2724 void SdrObject::SetResizeProtect(sal_Bool bProt)
2725 {
2726 	if(IsResizeProtect() != bProt)
2727 	{
2728 		// #i77187# secured and simplified
2729 		bSizProt = bProt;
2730 		SetChanged();
2731 		BroadcastObjectChange();
2732 	}
2733 }
2734 
SetPrintable(sal_Bool bPrn)2735 void SdrObject::SetPrintable(sal_Bool bPrn)
2736 {
2737 	if( bPrn == bNoPrint )
2738 	{
2739 		bNoPrint=!bPrn;
2740 		SetChanged();
2741 		if (IsInserted() && pModel!=NULL)
2742 		{
2743 			SdrHint aHint(*this);
2744 			pModel->Broadcast(aHint);
2745 		}
2746 	}
2747 }
2748 
SetVisible(sal_Bool bVisible)2749 void SdrObject::SetVisible(sal_Bool bVisible)
2750 {
2751 	if( bVisible != mbVisible )
2752 	{
2753 		mbVisible = bVisible;
2754 		SetChanged();
2755 		if (IsInserted() && pModel!=NULL)
2756 		{
2757 			SdrHint aHint(*this);
2758 			pModel->Broadcast(aHint);
2759 		}
2760 	}
2761 }
2762 
2763 ////////////////////////////////////////////////////////////////////////////////////////////////////
2764 
GetUserDataCount() const2765 sal_uInt16 SdrObject::GetUserDataCount() const
2766 {
2767 	if (pPlusData==NULL || pPlusData->pUserDataList==NULL) return 0;
2768 	return pPlusData->pUserDataList->GetUserDataCount();
2769 }
2770 
GetUserData(sal_uInt16 nNum) const2771 SdrObjUserData* SdrObject::GetUserData(sal_uInt16 nNum) const
2772 {
2773 	if (pPlusData==NULL || pPlusData->pUserDataList==NULL) return NULL;
2774 	return pPlusData->pUserDataList->GetUserData(nNum);
2775 }
2776 
InsertUserData(SdrObjUserData * pData,sal_uInt16 nPos)2777 void SdrObject::InsertUserData(SdrObjUserData* pData, sal_uInt16 nPos)
2778 {
2779 	if (pData!=NULL) {
2780 		ImpForcePlusData();
2781 		if (pPlusData->pUserDataList==NULL) pPlusData->pUserDataList=new SdrObjUserDataList;
2782 		pPlusData->pUserDataList->InsertUserData(pData,nPos);
2783 	} else {
2784 		DBG_ERROR("SdrObject::InsertUserData(): pData ist NULL-Pointer");
2785 	}
2786 }
2787 
DeleteUserData(sal_uInt16 nNum)2788 void SdrObject::DeleteUserData(sal_uInt16 nNum)
2789 {
2790 	sal_uInt16 nAnz=GetUserDataCount();
2791 	if (nNum<nAnz) {
2792 		pPlusData->pUserDataList->DeleteUserData(nNum);
2793 		if (nAnz==1)  {
2794 			delete pPlusData->pUserDataList;
2795 			pPlusData->pUserDataList=NULL;
2796 		}
2797 	} else {
2798 		DBG_ERROR("SdrObject::DeleteUserData(): ungueltiger Index");
2799 	}
2800 }
2801 
SendUserCall(SdrUserCallType eUserCall,const Rectangle & rBoundRect) const2802 void SdrObject::SendUserCall(SdrUserCallType eUserCall, const Rectangle& rBoundRect) const
2803 {
2804 	SdrObjGroup* pGroup = NULL;
2805 
2806 	if( pObjList && pObjList->GetListKind() == SDROBJLIST_GROUPOBJ )
2807 		pGroup = (SdrObjGroup*) pObjList->GetOwnerObj();
2808 
2809 	if ( pUserCall )
2810 	{
2811 		// UserCall ausfuehren
2812 		pUserCall->Changed( *this, eUserCall, rBoundRect );
2813 	}
2814 
2815 	while( pGroup )
2816 	{
2817 		// Gruppe benachrichtigen
2818 		if( pGroup->GetUserCall() )
2819 		{
2820 			SdrUserCallType eChildUserType = SDRUSERCALL_CHILD_CHGATTR;
2821 
2822 			switch( eUserCall )
2823 			{
2824 				case SDRUSERCALL_MOVEONLY:
2825 					eChildUserType = SDRUSERCALL_CHILD_MOVEONLY;
2826 				break;
2827 
2828 				case SDRUSERCALL_RESIZE:
2829 					eChildUserType = SDRUSERCALL_CHILD_RESIZE;
2830 				break;
2831 
2832 				case SDRUSERCALL_CHGATTR:
2833 					eChildUserType = SDRUSERCALL_CHILD_CHGATTR;
2834 				break;
2835 
2836 				case SDRUSERCALL_DELETE:
2837 					eChildUserType = SDRUSERCALL_CHILD_DELETE;
2838 				break;
2839 
2840 				case SDRUSERCALL_COPY:
2841 					eChildUserType = SDRUSERCALL_CHILD_COPY;
2842 				break;
2843 
2844 				case SDRUSERCALL_INSERTED:
2845 					eChildUserType = SDRUSERCALL_CHILD_INSERTED;
2846 				break;
2847 
2848 				case SDRUSERCALL_REMOVED:
2849 					eChildUserType = SDRUSERCALL_CHILD_REMOVED;
2850 				break;
2851 
2852 				default: break;
2853 			}
2854 
2855 			pGroup->GetUserCall()->Changed( *this, eChildUserType, rBoundRect );
2856 		}
2857 
2858 		if( pGroup->GetObjList()                                       &&
2859 			pGroup->GetObjList()->GetListKind() == SDROBJLIST_GROUPOBJ &&
2860 			pGroup != (SdrObjGroup*) pObjList->GetOwnerObj() )
2861 			pGroup = (SdrObjGroup*) pObjList->GetOwnerObj();
2862 		else
2863 			pGroup = NULL;
2864 	}
2865 
2866     // notify our UNO shape listeners
2867     switch ( eUserCall )
2868     {
2869     case SDRUSERCALL_RESIZE:
2870         notifyShapePropertyChange( ::svx::eShapeSize );
2871         // fall through - RESIZE might also imply a change of the position
2872     case SDRUSERCALL_MOVEONLY:
2873         notifyShapePropertyChange( ::svx::eShapePosition );
2874         break;
2875     default:
2876         // not interested in
2877         break;
2878     }
2879 }
2880 
2881 // ItemPool fuer dieses Objekt wechseln
MigrateItemPool(SfxItemPool * pSrcPool,SfxItemPool * pDestPool,SdrModel * pNewModel)2882 void SdrObject::MigrateItemPool(SfxItemPool* pSrcPool, SfxItemPool* pDestPool, SdrModel* pNewModel)
2883 {
2884 	if(pSrcPool && pDestPool && (pSrcPool != pDestPool))
2885 	{
2886 		GetProperties().MoveToItemPool(pSrcPool, pDestPool, pNewModel);
2887 	}
2888 }
2889 
IsTransparent(sal_Bool) const2890 sal_Bool SdrObject::IsTransparent( sal_Bool /*bCheckForAlphaChannel*/) const
2891 {
2892 	bool bRet = false;
2893 
2894 	if( IsGroupObject() )
2895 	{
2896 		SdrObjListIter aIter( *GetSubList(), IM_DEEPNOGROUPS );
2897 
2898 		for( SdrObject*	pO = aIter.Next(); pO && !bRet; pO = aIter.Next() )
2899 		{
2900 			const SfxItemSet& rAttr = pO->GetMergedItemSet();
2901 
2902 			if( ( ( (const XFillTransparenceItem&) rAttr.Get( XATTR_FILLTRANSPARENCE ) ).GetValue() ||
2903 				  ( (const XLineTransparenceItem&) rAttr.Get( XATTR_LINETRANSPARENCE ) ).GetValue()	) ||
2904 				( ( rAttr.GetItemState( XATTR_FILLFLOATTRANSPARENCE ) == SFX_ITEM_SET ) &&
2905 				  ( (const XFillFloatTransparenceItem&) rAttr.Get( XATTR_FILLFLOATTRANSPARENCE ) ).IsEnabled() ) )
2906 			{
2907 				bRet = sal_True;
2908 			}
2909 			else if( pO->ISA( SdrGrafObj ) )
2910 			{
2911 				SdrGrafObj* pGrafObj = (SdrGrafObj*) pO;
2912 				if( ( (const SdrGrafTransparenceItem&) rAttr.Get( SDRATTR_GRAFTRANSPARENCE ) ).GetValue() ||
2913                     ( pGrafObj->GetGraphicType() == GRAPHIC_BITMAP && pGrafObj->GetGraphic().GetBitmapEx().IsAlpha() ) )
2914 				{
2915 					bRet = sal_True;
2916 				}
2917 			}
2918 		}
2919 	}
2920 	else
2921 	{
2922 		const SfxItemSet& rAttr = GetMergedItemSet();
2923 
2924 		if( ( ( (const XFillTransparenceItem&) rAttr.Get( XATTR_FILLTRANSPARENCE ) ).GetValue() ||
2925 			  ( (const XLineTransparenceItem&) rAttr.Get( XATTR_LINETRANSPARENCE ) ).GetValue()	) ||
2926 			( ( rAttr.GetItemState( XATTR_FILLFLOATTRANSPARENCE ) == SFX_ITEM_SET ) &&
2927 			  ( (const XFillFloatTransparenceItem&) rAttr.Get( XATTR_FILLFLOATTRANSPARENCE ) ).IsEnabled() ) )
2928 		{
2929 			bRet = sal_True;
2930 		}
2931 		else if( ISA( SdrGrafObj ) )
2932 		{
2933 			SdrGrafObj* pGrafObj = (SdrGrafObj*) this;
2934 
2935 			// #i25616#
2936 			bRet = pGrafObj->IsObjectTransparent();
2937 		}
2938 	}
2939 
2940 	return bRet;
2941 }
2942 
impl_setUnoShape(const uno::Reference<uno::XInterface> & _rxUnoShape)2943 void SdrObject::impl_setUnoShape( const uno::Reference< uno::XInterface >& _rxUnoShape )
2944 {
2945 	maWeakUnoShape = _rxUnoShape;
2946 	mpSvxShape = SvxShape::getImplementation( _rxUnoShape );
2947 //    OSL_ENSURE( mpSvxShape || !_rxUnoShape.is(),
2948 //        "SdrObject::setUnoShape: not sure it's a good idea to have an XShape which is not implemented by SvxShape ..." );
2949 }
2950 
2951 /** only for internal use! */
getSvxShape()2952 SvxShape* SdrObject::getSvxShape()
2953 {
2954     DBG_TESTSOLARMUTEX();
2955         // retrieving the impl pointer and subsequently using it is not thread-safe, of course, so it needs to be
2956         // guarded by the SolarMutex
2957 
2958     uno::Reference< uno::XInterface > xShape( maWeakUnoShape );
2959 #if OSL_DEBUG_LEVE > 0
2960     OSL_ENSURE( !( !xShape.is() && mpSvxShape ),
2961         "SdrObject::getSvxShape: still having IMPL-Pointer to dead object!" );
2962 #endif
2963     //#113608#, make sure mpSvxShape is always synchronized with maWeakUnoShape
2964     if ( mpSvxShape && !xShape.is() )
2965         mpSvxShape = NULL;
2966 
2967 	return mpSvxShape;
2968 }
2969 
getUnoShape()2970 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SdrObject::getUnoShape()
2971 {
2972 	// try weak reference first
2973 	uno::Reference< uno::XInterface > xShape( getWeakUnoShape() );
2974 	if( !xShape.is() )
2975 	{
2976         OSL_ENSURE( mpSvxShape == NULL, "SdrObject::getUnoShape: XShape already dead, but still an IMPL pointer!" );
2977 		if ( pPage )
2978 		{
2979 			uno::Reference< uno::XInterface > xPage( pPage->getUnoPage() );
2980 			if( xPage.is() )
2981 			{
2982 				SvxDrawPage* pDrawPage = SvxDrawPage::getImplementation(xPage);
2983 				if( pDrawPage )
2984 				{
2985 					// create one
2986                     xShape = pDrawPage->_CreateShape( this );
2987                     impl_setUnoShape( xShape );
2988 				}
2989 			}
2990 		}
2991 		else
2992 		{
2993 			mpSvxShape = SvxDrawPage::CreateShapeByTypeAndInventor( GetObjIdentifier(), GetObjInventor(), this, NULL );
2994 			maWeakUnoShape = xShape = static_cast< ::cppu::OWeakObject* >( mpSvxShape );
2995 		}
2996 	}
2997 
2998 	return xShape;
2999 }
3000 
getShapePropertyChangeNotifier()3001 ::svx::PropertyChangeNotifier& SdrObject::getShapePropertyChangeNotifier()
3002 {
3003     DBG_TESTSOLARMUTEX();
3004 
3005     SvxShape* pSvxShape = getSvxShape();
3006     ENSURE_OR_THROW( pSvxShape, "no SvxShape, yet!" );
3007     return pSvxShape->getShapePropertyChangeNotifier();
3008 }
3009 
notifyShapePropertyChange(const::svx::ShapeProperty _eProperty) const3010 void SdrObject::notifyShapePropertyChange( const ::svx::ShapeProperty _eProperty ) const
3011 {
3012     DBG_TESTSOLARMUTEX();
3013 
3014     SvxShape* pSvxShape = const_cast< SdrObject* >( this )->getSvxShape();
3015     if ( pSvxShape )
3016         return pSvxShape->getShapePropertyChangeNotifier().notifyPropertyChange( _eProperty );
3017 }
3018 
3019 ////////////////////////////////////////////////////////////////////////////////////////////////////
3020 //
3021 // transformation interface for StarOfficeAPI. This implements support for
3022 // homogen 3x3 matrices containing the transformation of the SdrObject. At the
3023 // moment it contains a shearX, rotation and translation, but for setting all linear
3024 // transforms like Scale, ShearX, ShearY, Rotate and Translate are supported.
3025 //
3026 ////////////////////////////////////////////////////////////////////////////////////////////////////
3027 // gets base transformation and rectangle of object. If it's an SdrPathObj it fills the PolyPolygon
3028 // with the base geometry and returns TRUE. Otherwise it returns FALSE.
TRGetBaseGeometry(basegfx::B2DHomMatrix & rMatrix,basegfx::B2DPolyPolygon &) const3029 sal_Bool SdrObject::TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, basegfx::B2DPolyPolygon& /*rPolyPolygon*/) const
3030 {
3031 	// any kind of SdrObject, just use SnapRect
3032 	Rectangle aRectangle(GetSnapRect());
3033 
3034 	// convert to transformation values
3035 	basegfx::B2DTuple aScale(aRectangle.GetWidth(), aRectangle.GetHeight());
3036 	basegfx::B2DTuple aTranslate(aRectangle.Left(), aRectangle.Top());
3037 
3038 	// position maybe relative to anchorpos, convert
3039 	if( pModel && pModel->IsWriter() )
3040 	{
3041 		if(GetAnchorPos().X() || GetAnchorPos().Y())
3042 		{
3043 			aTranslate -= basegfx::B2DTuple(GetAnchorPos().X(), GetAnchorPos().Y());
3044 		}
3045 	}
3046 
3047 	// force MapUnit to 100th mm
3048 	const SfxMapUnit eMapUnit(GetObjectMapUnit());
3049 	if(eMapUnit != SFX_MAPUNIT_100TH_MM)
3050 	{
3051 		switch(eMapUnit)
3052 		{
3053 			case SFX_MAPUNIT_TWIP :
3054 			{
3055 				// position
3056 				aTranslate.setX(ImplTwipsToMM(aTranslate.getX()));
3057 				aTranslate.setY(ImplTwipsToMM(aTranslate.getY()));
3058 
3059 				// size
3060 				aScale.setX(ImplTwipsToMM(aScale.getX()));
3061 				aScale.setY(ImplTwipsToMM(aScale.getY()));
3062 
3063 				break;
3064 			}
3065 			default:
3066 			{
3067 				DBG_ERROR("TRGetBaseGeometry: Missing unit translation to 100th mm!");
3068 			}
3069 		}
3070 	}
3071 
3072 	// build matrix
3073 	rMatrix = basegfx::tools::createScaleTranslateB2DHomMatrix(aScale, aTranslate);
3074 
3075 	return sal_False;
3076 }
3077 
3078 // sets the base geometry of the object using infos contained in the homogen 3x3 matrix.
3079 // If it's an SdrPathObj it will use the provided geometry information. The Polygon has
3080 // to use (0,0) as upper left and will be scaled to the given size in the matrix.
TRSetBaseGeometry(const basegfx::B2DHomMatrix & rMatrix,const basegfx::B2DPolyPolygon &)3081 void SdrObject::TRSetBaseGeometry(const basegfx::B2DHomMatrix& rMatrix, const basegfx::B2DPolyPolygon& /*rPolyPolygon*/)
3082 {
3083 	// break up matrix
3084 	basegfx::B2DTuple aScale;
3085 	basegfx::B2DTuple aTranslate;
3086 	double fRotate, fShearX;
3087 	rMatrix.decompose(aScale, aTranslate, fRotate, fShearX);
3088 
3089 	// #i75086# Old DrawingLayer (GeoStat and geometry) does not support holding negative scalings
3090 	// in X and Y which equal a 180 degree rotation. Recognize it and react accordingly
3091 	if(basegfx::fTools::less(aScale.getX(), 0.0) && basegfx::fTools::less(aScale.getY(), 0.0))
3092 	{
3093 		aScale.setX(fabs(aScale.getX()));
3094 		aScale.setY(fabs(aScale.getY()));
3095 		fRotate = fmod(fRotate + F_PI, F_2PI);
3096 	}
3097 
3098 	// force metric to pool metric
3099 	const SfxMapUnit eMapUnit(GetObjectMapUnit());
3100 	if(eMapUnit != SFX_MAPUNIT_100TH_MM)
3101 	{
3102 		switch(eMapUnit)
3103 		{
3104 			case SFX_MAPUNIT_TWIP :
3105 			{
3106 				// position
3107 				aTranslate.setX(ImplMMToTwips(aTranslate.getX()));
3108 				aTranslate.setY(ImplMMToTwips(aTranslate.getY()));
3109 
3110 				// size
3111 				aScale.setX(ImplMMToTwips(aScale.getX()));
3112 				aScale.setY(ImplMMToTwips(aScale.getY()));
3113 
3114 				break;
3115 			}
3116 			default:
3117 			{
3118 				DBG_ERROR("TRSetBaseGeometry: Missing unit translation to PoolMetric!");
3119 			}
3120 		}
3121 	}
3122 
3123 	// if anchor is used, make position relative to it
3124 	if( pModel && pModel->IsWriter() )
3125 	{
3126 		if(GetAnchorPos().X() || GetAnchorPos().Y())
3127 		{
3128 			aTranslate += basegfx::B2DTuple(GetAnchorPos().X(), GetAnchorPos().Y());
3129 		}
3130 	}
3131 
3132 	// build BaseRect
3133 	Point aPoint(FRound(aTranslate.getX()), FRound(aTranslate.getY()));
3134 	Rectangle aBaseRect(aPoint, Size(FRound(aScale.getX()), FRound(aScale.getY())));
3135 
3136 	// set BaseRect
3137 	SetSnapRect(aBaseRect);
3138 }
3139 
3140 // #116168#
3141 // Give info if object is in destruction
IsInDestruction() const3142 sal_Bool SdrObject::IsInDestruction() const
3143 {
3144 	if(pModel)
3145 		return pModel->IsInDestruction();
3146 	return sal_False;
3147 }
3148 
3149 // return if fill is != XFILL_NONE
HasFillStyle() const3150 bool SdrObject::HasFillStyle() const
3151 {
3152 	return (((const XFillStyleItem&)GetObjectItem(XATTR_FILLSTYLE)).GetValue() != XFILL_NONE);
3153 }
3154 
HasLineStyle() const3155 bool SdrObject::HasLineStyle() const
3156 {
3157 	return (((const XLineStyleItem&)GetObjectItem(XATTR_LINESTYLE)).GetValue() != XLINE_NONE);
3158 }
3159 
3160 
3161 // #i52224#
3162 // on import of OLE object from MS documents the BLIP size might be retrieved,
3163 // the following four methods are used to control it;
3164 // usually this data makes no sence after the import is finished, since the object
3165 // might be resized
3166 
GetBLIPSizeRectangle() const3167 Rectangle SdrObject::GetBLIPSizeRectangle() const
3168 {
3169 	return maBLIPSizeRectangle;
3170 }
3171 
SetBLIPSizeRectangle(const Rectangle & aRect)3172 void SdrObject::SetBLIPSizeRectangle( const Rectangle& aRect )
3173 {
3174 	maBLIPSizeRectangle = aRect;
3175 }
3176 
SetContextWritingMode(const sal_Int16)3177 void SdrObject::SetContextWritingMode( const sal_Int16 /*_nContextWritingMode*/ )
3178 {
3179     // this base class does not support different writing modes, so ignore the call
3180 }
3181 
3182 // #121917#
HasText() const3183 bool SdrObject::HasText() const
3184 {
3185     return false;
3186 }
3187 
3188 ////////////////////////////////////////////////////////////////////////////////////////////////////
3189 //
3190 //   @@@@  @@@@@  @@@@@@  @@@@@  @@@@   @@@@  @@@@@@  @@@@  @@@@@  @@  @@
3191 //  @@  @@ @@  @@     @@  @@    @@  @@ @@  @@   @@   @@  @@ @@  @@ @@  @@
3192 //  @@  @@ @@  @@     @@  @@    @@  @@ @@       @@   @@  @@ @@  @@ @@  @@
3193 //  @@  @@ @@@@@      @@  @@@@  @@@@@@ @@       @@   @@  @@ @@@@@   @@@@
3194 //  @@  @@ @@  @@     @@  @@    @@  @@ @@       @@   @@  @@ @@  @@   @@
3195 //  @@  @@ @@  @@ @@  @@  @@    @@  @@ @@  @@   @@   @@  @@ @@  @@   @@
3196 //   @@@@  @@@@@   @@@@   @@    @@  @@  @@@@    @@    @@@@  @@  @@   @@
3197 //
3198 ////////////////////////////////////////////////////////////////////////////////////////////////////
3199 
SdrObjFactory(sal_uInt32 nInvent,sal_uInt16 nIdent,SdrPage * pNewPage,SdrModel * pNewModel)3200 SdrObjFactory::SdrObjFactory(sal_uInt32 nInvent, sal_uInt16 nIdent, SdrPage* pNewPage, SdrModel* pNewModel)
3201 {
3202 	nInventor=nInvent;
3203 	nIdentifier=nIdent;
3204 	pNewObj=NULL;
3205 	pPage=pNewPage;
3206 	pModel=pNewModel;
3207 	pObj=NULL;
3208 	pNewData=NULL;
3209 }
3210 
SdrObjFactory(sal_uInt32 nInvent,sal_uInt16 nIdent,SdrObject * pObj1)3211 SdrObjFactory::SdrObjFactory(sal_uInt32 nInvent, sal_uInt16 nIdent, SdrObject* pObj1)
3212 {
3213 	nInventor=nInvent;
3214 	nIdentifier=nIdent;
3215 	pNewObj=NULL;
3216 	pPage=NULL;
3217 	pModel=NULL;
3218 	pObj=pObj1;
3219 	pNewData=NULL;
3220 }
3221 
MakeNewObject(sal_uInt32 nInvent,sal_uInt16 nIdent,SdrPage * pPage,SdrModel * pModel)3222 SdrObject* SdrObjFactory::MakeNewObject(sal_uInt32 nInvent, sal_uInt16 nIdent, SdrPage* pPage, SdrModel* pModel)
3223 {
3224 	if(pModel == NULL && pPage != NULL)
3225 		pModel = pPage->GetModel();
3226 	SdrObject* pObj = NULL;
3227 
3228 	if(nInvent == SdrInventor)
3229 	{
3230 		switch (nIdent)
3231 		{
3232 			case sal_uInt16(OBJ_NONE       ): pObj=new SdrObject;                   break;
3233 			case sal_uInt16(OBJ_GRUP       ): pObj=new SdrObjGroup;                 break;
3234 			case sal_uInt16(OBJ_LINE       ): pObj=new SdrPathObj(OBJ_LINE       ); break;
3235 			case sal_uInt16(OBJ_POLY       ): pObj=new SdrPathObj(OBJ_POLY       ); break;
3236 			case sal_uInt16(OBJ_PLIN       ): pObj=new SdrPathObj(OBJ_PLIN       ); break;
3237 			case sal_uInt16(OBJ_PATHLINE   ): pObj=new SdrPathObj(OBJ_PATHLINE   ); break;
3238 			case sal_uInt16(OBJ_PATHFILL   ): pObj=new SdrPathObj(OBJ_PATHFILL   ); break;
3239 			case sal_uInt16(OBJ_FREELINE   ): pObj=new SdrPathObj(OBJ_FREELINE   ); break;
3240 			case sal_uInt16(OBJ_FREEFILL   ): pObj=new SdrPathObj(OBJ_FREEFILL   ); break;
3241 			case sal_uInt16(OBJ_PATHPOLY   ): pObj=new SdrPathObj(OBJ_POLY       ); break;
3242 			case sal_uInt16(OBJ_PATHPLIN   ): pObj=new SdrPathObj(OBJ_PLIN       ); break;
3243 			case sal_uInt16(OBJ_EDGE       ): pObj=new SdrEdgeObj;                  break;
3244 			case sal_uInt16(OBJ_RECT       ): pObj=new SdrRectObj;                  break;
3245 			case sal_uInt16(OBJ_CIRC       ): pObj=new SdrCircObj(OBJ_CIRC       ); break;
3246 			case sal_uInt16(OBJ_SECT       ): pObj=new SdrCircObj(OBJ_SECT       ); break;
3247 			case sal_uInt16(OBJ_CARC       ): pObj=new SdrCircObj(OBJ_CARC       ); break;
3248 			case sal_uInt16(OBJ_CCUT       ): pObj=new SdrCircObj(OBJ_CCUT       ); break;
3249 			case sal_uInt16(OBJ_TEXT       ): pObj=new SdrRectObj(OBJ_TEXT       ); break;
3250 			case sal_uInt16(OBJ_TEXTEXT    ): pObj=new SdrRectObj(OBJ_TEXTEXT    ); break;
3251 			case sal_uInt16(OBJ_TITLETEXT  ): pObj=new SdrRectObj(OBJ_TITLETEXT  ); break;
3252 			case sal_uInt16(OBJ_OUTLINETEXT): pObj=new SdrRectObj(OBJ_OUTLINETEXT); break;
3253 			case sal_uInt16(OBJ_MEASURE    ): pObj=new SdrMeasureObj;               break;
3254 			case sal_uInt16(OBJ_GRAF       ): pObj=new SdrGrafObj;                  break;
3255 			case sal_uInt16(OBJ_OLE2       ): pObj=new SdrOle2Obj;                  break;
3256 			case sal_uInt16(OBJ_FRAME      ): pObj=new SdrOle2Obj(sal_True);            break;
3257 			case sal_uInt16(OBJ_CAPTION    ): pObj=new SdrCaptionObj;               break;
3258 			case sal_uInt16(OBJ_PAGE       ): pObj=new SdrPageObj;                  break;
3259 			case sal_uInt16(OBJ_UNO        ): pObj=new SdrUnoObj(String());			break;
3260 			case sal_uInt16(OBJ_CUSTOMSHAPE  ): pObj=new SdrObjCustomShape();       break;
3261 			case sal_uInt16(OBJ_MEDIA 	   ): pObj=new SdrMediaObj();           	break;
3262 			case sal_uInt16(OBJ_TABLE	   ): pObj=new ::sdr::table::SdrTableObj(pModel);	break;
3263 		}
3264 	}
3265 
3266 	if(pObj == NULL)
3267 	{
3268 		SdrObjFactory* pFact=new SdrObjFactory(nInvent,nIdent,pPage,pModel);
3269 		SdrLinkList& rLL=ImpGetUserMakeObjHdl();
3270 		unsigned nAnz=rLL.GetLinkCount();
3271 		unsigned i=0;
3272 		while (i<nAnz && pObj==NULL) {
3273 			rLL.GetLink(i).Call((void*)pFact);
3274 			pObj=pFact->pNewObj;
3275 			i++;
3276 		}
3277 		delete pFact;
3278 	}
3279 
3280 	if(pObj == NULL)
3281 	{
3282 		// Na wenn's denn keiner will ...
3283 	}
3284 
3285 	if(pObj != NULL)
3286 	{
3287 		if(pPage != NULL)
3288 			pObj->SetPage(pPage);
3289 		else if(pModel != NULL)
3290 			pObj->SetModel(pModel);
3291 	}
3292 
3293 	return pObj;
3294 }
3295 
MakeNewObjUserData(sal_uInt32 nInvent,sal_uInt16 nIdent,SdrObject * pObj1)3296 SdrObjUserData* SdrObjFactory::MakeNewObjUserData(sal_uInt32 nInvent, sal_uInt16 nIdent, SdrObject* pObj1)
3297 {
3298 	SdrObjUserData* pData=NULL;
3299 	if (nInvent==SdrInventor) {
3300 		switch (nIdent)
3301 		{
3302 			case sal_uInt16(SDRUSERDATA_OBJTEXTLINK) : pData=new ImpSdrObjTextLinkUserData((SdrTextObj*)pObj1); break;
3303 		}
3304 	}
3305 	if (pData==NULL) {
3306 		SdrObjFactory aFact(nInvent,nIdent,pObj1);
3307 		SdrLinkList& rLL=ImpGetUserMakeObjUserDataHdl();
3308 		unsigned nAnz=rLL.GetLinkCount();
3309 		unsigned i=0;
3310 		while (i<nAnz && pData==NULL) {
3311 			rLL.GetLink(i).Call((void*)&aFact);
3312 			pData=aFact.pNewData;
3313 			i++;
3314 		}
3315 	}
3316 	return pData;
3317 }
3318 
InsertMakeObjectHdl(const Link & rLink)3319 void SdrObjFactory::InsertMakeObjectHdl(const Link& rLink)
3320 {
3321 	SdrLinkList& rLL=ImpGetUserMakeObjHdl();
3322 	rLL.InsertLink(rLink);
3323 }
3324 
RemoveMakeObjectHdl(const Link & rLink)3325 void SdrObjFactory::RemoveMakeObjectHdl(const Link& rLink)
3326 {
3327 	SdrLinkList& rLL=ImpGetUserMakeObjHdl();
3328 	rLL.RemoveLink(rLink);
3329 }
3330 
InsertMakeUserDataHdl(const Link & rLink)3331 void SdrObjFactory::InsertMakeUserDataHdl(const Link& rLink)
3332 {
3333 	SdrLinkList& rLL=ImpGetUserMakeObjUserDataHdl();
3334 	rLL.InsertLink(rLink);
3335 }
3336 
RemoveMakeUserDataHdl(const Link & rLink)3337 void SdrObjFactory::RemoveMakeUserDataHdl(const Link& rLink)
3338 {
3339 	SdrLinkList& rLL=ImpGetUserMakeObjUserDataHdl();
3340 	rLL.RemoveLink(rLink);
3341 }
3342 
3343 namespace svx
3344 {
~ISdrObjectFilter()3345     ISdrObjectFilter::~ISdrObjectFilter()
3346     {
3347     }
3348 }
3349 
3350 // eof
3351