LCOV - code coverage report
Current view: top level - drawinglayer/source/attribute - sdrsceneattribute3d.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 46 59 78.0 %
Date: 2012-08-25 Functions: 16 19 84.2 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 8 22 36.4 %

           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/sdrsceneattribute3d.hxx>
      32                 :            : 
      33                 :            : //////////////////////////////////////////////////////////////////////////////
      34                 :            : 
      35                 :            : namespace drawinglayer
      36                 :            : {
      37                 :            :     namespace attribute
      38                 :            :     {
      39                 :            :         class ImpSdrSceneAttribute
      40                 :            :         {
      41                 :            :         public:
      42                 :            :             // refcounter
      43                 :            :             sal_uInt32                              mnRefCount;
      44                 :            : 
      45                 :            :             // 3D scene attribute definitions
      46                 :            :             double                                      mfDistance;
      47                 :            :             double                                      mfShadowSlant;
      48                 :            :             ::com::sun::star::drawing::ProjectionMode   maProjectionMode;
      49                 :            :             ::com::sun::star::drawing::ShadeMode        maShadeMode;
      50                 :            : 
      51                 :            :             // bitfield
      52                 :            :             unsigned                                    mbTwoSidedLighting : 1;
      53                 :            : 
      54                 :            :         public:
      55                 :        557 :             ImpSdrSceneAttribute(
      56                 :            :                 double fDistance,
      57                 :            :                 double fShadowSlant,
      58                 :            :                 ::com::sun::star::drawing::ProjectionMode aProjectionMode,
      59                 :            :                 ::com::sun::star::drawing::ShadeMode aShadeMode,
      60                 :            :                 bool bTwoSidedLighting)
      61                 :            :             :   mnRefCount(0),
      62                 :            :                 mfDistance(fDistance),
      63                 :            :                 mfShadowSlant(fShadowSlant),
      64                 :            :                 maProjectionMode(aProjectionMode),
      65                 :            :                 maShadeMode(aShadeMode),
      66                 :        557 :                 mbTwoSidedLighting(bTwoSidedLighting)
      67                 :            :             {
      68                 :        557 :             }
      69                 :            : 
      70                 :            :             // data read access
      71                 :          0 :             double getDistance() const { return mfDistance; }
      72                 :         15 :             double getShadowSlant() const { return mfShadowSlant; }
      73                 :       1110 :             ::com::sun::star::drawing::ProjectionMode getProjectionMode() const { return maProjectionMode; }
      74                 :        144 :             ::com::sun::star::drawing::ShadeMode getShadeMode() const { return maShadeMode; }
      75                 :        551 :             bool getTwoSidedLighting() const { return mbTwoSidedLighting; }
      76                 :            : 
      77                 :          0 :             bool operator==(const ImpSdrSceneAttribute& rCandidate) const
      78                 :            :             {
      79                 :          0 :                 return (getDistance() == rCandidate.getDistance()
      80                 :          0 :                     && getShadowSlant() == rCandidate.getShadowSlant()
      81                 :          0 :                     && getProjectionMode() == rCandidate.getProjectionMode()
      82                 :          0 :                     && getShadeMode() == rCandidate.getShadeMode()
      83 [ #  # ][ #  #  :          0 :                     && getTwoSidedLighting() == rCandidate.getTwoSidedLighting());
          #  #  #  #  #  
                      # ]
      84                 :            :             }
      85                 :            : 
      86                 :       4473 :             static ImpSdrSceneAttribute* get_global_default()
      87                 :            :             {
      88                 :            :                 static ImpSdrSceneAttribute* pDefault = 0;
      89                 :            : 
      90         [ +  + ]:       4473 :                 if(!pDefault)
      91                 :            :                 {
      92                 :            :                     pDefault = new ImpSdrSceneAttribute(
      93                 :            :                         0.0, 0.0,
      94                 :            :                         ::com::sun::star::drawing::ProjectionMode_PARALLEL,
      95                 :            :                         ::com::sun::star::drawing::ShadeMode_FLAT,
      96                 :          2 :                         false);
      97                 :            : 
      98                 :            :                     // never delete; start with RefCount 1, not 0
      99                 :          2 :                     pDefault->mnRefCount++;
     100                 :            :                 }
     101                 :            : 
     102                 :       4473 :                 return pDefault;
     103                 :            :             }
     104                 :            :         };
     105                 :            : 
     106                 :        555 :         SdrSceneAttribute::SdrSceneAttribute(
     107                 :            :             double fDistance,
     108                 :            :             double fShadowSlant,
     109                 :            :             ::com::sun::star::drawing::ProjectionMode aProjectionMode,
     110                 :            :             ::com::sun::star::drawing::ShadeMode aShadeMode,
     111                 :            :             bool bTwoSidedLighting)
     112                 :            :         :   mpSdrSceneAttribute(new ImpSdrSceneAttribute(
     113                 :        555 :                 fDistance, fShadowSlant, aProjectionMode, aShadeMode, bTwoSidedLighting))
     114                 :            :         {
     115                 :        555 :         }
     116                 :            : 
     117                 :       3903 :         SdrSceneAttribute::SdrSceneAttribute()
     118                 :       3903 :         :   mpSdrSceneAttribute(ImpSdrSceneAttribute::get_global_default())
     119                 :            :         {
     120                 :       3903 :             mpSdrSceneAttribute->mnRefCount++;
     121                 :       3903 :         }
     122                 :            : 
     123                 :         15 :         SdrSceneAttribute::SdrSceneAttribute(const SdrSceneAttribute& rCandidate)
     124                 :         15 :         :   mpSdrSceneAttribute(rCandidate.mpSdrSceneAttribute)
     125                 :            :         {
     126                 :         15 :             mpSdrSceneAttribute->mnRefCount++;
     127                 :         15 :         }
     128                 :            : 
     129                 :       4473 :         SdrSceneAttribute::~SdrSceneAttribute()
     130                 :            :         {
     131         [ +  + ]:       4473 :             if(mpSdrSceneAttribute->mnRefCount)
     132                 :            :             {
     133                 :       4464 :                 mpSdrSceneAttribute->mnRefCount--;
     134                 :            :             }
     135                 :            :             else
     136                 :            :             {
     137                 :          9 :                 delete mpSdrSceneAttribute;
     138                 :            :             }
     139                 :       4473 :         }
     140                 :            : 
     141                 :        570 :         bool SdrSceneAttribute::isDefault() const
     142                 :            :         {
     143                 :        570 :             return mpSdrSceneAttribute == ImpSdrSceneAttribute::get_global_default();
     144                 :            :         }
     145                 :            : 
     146                 :       3722 :         SdrSceneAttribute& SdrSceneAttribute::operator=(const SdrSceneAttribute& rCandidate)
     147                 :            :         {
     148         [ +  + ]:       3722 :             if(rCandidate.mpSdrSceneAttribute != mpSdrSceneAttribute)
     149                 :            :             {
     150         [ +  + ]:       1101 :                 if(mpSdrSceneAttribute->mnRefCount)
     151                 :            :                 {
     152                 :        555 :                     mpSdrSceneAttribute->mnRefCount--;
     153                 :            :                 }
     154                 :            :                 else
     155                 :            :                 {
     156                 :        546 :                     delete mpSdrSceneAttribute;
     157                 :            :                 }
     158                 :            : 
     159                 :       1101 :                 mpSdrSceneAttribute = rCandidate.mpSdrSceneAttribute;
     160                 :       1101 :                 mpSdrSceneAttribute->mnRefCount++;
     161                 :            :             }
     162                 :            : 
     163                 :       3722 :             return *this;
     164                 :            :         }
     165                 :            : 
     166                 :          0 :         bool SdrSceneAttribute::operator==(const SdrSceneAttribute& rCandidate) const
     167                 :            :         {
     168         [ #  # ]:          0 :             if(rCandidate.mpSdrSceneAttribute == mpSdrSceneAttribute)
     169                 :            :             {
     170                 :          0 :                 return true;
     171                 :            :             }
     172                 :            : 
     173         [ #  # ]:          0 :             if(rCandidate.isDefault() != isDefault())
     174                 :            :             {
     175                 :          0 :                 return false;
     176                 :            :             }
     177                 :            : 
     178                 :          0 :             return (*rCandidate.mpSdrSceneAttribute == *mpSdrSceneAttribute);
     179                 :            :         }
     180                 :            : 
     181                 :         15 :         double SdrSceneAttribute::getShadowSlant() const
     182                 :            :         {
     183                 :         15 :             return mpSdrSceneAttribute->getShadowSlant();
     184                 :            :         }
     185                 :            : 
     186                 :       1110 :         ::com::sun::star::drawing::ProjectionMode SdrSceneAttribute::getProjectionMode() const
     187                 :            :         {
     188                 :       1110 :             return mpSdrSceneAttribute->getProjectionMode();
     189                 :            :         }
     190                 :            : 
     191                 :        144 :         ::com::sun::star::drawing::ShadeMode SdrSceneAttribute::getShadeMode() const
     192                 :            :         {
     193                 :        144 :             return mpSdrSceneAttribute->getShadeMode();
     194                 :            :         }
     195                 :            : 
     196                 :        551 :         bool SdrSceneAttribute::getTwoSidedLighting() const
     197                 :            :         {
     198                 :        551 :             return mpSdrSceneAttribute->getTwoSidedLighting();
     199                 :            :         }
     200                 :            : 
     201                 :            :     } // end of namespace attribute
     202                 :            : } // end of namespace drawinglayer
     203                 :            : 
     204                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10