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/objectcontact.hxx>
21 : #include <tools/debug.hxx>
22 : #include <svx/sdr/contact/viewobjectcontact.hxx>
23 : #include <svx/svdpage.hxx>
24 : #include <svx/sdr/contact/viewcontact.hxx>
25 : #include <svx/sdr/event/eventhandler.hxx>
26 : #include <basegfx/matrix/b2dhommatrix.hxx>
27 : #include <svx/sdr/animation/objectanimator.hxx>
28 :
29 : //////////////////////////////////////////////////////////////////////////////
30 :
31 : using namespace com::sun::star;
32 :
33 : //////////////////////////////////////////////////////////////////////////////
34 :
35 : namespace sdr
36 : {
37 : namespace contact
38 : {
39 147 : ObjectContact::ObjectContact()
40 : : maViewObjectContactVector(),
41 : maPrimitiveAnimator(),
42 : mpEventHandler(0),
43 : mpViewObjectContactRedirector(0),
44 : maViewInformation2D(uno::Sequence< beans::PropertyValue >()),
45 147 : mbIsPreviewRenderer(false)
46 : {
47 147 : }
48 :
49 44 : ObjectContact::~ObjectContact()
50 : {
51 : // get rid of all registered contacts
52 : // #i84257# To avoid that each 'delete pCandidate' again uses
53 : // the local RemoveViewObjectContact with a search and removal in the
54 : // vector, simply copy and clear local vector.
55 22 : std::vector< ViewObjectContact* > aLocalVOCList(maViewObjectContactVector);
56 22 : maViewObjectContactVector.clear();
57 :
58 162 : while(!aLocalVOCList.empty())
59 : {
60 118 : ViewObjectContact* pCandidate = aLocalVOCList.back();
61 118 : aLocalVOCList.pop_back();
62 : DBG_ASSERT(pCandidate, "Corrupted ViewObjectContactList (!)");
63 :
64 : // ViewObjectContacts only make sense with View and Object contacts.
65 : // When the contact to the SdrObject is deleted like in this case,
66 : // all ViewObjectContacts can be deleted, too.
67 118 : delete pCandidate;
68 : }
69 :
70 : // assert when there were new entries added during deletion
71 : DBG_ASSERT(maViewObjectContactVector.empty(), "Corrupted ViewObjectContactList (!)");
72 :
73 : // delete the EventHandler. This will destroy all still contained events.
74 22 : DeleteEventHandler();
75 22 : }
76 :
77 : // LazyInvalidate request. Default implementation directly handles
78 : // this by calling back triggerLazyInvalidate() at the VOC
79 0 : void ObjectContact::setLazyInvalidate(ViewObjectContact& rVOC)
80 : {
81 0 : rVOC.triggerLazyInvalidate();
82 0 : }
83 :
84 : // call this to support evtl. preparations for repaint. Default does nothing
85 0 : void ObjectContact::PrepareProcessDisplay()
86 : {
87 0 : }
88 :
89 : // A new ViewObjectContact was created and shall be remembered.
90 1740 : void ObjectContact::AddViewObjectContact(ViewObjectContact& rVOContact)
91 : {
92 1740 : maViewObjectContactVector.push_back(&rVOContact);
93 1740 : }
94 :
95 : // A ViewObjectContact was deleted and shall be forgotten.
96 118 : void ObjectContact::RemoveViewObjectContact(ViewObjectContact& rVOContact)
97 : {
98 118 : std::vector< ViewObjectContact* >::iterator aFindResult = std::find(maViewObjectContactVector.begin(), maViewObjectContactVector.end(), &rVOContact);
99 :
100 118 : if(aFindResult != maViewObjectContactVector.end())
101 : {
102 0 : maViewObjectContactVector.erase(aFindResult);
103 : }
104 118 : }
105 :
106 : // Process the whole displaying
107 0 : void ObjectContact::ProcessDisplay(DisplayInfo& /*rDisplayInfo*/)
108 : {
109 : // default does nothing
110 0 : }
111 :
112 : // test if visualizing of entered groups is switched on at all
113 20 : bool ObjectContact::DoVisualizeEnteredGroup() const
114 : {
115 : // Don not do that as default
116 20 : return false;
117 : }
118 :
119 : // get active group's (the entered group) ViewContact
120 0 : const ViewContact* ObjectContact::getActiveViewContact() const
121 : {
122 : // default has no active VC
123 0 : return 0;
124 : }
125 :
126 : // Invalidate given rectangle at the window/output which is represented by
127 : // this ObjectContact.
128 15 : void ObjectContact::InvalidatePartOfView(const basegfx::B2DRange& /*rRange*/) const
129 : {
130 : // nothing to do here in the default version
131 15 : }
132 :
133 : // Get info if given Rectangle is visible in this view
134 0 : bool ObjectContact::IsAreaVisible(const basegfx::B2DRange& /*rRange*/) const
135 : {
136 : // always visible in default version
137 0 : return true;
138 : }
139 :
140 : // Get info about the need to visualize GluePoints
141 15 : bool ObjectContact::AreGluePointsVisible() const
142 : {
143 15 : return false;
144 : }
145 :
146 : // method to create a EventHandler. Needs to give a result.
147 0 : sdr::event::TimerEventHandler* ObjectContact::CreateEventHandler()
148 : {
149 : // Create and return a new EventHandler
150 0 : return new sdr::event::TimerEventHandler();
151 : }
152 :
153 : // method to get the primitiveAnimator
154 816 : sdr::animation::primitiveAnimator& ObjectContact::getPrimitiveAnimator()
155 : {
156 816 : return maPrimitiveAnimator;
157 : }
158 :
159 : // method to get the EventHandler. It will
160 : // return a existing one or create a new one using CreateEventHandler().
161 0 : sdr::event::TimerEventHandler& ObjectContact::GetEventHandler() const
162 : {
163 0 : if(!HasEventHandler())
164 : {
165 0 : const_cast< ObjectContact* >(this)->mpEventHandler = const_cast< ObjectContact* >(this)->CreateEventHandler();
166 : DBG_ASSERT(mpEventHandler, "ObjectContact::GetEventHandler(): Got no EventHandler (!)");
167 : }
168 :
169 0 : return *mpEventHandler;
170 : }
171 :
172 : // delete the EventHandler
173 22 : void ObjectContact::DeleteEventHandler()
174 : {
175 22 : if(mpEventHandler)
176 : {
177 : // If there are still Events registered, something has went wrong
178 0 : delete mpEventHandler;
179 0 : mpEventHandler = 0L;
180 : }
181 22 : }
182 :
183 : // test if there is an EventHandler without creating one on demand
184 816 : bool ObjectContact::HasEventHandler() const
185 : {
186 816 : return (0L != mpEventHandler);
187 : }
188 :
189 : // check if text animation is allowed. Default is sal_true.
190 15 : bool ObjectContact::IsTextAnimationAllowed() const
191 : {
192 15 : return true;
193 : }
194 :
195 : // check if graphic animation is allowed. Default is sal_true.
196 15 : bool ObjectContact::IsGraphicAnimationAllowed() const
197 : {
198 15 : return true;
199 : }
200 :
201 : // check if asynchronious graphis loading is allowed. Default is false.
202 0 : bool ObjectContact::IsAsynchronGraphicsLoadingAllowed() const
203 : {
204 0 : return false;
205 : }
206 :
207 : // access to ViewObjectContactRedirector
208 300 : ViewObjectContactRedirector* ObjectContact::GetViewObjectContactRedirector() const
209 : {
210 300 : return mpViewObjectContactRedirector;
211 : }
212 :
213 1632 : void ObjectContact::SetViewObjectContactRedirector(ViewObjectContactRedirector* pNew)
214 : {
215 1632 : if(mpViewObjectContactRedirector != pNew)
216 : {
217 1096 : mpViewObjectContactRedirector = pNew;
218 : }
219 1632 : }
220 :
221 : // check if buffering of MasterPages is allowed. Default is false.
222 0 : bool ObjectContact::IsMasterPageBufferingAllowed() const
223 : {
224 0 : return false;
225 : }
226 :
227 : // print? Default is false
228 36 : bool ObjectContact::isOutputToPrinter() const
229 : {
230 36 : return false;
231 : }
232 :
233 : // window? Default is true
234 0 : bool ObjectContact::isOutputToWindow() const
235 : {
236 0 : return true;
237 : }
238 :
239 : // VirtualDevice? Default is false
240 0 : bool ObjectContact::isOutputToVirtualDevice() const
241 : {
242 0 : return false;
243 : }
244 :
245 : // recording MetaFile? Default is false
246 0 : bool ObjectContact::isOutputToRecordingMetaFile() const
247 : {
248 0 : return false;
249 : }
250 :
251 : // pdf export? Default is false
252 0 : bool ObjectContact::isOutputToPDFFile() const
253 : {
254 0 : return false;
255 : }
256 :
257 : // gray display mode
258 0 : bool ObjectContact::isDrawModeGray() const
259 : {
260 0 : return false;
261 : }
262 :
263 : // gray display mode
264 0 : bool ObjectContact::isDrawModeBlackWhite() const
265 : {
266 0 : return false;
267 : }
268 :
269 : // high contrast display mode
270 0 : bool ObjectContact::isDrawModeHighContrast() const
271 : {
272 0 : return false;
273 : }
274 :
275 : // access to SdrPageView. Default implementation returns NULL
276 21 : SdrPageView* ObjectContact::TryToGetSdrPageView() const
277 : {
278 21 : return 0;
279 : }
280 :
281 : // access to OutputDevice. Default implementation returns NULL
282 0 : OutputDevice* ObjectContact::TryToGetOutputDevice() const
283 : {
284 0 : return 0;
285 : }
286 :
287 0 : void ObjectContact::resetViewPort()
288 : {
289 0 : const drawinglayer::geometry::ViewInformation2D& rCurrentVI2D = getViewInformation2D();
290 :
291 0 : if(!rCurrentVI2D.getViewport().isEmpty())
292 : {
293 0 : const basegfx::B2DRange aEmptyRange;
294 :
295 : drawinglayer::geometry::ViewInformation2D aNewVI2D(
296 0 : rCurrentVI2D.getObjectTransformation(),
297 0 : rCurrentVI2D.getViewTransformation(),
298 : aEmptyRange,
299 0 : rCurrentVI2D.getVisualizedPage(),
300 : rCurrentVI2D.getViewTime(),
301 0 : rCurrentVI2D.getExtendedInformationSequence());
302 :
303 0 : updateViewInformation2D(aNewVI2D);
304 : }
305 0 : }
306 :
307 : } // end of namespace contact
308 : } // end of namespace sdr
309 :
310 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|