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