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: viewcontactofsdrobj.cxx,v $
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 <svx/sdr/contact/viewcontactofsdrobj.hxx>
34 #include <svx/sdr/contact/viewobjectcontactofsdrobj.hxx>
35 #include <svx/sdr/contact/viewobjectcontact.hxx>
36 #include <svx/svdobj.hxx>
37 #include <svx/sdr/contact/displayinfo.hxx>
38 #include <vcl/outdev.hxx>
39 #include <svx/svdoole2.hxx>
40 #include <svx/svdpage.hxx>
41 #include <svx/sdr/contact/objectcontact.hxx>
42 #include <basegfx/color/bcolor.hxx>
43 #include <drawinglayer/primitive2d/markerarrayprimitive2d.hxx>
44 #include <svx/sdr/contact/objectcontactofpageview.hxx>
45 #include <svx/sdrpagewindow.hxx>
46 #include <sdrpaintwindow.hxx>
47 #include <svx/sdr/primitive2d/sdrprimitivetools.hxx>
49 //////////////////////////////////////////////////////////////////////////////
55 // Create a Object-Specific ViewObjectContact, set ViewContact and
56 // ObjectContact. Always needs to return something.
57 ViewObjectContact
& ViewContactOfSdrObj::CreateObjectSpecificViewObjectContact(ObjectContact
& rObjectContact
)
59 ViewObjectContact
* pRetval
= new ViewObjectContactOfSdrObj(rObjectContact
, *this);
60 DBG_ASSERT(pRetval
, "ViewContactOfSdrObj::CreateObjectSpecificViewObjectContact() failed (!)");
65 ViewContactOfSdrObj::ViewContactOfSdrObj(SdrObject
& rObj
)
68 meRememberedAnimationKind(SDRTEXTANI_NONE
)
71 if(GetSdrObject().ISA(SdrTextObj
))
73 SdrTextObj
& rTextObj
= (SdrTextObj
&)GetSdrObject();
74 meRememberedAnimationKind
= rTextObj
.GetTextAniKind();
78 ViewContactOfSdrObj::~ViewContactOfSdrObj()
82 // Access to possible sub-hierarchy
83 sal_uInt32
ViewContactOfSdrObj::GetObjectCount() const
85 if(GetSdrObject().GetSubList())
87 return GetSdrObject().GetSubList()->GetObjCount();
93 ViewContact
& ViewContactOfSdrObj::GetViewContact(sal_uInt32 nIndex
) const
95 DBG_ASSERT(GetSdrObject().GetSubList(),
96 "ViewContactOfSdrObj::GetViewContact: Access to non-existent Sub-List (!)");
97 SdrObject
* pObj
= GetSdrObject().GetSubList()->GetObj(nIndex
);
98 DBG_ASSERT(pObj
, "ViewContactOfSdrObj::GetViewContact: Corrupt SdrObjList (!)");
99 return pObj
->GetViewContact();
102 ViewContact
* ViewContactOfSdrObj::GetParentContact() const
104 ViewContact
* pRetval
= 0L;
105 SdrObjList
* pObjList
= GetSdrObject().GetObjList();
109 if(pObjList
->ISA(SdrPage
))
112 pRetval
= &(((SdrPage
*)pObjList
)->GetViewContact());
117 if(pObjList
->GetOwnerObj())
119 pRetval
= &(pObjList
->GetOwnerObj()->GetViewContact());
127 // React on changes of the object of this ViewContact
128 void ViewContactOfSdrObj::ActionChanged()
130 // look for own changes
131 if(GetSdrObject().ISA(SdrTextObj
))
133 SdrTextObj
& rTextObj
= (SdrTextObj
&)GetSdrObject();
135 if(rTextObj
.GetTextAniKind() != meRememberedAnimationKind
)
137 // #i38135# now remember new type
138 meRememberedAnimationKind
= rTextObj
.GetTextAniKind();
143 ViewContact::ActionChanged();
146 // overload for acessing the SdrObject
147 SdrObject
* ViewContactOfSdrObj::TryToGetSdrObject() const
149 return &GetSdrObject();
152 //////////////////////////////////////////////////////////////////////////////
155 // add Gluepoints (if available)
156 drawinglayer::primitive2d::Primitive2DSequence
ViewContactOfSdrObj::createGluePointPrimitive2DSequence() const
158 drawinglayer::primitive2d::Primitive2DSequence xRetval
;
159 const SdrGluePointList
* pGluePointList
= GetSdrObject().GetGluePointList();
163 const sal_uInt32
nCount(pGluePointList
->GetCount());
167 // prepare point vector
168 std::vector
< basegfx::B2DPoint
> aGluepointVector
;
170 // create GluePoint primitives. ATM these are relative to the SnapRect
171 for(sal_uInt32
a(0L); a
< nCount
; a
++)
173 const SdrGluePoint
& rCandidate
= (*pGluePointList
)[(sal_uInt16
)a
];
174 const Point
aPosition(rCandidate
.GetAbsolutePos(GetSdrObject()));
176 aGluepointVector
.push_back(basegfx::B2DPoint(aPosition
.X(), aPosition
.Y()));
179 if(aGluepointVector
.size())
181 const basegfx::BColor
aBackPen(1.0, 1.0, 1.0);
182 const basegfx::BColor
aRGBFrontColor(0.0, 0.0, 1.0); // COL_LIGHTBLUE
183 const drawinglayer::primitive2d::Primitive2DReference
xReference(new drawinglayer::primitive2d::MarkerArrayPrimitive2D(
185 drawinglayer::primitive2d::createDefaultGluepoint_7x7(aBackPen
, aRGBFrontColor
)));
186 xRetval
= drawinglayer::primitive2d::Primitive2DSequence(&xReference
, 1);
193 } // end of namespace contact
194 } // end of namespace sdr
196 //////////////////////////////////////////////////////////////////////////////