LCOV - code coverage report
Current view: top level - svx/source/sdr/contact - objectcontact.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 44 93 47.3 %
Date: 2014-11-03 Functions: 16 35 45.7 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10