LCOV - code coverage report
Current view: top level - svx/source/svdraw - svdhlpln.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 20 60 33.3 %
Date: 2014-11-03 Functions: 5 9 55.6 %
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             : 
      21             : #include <svx/svdhlpln.hxx>
      22             : 
      23             : #include <vcl/outdev.hxx>
      24             : #include <vcl/window.hxx>
      25             : #include <tools/poly.hxx>
      26             : #include <vcl/lineinfo.hxx>
      27             : 
      28             : 
      29             : 
      30           0 : Pointer SdrHelpLine::GetPointer() const
      31             : {
      32           0 :     switch (eKind) {
      33           0 :         case SDRHELPLINE_VERTICAL  : return Pointer(POINTER_ESIZE);
      34           0 :         case SDRHELPLINE_HORIZONTAL: return Pointer(POINTER_SSIZE);
      35           0 :         default                    : return Pointer(POINTER_MOVE);
      36             :     } // switch
      37             : }
      38             : 
      39           0 : bool SdrHelpLine::IsHit(const Point& rPnt, sal_uInt16 nTolLog, const OutputDevice& rOut) const
      40             : {
      41           0 :     Size a1Pix(rOut.PixelToLogic(Size(1,1)));
      42           0 :     bool bXHit=rPnt.X()>=aPos.X()-nTolLog && rPnt.X()<=aPos.X()+nTolLog+a1Pix.Width();
      43           0 :     bool bYHit=rPnt.Y()>=aPos.Y()-nTolLog && rPnt.Y()<=aPos.Y()+nTolLog+a1Pix.Height();
      44           0 :     switch (eKind) {
      45           0 :         case SDRHELPLINE_VERTICAL  : return bXHit;
      46           0 :         case SDRHELPLINE_HORIZONTAL: return bYHit;
      47             :         case SDRHELPLINE_POINT: {
      48           0 :             if (bXHit || bYHit) {
      49           0 :                 Size aRad(rOut.PixelToLogic(Size(SDRHELPLINE_POINT_PIXELSIZE,SDRHELPLINE_POINT_PIXELSIZE)));
      50           0 :                 return rPnt.X()>=aPos.X()-aRad.Width() && rPnt.X()<=aPos.X()+aRad.Width()+a1Pix.Width() &&
      51           0 :                        rPnt.Y()>=aPos.Y()-aRad.Height() && rPnt.Y()<=aPos.Y()+aRad.Height()+a1Pix.Height();
      52             :             }
      53           0 :         } break;
      54             :     } // switch
      55           0 :     return false;
      56             : }
      57             : 
      58           0 : Rectangle SdrHelpLine::GetBoundRect(const OutputDevice& rOut) const
      59             : {
      60           0 :     Rectangle aRet(aPos,aPos);
      61           0 :     Point aOfs(rOut.GetMapMode().GetOrigin());
      62           0 :     Size aSiz(rOut.GetOutputSize());
      63           0 :     switch (eKind) {
      64           0 :         case SDRHELPLINE_VERTICAL  : aRet.Top()=-aOfs.Y(); aRet.Bottom()=-aOfs.Y()+aSiz.Height(); break;
      65           0 :         case SDRHELPLINE_HORIZONTAL: aRet.Left()=-aOfs.X(); aRet.Right()=-aOfs.X()+aSiz.Width();  break;
      66             :         case SDRHELPLINE_POINT     : {
      67           0 :             Size aRad(rOut.PixelToLogic(Size(SDRHELPLINE_POINT_PIXELSIZE,SDRHELPLINE_POINT_PIXELSIZE)));
      68           0 :             aRet.Left()  -=aRad.Width();
      69           0 :             aRet.Right() +=aRad.Width();
      70           0 :             aRet.Top()   -=aRad.Height();
      71           0 :             aRet.Bottom()+=aRad.Height();
      72           0 :         } break;
      73             :     } // switch
      74           0 :     return aRet;
      75             : }
      76             : 
      77       10725 : void SdrHelpLineList::Clear()
      78             : {
      79       10725 :     sal_uInt16 nAnz=GetCount();
      80       10761 :     for (sal_uInt16 i=0; i<nAnz; i++) {
      81          36 :         delete GetObject(i);
      82             :     }
      83       10725 :     aList.clear();
      84       10725 : }
      85             : 
      86        1560 : void SdrHelpLineList::operator=(const SdrHelpLineList& rSrcList)
      87             : {
      88        1560 :     Clear();
      89        1560 :     sal_uInt16 nAnz=rSrcList.GetCount();
      90        1578 :     for (sal_uInt16 i=0; i<nAnz; i++) {
      91          18 :         Insert(rSrcList[i]);
      92             :     }
      93        1560 : }
      94             : 
      95         550 : bool SdrHelpLineList::operator==(const SdrHelpLineList& rSrcList) const
      96             : {
      97         550 :     bool bEqual = false;
      98         550 :     sal_uInt16 nAnz=GetCount();
      99         550 :     if (nAnz==rSrcList.GetCount()) {
     100         550 :         bEqual = true;
     101         550 :         for (sal_uInt16 i=0; i<nAnz && bEqual; i++) {
     102           0 :             if (*GetObject(i)!=*rSrcList.GetObject(i)) {
     103           0 :                 bEqual = false;
     104             :             }
     105             :         }
     106             :     }
     107         550 :     return bEqual;
     108             : }
     109             : 
     110           0 : sal_uInt16 SdrHelpLineList::HitTest(const Point& rPnt, sal_uInt16 nTolLog, const OutputDevice& rOut) const
     111             : {
     112           0 :     sal_uInt16 nAnz=GetCount();
     113           0 :     for (sal_uInt16 i=nAnz; i>0;) {
     114           0 :         i--;
     115           0 :         if (GetObject(i)->IsHit(rPnt,nTolLog,rOut)) return i;
     116             :     }
     117           0 :     return SDRHELPLINE_NOTFOUND;
     118         651 : }
     119             : 
     120             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10