merge the formfield patch from ooo-build
[ooovba.git] / svx / source / sdr / contact / objectcontact.cxx
blob435c08fba53dd15d9f490bf73110d60ea3f991bf
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: objectcontact.cxx,v $
10 * $Revision: 1.16 $
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/objectcontact.hxx>
34 #include <tools/debug.hxx>
35 #include <svx/sdr/contact/viewobjectcontact.hxx>
36 #include <svx/svdpage.hxx>
37 #include <svx/sdr/contact/viewcontact.hxx>
38 #include <svx/sdr/event/eventhandler.hxx>
39 #include <basegfx/matrix/b2dhommatrix.hxx>
40 #include <svx/sdr/animation/objectanimator.hxx>
41 #include <svx/sdr/event/eventhandler.hxx>
43 //////////////////////////////////////////////////////////////////////////////
45 using namespace com::sun::star;
47 //////////////////////////////////////////////////////////////////////////////
49 namespace sdr
51 namespace contact
53 ObjectContact::ObjectContact()
54 : maViewObjectContactVector(),
55 maPrimitiveAnimator(),
56 mpEventHandler(0),
57 mpViewObjectContactRedirector(0),
58 maViewInformation2D(uno::Sequence< beans::PropertyValue >()),
59 mbIsPreviewRenderer(false)
63 ObjectContact::~ObjectContact()
65 // get rid of all registered contacts
66 // #i84257# To avoid that each 'delete pCandidate' again uses
67 // the local RemoveViewObjectContact with a search and removal in the
68 // vector, simply copy and clear local vector.
69 std::vector< ViewObjectContact* > aLocalVOCList(maViewObjectContactVector);
70 maViewObjectContactVector.clear();
72 while(aLocalVOCList.size())
74 ViewObjectContact* pCandidate = aLocalVOCList.back();
75 aLocalVOCList.pop_back();
76 DBG_ASSERT(pCandidate, "Corrupted ViewObjectContactList (!)");
78 // ViewObjectContacts only make sense with View and Object contacts.
79 // When the contact to the SdrObject is deleted like in this case,
80 // all ViewObjectContacts can be deleted, too.
81 delete pCandidate;
84 // assert when there were new entries added during deletion
85 DBG_ASSERT(maViewObjectContactVector.empty(), "Corrupted ViewObjectContactList (!)");
87 // delete the EventHandler. This will destroy all still contained events.
88 DeleteEventHandler();
91 // LazyInvalidate request. Default implementation directly handles
92 // this by calling back triggerLazyInvalidate() at the VOC
93 void ObjectContact::setLazyInvalidate(ViewObjectContact& rVOC)
95 rVOC.triggerLazyInvalidate();
98 // call this to support evtl. preparations for repaint. Default does nothing
99 void ObjectContact::PrepareProcessDisplay()
103 // A new ViewObjectContact was created and shall be remembered.
104 void ObjectContact::AddViewObjectContact(ViewObjectContact& rVOContact)
106 maViewObjectContactVector.push_back(&rVOContact);
109 // A ViewObjectContact was deleted and shall be forgotten.
110 void ObjectContact::RemoveViewObjectContact(ViewObjectContact& rVOContact)
112 std::vector< ViewObjectContact* >::iterator aFindResult = std::find(maViewObjectContactVector.begin(), maViewObjectContactVector.end(), &rVOContact);
114 if(aFindResult != maViewObjectContactVector.end())
116 maViewObjectContactVector.erase(aFindResult);
120 // Process the whole displaying
121 void ObjectContact::ProcessDisplay(DisplayInfo& /*rDisplayInfo*/)
123 // default does nothing
126 // test if visualizing of entered groups is switched on at all
127 bool ObjectContact::DoVisualizeEnteredGroup() const
129 // Don not do that as default
130 return false;
133 // get active group's (the entered group) ViewContact
134 const ViewContact* ObjectContact::getActiveViewContact() const
136 // default has no active VC
137 return 0;
140 // Invalidate given rectangle at the window/output which is represented by
141 // this ObjectContact.
142 void ObjectContact::InvalidatePartOfView(const basegfx::B2DRange& /*rRange*/) const
144 // nothing to do here in the default version
147 // Get info if given Rectangle is visible in this view
148 bool ObjectContact::IsAreaVisible(const basegfx::B2DRange& /*rRange*/) const
150 // always visible in default version
151 return true;
154 // Get info about the need to visualize GluePoints
155 bool ObjectContact::AreGluePointsVisible() const
157 return false;
160 // method to create a EventHandler. Needs to give a result.
161 sdr::event::TimerEventHandler* ObjectContact::CreateEventHandler()
163 // Create and return a new EventHandler
164 return new sdr::event::TimerEventHandler();
167 // method to get the primitiveAnimator
168 sdr::animation::primitiveAnimator& ObjectContact::getPrimitiveAnimator()
170 return maPrimitiveAnimator;
173 // method to get the EventHandler. It will
174 // return a existing one or create a new one using CreateEventHandler().
175 sdr::event::TimerEventHandler& ObjectContact::GetEventHandler() const
177 if(!HasEventHandler())
179 const_cast< ObjectContact* >(this)->mpEventHandler = const_cast< ObjectContact* >(this)->CreateEventHandler();
180 DBG_ASSERT(mpEventHandler, "ObjectContact::GetEventHandler(): Got no EventHandler (!)");
183 return *mpEventHandler;
186 // delete the EventHandler
187 void ObjectContact::DeleteEventHandler()
189 if(mpEventHandler)
191 // If there are still Events registered, something has went wrong
192 delete mpEventHandler;
193 mpEventHandler = 0L;
197 // test if there is an EventHandler without creating one on demand
198 bool ObjectContact::HasEventHandler() const
200 return (0L != mpEventHandler);
203 // check if text animation is allowed. Default is sal_true.
204 bool ObjectContact::IsTextAnimationAllowed() const
206 return true;
209 // check if graphic animation is allowed. Default is sal_true.
210 bool ObjectContact::IsGraphicAnimationAllowed() const
212 return true;
215 // check if asynchronious graphis loading is allowed. Default is false.
216 bool ObjectContact::IsAsynchronGraphicsLoadingAllowed() const
218 return false;
221 // access to ViewObjectContactRedirector
222 ViewObjectContactRedirector* ObjectContact::GetViewObjectContactRedirector() const
224 return mpViewObjectContactRedirector;
227 void ObjectContact::SetViewObjectContactRedirector(ViewObjectContactRedirector* pNew)
229 if(mpViewObjectContactRedirector != pNew)
231 mpViewObjectContactRedirector = pNew;
235 // check if buffering of MasterPages is allowed. Default is false.
236 bool ObjectContact::IsMasterPageBufferingAllowed() const
238 return false;
241 // print? Default is false
242 bool ObjectContact::isOutputToPrinter() const
244 return false;
247 // window? Default is true
248 bool ObjectContact::isOutputToWindow() const
250 return true;
253 // VirtualDevice? Default is false
254 bool ObjectContact::isOutputToVirtualDevice() const
256 return false;
259 // recording MetaFile? Default is false
260 bool ObjectContact::isOutputToRecordingMetaFile() const
262 return false;
265 // pdf export? Default is false
266 bool ObjectContact::isOutputToPDFFile() const
268 return false;
271 // gray display mode
272 bool ObjectContact::isDrawModeGray() const
274 return false;
277 // gray display mode
278 bool ObjectContact::isDrawModeBlackWhite() const
280 return false;
283 // high contrast display mode
284 bool ObjectContact::isDrawModeHighContrast() const
286 return false;
289 // access to SdrPageView. Default implementation returns NULL
290 SdrPageView* ObjectContact::TryToGetSdrPageView() const
292 return 0;
295 // access to OutputDevice. Default implementation returns NULL
296 OutputDevice* ObjectContact::TryToGetOutputDevice() const
298 return 0;
301 void ObjectContact::resetViewPort()
303 const drawinglayer::geometry::ViewInformation2D& rCurrentVI2D = getViewInformation2D();
305 if(!rCurrentVI2D.getViewport().isEmpty())
307 const basegfx::B2DRange aEmptyRange;
309 drawinglayer::geometry::ViewInformation2D aNewVI2D(
310 rCurrentVI2D.getObjectTransformation(),
311 rCurrentVI2D.getViewTransformation(),
312 aEmptyRange,
313 rCurrentVI2D.getVisualizedPage(),
314 rCurrentVI2D.getViewTime(),
315 rCurrentVI2D.getExtendedInformationSequence());
317 updateViewInformation2D(aNewVI2D);
321 } // end of namespace contact
322 } // end of namespace sdr
324 //////////////////////////////////////////////////////////////////////////////
325 // eof