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

Generated by: LCOV version 1.10