LCOV - code coverage report
Current view: top level - svx/source/sdr/overlay - overlayobjectlist.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 12 57 21.1 %
Date: 2012-08-25 Functions: 2 5 40.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 11 92 12.0 %

           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/overlay/overlayobjectlist.hxx>
      30                 :            : #include <svx/sdr/overlay/overlaymanager.hxx>
      31                 :            : #include <vcl/outdev.hxx>
      32                 :            : #include <basegfx/matrix/b2dhommatrix.hxx>
      33                 :            : 
      34                 :            : // for SOLARIS compiler include of algorithm part of _STL is necesary to
      35                 :            : // get access to basic algos like ::std::find
      36                 :            : #include <algorithm>
      37                 :            : 
      38                 :            : #include <drawinglayer/processor2d/hittestprocessor2d.hxx>
      39                 :            : 
      40                 :            : //////////////////////////////////////////////////////////////////////////////
      41                 :            : 
      42                 :            : namespace sdr
      43                 :            : {
      44                 :            :     namespace overlay
      45                 :            :     {
      46                 :      14863 :         OverlayObjectList::~OverlayObjectList()
      47                 :            :         {
      48         [ +  - ]:      14863 :             clear();
      49                 :      14863 :         }
      50                 :            : 
      51                 :      36152 :         void OverlayObjectList::clear()
      52                 :            :         {
      53                 :      36152 :             OverlayObjectVector::iterator aStart(maVector.begin());
      54                 :            : 
      55 [ +  - ][ +  - ]:      44912 :             for(; aStart != maVector.end(); ++aStart)
                 [ +  + ]
      56                 :            :             {
      57         [ +  - ]:       8760 :                 ::sdr::overlay::OverlayObject* pCandidate = *aStart;
      58                 :            : 
      59         [ +  + ]:       8760 :                 if(pCandidate->getOverlayManager())
      60                 :            :                 {
      61         [ +  - ]:       8306 :                     pCandidate->getOverlayManager()->remove(*pCandidate);
      62                 :            :                 }
      63                 :            : 
      64 [ +  - ][ +  - ]:       8760 :                 delete pCandidate;
      65                 :            :             }
      66                 :            : 
      67                 :      36152 :             maVector.clear();
      68                 :      36152 :         }
      69                 :            : 
      70                 :          0 :         bool OverlayObjectList::isHitLogic(const basegfx::B2DPoint& rLogicPosition, double fLogicTolerance) const
      71                 :            :         {
      72         [ #  # ]:          0 :             if(!maVector.empty())
      73                 :            :             {
      74                 :          0 :                 OverlayObjectVector::const_iterator aStart(maVector.begin());
      75         [ #  # ]:          0 :                 sdr::overlay::OverlayObject* pFirst = *aStart;
      76                 :            :                 OSL_ENSURE(pFirst, "Corrupt OverlayObjectList (!)");
      77                 :          0 :                 OverlayManager* pManager = pFirst->getOverlayManager();
      78                 :            : 
      79         [ #  # ]:          0 :                 if(pManager)
      80                 :            :                 {
      81         [ #  # ]:          0 :                     if(0.0 == fLogicTolerance)
      82                 :            :                     {
      83                 :          0 :                         const Size aSizeLogic(pManager->getOutputDevice().PixelToLogic(
      84         [ #  # ]:          0 :                             Size(DEFAULT_VALUE_FOR_HITTEST_PIXEL, DEFAULT_VALUE_FOR_HITTEST_PIXEL)));
      85                 :          0 :                         fLogicTolerance = aSizeLogic.Width();
      86                 :            :                     }
      87                 :            : 
      88         [ #  # ]:          0 :                     const drawinglayer::geometry::ViewInformation2D aViewInformation2D(pManager->getCurrentViewInformation2D());
      89                 :            :                     drawinglayer::processor2d::HitTestProcessor2D aHitTestProcessor2D(
      90                 :            :                         aViewInformation2D,
      91                 :            :                         rLogicPosition,
      92                 :            :                         fLogicTolerance,
      93         [ #  # ]:          0 :                         false);
      94                 :            : 
      95 [ #  # ][ #  # ]:          0 :                     for(; aStart != maVector.end(); ++aStart)
                 [ #  # ]
      96                 :            :                     {
      97         [ #  # ]:          0 :                         sdr::overlay::OverlayObject* pCandidate = *aStart;
      98                 :            :                         OSL_ENSURE(pCandidate, "Corrupt OverlayObjectList (!)");
      99                 :            : 
     100         [ #  # ]:          0 :                         if(pCandidate->isHittable())
     101                 :            :                         {
     102         [ #  # ]:          0 :                             const drawinglayer::primitive2d::Primitive2DSequence& rSequence = pCandidate->getOverlayObjectPrimitive2DSequence();
     103                 :            : 
     104         [ #  # ]:          0 :                             if(rSequence.hasElements())
     105                 :            :                             {
     106         [ #  # ]:          0 :                                 aHitTestProcessor2D.process(rSequence);
     107                 :            : 
     108         [ #  # ]:          0 :                                 if(aHitTestProcessor2D.getHit())
     109                 :            :                                 {
     110                 :          0 :                                     return true;
     111                 :            :                                 }
     112 [ #  # ][ #  # ]:          0 :                             }
     113                 :            :                         }
     114 [ #  # ][ #  # ]:          0 :                     }
         [ #  # ][ #  # ]
     115                 :            :                 }
     116                 :            :             }
     117                 :            : 
     118                 :          0 :             return false;
     119                 :            :         }
     120                 :            : 
     121                 :          0 :         bool OverlayObjectList::isHitPixel(const Point& rDiscretePosition, sal_uInt32 nDiscreteTolerance) const
     122                 :            :         {
     123         [ #  # ]:          0 :             if(!maVector.empty())
     124                 :            :             {
     125                 :          0 :                 OverlayObjectVector::const_iterator aStart(maVector.begin());
     126         [ #  # ]:          0 :                 sdr::overlay::OverlayObject* pCandidate = *aStart;
     127                 :          0 :                 OverlayManager* pManager = pCandidate->getOverlayManager();
     128                 :            : 
     129         [ #  # ]:          0 :                 if(pManager)
     130                 :            :                 {
     131         [ #  # ]:          0 :                     const Point aPosLogic(pManager->getOutputDevice().PixelToLogic(rDiscretePosition));
     132                 :          0 :                     const basegfx::B2DPoint aPosition(aPosLogic.X(), aPosLogic.Y());
     133                 :            : 
     134         [ #  # ]:          0 :                     if(nDiscreteTolerance)
     135                 :            :                     {
     136         [ #  # ]:          0 :                         const Size aSizeLogic(pManager->getOutputDevice().PixelToLogic(Size(nDiscreteTolerance, nDiscreteTolerance)));
     137         [ #  # ]:          0 :                         return isHitLogic(aPosition, (double)aSizeLogic.Width());
     138                 :            :                     }
     139                 :            :                     else
     140                 :            :                     {
     141         [ #  # ]:          0 :                         return isHitLogic(aPosition);
     142                 :          0 :                     }
     143                 :            :                 }
     144                 :            :             }
     145                 :            : 
     146                 :          0 :             return false;
     147                 :            :         }
     148                 :            : 
     149                 :          0 :         basegfx::B2DRange OverlayObjectList::getBaseRange() const
     150                 :            :         {
     151                 :          0 :             basegfx::B2DRange aRetval;
     152                 :            : 
     153         [ #  # ]:          0 :             if(!maVector.empty())
     154                 :            :             {
     155                 :          0 :                 OverlayObjectVector::const_iterator aStart(maVector.begin());
     156                 :            : 
     157 [ #  # ][ #  # ]:          0 :                 for(; aStart != maVector.end(); ++aStart)
                 [ #  # ]
     158                 :            :                 {
     159         [ #  # ]:          0 :                     ::sdr::overlay::OverlayObject* pCandidate = *aStart;
     160 [ #  # ][ #  # ]:          0 :                     aRetval.expand(pCandidate->getBaseRange());
     161                 :            :                 }
     162                 :            :             }
     163                 :            : 
     164                 :          0 :             return aRetval;
     165                 :            :         }
     166                 :            :     } // end of namespace overlay
     167                 :            : } // end of namespace sdr
     168                 :            : 
     169                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10