LCOV - code coverage report
Current view: top level - libreoffice/drawinglayer/source/attribute - sdrshadowattribute.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 28 54 51.9 %
Date: 2012-12-17 Functions: 8 17 47.1 %
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/sdrshadowattribute.hxx>
      21             : #include <basegfx/vector/b2dvector.hxx>
      22             : #include <basegfx/color/bcolor.hxx>
      23             : 
      24             : //////////////////////////////////////////////////////////////////////////////
      25             : 
      26             : namespace drawinglayer
      27             : {
      28             :     namespace attribute
      29             :     {
      30           0 :         class ImpSdrShadowAttribute
      31             :         {
      32             :         public:
      33             :             // refcounter
      34             :             sal_uInt32                              mnRefCount;
      35             : 
      36             :             // shadow definitions
      37             :             basegfx::B2DVector                  maOffset;                   // shadow offset 1/100th mm
      38             :             double                              mfTransparence;             // [0.0 .. 1.0], 0.0==no transp.
      39             :             basegfx::BColor                     maColor;                    // color of shadow
      40             : 
      41          22 :             ImpSdrShadowAttribute(
      42             :                 const basegfx::B2DVector& rOffset,
      43             :                 double fTransparence,
      44             :                 const basegfx::BColor& rColor)
      45             :             :   mnRefCount(0),
      46             :                 maOffset(rOffset),
      47             :                 mfTransparence(fTransparence),
      48          22 :                 maColor(rColor)
      49             :             {
      50          22 :             }
      51             : 
      52             :             // data read access
      53           0 :             const basegfx::B2DVector& getOffset() const { return maOffset; }
      54           0 :             double getTransparence() const { return mfTransparence; }
      55           0 :             const basegfx::BColor& getColor() const { return maColor; }
      56             : 
      57           0 :             bool operator==(const ImpSdrShadowAttribute& rCandidate) const
      58             :             {
      59           0 :                 return (getOffset() == rCandidate.getOffset()
      60           0 :                     && getTransparence() == rCandidate.getTransparence()
      61           0 :                     && getColor() == rCandidate.getColor());
      62             :             }
      63             : 
      64        2672 :             static ImpSdrShadowAttribute* get_global_default()
      65             :             {
      66             :                 static ImpSdrShadowAttribute* pDefault = 0;
      67             : 
      68        2672 :                 if(!pDefault)
      69             :                 {
      70             :                     pDefault = new ImpSdrShadowAttribute(
      71             :                         basegfx::B2DVector(),
      72             :                         0.0,
      73          22 :                         basegfx::BColor());
      74             : 
      75             :                     // never delete; start with RefCount 1, not 0
      76          22 :                     pDefault->mnRefCount++;
      77             :                 }
      78             : 
      79        2672 :                 return pDefault;
      80             :             }
      81             :         };
      82             : 
      83           0 :         SdrShadowAttribute::SdrShadowAttribute(
      84             :             const basegfx::B2DVector& rOffset,
      85             :             double fTransparence,
      86             :             const basegfx::BColor& rColor)
      87             :         :   mpSdrShadowAttribute(new ImpSdrShadowAttribute(
      88           0 :                 rOffset, fTransparence, rColor))
      89             :         {
      90           0 :         }
      91             : 
      92        1898 :         SdrShadowAttribute::SdrShadowAttribute()
      93        1898 :         :   mpSdrShadowAttribute(ImpSdrShadowAttribute::get_global_default())
      94             :         {
      95        1898 :             mpSdrShadowAttribute->mnRefCount++;
      96        1898 :         }
      97             : 
      98        1590 :         SdrShadowAttribute::SdrShadowAttribute(const SdrShadowAttribute& rCandidate)
      99        1590 :         :   mpSdrShadowAttribute(rCandidate.mpSdrShadowAttribute)
     100             :         {
     101        1590 :             mpSdrShadowAttribute->mnRefCount++;
     102        1590 :         }
     103             : 
     104        3440 :         SdrShadowAttribute::~SdrShadowAttribute()
     105             :         {
     106        3440 :             if(mpSdrShadowAttribute->mnRefCount)
     107             :             {
     108        3440 :                 mpSdrShadowAttribute->mnRefCount--;
     109             :             }
     110             :             else
     111             :             {
     112           0 :                 delete mpSdrShadowAttribute;
     113             :             }
     114        3440 :         }
     115             : 
     116         774 :         bool SdrShadowAttribute::isDefault() const
     117             :         {
     118         774 :             return mpSdrShadowAttribute == ImpSdrShadowAttribute::get_global_default();
     119             :         }
     120             : 
     121         396 :         SdrShadowAttribute& SdrShadowAttribute::operator=(const SdrShadowAttribute& rCandidate)
     122             :         {
     123         396 :             if(rCandidate.mpSdrShadowAttribute != mpSdrShadowAttribute)
     124             :             {
     125           0 :                 if(mpSdrShadowAttribute->mnRefCount)
     126             :                 {
     127           0 :                     mpSdrShadowAttribute->mnRefCount--;
     128             :                 }
     129             :                 else
     130             :                 {
     131           0 :                     delete mpSdrShadowAttribute;
     132             :                 }
     133             : 
     134           0 :                 mpSdrShadowAttribute = rCandidate.mpSdrShadowAttribute;
     135           0 :                 mpSdrShadowAttribute->mnRefCount++;
     136             :             }
     137             : 
     138         396 :             return *this;
     139             :         }
     140             : 
     141         148 :         bool SdrShadowAttribute::operator==(const SdrShadowAttribute& rCandidate) const
     142             :         {
     143         148 :             if(rCandidate.mpSdrShadowAttribute == mpSdrShadowAttribute)
     144             :             {
     145         148 :                 return true;
     146             :             }
     147             : 
     148           0 :             if(rCandidate.isDefault() != isDefault())
     149             :             {
     150           0 :                 return false;
     151             :             }
     152             : 
     153           0 :             return (*rCandidate.mpSdrShadowAttribute == *mpSdrShadowAttribute);
     154             :         }
     155             : 
     156           0 :         const basegfx::B2DVector& SdrShadowAttribute::getOffset() const
     157             :         {
     158           0 :             return mpSdrShadowAttribute->getOffset();
     159             :         }
     160             : 
     161           0 :         double SdrShadowAttribute::getTransparence() const
     162             :         {
     163           0 :             return mpSdrShadowAttribute->getTransparence();
     164             :         }
     165             : 
     166           0 :         const basegfx::BColor& SdrShadowAttribute::getColor() const
     167             :         {
     168           0 :             return mpSdrShadowAttribute->getColor();
     169             :         }
     170             :     } // end of namespace attribute
     171             : } // end of namespace drawinglayer
     172             : 
     173             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10