1f6e50924SAndrew Rist /************************************************************** 2*a70413d2Smseidel * 3f6e50924SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4f6e50924SAndrew Rist * or more contributor license agreements. See the NOTICE file 5f6e50924SAndrew Rist * distributed with this work for additional information 6f6e50924SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7f6e50924SAndrew Rist * to you under the Apache License, Version 2.0 (the 8f6e50924SAndrew Rist * "License"); you may not use this file except in compliance 9f6e50924SAndrew Rist * with the License. You may obtain a copy of the License at 10*a70413d2Smseidel * 11f6e50924SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*a70413d2Smseidel * 13f6e50924SAndrew Rist * Unless required by applicable law or agreed to in writing, 14f6e50924SAndrew Rist * software distributed under the License is distributed on an 15f6e50924SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16f6e50924SAndrew Rist * KIND, either express or implied. See the License for the 17f6e50924SAndrew Rist * specific language governing permissions and limitations 18f6e50924SAndrew Rist * under the License. 19*a70413d2Smseidel * 20f6e50924SAndrew Rist *************************************************************/ 21f6e50924SAndrew Rist 22f6e50924SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_svx.hxx" 26cdf0e10cSrcweir #include <svx/sdr/contact/objectcontact.hxx> 27cdf0e10cSrcweir #include <tools/debug.hxx> 28cdf0e10cSrcweir #include <svx/sdr/contact/viewobjectcontact.hxx> 29cdf0e10cSrcweir #include <svx/svdpage.hxx> 30cdf0e10cSrcweir #include <svx/sdr/contact/viewcontact.hxx> 31cdf0e10cSrcweir #include <svx/sdr/event/eventhandler.hxx> 32cdf0e10cSrcweir #include <basegfx/matrix/b2dhommatrix.hxx> 33cdf0e10cSrcweir #include <svx/sdr/animation/objectanimator.hxx> 34cdf0e10cSrcweir #include <svx/sdr/event/eventhandler.hxx> 35cdf0e10cSrcweir 36cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 37cdf0e10cSrcweir 38cdf0e10cSrcweir using namespace com::sun::star; 39cdf0e10cSrcweir 40cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 41cdf0e10cSrcweir 42cdf0e10cSrcweir namespace sdr 43cdf0e10cSrcweir { 44cdf0e10cSrcweir namespace contact 45cdf0e10cSrcweir { ObjectContact()46cdf0e10cSrcweir ObjectContact::ObjectContact() 47cdf0e10cSrcweir : maViewObjectContactVector(), 48cdf0e10cSrcweir maPrimitiveAnimator(), 49cdf0e10cSrcweir mpEventHandler(0), 50cdf0e10cSrcweir mpViewObjectContactRedirector(0), 51cdf0e10cSrcweir maViewInformation2D(uno::Sequence< beans::PropertyValue >()), 52cdf0e10cSrcweir mbIsPreviewRenderer(false) 53cdf0e10cSrcweir { 54cdf0e10cSrcweir } 55cdf0e10cSrcweir ~ObjectContact()56cdf0e10cSrcweir ObjectContact::~ObjectContact() 57cdf0e10cSrcweir { 58cdf0e10cSrcweir // get rid of all registered contacts 59cdf0e10cSrcweir // #i84257# To avoid that each 'delete pCandidate' again uses 60cdf0e10cSrcweir // the local RemoveViewObjectContact with a search and removal in the 61cdf0e10cSrcweir // vector, simply copy and clear local vector. 62cdf0e10cSrcweir std::vector< ViewObjectContact* > aLocalVOCList(maViewObjectContactVector); 63cdf0e10cSrcweir maViewObjectContactVector.clear(); 64cdf0e10cSrcweir 65cdf0e10cSrcweir while(!aLocalVOCList.empty()) 66cdf0e10cSrcweir { 67cdf0e10cSrcweir ViewObjectContact* pCandidate = aLocalVOCList.back(); 68cdf0e10cSrcweir aLocalVOCList.pop_back(); 69cdf0e10cSrcweir DBG_ASSERT(pCandidate, "Corrupted ViewObjectContactList (!)"); 70cdf0e10cSrcweir 71cdf0e10cSrcweir // ViewObjectContacts only make sense with View and Object contacts. 72cdf0e10cSrcweir // When the contact to the SdrObject is deleted like in this case, 73cdf0e10cSrcweir // all ViewObjectContacts can be deleted, too. 74cdf0e10cSrcweir delete pCandidate; 75cdf0e10cSrcweir } 76cdf0e10cSrcweir 77cdf0e10cSrcweir // assert when there were new entries added during deletion 78cdf0e10cSrcweir DBG_ASSERT(maViewObjectContactVector.empty(), "Corrupted ViewObjectContactList (!)"); 79cdf0e10cSrcweir 80cdf0e10cSrcweir // delete the EventHandler. This will destroy all still contained events. 81cdf0e10cSrcweir DeleteEventHandler(); 82cdf0e10cSrcweir } 83cdf0e10cSrcweir 84cdf0e10cSrcweir // LazyInvalidate request. Default implementation directly handles 85cdf0e10cSrcweir // this by calling back triggerLazyInvalidate() at the VOC setLazyInvalidate(ViewObjectContact & rVOC)86cdf0e10cSrcweir void ObjectContact::setLazyInvalidate(ViewObjectContact& rVOC) 87cdf0e10cSrcweir { 88cdf0e10cSrcweir rVOC.triggerLazyInvalidate(); 89cdf0e10cSrcweir } 90cdf0e10cSrcweir 91cdf0e10cSrcweir // call this to support evtl. preparations for repaint. Default does nothing PrepareProcessDisplay()92cdf0e10cSrcweir void ObjectContact::PrepareProcessDisplay() 93cdf0e10cSrcweir { 94cdf0e10cSrcweir } 95cdf0e10cSrcweir 96cdf0e10cSrcweir // A new ViewObjectContact was created and shall be remembered. AddViewObjectContact(ViewObjectContact & rVOContact)97cdf0e10cSrcweir void ObjectContact::AddViewObjectContact(ViewObjectContact& rVOContact) 98cdf0e10cSrcweir { 99cdf0e10cSrcweir maViewObjectContactVector.push_back(&rVOContact); 100cdf0e10cSrcweir } 101*a70413d2Smseidel 102cdf0e10cSrcweir // A ViewObjectContact was deleted and shall be forgotten. RemoveViewObjectContact(ViewObjectContact & rVOContact)103cdf0e10cSrcweir void ObjectContact::RemoveViewObjectContact(ViewObjectContact& rVOContact) 104cdf0e10cSrcweir { 105cdf0e10cSrcweir std::vector< ViewObjectContact* >::iterator aFindResult = std::find(maViewObjectContactVector.begin(), maViewObjectContactVector.end(), &rVOContact); 106*a70413d2Smseidel 107cdf0e10cSrcweir if(aFindResult != maViewObjectContactVector.end()) 108cdf0e10cSrcweir { 109cdf0e10cSrcweir maViewObjectContactVector.erase(aFindResult); 110cdf0e10cSrcweir } 111cdf0e10cSrcweir } 112cdf0e10cSrcweir 113cdf0e10cSrcweir // Process the whole displaying ProcessDisplay(DisplayInfo &)114cdf0e10cSrcweir void ObjectContact::ProcessDisplay(DisplayInfo& /*rDisplayInfo*/) 115cdf0e10cSrcweir { 116cdf0e10cSrcweir // default does nothing 117cdf0e10cSrcweir } 118cdf0e10cSrcweir 119cdf0e10cSrcweir // test if visualizing of entered groups is switched on at all DoVisualizeEnteredGroup() const120cdf0e10cSrcweir bool ObjectContact::DoVisualizeEnteredGroup() const 121cdf0e10cSrcweir { 122cdf0e10cSrcweir // Don not do that as default 123cdf0e10cSrcweir return false; 124cdf0e10cSrcweir } 125cdf0e10cSrcweir 126cdf0e10cSrcweir // get active group's (the entered group) ViewContact getActiveViewContact() const127cdf0e10cSrcweir const ViewContact* ObjectContact::getActiveViewContact() const 128cdf0e10cSrcweir { 129cdf0e10cSrcweir // default has no active VC 130cdf0e10cSrcweir return 0; 131cdf0e10cSrcweir } 132*a70413d2Smseidel 133cdf0e10cSrcweir // Invalidate given rectangle at the window/output which is represented by 134cdf0e10cSrcweir // this ObjectContact. InvalidatePartOfView(const basegfx::B2DRange &) const135cdf0e10cSrcweir void ObjectContact::InvalidatePartOfView(const basegfx::B2DRange& /*rRange*/) const 136cdf0e10cSrcweir { 137cdf0e10cSrcweir // nothing to do here in the default version 138cdf0e10cSrcweir } 139cdf0e10cSrcweir 140cdf0e10cSrcweir // Get info if given Rectangle is visible in this view IsAreaVisible(const basegfx::B2DRange &) const141cdf0e10cSrcweir bool ObjectContact::IsAreaVisible(const basegfx::B2DRange& /*rRange*/) const 142cdf0e10cSrcweir { 143cdf0e10cSrcweir // always visible in default version 144cdf0e10cSrcweir return true; 145cdf0e10cSrcweir } 146cdf0e10cSrcweir 147cdf0e10cSrcweir // Get info about the need to visualize GluePoints AreGluePointsVisible() const148cdf0e10cSrcweir bool ObjectContact::AreGluePointsVisible() const 149cdf0e10cSrcweir { 150cdf0e10cSrcweir return false; 151cdf0e10cSrcweir } 152cdf0e10cSrcweir 153cdf0e10cSrcweir // method to create a EventHandler. Needs to give a result. CreateEventHandler()154cdf0e10cSrcweir sdr::event::TimerEventHandler* ObjectContact::CreateEventHandler() 155cdf0e10cSrcweir { 156cdf0e10cSrcweir // Create and return a new EventHandler 157cdf0e10cSrcweir return new sdr::event::TimerEventHandler(); 158cdf0e10cSrcweir } 159cdf0e10cSrcweir 160cdf0e10cSrcweir // method to get the primitiveAnimator getPrimitiveAnimator()161cdf0e10cSrcweir sdr::animation::primitiveAnimator& ObjectContact::getPrimitiveAnimator() 162cdf0e10cSrcweir { 163cdf0e10cSrcweir return maPrimitiveAnimator; 164cdf0e10cSrcweir } 165cdf0e10cSrcweir 166cdf0e10cSrcweir // method to get the EventHandler. It will 167*a70413d2Smseidel // return an existing one or create a new one using CreateEventHandler(). GetEventHandler() const168cdf0e10cSrcweir sdr::event::TimerEventHandler& ObjectContact::GetEventHandler() const 169cdf0e10cSrcweir { 170cdf0e10cSrcweir if(!HasEventHandler()) 171cdf0e10cSrcweir { 172cdf0e10cSrcweir const_cast< ObjectContact* >(this)->mpEventHandler = const_cast< ObjectContact* >(this)->CreateEventHandler(); 173cdf0e10cSrcweir DBG_ASSERT(mpEventHandler, "ObjectContact::GetEventHandler(): Got no EventHandler (!)"); 174cdf0e10cSrcweir } 175cdf0e10cSrcweir 176cdf0e10cSrcweir return *mpEventHandler; 177cdf0e10cSrcweir } 178cdf0e10cSrcweir 179cdf0e10cSrcweir // delete the EventHandler DeleteEventHandler()180cdf0e10cSrcweir void ObjectContact::DeleteEventHandler() 181cdf0e10cSrcweir { 182cdf0e10cSrcweir if(mpEventHandler) 183cdf0e10cSrcweir { 184cdf0e10cSrcweir // If there are still Events registered, something has went wrong 185cdf0e10cSrcweir delete mpEventHandler; 186cdf0e10cSrcweir mpEventHandler = 0L; 187cdf0e10cSrcweir } 188cdf0e10cSrcweir } 189cdf0e10cSrcweir 190cdf0e10cSrcweir // test if there is an EventHandler without creating one on demand HasEventHandler() const191cdf0e10cSrcweir bool ObjectContact::HasEventHandler() const 192cdf0e10cSrcweir { 193cdf0e10cSrcweir return (0L != mpEventHandler); 194cdf0e10cSrcweir } 195cdf0e10cSrcweir 196cdf0e10cSrcweir // check if text animation is allowed. Default is sal_true. IsTextAnimationAllowed() const197cdf0e10cSrcweir bool ObjectContact::IsTextAnimationAllowed() const 198cdf0e10cSrcweir { 199cdf0e10cSrcweir return true; 200cdf0e10cSrcweir } 201cdf0e10cSrcweir 202cdf0e10cSrcweir // check if graphic animation is allowed. Default is sal_true. IsGraphicAnimationAllowed() const203cdf0e10cSrcweir bool ObjectContact::IsGraphicAnimationAllowed() const 204cdf0e10cSrcweir { 205cdf0e10cSrcweir return true; 206cdf0e10cSrcweir } 207cdf0e10cSrcweir 208*a70413d2Smseidel // check if asynchronous graphics loading is allowed. Default is false. IsAsynchronGraphicsLoadingAllowed() const209cdf0e10cSrcweir bool ObjectContact::IsAsynchronGraphicsLoadingAllowed() const 210cdf0e10cSrcweir { 211cdf0e10cSrcweir return false; 212cdf0e10cSrcweir } 213cdf0e10cSrcweir 214cdf0e10cSrcweir // access to ViewObjectContactRedirector GetViewObjectContactRedirector() const215cdf0e10cSrcweir ViewObjectContactRedirector* ObjectContact::GetViewObjectContactRedirector() const 216cdf0e10cSrcweir { 217cdf0e10cSrcweir return mpViewObjectContactRedirector; 218cdf0e10cSrcweir } 219cdf0e10cSrcweir SetViewObjectContactRedirector(ViewObjectContactRedirector * pNew)220cdf0e10cSrcweir void ObjectContact::SetViewObjectContactRedirector(ViewObjectContactRedirector* pNew) 221cdf0e10cSrcweir { 222cdf0e10cSrcweir if(mpViewObjectContactRedirector != pNew) 223cdf0e10cSrcweir { 224cdf0e10cSrcweir mpViewObjectContactRedirector = pNew; 225cdf0e10cSrcweir } 226cdf0e10cSrcweir } 227cdf0e10cSrcweir 228cdf0e10cSrcweir // check if buffering of MasterPages is allowed. Default is false. IsMasterPageBufferingAllowed() const229cdf0e10cSrcweir bool ObjectContact::IsMasterPageBufferingAllowed() const 230cdf0e10cSrcweir { 231cdf0e10cSrcweir return false; 232cdf0e10cSrcweir } 233cdf0e10cSrcweir 234cdf0e10cSrcweir // print? Default is false isOutputToPrinter() const235cdf0e10cSrcweir bool ObjectContact::isOutputToPrinter() const 236cdf0e10cSrcweir { 237cdf0e10cSrcweir return false; 238cdf0e10cSrcweir } 239cdf0e10cSrcweir 240cdf0e10cSrcweir // window? Default is true isOutputToWindow() const241cdf0e10cSrcweir bool ObjectContact::isOutputToWindow() const 242cdf0e10cSrcweir { 243cdf0e10cSrcweir return true; 244cdf0e10cSrcweir } 245cdf0e10cSrcweir 246cdf0e10cSrcweir // VirtualDevice? Default is false isOutputToVirtualDevice() const247cdf0e10cSrcweir bool ObjectContact::isOutputToVirtualDevice() const 248cdf0e10cSrcweir { 249cdf0e10cSrcweir return false; 250cdf0e10cSrcweir } 251cdf0e10cSrcweir 252cdf0e10cSrcweir // recording MetaFile? Default is false isOutputToRecordingMetaFile() const253cdf0e10cSrcweir bool ObjectContact::isOutputToRecordingMetaFile() const 254cdf0e10cSrcweir { 255cdf0e10cSrcweir return false; 256cdf0e10cSrcweir } 257cdf0e10cSrcweir 258cdf0e10cSrcweir // pdf export? Default is false isOutputToPDFFile() const259cdf0e10cSrcweir bool ObjectContact::isOutputToPDFFile() const 260cdf0e10cSrcweir { 261cdf0e10cSrcweir return false; 262cdf0e10cSrcweir } 263cdf0e10cSrcweir 264cdf0e10cSrcweir // gray display mode isDrawModeGray() const265cdf0e10cSrcweir bool ObjectContact::isDrawModeGray() const 266cdf0e10cSrcweir { 267cdf0e10cSrcweir return false; 268cdf0e10cSrcweir } 269cdf0e10cSrcweir 270cdf0e10cSrcweir // gray display mode isDrawModeBlackWhite() const271cdf0e10cSrcweir bool ObjectContact::isDrawModeBlackWhite() const 272cdf0e10cSrcweir { 273cdf0e10cSrcweir return false; 274cdf0e10cSrcweir } 275cdf0e10cSrcweir 276cdf0e10cSrcweir // high contrast display mode isDrawModeHighContrast() const277cdf0e10cSrcweir bool ObjectContact::isDrawModeHighContrast() const 278cdf0e10cSrcweir { 279cdf0e10cSrcweir return false; 280cdf0e10cSrcweir } 281cdf0e10cSrcweir 282*a70413d2Smseidel // access to SdrPageView. Default implementation returns NULL TryToGetSdrPageView() const283cdf0e10cSrcweir SdrPageView* ObjectContact::TryToGetSdrPageView() const 284*a70413d2Smseidel { 285*a70413d2Smseidel return 0; 286*a70413d2Smseidel } 287*a70413d2Smseidel 288cdf0e10cSrcweir // access to OutputDevice. Default implementation returns NULL TryToGetOutputDevice() const289cdf0e10cSrcweir OutputDevice* ObjectContact::TryToGetOutputDevice() const 290*a70413d2Smseidel { 291*a70413d2Smseidel return 0; 292*a70413d2Smseidel } 293cdf0e10cSrcweir resetViewPort()294*a70413d2Smseidel void ObjectContact::resetViewPort() 295*a70413d2Smseidel { 296cdf0e10cSrcweir const drawinglayer::geometry::ViewInformation2D& rCurrentVI2D = getViewInformation2D(); 297cdf0e10cSrcweir 298*a70413d2Smseidel if(!rCurrentVI2D.getViewport().isEmpty()) 299*a70413d2Smseidel { 300*a70413d2Smseidel const basegfx::B2DRange aEmptyRange; 301*a70413d2Smseidel 302*a70413d2Smseidel drawinglayer::geometry::ViewInformation2D aNewVI2D( 303*a70413d2Smseidel rCurrentVI2D.getObjectTransformation(), 304*a70413d2Smseidel rCurrentVI2D.getViewTransformation(), 305*a70413d2Smseidel aEmptyRange, 306*a70413d2Smseidel rCurrentVI2D.getVisualizedPage(), 307*a70413d2Smseidel rCurrentVI2D.getViewTime(), 308*a70413d2Smseidel rCurrentVI2D.getExtendedInformationSequence()); 309*a70413d2Smseidel 310*a70413d2Smseidel updateViewInformation2D(aNewVI2D); 311*a70413d2Smseidel } 312*a70413d2Smseidel } 313cdf0e10cSrcweir 314cdf0e10cSrcweir } // end of namespace contact 315cdf0e10cSrcweir } // end of namespace sdr 316cdf0e10cSrcweir 317cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 318cdf0e10cSrcweir // eof 319