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-27 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           4 :         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          14 :             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          14 :                 mbEndCentered(bEndCentered)
      65             :             {
      66          14 :             }
      67             : 
      68             :             // data read access
      69           5 :             const basegfx::B2DPolyPolygon& getStartPolyPolygon() const { return maStartPolyPolygon; }
      70           5 :             const basegfx::B2DPolyPolygon& getEndPolyPolygon() const { return maEndPolyPolygon; }
      71           5 :             double getStartWidth() const { return mfStartWidth; }
      72           5 :             double getEndWidth() const { return mfEndWidth; }
      73           4 :             bool isStartActive() const { return mbStartActive; }
      74           4 :             bool isEndActive() const { return mbEndActive; }
      75           5 :             bool isStartCentered() const { return mbStartCentered; }
      76           5 :             bool isEndCentered() const { return mbEndCentered; }
      77             : 
      78           2 :             bool operator==(const ImpSdrLineStartEndAttribute& rCandidate) const
      79             :             {
      80           2 :                 return (getStartPolyPolygon() == rCandidate.getStartPolyPolygon()
      81           2 :                     && getEndPolyPolygon() == rCandidate.getEndPolyPolygon()
      82           2 :                     && getStartWidth() == rCandidate.getStartWidth()
      83           2 :                     && getEndWidth() == rCandidate.getEndWidth()
      84           2 :                     && isStartActive() == rCandidate.isStartActive()
      85           2 :                     && isEndActive() == rCandidate.isEndActive()
      86           2 :                     && isStartCentered() == rCandidate.isStartCentered()
      87          14 :                     && isEndCentered() == rCandidate.isEndCentered());
      88             :             }
      89             : 
      90         793 :             static ImpSdrLineStartEndAttribute* get_global_default()
      91             :             {
      92             :                 static ImpSdrLineStartEndAttribute* pDefault = 0;
      93             : 
      94         793 :                 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           9 :                         false);
     105             : 
     106             :                     // never delete; start with RefCount 1, not 0
     107           9 :                     pDefault->mnRefCount++;
     108             :                 }
     109             : 
     110         793 :                 return pDefault;
     111             :             }
     112             :         };
     113             : 
     114           5 :         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           5 :                 rStartPolyPolygon, rEndPolyPolygon, fStartWidth, fEndWidth, bStartActive, bEndActive, bStartCentered, bEndCentered))
     125             :         {
     126           5 :         }
     127             : 
     128         646 :         SdrLineStartEndAttribute::SdrLineStartEndAttribute()
     129         646 :         :   mpSdrLineStartEndAttribute(ImpSdrLineStartEndAttribute::get_global_default())
     130             :         {
     131         646 :             mpSdrLineStartEndAttribute->mnRefCount++;
     132         646 :         }
     133             : 
     134         559 :         SdrLineStartEndAttribute::SdrLineStartEndAttribute(const SdrLineStartEndAttribute& rCandidate)
     135         559 :         :   mpSdrLineStartEndAttribute(rCandidate.mpSdrLineStartEndAttribute)
     136             :         {
     137         559 :             mpSdrLineStartEndAttribute->mnRefCount++;
     138         559 :         }
     139             : 
     140        1187 :         SdrLineStartEndAttribute::~SdrLineStartEndAttribute()
     141             :         {
     142        1187 :             if(mpSdrLineStartEndAttribute->mnRefCount)
     143             :             {
     144        1183 :                 mpSdrLineStartEndAttribute->mnRefCount--;
     145             :             }
     146             :             else
     147             :             {
     148           4 :                 delete mpSdrLineStartEndAttribute;
     149             :             }
     150        1187 :         }
     151             : 
     152         147 :         bool SdrLineStartEndAttribute::isDefault() const
     153             :         {
     154         147 :             return mpSdrLineStartEndAttribute == ImpSdrLineStartEndAttribute::get_global_default();
     155             :         }
     156             : 
     157         141 :         SdrLineStartEndAttribute& SdrLineStartEndAttribute::operator=(const SdrLineStartEndAttribute& rCandidate)
     158             :         {
     159         141 :             if(rCandidate.mpSdrLineStartEndAttribute != mpSdrLineStartEndAttribute)
     160             :             {
     161           5 :                 if(mpSdrLineStartEndAttribute->mnRefCount)
     162             :                 {
     163           5 :                     mpSdrLineStartEndAttribute->mnRefCount--;
     164             :                 }
     165             :                 else
     166             :                 {
     167           0 :                     delete mpSdrLineStartEndAttribute;
     168             :                 }
     169             : 
     170           5 :                 mpSdrLineStartEndAttribute = rCandidate.mpSdrLineStartEndAttribute;
     171           5 :                 mpSdrLineStartEndAttribute->mnRefCount++;
     172             :             }
     173             : 
     174         141 :             return *this;
     175             :         }
     176             : 
     177          42 :         bool SdrLineStartEndAttribute::operator==(const SdrLineStartEndAttribute& rCandidate) const
     178             :         {
     179          42 :             if(rCandidate.mpSdrLineStartEndAttribute == mpSdrLineStartEndAttribute)
     180             :             {
     181          40 :                 return true;
     182             :             }
     183             : 
     184           2 :             if(rCandidate.isDefault() != isDefault())
     185             :             {
     186           0 :                 return false;
     187             :             }
     188             : 
     189           2 :             return (*rCandidate.mpSdrLineStartEndAttribute == *mpSdrLineStartEndAttribute);
     190             :         }
     191             : 
     192           1 :         const basegfx::B2DPolyPolygon& SdrLineStartEndAttribute::getStartPolyPolygon() const
     193             :         {
     194           1 :             return mpSdrLineStartEndAttribute->getStartPolyPolygon();
     195             :         }
     196             : 
     197           1 :         const basegfx::B2DPolyPolygon& SdrLineStartEndAttribute::getEndPolyPolygon() const
     198             :         {
     199           1 :             return mpSdrLineStartEndAttribute->getEndPolyPolygon();
     200             :         }
     201             : 
     202           1 :         double SdrLineStartEndAttribute::getStartWidth() const
     203             :         {
     204           1 :             return mpSdrLineStartEndAttribute->getStartWidth();
     205             :         }
     206             : 
     207           1 :         double SdrLineStartEndAttribute::getEndWidth() const
     208             :         {
     209           1 :             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           1 :         bool SdrLineStartEndAttribute::isStartCentered() const
     223             :         {
     224           1 :             return mpSdrLineStartEndAttribute->isStartCentered();
     225             :         }
     226             : 
     227           1 :         bool SdrLineStartEndAttribute::isEndCentered() const
     228             :         {
     229           1 :             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