LCOV - code coverage report
Current view: top level - drawinglayer/source/attribute - sdrobjectattribute3d.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 70 82 85.4 %
Date: 2012-08-25 Functions: 30 32 93.8 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 21 44 47.7 %

           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/sdrobjectattribute3d.hxx>
      32                 :            : #include <drawinglayer/attribute/materialattribute3d.hxx>
      33                 :            : 
      34                 :            : //////////////////////////////////////////////////////////////////////////////
      35                 :            : 
      36                 :            : namespace drawinglayer
      37                 :            : {
      38                 :            :     namespace attribute
      39                 :            :     {
      40                 :      13391 :         class ImpSdr3DObjectAttribute
      41                 :            :         {
      42                 :            :         public:
      43                 :            :             // refcounter
      44                 :            :             sal_uInt32                              mnRefCount;
      45                 :            : 
      46                 :            :             // 3D object attribute definitions
      47                 :            :             ::com::sun::star::drawing::NormalsKind              maNormalsKind;              // normals type (0..2)
      48                 :            :             ::com::sun::star::drawing::TextureProjectionMode    maTextureProjectionX;       // texture projection type X (0..2)
      49                 :            :             ::com::sun::star::drawing::TextureProjectionMode    maTextureProjectionY;       // texture projection type Y (0..2)
      50                 :            :             ::com::sun::star::drawing::TextureKind2             maTextureKind;              // texture kind (see uno API)
      51                 :            :             ::com::sun::star::drawing::TextureMode              maTextureMode;              // texture kind (see uno API)
      52                 :            :             MaterialAttribute3D                                 maMaterial;                 // object, specular and emissive colors, SpecularIntensity
      53                 :            : 
      54                 :            :             // bitfield
      55                 :            :             unsigned                                            mbNormalsInvert : 1;        // invert normals
      56                 :            :             unsigned                                            mbDoubleSided : 1;          // surfaces are double sided
      57                 :            :             unsigned                                            mbShadow3D : 1;             // display shadow in 3D (if on), params for that are at scene
      58                 :            :             unsigned                                            mbTextureFilter : 1;        // filter texture to make more smooth
      59                 :            :             unsigned                                            mbReducedLineGeometry : 1;  // use reduced line geometry (object specific)
      60                 :            : 
      61                 :      13393 :             ImpSdr3DObjectAttribute(
      62                 :            :                 ::com::sun::star::drawing::NormalsKind  aNormalsKind,
      63                 :            :                 ::com::sun::star::drawing::TextureProjectionMode aTextureProjectionX,
      64                 :            :                 ::com::sun::star::drawing::TextureProjectionMode aTextureProjectionY,
      65                 :            :                 ::com::sun::star::drawing::TextureKind2 aTextureKind,
      66                 :            :                 ::com::sun::star::drawing::TextureMode aTextureMode,
      67                 :            :                 const MaterialAttribute3D& rMaterial,
      68                 :            :                 bool bNormalsInvert,
      69                 :            :                 bool bDoubleSided,
      70                 :            :                 bool bShadow3D,
      71                 :            :                 bool bTextureFilter,
      72                 :            :                 bool bReducedLineGeometry)
      73                 :            :             :   mnRefCount(0),
      74                 :            :                 maNormalsKind(aNormalsKind),
      75                 :            :                 maTextureProjectionX(aTextureProjectionX),
      76                 :            :                 maTextureProjectionY(aTextureProjectionY),
      77                 :            :                 maTextureKind(aTextureKind),
      78                 :            :                 maTextureMode(aTextureMode),
      79                 :            :                 maMaterial(rMaterial),
      80                 :            :                 mbNormalsInvert(bNormalsInvert),
      81                 :            :                 mbDoubleSided(bDoubleSided),
      82                 :            :                 mbShadow3D(bShadow3D),
      83                 :            :                 mbTextureFilter(bTextureFilter),
      84                 :      13393 :                 mbReducedLineGeometry(bReducedLineGeometry)
      85                 :            :             {
      86                 :      13393 :             }
      87                 :            : 
      88                 :            :             // data read access
      89                 :      22520 :             ::com::sun::star::drawing::NormalsKind getNormalsKind() const { return maNormalsKind; }
      90                 :      22279 :             ::com::sun::star::drawing::TextureProjectionMode getTextureProjectionX() const { return maTextureProjectionX; }
      91                 :      22279 :             ::com::sun::star::drawing::TextureProjectionMode getTextureProjectionY() const { return maTextureProjectionY; }
      92                 :      21974 :             ::com::sun::star::drawing::TextureKind2 getTextureKind() const { return maTextureKind; }
      93                 :      21974 :             ::com::sun::star::drawing::TextureMode getTextureMode() const { return maTextureMode; }
      94                 :      22389 :             const MaterialAttribute3D& getMaterial() const { return maMaterial; }
      95                 :      22255 :             bool getNormalsInvert() const { return mbNormalsInvert; }
      96                 :      22389 :             bool getDoubleSided() const { return mbDoubleSided; }
      97                 :      21966 :             bool getShadow3D() const { return mbShadow3D; }
      98                 :      21974 :             bool getTextureFilter() const { return mbTextureFilter; }
      99                 :      22014 :             bool getReducedLineGeometry() const { return mbReducedLineGeometry; }
     100                 :            : 
     101                 :      10983 :             bool operator==(const ImpSdr3DObjectAttribute& rCandidate) const
     102                 :            :             {
     103                 :      10983 :                 return (getNormalsKind() == rCandidate.getNormalsKind()
     104                 :      10983 :                     && getTextureProjectionX() == rCandidate.getTextureProjectionX()
     105                 :      10983 :                     && getTextureProjectionY() == rCandidate.getTextureProjectionY()
     106                 :      10983 :                     && getTextureKind() == rCandidate.getTextureKind()
     107                 :      10983 :                     && getTextureMode() == rCandidate.getTextureMode()
     108                 :      10983 :                     && getMaterial() == rCandidate.getMaterial()
     109                 :      10983 :                     && getNormalsInvert() == rCandidate.getNormalsInvert()
     110                 :      10983 :                     && getDoubleSided() == rCandidate.getDoubleSided()
     111                 :      10983 :                     && getShadow3D() == rCandidate.getShadow3D()
     112                 :      10983 :                     && getTextureFilter() == rCandidate.getTextureFilter()
     113 [ +  - ][ +  -  :     109830 :                     && getReducedLineGeometry() == rCandidate.getReducedLineGeometry());
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
                -  +  - ]
     114                 :            :             }
     115                 :            : 
     116                 :      21966 :             static ImpSdr3DObjectAttribute* get_global_default()
     117                 :            :             {
     118                 :            :                 static ImpSdr3DObjectAttribute* pDefault = 0;
     119                 :            : 
     120         [ +  + ]:      21966 :                 if(!pDefault)
     121                 :            :                 {
     122                 :            :                     pDefault = new ImpSdr3DObjectAttribute(
     123                 :            :                         ::com::sun::star::drawing::NormalsKind_SPECIFIC,
     124                 :            :                         ::com::sun::star::drawing::TextureProjectionMode_OBJECTSPECIFIC,
     125                 :            :                         ::com::sun::star::drawing::TextureProjectionMode_OBJECTSPECIFIC,
     126                 :            :                         ::com::sun::star::drawing::TextureKind2_LUMINANCE,
     127                 :            :                         ::com::sun::star::drawing::TextureMode_REPLACE,
     128                 :            :                         MaterialAttribute3D(),
     129                 :            :                         false,
     130                 :            :                         false,
     131                 :            :                         false,
     132                 :            :                         false,
     133 [ +  - ][ +  - ]:          2 :                         false);
     134                 :            : 
     135                 :            :                     // never delete; start with RefCount 1, not 0
     136                 :          2 :                     pDefault->mnRefCount++;
     137                 :            :                 }
     138                 :            : 
     139                 :      21966 :                 return pDefault;
     140                 :            :             }
     141                 :            :         };
     142                 :            : 
     143                 :      13391 :         Sdr3DObjectAttribute::Sdr3DObjectAttribute(
     144                 :            :             ::com::sun::star::drawing::NormalsKind  aNormalsKind,
     145                 :            :             ::com::sun::star::drawing::TextureProjectionMode aTextureProjectionX,
     146                 :            :             ::com::sun::star::drawing::TextureProjectionMode aTextureProjectionY,
     147                 :            :             ::com::sun::star::drawing::TextureKind2 aTextureKind,
     148                 :            :             ::com::sun::star::drawing::TextureMode aTextureMode,
     149                 :            :             const MaterialAttribute3D& rMaterial,
     150                 :            :             bool bNormalsInvert,
     151                 :            :             bool bDoubleSided,
     152                 :            :             bool bShadow3D,
     153                 :            :             bool bTextureFilter,
     154                 :            :             bool bReducedLineGeometry)
     155                 :            :         :   mpSdr3DObjectAttribute(new ImpSdr3DObjectAttribute(
     156                 :            :                 aNormalsKind, aTextureProjectionX, aTextureProjectionY, aTextureKind, aTextureMode,
     157         [ +  - ]:      13391 :                 rMaterial, bNormalsInvert, bDoubleSided, bShadow3D, bTextureFilter, bReducedLineGeometry))
     158                 :            :         {
     159                 :      13391 :         }
     160                 :            : 
     161                 :      37177 :         Sdr3DObjectAttribute::Sdr3DObjectAttribute(const Sdr3DObjectAttribute& rCandidate)
     162                 :      37177 :         :   mpSdr3DObjectAttribute(rCandidate.mpSdr3DObjectAttribute)
     163                 :            :         {
     164                 :      37177 :             mpSdr3DObjectAttribute->mnRefCount++;
     165                 :      37177 :         }
     166                 :            : 
     167                 :      50568 :         Sdr3DObjectAttribute::~Sdr3DObjectAttribute()
     168                 :            :         {
     169         [ +  + ]:      50568 :             if(mpSdr3DObjectAttribute->mnRefCount)
     170                 :            :             {
     171                 :      37177 :                 mpSdr3DObjectAttribute->mnRefCount--;
     172                 :            :             }
     173                 :            :             else
     174                 :            :             {
     175         [ +  - ]:      13391 :                 delete mpSdr3DObjectAttribute;
     176                 :            :             }
     177                 :      50568 :         }
     178                 :            : 
     179                 :      21966 :         bool Sdr3DObjectAttribute::isDefault() const
     180                 :            :         {
     181                 :      21966 :             return mpSdr3DObjectAttribute == ImpSdr3DObjectAttribute::get_global_default();
     182                 :            :         }
     183                 :            : 
     184                 :          0 :         Sdr3DObjectAttribute& Sdr3DObjectAttribute::operator=(const Sdr3DObjectAttribute& rCandidate)
     185                 :            :         {
     186         [ #  # ]:          0 :             if(rCandidate.mpSdr3DObjectAttribute != mpSdr3DObjectAttribute)
     187                 :            :             {
     188         [ #  # ]:          0 :                 if(mpSdr3DObjectAttribute->mnRefCount)
     189                 :            :                 {
     190                 :          0 :                     mpSdr3DObjectAttribute->mnRefCount--;
     191                 :            :                 }
     192                 :            :                 else
     193                 :            :                 {
     194         [ #  # ]:          0 :                     delete mpSdr3DObjectAttribute;
     195                 :            :                 }
     196                 :            : 
     197                 :          0 :                 mpSdr3DObjectAttribute = rCandidate.mpSdr3DObjectAttribute;
     198                 :          0 :                 mpSdr3DObjectAttribute->mnRefCount++;
     199                 :            :             }
     200                 :            : 
     201                 :          0 :             return *this;
     202                 :            :         }
     203                 :            : 
     204                 :      10983 :         bool Sdr3DObjectAttribute::operator==(const Sdr3DObjectAttribute& rCandidate) const
     205                 :            :         {
     206         [ -  + ]:      10983 :             if(rCandidate.mpSdr3DObjectAttribute == mpSdr3DObjectAttribute)
     207                 :            :             {
     208                 :          0 :                 return true;
     209                 :            :             }
     210                 :            : 
     211         [ -  + ]:      10983 :             if(rCandidate.isDefault() != isDefault())
     212                 :            :             {
     213                 :          0 :                 return false;
     214                 :            :             }
     215                 :            : 
     216                 :      10983 :             return (*rCandidate.mpSdr3DObjectAttribute == *mpSdr3DObjectAttribute);
     217                 :            :         }
     218                 :            : 
     219                 :        554 :         ::com::sun::star::drawing::NormalsKind Sdr3DObjectAttribute::getNormalsKind() const
     220                 :            :         {
     221                 :        554 :             return mpSdr3DObjectAttribute->getNormalsKind();
     222                 :            :         }
     223                 :            : 
     224                 :        313 :         ::com::sun::star::drawing::TextureProjectionMode Sdr3DObjectAttribute::getTextureProjectionX() const
     225                 :            :         {
     226                 :        313 :             return mpSdr3DObjectAttribute->getTextureProjectionX();
     227                 :            :         }
     228                 :            : 
     229                 :        313 :         ::com::sun::star::drawing::TextureProjectionMode Sdr3DObjectAttribute::getTextureProjectionY() const
     230                 :            :         {
     231                 :        313 :             return mpSdr3DObjectAttribute->getTextureProjectionY();
     232                 :            :         }
     233                 :            : 
     234                 :          8 :         ::com::sun::star::drawing::TextureKind2 Sdr3DObjectAttribute::getTextureKind() const
     235                 :            :         {
     236                 :          8 :             return mpSdr3DObjectAttribute->getTextureKind();
     237                 :            :         }
     238                 :            : 
     239                 :          8 :         ::com::sun::star::drawing::TextureMode Sdr3DObjectAttribute::getTextureMode() const
     240                 :            :         {
     241                 :          8 :             return mpSdr3DObjectAttribute->getTextureMode();
     242                 :            :         }
     243                 :            : 
     244                 :        423 :         const MaterialAttribute3D& Sdr3DObjectAttribute::getMaterial() const
     245                 :            :         {
     246                 :        423 :             return mpSdr3DObjectAttribute->getMaterial();
     247                 :            :         }
     248                 :            : 
     249                 :        289 :         bool Sdr3DObjectAttribute::getNormalsInvert() const
     250                 :            :         {
     251                 :        289 :             return mpSdr3DObjectAttribute->getNormalsInvert();
     252                 :            :         }
     253                 :            : 
     254                 :        423 :         bool Sdr3DObjectAttribute::getDoubleSided() const
     255                 :            :         {
     256                 :        423 :             return mpSdr3DObjectAttribute->getDoubleSided();
     257                 :            :         }
     258                 :            : 
     259                 :          0 :         bool Sdr3DObjectAttribute::getShadow3D() const
     260                 :            :         {
     261                 :          0 :             return mpSdr3DObjectAttribute->getShadow3D();
     262                 :            :         }
     263                 :            : 
     264                 :          8 :         bool Sdr3DObjectAttribute::getTextureFilter() const
     265                 :            :         {
     266                 :          8 :             return mpSdr3DObjectAttribute->getTextureFilter();
     267                 :            :         }
     268                 :            : 
     269                 :         48 :         bool Sdr3DObjectAttribute::getReducedLineGeometry() const
     270                 :            :         {
     271                 :         48 :             return mpSdr3DObjectAttribute->getReducedLineGeometry();
     272                 :            :         }
     273                 :            : 
     274                 :            :     } // end of namespace attribute
     275                 :            : } // end of namespace drawinglayer
     276                 :            : 
     277                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10