LCOV - code coverage report
Current view: top level - libreoffice/drawinglayer/source/attribute - sdrlinestartendattribute.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 68 74 91.9 %
Date: 2012-12-17 Functions: 25 27 92.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             : #include <drawinglayer/attribute/sdrlinestartendattribute.hxx>
      21             : #include <basegfx/polygon/b2dpolypolygon.hxx>
      22             : 
      23             : //////////////////////////////////////////////////////////////////////////////
      24             : 
      25             : namespace drawinglayer
      26             : {
      27             :     namespace attribute
      28             :     {
      29           8 :         class ImpSdrLineStartEndAttribute
      30             :         {
      31             :         public:
      32             :             // refcounter
      33             :             sal_uInt32                              mnRefCount;
      34             : 
      35             :             // line arrow definitions
      36             :             basegfx::B2DPolyPolygon                 maStartPolyPolygon;     // start Line PolyPolygon
      37             :             basegfx::B2DPolyPolygon                 maEndPolyPolygon;       // end Line PolyPolygon
      38             :             double                                  mfStartWidth;           // 1/100th mm
      39             :             double                                  mfEndWidth;             // 1/100th mm
      40             : 
      41             :             // bitfield
      42             :             unsigned                                mbStartActive : 1L;     // start of Line is active
      43             :             unsigned                                mbEndActive : 1L;       // end of Line is active
      44             :             unsigned                                mbStartCentered : 1L;   // Line is centered on line start point
      45             :             unsigned                                mbEndCentered : 1L;     // Line is centered on line end point
      46             : 
      47          28 :             ImpSdrLineStartEndAttribute(
      48             :                 const basegfx::B2DPolyPolygon& rStartPolyPolygon,
      49             :                 const basegfx::B2DPolyPolygon& rEndPolyPolygon,
      50             :                 double fStartWidth,
      51             :                 double fEndWidth,
      52             :                 bool bStartActive,
      53             :                 bool bEndActive,
      54             :                 bool bStartCentered,
      55             :                 bool bEndCentered)
      56             :             :   mnRefCount(0),
      57             :                 maStartPolyPolygon(rStartPolyPolygon),
      58             :                 maEndPolyPolygon(rEndPolyPolygon),
      59             :                 mfStartWidth(fStartWidth),
      60             :                 mfEndWidth(fEndWidth),
      61             :                 mbStartActive(bStartActive),
      62             :                 mbEndActive(bEndActive),
      63             :                 mbStartCentered(bStartCentered),
      64          28 :                 mbEndCentered(bEndCentered)
      65             :             {
      66          28 :             }
      67             : 
      68             :             // data read access
      69          10 :             const basegfx::B2DPolyPolygon& getStartPolyPolygon() const { return maStartPolyPolygon; }
      70          10 :             const basegfx::B2DPolyPolygon& getEndPolyPolygon() const { return maEndPolyPolygon; }
      71          10 :             double getStartWidth() const { return mfStartWidth; }
      72          10 :             double getEndWidth() const { return mfEndWidth; }
      73           8 :             bool isStartActive() const { return mbStartActive; }
      74           8 :             bool isEndActive() const { return mbEndActive; }
      75          10 :             bool isStartCentered() const { return mbStartCentered; }
      76          10 :             bool isEndCentered() const { return mbEndCentered; }
      77             : 
      78           4 :             bool operator==(const ImpSdrLineStartEndAttribute& rCandidate) const
      79             :             {
      80           4 :                 return (getStartPolyPolygon() == rCandidate.getStartPolyPolygon()
      81           4 :                     && getEndPolyPolygon() == rCandidate.getEndPolyPolygon()
      82           4 :                     && getStartWidth() == rCandidate.getStartWidth()
      83           4 :                     && getEndWidth() == rCandidate.getEndWidth()
      84           4 :                     && isStartActive() == rCandidate.isStartActive()
      85           4 :                     && isEndActive() == rCandidate.isEndActive()
      86           4 :                     && isStartCentered() == rCandidate.isStartCentered()
      87          28 :                     && isEndCentered() == rCandidate.isEndCentered());
      88             :             }
      89             : 
      90        1502 :             static ImpSdrLineStartEndAttribute* get_global_default()
      91             :             {
      92             :                 static ImpSdrLineStartEndAttribute* pDefault = 0;
      93             : 
      94        1502 :                 if(!pDefault)
      95             :                 {
      96             :                     pDefault = new ImpSdrLineStartEndAttribute(
      97             :                         basegfx::B2DPolyPolygon(),
      98             :                         basegfx::B2DPolyPolygon(),
      99             :                         0.0,
     100             :                         0.0,
     101             :                         false,
     102             :                         false,
     103             :                         false,
     104          18 :                         false);
     105             : 
     106             :                     // never delete; start with RefCount 1, not 0
     107          18 :                     pDefault->mnRefCount++;
     108             :                 }
     109             : 
     110        1502 :                 return pDefault;
     111             :             }
     112             :         };
     113             : 
     114          10 :         SdrLineStartEndAttribute::SdrLineStartEndAttribute(
     115             :             const basegfx::B2DPolyPolygon& rStartPolyPolygon,
     116             :             const basegfx::B2DPolyPolygon& rEndPolyPolygon,
     117             :             double fStartWidth,
     118             :             double fEndWidth,
     119             :             bool bStartActive,
     120             :             bool bEndActive,
     121             :             bool bStartCentered,
     122             :             bool bEndCentered)
     123             :         :   mpSdrLineStartEndAttribute(new ImpSdrLineStartEndAttribute(
     124          10 :                 rStartPolyPolygon, rEndPolyPolygon, fStartWidth, fEndWidth, bStartActive, bEndActive, bStartCentered, bEndCentered))
     125             :         {
     126          10 :         }
     127             : 
     128        1224 :         SdrLineStartEndAttribute::SdrLineStartEndAttribute()
     129        1224 :         :   mpSdrLineStartEndAttribute(ImpSdrLineStartEndAttribute::get_global_default())
     130             :         {
     131        1224 :             mpSdrLineStartEndAttribute->mnRefCount++;
     132        1224 :         }
     133             : 
     134        1062 :         SdrLineStartEndAttribute::SdrLineStartEndAttribute(const SdrLineStartEndAttribute& rCandidate)
     135        1062 :         :   mpSdrLineStartEndAttribute(rCandidate.mpSdrLineStartEndAttribute)
     136             :         {
     137        1062 :             mpSdrLineStartEndAttribute->mnRefCount++;
     138        1062 :         }
     139             : 
     140        2256 :         SdrLineStartEndAttribute::~SdrLineStartEndAttribute()
     141             :         {
     142        2256 :             if(mpSdrLineStartEndAttribute->mnRefCount)
     143             :             {
     144        2248 :                 mpSdrLineStartEndAttribute->mnRefCount--;
     145             :             }
     146             :             else
     147             :             {
     148           8 :                 delete mpSdrLineStartEndAttribute;
     149             :             }
     150        2256 :         }
     151             : 
     152         278 :         bool SdrLineStartEndAttribute::isDefault() const
     153             :         {
     154         278 :             return mpSdrLineStartEndAttribute == ImpSdrLineStartEndAttribute::get_global_default();
     155             :         }
     156             : 
     157         274 :         SdrLineStartEndAttribute& SdrLineStartEndAttribute::operator=(const SdrLineStartEndAttribute& rCandidate)
     158             :         {
     159         274 :             if(rCandidate.mpSdrLineStartEndAttribute != mpSdrLineStartEndAttribute)
     160             :             {
     161          10 :                 if(mpSdrLineStartEndAttribute->mnRefCount)
     162             :                 {
     163          10 :                     mpSdrLineStartEndAttribute->mnRefCount--;
     164             :                 }
     165             :                 else
     166             :                 {
     167           0 :                     delete mpSdrLineStartEndAttribute;
     168             :                 }
     169             : 
     170          10 :                 mpSdrLineStartEndAttribute = rCandidate.mpSdrLineStartEndAttribute;
     171          10 :                 mpSdrLineStartEndAttribute->mnRefCount++;
     172             :             }
     173             : 
     174         274 :             return *this;
     175             :         }
     176             : 
     177          76 :         bool SdrLineStartEndAttribute::operator==(const SdrLineStartEndAttribute& rCandidate) const
     178             :         {
     179          76 :             if(rCandidate.mpSdrLineStartEndAttribute == mpSdrLineStartEndAttribute)
     180             :             {
     181          72 :                 return true;
     182             :             }
     183             : 
     184           4 :             if(rCandidate.isDefault() != isDefault())
     185             :             {
     186           0 :                 return false;
     187             :             }
     188             : 
     189           4 :             return (*rCandidate.mpSdrLineStartEndAttribute == *mpSdrLineStartEndAttribute);
     190             :         }
     191             : 
     192           2 :         const basegfx::B2DPolyPolygon& SdrLineStartEndAttribute::getStartPolyPolygon() const
     193             :         {
     194           2 :             return mpSdrLineStartEndAttribute->getStartPolyPolygon();
     195             :         }
     196             : 
     197           2 :         const basegfx::B2DPolyPolygon& SdrLineStartEndAttribute::getEndPolyPolygon() const
     198             :         {
     199           2 :             return mpSdrLineStartEndAttribute->getEndPolyPolygon();
     200             :         }
     201             : 
     202           2 :         double SdrLineStartEndAttribute::getStartWidth() const
     203             :         {
     204           2 :             return mpSdrLineStartEndAttribute->getStartWidth();
     205             :         }
     206             : 
     207           2 :         double SdrLineStartEndAttribute::getEndWidth() const
     208             :         {
     209           2 :             return mpSdrLineStartEndAttribute->getEndWidth();
     210             :         }
     211             : 
     212           0 :         bool SdrLineStartEndAttribute::isStartActive() const
     213             :         {
     214           0 :             return mpSdrLineStartEndAttribute->isStartActive();
     215             :         }
     216             : 
     217           0 :         bool SdrLineStartEndAttribute::isEndActive() const
     218             :         {
     219           0 :             return mpSdrLineStartEndAttribute->isEndActive();
     220             :         }
     221             : 
     222           2 :         bool SdrLineStartEndAttribute::isStartCentered() const
     223             :         {
     224           2 :             return mpSdrLineStartEndAttribute->isStartCentered();
     225             :         }
     226             : 
     227           2 :         bool SdrLineStartEndAttribute::isEndCentered() const
     228             :         {
     229           2 :             return mpSdrLineStartEndAttribute->isEndCentered();
     230             :         }
     231             :     } // end of namespace attribute
     232             : } // end of namespace drawinglayer
     233             : 
     234             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10