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/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>
28 #include "eventhandler.hxx"
30 using namespace com::sun::star
;
32 namespace sdr
{ namespace contact
{
34 ObjectContact::ObjectContact()
35 : maViewObjectContactVector(),
36 maPrimitiveAnimator(),
37 mpEventHandler(nullptr),
38 mpViewObjectContactRedirector(nullptr),
39 maViewInformation2D(uno::Sequence
< beans::PropertyValue
>()),
40 mbIsPreviewRenderer(false)
44 ObjectContact::~ObjectContact()
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 std::vector
< ViewObjectContact
* > aLocalVOCList(maViewObjectContactVector
);
51 maViewObjectContactVector
.clear();
53 while(!aLocalVOCList
.empty())
55 ViewObjectContact
* pCandidate
= aLocalVOCList
.back();
56 aLocalVOCList
.pop_back();
57 DBG_ASSERT(pCandidate
, "Corrupted ViewObjectContactList (!)");
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.
65 // assert when there were new entries added during deletion
66 DBG_ASSERT(maViewObjectContactVector
.empty(), "Corrupted ViewObjectContactList (!)");
68 // delete the EventHandler. This will destroy all still contained events.
71 // If there are still Events registered, something has went wrong
72 delete mpEventHandler
;
73 mpEventHandler
= nullptr;
77 // LazyInvalidate request. Default implementation directly handles
78 // this by calling back triggerLazyInvalidate() at the VOC
79 void ObjectContact::setLazyInvalidate(ViewObjectContact
& rVOC
)
81 rVOC
.triggerLazyInvalidate();
84 // call this to support evtl. preparations for repaint. Default does nothing
85 void ObjectContact::PrepareProcessDisplay()
89 // A new ViewObjectContact was created and shall be remembered.
90 void ObjectContact::AddViewObjectContact(ViewObjectContact
& rVOContact
)
92 maViewObjectContactVector
.push_back(&rVOContact
);
95 // A ViewObjectContact was deleted and shall be forgotten.
96 void ObjectContact::RemoveViewObjectContact(ViewObjectContact
& rVOContact
)
98 std::vector
< ViewObjectContact
* >::iterator aFindResult
= std::find(maViewObjectContactVector
.begin(), maViewObjectContactVector
.end(), &rVOContact
);
100 if(aFindResult
!= maViewObjectContactVector
.end())
102 maViewObjectContactVector
.erase(aFindResult
);
106 // Process the whole displaying
107 void ObjectContact::ProcessDisplay(DisplayInfo
& /*rDisplayInfo*/)
109 // default does nothing
112 // test if visualizing of entered groups is switched on at all
113 bool ObjectContact::DoVisualizeEnteredGroup() const
115 // Do not do that as default
119 // get active group's (the entered group) ViewContact
120 const ViewContact
* ObjectContact::getActiveViewContact() const
122 // default has no active VC
126 // Invalidate given rectangle at the window/output which is represented by
127 // this ObjectContact.
128 void ObjectContact::InvalidatePartOfView(const basegfx::B2DRange
& /*rRange*/) const
130 // nothing to do here in the default version
133 // Get info if given Rectangle is visible in this view
134 bool ObjectContact::IsAreaVisible(const basegfx::B2DRange
& /*rRange*/) const
136 // always visible in default version
140 // Get info about the need to visualize GluePoints
141 bool ObjectContact::AreGluePointsVisible() const
146 // method to get the primitiveAnimator
148 // method to get the EventHandler. It will
149 // return a existing one or create a new one using CreateEventHandler().
150 sdr::event::TimerEventHandler
& ObjectContact::GetEventHandler() const
152 if(!HasEventHandler())
154 const_cast< ObjectContact
* >(this)->mpEventHandler
= new sdr::event::TimerEventHandler();
156 return *mpEventHandler
;
159 // test if there is an EventHandler without creating one on demand
160 bool ObjectContact::HasEventHandler() const
162 return (nullptr != mpEventHandler
);
165 // check if text animation is allowed. Default is sal_true.
166 bool ObjectContact::IsTextAnimationAllowed() const
171 // check if graphic animation is allowed. Default is sal_true.
172 bool ObjectContact::IsGraphicAnimationAllowed() const
177 // check if asynchronous graphics loading is allowed. Default is false.
178 bool ObjectContact::IsAsynchronGraphicsLoadingAllowed() const
183 void ObjectContact::SetViewObjectContactRedirector(ViewObjectContactRedirector
* pNew
)
185 if(mpViewObjectContactRedirector
!= pNew
)
187 mpViewObjectContactRedirector
= pNew
;
191 // print? Default is false
192 bool ObjectContact::isOutputToPrinter() const
197 // window? Default is true
198 bool ObjectContact::isOutputToWindow() const
203 // VirtualDevice? Default is false
204 bool ObjectContact::isOutputToVirtualDevice() const
209 // recording MetaFile? Default is false
210 bool ObjectContact::isOutputToRecordingMetaFile() const
215 // pdf export? Default is false
216 bool ObjectContact::isOutputToPDFFile() const
222 bool ObjectContact::isDrawModeGray() const
228 bool ObjectContact::isDrawModeBlackWhite() const
233 // high contrast display mode
234 bool ObjectContact::isDrawModeHighContrast() const
239 // access to SdrPageView. Default implementation returns NULL
240 SdrPageView
* ObjectContact::TryToGetSdrPageView() const
245 // access to OutputDevice. Default implementation returns NULL
246 OutputDevice
* ObjectContact::TryToGetOutputDevice() const
251 void ObjectContact::resetViewPort()
253 const drawinglayer::geometry::ViewInformation2D
& rCurrentVI2D
= getViewInformation2D();
255 if(!rCurrentVI2D
.getViewport().isEmpty())
257 const basegfx::B2DRange aEmptyRange
;
259 drawinglayer::geometry::ViewInformation2D
aNewVI2D(
260 rCurrentVI2D
.getObjectTransformation(),
261 rCurrentVI2D
.getViewTransformation(),
263 rCurrentVI2D
.getVisualizedPage(),
264 rCurrentVI2D
.getViewTime(),
265 rCurrentVI2D
.getExtendedInformationSequence());
267 updateViewInformation2D(aNewVI2D
);
273 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */