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 <svx/sdr/contact/viewcontactofsdrobj.hxx>
21 #include <svx/sdr/contact/viewobjectcontactofsdrobj.hxx>
22 #include <svx/sdr/contact/viewobjectcontact.hxx>
23 #include <svx/svdobj.hxx>
24 #include <svx/sdr/contact/displayinfo.hxx>
25 #include <vcl/outdev.hxx>
26 #include <svx/svdoole2.hxx>
27 #include <svx/svdpage.hxx>
28 #include <svx/sdr/contact/objectcontact.hxx>
29 #include <basegfx/color/bcolor.hxx>
30 #include <drawinglayer/primitive2d/markerarrayprimitive2d.hxx>
31 #include <drawinglayer/primitive2d/objectinfoprimitive2d.hxx>
32 #include <svx/sdr/contact/objectcontactofpageview.hxx>
33 #include <svx/sdrpagewindow.hxx>
34 #include <svx/sdrpaintwindow.hxx>
35 #include <svx/svdhdl.hxx>
37 //////////////////////////////////////////////////////////////////////////////
43 // Create a Object-Specific ViewObjectContact, set ViewContact and
44 // ObjectContact. Always needs to return something.
45 ViewObjectContact
& ViewContactOfSdrObj::CreateObjectSpecificViewObjectContact(ObjectContact
& rObjectContact
)
47 ViewObjectContact
* pRetval
= new ViewObjectContactOfSdrObj(rObjectContact
, *this);
48 DBG_ASSERT(pRetval
, "ViewContactOfSdrObj::CreateObjectSpecificViewObjectContact() failed (!)");
53 ViewContactOfSdrObj::ViewContactOfSdrObj(SdrObject
& rObj
)
56 meRememberedAnimationKind(SDRTEXTANI_NONE
)
59 if(GetSdrObject().ISA(SdrTextObj
))
61 SdrTextObj
& rTextObj
= (SdrTextObj
&)GetSdrObject();
62 meRememberedAnimationKind
= rTextObj
.GetTextAniKind();
66 ViewContactOfSdrObj::~ViewContactOfSdrObj()
70 // Access to possible sub-hierarchy
71 sal_uInt32
ViewContactOfSdrObj::GetObjectCount() const
73 if(GetSdrObject().GetSubList())
75 return GetSdrObject().GetSubList()->GetObjCount();
81 ViewContact
& ViewContactOfSdrObj::GetViewContact(sal_uInt32 nIndex
) const
83 DBG_ASSERT(GetSdrObject().GetSubList(),
84 "ViewContactOfSdrObj::GetViewContact: Access to non-existent Sub-List (!)");
85 SdrObject
* pObj
= GetSdrObject().GetSubList()->GetObj(nIndex
);
86 DBG_ASSERT(pObj
, "ViewContactOfSdrObj::GetViewContact: Corrupt SdrObjList (!)");
87 return pObj
->GetViewContact();
90 ViewContact
* ViewContactOfSdrObj::GetParentContact() const
92 ViewContact
* pRetval
= 0L;
93 SdrObjList
* pObjList
= GetSdrObject().GetObjList();
97 if(pObjList
->ISA(SdrPage
))
100 pRetval
= &(((SdrPage
*)pObjList
)->GetViewContact());
105 if(pObjList
->GetOwnerObj())
107 pRetval
= &(pObjList
->GetOwnerObj()->GetViewContact());
115 // React on changes of the object of this ViewContact
116 void ViewContactOfSdrObj::ActionChanged()
118 // look for own changes
119 if(GetSdrObject().ISA(SdrTextObj
))
121 SdrTextObj
& rTextObj
= (SdrTextObj
&)GetSdrObject();
123 if(rTextObj
.GetTextAniKind() != meRememberedAnimationKind
)
125 // #i38135# now remember new type
126 meRememberedAnimationKind
= rTextObj
.GetTextAniKind();
131 ViewContact::ActionChanged();
134 // overload for acessing the SdrObject
135 SdrObject
* ViewContactOfSdrObj::TryToGetSdrObject() const
137 return &GetSdrObject();
140 //////////////////////////////////////////////////////////////////////////////
143 // add Gluepoints (if available)
144 drawinglayer::primitive2d::Primitive2DSequence
ViewContactOfSdrObj::createGluePointPrimitive2DSequence() const
146 drawinglayer::primitive2d::Primitive2DSequence xRetval
;
147 const SdrGluePointList
* pGluePointList
= GetSdrObject().GetGluePointList();
151 const sal_uInt32
nCount(pGluePointList
->GetCount());
155 // prepare point vector
156 std::vector
< basegfx::B2DPoint
> aGluepointVector
;
158 // create GluePoint primitives. ATM these are relative to the SnapRect
159 for(sal_uInt32
a(0L); a
< nCount
; a
++)
161 const SdrGluePoint
& rCandidate
= (*pGluePointList
)[(sal_uInt16
)a
];
162 const Point
aPosition(rCandidate
.GetAbsolutePos(GetSdrObject()));
164 aGluepointVector
.push_back(basegfx::B2DPoint(aPosition
.X(), aPosition
.Y()));
167 if(!aGluepointVector
.empty())
169 const drawinglayer::primitive2d::Primitive2DReference
xReference(
170 new drawinglayer::primitive2d::MarkerArrayPrimitive2D(
171 aGluepointVector
, SdrHdl::createGluePointBitmap()));
172 xRetval
= drawinglayer::primitive2d::Primitive2DSequence(&xReference
, 1);
180 drawinglayer::primitive2d::Primitive2DSequence
ViewContactOfSdrObj::embedToObjectSpecificInformation(const drawinglayer::primitive2d::Primitive2DSequence
& rSource
) const
182 if(rSource
.hasElements() &&
183 (!GetSdrObject().GetName().isEmpty() ||
184 !GetSdrObject().GetTitle().isEmpty() ||
185 !GetSdrObject().GetDescription().isEmpty()))
187 const drawinglayer::primitive2d::Primitive2DReference
xRef(
188 new drawinglayer::primitive2d::ObjectInfoPrimitive2D(
190 GetSdrObject().GetName(),
191 GetSdrObject().GetTitle(),
192 GetSdrObject().GetDescription()));
194 return drawinglayer::primitive2d::Primitive2DSequence(&xRef
, 1);
200 } // end of namespace contact
201 } // end of namespace sdr
203 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */