LCOV - code coverage report
Current view: top level - drawinglayer/source/attribute - sdrlineattribute.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 63 65 96.9 %
Date: 2012-08-25 Functions: 23 23 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 21 36 58.3 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  *  OpenOffice.org - a multi-platform office productivity suite
       5                 :            :  *
       6                 :            :  *  The Contents of this file are made available subject to
       7                 :            :  *  the terms of GNU Lesser General Public License Version 2.1.
       8                 :            :  *
       9                 :            :  *
      10                 :            :  *    GNU Lesser General Public License Version 2.1
      11                 :            :  *    =============================================
      12                 :            :  *    Copyright 2005 by Sun Microsystems, Inc.
      13                 :            :  *    901 San Antonio Road, Palo Alto, CA 94303, USA
      14                 :            :  *
      15                 :            :  *    This library is free software; you can redistribute it and/or
      16                 :            :  *    modify it under the terms of the GNU Lesser General Public
      17                 :            :  *    License version 2.1, as published by the Free Software Foundation.
      18                 :            :  *
      19                 :            :  *    This library is distributed in the hope that it will be useful,
      20                 :            :  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
      21                 :            :  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      22                 :            :  *    Lesser General Public License for more details.
      23                 :            :  *
      24                 :            :  *    You should have received a copy of the GNU Lesser General Public
      25                 :            :  *    License along with this library; if not, write to the Free Software
      26                 :            :  *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
      27                 :            :  *    MA  02111-1307  USA
      28                 :            :  *
      29                 :            :  ************************************************************************/
      30                 :            : 
      31                 :            : #include <drawinglayer/attribute/sdrlineattribute.hxx>
      32                 :            : #include <basegfx/color/bcolor.hxx>
      33                 :            : 
      34                 :            : //////////////////////////////////////////////////////////////////////////////
      35                 :            : 
      36                 :            : namespace drawinglayer
      37                 :            : {
      38                 :            :     namespace attribute
      39                 :            :     {
      40                 :      23883 :         class ImpSdrLineAttribute
      41                 :            :         {
      42                 :            :         public:
      43                 :            :             // refcounter
      44                 :            :             sal_uInt32                              mnRefCount;
      45                 :            : 
      46                 :            :             // line definitions
      47                 :            :             basegfx::B2DLineJoin                    meJoin;             // B2DLINEJOIN_* defines
      48                 :            :             double                                  mfWidth;            // 1/100th mm, 0.0==hair
      49                 :            :             double                                  mfTransparence;     // [0.0 .. 1.0], 0.0==no transp.
      50                 :            :             basegfx::BColor                         maColor;            // color of line
      51                 :            :             ::std::vector< double >                 maDotDashArray;     // array of double which defines the dot-dash pattern
      52                 :            :             double                                  mfFullDotDashLen;   // sum of maDotDashArray (for convenience)
      53                 :            : 
      54                 :      23936 :             ImpSdrLineAttribute(
      55                 :            :                 basegfx::B2DLineJoin eJoin,
      56                 :            :                 double fWidth,
      57                 :            :                 double fTransparence,
      58                 :            :                 const basegfx::BColor& rColor,
      59                 :            :                 const ::std::vector< double >& rDotDashArray,
      60                 :            :                 double fFullDotDashLen)
      61                 :            :             :   mnRefCount(0),
      62                 :            :                 meJoin(eJoin),
      63                 :            :                 mfWidth(fWidth),
      64                 :            :                 mfTransparence(fTransparence),
      65                 :            :                 maColor(rColor),
      66                 :            :                 maDotDashArray(rDotDashArray),
      67         [ +  - ]:      23936 :                 mfFullDotDashLen(fFullDotDashLen)
      68                 :            :             {
      69                 :      23936 :             }
      70                 :            : 
      71                 :            :             explicit ImpSdrLineAttribute(const basegfx::BColor& rColor)
      72                 :            :             :   mnRefCount(0),
      73                 :            :                 meJoin(basegfx::B2DLINEJOIN_NONE),
      74                 :            :                 mfWidth(0.0),
      75                 :            :                 mfTransparence(0.0),
      76                 :            :                 maColor(rColor),
      77                 :            :                 maDotDashArray(),
      78                 :            :                 mfFullDotDashLen(0.0)
      79                 :            :             {
      80                 :            :             }
      81                 :            : 
      82                 :            :             // data read access
      83                 :      51815 :             basegfx::B2DLineJoin getJoin() const { return meJoin; }
      84                 :      80043 :             double getWidth() const { return mfWidth; }
      85                 :      51830 :             double getTransparence() const { return mfTransparence; }
      86                 :      51815 :             const basegfx::BColor& getColor() const { return maColor; }
      87                 :      51815 :             const ::std::vector< double >& getDotDashArray() const { return maDotDashArray; }
      88                 :      24467 :             double getFullDotDashLen() const { return mfFullDotDashLen; }
      89                 :            : 
      90                 :      13674 :             bool operator==(const ImpSdrLineAttribute& rCandidate) const
      91                 :            :             {
      92                 :      13674 :                 return (getJoin() == rCandidate.getJoin()
      93                 :      13674 :                     && getWidth() == rCandidate.getWidth()
      94                 :      13674 :                     && getTransparence() == rCandidate.getTransparence()
      95                 :      13674 :                     && getColor() == rCandidate.getColor()
      96 [ +  - ][ +  -  :      54696 :                     && getDotDashArray() == rCandidate.getDotDashArray());
          +  -  +  -  +  
                      - ]
      97                 :            :             }
      98                 :            : 
      99                 :     446936 :             static ImpSdrLineAttribute* get_global_default()
     100                 :            :             {
     101                 :            :                 static ImpSdrLineAttribute* pDefault = 0;
     102                 :            : 
     103         [ +  + ]:     446936 :                 if(!pDefault)
     104                 :            :                 {
     105                 :            :                     pDefault = new ImpSdrLineAttribute(
     106                 :            :                         basegfx::B2DLINEJOIN_ROUND,
     107                 :            :                         0.0,
     108                 :            :                         0.0,
     109                 :            :                         basegfx::BColor(),
     110                 :            :                         std::vector< double >(),
     111 [ +  - ][ +  - ]:         53 :                         0.0);
                 [ +  - ]
     112                 :            : 
     113                 :            :                     // never delete; start with RefCount 1, not 0
     114                 :         53 :                     pDefault->mnRefCount++;
     115                 :            :                 }
     116                 :            : 
     117                 :     446936 :                 return pDefault;
     118                 :            :             }
     119                 :            :         };
     120                 :            : 
     121                 :      23883 :         SdrLineAttribute::SdrLineAttribute(
     122                 :            :             basegfx::B2DLineJoin eJoin,
     123                 :            :             double fWidth,
     124                 :            :             double fTransparence,
     125                 :            :             const basegfx::BColor& rColor,
     126                 :            :             const ::std::vector< double >& rDotDashArray,
     127                 :            :             double fFullDotDashLen)
     128                 :            :         :   mpSdrLineAttribute(new ImpSdrLineAttribute(
     129         [ +  - ]:      23883 :                 eJoin, fWidth, fTransparence, rColor, rDotDashArray, fFullDotDashLen))
     130                 :            :         {
     131                 :      23883 :         }
     132                 :            : 
     133                 :     167856 :         SdrLineAttribute::SdrLineAttribute()
     134                 :     167856 :         :   mpSdrLineAttribute(ImpSdrLineAttribute::get_global_default())
     135                 :            :         {
     136                 :     167856 :             mpSdrLineAttribute->mnRefCount++;
     137                 :     167856 :         }
     138                 :            : 
     139                 :     183608 :         SdrLineAttribute::SdrLineAttribute(const SdrLineAttribute& rCandidate)
     140                 :     183608 :         :   mpSdrLineAttribute(rCandidate.mpSdrLineAttribute)
     141                 :            :         {
     142                 :     183608 :             mpSdrLineAttribute->mnRefCount++;
     143                 :     183608 :         }
     144                 :            : 
     145                 :     375347 :         SdrLineAttribute::~SdrLineAttribute()
     146                 :            :         {
     147         [ +  + ]:     375347 :             if(mpSdrLineAttribute->mnRefCount)
     148                 :            :             {
     149                 :     351464 :                 mpSdrLineAttribute->mnRefCount--;
     150                 :            :             }
     151                 :            :             else
     152                 :            :             {
     153         [ +  - ]:      23883 :                 delete mpSdrLineAttribute;
     154                 :            :             }
     155                 :     375347 :         }
     156                 :            : 
     157                 :     279080 :         bool SdrLineAttribute::isDefault() const
     158                 :            :         {
     159                 :     279080 :             return mpSdrLineAttribute == ImpSdrLineAttribute::get_global_default();
     160                 :            :         }
     161                 :            : 
     162                 :      83786 :         SdrLineAttribute& SdrLineAttribute::operator=(const SdrLineAttribute& rCandidate)
     163                 :            :         {
     164         [ +  + ]:      83786 :             if(rCandidate.mpSdrLineAttribute != mpSdrLineAttribute)
     165                 :            :             {
     166         [ +  - ]:      18703 :                 if(mpSdrLineAttribute->mnRefCount)
     167                 :            :                 {
     168                 :      18703 :                     mpSdrLineAttribute->mnRefCount--;
     169                 :            :                 }
     170                 :            :                 else
     171                 :            :                 {
     172         [ #  # ]:          0 :                     delete mpSdrLineAttribute;
     173                 :            :                 }
     174                 :            : 
     175                 :      18703 :                 mpSdrLineAttribute = rCandidate.mpSdrLineAttribute;
     176                 :      18703 :                 mpSdrLineAttribute->mnRefCount++;
     177                 :            :             }
     178                 :            : 
     179                 :      83786 :             return *this;
     180                 :            :         }
     181                 :            : 
     182                 :      64304 :         bool SdrLineAttribute::operator==(const SdrLineAttribute& rCandidate) const
     183                 :            :         {
     184         [ +  + ]:      64304 :             if(rCandidate.mpSdrLineAttribute == mpSdrLineAttribute)
     185                 :            :             {
     186                 :      50630 :                 return true;
     187                 :            :             }
     188                 :            : 
     189         [ -  + ]:      13674 :             if(rCandidate.isDefault() != isDefault())
     190                 :            :             {
     191                 :          0 :                 return false;
     192                 :            :             }
     193                 :            : 
     194                 :      64304 :             return (*rCandidate.mpSdrLineAttribute == *mpSdrLineAttribute);
     195                 :            :         }
     196                 :            : 
     197                 :      24467 :         basegfx::B2DLineJoin SdrLineAttribute::getJoin() const
     198                 :            :         {
     199                 :      24467 :             return mpSdrLineAttribute->getJoin();
     200                 :            :         }
     201                 :            : 
     202                 :      52695 :         double SdrLineAttribute::getWidth() const
     203                 :            :         {
     204                 :      52695 :             return mpSdrLineAttribute->getWidth();
     205                 :            :         }
     206                 :            : 
     207                 :      24482 :         double SdrLineAttribute::getTransparence() const
     208                 :            :         {
     209                 :      24482 :             return mpSdrLineAttribute->getTransparence();
     210                 :            :         }
     211                 :            : 
     212                 :      24467 :         const basegfx::BColor& SdrLineAttribute::getColor() const
     213                 :            :         {
     214                 :      24467 :             return mpSdrLineAttribute->getColor();
     215                 :            :         }
     216                 :            : 
     217                 :      24467 :         const ::std::vector< double >& SdrLineAttribute::getDotDashArray() const
     218                 :            :         {
     219                 :      24467 :             return mpSdrLineAttribute->getDotDashArray();
     220                 :            :         }
     221                 :            : 
     222                 :      24467 :         double SdrLineAttribute::getFullDotDashLen() const
     223                 :            :         {
     224                 :      24467 :             return mpSdrLineAttribute->getFullDotDashLen();
     225                 :            :         }
     226                 :            : 
     227                 :            :     } // end of namespace attribute
     228                 :            : } // end of namespace drawinglayer
     229                 :            : 
     230                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10