LCOV - code coverage report
Current view: top level - svx/source/sdr/contact - objectcontact.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 47 96 49.0 %
Date: 2014-04-11 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        1830 :         ObjectContact::ObjectContact()
      37             :         :   maViewObjectContactVector(),
      38             :             maPrimitiveAnimator(),
      39             :             mpEventHandler(0),
      40             :             mpViewObjectContactRedirector(0),
      41             :             maViewInformation2D(uno::Sequence< beans::PropertyValue >()),
      42        1830 :             mbIsPreviewRenderer(false)
      43             :         {
      44        1830 :         }
      45             : 
      46        3656 :         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        1828 :             std::vector< ViewObjectContact* > aLocalVOCList(maViewObjectContactVector);
      53        1828 :             maViewObjectContactVector.clear();
      54             : 
      55       38267 :             while(!aLocalVOCList.empty())
      56             :             {
      57       34611 :                 ViewObjectContact* pCandidate = aLocalVOCList.back();
      58       34611 :                 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       34611 :                 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        1828 :             DeleteEventHandler();
      72        1828 :         }
      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       34852 :         void ObjectContact::AddViewObjectContact(ViewObjectContact& rVOContact)
      88             :         {
      89       34852 :             maViewObjectContactVector.push_back(&rVOContact);
      90       34852 :         }
      91             : 
      92             :         // A ViewObjectContact was deleted and shall be forgotten.
      93       34826 :         void ObjectContact::RemoveViewObjectContact(ViewObjectContact& rVOContact)
      94             :         {
      95       34826 :             std::vector< ViewObjectContact* >::iterator aFindResult = std::find(maViewObjectContactVector.begin(), maViewObjectContactVector.end(), &rVOContact);
      96             : 
      97       34826 :             if(aFindResult != maViewObjectContactVector.end())
      98             :             {
      99         215 :                 maViewObjectContactVector.erase(aFindResult);
     100             :             }
     101       34826 :         }
     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         689 :         bool ObjectContact::DoVisualizeEnteredGroup() const
     111             :         {
     112             :             // Don not do that as default
     113         689 :             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       16355 :         void ObjectContact::InvalidatePartOfView(const basegfx::B2DRange& /*rRange*/) const
     126             :         {
     127             :             // nothing to do here in the default version
     128       16355 :         }
     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         642 :         bool ObjectContact::AreGluePointsVisible() const
     139             :         {
     140         642 :             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       27918 :         sdr::animation::primitiveAnimator& ObjectContact::getPrimitiveAnimator()
     152             :         {
     153       27918 :             return maPrimitiveAnimator;
     154             :         }
     155             : 
     156             :         // method to get the EventHandler. It will
     157             :         // return a existing one or create a new one using CreateEventHandler().
     158           0 :         sdr::event::TimerEventHandler& ObjectContact::GetEventHandler() const
     159             :         {
     160           0 :             if(!HasEventHandler())
     161             :             {
     162           0 :                 const_cast< ObjectContact* >(this)->mpEventHandler = const_cast< ObjectContact* >(this)->CreateEventHandler();
     163             :                 DBG_ASSERT(mpEventHandler, "ObjectContact::GetEventHandler(): Got no EventHandler (!)");
     164             :             }
     165             : 
     166           0 :             return *mpEventHandler;
     167             :         }
     168             : 
     169             :         // delete the EventHandler
     170        1828 :         void ObjectContact::DeleteEventHandler()
     171             :         {
     172        1828 :             if(mpEventHandler)
     173             :             {
     174             :                 // If there are still Events registered, something has went wrong
     175           0 :                 delete mpEventHandler;
     176           0 :                 mpEventHandler = 0L;
     177             :             }
     178        1828 :         }
     179             : 
     180             :         // test if there is an EventHandler without creating one on demand
     181       27918 :         bool ObjectContact::HasEventHandler() const
     182             :         {
     183       27918 :             return (0L != mpEventHandler);
     184             :         }
     185             : 
     186             :         // check if text animation is allowed. Default is sal_true.
     187         643 :         bool ObjectContact::IsTextAnimationAllowed() const
     188             :         {
     189         643 :             return true;
     190             :         }
     191             : 
     192             :         // check if graphic animation is allowed. Default is sal_true.
     193         643 :         bool ObjectContact::IsGraphicAnimationAllowed() const
     194             :         {
     195         643 :             return true;
     196             :         }
     197             : 
     198             :         // check if asynchronious graphis loading is allowed. Default is false.
     199           0 :         bool ObjectContact::IsAsynchronGraphicsLoadingAllowed() const
     200             :         {
     201           0 :             return false;
     202             :         }
     203             : 
     204             :         // access to ViewObjectContactRedirector
     205       33101 :         ViewObjectContactRedirector* ObjectContact::GetViewObjectContactRedirector() const
     206             :         {
     207       33101 :             return mpViewObjectContactRedirector;
     208             :         }
     209             : 
     210       55851 :         void ObjectContact::SetViewObjectContactRedirector(ViewObjectContactRedirector* pNew)
     211             :         {
     212       55851 :             if(mpViewObjectContactRedirector != pNew)
     213             :             {
     214       29074 :                 mpViewObjectContactRedirector = pNew;
     215             :             }
     216       55851 :         }
     217             : 
     218             :         // check if buffering of MasterPages is allowed. Default is false.
     219           0 :         bool ObjectContact::IsMasterPageBufferingAllowed() const
     220             :         {
     221           0 :             return false;
     222             :         }
     223             : 
     224             :         // print? Default is false
     225        1356 :         bool ObjectContact::isOutputToPrinter() const
     226             :         {
     227        1356 :             return false;
     228             :         }
     229             : 
     230             :         // window? Default is true
     231           0 :         bool ObjectContact::isOutputToWindow() const
     232             :         {
     233           0 :             return true;
     234             :         }
     235             : 
     236             :         // VirtualDevice? Default is false
     237           0 :         bool ObjectContact::isOutputToVirtualDevice() const
     238             :         {
     239           0 :             return false;
     240             :         }
     241             : 
     242             :         // recording MetaFile? Default is false
     243           0 :         bool ObjectContact::isOutputToRecordingMetaFile() const
     244             :         {
     245           0 :             return false;
     246             :         }
     247             : 
     248             :         // pdf export? Default is false
     249           0 :         bool ObjectContact::isOutputToPDFFile() const
     250             :         {
     251           0 :             return false;
     252             :         }
     253             : 
     254             :         // gray display mode
     255           0 :         bool ObjectContact::isDrawModeGray() const
     256             :         {
     257           0 :             return false;
     258             :         }
     259             : 
     260             :         // gray display mode
     261           0 :         bool ObjectContact::isDrawModeBlackWhite() const
     262             :         {
     263           0 :             return false;
     264             :         }
     265             : 
     266             :         // high contrast display mode
     267           0 :         bool ObjectContact::isDrawModeHighContrast() const
     268             :         {
     269           0 :             return false;
     270             :         }
     271             : 
     272             :         // access to SdrPageView. Default implementation returns NULL
     273         714 :         SdrPageView* ObjectContact::TryToGetSdrPageView() const
     274             :         {
     275         714 :             return 0;
     276             :         }
     277             : 
     278             :         // access to OutputDevice. Default implementation returns NULL
     279           0 :         OutputDevice* ObjectContact::TryToGetOutputDevice() const
     280             :         {
     281           0 :             return 0;
     282             :         }
     283             : 
     284           0 :         void ObjectContact::resetViewPort()
     285             :         {
     286           0 :             const drawinglayer::geometry::ViewInformation2D& rCurrentVI2D = getViewInformation2D();
     287             : 
     288           0 :             if(!rCurrentVI2D.getViewport().isEmpty())
     289             :             {
     290           0 :                 const basegfx::B2DRange aEmptyRange;
     291             : 
     292             :                 drawinglayer::geometry::ViewInformation2D aNewVI2D(
     293           0 :                     rCurrentVI2D.getObjectTransformation(),
     294           0 :                     rCurrentVI2D.getViewTransformation(),
     295             :                     aEmptyRange,
     296           0 :                     rCurrentVI2D.getVisualizedPage(),
     297             :                     rCurrentVI2D.getViewTime(),
     298           0 :                     rCurrentVI2D.getExtendedInformationSequence());
     299             : 
     300           0 :                 updateViewInformation2D(aNewVI2D);
     301             :             }
     302           0 :         }
     303             : 
     304             :     } // end of namespace contact
     305             : } // end of namespace sdr
     306             : 
     307             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10