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