LCOV - code coverage report
Current view: top level - svx/source/sdr/contact - objectcontact.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 47 96 49.0 %
Date: 2012-08-25 Functions: 16 35 45.7 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 24 68 35.3 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include <svx/sdr/contact/objectcontact.hxx>
      30                 :            : #include <tools/debug.hxx>
      31                 :            : #include <svx/sdr/contact/viewobjectcontact.hxx>
      32                 :            : #include <svx/svdpage.hxx>
      33                 :            : #include <svx/sdr/contact/viewcontact.hxx>
      34                 :            : #include <svx/sdr/event/eventhandler.hxx>
      35                 :            : #include <basegfx/matrix/b2dhommatrix.hxx>
      36                 :            : #include <svx/sdr/animation/objectanimator.hxx>
      37                 :            : 
      38                 :            : //////////////////////////////////////////////////////////////////////////////
      39                 :            : 
      40                 :            : using namespace com::sun::star;
      41                 :            : 
      42                 :            : //////////////////////////////////////////////////////////////////////////////
      43                 :            : 
      44                 :            : namespace sdr
      45                 :            : {
      46                 :            :     namespace contact
      47                 :            :     {
      48                 :       3802 :         ObjectContact::ObjectContact()
      49                 :            :         :   maViewObjectContactVector(),
      50                 :            :             maPrimitiveAnimator(),
      51                 :            :             mpEventHandler(0),
      52                 :            :             mpViewObjectContactRedirector(0),
      53                 :            :             maViewInformation2D(uno::Sequence< beans::PropertyValue >()),
      54 [ +  - ][ +  - ]:       3802 :             mbIsPreviewRenderer(false)
         [ +  - ][ +  - ]
      55                 :            :         {
      56                 :       3802 :         }
      57                 :            : 
      58 [ +  - ][ +  - ]:       3715 :         ObjectContact::~ObjectContact()
      59                 :            :         {
      60                 :            :             // get rid of all registered contacts
      61                 :            :             // #i84257# To avoid that each 'delete pCandidate' again uses
      62                 :            :             // the local RemoveViewObjectContact with a search and removal in the
      63                 :            :             // vector, simply copy and clear local vector.
      64         [ +  - ]:       3715 :             std::vector< ViewObjectContact* > aLocalVOCList(maViewObjectContactVector);
      65                 :       3715 :             maViewObjectContactVector.clear();
      66                 :            : 
      67         [ +  + ]:      94622 :             while(!aLocalVOCList.empty())
      68                 :            :             {
      69         [ +  - ]:      90907 :                 ViewObjectContact* pCandidate = aLocalVOCList.back();
      70         [ +  - ]:      90907 :                 aLocalVOCList.pop_back();
      71                 :            :                 DBG_ASSERT(pCandidate, "Corrupted ViewObjectContactList (!)");
      72                 :            : 
      73                 :            :                 // ViewObjectContacts only make sense with View and Object contacts.
      74                 :            :                 // When the contact to the SdrObject is deleted like in this case,
      75                 :            :                 // all ViewObjectContacts can be deleted, too.
      76 [ +  - ][ +  - ]:      90907 :                 delete pCandidate;
      77                 :            :             }
      78                 :            : 
      79                 :            :             // assert when there were new entries added during deletion
      80                 :            :             DBG_ASSERT(maViewObjectContactVector.empty(), "Corrupted ViewObjectContactList (!)");
      81                 :            : 
      82                 :            :             // delete the EventHandler. This will destroy all still contained events.
      83         [ +  - ]:       3715 :             DeleteEventHandler();
      84         [ -  + ]:       3715 :         }
      85                 :            : 
      86                 :            :         // LazyInvalidate request. Default implementation directly handles
      87                 :            :         // this by calling back triggerLazyInvalidate() at the VOC
      88                 :          0 :         void ObjectContact::setLazyInvalidate(ViewObjectContact& rVOC)
      89                 :            :         {
      90                 :          0 :             rVOC.triggerLazyInvalidate();
      91                 :          0 :         }
      92                 :            : 
      93                 :            :         // call this to support evtl. preparations for repaint. Default does nothing
      94                 :          0 :         void ObjectContact::PrepareProcessDisplay()
      95                 :            :         {
      96                 :          0 :         }
      97                 :            : 
      98                 :            :         // A new ViewObjectContact was created and shall be remembered.
      99                 :      95044 :         void ObjectContact::AddViewObjectContact(ViewObjectContact& rVOContact)
     100                 :            :         {
     101         [ +  - ]:      95044 :             maViewObjectContactVector.push_back(&rVOContact);
     102                 :      95044 :         }
     103                 :            : 
     104                 :            :         // A ViewObjectContact was deleted and shall be forgotten.
     105                 :      93904 :         void ObjectContact::RemoveViewObjectContact(ViewObjectContact& rVOContact)
     106                 :            :         {
     107         [ +  - ]:      93904 :             std::vector< ViewObjectContact* >::iterator aFindResult = std::find(maViewObjectContactVector.begin(), maViewObjectContactVector.end(), &rVOContact);
     108                 :            : 
     109 [ +  - ][ +  + ]:      93904 :             if(aFindResult != maViewObjectContactVector.end())
     110                 :            :             {
     111         [ +  - ]:       2997 :                 maViewObjectContactVector.erase(aFindResult);
     112                 :            :             }
     113                 :      93904 :         }
     114                 :            : 
     115                 :            :         // Process the whole displaying
     116                 :          0 :         void ObjectContact::ProcessDisplay(DisplayInfo& /*rDisplayInfo*/)
     117                 :            :         {
     118                 :            :             // default does nothing
     119                 :          0 :         }
     120                 :            : 
     121                 :            :         // test if visualizing of entered groups is switched on at all
     122                 :       2793 :         bool ObjectContact::DoVisualizeEnteredGroup() const
     123                 :            :         {
     124                 :            :             // Don not do that as default
     125                 :       2793 :             return false;
     126                 :            :         }
     127                 :            : 
     128                 :            :         // get active group's (the entered group) ViewContact
     129                 :          0 :         const ViewContact* ObjectContact::getActiveViewContact() const
     130                 :            :         {
     131                 :            :             // default has no active VC
     132                 :          0 :             return 0;
     133                 :            :         }
     134                 :            : 
     135                 :            :         // Invalidate given rectangle at the window/output which is represented by
     136                 :            :         // this ObjectContact.
     137                 :      41770 :         void ObjectContact::InvalidatePartOfView(const basegfx::B2DRange& /*rRange*/) const
     138                 :            :         {
     139                 :            :             // nothing to do here in the default version
     140                 :      41770 :         }
     141                 :            : 
     142                 :            :         // Get info if given Rectangle is visible in this view
     143                 :          0 :         bool ObjectContact::IsAreaVisible(const basegfx::B2DRange& /*rRange*/) const
     144                 :            :         {
     145                 :            :             // always visible in default version
     146                 :          0 :             return true;
     147                 :            :         }
     148                 :            : 
     149                 :            :         // Get info about the need to visualize GluePoints
     150                 :       2793 :         bool ObjectContact::AreGluePointsVisible() const
     151                 :            :         {
     152                 :       2793 :             return false;
     153                 :            :         }
     154                 :            : 
     155                 :            :         // method to create a EventHandler. Needs to give a result.
     156                 :          0 :         sdr::event::TimerEventHandler* ObjectContact::CreateEventHandler()
     157                 :            :         {
     158                 :            :             // Create and return a new EventHandler
     159         [ #  # ]:          0 :             return new sdr::event::TimerEventHandler();
     160                 :            :         }
     161                 :            : 
     162                 :            :         // method to get the primitiveAnimator
     163                 :      45734 :         sdr::animation::primitiveAnimator& ObjectContact::getPrimitiveAnimator()
     164                 :            :         {
     165                 :      45734 :             return maPrimitiveAnimator;
     166                 :            :         }
     167                 :            : 
     168                 :            :         // method to get the EventHandler. It will
     169                 :            :         // return a existing one or create a new one using CreateEventHandler().
     170                 :          0 :         sdr::event::TimerEventHandler& ObjectContact::GetEventHandler() const
     171                 :            :         {
     172         [ #  # ]:          0 :             if(!HasEventHandler())
     173                 :            :             {
     174                 :          0 :                 const_cast< ObjectContact* >(this)->mpEventHandler = const_cast< ObjectContact* >(this)->CreateEventHandler();
     175                 :            :                 DBG_ASSERT(mpEventHandler, "ObjectContact::GetEventHandler(): Got no EventHandler (!)");
     176                 :            :             }
     177                 :            : 
     178                 :          0 :             return *mpEventHandler;
     179                 :            :         }
     180                 :            : 
     181                 :            :         // delete the EventHandler
     182                 :       3715 :         void ObjectContact::DeleteEventHandler()
     183                 :            :         {
     184         [ -  + ]:       3715 :             if(mpEventHandler)
     185                 :            :             {
     186                 :            :                 // If there are still Events registered, something has went wrong
     187         [ #  # ]:          0 :                 delete mpEventHandler;
     188                 :          0 :                 mpEventHandler = 0L;
     189                 :            :             }
     190                 :       3715 :         }
     191                 :            : 
     192                 :            :         // test if there is an EventHandler without creating one on demand
     193                 :      45734 :         bool ObjectContact::HasEventHandler() const
     194                 :            :         {
     195                 :      45734 :             return (0L != mpEventHandler);
     196                 :            :         }
     197                 :            : 
     198                 :            :         // check if text animation is allowed. Default is sal_true.
     199                 :       2796 :         bool ObjectContact::IsTextAnimationAllowed() const
     200                 :            :         {
     201                 :       2796 :             return true;
     202                 :            :         }
     203                 :            : 
     204                 :            :         // check if graphic animation is allowed. Default is sal_true.
     205                 :       2796 :         bool ObjectContact::IsGraphicAnimationAllowed() const
     206                 :            :         {
     207                 :       2796 :             return true;
     208                 :            :         }
     209                 :            : 
     210                 :            :         // check if asynchronious graphis loading is allowed. Default is false.
     211                 :          0 :         bool ObjectContact::IsAsynchronGraphicsLoadingAllowed() const
     212                 :            :         {
     213                 :          0 :             return false;
     214                 :            :         }
     215                 :            : 
     216                 :            :         // access to ViewObjectContactRedirector
     217                 :      75046 :         ViewObjectContactRedirector* ObjectContact::GetViewObjectContactRedirector() const
     218                 :            :         {
     219                 :      75046 :             return mpViewObjectContactRedirector;
     220                 :            :         }
     221                 :            : 
     222                 :      91468 :         void ObjectContact::SetViewObjectContactRedirector(ViewObjectContactRedirector* pNew)
     223                 :            :         {
     224         [ +  + ]:      91468 :             if(mpViewObjectContactRedirector != pNew)
     225                 :            :             {
     226                 :      52192 :                 mpViewObjectContactRedirector = pNew;
     227                 :            :             }
     228                 :      91468 :         }
     229                 :            : 
     230                 :            :         // check if buffering of MasterPages is allowed. Default is false.
     231                 :          0 :         bool ObjectContact::IsMasterPageBufferingAllowed() const
     232                 :            :         {
     233                 :          0 :             return false;
     234                 :            :         }
     235                 :            : 
     236                 :            :         // print? Default is false
     237                 :       5589 :         bool ObjectContact::isOutputToPrinter() const
     238                 :            :         {
     239                 :       5589 :             return false;
     240                 :            :         }
     241                 :            : 
     242                 :            :         // window? Default is true
     243                 :          0 :         bool ObjectContact::isOutputToWindow() const
     244                 :            :         {
     245                 :          0 :             return true;
     246                 :            :         }
     247                 :            : 
     248                 :            :         // VirtualDevice? Default is false
     249                 :          0 :         bool ObjectContact::isOutputToVirtualDevice() const
     250                 :            :         {
     251                 :          0 :             return false;
     252                 :            :         }
     253                 :            : 
     254                 :            :         // recording MetaFile? Default is false
     255                 :          0 :         bool ObjectContact::isOutputToRecordingMetaFile() const
     256                 :            :         {
     257                 :          0 :             return false;
     258                 :            :         }
     259                 :            : 
     260                 :            :         // pdf export? Default is false
     261                 :          0 :         bool ObjectContact::isOutputToPDFFile() const
     262                 :            :         {
     263                 :          0 :             return false;
     264                 :            :         }
     265                 :            : 
     266                 :            :         // gray display mode
     267                 :          0 :         bool ObjectContact::isDrawModeGray() const
     268                 :            :         {
     269                 :          0 :             return false;
     270                 :            :         }
     271                 :            : 
     272                 :            :         // gray display mode
     273                 :          0 :         bool ObjectContact::isDrawModeBlackWhite() const
     274                 :            :         {
     275                 :          0 :             return false;
     276                 :            :         }
     277                 :            : 
     278                 :            :         // high contrast display mode
     279                 :          0 :         bool ObjectContact::isDrawModeHighContrast() const
     280                 :            :         {
     281                 :          0 :             return false;
     282                 :            :         }
     283                 :            : 
     284                 :            :         // access to SdrPageView. Default implementation returns NULL
     285                 :       2796 :         SdrPageView* ObjectContact::TryToGetSdrPageView() const
     286                 :            :         {
     287                 :       2796 :             return 0;
     288                 :            :         }
     289                 :            : 
     290                 :            :         // access to OutputDevice. Default implementation returns NULL
     291                 :          0 :         OutputDevice* ObjectContact::TryToGetOutputDevice() const
     292                 :            :         {
     293                 :          0 :             return 0;
     294                 :            :         }
     295                 :            : 
     296                 :          0 :         void ObjectContact::resetViewPort()
     297                 :            :         {
     298                 :          0 :             const drawinglayer::geometry::ViewInformation2D& rCurrentVI2D = getViewInformation2D();
     299                 :            : 
     300         [ #  # ]:          0 :             if(!rCurrentVI2D.getViewport().isEmpty())
     301                 :            :             {
     302         [ #  # ]:          0 :                 const basegfx::B2DRange aEmptyRange;
     303                 :            : 
     304                 :            :                 drawinglayer::geometry::ViewInformation2D aNewVI2D(
     305         [ #  # ]:          0 :                     rCurrentVI2D.getObjectTransformation(),
     306         [ #  # ]:          0 :                     rCurrentVI2D.getViewTransformation(),
     307                 :            :                     aEmptyRange,
     308         [ #  # ]:          0 :                     rCurrentVI2D.getVisualizedPage(),
     309                 :            :                     rCurrentVI2D.getViewTime(),
     310 [ #  # ][ #  # ]:          0 :                     rCurrentVI2D.getExtendedInformationSequence());
                 [ #  # ]
     311                 :            : 
     312 [ #  # ][ #  # ]:          0 :                 updateViewInformation2D(aNewVI2D);
     313                 :            :             }
     314                 :          0 :         }
     315                 :            : 
     316                 :            :     } // end of namespace contact
     317                 :            : } // end of namespace sdr
     318                 :            : 
     319                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10