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