LCOV - code coverage report
Current view: top level - drawinglayer/source/attribute - lineattribute.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 44 54 81.5 %
Date: 2012-08-25 Functions: 16 17 94.1 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 11 24 45.8 %

           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 <drawinglayer/attribute/lineattribute.hxx>
      30                 :            : #include <basegfx/color/bcolor.hxx>
      31                 :            : 
      32                 :            : //////////////////////////////////////////////////////////////////////////////
      33                 :            : 
      34                 :            : namespace drawinglayer
      35                 :            : {
      36                 :            :     namespace attribute
      37                 :            :     {
      38                 :      30416 :         class ImpLineAttribute
      39                 :            :         {
      40                 :            :         public:
      41                 :            :             // refcounter
      42                 :            :             sal_uInt32                              mnRefCount;
      43                 :            : 
      44                 :            :             // data definitions
      45                 :            :             basegfx::BColor                         maColor;                // color
      46                 :            :             double                                  mfWidth;                // absolute line width
      47                 :            :             basegfx::B2DLineJoin                    meLineJoin;             // type of LineJoin
      48                 :            : 
      49                 :      30489 :             ImpLineAttribute(
      50                 :            :                 const basegfx::BColor& rColor,
      51                 :            :                 double fWidth,
      52                 :            :                 basegfx::B2DLineJoin aB2DLineJoin)
      53                 :            :             :   mnRefCount(0),
      54                 :            :                 maColor(rColor),
      55                 :            :                 mfWidth(fWidth),
      56                 :      30489 :                 meLineJoin(aB2DLineJoin)
      57                 :            :             {
      58                 :      30489 :             }
      59                 :            : 
      60                 :            :             // data read access
      61                 :      42555 :             const basegfx::BColor& getColor() const { return maColor; }
      62                 :     477392 :             double getWidth() const { return mfWidth; }
      63                 :      79282 :             basegfx::B2DLineJoin getLineJoin() const { return meLineJoin; }
      64                 :            : 
      65                 :        108 :             bool operator==(const ImpLineAttribute& rCandidate) const
      66                 :            :             {
      67                 :        108 :                 return (getColor() == rCandidate.getColor()
      68                 :        108 :                     && getWidth() == rCandidate.getWidth()
      69         [ +  - ]:        216 :                     && getLineJoin() == rCandidate.getLineJoin());
           [ +  -  +  - ]
      70                 :            :             }
      71                 :            : 
      72                 :      21027 :             static ImpLineAttribute* get_global_default()
      73                 :            :             {
      74                 :            :                 static ImpLineAttribute* pDefault = 0;
      75                 :            : 
      76         [ +  + ]:      21027 :                 if(!pDefault)
      77                 :            :                 {
      78                 :            :                     pDefault = new ImpLineAttribute(
      79                 :            :                         basegfx::BColor(),
      80                 :            :                         0.0,
      81         [ +  - ]:         63 :                         basegfx::B2DLINEJOIN_ROUND);
      82                 :            : 
      83                 :            :                     // never delete; start with RefCount 1, not 0
      84                 :         63 :                     pDefault->mnRefCount++;
      85                 :            :                 }
      86                 :            : 
      87                 :      21027 :                 return pDefault;
      88                 :            :             }
      89                 :            :         };
      90                 :            : 
      91                 :      30426 :         LineAttribute::LineAttribute(
      92                 :            :             const basegfx::BColor& rColor,
      93                 :            :             double fWidth,
      94                 :            :             basegfx::B2DLineJoin aB2DLineJoin)
      95                 :            :         :   mpLineAttribute(new ImpLineAttribute(
      96                 :      30426 :                 rColor, fWidth, aB2DLineJoin))
      97                 :            :         {
      98                 :      30426 :         }
      99                 :            : 
     100                 :         63 :         LineAttribute::LineAttribute()
     101                 :         63 :         :   mpLineAttribute(ImpLineAttribute::get_global_default())
     102                 :            :         {
     103                 :         63 :             mpLineAttribute->mnRefCount++;
     104                 :         63 :         }
     105                 :            : 
     106                 :      30529 :         LineAttribute::LineAttribute(const LineAttribute& rCandidate)
     107                 :      30529 :         :   mpLineAttribute(rCandidate.mpLineAttribute)
     108                 :            :         {
     109                 :      30529 :             mpLineAttribute->mnRefCount++;
     110                 :      30529 :         }
     111                 :            : 
     112                 :      60945 :         LineAttribute::~LineAttribute()
     113                 :            :         {
     114         [ +  + ]:      60945 :             if(mpLineAttribute->mnRefCount)
     115                 :            :             {
     116                 :      30529 :                 mpLineAttribute->mnRefCount--;
     117                 :            :             }
     118                 :            :             else
     119                 :            :             {
     120         [ +  - ]:      30416 :                 delete mpLineAttribute;
     121                 :            :             }
     122                 :      60945 :         }
     123                 :            : 
     124                 :      20964 :         bool LineAttribute::isDefault() const
     125                 :            :         {
     126                 :      20964 :             return mpLineAttribute == ImpLineAttribute::get_global_default();
     127                 :            :         }
     128                 :            : 
     129                 :          0 :         LineAttribute& LineAttribute::operator=(const LineAttribute& rCandidate)
     130                 :            :         {
     131         [ #  # ]:          0 :             if(rCandidate.mpLineAttribute != mpLineAttribute)
     132                 :            :             {
     133         [ #  # ]:          0 :                 if(mpLineAttribute->mnRefCount)
     134                 :            :                 {
     135                 :          0 :                     mpLineAttribute->mnRefCount--;
     136                 :            :                 }
     137                 :            :                 else
     138                 :            :                 {
     139         [ #  # ]:          0 :                     delete mpLineAttribute;
     140                 :            :                 }
     141                 :            : 
     142                 :          0 :                 mpLineAttribute = rCandidate.mpLineAttribute;
     143                 :          0 :                 mpLineAttribute->mnRefCount++;
     144                 :            :             }
     145                 :            : 
     146                 :          0 :             return *this;
     147                 :            :         }
     148                 :            : 
     149                 :        108 :         bool LineAttribute::operator==(const LineAttribute& rCandidate) const
     150                 :            :         {
     151         [ -  + ]:        108 :             if(rCandidate.mpLineAttribute == mpLineAttribute)
     152                 :            :             {
     153                 :          0 :                 return true;
     154                 :            :             }
     155                 :            : 
     156         [ -  + ]:        108 :             if(rCandidate.isDefault() != isDefault())
     157                 :            :             {
     158                 :          0 :                 return false;
     159                 :            :             }
     160                 :            : 
     161                 :        108 :             return (*rCandidate.mpLineAttribute == *mpLineAttribute);
     162                 :            :         }
     163                 :            : 
     164                 :      42339 :         const basegfx::BColor& LineAttribute::getColor() const
     165                 :            :         {
     166                 :      42339 :             return mpLineAttribute->getColor();
     167                 :            :         }
     168                 :            : 
     169                 :     477176 :         double LineAttribute::getWidth() const
     170                 :            :         {
     171                 :     477176 :             return mpLineAttribute->getWidth();
     172                 :            :         }
     173                 :            : 
     174                 :      79066 :         basegfx::B2DLineJoin LineAttribute::getLineJoin() const
     175                 :            :         {
     176                 :      79066 :             return mpLineAttribute->getLineJoin();
     177                 :            :         }
     178                 :            : 
     179                 :            :     } // end of namespace attribute
     180                 :            : } // end of namespace drawinglayer
     181                 :            : 
     182                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10