LCOV - code coverage report
Current view: top level - drawinglayer/source/attribute - fillgradientattribute.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 72 74 97.3 %
Date: 2012-08-25 Functions: 27 27 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 20 34 58.8 %

           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/fillgradientattribute.hxx>
      21                 :            : #include <basegfx/color/bcolor.hxx>
      22                 :            : 
      23                 :            : //////////////////////////////////////////////////////////////////////////////
      24                 :            : 
      25                 :            : namespace drawinglayer
      26                 :            : {
      27                 :            :     namespace attribute
      28                 :            :     {
      29                 :       6360 :         class ImpFillGradientAttribute
      30                 :            :         {
      31                 :            :         public:
      32                 :            :             // refcounter
      33                 :            :             sal_uInt32                              mnRefCount;
      34                 :            : 
      35                 :            :             // data definitions
      36                 :            :             GradientStyle                           meStyle;
      37                 :            :             double                                  mfBorder;
      38                 :            :             double                                  mfOffsetX;
      39                 :            :             double                                  mfOffsetY;
      40                 :            :             double                                  mfAngle;
      41                 :            :             basegfx::BColor                         maStartColor;
      42                 :            :             basegfx::BColor                         maEndColor;
      43                 :            :             sal_uInt16                              mnSteps;
      44                 :            : 
      45                 :       6423 :             ImpFillGradientAttribute(
      46                 :            :                 GradientStyle eStyle,
      47                 :            :                 double fBorder,
      48                 :            :                 double fOffsetX,
      49                 :            :                 double fOffsetY,
      50                 :            :                 double fAngle,
      51                 :            :                 const basegfx::BColor& rStartColor,
      52                 :            :                 const basegfx::BColor& rEndColor,
      53                 :            :                 sal_uInt16 nSteps)
      54                 :            :             :   mnRefCount(0),
      55                 :            :                 meStyle(eStyle),
      56                 :            :                 mfBorder(fBorder),
      57                 :            :                 mfOffsetX(fOffsetX),
      58                 :            :                 mfOffsetY(fOffsetY),
      59                 :            :                 mfAngle(fAngle),
      60                 :            :                 maStartColor(rStartColor),
      61                 :            :                 maEndColor(rEndColor),
      62                 :       6423 :                 mnSteps(nSteps)
      63                 :            :             {
      64                 :       6423 :             }
      65                 :            : 
      66                 :            :             // data read access
      67                 :      12445 :             GradientStyle getStyle() const { return meStyle; }
      68                 :       8443 :             double getBorder() const { return mfBorder; }
      69                 :       7093 :             double getOffsetX() const { return mfOffsetX; }
      70                 :       7093 :             double getOffsetY() const { return mfOffsetY; }
      71                 :       8443 :             double getAngle() const { return mfAngle; }
      72                 :       8443 :             const basegfx::BColor& getStartColor() const { return maStartColor; }
      73                 :       8443 :             const basegfx::BColor& getEndColor() const { return maEndColor; }
      74                 :       8443 :             sal_uInt16 getSteps() const { return mnSteps; }
      75                 :            : 
      76                 :       3429 :             bool operator==(const ImpFillGradientAttribute& rCandidate) const
      77                 :            :             {
      78                 :       3429 :                 return (getStyle() == rCandidate.getStyle()
      79                 :       3429 :                     && getBorder() == rCandidate.getBorder()
      80                 :       3429 :                     && getOffsetX() == rCandidate.getOffsetX()
      81                 :       3429 :                     && getOffsetY() == rCandidate.getOffsetY()
      82                 :       3429 :                     && getAngle() == rCandidate.getAngle()
      83                 :       3429 :                     && getStartColor() == rCandidate.getStartColor()
      84                 :       3429 :                     && getEndColor() == rCandidate.getEndColor()
      85 [ +  - ][ +  -  :      24003 :                     && getSteps() == rCandidate.getSteps());
          +  -  +  -  +  
          -  +  -  +  -  
                   +  - ]
      86                 :            :             }
      87                 :            : 
      88                 :     252222 :             static ImpFillGradientAttribute* get_global_default()
      89                 :            :             {
      90                 :            :                 static ImpFillGradientAttribute* pDefault = 0;
      91                 :            : 
      92         [ +  + ]:     252222 :                 if(!pDefault)
      93                 :            :                 {
      94                 :            :                     pDefault = new ImpFillGradientAttribute(
      95                 :            :                         GRADIENTSTYLE_LINEAR,
      96                 :            :                         0.0, 0.0, 0.0, 0.0,
      97                 :            :                         basegfx::BColor(),
      98                 :            :                         basegfx::BColor(),
      99         [ +  - ]:         58 :                         0);
     100                 :            : 
     101                 :            :                     // never delete; start with RefCount 1, not 0
     102                 :         58 :                     pDefault->mnRefCount++;
     103                 :            :                 }
     104                 :            : 
     105                 :     252222 :                 return pDefault;
     106                 :            :             }
     107                 :            :         };
     108                 :            : 
     109                 :       6365 :         FillGradientAttribute::FillGradientAttribute(
     110                 :            :             GradientStyle eStyle,
     111                 :            :             double fBorder,
     112                 :            :             double fOffsetX,
     113                 :            :             double fOffsetY,
     114                 :            :             double fAngle,
     115                 :            :             const basegfx::BColor& rStartColor,
     116                 :            :             const basegfx::BColor& rEndColor,
     117                 :            :             sal_uInt16 nSteps)
     118                 :            :         :   mpFillGradientAttribute(new ImpFillGradientAttribute(
     119                 :       6365 :                 eStyle, fBorder, fOffsetX, fOffsetY, fAngle, rStartColor, rEndColor, nSteps))
     120                 :            :         {
     121                 :       6365 :         }
     122                 :            : 
     123                 :     214815 :         FillGradientAttribute::FillGradientAttribute()
     124                 :     214815 :         :   mpFillGradientAttribute(ImpFillGradientAttribute::get_global_default())
     125                 :            :         {
     126                 :     214815 :             mpFillGradientAttribute->mnRefCount++;
     127                 :     214815 :         }
     128                 :            : 
     129                 :     242896 :         FillGradientAttribute::FillGradientAttribute(const FillGradientAttribute& rCandidate)
     130                 :     242896 :         :   mpFillGradientAttribute(rCandidate.mpFillGradientAttribute)
     131                 :            :         {
     132                 :     242896 :             mpFillGradientAttribute->mnRefCount++;
     133                 :     242896 :         }
     134                 :            : 
     135                 :     464018 :         FillGradientAttribute::~FillGradientAttribute()
     136                 :            :         {
     137         [ +  + ]:     464018 :             if(mpFillGradientAttribute->mnRefCount)
     138                 :            :             {
     139                 :     457658 :                 mpFillGradientAttribute->mnRefCount--;
     140                 :            :             }
     141                 :            :             else
     142                 :            :             {
     143         [ +  - ]:       6360 :                 delete mpFillGradientAttribute;
     144                 :            :             }
     145                 :     464018 :         }
     146                 :            : 
     147                 :      37407 :         bool FillGradientAttribute::isDefault() const
     148                 :            :         {
     149                 :      37407 :             return mpFillGradientAttribute == ImpFillGradientAttribute::get_global_default();
     150                 :            :         }
     151                 :            : 
     152                 :      56729 :         FillGradientAttribute& FillGradientAttribute::operator=(const FillGradientAttribute& rCandidate)
     153                 :            :         {
     154         [ +  + ]:      56729 :             if(rCandidate.mpFillGradientAttribute != mpFillGradientAttribute)
     155                 :            :             {
     156         [ +  - ]:       6215 :                 if(mpFillGradientAttribute->mnRefCount)
     157                 :            :                 {
     158                 :       6215 :                     mpFillGradientAttribute->mnRefCount--;
     159                 :            :                 }
     160                 :            :                 else
     161                 :            :                 {
     162         [ #  # ]:          0 :                     delete mpFillGradientAttribute;
     163                 :            :                 }
     164                 :            : 
     165                 :       6215 :                 mpFillGradientAttribute = rCandidate.mpFillGradientAttribute;
     166                 :       6215 :                 mpFillGradientAttribute->mnRefCount++;
     167                 :            :             }
     168                 :            : 
     169                 :      56729 :             return *this;
     170                 :            :         }
     171                 :            : 
     172                 :      97619 :         bool FillGradientAttribute::operator==(const FillGradientAttribute& rCandidate) const
     173                 :            :         {
     174         [ +  + ]:      97619 :             if(rCandidate.mpFillGradientAttribute == mpFillGradientAttribute)
     175                 :            :             {
     176                 :      94190 :                 return true;
     177                 :            :             }
     178                 :            : 
     179         [ -  + ]:       3429 :             if(rCandidate.isDefault() != isDefault())
     180                 :            :             {
     181                 :          0 :                 return false;
     182                 :            :             }
     183                 :            : 
     184                 :      97619 :             return (*rCandidate.mpFillGradientAttribute == *mpFillGradientAttribute);
     185                 :            :         }
     186                 :            : 
     187                 :       1585 :         const basegfx::BColor& FillGradientAttribute::getStartColor() const
     188                 :            :         {
     189                 :       1585 :             return mpFillGradientAttribute->getStartColor();
     190                 :            :         }
     191                 :            : 
     192                 :       1585 :         const basegfx::BColor& FillGradientAttribute::getEndColor() const
     193                 :            :         {
     194                 :       1585 :             return mpFillGradientAttribute->getEndColor();
     195                 :            :         }
     196                 :            : 
     197                 :       1585 :         double FillGradientAttribute::getBorder() const
     198                 :            :         {
     199                 :       1585 :             return mpFillGradientAttribute->getBorder();
     200                 :            :         }
     201                 :            : 
     202                 :        235 :         double FillGradientAttribute::getOffsetX() const
     203                 :            :         {
     204                 :        235 :             return mpFillGradientAttribute->getOffsetX();
     205                 :            :         }
     206                 :            : 
     207                 :        235 :         double FillGradientAttribute::getOffsetY() const
     208                 :            :         {
     209                 :        235 :             return mpFillGradientAttribute->getOffsetY();
     210                 :            :         }
     211                 :            : 
     212                 :       1585 :         double FillGradientAttribute::getAngle() const
     213                 :            :         {
     214                 :       1585 :             return mpFillGradientAttribute->getAngle();
     215                 :            :         }
     216                 :            : 
     217                 :       5587 :         GradientStyle FillGradientAttribute::getStyle() const
     218                 :            :         {
     219                 :       5587 :             return mpFillGradientAttribute->getStyle();
     220                 :            :         }
     221                 :            : 
     222                 :       1585 :         sal_uInt16 FillGradientAttribute::getSteps() const
     223                 :            :         {
     224                 :       1585 :             return mpFillGradientAttribute->getSteps();
     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