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

Generated by: LCOV version 1.10