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

Generated by: LCOV version 1.10