1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "sal/config.h"
22 #include <com/sun/star/lang/XComponent.hpp>
25 #include <vcl/metaact.hxx> // for TakeContour
26 #include <vcl/cvtsvm.hxx>
27 #include <tools/line.hxx>
28 #include <tools/bigint.hxx>
29 #include <tools/diagnose_ex.h>
30 #include <tools/helpers.hxx>
32 #include <svx/svdobj.hxx>
33 #include <svx/xpoly.hxx>
34 #include <svx/svdetc.hxx>
35 #include <svx/svdtrans.hxx>
36 #include <svx/svdhdl.hxx>
37 #include <svx/svddrag.hxx>
38 #include <svx/svdmodel.hxx>
39 #include <svx/svdpage.hxx>
40 #include <svx/svdovirt.hxx> // for Add/Del Ref
41 #include <svx/svdview.hxx> // for Dragging (check Ortho)
42 #include "svx/svdglob.hxx" // StringCache
43 #include <svx/svdstr.hrc> // the object's name
44 #include <svx/svdogrp.hxx> // Factory
45 #include <svx/svdopath.hxx> // Factory
46 #include <svx/svdoedge.hxx> // Factory
47 #include <svx/svdorect.hxx> // Factory
48 #include <svx/svdocirc.hxx> // Factory
49 #include <svx/svdotext.hxx> // Factory
50 #include <svx/svdomeas.hxx> // Factory
51 #include <svx/svdograf.hxx> // Factory
52 #include <svx/svdoole2.hxx> // Factory
53 #include <svx/svdocapt.hxx> // Factory
54 #include <svx/svdopage.hxx> // Factory
55 #include <svx/svdouno.hxx> // Factory
56 #include <svx/svdattrx.hxx> // NotPersistItems
57 #include <svx/svdoashp.hxx>
58 #include <svx/svdomedia.hxx>
59 #include <svx/xlnwtit.hxx>
60 #include <svx/xlnstwit.hxx>
61 #include <svx/xlnedwit.hxx>
62 #include <svx/xlnstit.hxx>
63 #include <svx/xlnedit.hxx>
64 #include <svx/xlnstcit.hxx>
65 #include <svx/xlnedcit.hxx>
66 #include <svx/xlndsit.hxx>
67 #include <svx/xlnclit.hxx>
68 #include <svx/xflclit.hxx>
69 #include <svx/svditer.hxx>
70 #include <svx/xlntrit.hxx>
71 #include <svx/xfltrit.hxx>
72 #include <svx/xflftrit.hxx>
73 #include "svx/xlinjoit.hxx"
74 #include <svx/unopage.hxx>
75 #include <editeng/eeitem.hxx>
76 #include <svx/xenum.hxx>
77 #include <svx/xgrad.hxx>
78 #include <svx/xhatch.hxx>
79 #include <svx/xflhtit.hxx>
80 #include <svx/xbtmpit.hxx>
81 #include <svx/svdpool.hxx>
82 #include <editeng/editeng.hxx>
83 #include <svl/whiter.hxx>
85 #include <svx/fmmodel.hxx>
86 #include <sfx2/objsh.hxx>
87 #include <sfx2/objface.hxx>
88 #include <vcl/graphictools.hxx>
89 #include <svtools/colorcfg.hxx>
90 #include <svx/sdr/properties/emptyproperties.hxx>
91 #include <svx/sdr/contact/viewcontactofsdrobj.hxx>
92 #include <svx/sdr/contact/viewcontactofgraphic.hxx>
93 #include <svx/sdr/contact/objectcontactofobjlistpainter.hxx>
94 #include <svx/sdr/contact/displayinfo.hxx>
95 #include <basegfx/polygon/b2dpolygon.hxx>
96 #include <basegfx/polygon/b2dpolygontools.hxx>
97 #include <basegfx/matrix/b2dhommatrix.hxx>
98 #include <basegfx/polygon/b2dpolypolygontools.hxx>
99 #include <basegfx/range/b2drange.hxx>
100 #include <svx/unoshape.hxx>
101 #include <vcl/virdev.hxx>
102 #include <basegfx/polygon/b2dpolypolygoncutter.hxx>
103 #include <drawinglayer/processor2d/contourextractor2d.hxx>
104 #include <drawinglayer/processor2d/linegeometryextractor2d.hxx>
105 #include <svx/polysc3d.hxx>
106 #include "svx/svdotable.hxx"
107 #include "svx/shapepropertynotifier.hxx"
108 #include <svx/sdrhittesthelper.hxx>
109 #include <svx/svdundo.hxx>
110 #include <basegfx/matrix/b2dhommatrixtools.hxx>
111 #include <svx/sdrobjectfilter.hxx>
112 #include "svdconv.hxx"
114 using namespace ::com::sun::star
;
116 ////////////////////////////////////////////////////////////////////////////////////////////////////
118 TYPEINIT0(SdrObjUserCall
);
120 SdrObjUserCall::~SdrObjUserCall()
124 void SdrObjUserCall::Changed(const SdrObject
& /*rObj*/, SdrUserCallType
/*eType*/, const Rectangle
& /*rOldBoundRect*/)
128 SdrObjMacroHitRec::SdrObjMacroHitRec() :
135 ////////////////////////////////////////////////////////////////////////////////////////////////////
137 TYPEINIT0(SdrObjUserData
);
139 SdrObjUserData::SdrObjUserData(sal_uInt32 nInv
, sal_uInt16 nId
, sal_uInt16 nVer
) :
144 SdrObjUserData::SdrObjUserData(const SdrObjUserData
& rData
) :
145 nInventor(rData
.nInventor
),
146 nIdentifier(rData
.nIdentifier
),
147 nVersion(rData
.nVersion
) {}
149 SdrObjUserData::~SdrObjUserData() {}
151 sal_uInt32
SdrObjUserData::GetInventor() const
156 sal_uInt16
SdrObjUserData::GetId() const
161 bool SdrObjUserData::HasMacro(const SdrObject
* /*pObj*/) const
166 SdrObject
* SdrObjUserData::CheckMacroHit(const SdrObjMacroHitRec
& rRec
, const SdrObject
* pObj
) const
172 return SdrObjectPrimitiveHit(*pObj
, rRec
.aPos
, rRec
.nTol
, *rRec
.pPageView
, rRec
.pVisiLayer
, false);
179 Pointer
SdrObjUserData::GetMacroPointer(const SdrObjMacroHitRec
& /*rRec*/, const SdrObject
* /*pObj*/) const
181 return Pointer(POINTER_REFHAND
);
184 void SdrObjUserData::PaintMacro(OutputDevice
& rOut
, const Rectangle
& /*rDirtyRect*/, const SdrObjMacroHitRec
& /*rRec*/, const SdrObject
* pObj
) const
189 const RasterOp
eRop(rOut
.GetRasterOp());
190 const basegfx::B2DPolyPolygon
aPolyPolygon(pObj
->TakeXorPoly());
191 const sal_uInt32
nCount(aPolyPolygon
.count());
193 rOut
.SetLineColor(COL_BLACK
);
195 rOut
.SetRasterOp(ROP_INVERT
);
197 for(sal_uInt32
a(0); a
< nCount
; a
++)
199 rOut
.DrawPolyLine(aPolyPolygon
.getB2DPolygon(a
));
202 rOut
.SetRasterOp(eRop
);
205 bool SdrObjUserData::DoMacro(const SdrObjMacroHitRec
& /*rRec*/, SdrObject
* /*pObj*/)
210 OUString
SdrObjUserData::GetMacroPopupComment(const SdrObjMacroHitRec
& /*rRec*/, const SdrObject
* /*pObj*/) const
215 SdrObjUserDataList::SdrObjUserDataList() {}
216 SdrObjUserDataList::~SdrObjUserDataList() {}
218 size_t SdrObjUserDataList::GetUserDataCount() const
220 return static_cast<sal_uInt16
>(maList
.size());
223 const SdrObjUserData
* SdrObjUserDataList::GetUserData(size_t nNum
) const
225 return &maList
.at(nNum
);
228 SdrObjUserData
* SdrObjUserDataList::GetUserData(size_t nNum
)
230 return &maList
.at(nNum
);
233 void SdrObjUserDataList::AppendUserData(SdrObjUserData
* pData
)
235 maList
.push_back(pData
);
238 void SdrObjUserDataList::DeleteUserData(size_t nNum
)
240 maList
.erase(maList
.begin()+nNum
);
243 ////////////////////////////////////////////////////////////////////////////////////////////////////
245 DBG_NAME(SdrObjGeoData
);
247 SdrObjGeoData::SdrObjGeoData():
256 DBG_CTOR(SdrObjGeoData
,NULL
);
259 SdrObjGeoData::~SdrObjGeoData()
261 DBG_DTOR(SdrObjGeoData
,NULL
);
265 ////////////////////////////////////////////////////////////////////////////////////////////////////
267 TYPEINIT0(SdrObjPlusData
);
269 SdrObjPlusData::SdrObjPlusData():
276 SdrObjPlusData::~SdrObjPlusData()
279 delete pUserDataList
;
283 SdrObjPlusData
* SdrObjPlusData::Clone(SdrObject
* pObj1
) const
285 SdrObjPlusData
* pNeuPlusData
=new SdrObjPlusData
;
286 if (pUserDataList
!=NULL
) {
287 sal_uInt16 nAnz
=pUserDataList
->GetUserDataCount();
289 pNeuPlusData
->pUserDataList
=new SdrObjUserDataList
;
290 for (sal_uInt16 i
=0; i
<nAnz
; i
++) {
291 SdrObjUserData
* pNeuUserData
=pUserDataList
->GetUserData(i
)->Clone(pObj1
);
292 if (pNeuUserData
!=NULL
) {
293 pNeuPlusData
->pUserDataList
->AppendUserData(pNeuUserData
);
295 OSL_FAIL("SdrObjPlusData::Clone(): UserData.Clone() returns NULL.");
300 if (pGluePoints
!=NULL
) pNeuPlusData
->pGluePoints
=new SdrGluePointList(*pGluePoints
);
301 // MtfAnimator isn't copied either
304 // copy object name, title and description
305 pNeuPlusData
->aObjName
= aObjName
;
306 pNeuPlusData
->aObjTitle
= aObjTitle
;
307 pNeuPlusData
->aObjDescription
= aObjDescription
;
312 void SdrObjPlusData::SetGluePoints(const SdrGluePointList
& rPts
)
314 return *pGluePoints
= rPts
;
317 SdrObjTransformInfoRec::SdrObjTransformInfoRec() :
318 bSelectAllowed(true),
320 bResizeFreeAllowed(true),
321 bResizePropAllowed(true),
322 bRotateFreeAllowed(true),
323 bRotate90Allowed(true),
324 bMirrorFreeAllowed(true),
325 bMirror45Allowed(true),
326 bMirror90Allowed(true),
327 bTransparenceAllowed(true),
328 bGradientAllowed(true),
330 bEdgeRadiusAllowed(true),
331 bNoOrthoDesired(true),
333 bCanConvToPath(true),
334 bCanConvToPoly(true),
335 bCanConvToContour(false),
336 bCanConvToPathLineToArea(true),
337 bCanConvToPolyLineToArea(true) {}
339 //////////////////////////////////////////////////////////////////////////////
340 // BaseProperties section
342 sdr::properties::BaseProperties
* SdrObject::CreateObjectSpecificProperties()
344 return new sdr::properties::EmptyProperties(*this);
347 sdr::properties::BaseProperties
& SdrObject::GetProperties() const
351 const_cast< SdrObject
* >(this)->mpProperties
=
352 const_cast< SdrObject
* >(this)->CreateObjectSpecificProperties();
355 return *mpProperties
;
358 //////////////////////////////////////////////////////////////////////////////
359 // ObjectUser section
361 void SdrObject::AddObjectUser(sdr::ObjectUser
& rNewUser
)
363 maObjectUsers
.push_back(&rNewUser
);
366 void SdrObject::RemoveObjectUser(sdr::ObjectUser
& rOldUser
)
368 const ::sdr::ObjectUserVector::iterator aFindResult
= ::std::find(maObjectUsers
.begin(), maObjectUsers
.end(), &rOldUser
);
369 if(aFindResult
!= maObjectUsers
.end())
371 maObjectUsers
.erase(aFindResult
);
375 //////////////////////////////////////////////////////////////////////////////
376 // DrawContact section
378 sdr::contact::ViewContact
* SdrObject::CreateObjectSpecificViewContact()
380 return new sdr::contact::ViewContactOfSdrObj(*this);
383 sdr::contact::ViewContact
& SdrObject::GetViewContact() const
387 const_cast< SdrObject
* >(this)->mpViewContact
=
388 const_cast< SdrObject
* >(this)->CreateObjectSpecificViewContact();
391 return *mpViewContact
;
394 // DrawContact support: Methods for handling Object changes
395 void SdrObject::ActionChanged() const
397 // Do necessary ViewContact actions
398 GetViewContact().ActionChanged();
401 //////////////////////////////////////////////////////////////////////////////
403 void SdrObject::SetBoundRectDirty()
405 aOutRect
= Rectangle();
408 //////////////////////////////////////////////////////////////////////////////
411 TYPEINIT1(SdrObject
,SfxListener
);
413 SdrObject::SdrObject()
422 ,mnNavigationPosition(SAL_MAX_UINT32
)
426 ,mbDoNotInsertIntoPageAutomatically(false)
428 DBG_CTOR(SdrObject
,NULL
);
430 bSnapRectDirty
=true;
437 bEmptyPresObj
=false;
438 bNotVisibleAsMaster
=false;
443 mbLineIsOutsideGeometry
= false;
446 mbSupportTextIndentingOnLineWidthChange
= false;
448 bNotMasterCachable
=false;
455 SdrObject::~SdrObject()
457 // tell all the registered ObjectUsers that the page is in destruction
458 ::sdr::ObjectUserVector
aListCopy(maObjectUsers
.begin(), maObjectUsers
.end());
459 for(::sdr::ObjectUserVector::iterator aIterator
= aListCopy
.begin(); aIterator
!= aListCopy
.end(); ++aIterator
)
461 sdr::ObjectUser
* pObjectUser
= *aIterator
;
462 DBG_ASSERT(pObjectUser
, "SdrObject::~SdrObject: corrupt ObjectUser list (!)");
463 pObjectUser
->ObjectInDestruction(*this);
466 // Clear the vector. This means that user do not need to call RemoveObjectUser()
467 // when they get called from ObjectInDestruction().
468 maObjectUsers
.clear();
472 SvxShape
* pSvxShape
= getSvxShape();
475 OSL_ENSURE(!pSvxShape
->HasSdrObjectOwnership(),"Please check where this call come from and replace it with SdrObject::Free");
476 pSvxShape
->InvalidateSdrObject();
477 uno::Reference
< lang::XComponent
> xShapeComp( getWeakUnoShape(), uno::UNO_QUERY_THROW
);
478 xShapeComp
->dispose();
481 catch( const uno::Exception
& )
483 DBG_UNHANDLED_EXCEPTION();
486 DBG_DTOR(SdrObject
,NULL
);
487 SendUserCall(SDRUSERCALL_DELETE
, GetLastBoundRect());
498 delete mpViewContact
;
503 void SdrObject::Free( SdrObject
*& _rpObject
)
505 SdrObject
* pObject
= _rpObject
; _rpObject
= NULL
;
506 if ( pObject
== NULL
)
510 SvxShape
* pShape
= pObject
->getSvxShape();
511 if ( pShape
&& pShape
->HasSdrObjectOwnership() )
512 // only the shape is allowed to delete me, and will reset the ownership before doing so
518 SdrObjPlusData
* SdrObject::NewPlusData() const
520 return new SdrObjPlusData
;
523 void SdrObject::SetRectsDirty(sal_Bool bNotMyself
)
529 if (pObjList
!=NULL
) {
530 pObjList
->SetRectsDirty();
534 void SdrObject::SetModel(SdrModel
* pNewModel
)
536 if(pNewModel
&& pPage
)
538 if(pPage
->GetModel() != pNewModel
)
544 // update listeners at possible API wrapper object
545 if( pModel
!= pNewModel
)
547 SvxShape
* pShape
= getSvxShape();
549 pShape
->ChangeModel( pNewModel
);
555 SdrModel
* SdrObject::GetModel() const
560 void SdrObject::SetObjList(SdrObjList
* pNewObjList
)
562 pObjList
=pNewObjList
;
565 SdrObjList
* SdrObject::GetObjList() const
570 void SdrObject::SetPage(SdrPage
* pNewPage
)
572 SdrModel
* pOldModel
= pModel
;
573 SdrPage
* pOldPage
= pPage
;
577 SdrModel
* pMod
=pPage
->GetModel();
578 if (pMod
!=pModel
&& pMod
!=NULL
) {
582 // The creation of the UNO shape in SdrObject::getUnoShape is influenced
583 // by pPage, so when the page changes we need to discard the cached UNO
584 // shape so that a new one will be created.
585 // If the page is changing to another page with the same model, we
586 // assume they create compatible UNO shape objects so we shouldn't have
588 if (pOldPage
!= pPage
&& !(pOldPage
&& pPage
&& pOldModel
== pModel
))
590 SvxShape
* const pShape(getSvxShape());
591 if (pShape
&& !pShape
->HasSdrObjectOwnership())
596 SdrPage
* SdrObject::GetPage() const
601 // init global static itempool
602 SdrItemPool
* SdrObject::mpGlobalItemPool
= NULL
;
604 SdrItemPool
& SdrObject::GetGlobalDrawObjectItemPool()
606 if(!mpGlobalItemPool
)
608 mpGlobalItemPool
= new SdrItemPool();
609 SfxItemPool
* pGlobalOutlPool
= EditEngine::CreatePool();
610 mpGlobalItemPool
->SetSecondaryPool(pGlobalOutlPool
);
611 mpGlobalItemPool
->SetDefaultMetric((SfxMapUnit
)SdrEngineDefaults::GetMapUnit());
612 mpGlobalItemPool
->FreezeIdRanges();
615 return *mpGlobalItemPool
;
618 SdrItemPool
* SdrObject::GetObjectItemPool() const
621 return (SdrItemPool
*)(&pModel
->GetItemPool());
623 // use a static global default pool
624 return &SdrObject::GetGlobalDrawObjectItemPool();
627 sal_uInt32
SdrObject::GetObjInventor() const
632 sal_uInt16
SdrObject::GetObjIdentifier() const
634 return sal_uInt16(OBJ_NONE
);
637 void SdrObject::TakeObjInfo(SdrObjTransformInfoRec
& rInfo
) const
639 rInfo
.bRotateFreeAllowed
=false;
640 rInfo
.bMirrorFreeAllowed
=false;
641 rInfo
.bTransparenceAllowed
= false;
642 rInfo
.bGradientAllowed
= false;
643 rInfo
.bShearAllowed
=false;
644 rInfo
.bEdgeRadiusAllowed
=false;
645 rInfo
.bCanConvToPath
=false;
646 rInfo
.bCanConvToPoly
=false;
647 rInfo
.bCanConvToContour
= false;
648 rInfo
.bCanConvToPathLineToArea
=false;
649 rInfo
.bCanConvToPolyLineToArea
=false;
652 SdrLayerID
SdrObject::GetLayer() const
657 void SdrObject::getMergedHierarchyLayerSet(SetOfByte
& rSet
) const
659 rSet
.Set(GetLayer());
660 SdrObjList
* pOL
=GetSubList();
662 sal_uIntPtr nObjAnz
=pOL
->GetObjCount();
663 for (sal_uIntPtr nObjNum
=0; nObjNum
<nObjAnz
; nObjNum
++) {
664 pOL
->GetObj(nObjNum
)->getMergedHierarchyLayerSet(rSet
);
669 void SdrObject::NbcSetLayer(SdrLayerID nLayer
)
674 void SdrObject::SetLayer(SdrLayerID nLayer
)
678 BroadcastObjectChange();
681 void SdrObject::AddListener(SfxListener
& rListener
)
684 if (pPlusData
->pBroadcast
==NULL
) pPlusData
->pBroadcast
=new SfxBroadcaster
;
685 rListener
.StartListening(*pPlusData
->pBroadcast
);
688 void SdrObject::RemoveListener(SfxListener
& rListener
)
690 if (pPlusData
!=NULL
&& pPlusData
->pBroadcast
!=NULL
) {
691 rListener
.EndListening(*pPlusData
->pBroadcast
);
692 if (!pPlusData
->pBroadcast
->HasListeners()) {
693 delete pPlusData
->pBroadcast
;
694 pPlusData
->pBroadcast
=NULL
;
699 const SfxBroadcaster
* SdrObject::GetBroadcaster() const
701 return pPlusData
!=NULL
? pPlusData
->pBroadcast
: NULL
;
704 void SdrObject::AddReference(SdrVirtObj
& rVrtObj
)
706 AddListener(rVrtObj
);
709 void SdrObject::DelReference(SdrVirtObj
& rVrtObj
)
711 RemoveListener(rVrtObj
);
714 bool SdrObject::HasRefPoint() const
719 Point
SdrObject::GetRefPoint() const
721 return GetCurrentBoundRect().Center();
724 void SdrObject::SetRefPoint(const Point
& /*rPnt*/)
728 bool SdrObject::IsGroupObject() const
730 return GetSubList()!=NULL
;
733 SdrObjList
* SdrObject::GetSubList() const
738 SdrObject
* SdrObject::GetUpGroup() const
740 return pObjList
!=NULL
? pObjList
->GetOwnerObj() : NULL
;
743 void SdrObject::SetName(const OUString
& rStr
)
745 if (!rStr
.isEmpty() && !pPlusData
)
750 if(pPlusData
&& !pPlusData
->aObjName
.equals(rStr
))
752 // Undo/Redo for setting object's name (#i73249#)
754 if ( GetModel() && GetModel()->IsUndoEnabled() )
757 SdrUndoAction
* pUndoAction
=
758 GetModel()->GetSdrUndoFactory().CreateUndoObjectStrAttr(
760 SdrUndoObjStrAttr::OBJ_NAME
,
763 GetModel()->BegUndo( pUndoAction
->GetComment() );
764 GetModel()->AddUndo( pUndoAction
);
766 pPlusData
->aObjName
= rStr
;
767 // Undo/Redo for setting object's name (#i73249#)
770 GetModel()->EndUndo();
773 BroadcastObjectChange();
777 OUString
SdrObject::GetName() const
781 return pPlusData
->aObjName
;
787 void SdrObject::SetTitle(const OUString
& rStr
)
789 if (!rStr
.isEmpty() && !pPlusData
)
794 if(pPlusData
&& pPlusData
->aObjTitle
!= rStr
)
796 // Undo/Redo for setting object's title (#i73249#)
798 if ( GetModel() && GetModel()->IsUndoEnabled() )
801 SdrUndoAction
* pUndoAction
=
802 GetModel()->GetSdrUndoFactory().CreateUndoObjectStrAttr(
804 SdrUndoObjStrAttr::OBJ_TITLE
,
807 GetModel()->BegUndo( pUndoAction
->GetComment() );
808 GetModel()->AddUndo( pUndoAction
);
810 pPlusData
->aObjTitle
= rStr
;
811 // Undo/Redo for setting object's title (#i73249#)
814 GetModel()->EndUndo();
817 BroadcastObjectChange();
821 OUString
SdrObject::GetTitle() const
825 return pPlusData
->aObjTitle
;
831 void SdrObject::SetDescription(const OUString
& rStr
)
833 if (!rStr
.isEmpty() && !pPlusData
)
838 if(pPlusData
&& !pPlusData
->aObjDescription
.equals(rStr
))
840 // Undo/Redo for setting object's description (#i73249#)
842 if ( GetModel() && GetModel()->IsUndoEnabled() )
845 SdrUndoAction
* pUndoAction
=
846 GetModel()->GetSdrUndoFactory().CreateUndoObjectStrAttr(
848 SdrUndoObjStrAttr::OBJ_DESCRIPTION
,
851 GetModel()->BegUndo( pUndoAction
->GetComment() );
852 GetModel()->AddUndo( pUndoAction
);
854 pPlusData
->aObjDescription
= rStr
;
855 // Undo/Redo for setting object's description (#i73249#)
858 GetModel()->EndUndo();
861 BroadcastObjectChange();
865 OUString
SdrObject::GetDescription() const
869 return pPlusData
->aObjDescription
;
875 sal_uInt32
SdrObject::GetOrdNum() const
877 if (pObjList
!=NULL
) {
878 if (pObjList
->IsObjOrdNumsDirty()) {
879 pObjList
->RecalcObjOrdNums();
881 } else ((SdrObject
*)this)->nOrdNum
=0;
885 sal_uInt32
SdrObject::GetOrdNumDirect() const
890 void SdrObject::SetOrdNum(sal_uInt32 nNum
)
895 sal_uInt32
SdrObject::GetNavigationPosition (void)
897 if (pObjList
!=NULL
&& pObjList
->RecalcNavigationPositions())
899 return mnNavigationPosition
;
908 void SdrObject::SetNavigationPosition (const sal_uInt32 nNewPosition
)
910 mnNavigationPosition
= nNewPosition
;
916 // To make clearer that this method may trigger RecalcBoundRect and thus may be
917 // expensive and sometimes problematic (inside a bigger object change you will get
918 // non-useful BoundRects sometimes) I rename that method from GetBoundRect() to
919 // GetCurrentBoundRect().
920 const Rectangle
& SdrObject::GetCurrentBoundRect() const
922 if(aOutRect
.IsEmpty())
924 const_cast< SdrObject
* >(this)->RecalcBoundRect();
930 // To have a possibility to get the last calculated BoundRect e.g for producing
931 // the first rectangle for repaints (old and new need to be used) without forcing
932 // a RecalcBoundRect (which may be problematical and expensive sometimes) I add here
933 // a new method for accessing the last BoundRect.
934 const Rectangle
& SdrObject::GetLastBoundRect() const
939 void SdrObject::RecalcBoundRect()
941 // #i101680# suppress BoundRect calculations on import(s)
942 if(pModel
&& pModel
->isLocked())
945 // central new method which will calculate the BoundRect using primitive geometry
946 if(aOutRect
.IsEmpty())
948 const drawinglayer::primitive2d::Primitive2DSequence
xPrimitives(GetViewContact().getViewIndependentPrimitive2DSequence());
950 if(xPrimitives
.hasElements())
952 // use neutral ViewInformation and get the range of the primitives
953 const drawinglayer::geometry::ViewInformation2D aViewInformation2D
;
954 const basegfx::B2DRange
aRange(drawinglayer::primitive2d::getB2DRangeFromPrimitive2DSequence(xPrimitives
, aViewInformation2D
));
956 if(!aRange
.isEmpty())
958 aOutRect
= Rectangle(
959 (sal_Int32
)floor(aRange
.getMinX()), (sal_Int32
)floor(aRange
.getMinY()),
960 (sal_Int32
)ceil(aRange
.getMaxX()), (sal_Int32
)ceil(aRange
.getMaxY()));
961 aOutRect
-= GetGridOffset(); // don't include grid offset
968 void SdrObject::BroadcastObjectChange() const
970 if( pModel
&& pModel
->isLocked() )
973 bool bPlusDataBroadcast(pPlusData
&& pPlusData
->pBroadcast
);
974 bool bObjectChange(IsInserted() && pModel
);
976 if(bPlusDataBroadcast
|| bObjectChange
)
978 SdrHint
aHint(*this);
980 if(bPlusDataBroadcast
)
982 pPlusData
->pBroadcast
->Broadcast(aHint
);
987 pModel
->Broadcast(aHint
);
992 void SdrObject::SetChanged()
994 // For testing purposes, use the new ViewContact for change
998 if(IsInserted() && pModel
)
1000 pModel
->SetChanged();
1004 // tooling for painting a single object to an OutputDevice.
1005 bool SdrObject::SingleObjectPainter(OutputDevice
& rOut
) const
1007 sdr::contact::SdrObjectVector aObjectVector
;
1008 aObjectVector
.push_back(const_cast< SdrObject
* >(this));
1010 sdr::contact::ObjectContactOfObjListPainter
aPainter(rOut
, aObjectVector
, GetPage());
1011 sdr::contact::DisplayInfo aDisplayInfo
;
1013 aPainter
.ProcessDisplay(aDisplayInfo
);
1018 bool SdrObject::LineGeometryUsageIsNecessary() const
1020 XLineStyle eXLS
= (XLineStyle
)((const XLineStyleItem
&)GetMergedItem(XATTR_LINESTYLE
)).GetValue();
1021 return (eXLS
!= XLINE_NONE
);
1024 SdrObject
* SdrObject::Clone() const
1026 return CloneHelper
< SdrObject
>();
1029 SdrObject
& SdrObject::operator=(const SdrObject
& rObj
)
1036 delete mpProperties
;
1042 delete mpViewContact
;
1046 // The Clone() method uses the local copy constructor from the individual
1047 // sdr::properties::BaseProperties class. Since the target class maybe for another
1048 // draw object, an SdrObject needs to be provided, as in the normal constructor.
1049 mpProperties
= &rObj
.GetProperties().Clone(*this);
1051 pModel
=rObj
.pModel
;
1053 aOutRect
=rObj
.aOutRect
;
1054 mnLayerID
= rObj
.mnLayerID
;
1055 aAnchor
=rObj
.aAnchor
;
1056 bVirtObj
=rObj
.bVirtObj
;
1057 bSizProt
=rObj
.bSizProt
;
1058 bMovProt
=rObj
.bMovProt
;
1059 bNoPrint
=rObj
.bNoPrint
;
1060 mbVisible
=rObj
.mbVisible
;
1061 bMarkProt
=rObj
.bMarkProt
;
1062 bEmptyPresObj
=rObj
.bEmptyPresObj
;
1063 bNotVisibleAsMaster
=rObj
.bNotVisibleAsMaster
;
1064 bSnapRectDirty
=true;
1065 bNotMasterCachable
=rObj
.bNotMasterCachable
;
1068 if (rObj
.pPlusData
!=NULL
) {
1069 pPlusData
=rObj
.pPlusData
->Clone(this);
1071 if (pPlusData
!=NULL
&& pPlusData
->pBroadcast
!=NULL
) {
1072 delete pPlusData
->pBroadcast
; // broadcaster isn't copied
1073 pPlusData
->pBroadcast
=NULL
;
1075 aGridOffset
= rObj
.aGridOffset
;
1079 void SdrObject::TakeObjNameSingul(XubString
& rName
) const
1081 rName
=ImpGetResStr(STR_ObjNameSingulNONE
);
1083 String
aName( GetName() );
1086 rName
+= sal_Unicode(' ');
1087 rName
+= sal_Unicode('\'');
1089 rName
+= sal_Unicode('\'');
1093 void SdrObject::TakeObjNamePlural(XubString
& rName
) const
1095 rName
=ImpGetResStr(STR_ObjNamePluralNONE
);
1098 void SdrObject::ImpTakeDescriptionStr(sal_uInt16 nStrCacheID
, OUString
& rStr
, sal_uInt16 nVal
) const
1100 rStr
= ImpGetResStr(nStrCacheID
);
1101 sal_Int32 nPos
= rStr
.indexOf("%1");
1104 // Replace '%1' with the object name.
1106 TakeObjNameSingul(aObjName
);
1107 rStr
= rStr
.replaceAt(nPos
, 2, aObjName
);
1110 nPos
= rStr
.indexOf("%2");
1112 // Replace '%2' with the passed value.
1113 rStr
= rStr
.replaceAt(
1114 nPos
, 2, OUString::number(nVal
));
1117 void SdrObject::ImpForcePlusData()
1120 pPlusData
= NewPlusData();
1123 OUString
SdrObject::GetWinkStr(long nWink
, bool bNoDegChar
) const
1127 pModel
->TakeWinkStr(nWink
,aStr
,bNoDegChar
);
1132 OUString
SdrObject::GetMetrStr(long nVal
, MapUnit
/*eWantMap*/, bool bNoUnitChars
) const
1136 pModel
->TakeMetricStr(nVal
,aStr
,bNoUnitChars
);
1141 basegfx::B2DPolyPolygon
SdrObject::TakeXorPoly() const
1143 basegfx::B2DPolyPolygon aRetval
;
1144 const Rectangle
aR(GetCurrentBoundRect());
1145 const basegfx::B2DRange
aRange(aR
.Left(), aR
.Top(), aR
.Right(), aR
.Bottom());
1146 aRetval
.append(basegfx::tools::createPolygonFromRect(aRange
));
1151 basegfx::B2DPolyPolygon
SdrObject::TakeContour() const
1153 basegfx::B2DPolyPolygon aRetval
;
1155 // create cloned object without text, but with XLINE_SOLID,
1156 // COL_BLACK as line color and XFILL_NONE
1157 SdrObject
* pClone
= Clone();
1161 const SdrTextObj
* pTextObj
= dynamic_cast< const SdrTextObj
* >(this);
1165 // no text and no text animation
1166 pClone
->SetMergedItem(SdrTextAniKindItem(SDRTEXTANI_NONE
));
1167 pClone
->SetOutlinerParaObject(0);
1170 const SdrEdgeObj
* pEdgeObj
= dynamic_cast< const SdrEdgeObj
* >(this);
1174 // create connections if connector, will be cleaned up when
1175 // deleting the connector again
1176 SdrObject
* pLeft
= pEdgeObj
->GetConnectedNode(true);
1177 SdrObject
* pRight
= pEdgeObj
->GetConnectedNode(false);
1181 pClone
->ConnectToNode(true, pLeft
);
1186 pClone
->ConnectToNode(false, pRight
);
1190 SfxItemSet
aNewSet(*GetObjectItemPool());
1192 // #i101980# ignore LineWidth; that's what the old implementation
1193 // did. With line width, the result may be huge due to fat/thick
1194 // line decompositions
1195 aNewSet
.Put(XLineWidthItem(0));
1197 // solid black lines and no fill
1198 aNewSet
.Put(XLineStyleItem(XLINE_SOLID
));
1199 aNewSet
.Put(XLineColorItem(String(), Color(COL_BLACK
)));
1200 aNewSet
.Put(XFillStyleItem(XFILL_NONE
));
1201 pClone
->SetMergedItemSet(aNewSet
);
1203 // get sequence from clone
1204 const sdr::contact::ViewContact
& rVC(pClone
->GetViewContact());
1205 const drawinglayer::primitive2d::Primitive2DSequence
xSequence(rVC
.getViewIndependentPrimitive2DSequence());
1207 if(xSequence
.hasElements())
1209 // use neutral ViewInformation
1210 const drawinglayer::geometry::ViewInformation2D aViewInformation2D
;
1212 // create extractor, process and get result (with hairlines as opened polygons)
1213 drawinglayer::processor2d::ContourExtractor2D
aExtractor(aViewInformation2D
, false);
1214 aExtractor
.process(xSequence
);
1215 const basegfx::B2DPolyPolygonVector
& rResult(aExtractor
.getExtractedContour());
1216 const sal_uInt32
nSize(rResult
.size());
1218 // when count is one, it is implied that the object has only its normal
1219 // contour anyways and TakeCountour() is to return an empty PolyPolygon
1220 // (see old implementation for historical reasons)
1223 // the topology for contour is correctly a vector of PolyPolygons; for
1224 // historical reasons cut it back to a single PolyPolygon here
1225 for(sal_uInt32
a(0); a
< nSize
; a
++)
1227 aRetval
.append(rResult
[a
]);
1238 sal_uInt32
SdrObject::GetHdlCount() const
1243 SdrHdl
* SdrObject::GetHdl(sal_uInt32 nHdlNum
) const
1246 const Rectangle
& rR
=GetSnapRect();
1248 case 0: pH
=new SdrHdl(rR
.TopLeft(), HDL_UPLFT
); break;
1249 case 1: pH
=new SdrHdl(rR
.TopCenter(), HDL_UPPER
); break;
1250 case 2: pH
=new SdrHdl(rR
.TopRight(), HDL_UPRGT
); break;
1251 case 3: pH
=new SdrHdl(rR
.LeftCenter(), HDL_LEFT
); break;
1252 case 4: pH
=new SdrHdl(rR
.RightCenter(), HDL_RIGHT
); break;
1253 case 5: pH
=new SdrHdl(rR
.BottomLeft(), HDL_LWLFT
); break;
1254 case 6: pH
=new SdrHdl(rR
.BottomCenter(),HDL_LOWER
); break;
1255 case 7: pH
=new SdrHdl(rR
.BottomRight(), HDL_LWRGT
); break;
1260 sal_uInt32
SdrObject::GetPlusHdlCount(const SdrHdl
& /*rHdl*/) const
1265 SdrHdl
* SdrObject::GetPlusHdl(const SdrHdl
& /*rHdl*/, sal_uInt32
/*nPlNum*/) const
1270 void SdrObject::AddToHdlList(SdrHdlList
& rHdlList
) const
1272 sal_uInt32 nAnz
=GetHdlCount();
1273 for (sal_uInt32 i
=0L; i
<nAnz
; i
++) {
1274 SdrHdl
* pHdl
=GetHdl(i
);
1276 rHdlList
.AddHdl(pHdl
);
1281 Rectangle
SdrObject::ImpDragCalcRect(const SdrDragStat
& rDrag
) const
1283 Rectangle
aTmpRect(GetSnapRect());
1284 Rectangle
aRect(aTmpRect
);
1285 const SdrHdl
* pHdl
=rDrag
.GetHdl();
1286 SdrHdlKind eHdl
=pHdl
==NULL
? HDL_MOVE
: pHdl
->GetKind();
1287 bool bEcke
=(eHdl
==HDL_UPLFT
|| eHdl
==HDL_UPRGT
|| eHdl
==HDL_LWLFT
|| eHdl
==HDL_LWRGT
);
1288 bool bOrtho
=rDrag
.GetView()!=NULL
&& rDrag
.GetView()->IsOrtho();
1289 bool bBigOrtho
=bEcke
&& bOrtho
&& rDrag
.GetView()->IsBigOrtho();
1290 Point
aPos(rDrag
.GetNow());
1291 bool bLft
=(eHdl
==HDL_UPLFT
|| eHdl
==HDL_LEFT
|| eHdl
==HDL_LWLFT
);
1292 bool bRgt
=(eHdl
==HDL_UPRGT
|| eHdl
==HDL_RIGHT
|| eHdl
==HDL_LWRGT
);
1293 bool bTop
=(eHdl
==HDL_UPRGT
|| eHdl
==HDL_UPPER
|| eHdl
==HDL_UPLFT
);
1294 bool bBtm
=(eHdl
==HDL_LWRGT
|| eHdl
==HDL_LOWER
|| eHdl
==HDL_LWLFT
);
1295 if (bLft
) aTmpRect
.Left() =aPos
.X();
1296 if (bRgt
) aTmpRect
.Right() =aPos
.X();
1297 if (bTop
) aTmpRect
.Top() =aPos
.Y();
1298 if (bBtm
) aTmpRect
.Bottom()=aPos
.Y();
1299 if (bOrtho
) { // Ortho
1300 long nWdt0
=aRect
.Right() -aRect
.Left();
1301 long nHgt0
=aRect
.Bottom()-aRect
.Top();
1302 long nXMul
=aTmpRect
.Right() -aTmpRect
.Left();
1303 long nYMul
=aTmpRect
.Bottom()-aTmpRect
.Top();
1306 bool bXNeg
=(nXMul
<0)!=(nXDiv
<0);
1307 bool bYNeg
=(nYMul
<0)!=(nYDiv
<0);
1308 nXMul
=std::abs(nXMul
);
1309 nYMul
=std::abs(nYMul
);
1310 nXDiv
=std::abs(nXDiv
);
1311 nYDiv
=std::abs(nYDiv
);
1312 Fraction
aXFact(nXMul
,nXDiv
); // fractions for canceling
1313 Fraction
aYFact(nYMul
,nYDiv
); // and for comparing
1314 nXMul
=aXFact
.GetNumerator();
1315 nYMul
=aYFact
.GetNumerator();
1316 nXDiv
=aXFact
.GetDenominator();
1317 nYDiv
=aYFact
.GetDenominator();
1318 if (bEcke
) { // corner point handles
1319 bool bUseX
=(aXFact
<aYFact
) != bBigOrtho
;
1321 long nNeed
=long(BigInt(nHgt0
)*BigInt(nXMul
)/BigInt(nXDiv
));
1322 if (bYNeg
) nNeed
=-nNeed
;
1323 if (bTop
) aTmpRect
.Top()=aTmpRect
.Bottom()-nNeed
;
1324 if (bBtm
) aTmpRect
.Bottom()=aTmpRect
.Top()+nNeed
;
1326 long nNeed
=long(BigInt(nWdt0
)*BigInt(nYMul
)/BigInt(nYDiv
));
1327 if (bXNeg
) nNeed
=-nNeed
;
1328 if (bLft
) aTmpRect
.Left()=aTmpRect
.Right()-nNeed
;
1329 if (bRgt
) aTmpRect
.Right()=aTmpRect
.Left()+nNeed
;
1331 } else { // apex handles
1332 if ((bLft
|| bRgt
) && nXDiv
!=0) {
1333 long nHgt0b
=aRect
.Bottom()-aRect
.Top();
1334 long nNeed
=long(BigInt(nHgt0b
)*BigInt(nXMul
)/BigInt(nXDiv
));
1335 aTmpRect
.Top()-=(nNeed
-nHgt0b
)/2;
1336 aTmpRect
.Bottom()=aTmpRect
.Top()+nNeed
;
1338 if ((bTop
|| bBtm
) && nYDiv
!=0) {
1339 long nWdt0b
=aRect
.Right()-aRect
.Left();
1340 long nNeed
=long(BigInt(nWdt0b
)*BigInt(nYMul
)/BigInt(nYDiv
));
1341 aTmpRect
.Left()-=(nNeed
-nWdt0b
)/2;
1342 aTmpRect
.Right()=aTmpRect
.Left()+nNeed
;
1350 ////////////////////////////////////////////////////////////////////////////////////////////////////
1352 bool SdrObject::hasSpecialDrag() const
1357 bool SdrObject::supportsFullDrag() const
1362 SdrObject
* SdrObject::getFullDragClone() const
1364 // default uses simple clone
1368 bool SdrObject::beginSpecialDrag(SdrDragStat
& rDrag
) const
1370 const SdrHdl
* pHdl
= rDrag
.GetHdl();
1372 SdrHdlKind eHdl
= (pHdl
== NULL
) ? HDL_MOVE
: pHdl
->GetKind();
1374 if(eHdl
==HDL_UPLFT
|| eHdl
==HDL_UPPER
|| eHdl
==HDL_UPRGT
||
1375 eHdl
==HDL_LEFT
|| eHdl
==HDL_RIGHT
|| eHdl
==HDL_LWLFT
||
1376 eHdl
==HDL_LOWER
|| eHdl
==HDL_LWRGT
)
1384 bool SdrObject::applySpecialDrag(SdrDragStat
& rDrag
)
1386 Rectangle
aNewRect(ImpDragCalcRect(rDrag
));
1388 if(aNewRect
!= GetSnapRect())
1390 NbcSetSnapRect(aNewRect
);
1396 String
SdrObject::getSpecialDragComment(const SdrDragStat
& /*rDrag*/) const
1401 basegfx::B2DPolyPolygon
SdrObject::getSpecialDragPoly(const SdrDragStat
& /*rDrag*/) const
1403 // default has nothing to add
1404 return basegfx::B2DPolyPolygon();
1407 ////////////////////////////////////////////////////////////////////////////////////////////////////
1409 bool SdrObject::BegCreate(SdrDragStat
& rStat
)
1411 rStat
.SetOrtho4Possible();
1412 Rectangle
aRect1(rStat
.GetStart(), rStat
.GetNow());
1414 rStat
.SetActionRect(aRect1
);
1419 bool SdrObject::MovCreate(SdrDragStat
& rStat
)
1421 rStat
.TakeCreateRect(aOutRect
);
1422 rStat
.SetActionRect(aOutRect
);
1428 bool SdrObject::EndCreate(SdrDragStat
& rStat
, SdrCreateCmd eCmd
)
1430 rStat
.TakeCreateRect(aOutRect
);
1433 return (eCmd
==SDRCREATE_FORCEEND
|| rStat
.GetPointAnz()>=2);
1436 void SdrObject::BrkCreate(SdrDragStat
& /*rStat*/)
1440 bool SdrObject::BckCreate(SdrDragStat
& /*rStat*/)
1445 basegfx::B2DPolyPolygon
SdrObject::TakeCreatePoly(const SdrDragStat
& rDrag
) const
1448 rDrag
.TakeCreateRect(aRect1
);
1451 basegfx::B2DPolyPolygon aRetval
;
1452 const basegfx::B2DRange
aRange(aRect1
.Left(), aRect1
.Top(), aRect1
.Right(), aRect1
.Bottom());
1453 aRetval
.append(basegfx::tools::createPolygonFromRect(aRange
));
1457 Pointer
SdrObject::GetCreatePointer() const
1459 return Pointer(POINTER_CROSS
);
1463 void SdrObject::NbcMove(const Size
& rSiz
)
1465 MoveRect(aOutRect
,rSiz
);
1469 void SdrObject::NbcResize(const Point
& rRef
, const Fraction
& xFact
, const Fraction
& yFact
)
1471 bool bXMirr
=(xFact
.GetNumerator()<0) != (xFact
.GetDenominator()<0);
1472 bool bYMirr
=(yFact
.GetNumerator()<0) != (yFact
.GetDenominator()<0);
1473 if (bXMirr
|| bYMirr
) {
1474 Point
aRef1(GetSnapRect().Center());
1478 NbcMirrorGluePoints(aRef1
,aRef2
);
1483 NbcMirrorGluePoints(aRef1
,aRef2
);
1486 ResizeRect(aOutRect
,rRef
,xFact
,yFact
);
1490 void SdrObject::NbcRotate(const Point
& rRef
, long nWink
, double sn
, double cs
)
1492 SetGlueReallyAbsolute(true);
1493 aOutRect
.Move(-rRef
.X(),-rRef
.Y());
1494 Rectangle
R(aOutRect
);
1495 if (sn
==1.0 && cs
==0.0) { // 90deg
1496 aOutRect
.Left() =-R
.Bottom();
1497 aOutRect
.Right() =-R
.Top();
1498 aOutRect
.Top() =R
.Left();
1499 aOutRect
.Bottom()=R
.Right();
1500 } else if (sn
==0.0 && cs
==-1.0) { // 180deg
1501 aOutRect
.Left() =-R
.Right();
1502 aOutRect
.Right() =-R
.Left();
1503 aOutRect
.Top() =-R
.Bottom();
1504 aOutRect
.Bottom()=-R
.Top();
1505 } else if (sn
==-1.0 && cs
==0.0) { // 270deg
1506 aOutRect
.Left() =R
.Top();
1507 aOutRect
.Right() =R
.Bottom();
1508 aOutRect
.Top() =-R
.Right();
1509 aOutRect
.Bottom()=-R
.Left();
1511 aOutRect
.Move(rRef
.X(),rRef
.Y());
1512 aOutRect
.Justify(); // just in case
1514 NbcRotateGluePoints(rRef
,nWink
,sn
,cs
);
1515 SetGlueReallyAbsolute(false);
1518 void SdrObject::NbcMirror(const Point
& rRef1
, const Point
& rRef2
)
1520 SetGlueReallyAbsolute(true);
1521 aOutRect
.Move(-rRef1
.X(),-rRef1
.Y());
1522 Rectangle
R(aOutRect
);
1523 long dx
=rRef2
.X()-rRef1
.X();
1524 long dy
=rRef2
.Y()-rRef1
.Y();
1525 if (dx
==0) { // vertical axis
1526 aOutRect
.Left() =-R
.Right();
1527 aOutRect
.Right()=-R
.Left();
1528 } else if (dy
==0) { // horizontal axis
1529 aOutRect
.Top() =-R
.Bottom();
1530 aOutRect
.Bottom()=-R
.Top();
1531 } else if (dx
==dy
) { // 45deg axis
1532 aOutRect
.Left() =R
.Top();
1533 aOutRect
.Right() =R
.Bottom();
1534 aOutRect
.Top() =R
.Left();
1535 aOutRect
.Bottom()=R
.Right();
1536 } else if (dx
==-dy
) { // 45deg axis
1537 aOutRect
.Left() =-R
.Bottom();
1538 aOutRect
.Right() =-R
.Top();
1539 aOutRect
.Top() =-R
.Right();
1540 aOutRect
.Bottom()=-R
.Left();
1542 aOutRect
.Move(rRef1
.X(),rRef1
.Y());
1543 aOutRect
.Justify(); // just in case
1545 NbcMirrorGluePoints(rRef1
,rRef2
);
1546 SetGlueReallyAbsolute(false);
1549 void SdrObject::NbcShear(const Point
& rRef
, long nWink
, double tn
, bool bVShear
)
1551 SetGlueReallyAbsolute(true);
1552 NbcShearGluePoints(rRef
,nWink
,tn
,bVShear
);
1553 SetGlueReallyAbsolute(false);
1556 void SdrObject::Move(const Size
& rSiz
)
1558 if (rSiz
.Width()!=0 || rSiz
.Height()!=0) {
1559 Rectangle aBoundRect0
; if (pUserCall
!=NULL
) aBoundRect0
=GetLastBoundRect();
1562 BroadcastObjectChange();
1563 SendUserCall(SDRUSERCALL_MOVEONLY
,aBoundRect0
);
1567 void SdrObject::Resize(const Point
& rRef
, const Fraction
& xFact
, const Fraction
& yFact
, bool bUnsetRelative
)
1569 if (xFact
.GetNumerator()!=xFact
.GetDenominator() || yFact
.GetNumerator()!=yFact
.GetDenominator()) {
1572 mnRelativeWidth
.reset( );
1573 mnRelativeHeight
.reset( );
1575 Rectangle aBoundRect0
; if (pUserCall
!=NULL
) aBoundRect0
=GetLastBoundRect();
1576 NbcResize(rRef
,xFact
,yFact
);
1578 BroadcastObjectChange();
1579 SendUserCall(SDRUSERCALL_RESIZE
,aBoundRect0
);
1583 void SdrObject::Rotate(const Point
& rRef
, long nWink
, double sn
, double cs
)
1586 Rectangle aBoundRect0
; if (pUserCall
!=NULL
) aBoundRect0
=GetLastBoundRect();
1587 NbcRotate(rRef
,nWink
,sn
,cs
);
1589 BroadcastObjectChange();
1590 SendUserCall(SDRUSERCALL_RESIZE
,aBoundRect0
);
1594 void SdrObject::Mirror(const Point
& rRef1
, const Point
& rRef2
)
1596 Rectangle aBoundRect0
; if (pUserCall
!=NULL
) aBoundRect0
=GetLastBoundRect();
1597 NbcMirror(rRef1
,rRef2
);
1599 BroadcastObjectChange();
1600 SendUserCall(SDRUSERCALL_RESIZE
,aBoundRect0
);
1603 void SdrObject::Shear(const Point
& rRef
, long nWink
, double tn
, bool bVShear
)
1606 Rectangle aBoundRect0
; if (pUserCall
!=NULL
) aBoundRect0
=GetLastBoundRect();
1607 NbcShear(rRef
,nWink
,tn
,bVShear
);
1609 BroadcastObjectChange();
1610 SendUserCall(SDRUSERCALL_RESIZE
,aBoundRect0
);
1614 void SdrObject::NbcSetRelativePos(const Point
& rPnt
)
1616 Point
aRelPos0(GetSnapRect().TopLeft()-aAnchor
);
1617 Size
aSiz(rPnt
.X()-aRelPos0
.X(),rPnt
.Y()-aRelPos0
.Y());
1618 NbcMove(aSiz
); // This also calls SetRectsDirty()
1621 void SdrObject::SetRelativePos(const Point
& rPnt
)
1623 if (rPnt
!=GetRelativePos()) {
1624 Rectangle aBoundRect0
; if (pUserCall
!=NULL
) aBoundRect0
=GetLastBoundRect();
1625 NbcSetRelativePos(rPnt
);
1627 BroadcastObjectChange();
1628 SendUserCall(SDRUSERCALL_MOVEONLY
,aBoundRect0
);
1632 Point
SdrObject::GetRelativePos() const
1634 return GetSnapRect().TopLeft()-aAnchor
;
1637 void SdrObject::ImpSetAnchorPos(const Point
& rPnt
)
1642 void SdrObject::NbcSetAnchorPos(const Point
& rPnt
)
1644 Size
aSiz(rPnt
.X()-aAnchor
.X(),rPnt
.Y()-aAnchor
.Y());
1646 NbcMove(aSiz
); // This also calls SetRectsDirty()
1649 void SdrObject::SetAnchorPos(const Point
& rPnt
)
1651 if (rPnt
!=aAnchor
) {
1652 Rectangle aBoundRect0
; if (pUserCall
!=NULL
) aBoundRect0
=GetLastBoundRect();
1653 NbcSetAnchorPos(rPnt
);
1655 BroadcastObjectChange();
1656 SendUserCall(SDRUSERCALL_MOVEONLY
,aBoundRect0
);
1660 const Point
& SdrObject::GetAnchorPos() const
1665 void SdrObject::RecalcSnapRect()
1669 const Rectangle
& SdrObject::GetSnapRect() const
1674 void SdrObject::NbcSetSnapRect(const Rectangle
& rRect
)
1679 const Rectangle
& SdrObject::GetLogicRect() const
1681 return GetSnapRect();
1684 void SdrObject::NbcSetLogicRect(const Rectangle
& rRect
)
1686 NbcSetSnapRect(rRect
);
1689 void SdrObject::AdjustToMaxRect( const Rectangle
& rMaxRect
, bool /* bShrinkOnly = false */ )
1691 SetLogicRect( rMaxRect
);
1694 void SdrObject::SetSnapRect(const Rectangle
& rRect
)
1696 Rectangle aBoundRect0
; if (pUserCall
!=NULL
) aBoundRect0
=GetLastBoundRect();
1697 NbcSetSnapRect(rRect
);
1699 BroadcastObjectChange();
1700 SendUserCall(SDRUSERCALL_RESIZE
,aBoundRect0
);
1703 void SdrObject::SetLogicRect(const Rectangle
& rRect
)
1705 Rectangle aBoundRect0
; if (pUserCall
!=NULL
) aBoundRect0
=GetLastBoundRect();
1706 NbcSetLogicRect(rRect
);
1708 BroadcastObjectChange();
1709 SendUserCall(SDRUSERCALL_RESIZE
,aBoundRect0
);
1712 long SdrObject::GetRotateAngle() const
1717 long SdrObject::GetShearAngle(bool /*bVertical*/) const
1722 sal_uInt32
SdrObject::GetSnapPointCount() const
1724 return GetPointCount();
1727 Point
SdrObject::GetSnapPoint(sal_uInt32 i
) const
1732 sal_Bool
SdrObject::IsPolyObj() const
1737 sal_uInt32
SdrObject::GetPointCount() const
1742 Point
SdrObject::GetPoint(sal_uInt32
/*i*/) const
1747 void SdrObject::SetPoint(const Point
& rPnt
, sal_uInt32 i
)
1749 Rectangle aBoundRect0
; if (pUserCall
!=NULL
) aBoundRect0
=GetLastBoundRect();
1750 NbcSetPoint(rPnt
, i
);
1752 BroadcastObjectChange();
1753 SendUserCall(SDRUSERCALL_RESIZE
,aBoundRect0
);
1756 void SdrObject::NbcSetPoint(const Point
& /*rPnt*/, sal_uInt32
/*i*/)
1760 bool SdrObject::HasTextEdit() const
1765 sal_Bool
SdrObject::BegTextEdit(SdrOutliner
& /*rOutl*/)
1770 void SdrObject::EndTextEdit(SdrOutliner
& /*rOutl*/)
1774 void SdrObject::SetOutlinerParaObject(OutlinerParaObject
* pTextObject
)
1776 Rectangle aBoundRect0
; if (pUserCall
!=NULL
) aBoundRect0
=GetLastBoundRect();
1777 NbcSetOutlinerParaObject(pTextObject
);
1779 BroadcastObjectChange();
1780 if (GetCurrentBoundRect()!=aBoundRect0
) {
1781 SendUserCall(SDRUSERCALL_RESIZE
,aBoundRect0
);
1785 void SdrObject::NbcSetOutlinerParaObject(OutlinerParaObject
* /*pTextObject*/)
1789 OutlinerParaObject
* SdrObject::GetOutlinerParaObject() const
1794 void SdrObject::NbcReformatText()
1798 void SdrObject::ReformatText()
1800 Rectangle aBoundRect0
; if (pUserCall
!=NULL
) aBoundRect0
=GetLastBoundRect();
1803 BroadcastObjectChange();
1804 if (GetCurrentBoundRect()!=aBoundRect0
) {
1805 SendUserCall(SDRUSERCALL_RESIZE
,aBoundRect0
);
1809 void SdrObject::BurnInStyleSheetAttributes()
1811 GetProperties().ForceStyleToHardAttributes();
1814 SdrObjUserData
* SdrObject::ImpGetMacroUserData() const
1816 SdrObjUserData
* pData
=NULL
;
1817 sal_uInt16 nAnz
=GetUserDataCount();
1818 for (sal_uInt16 nNum
=nAnz
; nNum
>0 && pData
==NULL
;) {
1820 pData
=GetUserData(nNum
);
1821 if (!pData
->HasMacro(this)) pData
=NULL
;
1826 bool SdrObject::HasMacro() const
1828 SdrObjUserData
* pData
=ImpGetMacroUserData();
1829 return pData
!=NULL
? pData
->HasMacro(this) : false;
1832 SdrObject
* SdrObject::CheckMacroHit(const SdrObjMacroHitRec
& rRec
) const
1834 SdrObjUserData
* pData
= ImpGetMacroUserData();
1838 return pData
->CheckMacroHit(rRec
, this);
1843 return SdrObjectPrimitiveHit(*this, rRec
.aPos
, rRec
.nTol
, *rRec
.pPageView
, rRec
.pVisiLayer
, false);
1849 Pointer
SdrObject::GetMacroPointer(const SdrObjMacroHitRec
& rRec
) const
1851 SdrObjUserData
* pData
=ImpGetMacroUserData();
1853 return pData
->GetMacroPointer(rRec
,this);
1855 return Pointer(POINTER_REFHAND
);
1858 void SdrObject::PaintMacro(OutputDevice
& rOut
, const Rectangle
& rDirtyRect
, const SdrObjMacroHitRec
& rRec
) const
1860 SdrObjUserData
* pData
=ImpGetMacroUserData();
1864 pData
->PaintMacro(rOut
,rDirtyRect
,rRec
,this);
1868 const RasterOp
eRop(rOut
.GetRasterOp());
1869 const basegfx::B2DPolyPolygon
aPolyPolygon(TakeXorPoly());
1870 const sal_uInt32
nCount(aPolyPolygon
.count());
1872 rOut
.SetLineColor(COL_BLACK
);
1873 rOut
.SetFillColor();
1874 rOut
.SetRasterOp(ROP_INVERT
);
1876 for(sal_uInt32
a(0); a
< nCount
; a
++)
1878 rOut
.DrawPolyLine(aPolyPolygon
.getB2DPolygon(a
));
1881 rOut
.SetRasterOp(eRop
);
1885 bool SdrObject::DoMacro(const SdrObjMacroHitRec
& rRec
)
1887 SdrObjUserData
* pData
=ImpGetMacroUserData();
1889 return pData
->DoMacro(rRec
,this);
1894 OUString
SdrObject::GetMacroPopupComment(const SdrObjMacroHitRec
& rRec
) const
1896 SdrObjUserData
* pData
=ImpGetMacroUserData();
1898 return pData
->GetMacroPopupComment(rRec
,this);
1903 bool SdrObject::IsMacroHit(const SdrObjMacroHitRec
& rRec
) const
1905 return CheckMacroHit(rRec
) != NULL
;
1908 ////////////////////////////////////////////////////////////////////////////////////////////////////
1910 SdrObjGeoData
* SdrObject::NewGeoData() const
1912 return new SdrObjGeoData
;
1915 void SdrObject::SaveGeoData(SdrObjGeoData
& rGeo
) const
1917 rGeo
.aBoundRect
=GetCurrentBoundRect();
1918 rGeo
.aAnchor
=aAnchor
;
1919 rGeo
.bMovProt
=bMovProt
;
1920 rGeo
.bSizProt
=bSizProt
;
1921 rGeo
.bNoPrint
=bNoPrint
;
1922 rGeo
.mbVisible
=mbVisible
;
1923 rGeo
.bClosedObj
=bClosedObj
;
1924 rGeo
.mnLayerID
= mnLayerID
;
1926 // user-defined glue points
1927 if (pPlusData
!=NULL
&& pPlusData
->pGluePoints
!=NULL
) {
1928 if (rGeo
.pGPL
!=NULL
) {
1929 *rGeo
.pGPL
=*pPlusData
->pGluePoints
;
1931 rGeo
.pGPL
=new SdrGluePointList(*pPlusData
->pGluePoints
);
1934 if (rGeo
.pGPL
!=NULL
) {
1941 void SdrObject::RestGeoData(const SdrObjGeoData
& rGeo
)
1944 aOutRect
=rGeo
.aBoundRect
;
1945 aAnchor
=rGeo
.aAnchor
;
1946 bMovProt
=rGeo
.bMovProt
;
1947 bSizProt
=rGeo
.bSizProt
;
1948 bNoPrint
=rGeo
.bNoPrint
;
1949 mbVisible
=rGeo
.mbVisible
;
1950 bClosedObj
=rGeo
.bClosedObj
;
1951 mnLayerID
= rGeo
.mnLayerID
;
1953 // user-defined glue points
1954 if (rGeo
.pGPL
!=NULL
) {
1956 if (pPlusData
->pGluePoints
!=NULL
) {
1957 *pPlusData
->pGluePoints
=*rGeo
.pGPL
;
1959 pPlusData
->pGluePoints
=new SdrGluePointList(*rGeo
.pGPL
);
1962 if (pPlusData
!=NULL
&& pPlusData
->pGluePoints
!=NULL
) {
1963 delete pPlusData
->pGluePoints
;
1964 pPlusData
->pGluePoints
=NULL
;
1969 SdrObjGeoData
* SdrObject::GetGeoData() const
1971 SdrObjGeoData
* pGeo
=NewGeoData();
1976 void SdrObject::SetGeoData(const SdrObjGeoData
& rGeo
)
1978 Rectangle aBoundRect0
; if (pUserCall
!=NULL
) aBoundRect0
=GetLastBoundRect();
1981 BroadcastObjectChange();
1982 SendUserCall(SDRUSERCALL_RESIZE
,aBoundRect0
);
1985 ////////////////////////////////////////////////////////////////////////////////////////////////////
1988 const SfxItemSet
& SdrObject::GetObjectItemSet() const
1990 return GetProperties().GetObjectItemSet();
1993 const SfxItemSet
& SdrObject::GetMergedItemSet() const
1995 return GetProperties().GetMergedItemSet();
1998 void SdrObject::SetObjectItem(const SfxPoolItem
& rItem
)
2000 GetProperties().SetObjectItem(rItem
);
2003 void SdrObject::SetMergedItem(const SfxPoolItem
& rItem
)
2005 GetProperties().SetMergedItem(rItem
);
2008 void SdrObject::ClearMergedItem(const sal_uInt16 nWhich
)
2010 GetProperties().ClearMergedItem(nWhich
);
2013 void SdrObject::SetObjectItemSet(const SfxItemSet
& rSet
)
2015 GetProperties().SetObjectItemSet(rSet
);
2018 void SdrObject::SetMergedItemSet(const SfxItemSet
& rSet
, bool bClearAllItems
)
2020 GetProperties().SetMergedItemSet(rSet
, bClearAllItems
);
2023 const SfxPoolItem
& SdrObject::GetObjectItem(const sal_uInt16 nWhich
) const
2025 return GetObjectItemSet().Get(nWhich
);
2028 SfxMapUnit
SdrObject::GetObjectMapUnit() const
2030 SfxMapUnit
aRetval(SFX_MAPUNIT_100TH_MM
);
2031 SdrItemPool
* pPool
= GetObjectItemPool();
2035 aRetval
= pPool
->GetMetric(0);
2039 OSL_ENSURE(pPool
, "SdrObjects always need a pool (!)");
2045 const SfxPoolItem
& SdrObject::GetMergedItem(const sal_uInt16 nWhich
) const
2047 return GetMergedItemSet().Get(nWhich
);
2050 void SdrObject::SetMergedItemSetAndBroadcast(const SfxItemSet
& rSet
, bool bClearAllItems
)
2052 GetProperties().SetMergedItemSetAndBroadcast(rSet
, bClearAllItems
);
2055 void SdrObject::ApplyNotPersistAttr(const SfxItemSet
& rAttr
)
2057 Rectangle aBoundRect0
; if (pUserCall
!=NULL
) aBoundRect0
=GetLastBoundRect();
2058 NbcApplyNotPersistAttr(rAttr
);
2060 BroadcastObjectChange();
2061 SendUserCall(SDRUSERCALL_RESIZE
,aBoundRect0
);
2064 void SdrObject::NbcApplyNotPersistAttr(const SfxItemSet
& rAttr
)
2066 const Rectangle
& rSnap
=GetSnapRect();
2067 const Rectangle
& rLogic
=GetLogicRect();
2068 Point
aRef1(rSnap
.Center());
2069 Point
aRef2(aRef1
); aRef2
.Y()++;
2070 const SfxPoolItem
*pPoolItem
=NULL
;
2071 if (rAttr
.GetItemState(SDRATTR_TRANSFORMREF1X
,true,&pPoolItem
)==SFX_ITEM_SET
) {
2072 aRef1
.X()=((const SdrTransformRef1XItem
*)pPoolItem
)->GetValue();
2074 if (rAttr
.GetItemState(SDRATTR_TRANSFORMREF1Y
,true,&pPoolItem
)==SFX_ITEM_SET
) {
2075 aRef1
.Y()=((const SdrTransformRef1YItem
*)pPoolItem
)->GetValue();
2077 if (rAttr
.GetItemState(SDRATTR_TRANSFORMREF2X
,true,&pPoolItem
)==SFX_ITEM_SET
) {
2078 aRef2
.X()=((const SdrTransformRef2XItem
*)pPoolItem
)->GetValue();
2080 if (rAttr
.GetItemState(SDRATTR_TRANSFORMREF2Y
,true,&pPoolItem
)==SFX_ITEM_SET
) {
2081 aRef2
.Y()=((const SdrTransformRef2YItem
*)pPoolItem
)->GetValue();
2084 Rectangle
aNewSnap(rSnap
);
2085 if (rAttr
.GetItemState(SDRATTR_MOVEX
,true,&pPoolItem
)==SFX_ITEM_SET
) {
2086 long n
=((const SdrMoveXItem
*)pPoolItem
)->GetValue();
2089 if (rAttr
.GetItemState(SDRATTR_MOVEY
,true,&pPoolItem
)==SFX_ITEM_SET
) {
2090 long n
=((const SdrMoveYItem
*)pPoolItem
)->GetValue();
2093 if (rAttr
.GetItemState(SDRATTR_ONEPOSITIONX
,true,&pPoolItem
)==SFX_ITEM_SET
) {
2094 long n
=((const SdrOnePositionXItem
*)pPoolItem
)->GetValue();
2095 aNewSnap
.Move(n
-aNewSnap
.Left(),0);
2097 if (rAttr
.GetItemState(SDRATTR_ONEPOSITIONY
,true,&pPoolItem
)==SFX_ITEM_SET
) {
2098 long n
=((const SdrOnePositionYItem
*)pPoolItem
)->GetValue();
2099 aNewSnap
.Move(0,n
-aNewSnap
.Top());
2101 if (rAttr
.GetItemState(SDRATTR_ONESIZEWIDTH
,true,&pPoolItem
)==SFX_ITEM_SET
) {
2102 long n
=((const SdrOneSizeWidthItem
*)pPoolItem
)->GetValue();
2103 aNewSnap
.Right()=aNewSnap
.Left()+n
;
2105 if (rAttr
.GetItemState(SDRATTR_ONESIZEHEIGHT
,true,&pPoolItem
)==SFX_ITEM_SET
) {
2106 long n
=((const SdrOneSizeHeightItem
*)pPoolItem
)->GetValue();
2107 aNewSnap
.Bottom()=aNewSnap
.Top()+n
;
2109 if (aNewSnap
!=rSnap
) {
2110 if (aNewSnap
.GetSize()==rSnap
.GetSize()) {
2111 NbcMove(Size(aNewSnap
.Left()-rSnap
.Left(),aNewSnap
.Top()-rSnap
.Top()));
2113 NbcSetSnapRect(aNewSnap
);
2117 if (rAttr
.GetItemState(SDRATTR_SHEARANGLE
,true,&pPoolItem
)==SFX_ITEM_SET
) {
2118 long n
=((const SdrShearAngleItem
*)pPoolItem
)->GetValue();
2121 double nTan
=tan(n
*nPi180
);
2122 NbcShear(aRef1
,n
,nTan
,false);
2125 if (rAttr
.GetItemState(SDRATTR_ROTATEANGLE
,true,&pPoolItem
)==SFX_ITEM_SET
) {
2126 long n
=((const SdrRotateAngleItem
*)pPoolItem
)->GetValue();
2127 n
-=GetRotateAngle();
2129 double nSin
=sin(n
*nPi180
);
2130 double nCos
=cos(n
*nPi180
);
2131 NbcRotate(aRef1
,n
,nSin
,nCos
);
2134 if (rAttr
.GetItemState(SDRATTR_ROTATEONE
,true,&pPoolItem
)==SFX_ITEM_SET
) {
2135 long n
=((const SdrRotateOneItem
*)pPoolItem
)->GetValue();
2136 double nSin
=sin(n
*nPi180
);
2137 double nCos
=cos(n
*nPi180
);
2138 NbcRotate(aRef1
,n
,nSin
,nCos
);
2140 if (rAttr
.GetItemState(SDRATTR_HORZSHEARONE
,true,&pPoolItem
)==SFX_ITEM_SET
) {
2141 long n
=((const SdrHorzShearOneItem
*)pPoolItem
)->GetValue();
2142 double nTan
=tan(n
*nPi180
);
2143 NbcShear(aRef1
,n
,nTan
,false);
2145 if (rAttr
.GetItemState(SDRATTR_VERTSHEARONE
,true,&pPoolItem
)==SFX_ITEM_SET
) {
2146 long n
=((const SdrVertShearOneItem
*)pPoolItem
)->GetValue();
2147 double nTan
=tan(n
*nPi180
);
2148 NbcShear(aRef1
,n
,nTan
,true);
2151 if (rAttr
.GetItemState(SDRATTR_OBJMOVEPROTECT
,true,&pPoolItem
)==SFX_ITEM_SET
) {
2152 bool b
=((const SdrObjMoveProtectItem
*)pPoolItem
)->GetValue();
2155 if (rAttr
.GetItemState(SDRATTR_OBJSIZEPROTECT
,true,&pPoolItem
)==SFX_ITEM_SET
) {
2156 bool b
=((const SdrObjSizeProtectItem
*)pPoolItem
)->GetValue();
2157 SetResizeProtect(b
);
2160 /* move protect always sets size protect */
2161 if( IsMoveProtect() )
2162 SetResizeProtect( true );
2164 if (rAttr
.GetItemState(SDRATTR_OBJPRINTABLE
,true,&pPoolItem
)==SFX_ITEM_SET
) {
2165 bool b
=((const SdrObjPrintableItem
*)pPoolItem
)->GetValue();
2169 if (rAttr
.GetItemState(SDRATTR_OBJVISIBLE
,true,&pPoolItem
)==SFX_ITEM_SET
) {
2170 bool b
=((const SdrObjVisibleItem
*)pPoolItem
)->GetValue();
2174 SdrLayerID nLayer
=SDRLAYER_NOTFOUND
;
2175 if (rAttr
.GetItemState(SDRATTR_LAYERID
,true,&pPoolItem
)==SFX_ITEM_SET
) {
2176 nLayer
=((const SdrLayerIdItem
*)pPoolItem
)->GetValue();
2178 if (rAttr
.GetItemState(SDRATTR_LAYERNAME
,true,&pPoolItem
)==SFX_ITEM_SET
&& pModel
!=NULL
) {
2179 XubString aLayerName
=((const SdrLayerNameItem
*)pPoolItem
)->GetValue();
2180 const SdrLayerAdmin
* pLayAd
=pPage
!=NULL
? &pPage
->GetLayerAdmin() : pModel
!=NULL
? &pModel
->GetLayerAdmin() : NULL
;
2182 const SdrLayer
* pLayer
=pLayAd
->GetLayer(aLayerName
, true);
2184 nLayer
=pLayer
->GetID();
2189 if (nLayer
!=SDRLAYER_NOTFOUND
) {
2190 NbcSetLayer(nLayer
);
2193 if (rAttr
.GetItemState(SDRATTR_OBJECTNAME
,true,&pPoolItem
)==SFX_ITEM_SET
) {
2194 XubString aName
=((const SdrObjectNameItem
*)pPoolItem
)->GetValue();
2197 Rectangle
aNewLogic(rLogic
);
2198 if (rAttr
.GetItemState(SDRATTR_LOGICSIZEWIDTH
,true,&pPoolItem
)==SFX_ITEM_SET
) {
2199 long n
=((const SdrLogicSizeWidthItem
*)pPoolItem
)->GetValue();
2200 aNewLogic
.Right()=aNewLogic
.Left()+n
;
2202 if (rAttr
.GetItemState(SDRATTR_LOGICSIZEHEIGHT
,true,&pPoolItem
)==SFX_ITEM_SET
) {
2203 long n
=((const SdrLogicSizeHeightItem
*)pPoolItem
)->GetValue();
2204 aNewLogic
.Bottom()=aNewLogic
.Top()+n
;
2206 if (aNewLogic
!=rLogic
) {
2207 NbcSetLogicRect(aNewLogic
);
2209 Fraction
aResizeX(1,1);
2210 Fraction
aResizeY(1,1);
2211 if (rAttr
.GetItemState(SDRATTR_RESIZEXONE
,true,&pPoolItem
)==SFX_ITEM_SET
) {
2212 aResizeX
*=((const SdrResizeXOneItem
*)pPoolItem
)->GetValue();
2214 if (rAttr
.GetItemState(SDRATTR_RESIZEYONE
,true,&pPoolItem
)==SFX_ITEM_SET
) {
2215 aResizeY
*=((const SdrResizeYOneItem
*)pPoolItem
)->GetValue();
2217 if (aResizeX
!=Fraction(1,1) || aResizeY
!=Fraction(1,1)) {
2218 NbcResize(aRef1
,aResizeX
,aResizeY
);
2222 static void lcl_SetItem(SfxItemSet
& rAttr
, bool bMerge
, const SfxPoolItem
& rItem
)
2224 if (bMerge
) rAttr
.MergeValue(rItem
,true);
2225 else rAttr
.Put(rItem
);
2228 void SdrObject::TakeNotPersistAttr(SfxItemSet
& rAttr
, bool bMerge
) const
2230 const Rectangle
& rSnap
=GetSnapRect();
2231 const Rectangle
& rLogic
=GetLogicRect();
2232 lcl_SetItem(rAttr
,bMerge
,SdrObjMoveProtectItem(IsMoveProtect()));
2233 lcl_SetItem(rAttr
,bMerge
,SdrObjSizeProtectItem(IsResizeProtect()));
2234 lcl_SetItem(rAttr
,bMerge
,SdrObjPrintableItem(IsPrintable()));
2235 lcl_SetItem(rAttr
,bMerge
,SdrObjVisibleItem(IsVisible()));
2236 lcl_SetItem(rAttr
,bMerge
,SdrRotateAngleItem(GetRotateAngle()));
2237 lcl_SetItem(rAttr
,bMerge
,SdrShearAngleItem(GetShearAngle()));
2238 lcl_SetItem(rAttr
,bMerge
,SdrOneSizeWidthItem(rSnap
.GetWidth()-1));
2239 lcl_SetItem(rAttr
,bMerge
,SdrOneSizeHeightItem(rSnap
.GetHeight()-1));
2240 lcl_SetItem(rAttr
,bMerge
,SdrOnePositionXItem(rSnap
.Left()));
2241 lcl_SetItem(rAttr
,bMerge
,SdrOnePositionYItem(rSnap
.Top()));
2242 if (rLogic
.GetWidth()!=rSnap
.GetWidth()) {
2243 lcl_SetItem(rAttr
,bMerge
,SdrLogicSizeWidthItem(rLogic
.GetWidth()-1));
2245 if (rLogic
.GetHeight()!=rSnap
.GetHeight()) {
2246 lcl_SetItem(rAttr
,bMerge
,SdrLogicSizeHeightItem(rLogic
.GetHeight()-1));
2248 XubString
aName(GetName());
2252 lcl_SetItem(rAttr
, bMerge
, SdrObjectNameItem(aName
));
2255 lcl_SetItem(rAttr
,bMerge
,SdrLayerIdItem(GetLayer()));
2256 const SdrLayerAdmin
* pLayAd
=pPage
!=NULL
? &pPage
->GetLayerAdmin() : pModel
!=NULL
? &pModel
->GetLayerAdmin() : NULL
;
2258 const SdrLayer
* pLayer
=pLayAd
->GetLayerPerID(GetLayer());
2260 lcl_SetItem(rAttr
,bMerge
,SdrLayerNameItem(pLayer
->GetName()));
2263 Point
aRef1(rSnap
.Center());
2264 Point
aRef2(aRef1
); aRef2
.Y()++;
2265 lcl_SetItem(rAttr
,bMerge
,SdrTransformRef1XItem(aRef1
.X()));
2266 lcl_SetItem(rAttr
,bMerge
,SdrTransformRef1YItem(aRef1
.Y()));
2267 lcl_SetItem(rAttr
,bMerge
,SdrTransformRef2XItem(aRef2
.X()));
2268 lcl_SetItem(rAttr
,bMerge
,SdrTransformRef2YItem(aRef2
.Y()));
2271 SfxStyleSheet
* SdrObject::GetStyleSheet() const
2273 return GetProperties().GetStyleSheet();
2276 void SdrObject::SetStyleSheet(SfxStyleSheet
* pNewStyleSheet
, bool bDontRemoveHardAttr
)
2278 Rectangle aBoundRect0
;
2281 aBoundRect0
= GetLastBoundRect();
2283 NbcSetStyleSheet(pNewStyleSheet
, bDontRemoveHardAttr
);
2285 BroadcastObjectChange();
2286 SendUserCall(SDRUSERCALL_CHGATTR
, aBoundRect0
);
2289 void SdrObject::NbcSetStyleSheet(SfxStyleSheet
* pNewStyleSheet
, sal_Bool bDontRemoveHardAttr
)
2291 // only allow graphic and presentation styles for shapes
2292 if( pNewStyleSheet
&& (pNewStyleSheet
->GetFamily() == SFX_STYLE_FAMILY_PARA
) && (pNewStyleSheet
->GetFamily() == SFX_STYLE_FAMILY_PAGE
) )
2295 GetProperties().SetStyleSheet(pNewStyleSheet
, bDontRemoveHardAttr
);
2298 // Broadcasting while setting attributes is managed by the AttrObj.
2299 ////////////////////////////////////////////////////////////////////////////////////////////////////
2301 bool SdrObject::IsNode() const
2306 SdrGluePoint
SdrObject::GetVertexGluePoint(sal_uInt16 nPosNum
) const
2308 // #i41936# Use SnapRect for default GluePoints
2309 const Rectangle
aR(GetSnapRect());
2314 case 0 : aPt
= aR
.TopCenter(); break;
2315 case 1 : aPt
= aR
.RightCenter(); break;
2316 case 2 : aPt
= aR
.BottomCenter(); break;
2317 case 3 : aPt
= aR
.LeftCenter(); break;
2321 SdrGluePoint
aGP(aPt
);
2322 aGP
.SetPercent(false);
2327 SdrGluePoint
SdrObject::GetCornerGluePoint(sal_uInt16 nPosNum
) const
2329 Rectangle
aR(GetCurrentBoundRect());
2332 case 0 : aPt
=aR
.TopLeft(); break;
2333 case 1 : aPt
=aR
.TopRight(); break;
2334 case 2 : aPt
=aR
.BottomRight(); break;
2335 case 3 : aPt
=aR
.BottomLeft(); break;
2337 aPt
-=GetSnapRect().Center();
2338 SdrGluePoint
aGP(aPt
);
2339 aGP
.SetPercent(false);
2343 const SdrGluePointList
* SdrObject::GetGluePointList() const
2345 if (pPlusData
!=NULL
) return pPlusData
->pGluePoints
;
2350 SdrGluePointList
* SdrObject::ForceGluePointList()
2353 if (pPlusData
->pGluePoints
==NULL
) {
2354 pPlusData
->pGluePoints
=new SdrGluePointList
;
2356 return pPlusData
->pGluePoints
;
2359 void SdrObject::SetGlueReallyAbsolute(bool bOn
)
2361 // First a const call to see whether there are any glue points.
2362 // Force const call!
2363 if (GetGluePointList()!=NULL
) {
2364 SdrGluePointList
* pGPL
=ForceGluePointList();
2365 pGPL
->SetReallyAbsolute(bOn
,*this);
2369 void SdrObject::NbcRotateGluePoints(const Point
& rRef
, long nWink
, double sn
, double cs
)
2371 // First a const call to see whether there are any glue points.
2372 // Force const call!
2373 if (GetGluePointList()!=NULL
) {
2374 SdrGluePointList
* pGPL
=ForceGluePointList();
2375 pGPL
->Rotate(rRef
,nWink
,sn
,cs
,this);
2379 void SdrObject::NbcMirrorGluePoints(const Point
& rRef1
, const Point
& rRef2
)
2381 // First a const call to see whether there are any glue points.
2382 // Force const call!
2383 if (GetGluePointList()!=NULL
) {
2384 SdrGluePointList
* pGPL
=ForceGluePointList();
2385 pGPL
->Mirror(rRef1
,rRef2
,this);
2389 void SdrObject::NbcShearGluePoints(const Point
& rRef
, long nWink
, double tn
, bool bVShear
)
2391 // First a const call to see whether there are any glue points.
2392 // Force const call!
2393 if (GetGluePointList()!=NULL
) {
2394 SdrGluePointList
* pGPL
=ForceGluePointList();
2395 pGPL
->Shear(rRef
,nWink
,tn
,bVShear
,this);
2399 bool SdrObject::IsEdge() const
2404 void SdrObject::ConnectToNode(bool /*bTail1*/, SdrObject
* /*pObj*/)
2408 void SdrObject::DisconnectFromNode(bool /*bTail1*/)
2412 SdrObject
* SdrObject::GetConnectedNode(bool /*bTail1*/) const
2417 ////////////////////////////////////////////////////////////////////////////////////////////////////
2419 SdrObject
* SdrObject::ImpConvertToContourObj(SdrObject
* pRet
, bool bForceLineDash
) const
2421 bool bNoChange(true);
2423 if(pRet
->LineGeometryUsageIsNecessary())
2425 basegfx::B2DPolyPolygon aMergedLineFillPolyPolygon
;
2426 basegfx::B2DPolyPolygon aMergedHairlinePolyPolygon
;
2427 const drawinglayer::primitive2d::Primitive2DSequence
xSequence(pRet
->GetViewContact().getViewIndependentPrimitive2DSequence());
2429 if(xSequence
.hasElements())
2431 // use neutral ViewInformation
2432 const drawinglayer::geometry::ViewInformation2D aViewInformation2D
;
2434 // create extractor, process and get result
2435 drawinglayer::processor2d::LineGeometryExtractor2D
aExtractor(aViewInformation2D
);
2436 aExtractor
.process(xSequence
);
2438 // #i102241# check for line results
2439 const basegfx::B2DPolygonVector
& rHairlineVector
= aExtractor
.getExtractedHairlines();
2441 if(!rHairlineVector
.empty())
2443 // for SdrObject creation, just copy all to a single Hairline-PolyPolygon
2444 for(sal_uInt32
a(0); a
< rHairlineVector
.size(); a
++)
2446 aMergedHairlinePolyPolygon
.append(rHairlineVector
[a
]);
2450 // #i102241# check for fill rsults
2451 const basegfx::B2DPolyPolygonVector
& rLineFillVector(aExtractor
.getExtractedLineFills());
2453 if(!rLineFillVector
.empty())
2455 // merge to a single PolyPolygon (OR)
2456 aMergedLineFillPolyPolygon
= basegfx::tools::mergeToSinglePolyPolygon(rLineFillVector
);
2460 // || aMergedHairlinePolyPolygon.Count() removed; the conversion is ONLY
2461 // useful when new closed filled polygons are created
2462 if(aMergedLineFillPolyPolygon
.count() || (bForceLineDash
&& aMergedHairlinePolyPolygon
.count()))
2464 SfxItemSet
aSet(pRet
->GetMergedItemSet());
2465 XFillStyle eOldFillStyle
= ((const XFillStyleItem
&)(aSet
.Get(XATTR_FILLSTYLE
))).GetValue();
2466 SdrPathObj
* aLinePolygonPart
= NULL
;
2467 SdrPathObj
* aLineHairlinePart
= NULL
;
2468 bool bBuildGroup(false);
2470 if(aMergedLineFillPolyPolygon
.count())
2472 // create SdrObject for filled line geometry
2473 aLinePolygonPart
= new SdrPathObj(OBJ_PATHFILL
, aMergedLineFillPolyPolygon
);
2474 aLinePolygonPart
->SetModel(pRet
->GetModel());
2476 // correct item properties
2477 aSet
.Put(XLineWidthItem(0L));
2478 aSet
.Put(XLineStyleItem(XLINE_NONE
));
2479 Color aColorLine
= ((const XLineColorItem
&)(aSet
.Get(XATTR_LINECOLOR
))).GetColorValue();
2480 sal_uInt16 nTransLine
= ((const XLineTransparenceItem
&)(aSet
.Get(XATTR_LINETRANSPARENCE
))).GetValue();
2481 aSet
.Put(XFillColorItem(XubString(), aColorLine
));
2482 aSet
.Put(XFillStyleItem(XFILL_SOLID
));
2483 aSet
.Put(XFillTransparenceItem(nTransLine
));
2485 aLinePolygonPart
->SetMergedItemSet(aSet
);
2488 if(aMergedHairlinePolyPolygon
.count())
2490 // create SdrObject for hairline geometry
2491 // OBJ_PATHLINE is necessary here, not OBJ_PATHFILL. This is intended
2492 // to get a non-filled object. If the poly is closed, the PathObj takes care for
2493 // the correct closed state.
2494 aLineHairlinePart
= new SdrPathObj(OBJ_PATHLINE
, aMergedHairlinePolyPolygon
);
2495 aLineHairlinePart
->SetModel(pRet
->GetModel());
2497 aSet
.Put(XLineWidthItem(0L));
2498 aSet
.Put(XFillStyleItem(XFILL_NONE
));
2499 aSet
.Put(XLineStyleItem(XLINE_SOLID
));
2501 // it is also necessary to switch off line start and ends here
2502 aSet
.Put(XLineStartWidthItem(0));
2503 aSet
.Put(XLineEndWidthItem(0));
2505 aLineHairlinePart
->SetMergedItemSet(aSet
);
2507 if(aLinePolygonPart
)
2513 // check if original geometry should be added (e.g. filled and closed)
2514 bool bAddOriginalGeometry(false);
2515 SdrPathObj
* pPath
= PTR_CAST(SdrPathObj
, pRet
);
2517 if(pPath
&& pPath
->IsClosed())
2519 if(eOldFillStyle
!= XFILL_NONE
)
2521 bAddOriginalGeometry
= true;
2525 // do we need a group?
2526 if(bBuildGroup
|| bAddOriginalGeometry
)
2528 SdrObject
* pGroup
= new SdrObjGroup
;
2529 pGroup
->SetModel(pRet
->GetModel());
2531 if(bAddOriginalGeometry
)
2533 // Add a clone of the original geometry.
2535 aSet
.Put(pRet
->GetMergedItemSet());
2536 aSet
.Put(XLineStyleItem(XLINE_NONE
));
2537 aSet
.Put(XLineWidthItem(0L));
2539 SdrObject
* pClone
= pRet
->Clone();
2541 pClone
->SetModel(pRet
->GetModel());
2542 pClone
->SetMergedItemSet(aSet
);
2544 pGroup
->GetSubList()->NbcInsertObject(pClone
);
2547 if(aLinePolygonPart
)
2549 pGroup
->GetSubList()->NbcInsertObject(aLinePolygonPart
);
2552 if(aLineHairlinePart
)
2554 pGroup
->GetSubList()->NbcInsertObject(aLineHairlinePart
);
2559 // be more careful with the state describing bool
2564 if(aLinePolygonPart
)
2566 pRet
= aLinePolygonPart
;
2567 // be more careful with the state describing bool
2570 else if(aLineHairlinePart
)
2572 pRet
= aLineHairlinePart
;
2573 // be more careful with the state describing bool
2582 // due to current method usage, create and return a clone when nothing has changed
2583 SdrObject
* pClone
= pRet
->Clone();
2584 pClone
->SetModel(pRet
->GetModel());
2591 bool SdrObject::IsVirtualObj() const
2596 bool SdrObject::IsClosedObj() const
2601 bool SdrObject::IsEdgeObj() const
2606 bool SdrObject::Is3DObj() const
2611 bool SdrObject::IsUnoObj() const
2616 void SdrObject::SetMarkProtect(bool bProt
)
2621 bool SdrObject::IsMarkProtect() const
2626 bool SdrObject::IsInserted() const
2631 bool SdrObject::IsMoveProtect() const
2636 bool SdrObject::IsResizeProtect() const
2641 bool SdrObject::IsPrintable() const
2646 bool SdrObject::IsVisible() const
2651 void SdrObject::SetEmptyPresObj(bool bEpt
)
2653 bEmptyPresObj
= bEpt
;
2656 bool SdrObject::IsEmptyPresObj() const
2658 return bEmptyPresObj
;
2661 void SdrObject::SetNotVisibleAsMaster(bool bFlg
)
2663 bNotVisibleAsMaster
=bFlg
;
2666 bool SdrObject::IsNotVisibleAsMaster() const
2668 return bNotVisibleAsMaster
;
2671 bool SdrObject::LineIsOutsideGeometry() const
2673 return mbLineIsOutsideGeometry
;
2676 bool SdrObject::DoesSupportTextIndentingOnLineWidthChange() const
2678 return mbSupportTextIndentingOnLineWidthChange
;
2681 // convert this path object to contour object, even when it is a group
2682 SdrObject
* SdrObject::ConvertToContourObj(SdrObject
* pRet
, bool bForceLineDash
) const
2684 if(pRet
->ISA(SdrObjGroup
))
2686 SdrObjList
* pObjList2
= pRet
->GetSubList();
2687 SdrObject
* pGroup
= new SdrObjGroup
;
2688 pGroup
->SetModel(pRet
->GetModel());
2690 for(sal_uInt32 a
=0;a
<pObjList2
->GetObjCount();a
++)
2692 SdrObject
* pIterObj
= pObjList2
->GetObj(a
);
2693 pGroup
->GetSubList()->NbcInsertObject(ConvertToContourObj(pIterObj
, bForceLineDash
));
2700 if(pRet
&& pRet
->ISA(SdrPathObj
))
2702 SdrPathObj
* pPathObj
= (SdrPathObj
*)pRet
;
2704 // bezier geometry got created, even for straight edges since the given
2705 // object is a result of DoConvertToPolyObj. For conversion to contour
2706 // this is not really needed and can be reduced again AFAP
2707 pPathObj
->SetPathPoly(basegfx::tools::simplifyCurveSegments(pPathObj
->GetPathPoly()));
2710 pRet
= ImpConvertToContourObj(pRet
, bForceLineDash
);
2713 // #i73441# preserve LayerID
2714 if(pRet
&& pRet
->GetLayer() != GetLayer())
2716 pRet
->SetLayer(GetLayer());
2722 ////////////////////////////////////////////////////////////////////////////////////////////////////
2724 SdrObject
* SdrObject::ConvertToPolyObj(bool bBezier
, bool bLineToArea
) const
2726 SdrObject
* pRet
= DoConvertToPolyObj(bBezier
, true);
2728 if(pRet
&& bLineToArea
)
2730 SdrObject
* pNewRet
= ConvertToContourObj(pRet
);
2735 // #i73441# preserve LayerID
2736 if(pRet
&& pRet
->GetLayer() != GetLayer())
2738 pRet
->SetLayer(GetLayer());
2744 ////////////////////////////////////////////////////////////////////////////////////////////////////
2746 SdrObject
* SdrObject::DoConvertToPolyObj(sal_Bool
/*bBezier*/, bool /*bAddText*/) const
2751 ////////////////////////////////////////////////////////////////////////////////////////////////////
2753 void SdrObject::SetInserted(bool bIns
)
2755 if (bIns
!=IsInserted()) {
2757 Rectangle
aBoundRect0(GetLastBoundRect());
2758 if (bIns
) SendUserCall(SDRUSERCALL_INSERTED
,aBoundRect0
);
2759 else SendUserCall(SDRUSERCALL_REMOVED
,aBoundRect0
);
2761 if (pPlusData
!=NULL
&& pPlusData
->pBroadcast
!=NULL
) {
2762 SdrHint
aHint(*this);
2763 aHint
.SetKind(bIns
?HINT_OBJINSERTED
:HINT_OBJREMOVED
);
2764 pPlusData
->pBroadcast
->Broadcast(aHint
);
2769 void SdrObject::SetMoveProtect(bool bProt
)
2771 if(IsMoveProtect() != bProt
)
2773 // #i77187# secured and simplified
2776 BroadcastObjectChange();
2780 void SdrObject::SetResizeProtect(bool bProt
)
2782 if(IsResizeProtect() != bProt
)
2784 // #i77187# secured and simplified
2787 BroadcastObjectChange();
2791 void SdrObject::SetPrintable(bool bPrn
)
2793 if( bPrn
== bNoPrint
)
2797 if (IsInserted() && pModel
!=NULL
)
2799 SdrHint
aHint(*this);
2800 pModel
->Broadcast(aHint
);
2805 void SdrObject::SetVisible(bool bVisible
)
2807 if( bVisible
!= mbVisible
)
2809 mbVisible
= bVisible
;
2811 if (IsInserted() && pModel
!=NULL
)
2813 SdrHint
aHint(*this);
2814 pModel
->Broadcast(aHint
);
2819 ////////////////////////////////////////////////////////////////////////////////////////////////////
2821 sal_uInt16
SdrObject::GetUserDataCount() const
2823 if (pPlusData
==NULL
|| pPlusData
->pUserDataList
==NULL
) return 0;
2824 return pPlusData
->pUserDataList
->GetUserDataCount();
2827 SdrObjUserData
* SdrObject::GetUserData(sal_uInt16 nNum
) const
2829 if (pPlusData
==NULL
|| pPlusData
->pUserDataList
==NULL
) return NULL
;
2830 return pPlusData
->pUserDataList
->GetUserData(nNum
);
2833 void SdrObject::AppendUserData(SdrObjUserData
* pData
)
2837 OSL_FAIL("SdrObject::AppendUserData(): pData is NULL pointer.");
2842 if (!pPlusData
->pUserDataList
)
2843 pPlusData
->pUserDataList
= new SdrObjUserDataList
;
2845 pPlusData
->pUserDataList
->AppendUserData(pData
);
2848 void SdrObject::DeleteUserData(sal_uInt16 nNum
)
2850 sal_uInt16 nAnz
=GetUserDataCount();
2852 pPlusData
->pUserDataList
->DeleteUserData(nNum
);
2854 delete pPlusData
->pUserDataList
;
2855 pPlusData
->pUserDataList
=NULL
;
2858 OSL_FAIL("SdrObject::DeleteUserData(): Invalid Index.");
2862 void SdrObject::SetUserCall(SdrObjUserCall
* pUser
)
2867 SdrObjUserCall
* SdrObject::GetUserCall() const
2872 void SdrObject::SendUserCall(SdrUserCallType eUserCall
, const Rectangle
& rBoundRect
) const
2874 SdrObjGroup
* pGroup
= NULL
;
2876 if( pObjList
&& pObjList
->GetListKind() == SDROBJLIST_GROUPOBJ
)
2877 pGroup
= (SdrObjGroup
*) pObjList
->GetOwnerObj();
2881 pUserCall
->Changed( *this, eUserCall
, rBoundRect
);
2886 // broadcast to group
2887 if( pGroup
->GetUserCall() )
2889 SdrUserCallType eChildUserType
= SDRUSERCALL_CHILD_CHGATTR
;
2893 case SDRUSERCALL_MOVEONLY
:
2894 eChildUserType
= SDRUSERCALL_CHILD_MOVEONLY
;
2897 case SDRUSERCALL_RESIZE
:
2898 eChildUserType
= SDRUSERCALL_CHILD_RESIZE
;
2901 case SDRUSERCALL_CHGATTR
:
2902 eChildUserType
= SDRUSERCALL_CHILD_CHGATTR
;
2905 case SDRUSERCALL_DELETE
:
2906 eChildUserType
= SDRUSERCALL_CHILD_DELETE
;
2909 case SDRUSERCALL_COPY
:
2910 eChildUserType
= SDRUSERCALL_CHILD_COPY
;
2913 case SDRUSERCALL_INSERTED
:
2914 eChildUserType
= SDRUSERCALL_CHILD_INSERTED
;
2917 case SDRUSERCALL_REMOVED
:
2918 eChildUserType
= SDRUSERCALL_CHILD_REMOVED
;
2924 pGroup
->GetUserCall()->Changed( *this, eChildUserType
, rBoundRect
);
2927 if( pGroup
->GetObjList() &&
2928 pGroup
->GetObjList()->GetListKind() == SDROBJLIST_GROUPOBJ
&&
2929 pGroup
!= (SdrObjGroup
*) pObjList
->GetOwnerObj() )
2930 pGroup
= (SdrObjGroup
*) pObjList
->GetOwnerObj();
2935 // notify our UNO shape listeners
2936 switch ( eUserCall
)
2938 case SDRUSERCALL_RESIZE
:
2939 notifyShapePropertyChange( ::svx::eShapeSize
);
2940 // fall through - RESIZE might also imply a change of the position
2941 case SDRUSERCALL_MOVEONLY
:
2942 notifyShapePropertyChange( ::svx::eShapePosition
);
2945 // not interested in
2950 // change ItemPool for this object
2951 void SdrObject::MigrateItemPool(SfxItemPool
* pSrcPool
, SfxItemPool
* pDestPool
, SdrModel
* pNewModel
)
2953 if(pSrcPool
&& pDestPool
&& (pSrcPool
!= pDestPool
))
2955 GetProperties().MoveToItemPool(pSrcPool
, pDestPool
, pNewModel
);
2959 void SdrObject::impl_setUnoShape( const uno::Reference
< uno::XInterface
>& _rxUnoShape
)
2961 const uno::Reference
< uno::XInterface
>& xOldUnoShape( maWeakUnoShape
);
2962 // the UNO shape would be gutted by the following code; return early
2963 if ( _rxUnoShape
== xOldUnoShape
)
2965 if ( !xOldUnoShape
.is() )
2967 // make sure there is no stale impl. pointer if the UNO
2968 // shape was destroyed meanwhile (remember we only hold weak
2969 // reference to it!)
2975 bool bTransferOwnership( false );
2976 if ( xOldUnoShape
.is() )
2978 bTransferOwnership
= mpSvxShape
->HasSdrObjectOwnership();
2979 // Remove yourself from the current UNO shape. Its destructor
2980 // will reset our UNO shape otherwise.
2981 mpSvxShape
->InvalidateSdrObject();
2984 maWeakUnoShape
= _rxUnoShape
;
2985 mpSvxShape
= SvxShape::getImplementation( _rxUnoShape
);
2987 // I think this may never happen... But I am not sure enough .-)
2988 if ( bTransferOwnership
)
2990 if ( _rxUnoShape
.is() )
2991 mpSvxShape
->TakeSdrObjectOwnership();
2992 SAL_WARN( "svx.uno", "a UNO shape took over an SdrObject previously owned by another UNO shape!");
2996 /** only for internal use! */
2997 SvxShape
* SdrObject::getSvxShape()
2999 DBG_TESTSOLARMUTEX();
3000 // retrieving the impl pointer and subsequently using it is not thread-safe, of course, so it needs to be
3001 // guarded by the SolarMutex
3003 uno::Reference
< uno::XInterface
> xShape( maWeakUnoShape
);
3004 #if OSL_DEBUG_LEVEL > 0
3005 OSL_ENSURE( !( !xShape
.is() && mpSvxShape
),
3006 "SdrObject::getSvxShape: still having IMPL-Pointer to dead object!" );
3008 //#113608#, make sure mpSvxShape is always synchronized with maWeakUnoShape
3009 if ( mpSvxShape
&& !xShape
.is() )
3015 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
> SdrObject::getUnoShape()
3017 // try weak reference first
3018 uno::Reference
< uno::XInterface
> xShape( getWeakUnoShape() );
3021 OSL_ENSURE( mpSvxShape
== NULL
, "SdrObject::getUnoShape: XShape already dead, but still an IMPL pointer!" );
3024 uno::Reference
< uno::XInterface
> xPage( pPage
->getUnoPage() );
3027 SvxDrawPage
* pDrawPage
= SvxDrawPage::getImplementation(xPage
);
3031 xShape
= pDrawPage
->_CreateShape( this );
3032 impl_setUnoShape( xShape
);
3038 mpSvxShape
= SvxDrawPage::CreateShapeByTypeAndInventor( GetObjIdentifier(), GetObjInventor(), this, NULL
);
3039 maWeakUnoShape
= xShape
= static_cast< ::cppu::OWeakObject
* >( mpSvxShape
);
3046 void SdrObject::setUnoShape(const uno::Reference
<uno::XInterface
>& _rxUnoShape
)
3048 impl_setUnoShape( _rxUnoShape
);
3051 ::svx::PropertyChangeNotifier
& SdrObject::getShapePropertyChangeNotifier()
3053 DBG_TESTSOLARMUTEX();
3055 SvxShape
* pSvxShape
= getSvxShape();
3056 ENSURE_OR_THROW( pSvxShape
, "no SvxShape, yet!" );
3057 return pSvxShape
->getShapePropertyChangeNotifier();
3060 void SdrObject::notifyShapePropertyChange( const ::svx::ShapeProperty _eProperty
) const
3062 DBG_TESTSOLARMUTEX();
3064 SvxShape
* pSvxShape
= const_cast< SdrObject
* >( this )->getSvxShape();
3066 return pSvxShape
->getShapePropertyChangeNotifier().notifyPropertyChange( _eProperty
);
3069 ////////////////////////////////////////////////////////////////////////////////////////////////////
3071 // transformation interface for StarOfficeAPI. This implements support for
3072 // homogeneous 3x3 matrices containing the transformation of the SdrObject. At the
3073 // moment it contains a shearX, rotation and translation, but for setting all linear
3074 // transforms like Scale, ShearX, ShearY, Rotate and Translate are supported.
3076 ////////////////////////////////////////////////////////////////////////////////////////////////////
3077 // gets base transformation and rectangle of object. If it's an SdrPathObj it fills the PolyPolygon
3078 // with the base geometry and returns TRUE. Otherwise it returns FALSE.
3079 sal_Bool
SdrObject::TRGetBaseGeometry(basegfx::B2DHomMatrix
& rMatrix
, basegfx::B2DPolyPolygon
& /*rPolyPolygon*/) const
3081 // any kind of SdrObject, just use SnapRect
3082 Rectangle
aRectangle(GetSnapRect());
3084 // convert to transformation values
3085 basegfx::B2DTuple
aScale(aRectangle
.GetWidth(), aRectangle
.GetHeight());
3086 basegfx::B2DTuple
aTranslate(aRectangle
.Left(), aRectangle
.Top());
3088 // position maybe relative to anchorpos, convert
3089 if( pModel
&& pModel
->IsWriter() )
3091 if(GetAnchorPos().X() || GetAnchorPos().Y())
3093 aTranslate
-= basegfx::B2DTuple(GetAnchorPos().X(), GetAnchorPos().Y());
3097 // force MapUnit to 100th mm
3098 const SfxMapUnit
eMapUnit(GetObjectMapUnit());
3099 if(eMapUnit
!= SFX_MAPUNIT_100TH_MM
)
3103 case SFX_MAPUNIT_TWIP
:
3106 aTranslate
.setX(ImplTwipsToMM(aTranslate
.getX()));
3107 aTranslate
.setY(ImplTwipsToMM(aTranslate
.getY()));
3110 aScale
.setX(ImplTwipsToMM(aScale
.getX()));
3111 aScale
.setY(ImplTwipsToMM(aScale
.getY()));
3117 OSL_FAIL("TRGetBaseGeometry: Missing unit translation to 100th mm!");
3123 rMatrix
= basegfx::tools::createScaleTranslateB2DHomMatrix(aScale
, aTranslate
);
3128 // sets the base geometry of the object using infos contained in the homogeneous 3x3 matrix.
3129 // If it's an SdrPathObj it will use the provided geometry information. The Polygon has
3130 // to use (0,0) as upper left and will be scaled to the given size in the matrix.
3131 void SdrObject::TRSetBaseGeometry(const basegfx::B2DHomMatrix
& rMatrix
, const basegfx::B2DPolyPolygon
& /*rPolyPolygon*/)
3134 basegfx::B2DTuple aScale
;
3135 basegfx::B2DTuple aTranslate
;
3136 double fRotate
, fShearX
;
3137 rMatrix
.decompose(aScale
, aTranslate
, fRotate
, fShearX
);
3139 // #i75086# Old DrawingLayer (GeoStat and geometry) does not support holding negative scalings
3140 // in X and Y which equal a 180 degree rotation. Recognize it and react accordingly
3141 if(basegfx::fTools::less(aScale
.getX(), 0.0) && basegfx::fTools::less(aScale
.getY(), 0.0))
3143 aScale
.setX(fabs(aScale
.getX()));
3144 aScale
.setY(fabs(aScale
.getY()));
3145 fRotate
= fmod(fRotate
+ F_PI
, F_2PI
);
3148 // force metric to pool metric
3149 const SfxMapUnit
eMapUnit(GetObjectMapUnit());
3150 if(eMapUnit
!= SFX_MAPUNIT_100TH_MM
)
3154 case SFX_MAPUNIT_TWIP
:
3157 aTranslate
.setX(ImplMMToTwips(aTranslate
.getX()));
3158 aTranslate
.setY(ImplMMToTwips(aTranslate
.getY()));
3161 aScale
.setX(ImplMMToTwips(aScale
.getX()));
3162 aScale
.setY(ImplMMToTwips(aScale
.getY()));
3168 OSL_FAIL("TRSetBaseGeometry: Missing unit translation to PoolMetric!");
3173 // if anchor is used, make position relative to it
3174 if( pModel
&& pModel
->IsWriter() )
3176 if(GetAnchorPos().X() || GetAnchorPos().Y())
3178 aTranslate
+= basegfx::B2DTuple(GetAnchorPos().X(), GetAnchorPos().Y());
3183 Point
aPoint(FRound(aTranslate
.getX()), FRound(aTranslate
.getY()));
3184 Rectangle
aBaseRect(aPoint
, Size(FRound(aScale
.getX()), FRound(aScale
.getY())));
3187 SetSnapRect(aBaseRect
);
3190 // Give info if object is in destruction
3191 bool SdrObject::IsInDestruction() const
3194 return pModel
->IsInDestruction();
3198 // return if fill is != XFILL_NONE
3199 bool SdrObject::HasFillStyle() const
3201 return (((const XFillStyleItem
&)GetObjectItem(XATTR_FILLSTYLE
)).GetValue() != XFILL_NONE
);
3204 bool SdrObject::HasLineStyle() const
3206 return (((const XLineStyleItem
&)GetObjectItem(XATTR_LINESTYLE
)).GetValue() != XLINE_NONE
);
3211 // on import of OLE object from MS documents the BLIP size might be retrieved,
3212 // the following four methods are used to control it;
3213 // usually this data makes no sence after the import is finished, since the object
3216 Rectangle
SdrObject::GetBLIPSizeRectangle() const
3218 return maBLIPSizeRectangle
;
3221 void SdrObject::SetBLIPSizeRectangle( const Rectangle
& aRect
)
3223 maBLIPSizeRectangle
= aRect
;
3226 void SdrObject::SetContextWritingMode( const sal_Int16
/*_nContextWritingMode*/ )
3228 // this base class does not support different writing modes, so ignore the call
3231 void SdrObject::SetDoNotInsertIntoPageAutomatically(const bool bSet
)
3233 mbDoNotInsertIntoPageAutomatically
= bSet
;
3236 bool SdrObject::IsDoNotInsertIntoPageAutomatically() const
3238 return mbDoNotInsertIntoPageAutomatically
;
3242 SdrObjFactory::SdrObjFactory(sal_uInt32 nInvent
, sal_uInt16 nIdent
, SdrPage
* pNewPage
, SdrModel
* pNewModel
)
3253 SdrObject
* SdrObjFactory::MakeNewObject(sal_uInt32 nInvent
, sal_uInt16 nIdent
, SdrPage
* pPage
, SdrModel
* pModel
)
3255 if(pModel
== NULL
&& pPage
!= NULL
)
3256 pModel
= pPage
->GetModel();
3257 SdrObject
* pObj
= NULL
;
3259 if(nInvent
== SdrInventor
)
3263 case sal_uInt16(OBJ_NONE
): pObj
=new SdrObject
; break;
3264 case sal_uInt16(OBJ_GRUP
): pObj
=new SdrObjGroup
; break;
3265 case sal_uInt16(OBJ_LINE
): pObj
=new SdrPathObj(OBJ_LINE
); break;
3266 case sal_uInt16(OBJ_POLY
): pObj
=new SdrPathObj(OBJ_POLY
); break;
3267 case sal_uInt16(OBJ_PLIN
): pObj
=new SdrPathObj(OBJ_PLIN
); break;
3268 case sal_uInt16(OBJ_PATHLINE
): pObj
=new SdrPathObj(OBJ_PATHLINE
); break;
3269 case sal_uInt16(OBJ_PATHFILL
): pObj
=new SdrPathObj(OBJ_PATHFILL
); break;
3270 case sal_uInt16(OBJ_FREELINE
): pObj
=new SdrPathObj(OBJ_FREELINE
); break;
3271 case sal_uInt16(OBJ_FREEFILL
): pObj
=new SdrPathObj(OBJ_FREEFILL
); break;
3272 case sal_uInt16(OBJ_PATHPOLY
): pObj
=new SdrPathObj(OBJ_POLY
); break;
3273 case sal_uInt16(OBJ_PATHPLIN
): pObj
=new SdrPathObj(OBJ_PLIN
); break;
3274 case sal_uInt16(OBJ_EDGE
): pObj
=new SdrEdgeObj
; break;
3275 case sal_uInt16(OBJ_RECT
): pObj
=new SdrRectObj
; break;
3276 case sal_uInt16(OBJ_CIRC
): pObj
=new SdrCircObj(OBJ_CIRC
); break;
3277 case sal_uInt16(OBJ_SECT
): pObj
=new SdrCircObj(OBJ_SECT
); break;
3278 case sal_uInt16(OBJ_CARC
): pObj
=new SdrCircObj(OBJ_CARC
); break;
3279 case sal_uInt16(OBJ_CCUT
): pObj
=new SdrCircObj(OBJ_CCUT
); break;
3280 case sal_uInt16(OBJ_TEXT
): pObj
=new SdrRectObj(OBJ_TEXT
); break;
3281 case sal_uInt16(OBJ_TEXTEXT
): pObj
=new SdrRectObj(OBJ_TEXTEXT
); break;
3282 case sal_uInt16(OBJ_TITLETEXT
): pObj
=new SdrRectObj(OBJ_TITLETEXT
); break;
3283 case sal_uInt16(OBJ_OUTLINETEXT
): pObj
=new SdrRectObj(OBJ_OUTLINETEXT
); break;
3284 case sal_uInt16(OBJ_MEASURE
): pObj
=new SdrMeasureObj
; break;
3285 case sal_uInt16(OBJ_GRAF
): pObj
=new SdrGrafObj
; break;
3286 case sal_uInt16(OBJ_OLE2
): pObj
=new SdrOle2Obj
; break;
3287 case sal_uInt16(OBJ_FRAME
): pObj
=new SdrOle2Obj(true); break;
3288 case sal_uInt16(OBJ_CAPTION
): pObj
=new SdrCaptionObj
; break;
3289 case sal_uInt16(OBJ_PAGE
): pObj
=new SdrPageObj
; break;
3290 case sal_uInt16(OBJ_UNO
): pObj
=new SdrUnoObj(String()); break;
3291 case sal_uInt16(OBJ_CUSTOMSHAPE
): pObj
=new SdrObjCustomShape(); break;
3292 case sal_uInt16(OBJ_MEDIA
): pObj
=new SdrMediaObj(); break;
3293 case sal_uInt16(OBJ_TABLE
): pObj
=new ::sdr::table::SdrTableObj(pModel
); break;
3299 SdrObjFactory
* pFact
=new SdrObjFactory(nInvent
,nIdent
,pPage
,pModel
);
3300 SdrLinkList
& rLL
=ImpGetUserMakeObjHdl();
3301 unsigned nAnz
=rLL
.GetLinkCount();
3303 while (i
<nAnz
&& pObj
==NULL
) {
3304 rLL
.GetLink(i
).Call((void*)pFact
);
3305 pObj
=pFact
->pNewObj
;
3313 // Well, if no one wants it...
3319 pObj
->SetPage(pPage
);
3320 else if(pModel
!= NULL
)
3321 pObj
->SetModel(pModel
);
3327 void SdrObjFactory::InsertMakeObjectHdl(const Link
& rLink
)
3329 SdrLinkList
& rLL
=ImpGetUserMakeObjHdl();
3330 rLL
.InsertLink(rLink
);
3333 void SdrObjFactory::RemoveMakeObjectHdl(const Link
& rLink
)
3335 SdrLinkList
& rLL
=ImpGetUserMakeObjHdl();
3336 rLL
.RemoveLink(rLink
);
3339 void SdrObjFactory::InsertMakeUserDataHdl(const Link
& rLink
)
3341 SdrLinkList
& rLL
=ImpGetUserMakeObjUserDataHdl();
3342 rLL
.InsertLink(rLink
);
3345 void SdrObjFactory::RemoveMakeUserDataHdl(const Link
& rLink
)
3347 SdrLinkList
& rLL
=ImpGetUserMakeObjUserDataHdl();
3348 rLL
.RemoveLink(rLink
);
3353 ISdrObjectFilter::~ISdrObjectFilter()
3358 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */