update dev300-m58
[ooovba.git] / svx / source / svdraw / svdobj.cxx
blobae5686b2c6bed2fd521cbd41ed318343566d7b3f
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: svdobj.cxx,v $
10 * $Revision: 1.99.16.2 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
33 #include <com/sun/star/lang/XComponent.hpp>
35 #define _USE_MATH_DEFINES
36 #include <math.h>
37 #include <vcl/metaact.hxx> // fuer TakeContour
38 #include <vcl/cvtsvm.hxx>
39 #include <tools/line.hxx>
40 #include <tools/bigint.hxx>
41 #include <tools/diagnose_ex.h>
42 #include <vector>
43 #include <svx/svdobj.hxx>
44 #include <svx/xpoly.hxx>
45 #include <svx/svdetc.hxx>
46 #include <svx/svdtrans.hxx>
47 #include <svx/svdhdl.hxx>
48 #include <svx/svddrag.hxx>
49 #include <svx/svdmodel.hxx>
50 #include <svx/svdpage.hxx>
51 #include <svx/svdovirt.hxx> // Fuer Add/Del Ref
52 #include <svx/svdview.hxx> // fuer Dragging (Ortho abfragen)
53 #include "svdscrol.hxx"
54 #include "svdglob.hxx" // StringCache
55 #include "svdstr.hrc" // Objektname
56 #include <svx/svdogrp.hxx> // Factory
57 #include <svx/svdopath.hxx> // Factory
58 #include <svx/svdoedge.hxx> // Factory
59 #include <svx/svdorect.hxx> // Factory
60 #include <svx/svdocirc.hxx> // Factory
61 #include <svx/svdotext.hxx> // Factory
62 #include <svx/svdomeas.hxx> // Factory
63 #include <svx/svdograf.hxx> // Factory
64 #include <svx/svdoole2.hxx> // Factory
65 #include <svx/svdocapt.hxx> // Factory
66 #include <svx/svdopage.hxx> // Factory
67 #include <svx/svdouno.hxx> // Factory
68 #include <svx/svdattrx.hxx> // NotPersistItems
69 #include <svx/svdoashp.hxx>
70 #include <svx/svdomedia.hxx>
72 ////////////////////////////////////////////////////////////////////////////////////////////////////
74 #include <svx/xlnwtit.hxx>
75 #include <svx/xlnstwit.hxx>
76 #include <svx/xlnedwit.hxx>
77 #include <svx/xlnstit.hxx>
78 #include <svx/xlnedit.hxx>
79 #include <svx/xlnstcit.hxx>
80 #include <svx/xlnedcit.hxx>
81 #include <svx/xlndsit.hxx>
82 #include <svx/xlnclit.hxx>
83 #include <svx/xflclit.hxx>
84 #include "svditer.hxx"
85 #include <svx/xlntrit.hxx>
86 #include <svx/xfltrit.hxx>
87 #include <svx/xfltrit.hxx>
88 #include <svx/xflftrit.hxx>
89 #include "xlinjoit.hxx"
90 #include <svx/unopage.hxx>
91 #include <svx/eeitem.hxx>
92 #include <svx/xenum.hxx>
93 #include <svx/xgrad.hxx>
94 #include <svx/xhatch.hxx>
95 #include <svx/xflhtit.hxx>
96 #include <svx/xbtmpit.hxx>
97 #include <svx/svdpool.hxx>
98 #include <svx/editeng.hxx>
99 #include <vcl/salbtype.hxx> // FRound
100 #include <svtools/whiter.hxx>
102 // #97849#
103 #include <svx/fmmodel.hxx>
104 #include <sfx2/objsh.hxx>
105 #include <sfx2/objface.hxx>
106 #include "svdoimp.hxx"
107 #include <vcl/graphictools.hxx>
108 #include <svtools/colorcfg.hxx>
109 #include <svx/sdr/properties/emptyproperties.hxx>
111 // #110094#
112 #include <svx/sdr/contact/viewcontactofsdrobj.hxx>
113 #include <svx/sdr/contact/viewcontactofgraphic.hxx>
114 #include <svx/sdr/contact/objectcontactofobjlistpainter.hxx>
115 #include <svx/sdr/contact/displayinfo.hxx>
116 #include <basegfx/polygon/b2dpolygon.hxx>
117 #include <basegfx/polygon/b2dpolygontools.hxx>
118 #include <basegfx/matrix/b2dhommatrix.hxx>
119 #include <basegfx/polygon/b2dpolypolygontools.hxx>
120 #include <basegfx/range/b2drange.hxx>
121 #include <svx/unoshape.hxx>
122 #include <vcl/virdev.hxx>
124 #include <basegfx/polygon/b2dpolypolygoncutter.hxx>
125 #include <drawinglayer/processor2d/contourextractor2d.hxx>
126 #include <drawinglayer/processor2d/linegeometryextractor2d.hxx>
127 #include <svx/polysc3d.hxx>
128 #include "svx/svdotable.hxx"
129 #include "svx/shapepropertynotifier.hxx"
130 #include <svx/sdrhittesthelper.hxx>
132 // --> OD 2009-07-10 #i73249#
133 #include <svx/svdundo.hxx>
134 // <--
136 using namespace ::com::sun::star;
138 // #104018# replace macros above with type-detecting methods
139 inline double ImplTwipsToMM(double fVal) { return (fVal * (127.0 / 72.0)); }
140 inline double ImplMMToTwips(double fVal) { return (fVal * (72.0 / 127.0)); }
142 ////////////////////////////////////////////////////////////////////////////////////////////////////
144 TYPEINIT0(SdrObjUserCall);
146 SdrObjUserCall::~SdrObjUserCall()
150 void SdrObjUserCall::Changed(const SdrObject& /*rObj*/, SdrUserCallType /*eType*/, const Rectangle& /*rOldBoundRect*/)
154 ////////////////////////////////////////////////////////////////////////////////////////////////////
156 TYPEINIT0(SdrObjUserData);
158 void SdrObjUserData::operator=(const SdrObjUserData& /*rData*/) // nicht implementiert
162 sal_Bool SdrObjUserData::operator==(const SdrObjUserData& /*rData*/) const // nicht implementiert
164 return FALSE;
167 sal_Bool SdrObjUserData::operator!=(const SdrObjUserData& /*rData*/) const // nicht implementiert
169 return FALSE;
172 SdrObjUserData::~SdrObjUserData()
176 FASTBOOL SdrObjUserData::HasMacro(const SdrObject* /*pObj*/) const
178 return FALSE;
181 SdrObject* SdrObjUserData::CheckMacroHit(const SdrObjMacroHitRec& rRec, const SdrObject* pObj) const
183 if(pObj)
185 if(rRec.pPageView)
187 return SdrObjectPrimitiveHit(*pObj, rRec.aPos, rRec.nTol, *rRec.pPageView, rRec.pVisiLayer, false);
191 return 0;
194 Pointer SdrObjUserData::GetMacroPointer(const SdrObjMacroHitRec& /*rRec*/, const SdrObject* /*pObj*/) const
196 return Pointer(POINTER_REFHAND);
199 void SdrObjUserData::PaintMacro(OutputDevice& rOut, const Rectangle& /*rDirtyRect*/, const SdrObjMacroHitRec& /*rRec*/, const SdrObject* pObj) const
201 if(!pObj)
202 return;
204 const RasterOp eRop(rOut.GetRasterOp());
205 const basegfx::B2DPolyPolygon aPolyPolygon(pObj->TakeXorPoly());
206 const sal_uInt32 nCount(aPolyPolygon.count());
208 rOut.SetLineColor(COL_BLACK);
209 rOut.SetFillColor();
210 rOut.SetRasterOp(ROP_INVERT);
212 for(sal_uInt32 a(0); a < nCount; a++)
214 rOut.DrawPolyLine(aPolyPolygon.getB2DPolygon(a));
217 rOut.SetRasterOp(eRop);
220 FASTBOOL SdrObjUserData::DoMacro(const SdrObjMacroHitRec& /*rRec*/, SdrObject* /*pObj*/)
222 return FALSE;
225 XubString SdrObjUserData::GetMacroPopupComment(const SdrObjMacroHitRec& /*rRec*/, const SdrObject* /*pObj*/) const
227 return String();
230 void SdrObjUserDataList::Clear()
232 USHORT nAnz=GetUserDataCount();
233 for (USHORT i=0; i<nAnz; i++) {
234 delete GetUserData(i);
236 aList.Clear();
239 ////////////////////////////////////////////////////////////////////////////////////////////////////
241 DBG_NAME(SdrObjGeoData);
243 SdrObjGeoData::SdrObjGeoData():
244 pGPL(NULL),
245 bMovProt(FALSE),
246 bSizProt(FALSE),
247 bNoPrint(FALSE),
248 bClosedObj(FALSE),
249 mnLayerID(0)
251 DBG_CTOR(SdrObjGeoData,NULL);
254 SdrObjGeoData::~SdrObjGeoData()
256 DBG_DTOR(SdrObjGeoData,NULL);
257 delete pGPL;
260 ////////////////////////////////////////////////////////////////////////////////////////////////////
262 TYPEINIT0(SdrObjPlusData);
264 SdrObjPlusData::SdrObjPlusData():
265 pBroadcast(NULL),
266 pUserDataList(NULL),
267 pGluePoints(NULL),
268 pAutoTimer(NULL)
272 SdrObjPlusData::~SdrObjPlusData()
274 if (pBroadcast !=NULL) delete pBroadcast;
275 if (pUserDataList!=NULL) delete pUserDataList;
276 if (pGluePoints !=NULL) delete pGluePoints;
277 if (pAutoTimer !=NULL) delete pAutoTimer;
280 SdrObjPlusData* SdrObjPlusData::Clone(SdrObject* pObj1) const
282 SdrObjPlusData* pNeuPlusData=new SdrObjPlusData;
283 if (pUserDataList!=NULL) {
284 USHORT nAnz=pUserDataList->GetUserDataCount();
285 if (nAnz!=0) {
286 pNeuPlusData->pUserDataList=new SdrObjUserDataList;
287 for (USHORT i=0; i<nAnz; i++) {
288 SdrObjUserData* pNeuUserData=pUserDataList->GetUserData(i)->Clone(pObj1);
289 if (pNeuUserData!=NULL) {
290 pNeuPlusData->pUserDataList->InsertUserData(pNeuUserData);
291 } else {
292 DBG_ERROR("SdrObjPlusData::Clone(): UserData.Clone() liefert NULL");
297 if (pGluePoints!=NULL) pNeuPlusData->pGluePoints=new SdrGluePointList(*pGluePoints);
298 // MtfAnimator wird auch nicht mitkopiert
300 // #i68101#
301 // copy object name, title and description
302 pNeuPlusData->aObjName = aObjName;
303 pNeuPlusData->aObjTitle = aObjTitle;
304 pNeuPlusData->aObjDescription = aObjDescription;
306 if (pAutoTimer!=NULL) {
307 pNeuPlusData->pAutoTimer=new AutoTimer;
308 // Handler, etc. nicht mitkopieren!
311 // For HTMLName: Do not clone, leave uninitialized (empty string)
313 return pNeuPlusData;
316 ////////////////////////////////////////////////////////////////////////////////////////////////////
318 // @@@@ @@@@@ @@@@@@ @@@@@ @@@@ @@@@@@
319 // @@ @@ @@ @@ @@ @@ @@ @@ @@
320 // @@ @@ @@ @@ @@ @@ @@ @@
321 // @@ @@ @@@@@ @@ @@@@ @@ @@
322 // @@ @@ @@ @@ @@ @@ @@ @@
323 // @@ @@ @@ @@ @@ @@ @@ @@ @@ @@
324 // @@@@ @@@@@ @@@@ @@@@@ @@@@ @@
326 ////////////////////////////////////////////////////////////////////////////////////////////////////
328 //////////////////////////////////////////////////////////////////////////////
329 // BaseProperties section
331 sdr::properties::BaseProperties* SdrObject::CreateObjectSpecificProperties()
333 return new sdr::properties::EmptyProperties(*this);
336 sdr::properties::BaseProperties& SdrObject::GetProperties() const
338 if(!mpProperties)
340 ((SdrObject*)this)->mpProperties = ((SdrObject*)this)->CreateObjectSpecificProperties();
343 return *mpProperties;
346 //////////////////////////////////////////////////////////////////////////////
347 // ObjectUser section
349 void SdrObject::AddObjectUser(sdr::ObjectUser& rNewUser)
351 maObjectUsers.push_back(&rNewUser);
354 void SdrObject::RemoveObjectUser(sdr::ObjectUser& rOldUser)
356 const ::sdr::ObjectUserVector::iterator aFindResult = ::std::find(maObjectUsers.begin(), maObjectUsers.end(), &rOldUser);
357 if(aFindResult != maObjectUsers.end())
359 maObjectUsers.erase(aFindResult);
363 //////////////////////////////////////////////////////////////////////////////
364 // #110094# DrawContact section
366 sdr::contact::ViewContact* SdrObject::CreateObjectSpecificViewContact()
368 return new sdr::contact::ViewContactOfSdrObj(*this);
371 sdr::contact::ViewContact& SdrObject::GetViewContact() const
373 if(!mpViewContact)
375 ((SdrObject*)this)->mpViewContact = ((SdrObject*)this)->CreateObjectSpecificViewContact();
378 return *mpViewContact;
381 // DrawContact support: Methods for handling Object changes
382 void SdrObject::ActionChanged() const
384 // Forward change call to MasterPageDescriptor if BackgroundObject was changed
385 const SdrPage* pObjectsPage = GetPage();
387 if(pObjectsPage)
389 // do the necessary ActionChange() forwards when a MasterPageBackgroundObject
390 // gets changed. This can be removed as soon as the MasterPageBackgroundObject
391 // handling is replaced with the proper ItemSet handling at the SdrPages. The
392 // needed ActionChanged calls will then be triggered by changing those ItemSets.
393 if(pObjectsPage->IsMasterPage())
395 if(IsMasterPageBackgroundObject())
397 SdrModel* pObjectsModel = GetModel();
399 if(pObjectsModel)
401 const sal_uInt16 nCount(pObjectsModel->GetPageCount());
403 for(sal_uInt16 a(0); a < nCount; a++)
405 const SdrPage* pUserPage = pObjectsModel->GetPage(a);
407 if(pUserPage && pUserPage->TRG_HasMasterPage())
409 SdrPage& rUsedMasterPage = pUserPage->TRG_GetMasterPage();
411 if(&rUsedMasterPage == pObjectsPage)
413 pUserPage->TRG_GetMasterPageDescriptorViewContact().ActionChanged();
420 else
422 if(pObjectsPage->TRG_HasMasterPage() && pObjectsPage->GetBackgroundObj() == this)
424 pObjectsPage->TRG_GetMasterPageDescriptorViewContact().ActionChanged();
429 // Do necessary ViewContact actions
430 GetViewContact().ActionChanged();
433 //////////////////////////////////////////////////////////////////////////////
435 void SdrObject::SetBoundRectDirty()
437 aOutRect = Rectangle();
440 //////////////////////////////////////////////////////////////////////////////
442 DBG_NAME(SdrObject);
443 TYPEINIT1(SdrObject,SfxListener);
445 SdrObject::SdrObject()
446 :mpProperties(0L)
447 ,mpViewContact(0L)
448 ,pObjList(NULL)
449 ,pPage(NULL)
450 ,pModel(NULL)
451 ,pUserCall(NULL)
452 ,pPlusData(NULL)
453 ,nOrdNum(0)
454 ,mnNavigationPosition(SAL_MAX_UINT32)
455 ,mnLayerID(0)
456 ,mpSvxShape( NULL )
457 ,maWeakUnoShape()
459 DBG_CTOR(SdrObject,NULL);
460 bVirtObj =FALSE;
461 bSnapRectDirty =TRUE;
462 bNetLock =FALSE;
463 bInserted =FALSE;
464 bGrouped =FALSE;
465 bMovProt =FALSE;
466 bSizProt =FALSE;
467 bNoPrint =FALSE;
468 bEmptyPresObj =FALSE;
469 bNotVisibleAsMaster=FALSE;
470 bClosedObj =FALSE;
472 // #i25616#
473 mbLineIsOutsideGeometry = sal_False;
475 // #i25616#
476 mbSupportTextIndentingOnLineWidthChange = sal_False;
478 //#110094#-1
479 //bWriterFlyFrame =FALSE;
481 bNotMasterCachable=FALSE;
482 bIsEdge=FALSE;
483 bIs3DObj=FALSE;
484 bMarkProt=FALSE;
485 bIsUnoObj=FALSE;
488 SdrObject::~SdrObject()
490 // tell all the registered ObjectUsers that the page is in destruction
491 ::sdr::ObjectUserVector aListCopy(maObjectUsers.begin(), maObjectUsers.end());
492 for(::sdr::ObjectUserVector::iterator aIterator = aListCopy.begin(); aIterator != aListCopy.end(); aIterator++)
494 sdr::ObjectUser* pObjectUser = *aIterator;
495 DBG_ASSERT(pObjectUser, "SdrObject::~SdrObject: corrupt ObjectUser list (!)");
496 pObjectUser->ObjectInDestruction(*this);
499 // Clear the vector. This means that user do not need to call RemoveObjectUser()
500 // when they get called from ObjectInDestruction().
501 maObjectUsers.clear();
505 SvxShape* pSvxShape = getSvxShape();
506 if ( pSvxShape )
508 OSL_ENSURE(!pSvxShape->HasSdrObjectOwnership(),"Please check where this call come from and replace it with SdrObject::Free");
509 pSvxShape->InvalidateSdrObject();
510 uno::Reference< lang::XComponent > xShapeComp( getWeakUnoShape(), uno::UNO_QUERY_THROW );
511 xShapeComp->dispose();
514 catch( const uno::Exception& )
516 DBG_UNHANDLED_EXCEPTION();
519 DBG_DTOR(SdrObject,NULL);
520 SendUserCall(SDRUSERCALL_DELETE, GetLastBoundRect());
521 if (pPlusData!=NULL) delete pPlusData;
523 if(mpProperties)
525 delete mpProperties;
526 mpProperties = 0L;
529 // #110094#
530 if(mpViewContact)
532 delete mpViewContact;
533 mpViewContact = 0L;
537 void SdrObject::Free( SdrObject*& _rpObject )
539 SdrObject* pObject = _rpObject; _rpObject = NULL;
540 if ( pObject == NULL )
541 // nothing to do
542 return;
544 SvxShape* pShape = pObject->getSvxShape();
545 if ( pShape && pShape->HasSdrObjectOwnership() )
546 // only the shape is allowed to delete me, and will reset the ownership before doing so
547 return;
549 delete pObject;
552 SdrObjPlusData* SdrObject::NewPlusData() const
554 return new SdrObjPlusData;
557 void SdrObject::SetRectsDirty(sal_Bool bNotMyself)
559 if (!bNotMyself) {
560 SetBoundRectDirty();
561 bSnapRectDirty=TRUE;
563 if (pObjList!=NULL) {
564 pObjList->SetRectsDirty();
568 void SdrObject::SetModel(SdrModel* pNewModel)
570 if(pNewModel && pPage)
572 if(pPage->GetModel() != pNewModel)
574 pPage = NULL;
578 // update listeners at possible api wrapper object
579 if( pModel != pNewModel )
581 SvxShape* pShape = getSvxShape();
582 if( pShape )
583 pShape->ChangeModel( pNewModel );
586 pModel = pNewModel;
589 void SdrObject::SetObjList(SdrObjList* pNewObjList)
591 pObjList=pNewObjList;
594 void SdrObject::SetPage(SdrPage* pNewPage)
596 pPage=pNewPage;
597 if (pPage!=NULL) {
598 SdrModel* pMod=pPage->GetModel();
599 if (pMod!=pModel && pMod!=NULL) {
600 SetModel(pMod);
604 // init global static itempool
605 SdrItemPool* SdrObject::mpGlobalItemPool = NULL;
607 SdrItemPool& SdrObject::GetGlobalDrawObjectItemPool()
609 if(!mpGlobalItemPool)
611 mpGlobalItemPool = new SdrItemPool();
612 SfxItemPool* pGlobalOutlPool = EditEngine::CreatePool();
613 mpGlobalItemPool->SetSecondaryPool(pGlobalOutlPool);
614 mpGlobalItemPool->SetDefaultMetric((SfxMapUnit)SdrEngineDefaults::GetMapUnit());
615 mpGlobalItemPool->FreezeIdRanges();
618 return *mpGlobalItemPool;
621 void SdrObject::FreeGlobalDrawObjectItemPool()
623 // code for deletion of GlobalItemPool
624 if(mpGlobalItemPool)
626 SfxItemPool* pGlobalOutlPool = mpGlobalItemPool->GetSecondaryPool();
627 SfxItemPool::Free(mpGlobalItemPool);
628 SfxItemPool::Free(pGlobalOutlPool);
632 SdrItemPool* SdrObject::GetObjectItemPool() const
634 if(pModel)
635 return (SdrItemPool*)(&pModel->GetItemPool());
637 // use a static global default pool
638 return &SdrObject::GetGlobalDrawObjectItemPool();
641 UINT32 SdrObject::GetObjInventor() const
643 return SdrInventor;
646 UINT16 SdrObject::GetObjIdentifier() const
648 return UINT16(OBJ_NONE);
651 void SdrObject::TakeObjInfo(SdrObjTransformInfoRec& rInfo) const
653 rInfo.bRotateFreeAllowed=FALSE;
654 rInfo.bMirrorFreeAllowed=FALSE;
655 rInfo.bTransparenceAllowed = FALSE;
656 rInfo.bGradientAllowed = FALSE;
657 rInfo.bShearAllowed =FALSE;
658 rInfo.bEdgeRadiusAllowed=FALSE;
659 rInfo.bCanConvToPath =FALSE;
660 rInfo.bCanConvToPoly =FALSE;
661 rInfo.bCanConvToContour = FALSE;
662 rInfo.bCanConvToPathLineToArea=FALSE;
663 rInfo.bCanConvToPolyLineToArea=FALSE;
666 SdrLayerID SdrObject::GetLayer() const
668 return mnLayerID;
671 void SdrObject::getMergedHierarchyLayerSet(SetOfByte& rSet) const
673 rSet.Set(GetLayer());
674 SdrObjList* pOL=GetSubList();
675 if (pOL!=NULL) {
676 ULONG nObjAnz=pOL->GetObjCount();
677 for (ULONG nObjNum=0; nObjNum<nObjAnz; nObjNum++) {
678 pOL->GetObj(nObjNum)->getMergedHierarchyLayerSet(rSet);
683 void SdrObject::NbcSetLayer(SdrLayerID nLayer)
685 if(GetLayer() != nLayer)
687 mnLayerID = nLayer;
691 void SdrObject::SetLayer(SdrLayerID nLayer)
693 NbcSetLayer(nLayer);
694 SetChanged();
695 BroadcastObjectChange();
698 void SdrObject::AddListener(SfxListener& rListener)
700 ImpForcePlusData();
701 if (pPlusData->pBroadcast==NULL) pPlusData->pBroadcast=new SfxBroadcaster;
702 rListener.StartListening(*pPlusData->pBroadcast);
705 void SdrObject::RemoveListener(SfxListener& rListener)
707 if (pPlusData!=NULL && pPlusData->pBroadcast!=NULL) {
708 rListener.EndListening(*pPlusData->pBroadcast);
709 if (!pPlusData->pBroadcast->HasListeners()) {
710 delete pPlusData->pBroadcast;
711 pPlusData->pBroadcast=NULL;
716 void SdrObject::AddReference(SdrVirtObj& rVrtObj)
718 AddListener(rVrtObj);
721 void SdrObject::DelReference(SdrVirtObj& rVrtObj)
723 RemoveListener(rVrtObj);
726 AutoTimer* SdrObject::ForceAutoTimer()
728 ImpForcePlusData();
729 if (pPlusData->pAutoTimer==NULL) pPlusData->pAutoTimer=new AutoTimer;
730 return pPlusData->pAutoTimer;
733 FASTBOOL SdrObject::HasRefPoint() const
735 return FALSE;
738 Point SdrObject::GetRefPoint() const
740 return GetCurrentBoundRect().Center();
743 void SdrObject::SetRefPoint(const Point& /*rPnt*/)
747 SdrObjList* SdrObject::GetSubList() const
749 return NULL;
752 SdrObject* SdrObject::GetUpGroup() const
754 return pObjList!=NULL ? pObjList->GetOwnerObj() : NULL;
757 void SdrObject::SetName(const String& rStr)
759 if(rStr.Len() && !pPlusData)
761 ImpForcePlusData();
764 if(pPlusData && pPlusData->aObjName != rStr)
766 // --> OD 2009-07-09 #i73249#
767 // Undo/Redo for setting object's name
768 bool bUndo( false );
769 if ( GetModel() && GetModel()->IsUndoEnabled() )
771 bUndo = true;
772 SdrUndoAction* pUndoAction =
773 GetModel()->GetSdrUndoFactory().CreateUndoObjectStrAttr(
774 *this,
775 SdrUndoObjStrAttr::OBJ_NAME,
776 GetName(),
777 rStr );
778 GetModel()->BegUndo( pUndoAction->GetComment() );
779 GetModel()->AddUndo( pUndoAction );
781 // <--
782 pPlusData->aObjName = rStr;
783 // --> OD 2009-07-09 #i73249#
784 if ( bUndo )
786 GetModel()->EndUndo();
788 // <--
789 SetChanged();
790 BroadcastObjectChange();
794 String SdrObject::GetName() const
796 if(pPlusData)
798 return pPlusData->aObjName;
801 return String();
804 void SdrObject::SetTitle(const String& rStr)
806 if(rStr.Len() && !pPlusData)
808 ImpForcePlusData();
811 if(pPlusData && pPlusData->aObjTitle != rStr)
813 // --> OD 2009-07-13 #i73249#
814 // Undo/Redo for setting object's title
815 bool bUndo( false );
816 if ( GetModel() && GetModel()->IsUndoEnabled() )
818 bUndo = true;
819 SdrUndoAction* pUndoAction =
820 GetModel()->GetSdrUndoFactory().CreateUndoObjectStrAttr(
821 *this,
822 SdrUndoObjStrAttr::OBJ_TITLE,
823 GetTitle(),
824 rStr );
825 GetModel()->BegUndo( pUndoAction->GetComment() );
826 GetModel()->AddUndo( pUndoAction );
828 // <--
829 pPlusData->aObjTitle = rStr;
830 // --> OD 2009-07-13 #i73249#
831 if ( bUndo )
833 GetModel()->EndUndo();
835 // <--
836 SetChanged();
837 BroadcastObjectChange();
841 String SdrObject::GetTitle() const
843 if(pPlusData)
845 return pPlusData->aObjTitle;
848 return String();
851 void SdrObject::SetDescription(const String& rStr)
853 if(rStr.Len() && !pPlusData)
855 ImpForcePlusData();
858 if(pPlusData && pPlusData->aObjDescription != rStr)
860 // --> OD 2009-07-13 #i73249#
861 // Undo/Redo for setting object's description
862 bool bUndo( false );
863 if ( GetModel() && GetModel()->IsUndoEnabled() )
865 bUndo = true;
866 SdrUndoAction* pUndoAction =
867 GetModel()->GetSdrUndoFactory().CreateUndoObjectStrAttr(
868 *this,
869 SdrUndoObjStrAttr::OBJ_DESCRIPTION,
870 GetDescription(),
871 rStr );
872 GetModel()->BegUndo( pUndoAction->GetComment() );
873 GetModel()->AddUndo( pUndoAction );
875 // <--
876 pPlusData->aObjDescription = rStr;
877 // --> OD 2009-07-13 #i73249#
878 if ( bUndo )
880 GetModel()->EndUndo();
882 // <--
883 SetChanged();
884 BroadcastObjectChange();
888 String SdrObject::GetDescription() const
890 if(pPlusData)
892 return pPlusData->aObjDescription;
895 return String();
898 void SdrObject::SetHTMLName(const String& rStr)
900 if(rStr.Len() && !pPlusData)
902 ImpForcePlusData();
905 if(pPlusData && pPlusData->aObjName != rStr)
907 pPlusData->aHTMLName = rStr;
908 SetChanged();
912 String SdrObject::GetHTMLName() const
914 if(pPlusData)
916 return pPlusData->aHTMLName;
919 return String();
922 UINT32 SdrObject::GetOrdNum() const
924 if (pObjList!=NULL) {
925 if (pObjList->IsObjOrdNumsDirty()) {
926 pObjList->RecalcObjOrdNums();
928 } else ((SdrObject*)this)->nOrdNum=0;
929 return nOrdNum;
935 sal_uInt32 SdrObject::GetNavigationPosition (void)
937 if (pObjList!=NULL && pObjList->RecalcNavigationPositions())
939 return mnNavigationPosition;
941 else
942 return GetOrdNum();
948 void SdrObject::SetNavigationPosition (const sal_uInt32 nNewPosition)
950 mnNavigationPosition = nNewPosition;
956 // #111111#
957 // To make clearer that this method may trigger RecalcBoundRect and thus may be
958 // expensive and somtimes problematic (inside a bigger object change You will get
959 // non-useful BoundRects sometimes) i rename that method from GetBoundRect() to
960 // GetCurrentBoundRect().
961 const Rectangle& SdrObject::GetCurrentBoundRect() const
963 if(aOutRect.IsEmpty())
965 const_cast< SdrObject* >(this)->RecalcBoundRect();
968 return aOutRect;
971 // #111111#
972 // To have a possibility to get the last calculated BoundRect e.g for producing
973 // the first rectangle for repaints (old and new need to be used) without forcing
974 // a RecalcBoundRect (which may be problematical and expensive sometimes) i add here
975 // a new method for accessing the last BoundRect.
976 const Rectangle& SdrObject::GetLastBoundRect() const
978 return aOutRect;
981 void SdrObject::RecalcBoundRect()
983 // #i101680# suppress BoundRect calculations on import(s)
984 if(pModel && pModel->isLocked() )
985 return;
987 // central new method which will calculate the BoundRect using primitive geometry
988 if(aOutRect.IsEmpty())
990 const drawinglayer::primitive2d::Primitive2DSequence xPrimitives(GetViewContact().getViewIndependentPrimitive2DSequence());
992 if(xPrimitives.hasElements())
994 // use neutral ViewInformation and get the range of the primitives
995 const drawinglayer::geometry::ViewInformation2D aViewInformation2D(0);
996 const basegfx::B2DRange aRange(drawinglayer::primitive2d::getB2DRangeFromPrimitive2DSequence(xPrimitives, aViewInformation2D));
998 if(!aRange.isEmpty())
1000 aOutRect = Rectangle(
1001 (sal_Int32)floor(aRange.getMinX()), (sal_Int32)floor(aRange.getMinY()),
1002 (sal_Int32)ceil(aRange.getMaxX()), (sal_Int32)ceil(aRange.getMaxY()));
1003 return;
1009 void SdrObject::BroadcastObjectChange() const
1011 if( pModel && pModel->isLocked() )
1012 return;
1014 sal_Bool bPlusDataBroadcast(pPlusData && pPlusData->pBroadcast);
1015 sal_Bool bObjectChange(IsInserted() && pModel);
1017 if(bPlusDataBroadcast || bObjectChange)
1019 SdrHint aHint(*this);
1021 if(bPlusDataBroadcast)
1023 pPlusData->pBroadcast->Broadcast(aHint);
1026 if(bObjectChange)
1028 pModel->Broadcast(aHint);
1033 void SdrObject::SetChanged()
1035 // #110094#-11
1036 // For test purposes, use the new ViewContact for change
1037 // notification now.
1038 ActionChanged();
1040 if(IsInserted() && pModel)
1042 pModel->SetChanged();
1046 // Tooling for painting a single object to a OutputDevice.
1047 sal_Bool SdrObject::SingleObjectPainter(OutputDevice& rOut) const
1049 sdr::contact::SdrObjectVector aObjectVector;
1050 aObjectVector.push_back(const_cast< SdrObject* >(this));
1052 sdr::contact::ObjectContactOfObjListPainter aPainter(rOut, aObjectVector, GetPage());
1053 sdr::contact::DisplayInfo aDisplayInfo;
1055 // do processing
1056 aPainter.ProcessDisplay(aDisplayInfo);
1058 return sal_True;
1061 BOOL SdrObject::LineGeometryUsageIsNecessary() const
1063 XLineStyle eXLS = (XLineStyle)((const XLineStyleItem&)GetMergedItem(XATTR_LINESTYLE)).GetValue();
1064 return (eXLS != XLINE_NONE);
1067 SdrObject* SdrObject::Clone() const
1069 SdrObject* pObj=SdrObjFactory::MakeNewObject(GetObjInventor(),GetObjIdentifier(),NULL);
1070 if (pObj!=NULL) {
1071 pObj->pModel=pModel;
1072 pObj->pPage=pPage;
1073 *pObj=*this;
1075 return pObj;
1078 void SdrObject::operator=(const SdrObject& rObj)
1080 if(mpProperties)
1082 delete mpProperties;
1083 mpProperties = 0L;
1086 // #110094#
1087 if(mpViewContact)
1089 delete mpViewContact;
1090 mpViewContact = 0L;
1093 // The Clone() method uses the local copy constructor from the individual
1094 // sdr::properties::BaseProperties class. Since the target class maybe for another
1095 // draw object a SdrObject needs to be provided, as in the nromal constructor.
1096 mpProperties = &rObj.GetProperties().Clone(*this);
1098 pModel =rObj.pModel;
1099 aOutRect=rObj.aOutRect;
1100 mnLayerID = rObj.mnLayerID;
1101 aAnchor =rObj.aAnchor;
1102 bVirtObj=rObj.bVirtObj;
1103 bSizProt=rObj.bSizProt;
1104 bMovProt=rObj.bMovProt;
1105 bNoPrint=rObj.bNoPrint;
1106 bMarkProt=rObj.bMarkProt;
1107 //EmptyPresObj wird nicht kopiert: nun doch! (25-07-1995, Joe)
1108 bEmptyPresObj =rObj.bEmptyPresObj;
1109 //NotVisibleAsMaster wird nicht kopiert: nun doch! (25-07-1995, Joe)
1110 bNotVisibleAsMaster=rObj.bNotVisibleAsMaster;
1111 bSnapRectDirty=TRUE; //rObj.bSnapRectDirty;
1112 bNotMasterCachable=rObj.bNotMasterCachable;
1113 if (pPlusData!=NULL) { delete pPlusData; pPlusData=NULL; }
1114 if (rObj.pPlusData!=NULL) {
1115 pPlusData=rObj.pPlusData->Clone(this);
1117 if (pPlusData!=NULL && pPlusData->pBroadcast!=NULL) {
1118 delete pPlusData->pBroadcast; // der Broadcaster wird nicht mitkopiert
1119 pPlusData->pBroadcast=NULL;
1123 void SdrObject::TakeObjNameSingul(XubString& rName) const
1125 rName=ImpGetResStr(STR_ObjNameSingulNONE);
1127 String aName( GetName() );
1128 if(aName.Len())
1130 rName += sal_Unicode(' ');
1131 rName += sal_Unicode('\'');
1132 rName += aName;
1133 rName += sal_Unicode('\'');
1137 void SdrObject::TakeObjNamePlural(XubString& rName) const
1139 rName=ImpGetResStr(STR_ObjNamePluralNONE);
1142 void SdrObject::ImpTakeDescriptionStr(USHORT nStrCacheID, XubString& rStr, USHORT nVal) const
1144 rStr = ImpGetResStr(nStrCacheID);
1146 sal_Char aSearchText1[] = "%1";
1147 sal_Char aSearchText2[] = "%2";
1148 xub_StrLen nPos = rStr.SearchAscii(aSearchText1);
1150 if(nPos != STRING_NOTFOUND)
1152 rStr.Erase(nPos, 2);
1154 XubString aObjName;
1156 TakeObjNameSingul(aObjName);
1157 rStr.Insert(aObjName, nPos);
1160 nPos = rStr.SearchAscii(aSearchText2);
1162 if(nPos != STRING_NOTFOUND)
1164 rStr.Erase(nPos, 2);
1165 rStr.Insert(UniString::CreateFromInt32(nVal), nPos);
1169 XubString SdrObject::GetWinkStr(long nWink, FASTBOOL bNoDegChar) const
1171 XubString aStr;
1172 if (pModel!=NULL) {
1173 pModel->TakeWinkStr(nWink,aStr,bNoDegChar);
1175 return aStr;
1178 XubString SdrObject::GetMetrStr(long nVal, MapUnit /*eWantMap*/, FASTBOOL bNoUnitChars) const
1180 XubString aStr;
1181 if (pModel!=NULL) {
1182 pModel->TakeMetricStr(nVal,aStr,bNoUnitChars);
1184 return aStr;
1187 basegfx::B2DPolyPolygon SdrObject::TakeXorPoly() const
1189 basegfx::B2DPolyPolygon aRetval;
1190 const Rectangle aR(GetCurrentBoundRect());
1191 const basegfx::B2DRange aRange(aR.Left(), aR.Top(), aR.Right(), aR.Bottom());
1192 aRetval.append(basegfx::tools::createPolygonFromRect(aRange));
1194 return aRetval;
1197 basegfx::B2DPolyPolygon SdrObject::TakeContour() const
1199 basegfx::B2DPolyPolygon aRetval;
1201 // create cloned object without text, but with XLINE_SOLID,
1202 // COL_BLACK as line color and XFILL_NONE
1203 SdrObject* pClone = Clone();
1205 if(pClone)
1207 const SdrTextObj* pTextObj = dynamic_cast< const SdrTextObj* >(this);
1209 if(pTextObj)
1211 // no text and no text animation
1212 pClone->SetMergedItem(SdrTextAniKindItem(SDRTEXTANI_NONE));
1213 pClone->SetOutlinerParaObject(0);
1216 const SdrEdgeObj* pEdgeObj = dynamic_cast< const SdrEdgeObj* >(this);
1218 if(pEdgeObj)
1220 // create connections if connector, will be cleaned up when
1221 // deleting the connector again
1222 SdrObject* pLeft = pEdgeObj->GetConnectedNode(TRUE);
1223 SdrObject* pRight = pEdgeObj->GetConnectedNode(FALSE);
1225 if(pLeft)
1227 pClone->ConnectToNode(TRUE, pLeft);
1230 if(pRight)
1232 pClone->ConnectToNode(FALSE, pRight);
1236 SfxItemSet aNewSet(*GetObjectItemPool());
1238 // #i101980# ignore LineWidth; that's what the old implementation
1239 // did. With linewidth, the result may be huge due to fat/thick
1240 // line decompositions
1241 aNewSet.Put(XLineWidthItem(0));
1243 // solid black lines and no fill
1244 aNewSet.Put(XLineStyleItem(XLINE_SOLID));
1245 aNewSet.Put(XLineColorItem(String(), Color(COL_BLACK)));
1246 aNewSet.Put(XFillStyleItem(XFILL_NONE));
1247 pClone->SetMergedItemSet(aNewSet);
1249 // get sequence from clone
1250 const sdr::contact::ViewContact& rVC(pClone->GetViewContact());
1251 const drawinglayer::primitive2d::Primitive2DSequence xSequence(rVC.getViewIndependentPrimitive2DSequence());
1253 if(xSequence.hasElements())
1255 // use neutral ViewInformation
1256 const drawinglayer::geometry::ViewInformation2D aViewInformation2D(0);
1258 // create extractor, process and get result
1259 drawinglayer::processor2d::ContourExtractor2D aExtractor(aViewInformation2D);
1260 aExtractor.process(xSequence);
1261 const std::vector< basegfx::B2DPolyPolygon >& rResult(aExtractor.getExtractedContour());
1262 const sal_uInt32 nSize(rResult.size());
1264 // when count is one, it is implied that the object has only it's normal
1265 // contour anyways and TakeCountour() is to return an empty PolyPolygon
1266 // (see old implementation for historical reasons)
1267 if(nSize > 1)
1269 // the topology for contour is correctly a vector of PolyPolygons; for
1270 // historical reasons cut it back to a single PolyPolygon here
1271 for(sal_uInt32 a(0); a < nSize; a++)
1273 aRetval.append(rResult[a]);
1278 delete pClone;
1281 return aRetval;
1284 sal_uInt32 SdrObject::GetHdlCount() const
1286 return 8L;
1289 SdrHdl* SdrObject::GetHdl(sal_uInt32 nHdlNum) const
1291 SdrHdl* pH=NULL;
1292 const Rectangle& rR=GetSnapRect();
1293 switch (nHdlNum) {
1294 case 0: pH=new SdrHdl(rR.TopLeft(), HDL_UPLFT); break; // Oben links
1295 case 1: pH=new SdrHdl(rR.TopCenter(), HDL_UPPER); break; // Oben
1296 case 2: pH=new SdrHdl(rR.TopRight(), HDL_UPRGT); break; // Oben rechts
1297 case 3: pH=new SdrHdl(rR.LeftCenter(), HDL_LEFT ); break; // Links
1298 case 4: pH=new SdrHdl(rR.RightCenter(), HDL_RIGHT); break; // Rechts
1299 case 5: pH=new SdrHdl(rR.BottomLeft(), HDL_LWLFT); break; // Unten links
1300 case 6: pH=new SdrHdl(rR.BottomCenter(),HDL_LOWER); break; // Unten
1301 case 7: pH=new SdrHdl(rR.BottomRight(), HDL_LWRGT); break; // Unten rechts
1303 return pH;
1306 sal_uInt32 SdrObject::GetPlusHdlCount(const SdrHdl& /*rHdl*/) const
1308 return 0L;
1311 SdrHdl* SdrObject::GetPlusHdl(const SdrHdl& /*rHdl*/, sal_uInt32 /*nPlNum*/) const
1313 return 0L;
1316 void SdrObject::AddToHdlList(SdrHdlList& rHdlList) const
1318 sal_uInt32 nAnz=GetHdlCount();
1319 for (sal_uInt32 i=0L; i<nAnz; i++) {
1320 SdrHdl* pHdl=GetHdl(i);
1321 if (pHdl!=NULL) {
1322 rHdlList.AddHdl(pHdl);
1327 Rectangle SdrObject::ImpDragCalcRect(const SdrDragStat& rDrag) const
1329 Rectangle aTmpRect(GetSnapRect());
1330 Rectangle aRect(aTmpRect);
1331 const SdrHdl* pHdl=rDrag.GetHdl();
1332 SdrHdlKind eHdl=pHdl==NULL ? HDL_MOVE : pHdl->GetKind();
1333 FASTBOOL bEcke=(eHdl==HDL_UPLFT || eHdl==HDL_UPRGT || eHdl==HDL_LWLFT || eHdl==HDL_LWRGT);
1334 FASTBOOL bOrtho=rDrag.GetView()!=NULL && rDrag.GetView()->IsOrtho();
1335 FASTBOOL bBigOrtho=bEcke && bOrtho && rDrag.GetView()->IsBigOrtho();
1336 Point aPos(rDrag.GetNow());
1337 FASTBOOL bLft=(eHdl==HDL_UPLFT || eHdl==HDL_LEFT || eHdl==HDL_LWLFT);
1338 FASTBOOL bRgt=(eHdl==HDL_UPRGT || eHdl==HDL_RIGHT || eHdl==HDL_LWRGT);
1339 FASTBOOL bTop=(eHdl==HDL_UPRGT || eHdl==HDL_UPPER || eHdl==HDL_UPLFT);
1340 FASTBOOL bBtm=(eHdl==HDL_LWRGT || eHdl==HDL_LOWER || eHdl==HDL_LWLFT);
1341 if (bLft) aTmpRect.Left() =aPos.X();
1342 if (bRgt) aTmpRect.Right() =aPos.X();
1343 if (bTop) aTmpRect.Top() =aPos.Y();
1344 if (bBtm) aTmpRect.Bottom()=aPos.Y();
1345 if (bOrtho) { // Ortho
1346 long nWdt0=aRect.Right() -aRect.Left();
1347 long nHgt0=aRect.Bottom()-aRect.Top();
1348 long nXMul=aTmpRect.Right() -aTmpRect.Left();
1349 long nYMul=aTmpRect.Bottom()-aTmpRect.Top();
1350 long nXDiv=nWdt0;
1351 long nYDiv=nHgt0;
1352 FASTBOOL bXNeg=(nXMul<0)!=(nXDiv<0);
1353 FASTBOOL bYNeg=(nYMul<0)!=(nYDiv<0);
1354 nXMul=Abs(nXMul);
1355 nYMul=Abs(nYMul);
1356 nXDiv=Abs(nXDiv);
1357 nYDiv=Abs(nYDiv);
1358 Fraction aXFact(nXMul,nXDiv); // Fractions zum kuerzen
1359 Fraction aYFact(nYMul,nYDiv); // und zum vergleichen
1360 nXMul=aXFact.GetNumerator();
1361 nYMul=aYFact.GetNumerator();
1362 nXDiv=aXFact.GetDenominator();
1363 nYDiv=aYFact.GetDenominator();
1364 if (bEcke) { // Eckpunkthandles
1365 FASTBOOL bUseX=(aXFact<aYFact) != bBigOrtho;
1366 if (bUseX) {
1367 long nNeed=long(BigInt(nHgt0)*BigInt(nXMul)/BigInt(nXDiv));
1368 if (bYNeg) nNeed=-nNeed;
1369 if (bTop) aTmpRect.Top()=aTmpRect.Bottom()-nNeed;
1370 if (bBtm) aTmpRect.Bottom()=aTmpRect.Top()+nNeed;
1371 } else {
1372 long nNeed=long(BigInt(nWdt0)*BigInt(nYMul)/BigInt(nYDiv));
1373 if (bXNeg) nNeed=-nNeed;
1374 if (bLft) aTmpRect.Left()=aTmpRect.Right()-nNeed;
1375 if (bRgt) aTmpRect.Right()=aTmpRect.Left()+nNeed;
1377 } else { // Scheitelpunkthandles
1378 if ((bLft || bRgt) && nXDiv!=0) {
1379 long nHgt0b=aRect.Bottom()-aRect.Top();
1380 long nNeed=long(BigInt(nHgt0b)*BigInt(nXMul)/BigInt(nXDiv));
1381 aTmpRect.Top()-=(nNeed-nHgt0b)/2;
1382 aTmpRect.Bottom()=aTmpRect.Top()+nNeed;
1384 if ((bTop || bBtm) && nYDiv!=0) {
1385 long nWdt0b=aRect.Right()-aRect.Left();
1386 long nNeed=long(BigInt(nWdt0b)*BigInt(nYMul)/BigInt(nYDiv));
1387 aTmpRect.Left()-=(nNeed-nWdt0b)/2;
1388 aTmpRect.Right()=aTmpRect.Left()+nNeed;
1392 aTmpRect.Justify();
1393 return aTmpRect;
1396 ////////////////////////////////////////////////////////////////////////////////////////////////////
1398 bool SdrObject::hasSpecialDrag() const
1400 return false;
1403 bool SdrObject::supportsFullDrag() const
1405 return true;
1408 SdrObject* SdrObject::getFullDragClone() const
1410 // default uses simple clone
1411 return Clone();
1414 bool SdrObject::beginSpecialDrag(SdrDragStat& rDrag) const
1416 const SdrHdl* pHdl = rDrag.GetHdl();
1418 SdrHdlKind eHdl = (pHdl == NULL) ? HDL_MOVE : pHdl->GetKind();
1420 if(eHdl==HDL_UPLFT || eHdl==HDL_UPPER || eHdl==HDL_UPRGT ||
1421 eHdl==HDL_LEFT || eHdl==HDL_RIGHT || eHdl==HDL_LWLFT ||
1422 eHdl==HDL_LOWER || eHdl==HDL_LWRGT)
1424 return true;
1427 return false;
1430 bool SdrObject::applySpecialDrag(SdrDragStat& rDrag)
1432 Rectangle aNewRect(ImpDragCalcRect(rDrag));
1434 if(aNewRect != GetSnapRect())
1436 NbcSetSnapRect(aNewRect);
1439 return true;
1442 String SdrObject::getSpecialDragComment(const SdrDragStat& /*rDrag*/) const
1444 return String();
1447 basegfx::B2DPolyPolygon SdrObject::getSpecialDragPoly(const SdrDragStat& /*rDrag*/) const
1449 // default has nothing to add
1450 return basegfx::B2DPolyPolygon();
1453 ////////////////////////////////////////////////////////////////////////////////////////////////////
1454 // Create
1455 FASTBOOL SdrObject::BegCreate(SdrDragStat& rStat)
1457 rStat.SetOrtho4Possible();
1458 Rectangle aRect1(rStat.GetStart(), rStat.GetNow());
1459 aRect1.Justify();
1460 rStat.SetActionRect(aRect1);
1461 aOutRect = aRect1;
1462 return TRUE;
1465 FASTBOOL SdrObject::MovCreate(SdrDragStat& rStat)
1467 rStat.TakeCreateRect(aOutRect);
1468 rStat.SetActionRect(aOutRect);
1469 aOutRect.Justify();
1471 // #i101648# for naked (non-derived) SdrObjects, do not invalidate aOutRect
1472 // by calling SetBoundRectDirty(); aOutRect IS the geometry for such objects.
1473 // No derivation implementation calls the parent implementation, so this will
1474 // cause no further prolems
1476 // SetBoundRectDirty();
1477 // bSnapRectDirty=TRUE;
1479 return TRUE;
1482 FASTBOOL SdrObject::EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd)
1484 rStat.TakeCreateRect(aOutRect);
1485 aOutRect.Justify();
1487 // #i101648# see description at MovCreate
1489 // SetRectsDirty();
1491 return (eCmd==SDRCREATE_FORCEEND || rStat.GetPointAnz()>=2);
1494 void SdrObject::BrkCreate(SdrDragStat& /*rStat*/)
1498 FASTBOOL SdrObject::BckCreate(SdrDragStat& /*rStat*/)
1500 return FALSE;
1503 basegfx::B2DPolyPolygon SdrObject::TakeCreatePoly(const SdrDragStat& rDrag) const
1505 Rectangle aRect1;
1506 rDrag.TakeCreateRect(aRect1);
1507 aRect1.Justify();
1509 basegfx::B2DPolyPolygon aRetval;
1510 const basegfx::B2DRange aRange(aRect1.Left(), aRect1.Top(), aRect1.Right(), aRect1.Bottom());
1511 aRetval.append(basegfx::tools::createPolygonFromRect(aRange));
1512 return aRetval;
1515 Pointer SdrObject::GetCreatePointer() const
1517 return Pointer(POINTER_CROSS);
1520 // Transformationen
1521 void SdrObject::NbcMove(const Size& rSiz)
1523 MoveRect(aOutRect,rSiz);
1524 SetRectsDirty();
1527 void SdrObject::NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact)
1529 FASTBOOL bXMirr=(xFact.GetNumerator()<0) != (xFact.GetDenominator()<0);
1530 FASTBOOL bYMirr=(yFact.GetNumerator()<0) != (yFact.GetDenominator()<0);
1531 if (bXMirr || bYMirr) {
1532 Point aRef1(GetSnapRect().Center());
1533 if (bXMirr) {
1534 Point aRef2(aRef1);
1535 aRef2.Y()++;
1536 NbcMirrorGluePoints(aRef1,aRef2);
1538 if (bYMirr) {
1539 Point aRef2(aRef1);
1540 aRef2.X()++;
1541 NbcMirrorGluePoints(aRef1,aRef2);
1544 ResizeRect(aOutRect,rRef,xFact,yFact);
1545 SetRectsDirty();
1548 void SdrObject::NbcRotate(const Point& rRef, long nWink, double sn, double cs)
1550 SetGlueReallyAbsolute(TRUE);
1551 aOutRect.Move(-rRef.X(),-rRef.Y());
1552 Rectangle R(aOutRect);
1553 if (sn==1.0 && cs==0.0) { // 90deg
1554 aOutRect.Left() =-R.Bottom();
1555 aOutRect.Right() =-R.Top();
1556 aOutRect.Top() =R.Left();
1557 aOutRect.Bottom()=R.Right();
1558 } else if (sn==0.0 && cs==-1.0) { // 180deg
1559 aOutRect.Left() =-R.Right();
1560 aOutRect.Right() =-R.Left();
1561 aOutRect.Top() =-R.Bottom();
1562 aOutRect.Bottom()=-R.Top();
1563 } else if (sn==-1.0 && cs==0.0) { // 270deg
1564 aOutRect.Left() =R.Top();
1565 aOutRect.Right() =R.Bottom();
1566 aOutRect.Top() =-R.Right();
1567 aOutRect.Bottom()=-R.Left();
1569 aOutRect.Move(rRef.X(),rRef.Y());
1570 aOutRect.Justify(); // Sicherheitshalber
1571 SetRectsDirty();
1572 NbcRotateGluePoints(rRef,nWink,sn,cs);
1573 SetGlueReallyAbsolute(FALSE);
1576 void SdrObject::NbcMirror(const Point& rRef1, const Point& rRef2)
1578 SetGlueReallyAbsolute(TRUE);
1579 aOutRect.Move(-rRef1.X(),-rRef1.Y());
1580 Rectangle R(aOutRect);
1581 long dx=rRef2.X()-rRef1.X();
1582 long dy=rRef2.Y()-rRef1.Y();
1583 if (dx==0) { // Vertikale Achse
1584 aOutRect.Left() =-R.Right();
1585 aOutRect.Right()=-R.Left();
1586 } else if (dy==0) { // Horizontale Achse
1587 aOutRect.Top() =-R.Bottom();
1588 aOutRect.Bottom()=-R.Top();
1589 } else if (dx==dy) { /* 45 Grad Achse \ */
1590 aOutRect.Left() =R.Top();
1591 aOutRect.Right() =R.Bottom();
1592 aOutRect.Top() =R.Left();
1593 aOutRect.Bottom()=R.Right();
1594 } else if (dx==-dy) { // 45 Grad Achse /
1595 aOutRect.Left() =-R.Bottom();
1596 aOutRect.Right() =-R.Top();
1597 aOutRect.Top() =-R.Right();
1598 aOutRect.Bottom()=-R.Left();
1600 aOutRect.Move(rRef1.X(),rRef1.Y());
1601 aOutRect.Justify(); // Sicherheitshalber
1602 SetRectsDirty();
1603 NbcMirrorGluePoints(rRef1,rRef2);
1604 SetGlueReallyAbsolute(FALSE);
1607 void SdrObject::NbcShear(const Point& rRef, long nWink, double tn, FASTBOOL bVShear)
1609 SetGlueReallyAbsolute(TRUE);
1610 NbcShearGluePoints(rRef,nWink,tn,bVShear);
1611 SetGlueReallyAbsolute(FALSE);
1614 void SdrObject::Move(const Size& rSiz)
1616 if (rSiz.Width()!=0 || rSiz.Height()!=0) {
1617 Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
1618 // #110094#-14 SendRepaintBroadcast();
1619 NbcMove(rSiz);
1620 SetChanged();
1621 BroadcastObjectChange();
1622 SendUserCall(SDRUSERCALL_MOVEONLY,aBoundRect0);
1626 void SdrObject::Resize(const Point& rRef, const Fraction& xFact, const Fraction& yFact)
1628 if (xFact.GetNumerator()!=xFact.GetDenominator() || yFact.GetNumerator()!=yFact.GetDenominator()) {
1629 Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
1630 // #110094#-14 SendRepaintBroadcast();
1631 NbcResize(rRef,xFact,yFact);
1632 SetChanged();
1633 BroadcastObjectChange();
1634 SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
1638 void SdrObject::Rotate(const Point& rRef, long nWink, double sn, double cs)
1640 if (nWink!=0) {
1641 Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
1642 // #110094#-14 SendRepaintBroadcast();
1643 NbcRotate(rRef,nWink,sn,cs);
1644 SetChanged();
1645 BroadcastObjectChange();
1646 SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
1650 void SdrObject::Mirror(const Point& rRef1, const Point& rRef2)
1652 Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
1653 // #110094#-14 SendRepaintBroadcast();
1654 NbcMirror(rRef1,rRef2);
1655 SetChanged();
1656 BroadcastObjectChange();
1657 SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
1660 void SdrObject::Shear(const Point& rRef, long nWink, double tn, FASTBOOL bVShear)
1662 if (nWink!=0) {
1663 Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
1664 // #110094#-14 SendRepaintBroadcast();
1665 NbcShear(rRef,nWink,tn,bVShear);
1666 SetChanged();
1667 BroadcastObjectChange();
1668 SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
1672 void SdrObject::NbcSetRelativePos(const Point& rPnt)
1674 Point aRelPos0(GetSnapRect().TopLeft()-aAnchor);
1675 Size aSiz(rPnt.X()-aRelPos0.X(),rPnt.Y()-aRelPos0.Y());
1676 NbcMove(aSiz); // Der ruft auch das SetRectsDirty()
1679 void SdrObject::SetRelativePos(const Point& rPnt)
1681 if (rPnt!=GetRelativePos()) {
1682 Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
1683 // #110094#-14 SendRepaintBroadcast();
1684 NbcSetRelativePos(rPnt);
1685 SetChanged();
1686 BroadcastObjectChange();
1687 SendUserCall(SDRUSERCALL_MOVEONLY,aBoundRect0);
1691 Point SdrObject::GetRelativePos() const
1693 return GetSnapRect().TopLeft()-aAnchor;
1696 void SdrObject::NbcSetAnchorPos(const Point& rPnt)
1698 Size aSiz(rPnt.X()-aAnchor.X(),rPnt.Y()-aAnchor.Y());
1699 aAnchor=rPnt;
1700 NbcMove(aSiz); // Der ruft auch das SetRectsDirty()
1703 void SdrObject::SetAnchorPos(const Point& rPnt)
1705 if (rPnt!=aAnchor) {
1706 Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
1707 // #110094#-14 SendRepaintBroadcast();
1708 NbcSetAnchorPos(rPnt);
1709 SetChanged();
1710 BroadcastObjectChange();
1711 SendUserCall(SDRUSERCALL_MOVEONLY,aBoundRect0);
1715 const Point& SdrObject::GetAnchorPos() const
1717 return aAnchor;
1720 void SdrObject::RecalcSnapRect()
1724 const Rectangle& SdrObject::GetSnapRect() const
1726 return aOutRect;
1729 void SdrObject::NbcSetSnapRect(const Rectangle& rRect)
1731 aOutRect=rRect;
1734 const Rectangle& SdrObject::GetLogicRect() const
1736 return GetSnapRect();
1739 void SdrObject::NbcSetLogicRect(const Rectangle& rRect)
1741 NbcSetSnapRect(rRect);
1744 void SdrObject::SetSnapRect(const Rectangle& rRect)
1746 Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
1747 // #110094#-14 SendRepaintBroadcast();
1748 NbcSetSnapRect(rRect);
1749 SetChanged();
1750 BroadcastObjectChange();
1751 SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
1754 void SdrObject::SetLogicRect(const Rectangle& rRect)
1756 Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
1757 // #110094#-14 SendRepaintBroadcast();
1758 NbcSetLogicRect(rRect);
1759 SetChanged();
1760 BroadcastObjectChange();
1761 SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
1764 long SdrObject::GetRotateAngle() const
1766 return 0;
1769 long SdrObject::GetShearAngle(FASTBOOL /*bVertical*/) const
1771 return 0;
1774 sal_uInt32 SdrObject::GetSnapPointCount() const
1776 return GetPointCount();
1779 Point SdrObject::GetSnapPoint(sal_uInt32 i) const
1781 return GetPoint(i);
1784 sal_Bool SdrObject::IsPolyObj() const
1786 return sal_False;
1789 sal_uInt32 SdrObject::GetPointCount() const
1791 return 0L;
1794 Point SdrObject::GetPoint(sal_uInt32 /*i*/) const
1796 return Point();
1799 void SdrObject::SetPoint(const Point& rPnt, sal_uInt32 i)
1801 Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
1802 // #110094#-14 SendRepaintBroadcast();
1803 NbcSetPoint(rPnt, i);
1804 SetChanged();
1805 BroadcastObjectChange();
1806 SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
1809 void SdrObject::NbcSetPoint(const Point& /*rPnt*/, sal_uInt32 /*i*/)
1813 FASTBOOL SdrObject::HasTextEdit() const
1815 return FALSE;
1818 sal_Bool SdrObject::BegTextEdit(SdrOutliner& /*rOutl*/)
1820 return FALSE;
1823 void SdrObject::EndTextEdit(SdrOutliner& /*rOutl*/)
1827 void SdrObject::SetOutlinerParaObject(OutlinerParaObject* pTextObject)
1829 Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
1830 // #110094#-14 SendRepaintBroadcast();
1831 NbcSetOutlinerParaObject(pTextObject);
1832 SetChanged();
1833 BroadcastObjectChange();
1834 if (GetCurrentBoundRect()!=aBoundRect0) {
1835 SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
1839 void SdrObject::NbcSetOutlinerParaObject(OutlinerParaObject* /*pTextObject*/)
1843 OutlinerParaObject* SdrObject::GetOutlinerParaObject() const
1845 return NULL;
1848 void SdrObject::NbcReformatText()
1852 void SdrObject::ReformatText()
1854 Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
1855 NbcReformatText();
1856 SetChanged();
1857 BroadcastObjectChange();
1858 if (GetCurrentBoundRect()!=aBoundRect0) {
1859 SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
1863 void SdrObject::BurnInStyleSheetAttributes()
1865 GetProperties().ForceStyleToHardAttributes();
1868 #define Imp2ndKennung (0x434F4D43)
1869 SdrObjUserData* SdrObject::ImpGetMacroUserData() const
1871 SdrObjUserData* pData=NULL;
1872 USHORT nAnz=GetUserDataCount();
1873 for (USHORT nNum=nAnz; nNum>0 && pData==NULL;) {
1874 nNum--;
1875 pData=GetUserData(nNum);
1876 if (!pData->HasMacro(this)) pData=NULL;
1878 return pData;
1881 FASTBOOL SdrObject::HasMacro() const
1883 SdrObjUserData* pData=ImpGetMacroUserData();
1884 return pData!=NULL ? pData->HasMacro(this) : FALSE;
1887 SdrObject* SdrObject::CheckMacroHit(const SdrObjMacroHitRec& rRec) const
1889 SdrObjUserData* pData = ImpGetMacroUserData();
1891 if(pData)
1893 return pData->CheckMacroHit(rRec, this);
1896 if(rRec.pPageView)
1898 return SdrObjectPrimitiveHit(*this, rRec.aPos, rRec.nTol, *rRec.pPageView, rRec.pVisiLayer, false);
1901 return 0;
1904 Pointer SdrObject::GetMacroPointer(const SdrObjMacroHitRec& rRec) const
1906 SdrObjUserData* pData=ImpGetMacroUserData();
1907 if (pData!=NULL) {
1908 return pData->GetMacroPointer(rRec,this);
1910 return Pointer(POINTER_REFHAND);
1913 void SdrObject::PaintMacro(OutputDevice& rOut, const Rectangle& rDirtyRect, const SdrObjMacroHitRec& rRec) const
1915 SdrObjUserData* pData=ImpGetMacroUserData();
1917 if(pData)
1919 pData->PaintMacro(rOut,rDirtyRect,rRec,this);
1921 else
1923 const RasterOp eRop(rOut.GetRasterOp());
1924 const basegfx::B2DPolyPolygon aPolyPolygon(TakeXorPoly());
1925 const sal_uInt32 nCount(aPolyPolygon.count());
1927 rOut.SetLineColor(COL_BLACK);
1928 rOut.SetFillColor();
1929 rOut.SetRasterOp(ROP_INVERT);
1931 for(sal_uInt32 a(0); a < nCount; a++)
1933 rOut.DrawPolyLine(aPolyPolygon.getB2DPolygon(a));
1936 rOut.SetRasterOp(eRop);
1940 FASTBOOL SdrObject::DoMacro(const SdrObjMacroHitRec& rRec)
1942 SdrObjUserData* pData=ImpGetMacroUserData();
1943 if (pData!=NULL) {
1944 return pData->DoMacro(rRec,this);
1946 return FALSE;
1949 XubString SdrObject::GetMacroPopupComment(const SdrObjMacroHitRec& rRec) const
1951 SdrObjUserData* pData=ImpGetMacroUserData();
1952 if (pData!=NULL) {
1953 return pData->GetMacroPopupComment(rRec,this);
1955 return String();
1958 ////////////////////////////////////////////////////////////////////////////////////////////////////
1960 SdrObjGeoData* SdrObject::NewGeoData() const
1962 return new SdrObjGeoData;
1965 void SdrObject::SaveGeoData(SdrObjGeoData& rGeo) const
1967 rGeo.aBoundRect =GetCurrentBoundRect();
1968 rGeo.aAnchor =aAnchor ;
1969 rGeo.bMovProt =bMovProt ;
1970 rGeo.bSizProt =bSizProt ;
1971 rGeo.bNoPrint =bNoPrint ;
1972 rGeo.bClosedObj =bClosedObj ;
1973 rGeo.mnLayerID = mnLayerID;
1975 // Benutzerdefinierte Klebepunkte
1976 if (pPlusData!=NULL && pPlusData->pGluePoints!=NULL) {
1977 if (rGeo.pGPL!=NULL) {
1978 *rGeo.pGPL=*pPlusData->pGluePoints;
1979 } else {
1980 rGeo.pGPL=new SdrGluePointList(*pPlusData->pGluePoints);
1982 } else {
1983 if (rGeo.pGPL!=NULL) {
1984 delete rGeo.pGPL;
1985 rGeo.pGPL=NULL;
1990 void SdrObject::RestGeoData(const SdrObjGeoData& rGeo)
1992 SetRectsDirty();
1993 aOutRect =rGeo.aBoundRect ;
1994 aAnchor =rGeo.aAnchor ;
1995 bMovProt =rGeo.bMovProt ;
1996 bSizProt =rGeo.bSizProt ;
1997 bNoPrint =rGeo.bNoPrint ;
1998 bClosedObj =rGeo.bClosedObj ;
1999 mnLayerID = rGeo.mnLayerID;
2001 // Benutzerdefinierte Klebepunkte
2002 if (rGeo.pGPL!=NULL) {
2003 ImpForcePlusData();
2004 if (pPlusData->pGluePoints!=NULL) {
2005 *pPlusData->pGluePoints=*rGeo.pGPL;
2006 } else {
2007 pPlusData->pGluePoints=new SdrGluePointList(*rGeo.pGPL);
2009 } else {
2010 if (pPlusData!=NULL && pPlusData->pGluePoints!=NULL) {
2011 delete pPlusData->pGluePoints;
2012 pPlusData->pGluePoints=NULL;
2017 SdrObjGeoData* SdrObject::GetGeoData() const
2019 SdrObjGeoData* pGeo=NewGeoData();
2020 SaveGeoData(*pGeo);
2021 return pGeo;
2024 void SdrObject::SetGeoData(const SdrObjGeoData& rGeo)
2026 Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
2027 RestGeoData(rGeo);
2028 SetChanged();
2029 BroadcastObjectChange();
2030 SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
2033 ////////////////////////////////////////////////////////////////////////////////////////////////////
2034 // ItemSet access
2036 const SfxItemSet& SdrObject::GetObjectItemSet() const
2038 return GetProperties().GetObjectItemSet();
2041 const SfxItemSet& SdrObject::GetMergedItemSet() const
2043 return GetProperties().GetMergedItemSet();
2046 void SdrObject::SetObjectItem(const SfxPoolItem& rItem)
2048 GetProperties().SetObjectItem(rItem);
2051 void SdrObject::SetMergedItem(const SfxPoolItem& rItem)
2053 GetProperties().SetMergedItem(rItem);
2056 void SdrObject::ClearObjectItem(const sal_uInt16 nWhich)
2058 GetProperties().ClearObjectItem(nWhich);
2061 void SdrObject::ClearMergedItem(const sal_uInt16 nWhich)
2063 GetProperties().ClearMergedItem(nWhich);
2066 void SdrObject::SetObjectItemSet(const SfxItemSet& rSet)
2068 GetProperties().SetObjectItemSet(rSet);
2071 void SdrObject::SetMergedItemSet(const SfxItemSet& rSet, sal_Bool bClearAllItems)
2073 GetProperties().SetMergedItemSet(rSet, bClearAllItems);
2076 const SfxPoolItem& SdrObject::GetObjectItem(const sal_uInt16 nWhich) const
2078 return GetObjectItemSet().Get(nWhich);
2081 const SfxPoolItem& SdrObject::GetMergedItem(const sal_uInt16 nWhich) const
2083 return GetMergedItemSet().Get(nWhich);
2086 void SdrObject::SetMergedItemSetAndBroadcast(const SfxItemSet& rSet, sal_Bool bClearAllItems)
2088 GetProperties().SetMergedItemSetAndBroadcast(rSet, bClearAllItems);
2091 void SdrObject::ApplyNotPersistAttr(const SfxItemSet& rAttr)
2093 Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
2094 NbcApplyNotPersistAttr(rAttr);
2095 SetChanged();
2096 BroadcastObjectChange();
2097 SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
2100 void SdrObject::NbcApplyNotPersistAttr(const SfxItemSet& rAttr)
2102 const Rectangle& rSnap=GetSnapRect();
2103 const Rectangle& rLogic=GetLogicRect();
2104 Point aRef1(rSnap.Center());
2105 Point aRef2(aRef1); aRef2.Y()++;
2106 const SfxPoolItem *pPoolItem=NULL;
2107 if (rAttr.GetItemState(SDRATTR_TRANSFORMREF1X,TRUE,&pPoolItem)==SFX_ITEM_SET) {
2108 aRef1.X()=((const SdrTransformRef1XItem*)pPoolItem)->GetValue();
2110 if (rAttr.GetItemState(SDRATTR_TRANSFORMREF1Y,TRUE,&pPoolItem)==SFX_ITEM_SET) {
2111 aRef1.Y()=((const SdrTransformRef1YItem*)pPoolItem)->GetValue();
2113 if (rAttr.GetItemState(SDRATTR_TRANSFORMREF2X,TRUE,&pPoolItem)==SFX_ITEM_SET) {
2114 aRef2.X()=((const SdrTransformRef2XItem*)pPoolItem)->GetValue();
2116 if (rAttr.GetItemState(SDRATTR_TRANSFORMREF2Y,TRUE,&pPoolItem)==SFX_ITEM_SET) {
2117 aRef2.Y()=((const SdrTransformRef2YItem*)pPoolItem)->GetValue();
2120 Rectangle aNewSnap(rSnap);
2121 if (rAttr.GetItemState(SDRATTR_MOVEX,TRUE,&pPoolItem)==SFX_ITEM_SET) {
2122 long n=((const SdrMoveXItem*)pPoolItem)->GetValue();
2123 aNewSnap.Move(n,0);
2125 if (rAttr.GetItemState(SDRATTR_MOVEY,TRUE,&pPoolItem)==SFX_ITEM_SET) {
2126 long n=((const SdrMoveYItem*)pPoolItem)->GetValue();
2127 aNewSnap.Move(0,n);
2129 if (rAttr.GetItemState(SDRATTR_ONEPOSITIONX,TRUE,&pPoolItem)==SFX_ITEM_SET) {
2130 long n=((const SdrOnePositionXItem*)pPoolItem)->GetValue();
2131 aNewSnap.Move(n-aNewSnap.Left(),0);
2133 if (rAttr.GetItemState(SDRATTR_ONEPOSITIONY,TRUE,&pPoolItem)==SFX_ITEM_SET) {
2134 long n=((const SdrOnePositionYItem*)pPoolItem)->GetValue();
2135 aNewSnap.Move(0,n-aNewSnap.Top());
2137 if (rAttr.GetItemState(SDRATTR_ONESIZEWIDTH,TRUE,&pPoolItem)==SFX_ITEM_SET) {
2138 long n=((const SdrOneSizeWidthItem*)pPoolItem)->GetValue();
2139 aNewSnap.Right()=aNewSnap.Left()+n;
2141 if (rAttr.GetItemState(SDRATTR_ONESIZEHEIGHT,TRUE,&pPoolItem)==SFX_ITEM_SET) {
2142 long n=((const SdrOneSizeHeightItem*)pPoolItem)->GetValue();
2143 aNewSnap.Bottom()=aNewSnap.Top()+n;
2145 if (aNewSnap!=rSnap) {
2146 if (aNewSnap.GetSize()==rSnap.GetSize()) {
2147 NbcMove(Size(aNewSnap.Left()-rSnap.Left(),aNewSnap.Top()-rSnap.Top()));
2148 } else {
2149 NbcSetSnapRect(aNewSnap);
2153 if (rAttr.GetItemState(SDRATTR_SHEARANGLE,TRUE,&pPoolItem)==SFX_ITEM_SET) {
2154 long n=((const SdrShearAngleItem*)pPoolItem)->GetValue();
2155 n-=GetShearAngle();
2156 if (n!=0) {
2157 double nTan=tan(n*nPi180);
2158 NbcShear(aRef1,n,nTan,FALSE);
2161 if (rAttr.GetItemState(SDRATTR_ROTATEANGLE,TRUE,&pPoolItem)==SFX_ITEM_SET) {
2162 long n=((const SdrRotateAngleItem*)pPoolItem)->GetValue();
2163 n-=GetRotateAngle();
2164 if (n!=0) {
2165 double nSin=sin(n*nPi180);
2166 double nCos=cos(n*nPi180);
2167 NbcRotate(aRef1,n,nSin,nCos);
2170 if (rAttr.GetItemState(SDRATTR_ROTATEONE,TRUE,&pPoolItem)==SFX_ITEM_SET) {
2171 long n=((const SdrRotateOneItem*)pPoolItem)->GetValue();
2172 double nSin=sin(n*nPi180);
2173 double nCos=cos(n*nPi180);
2174 NbcRotate(aRef1,n,nSin,nCos);
2176 if (rAttr.GetItemState(SDRATTR_HORZSHEARONE,TRUE,&pPoolItem)==SFX_ITEM_SET) {
2177 long n=((const SdrHorzShearOneItem*)pPoolItem)->GetValue();
2178 double nTan=tan(n*nPi180);
2179 NbcShear(aRef1,n,nTan,FALSE);
2181 if (rAttr.GetItemState(SDRATTR_VERTSHEARONE,TRUE,&pPoolItem)==SFX_ITEM_SET) {
2182 long n=((const SdrVertShearOneItem*)pPoolItem)->GetValue();
2183 double nTan=tan(n*nPi180);
2184 NbcShear(aRef1,n,nTan,TRUE);
2187 if (rAttr.GetItemState(SDRATTR_OBJMOVEPROTECT,TRUE,&pPoolItem)==SFX_ITEM_SET) {
2188 bool b=((const SdrObjMoveProtectItem*)pPoolItem)->GetValue();
2189 SetMoveProtect(b);
2191 if (rAttr.GetItemState(SDRATTR_OBJSIZEPROTECT,TRUE,&pPoolItem)==SFX_ITEM_SET) {
2192 bool b=((const SdrObjSizeProtectItem*)pPoolItem)->GetValue();
2193 SetResizeProtect(b);
2196 /* #67368# move protect always sets size protect */
2197 if( IsMoveProtect() )
2198 SetResizeProtect( true );
2200 if (rAttr.GetItemState(SDRATTR_OBJPRINTABLE,TRUE,&pPoolItem)==SFX_ITEM_SET) {
2201 bool b=((const SdrObjPrintableItem*)pPoolItem)->GetValue();
2202 SetPrintable(b);
2205 SdrLayerID nLayer=SDRLAYER_NOTFOUND;
2206 if (rAttr.GetItemState(SDRATTR_LAYERID,TRUE,&pPoolItem)==SFX_ITEM_SET) {
2207 nLayer=((const SdrLayerIdItem*)pPoolItem)->GetValue();
2209 if (rAttr.GetItemState(SDRATTR_LAYERNAME,TRUE,&pPoolItem)==SFX_ITEM_SET && pModel!=NULL) {
2210 XubString aLayerName=((const SdrLayerNameItem*)pPoolItem)->GetValue();
2211 const SdrLayerAdmin* pLayAd=pPage!=NULL ? &pPage->GetLayerAdmin() : pModel!=NULL ? &pModel->GetLayerAdmin() : NULL;
2212 if (pLayAd!=NULL) {
2213 const SdrLayer* pLayer=pLayAd->GetLayer(aLayerName, TRUE);
2214 if (pLayer!=NULL) {
2215 nLayer=pLayer->GetID();
2220 if (nLayer!=SDRLAYER_NOTFOUND) {
2221 NbcSetLayer(nLayer);
2224 if (rAttr.GetItemState(SDRATTR_OBJECTNAME,TRUE,&pPoolItem)==SFX_ITEM_SET) {
2225 XubString aName=((const SdrObjectNameItem*)pPoolItem)->GetValue();
2226 SetName(aName);
2228 Rectangle aNewLogic(rLogic);
2229 if (rAttr.GetItemState(SDRATTR_LOGICSIZEWIDTH,TRUE,&pPoolItem)==SFX_ITEM_SET) {
2230 long n=((const SdrLogicSizeWidthItem*)pPoolItem)->GetValue();
2231 aNewLogic.Right()=aNewLogic.Left()+n;
2233 if (rAttr.GetItemState(SDRATTR_LOGICSIZEHEIGHT,TRUE,&pPoolItem)==SFX_ITEM_SET) {
2234 long n=((const SdrLogicSizeHeightItem*)pPoolItem)->GetValue();
2235 aNewLogic.Bottom()=aNewLogic.Top()+n;
2237 if (aNewLogic!=rLogic) {
2238 NbcSetLogicRect(aNewLogic);
2240 Fraction aResizeX(1,1);
2241 Fraction aResizeY(1,1);
2242 if (rAttr.GetItemState(SDRATTR_RESIZEXONE,TRUE,&pPoolItem)==SFX_ITEM_SET) {
2243 aResizeX*=((const SdrResizeXOneItem*)pPoolItem)->GetValue();
2245 if (rAttr.GetItemState(SDRATTR_RESIZEYONE,TRUE,&pPoolItem)==SFX_ITEM_SET) {
2246 aResizeY*=((const SdrResizeYOneItem*)pPoolItem)->GetValue();
2248 if (aResizeX!=Fraction(1,1) || aResizeY!=Fraction(1,1)) {
2249 NbcResize(aRef1,aResizeX,aResizeY);
2253 void lcl_SetItem(SfxItemSet& rAttr, FASTBOOL bMerge, const SfxPoolItem& rItem)
2255 if (bMerge) rAttr.MergeValue(rItem,TRUE);
2256 else rAttr.Put(rItem);
2259 void SdrObject::TakeNotPersistAttr(SfxItemSet& rAttr, FASTBOOL bMerge) const
2261 const Rectangle& rSnap=GetSnapRect();
2262 const Rectangle& rLogic=GetLogicRect();
2263 lcl_SetItem(rAttr,bMerge,SdrObjMoveProtectItem(IsMoveProtect()));
2264 lcl_SetItem(rAttr,bMerge,SdrObjSizeProtectItem(IsResizeProtect()));
2265 lcl_SetItem(rAttr,bMerge,SdrObjPrintableItem(IsPrintable()));
2266 lcl_SetItem(rAttr,bMerge,SdrRotateAngleItem(GetRotateAngle()));
2267 lcl_SetItem(rAttr,bMerge,SdrShearAngleItem(GetShearAngle()));
2268 lcl_SetItem(rAttr,bMerge,SdrOneSizeWidthItem(rSnap.GetWidth()-1));
2269 lcl_SetItem(rAttr,bMerge,SdrOneSizeHeightItem(rSnap.GetHeight()-1));
2270 lcl_SetItem(rAttr,bMerge,SdrOnePositionXItem(rSnap.Left()));
2271 lcl_SetItem(rAttr,bMerge,SdrOnePositionYItem(rSnap.Top()));
2272 if (rLogic.GetWidth()!=rSnap.GetWidth()) {
2273 lcl_SetItem(rAttr,bMerge,SdrLogicSizeWidthItem(rLogic.GetWidth()-1));
2275 if (rLogic.GetHeight()!=rSnap.GetHeight()) {
2276 lcl_SetItem(rAttr,bMerge,SdrLogicSizeHeightItem(rLogic.GetHeight()-1));
2278 XubString aName(GetName());
2280 if(aName.Len())
2282 lcl_SetItem(rAttr, bMerge, SdrObjectNameItem(aName));
2285 lcl_SetItem(rAttr,bMerge,SdrLayerIdItem(GetLayer()));
2286 const SdrLayerAdmin* pLayAd=pPage!=NULL ? &pPage->GetLayerAdmin() : pModel!=NULL ? &pModel->GetLayerAdmin() : NULL;
2287 if (pLayAd!=NULL) {
2288 const SdrLayer* pLayer=pLayAd->GetLayerPerID(GetLayer());
2289 if (pLayer!=NULL) {
2290 lcl_SetItem(rAttr,bMerge,SdrLayerNameItem(pLayer->GetName()));
2293 Point aRef1(rSnap.Center());
2294 Point aRef2(aRef1); aRef2.Y()++;
2295 lcl_SetItem(rAttr,bMerge,SdrTransformRef1XItem(aRef1.X()));
2296 lcl_SetItem(rAttr,bMerge,SdrTransformRef1YItem(aRef1.Y()));
2297 lcl_SetItem(rAttr,bMerge,SdrTransformRef2XItem(aRef2.X()));
2298 lcl_SetItem(rAttr,bMerge,SdrTransformRef2YItem(aRef2.Y()));
2301 SfxStyleSheet* SdrObject::GetStyleSheet() const
2303 return GetProperties().GetStyleSheet();
2306 void SdrObject::SetStyleSheet(SfxStyleSheet* pNewStyleSheet, sal_Bool bDontRemoveHardAttr)
2308 Rectangle aBoundRect0;
2310 if(pUserCall)
2311 aBoundRect0 = GetLastBoundRect();
2313 // #110094#-14 SendRepaintBroadcast();
2314 NbcSetStyleSheet(pNewStyleSheet, bDontRemoveHardAttr);
2315 SetChanged();
2316 BroadcastObjectChange();
2317 SendUserCall(SDRUSERCALL_CHGATTR, aBoundRect0);
2320 void SdrObject::NbcSetStyleSheet(SfxStyleSheet* pNewStyleSheet, sal_Bool bDontRemoveHardAttr)
2322 // only allow graphic and presentation styles for shapes
2323 if( pNewStyleSheet && (pNewStyleSheet->GetFamily() == SFX_STYLE_FAMILY_PARA) && (pNewStyleSheet->GetFamily() == SFX_STYLE_FAMILY_PAGE) )
2324 return;
2326 GetProperties().SetStyleSheet(pNewStyleSheet, bDontRemoveHardAttr);
2329 // Das Broadcasting beim Setzen der Attribute wird vom AttrObj gemanagt
2330 ////////////////////////////////////////////////////////////////////////////////////////////////////
2332 FASTBOOL SdrObject::IsNode() const
2334 return TRUE;
2337 SdrGluePoint SdrObject::GetVertexGluePoint(USHORT nPosNum) const
2339 // #i41936# Use SnapRect for default GluePoints
2340 const Rectangle aR(GetSnapRect());
2341 Point aPt;
2343 switch(nPosNum)
2345 case 0 : aPt = aR.TopCenter(); break;
2346 case 1 : aPt = aR.RightCenter(); break;
2347 case 2 : aPt = aR.BottomCenter(); break;
2348 case 3 : aPt = aR.LeftCenter(); break;
2351 aPt -= aR.Center();
2352 SdrGluePoint aGP(aPt);
2353 aGP.SetPercent(FALSE);
2355 return aGP;
2358 SdrGluePoint SdrObject::GetCornerGluePoint(USHORT nPosNum) const
2360 Rectangle aR(GetCurrentBoundRect());
2361 Point aPt;
2362 switch (nPosNum) {
2363 case 0 : aPt=aR.TopLeft(); break;
2364 case 1 : aPt=aR.TopRight(); break;
2365 case 2 : aPt=aR.BottomRight(); break;
2366 case 3 : aPt=aR.BottomLeft(); break;
2368 aPt-=GetSnapRect().Center();
2369 SdrGluePoint aGP(aPt);
2370 aGP.SetPercent(FALSE);
2371 return aGP;
2374 const SdrGluePointList* SdrObject::GetGluePointList() const
2376 if (pPlusData!=NULL) return pPlusData->pGluePoints;
2377 return NULL;
2380 //SdrGluePointList* SdrObject::GetGluePointList()
2382 // if (pPlusData!=NULL) return pPlusData->pGluePoints;
2383 // return NULL;
2386 SdrGluePointList* SdrObject::ForceGluePointList()
2388 ImpForcePlusData();
2389 if (pPlusData->pGluePoints==NULL) {
2390 pPlusData->pGluePoints=new SdrGluePointList;
2392 return pPlusData->pGluePoints;
2395 void SdrObject::SetGlueReallyAbsolute(FASTBOOL bOn)
2397 // erst Const-Aufruf um zu sehen, ob
2398 // ueberhaupt Klebepunkte da sind
2399 // const-Aufruf erzwingen!
2400 if (GetGluePointList()!=NULL) {
2401 SdrGluePointList* pGPL=ForceGluePointList();
2402 pGPL->SetReallyAbsolute(bOn,*this);
2406 void SdrObject::NbcRotateGluePoints(const Point& rRef, long nWink, double sn, double cs)
2408 // erst Const-Aufruf um zu sehen, ob
2409 // ueberhaupt Klebepunkte da sind
2410 // const-Aufruf erzwingen!
2411 if (GetGluePointList()!=NULL) {
2412 SdrGluePointList* pGPL=ForceGluePointList();
2413 pGPL->Rotate(rRef,nWink,sn,cs,this);
2417 void SdrObject::NbcMirrorGluePoints(const Point& rRef1, const Point& rRef2)
2419 // erst Const-Aufruf um zu sehen, ob
2420 // ueberhaupt Klebepunkte da sind
2421 // const-Aufruf erzwingen!
2422 if (GetGluePointList()!=NULL) {
2423 SdrGluePointList* pGPL=ForceGluePointList();
2424 pGPL->Mirror(rRef1,rRef2,this);
2428 void SdrObject::NbcShearGluePoints(const Point& rRef, long nWink, double tn, FASTBOOL bVShear)
2430 // erst Const-Aufruf um zu sehen, ob
2431 // ueberhaupt Klebepunkte da sind
2432 // const-Aufruf erzwingen!
2433 if (GetGluePointList()!=NULL) {
2434 SdrGluePointList* pGPL=ForceGluePointList();
2435 pGPL->Shear(rRef,nWink,tn,bVShear,this);
2439 FASTBOOL SdrObject::IsEdge() const
2441 return FALSE;
2444 void SdrObject::ConnectToNode(FASTBOOL /*bTail1*/, SdrObject* /*pObj*/)
2448 void SdrObject::DisconnectFromNode(FASTBOOL /*bTail1*/)
2452 SdrObject* SdrObject::GetConnectedNode(FASTBOOL /*bTail1*/) const
2454 return NULL;
2457 ////////////////////////////////////////////////////////////////////////////////////////////////////
2459 SdrObject* SdrObject::ImpConvertToContourObj(SdrObject* pRet, BOOL bForceLineDash) const
2461 bool bNoChange(true);
2463 if(pRet->LineGeometryUsageIsNecessary())
2465 basegfx::B2DPolyPolygon aMergedLineFillPolyPolygon;
2466 basegfx::B2DPolyPolygon aMergedHairlinePolyPolygon;
2467 const drawinglayer::primitive2d::Primitive2DSequence xSequence(pRet->GetViewContact().getViewIndependentPrimitive2DSequence());
2469 if(xSequence.hasElements())
2471 // use neutral ViewInformation
2472 const drawinglayer::geometry::ViewInformation2D aViewInformation2D(0);
2474 // create extractor, process and get result
2475 drawinglayer::processor2d::LineGeometryExtractor2D aExtractor(aViewInformation2D);
2476 aExtractor.process(xSequence);
2478 // #i102241# check for line results
2479 const std::vector< basegfx::B2DPolygon >& rHairlineVector = aExtractor.getExtractedHairlines();
2481 if(rHairlineVector.size())
2483 // for SdrObject creation, just copy all to a single Hairline-PolyPolygon
2484 for(sal_uInt32 a(0); a < rHairlineVector.size(); a++)
2486 aMergedHairlinePolyPolygon.append(rHairlineVector[a]);
2490 // #i102241# check for fill rsults
2491 const std::vector< basegfx::B2DPolyPolygon >& rLineFillVector(aExtractor.getExtractedLineFills());
2493 if(rLineFillVector.size())
2495 // merge to a single PolyPolygon (OR)
2496 aMergedLineFillPolyPolygon = basegfx::tools::mergeToSinglePolyPolygon(rLineFillVector);
2500 // || aMergedHairlinePolyPolygon.Count() removed; the conversion is ONLY
2501 // useful when new closed filled polygons are created
2502 if(aMergedLineFillPolyPolygon.count() || (bForceLineDash && aMergedHairlinePolyPolygon.count()))
2504 SfxItemSet aSet(pRet->GetMergedItemSet());
2505 XFillStyle eOldFillStyle = ((const XFillStyleItem&)(aSet.Get(XATTR_FILLSTYLE))).GetValue();
2506 SdrPathObj* aLinePolygonPart = NULL;
2507 SdrPathObj* aLineHairlinePart = NULL;
2508 bool bBuildGroup(false);
2510 if(aMergedLineFillPolyPolygon.count())
2512 // create SdrObject for filled line geometry
2513 aLinePolygonPart = new SdrPathObj(OBJ_PATHFILL, aMergedLineFillPolyPolygon);
2514 aLinePolygonPart->SetModel(pRet->GetModel());
2516 // correct item properties
2517 aSet.Put(XLineWidthItem(0L));
2518 aSet.Put(XLineStyleItem(XLINE_NONE));
2519 Color aColorLine = ((const XLineColorItem&)(aSet.Get(XATTR_LINECOLOR))).GetColorValue();
2520 UINT16 nTransLine = ((const XLineTransparenceItem&)(aSet.Get(XATTR_LINETRANSPARENCE))).GetValue();
2521 aSet.Put(XFillColorItem(XubString(), aColorLine));
2522 aSet.Put(XFillStyleItem(XFILL_SOLID));
2523 aSet.Put(XFillTransparenceItem(nTransLine));
2525 aLinePolygonPart->SetMergedItemSet(aSet);
2528 if(aMergedHairlinePolyPolygon.count())
2530 // create SdrObject for hairline geometry
2531 // OBJ_PATHLINE is necessary here, not OBJ_PATHFILL. This is intended
2532 // to get a non-filled object. If the poly is closed, the PathObj takes care for
2533 // the correct closed state.
2534 aLineHairlinePart = new SdrPathObj(OBJ_PATHLINE, aMergedHairlinePolyPolygon);
2535 aLineHairlinePart->SetModel(pRet->GetModel());
2537 aSet.Put(XLineWidthItem(0L));
2538 aSet.Put(XFillStyleItem(XFILL_NONE));
2539 aSet.Put(XLineStyleItem(XLINE_SOLID));
2541 // it is also necessary to switch off line start and ends here
2542 aSet.Put(XLineStartWidthItem(0));
2543 aSet.Put(XLineEndWidthItem(0));
2545 aLineHairlinePart->SetMergedItemSet(aSet);
2547 if(aLinePolygonPart)
2549 bBuildGroup = true;
2553 // check if original geometry should be added (e.g. filled and closed)
2554 bool bAddOriginalGeometry(false);
2555 SdrPathObj* pPath = PTR_CAST(SdrPathObj, pRet);
2557 if(pPath && pPath->IsClosed())
2559 if(eOldFillStyle != XFILL_NONE)
2561 // #107600# use new boolean here
2562 bAddOriginalGeometry = true;
2566 // do we need a group?
2567 if(bBuildGroup || bAddOriginalGeometry)
2569 SdrObject* pGroup = new SdrObjGroup;
2570 pGroup->SetModel(pRet->GetModel());
2572 if(bAddOriginalGeometry)
2574 // Add a clone of the original geometry.
2575 aSet.ClearItem();
2576 aSet.Put(pRet->GetMergedItemSet());
2577 aSet.Put(XLineStyleItem(XLINE_NONE));
2578 aSet.Put(XLineWidthItem(0L));
2580 SdrObject* pClone = pRet->Clone();
2582 pClone->SetModel(pRet->GetModel());
2583 pClone->SetMergedItemSet(aSet);
2585 pGroup->GetSubList()->NbcInsertObject(pClone);
2588 if(aLinePolygonPart)
2590 pGroup->GetSubList()->NbcInsertObject(aLinePolygonPart);
2593 if(aLineHairlinePart)
2595 pGroup->GetSubList()->NbcInsertObject(aLineHairlinePart);
2598 pRet = pGroup;
2600 // be more careful with the state describing bool
2601 bNoChange = false;
2603 else
2605 if(aLinePolygonPart)
2607 pRet = aLinePolygonPart;
2608 // be more careful with the state describing bool
2609 bNoChange = false;
2611 else if(aLineHairlinePart)
2613 pRet = aLineHairlinePart;
2614 // be more careful with the state describing bool
2615 bNoChange = false;
2621 if(bNoChange)
2623 // due to current method usage, create and return a clone when nothing has changed
2624 SdrObject* pClone = pRet->Clone();
2625 pClone->SetModel(pRet->GetModel());
2626 pRet = pClone;
2629 return pRet;
2632 // convert this path object to contour object, even when it is a group
2633 SdrObject* SdrObject::ConvertToContourObj(SdrObject* pRet, BOOL bForceLineDash) const
2635 if(pRet->ISA(SdrObjGroup))
2637 SdrObjList* pObjList2 = pRet->GetSubList();
2638 SdrObject* pGroup = new SdrObjGroup;
2639 pGroup->SetModel(pRet->GetModel());
2641 for(UINT32 a=0;a<pObjList2->GetObjCount();a++)
2643 SdrObject* pIterObj = pObjList2->GetObj(a);
2644 pGroup->GetSubList()->NbcInsertObject(ConvertToContourObj(pIterObj, bForceLineDash));
2647 pRet = pGroup;
2649 else
2651 if(pRet && pRet->ISA(SdrPathObj))
2653 SdrPathObj* pPathObj = (SdrPathObj*)pRet;
2655 // bezier geometry got created, even for straight edges since the given
2656 // object is a result of DoConvertToPolyObj. For conversion to contour
2657 // this is not really needed and can be reduced again AFAP
2658 pPathObj->SetPathPoly(basegfx::tools::simplifyCurveSegments(pPathObj->GetPathPoly()));
2661 pRet = ImpConvertToContourObj(pRet, bForceLineDash);
2664 // #i73441# preserve LayerID
2665 if(pRet && pRet->GetLayer() != GetLayer())
2667 pRet->SetLayer(GetLayer());
2670 return pRet;
2673 ////////////////////////////////////////////////////////////////////////////////////////////////////
2675 SdrObject* SdrObject::ConvertToPolyObj(BOOL bBezier, BOOL bLineToArea) const
2677 SdrObject* pRet = DoConvertToPolyObj(bBezier);
2679 if(pRet && bLineToArea)
2681 SdrObject* pNewRet = ConvertToContourObj(pRet);
2682 delete pRet;
2683 pRet = pNewRet;
2686 // #i73441# preserve LayerID
2687 if(pRet && pRet->GetLayer() != GetLayer())
2689 pRet->SetLayer(GetLayer());
2692 return pRet;
2695 ////////////////////////////////////////////////////////////////////////////////////////////////////
2697 SdrObject* SdrObject::DoConvertToPolyObj(BOOL /*bBezier*/) const
2699 return NULL;
2702 ////////////////////////////////////////////////////////////////////////////////////////////////////
2704 void SdrObject::SetInserted(sal_Bool bIns)
2706 if (bIns!=IsInserted()) {
2707 bInserted=bIns;
2708 Rectangle aBoundRect0(GetLastBoundRect());
2709 if (bIns) SendUserCall(SDRUSERCALL_INSERTED,aBoundRect0);
2710 else SendUserCall(SDRUSERCALL_REMOVED,aBoundRect0);
2712 if (pPlusData!=NULL && pPlusData->pBroadcast!=NULL) { // #42522#
2713 SdrHint aHint(*this);
2714 aHint.SetKind(bIns?HINT_OBJINSERTED:HINT_OBJREMOVED);
2715 pPlusData->pBroadcast->Broadcast(aHint);
2720 void SdrObject::SetMoveProtect(sal_Bool bProt)
2722 if(IsMoveProtect() != bProt)
2724 // #i77187# secured and simplified
2725 bMovProt = bProt;
2726 SetChanged();
2727 BroadcastObjectChange();
2731 void SdrObject::SetResizeProtect(sal_Bool bProt)
2733 if(IsResizeProtect() != bProt)
2735 // #i77187# secured and simplified
2736 bSizProt = bProt;
2737 SetChanged();
2738 BroadcastObjectChange();
2742 void SdrObject::SetPrintable(sal_Bool bPrn)
2744 bNoPrint=!bPrn;
2745 SetChanged();
2746 if (IsInserted() && pModel!=NULL) {
2747 SdrHint aHint(*this);
2748 pModel->Broadcast(aHint);
2752 ////////////////////////////////////////////////////////////////////////////////////////////////////
2754 USHORT SdrObject::GetUserDataCount() const
2756 if (pPlusData==NULL || pPlusData->pUserDataList==NULL) return 0;
2757 return pPlusData->pUserDataList->GetUserDataCount();
2760 SdrObjUserData* SdrObject::GetUserData(USHORT nNum) const
2762 if (pPlusData==NULL || pPlusData->pUserDataList==NULL) return NULL;
2763 return pPlusData->pUserDataList->GetUserData(nNum);
2766 void SdrObject::InsertUserData(SdrObjUserData* pData, USHORT nPos)
2768 if (pData!=NULL) {
2769 ImpForcePlusData();
2770 if (pPlusData->pUserDataList==NULL) pPlusData->pUserDataList=new SdrObjUserDataList;
2771 pPlusData->pUserDataList->InsertUserData(pData,nPos);
2772 } else {
2773 DBG_ERROR("SdrObject::InsertUserData(): pData ist NULL-Pointer");
2777 void SdrObject::DeleteUserData(USHORT nNum)
2779 USHORT nAnz=GetUserDataCount();
2780 if (nNum<nAnz) {
2781 pPlusData->pUserDataList->DeleteUserData(nNum);
2782 if (nAnz==1) {
2783 delete pPlusData->pUserDataList;
2784 pPlusData->pUserDataList=NULL;
2786 } else {
2787 DBG_ERROR("SdrObject::DeleteUserData(): ungueltiger Index");
2791 void SdrObject::SendUserCall(SdrUserCallType eUserCall, const Rectangle& rBoundRect) const
2793 SdrObjGroup* pGroup = NULL;
2795 if( pObjList && pObjList->GetListKind() == SDROBJLIST_GROUPOBJ )
2796 pGroup = (SdrObjGroup*) pObjList->GetOwnerObj();
2798 if ( pUserCall )
2800 // UserCall ausfuehren
2801 pUserCall->Changed( *this, eUserCall, rBoundRect );
2804 while( pGroup )
2806 // Gruppe benachrichtigen
2807 if( pGroup->GetUserCall() )
2809 SdrUserCallType eChildUserType = SDRUSERCALL_CHILD_CHGATTR;
2811 switch( eUserCall )
2813 case SDRUSERCALL_MOVEONLY:
2814 eChildUserType = SDRUSERCALL_CHILD_MOVEONLY;
2815 break;
2817 case SDRUSERCALL_RESIZE:
2818 eChildUserType = SDRUSERCALL_CHILD_RESIZE;
2819 break;
2821 case SDRUSERCALL_CHGATTR:
2822 eChildUserType = SDRUSERCALL_CHILD_CHGATTR;
2823 break;
2825 case SDRUSERCALL_DELETE:
2826 eChildUserType = SDRUSERCALL_CHILD_DELETE;
2827 break;
2829 case SDRUSERCALL_COPY:
2830 eChildUserType = SDRUSERCALL_CHILD_COPY;
2831 break;
2833 case SDRUSERCALL_INSERTED:
2834 eChildUserType = SDRUSERCALL_CHILD_INSERTED;
2835 break;
2837 case SDRUSERCALL_REMOVED:
2838 eChildUserType = SDRUSERCALL_CHILD_REMOVED;
2839 break;
2841 default: break;
2844 pGroup->GetUserCall()->Changed( *this, eChildUserType, rBoundRect );
2847 if( pGroup->GetObjList() &&
2848 pGroup->GetObjList()->GetListKind() == SDROBJLIST_GROUPOBJ &&
2849 pGroup != (SdrObjGroup*) pObjList->GetOwnerObj() )
2850 pGroup = (SdrObjGroup*) pObjList->GetOwnerObj();
2851 else
2852 pGroup = NULL;
2855 // notify our UNO shape listeners
2856 switch ( eUserCall )
2858 case SDRUSERCALL_RESIZE:
2859 notifyShapePropertyChange( ::svx::eShapeSize );
2860 // fall through - RESIZE might also imply a change of the position
2861 case SDRUSERCALL_MOVEONLY:
2862 notifyShapePropertyChange( ::svx::eShapePosition );
2863 break;
2864 default:
2865 // not interested in
2866 break;
2870 // ItemPool fuer dieses Objekt wechseln
2871 void SdrObject::MigrateItemPool(SfxItemPool* pSrcPool, SfxItemPool* pDestPool, SdrModel* pNewModel)
2873 if(pSrcPool && pDestPool && (pSrcPool != pDestPool))
2875 GetProperties().MoveToItemPool(pSrcPool, pDestPool, pNewModel);
2879 sal_Bool SdrObject::IsTransparent( BOOL /*bCheckForAlphaChannel*/) const
2881 bool bRet = false;
2883 if( IsGroupObject() )
2885 SdrObjListIter aIter( *GetSubList(), IM_DEEPNOGROUPS );
2887 for( SdrObject* pO = aIter.Next(); pO && !bRet; pO = aIter.Next() )
2889 const SfxItemSet& rAttr = pO->GetMergedItemSet();
2891 if( ( ( (const XFillTransparenceItem&) rAttr.Get( XATTR_FILLTRANSPARENCE ) ).GetValue() ||
2892 ( (const XLineTransparenceItem&) rAttr.Get( XATTR_LINETRANSPARENCE ) ).GetValue() ) ||
2893 ( ( rAttr.GetItemState( XATTR_FILLFLOATTRANSPARENCE ) == SFX_ITEM_SET ) &&
2894 ( (const XFillFloatTransparenceItem&) rAttr.Get( XATTR_FILLFLOATTRANSPARENCE ) ).IsEnabled() ) )
2896 bRet = TRUE;
2898 else if( pO->ISA( SdrGrafObj ) )
2900 SdrGrafObj* pGrafObj = (SdrGrafObj*) pO;
2901 if( ( (const SdrGrafTransparenceItem&) rAttr.Get( SDRATTR_GRAFTRANSPARENCE ) ).GetValue() ||
2902 ( pGrafObj->GetGraphicType() == GRAPHIC_BITMAP && pGrafObj->GetGraphic().GetBitmapEx().IsAlpha() ) )
2904 bRet = TRUE;
2909 else
2911 const SfxItemSet& rAttr = GetMergedItemSet();
2913 if( ( ( (const XFillTransparenceItem&) rAttr.Get( XATTR_FILLTRANSPARENCE ) ).GetValue() ||
2914 ( (const XLineTransparenceItem&) rAttr.Get( XATTR_LINETRANSPARENCE ) ).GetValue() ) ||
2915 ( ( rAttr.GetItemState( XATTR_FILLFLOATTRANSPARENCE ) == SFX_ITEM_SET ) &&
2916 ( (const XFillFloatTransparenceItem&) rAttr.Get( XATTR_FILLFLOATTRANSPARENCE ) ).IsEnabled() ) )
2918 bRet = TRUE;
2920 else if( ISA( SdrGrafObj ) )
2922 SdrGrafObj* pGrafObj = (SdrGrafObj*) this;
2924 // #i25616#
2925 bRet = pGrafObj->IsObjectTransparent();
2929 return bRet;
2932 void SdrObject::impl_setUnoShape( const uno::Reference< uno::XInterface >& _rxUnoShape )
2934 maWeakUnoShape = _rxUnoShape;
2935 mpSvxShape = SvxShape::getImplementation( _rxUnoShape );
2936 // OSL_ENSURE( mpSvxShape || !_rxUnoShape.is(),
2937 // "SdrObject::setUnoShape: not sure it's a good idea to have an XShape which is not implemented by SvxShape ..." );
2940 /** only for internal use! */
2941 SvxShape* SdrObject::getSvxShape() const
2943 DBG_TESTSOLARMUTEX();
2944 // retrieving the impl pointer and subsequently using it is not thread-safe, of course, so it needs to be
2945 // guarded by the SolarMutex
2947 #if OSL_DEBUG_LEVE > 0
2948 uno::Reference< uno::XInterface > xShape( maWeakUnoShape );
2949 OSL_ENSURE( !( !xShapeGuard.is() && mpSvxShape ),
2950 "SdrObject::getSvxShape: still having IMPL-Pointer to dead object!" );
2951 #endif
2953 return mpSvxShape;
2956 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SdrObject::getUnoShape()
2958 // try weak reference first
2959 uno::Reference< uno::XInterface > xShape( getWeakUnoShape() );
2960 if( !xShape.is() )
2962 OSL_ENSURE( mpSvxShape == NULL, "SdrObject::getUnoShape: XShape already dead, but still an IMPL pointer!" );
2963 if ( pPage )
2965 uno::Reference< uno::XInterface > xPage( pPage->getUnoPage() );
2966 if( xPage.is() )
2968 SvxDrawPage* pDrawPage = SvxDrawPage::getImplementation(xPage);
2969 if( pDrawPage )
2971 // create one
2972 xShape = pDrawPage->_CreateShape( this );
2973 impl_setUnoShape( xShape );
2977 else
2979 mpSvxShape = SvxDrawPage::CreateShapeByTypeAndInventor( GetObjIdentifier(), GetObjInventor(), this, NULL );
2980 maWeakUnoShape = xShape = static_cast< ::cppu::OWeakObject* >( mpSvxShape );
2984 return xShape;
2987 ::svx::PropertyChangeNotifier& SdrObject::getShapePropertyChangeNotifier()
2989 DBG_TESTSOLARMUTEX();
2991 SvxShape* pSvxShape = getSvxShape();
2992 ENSURE_OR_THROW( pSvxShape, "no SvxShape, yet!" );
2993 return pSvxShape->getShapePropertyChangeNotifier();
2996 void SdrObject::notifyShapePropertyChange( const ::svx::ShapeProperty _eProperty ) const
2998 DBG_TESTSOLARMUTEX();
3000 SvxShape* pSvxShape = const_cast< SdrObject* >( this )->getSvxShape();
3001 if ( pSvxShape )
3002 return pSvxShape->getShapePropertyChangeNotifier().notifyPropertyChange( _eProperty );
3005 ////////////////////////////////////////////////////////////////////////////////////////////////////
3007 // transformation interface for StarOfficeAPI. This implements support for
3008 // homogen 3x3 matrices containing the transformation of the SdrObject. At the
3009 // moment it contains a shearX, rotation and translation, but for setting all linear
3010 // transforms like Scale, ShearX, ShearY, Rotate and Translate are supported.
3012 ////////////////////////////////////////////////////////////////////////////////////////////////////
3013 // gets base transformation and rectangle of object. If it's an SdrPathObj it fills the PolyPolygon
3014 // with the base geometry and returns TRUE. Otherwise it returns FALSE.
3015 sal_Bool SdrObject::TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, basegfx::B2DPolyPolygon& /*rPolyPolygon*/) const
3017 // any kind of SdrObject, just use SnapRect
3018 Rectangle aRectangle(GetSnapRect());
3020 // convert to transformation values
3021 basegfx::B2DTuple aScale(aRectangle.GetWidth(), aRectangle.GetHeight());
3022 basegfx::B2DTuple aTranslate(aRectangle.Left(), aRectangle.Top());
3024 // position maybe relative to anchorpos, convert
3025 if( pModel && pModel->IsWriter() )
3027 if(GetAnchorPos().X() || GetAnchorPos().Y())
3029 aTranslate -= basegfx::B2DTuple(GetAnchorPos().X(), GetAnchorPos().Y());
3033 // force MapUnit to 100th mm
3034 SfxMapUnit eMapUnit = GetObjectItemSet().GetPool()->GetMetric(0);
3035 if(eMapUnit != SFX_MAPUNIT_100TH_MM)
3037 switch(eMapUnit)
3039 case SFX_MAPUNIT_TWIP :
3041 // postion
3042 aTranslate.setX(ImplTwipsToMM(aTranslate.getX()));
3043 aTranslate.setY(ImplTwipsToMM(aTranslate.getY()));
3045 // size
3046 aScale.setX(ImplTwipsToMM(aScale.getX()));
3047 aScale.setY(ImplTwipsToMM(aScale.getY()));
3049 break;
3051 default:
3053 DBG_ERROR("TRGetBaseGeometry: Missing unit translation to 100th mm!");
3058 // build matrix
3059 rMatrix.identity();
3061 if(1.0 != aScale.getX() || 1.0 != aScale.getY())
3063 rMatrix.scale(aScale.getX(), aScale.getY());
3066 if(0.0 != aTranslate.getX() || 0.0 != aTranslate.getY())
3068 rMatrix.translate(aTranslate.getX(), aTranslate.getY());
3071 return sal_False;
3074 // sets the base geometry of the object using infos contained in the homogen 3x3 matrix.
3075 // If it's an SdrPathObj it will use the provided geometry information. The Polygon has
3076 // to use (0,0) as upper left and will be scaled to the given size in the matrix.
3077 void SdrObject::TRSetBaseGeometry(const basegfx::B2DHomMatrix& rMatrix, const basegfx::B2DPolyPolygon& /*rPolyPolygon*/)
3079 // break up matrix
3080 basegfx::B2DTuple aScale;
3081 basegfx::B2DTuple aTranslate;
3082 double fRotate, fShearX;
3083 rMatrix.decompose(aScale, aTranslate, fRotate, fShearX);
3085 // #i75086# Old DrawingLayer (GeoStat and geometry) does not support holding negative scalings
3086 // in X and Y which equal a 180 degree rotation. Recognize it and react accordingly
3087 if(basegfx::fTools::less(aScale.getX(), 0.0) && basegfx::fTools::less(aScale.getY(), 0.0))
3089 aScale.setX(fabs(aScale.getX()));
3090 aScale.setY(fabs(aScale.getY()));
3091 fRotate = fmod(fRotate + F_PI, F_2PI);
3094 // force metric to pool metric
3095 SfxMapUnit eMapUnit = GetObjectItemSet().GetPool()->GetMetric(0);
3096 if(eMapUnit != SFX_MAPUNIT_100TH_MM)
3098 switch(eMapUnit)
3100 case SFX_MAPUNIT_TWIP :
3102 // position
3103 aTranslate.setX(ImplMMToTwips(aTranslate.getX()));
3104 aTranslate.setY(ImplMMToTwips(aTranslate.getY()));
3106 // size
3107 aScale.setX(ImplMMToTwips(aScale.getX()));
3108 aScale.setY(ImplMMToTwips(aScale.getY()));
3110 break;
3112 default:
3114 DBG_ERROR("TRSetBaseGeometry: Missing unit translation to PoolMetric!");
3119 // if anchor is used, make position relative to it
3120 if( pModel && pModel->IsWriter() )
3122 if(GetAnchorPos().X() || GetAnchorPos().Y())
3124 aTranslate += basegfx::B2DTuple(GetAnchorPos().X(), GetAnchorPos().Y());
3128 // build BaseRect
3129 Point aPoint(FRound(aTranslate.getX()), FRound(aTranslate.getY()));
3130 Rectangle aBaseRect(aPoint, Size(FRound(aScale.getX()), FRound(aScale.getY())));
3132 // set BaseRect
3133 SetSnapRect(aBaseRect);
3136 // #111111#
3137 // Needed again and again i will now add a test for finding out if
3138 // this object is the BackgroundObject of the page.
3139 sal_Bool SdrObject::IsMasterPageBackgroundObject() const
3141 if(pObjList
3142 && pObjList == pPage
3143 && pPage->IsMasterPage()
3144 && pObjList->GetObj(0) == this
3145 && 1L == (pPage->GetPageNum() % 2))
3147 // 0'th object, directly on page, page is MasterPage,
3148 // MasterPagePageNum is 1,3,5,...
3149 // --> It's the background object (!)
3150 return sal_True;
3153 return sal_False;
3156 // #116168#
3157 // Give info if object is in destruction
3158 sal_Bool SdrObject::IsInDestruction() const
3160 if(pModel)
3161 return pModel->IsInDestruction();
3162 return sal_False;
3165 // return if fill is != XFILL_NONE
3166 bool SdrObject::HasFillStyle() const
3168 return (((const XFillStyleItem&)GetObjectItem(XATTR_FILLSTYLE)).GetValue() != XFILL_NONE);
3171 bool SdrObject::HasLineStyle() const
3173 return (((const XLineStyleItem&)GetObjectItem(XATTR_LINESTYLE)).GetValue() != XLINE_NONE);
3177 // #i52224#
3178 // on import of OLE object from MS documents the BLIP size might be retrieved,
3179 // the following four methods are used to control it;
3180 // usually this data makes no sence after the import is finished, since the object
3181 // might be resized
3183 Rectangle SdrObject::GetBLIPSizeRectangle() const
3185 return maBLIPSizeRectangle;
3188 void SdrObject::SetBLIPSizeRectangle( const Rectangle& aRect )
3190 maBLIPSizeRectangle = aRect;
3193 void SdrObject::SetContextWritingMode( const sal_Int16 /*_nContextWritingMode*/ )
3195 // this base class does not support different writing modes, so ignore the call
3198 ////////////////////////////////////////////////////////////////////////////////////////////////////
3200 // @@@@ @@@@@ @@@@@@ @@@@@ @@@@ @@@@ @@@@@@ @@@@ @@@@@ @@ @@
3201 // @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@
3202 // @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@
3203 // @@ @@ @@@@@ @@ @@@@ @@@@@@ @@ @@ @@ @@ @@@@@ @@@@
3204 // @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@
3205 // @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@
3206 // @@@@ @@@@@ @@@@ @@ @@ @@ @@@@ @@ @@@@ @@ @@ @@
3208 ////////////////////////////////////////////////////////////////////////////////////////////////////
3210 SdrObjFactory::SdrObjFactory(UINT32 nInvent, UINT16 nIdent, SdrPage* pNewPage, SdrModel* pNewModel)
3212 nInventor=nInvent;
3213 nIdentifier=nIdent;
3214 pNewObj=NULL;
3215 pPage=pNewPage;
3216 pModel=pNewModel;
3217 pObj=NULL;
3218 pNewData=NULL;
3221 SdrObjFactory::SdrObjFactory(UINT32 nInvent, UINT16 nIdent, SdrObject* pObj1)
3223 nInventor=nInvent;
3224 nIdentifier=nIdent;
3225 pNewObj=NULL;
3226 pPage=NULL;
3227 pModel=NULL;
3228 pObj=pObj1;
3229 pNewData=NULL;
3232 SdrObject* SdrObjFactory::MakeNewObject(UINT32 nInvent, UINT16 nIdent, SdrPage* pPage, SdrModel* pModel)
3234 if(pModel == NULL && pPage != NULL)
3235 pModel = pPage->GetModel();
3236 SdrObject* pObj = NULL;
3238 if(nInvent == SdrInventor)
3240 switch (nIdent)
3242 case USHORT(OBJ_NONE ): pObj=new SdrObject; break;
3243 case USHORT(OBJ_GRUP ): pObj=new SdrObjGroup; break;
3244 case USHORT(OBJ_LINE ): pObj=new SdrPathObj(OBJ_LINE ); break;
3245 case USHORT(OBJ_POLY ): pObj=new SdrPathObj(OBJ_POLY ); break;
3246 case USHORT(OBJ_PLIN ): pObj=new SdrPathObj(OBJ_PLIN ); break;
3247 case USHORT(OBJ_PATHLINE ): pObj=new SdrPathObj(OBJ_PATHLINE ); break;
3248 case USHORT(OBJ_PATHFILL ): pObj=new SdrPathObj(OBJ_PATHFILL ); break;
3249 case USHORT(OBJ_FREELINE ): pObj=new SdrPathObj(OBJ_FREELINE ); break;
3250 case USHORT(OBJ_FREEFILL ): pObj=new SdrPathObj(OBJ_FREEFILL ); break;
3251 case USHORT(OBJ_PATHPOLY ): pObj=new SdrPathObj(OBJ_POLY ); break;
3252 case USHORT(OBJ_PATHPLIN ): pObj=new SdrPathObj(OBJ_PLIN ); break;
3253 case USHORT(OBJ_EDGE ): pObj=new SdrEdgeObj; break;
3254 case USHORT(OBJ_RECT ): pObj=new SdrRectObj; break;
3255 case USHORT(OBJ_CIRC ): pObj=new SdrCircObj(OBJ_CIRC ); break;
3256 case USHORT(OBJ_SECT ): pObj=new SdrCircObj(OBJ_SECT ); break;
3257 case USHORT(OBJ_CARC ): pObj=new SdrCircObj(OBJ_CARC ); break;
3258 case USHORT(OBJ_CCUT ): pObj=new SdrCircObj(OBJ_CCUT ); break;
3259 case USHORT(OBJ_TEXT ): pObj=new SdrRectObj(OBJ_TEXT ); break;
3260 case USHORT(OBJ_TEXTEXT ): pObj=new SdrRectObj(OBJ_TEXTEXT ); break;
3261 case USHORT(OBJ_TITLETEXT ): pObj=new SdrRectObj(OBJ_TITLETEXT ); break;
3262 case USHORT(OBJ_OUTLINETEXT): pObj=new SdrRectObj(OBJ_OUTLINETEXT); break;
3263 case USHORT(OBJ_MEASURE ): pObj=new SdrMeasureObj; break;
3264 case USHORT(OBJ_GRAF ): pObj=new SdrGrafObj; break;
3265 case USHORT(OBJ_OLE2 ): pObj=new SdrOle2Obj; break;
3266 case USHORT(OBJ_FRAME ): pObj=new SdrOle2Obj(TRUE); break;
3267 case USHORT(OBJ_CAPTION ): pObj=new SdrCaptionObj; break;
3268 case USHORT(OBJ_PAGE ): pObj=new SdrPageObj; break;
3269 case USHORT(OBJ_UNO ): pObj=new SdrUnoObj(String()); break;
3270 case USHORT(OBJ_CUSTOMSHAPE ): pObj=new SdrObjCustomShape(); break;
3271 case USHORT(OBJ_MEDIA ): pObj=new SdrMediaObj(); break;
3272 case USHORT(OBJ_TABLE ): pObj=new ::sdr::table::SdrTableObj(pModel); break;
3276 if(pObj == NULL)
3278 SdrObjFactory* pFact=new SdrObjFactory(nInvent,nIdent,pPage,pModel);
3279 SdrLinkList& rLL=ImpGetUserMakeObjHdl();
3280 unsigned nAnz=rLL.GetLinkCount();
3281 unsigned i=0;
3282 while (i<nAnz && pObj==NULL) {
3283 rLL.GetLink(i).Call((void*)pFact);
3284 pObj=pFact->pNewObj;
3285 i++;
3287 delete pFact;
3290 if(pObj == NULL)
3292 // Na wenn's denn keiner will ...
3295 if(pObj != NULL)
3297 if(pPage != NULL)
3298 pObj->SetPage(pPage);
3299 else if(pModel != NULL)
3300 pObj->SetModel(pModel);
3303 return pObj;
3306 SdrObjUserData* SdrObjFactory::MakeNewObjUserData(UINT32 nInvent, UINT16 nIdent, SdrObject* pObj1)
3308 SdrObjUserData* pData=NULL;
3309 if (nInvent==SdrInventor) {
3310 switch (nIdent)
3312 case USHORT(SDRUSERDATA_OBJTEXTLINK) : pData=new ImpSdrObjTextLinkUserData((SdrTextObj*)pObj1); break;
3315 if (pData==NULL) {
3316 SdrObjFactory aFact(nInvent,nIdent,pObj1);
3317 SdrLinkList& rLL=ImpGetUserMakeObjUserDataHdl();
3318 unsigned nAnz=rLL.GetLinkCount();
3319 unsigned i=0;
3320 while (i<nAnz && pData==NULL) {
3321 rLL.GetLink(i).Call((void*)&aFact);
3322 pData=aFact.pNewData;
3323 i++;
3326 return pData;
3329 void SdrObjFactory::InsertMakeObjectHdl(const Link& rLink)
3331 SdrLinkList& rLL=ImpGetUserMakeObjHdl();
3332 rLL.InsertLink(rLink);
3335 void SdrObjFactory::RemoveMakeObjectHdl(const Link& rLink)
3337 SdrLinkList& rLL=ImpGetUserMakeObjHdl();
3338 rLL.RemoveLink(rLink);
3341 void SdrObjFactory::InsertMakeUserDataHdl(const Link& rLink)
3343 SdrLinkList& rLL=ImpGetUserMakeObjUserDataHdl();
3344 rLL.InsertLink(rLink);
3347 void SdrObjFactory::RemoveMakeUserDataHdl(const Link& rLink)
3349 SdrLinkList& rLL=ImpGetUserMakeObjUserDataHdl();
3350 rLL.RemoveLink(rLink);
3353 // eof