Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
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>
36 :
37 :
38 :
39 : namespace sdr
40 : {
41 : namespace contact
42 : {
43 : // Create a Object-Specific ViewObjectContact, set ViewContact and
44 : // ObjectContact. Always needs to return something.
45 0 : ViewObjectContact& ViewContactOfSdrObj::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact)
46 : {
47 0 : ViewObjectContact* pRetval = new ViewObjectContactOfSdrObj(rObjectContact, *this);
48 : DBG_ASSERT(pRetval, "ViewContactOfSdrObj::CreateObjectSpecificViewObjectContact() failed (!)");
49 :
50 0 : return *pRetval;
51 : }
52 :
53 0 : ViewContactOfSdrObj::ViewContactOfSdrObj(SdrObject& rObj)
54 : : ViewContact(),
55 : mrObject(rObj),
56 0 : meRememberedAnimationKind(SDRTEXTANI_NONE)
57 : {
58 : // init AnimationKind
59 0 : if(GetSdrObject().ISA(SdrTextObj))
60 : {
61 0 : SdrTextObj& rTextObj = (SdrTextObj&)GetSdrObject();
62 0 : meRememberedAnimationKind = rTextObj.GetTextAniKind();
63 : }
64 0 : }
65 :
66 0 : ViewContactOfSdrObj::~ViewContactOfSdrObj()
67 : {
68 0 : }
69 :
70 : // Access to possible sub-hierarchy
71 0 : sal_uInt32 ViewContactOfSdrObj::GetObjectCount() const
72 : {
73 0 : if(GetSdrObject().GetSubList())
74 : {
75 0 : return GetSdrObject().GetSubList()->GetObjCount();
76 : }
77 :
78 0 : return 0L;
79 : }
80 :
81 0 : ViewContact& ViewContactOfSdrObj::GetViewContact(sal_uInt32 nIndex) const
82 : {
83 : DBG_ASSERT(GetSdrObject().GetSubList(),
84 : "ViewContactOfSdrObj::GetViewContact: Access to non-existent Sub-List (!)");
85 0 : SdrObject* pObj = GetSdrObject().GetSubList()->GetObj(nIndex);
86 : DBG_ASSERT(pObj, "ViewContactOfSdrObj::GetViewContact: Corrupt SdrObjList (!)");
87 0 : return pObj->GetViewContact();
88 : }
89 :
90 0 : ViewContact* ViewContactOfSdrObj::GetParentContact() const
91 : {
92 0 : ViewContact* pRetval = 0L;
93 0 : SdrObjList* pObjList = GetSdrObject().GetObjList();
94 :
95 0 : if(pObjList)
96 : {
97 0 : if(pObjList->ISA(SdrPage))
98 : {
99 : // Is a page
100 0 : pRetval = &(((SdrPage*)pObjList)->GetViewContact());
101 : }
102 : else
103 : {
104 : // Is a group?
105 0 : if(pObjList->GetOwnerObj())
106 : {
107 0 : pRetval = &(pObjList->GetOwnerObj()->GetViewContact());
108 : }
109 : }
110 : }
111 :
112 0 : return pRetval;
113 : }
114 :
115 : // React on changes of the object of this ViewContact
116 0 : void ViewContactOfSdrObj::ActionChanged()
117 : {
118 : // look for own changes
119 0 : if(GetSdrObject().ISA(SdrTextObj))
120 : {
121 0 : SdrTextObj& rTextObj = (SdrTextObj&)GetSdrObject();
122 :
123 0 : if(rTextObj.GetTextAniKind() != meRememberedAnimationKind)
124 : {
125 : // #i38135# now remember new type
126 0 : meRememberedAnimationKind = rTextObj.GetTextAniKind();
127 : }
128 : }
129 :
130 : // call parent
131 0 : ViewContact::ActionChanged();
132 0 : }
133 :
134 : // overload for acessing the SdrObject
135 0 : SdrObject* ViewContactOfSdrObj::TryToGetSdrObject() const
136 : {
137 0 : return &GetSdrObject();
138 : }
139 :
140 :
141 : // primitive stuff
142 :
143 : // add Gluepoints (if available)
144 0 : drawinglayer::primitive2d::Primitive2DSequence ViewContactOfSdrObj::createGluePointPrimitive2DSequence() const
145 : {
146 0 : drawinglayer::primitive2d::Primitive2DSequence xRetval;
147 0 : const SdrGluePointList* pGluePointList = GetSdrObject().GetGluePointList();
148 :
149 0 : if(pGluePointList)
150 : {
151 0 : const sal_uInt32 nCount(pGluePointList->GetCount());
152 :
153 0 : if(nCount)
154 : {
155 : // prepare point vector
156 0 : std::vector< basegfx::B2DPoint > aGluepointVector;
157 :
158 : // create GluePoint primitives. ATM these are relative to the SnapRect
159 0 : for(sal_uInt32 a(0L); a < nCount; a++)
160 : {
161 0 : const SdrGluePoint& rCandidate = (*pGluePointList)[(sal_uInt16)a];
162 0 : const Point aPosition(rCandidate.GetAbsolutePos(GetSdrObject()));
163 :
164 0 : aGluepointVector.push_back(basegfx::B2DPoint(aPosition.X(), aPosition.Y()));
165 : }
166 :
167 0 : if(!aGluepointVector.empty())
168 : {
169 : const drawinglayer::primitive2d::Primitive2DReference xReference(
170 : new drawinglayer::primitive2d::MarkerArrayPrimitive2D(
171 0 : aGluepointVector, SdrHdl::createGluePointBitmap()));
172 0 : xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
173 0 : }
174 : }
175 : }
176 :
177 0 : return xRetval;
178 : }
179 :
180 0 : drawinglayer::primitive2d::Primitive2DSequence ViewContactOfSdrObj::embedToObjectSpecificInformation(const drawinglayer::primitive2d::Primitive2DSequence& rSource) const
181 : {
182 0 : if(rSource.hasElements() &&
183 0 : (!GetSdrObject().GetName().isEmpty() ||
184 0 : !GetSdrObject().GetTitle().isEmpty() ||
185 0 : !GetSdrObject().GetDescription().isEmpty()))
186 : {
187 : const drawinglayer::primitive2d::Primitive2DReference xRef(
188 : new drawinglayer::primitive2d::ObjectInfoPrimitive2D(
189 : rSource,
190 0 : GetSdrObject().GetName(),
191 0 : GetSdrObject().GetTitle(),
192 0 : GetSdrObject().GetDescription()));
193 :
194 0 : return drawinglayer::primitive2d::Primitive2DSequence(&xRef, 1);
195 : }
196 :
197 0 : return rSource;
198 : }
199 :
200 : } // end of namespace contact
201 : } // end of namespace sdr
202 :
203 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|