LCOV - code coverage report
Current view: top level - drawinglayer/source/attribute - fillhatchattribute.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 60 62 96.8 %
Date: 2012-08-25 Functions: 21 21 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 16 28 57.1 %

           Branch data     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/fillhatchattribute.hxx>
      21                 :            : #include <basegfx/color/bcolor.hxx>
      22                 :            : 
      23                 :            : //////////////////////////////////////////////////////////////////////////////
      24                 :            : 
      25                 :            : namespace drawinglayer
      26                 :            : {
      27                 :            :     namespace attribute
      28                 :            :     {
      29                 :       2868 :         class ImpFillHatchAttribute
      30                 :            :         {
      31                 :            :         public:
      32                 :            :             // refcounter
      33                 :            :             sal_uInt32                              mnRefCount;
      34                 :            : 
      35                 :            :             // data definitions
      36                 :            :             HatchStyle                              meStyle;
      37                 :            :             double                                  mfDistance;
      38                 :            :             double                                  mfAngle;
      39                 :            :             basegfx::BColor                         maColor;
      40                 :            : 
      41                 :            :             // bitfield
      42                 :            :             unsigned                                mbFillBackground : 1;
      43                 :            : 
      44                 :       2921 :             ImpFillHatchAttribute(
      45                 :            :                 HatchStyle eStyle,
      46                 :            :                 double fDistance,
      47                 :            :                 double fAngle,
      48                 :            :                 const basegfx::BColor& rColor,
      49                 :            :                 bool bFillBackground)
      50                 :            :             :   mnRefCount(0),
      51                 :            :                 meStyle(eStyle),
      52                 :            :                 mfDistance(fDistance),
      53                 :            :                 mfAngle(fAngle),
      54                 :            :                 maColor(rColor),
      55                 :       2921 :                 mbFillBackground(bFillBackground)
      56                 :            :             {
      57                 :       2921 :             }
      58                 :            : 
      59                 :            :             // data read access
      60                 :       3836 :             HatchStyle getStyle() const { return meStyle; }
      61                 :       3820 :             double getDistance() const { return mfDistance; }
      62                 :       3820 :             double getAngle() const { return mfAngle; }
      63                 :       3820 :             const basegfx::BColor& getColor() const { return maColor; }
      64                 :       3852 :             bool isFillBackground() const { return mbFillBackground; }
      65                 :            : 
      66                 :       1590 :             bool operator==(const ImpFillHatchAttribute& rCandidate) const
      67                 :            :             {
      68                 :       1590 :                 return (getStyle() == rCandidate.getStyle()
      69                 :       1590 :                     && getDistance() == rCandidate.getDistance()
      70                 :       1590 :                     && getAngle() == rCandidate.getAngle()
      71                 :       1590 :                     && getColor() == rCandidate.getColor()
      72 [ +  - ][ +  -  :       6360 :                     && isFillBackground()  == rCandidate.isFillBackground());
          +  -  +  -  +  
                      - ]
      73                 :            :             }
      74                 :            : 
      75                 :      75111 :             static ImpFillHatchAttribute* get_global_default()
      76                 :            :             {
      77                 :            :                 static ImpFillHatchAttribute* pDefault = 0;
      78                 :            : 
      79         [ +  + ]:      75111 :                 if(!pDefault)
      80                 :            :                 {
      81                 :            :                     pDefault = new ImpFillHatchAttribute(
      82                 :            :                         HATCHSTYLE_SINGLE,
      83                 :            :                         0.0, 0.0,
      84                 :            :                         basegfx::BColor(),
      85         [ +  - ]:         53 :                         false);
      86                 :            : 
      87                 :            :                     // never delete; start with RefCount 1, not 0
      88                 :         53 :                     pDefault->mnRefCount++;
      89                 :            :                 }
      90                 :            : 
      91                 :      75111 :                 return pDefault;
      92                 :            :             }
      93                 :            :         };
      94                 :            : 
      95                 :       2868 :         FillHatchAttribute::FillHatchAttribute(
      96                 :            :             HatchStyle eStyle,
      97                 :            :             double fDistance,
      98                 :            :             double fAngle,
      99                 :            :             const basegfx::BColor& rColor,
     100                 :            :             bool bFillBackground)
     101                 :            :         :   mpFillHatchAttribute(new ImpFillHatchAttribute(
     102                 :       2868 :                 eStyle, fDistance, fAngle, rColor, bFillBackground))
     103                 :            :         {
     104                 :       2868 :         }
     105                 :            : 
     106                 :      56349 :         FillHatchAttribute::FillHatchAttribute()
     107                 :      56349 :         :   mpFillHatchAttribute(ImpFillHatchAttribute::get_global_default())
     108                 :            :         {
     109                 :      56349 :             mpFillHatchAttribute->mnRefCount++;
     110                 :      56349 :         }
     111                 :            : 
     112                 :      58889 :         FillHatchAttribute::FillHatchAttribute(const FillHatchAttribute& rCandidate)
     113                 :      58889 :         :   mpFillHatchAttribute(rCandidate.mpFillHatchAttribute)
     114                 :            :         {
     115                 :      58889 :             mpFillHatchAttribute->mnRefCount++;
     116                 :      58889 :         }
     117                 :            : 
     118                 :     118053 :         FillHatchAttribute::~FillHatchAttribute()
     119                 :            :         {
     120         [ +  + ]:     118053 :             if(mpFillHatchAttribute->mnRefCount)
     121                 :            :             {
     122                 :     115185 :                 mpFillHatchAttribute->mnRefCount--;
     123                 :            :             }
     124                 :            :             else
     125                 :            :             {
     126         [ +  - ]:       2868 :                 delete mpFillHatchAttribute;
     127                 :            :             }
     128                 :     118053 :         }
     129                 :            : 
     130                 :      18762 :         bool FillHatchAttribute::isDefault() const
     131                 :            :         {
     132                 :      18762 :             return mpFillHatchAttribute == ImpFillHatchAttribute::get_global_default();
     133                 :            :         }
     134                 :            : 
     135                 :       2868 :         FillHatchAttribute& FillHatchAttribute::operator=(const FillHatchAttribute& rCandidate)
     136                 :            :         {
     137         [ +  - ]:       2868 :             if(rCandidate.mpFillHatchAttribute != mpFillHatchAttribute)
     138                 :            :             {
     139         [ +  - ]:       2868 :                 if(mpFillHatchAttribute->mnRefCount)
     140                 :            :                 {
     141                 :       2868 :                     mpFillHatchAttribute->mnRefCount--;
     142                 :            :                 }
     143                 :            :                 else
     144                 :            :                 {
     145         [ #  # ]:          0 :                     delete mpFillHatchAttribute;
     146                 :            :                 }
     147                 :            : 
     148                 :       2868 :                 mpFillHatchAttribute = rCandidate.mpFillHatchAttribute;
     149                 :       2868 :                 mpFillHatchAttribute->mnRefCount++;
     150                 :            :             }
     151                 :            : 
     152                 :       2868 :             return *this;
     153                 :            :         }
     154                 :            : 
     155                 :      33361 :         bool FillHatchAttribute::operator==(const FillHatchAttribute& rCandidate) const
     156                 :            :         {
     157         [ +  + ]:      33361 :             if(rCandidate.mpFillHatchAttribute == mpFillHatchAttribute)
     158                 :            :             {
     159                 :      31771 :                 return true;
     160                 :            :             }
     161                 :            : 
     162         [ -  + ]:       1590 :             if(rCandidate.isDefault() != isDefault())
     163                 :            :             {
     164                 :          0 :                 return false;
     165                 :            :             }
     166                 :            : 
     167                 :      33361 :             return (*rCandidate.mpFillHatchAttribute == *mpFillHatchAttribute);
     168                 :            :         }
     169                 :            : 
     170                 :            :         // data read access
     171                 :        656 :         HatchStyle FillHatchAttribute::getStyle() const
     172                 :            :         {
     173                 :        656 :             return mpFillHatchAttribute->getStyle();
     174                 :            :         }
     175                 :            : 
     176                 :        640 :         double FillHatchAttribute::getDistance() const
     177                 :            :         {
     178                 :        640 :             return mpFillHatchAttribute->getDistance();
     179                 :            :         }
     180                 :            : 
     181                 :        640 :         double FillHatchAttribute::getAngle() const
     182                 :            :         {
     183                 :        640 :             return mpFillHatchAttribute->getAngle();
     184                 :            :         }
     185                 :            : 
     186                 :        640 :         const basegfx::BColor& FillHatchAttribute::getColor() const
     187                 :            :         {
     188                 :        640 :             return mpFillHatchAttribute->getColor();
     189                 :            :         }
     190                 :            : 
     191                 :        672 :         bool FillHatchAttribute::isFillBackground() const
     192                 :            :         {
     193                 :        672 :             return mpFillHatchAttribute->isFillBackground();
     194                 :            :         }
     195                 :            : 
     196                 :            :     } // end of namespace attribute
     197                 :            : } // end of namespace drawinglayer
     198                 :            : 
     199                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10