LCOV - code coverage report
Current view: top level - drawinglayer/source/attribute - fillgraphicattribute.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 34 45 75.6 %
Date: 2014-11-03 Functions: 20 23 87.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/fillgraphicattribute.hxx>
      21             : #include <vcl/graph.hxx>
      22             : 
      23             : namespace drawinglayer
      24             : {
      25             :     namespace attribute
      26             :     {
      27         878 :         class ImpFillGraphicAttribute
      28             :         {
      29             :         public:
      30             :             // data definitions
      31             :             Graphic                                 maGraphic;
      32             :             basegfx::B2DRange                       maGraphicRange;
      33             : 
      34             :             // bitfield
      35             :             bool                                    mbTiling : 1;
      36             : 
      37             :             // tiling definitions, offsets in X/Y in percent for each 2nd row.
      38             :             // If both are set, Y is ignored (X has precedence)
      39             :             double                                  mfOffsetX;
      40             :             double                                  mfOffsetY;
      41             : 
      42         290 :             ImpFillGraphicAttribute(
      43             :                 const Graphic& rGraphic,
      44             :                 const basegfx::B2DRange& rGraphicRange,
      45             :                 bool bTiling,
      46             :                 double fOffsetX,
      47             :                 double fOffsetY)
      48             :             :   maGraphic(rGraphic),
      49             :                 maGraphicRange(rGraphicRange),
      50             :                 mbTiling(bTiling),
      51             :                 mfOffsetX(fOffsetX),
      52         290 :                 mfOffsetY(fOffsetY)
      53             :             {
      54         290 :             }
      55             : 
      56          14 :             ImpFillGraphicAttribute()
      57             :             :   maGraphic(Graphic()),
      58             :                 maGraphicRange(basegfx::B2DRange()),
      59             :                 mbTiling(false),
      60             :                 mfOffsetX(0.0),
      61          14 :                 mfOffsetY(0.0)
      62             :             {
      63          14 :             }
      64             : 
      65             :             // data read access
      66        1126 :             const Graphic& getGraphic() const { return maGraphic; }
      67         406 :             const basegfx::B2DRange& getGraphicRange() const { return maGraphicRange; }
      68         248 :             bool getTiling() const { return mbTiling; }
      69          86 :             double getOffsetX() const { return mfOffsetX; }
      70          86 :             double getOffsetY() const { return mfOffsetY; }
      71             : 
      72           0 :             bool operator==(const ImpFillGraphicAttribute& rCandidate) const
      73             :             {
      74           0 :                 return (getGraphic() == rCandidate.getGraphic()
      75           0 :                     && getGraphicRange() == rCandidate.getGraphicRange()
      76           0 :                     && getTiling() == rCandidate.getTiling()
      77           0 :                     && getOffsetX() == rCandidate.getOffsetX()
      78           0 :                     && getOffsetY() == rCandidate.getOffsetY());
      79             :             }
      80             :         };
      81             : 
      82             :         namespace
      83             :         {
      84             :             struct theGlobalDefault :
      85             :                 public rtl::Static< FillGraphicAttribute::ImplType, theGlobalDefault > {};
      86             :         }
      87             : 
      88         290 :         FillGraphicAttribute::FillGraphicAttribute(
      89             :             const Graphic& rGraphic,
      90             :             const basegfx::B2DRange& rGraphicRange,
      91             :             bool bTiling,
      92             :             double fOffsetX,
      93             :             double fOffsetY)
      94             :         :   mpFillGraphicAttribute(ImpFillGraphicAttribute(
      95             :                 rGraphic, rGraphicRange, bTiling,
      96         580 :                     basegfx::clamp(fOffsetX, 0.0, 1.0),
      97         870 :                     basegfx::clamp(fOffsetY, 0.0, 1.0)))
      98             :         {
      99         290 :         }
     100             : 
     101         580 :         FillGraphicAttribute::FillGraphicAttribute(const FillGraphicAttribute& rCandidate)
     102         580 :         :   mpFillGraphicAttribute(rCandidate.mpFillGraphicAttribute)
     103             :         {
     104         580 :         }
     105             : 
     106         858 :         FillGraphicAttribute::~FillGraphicAttribute()
     107             :         {
     108         858 :         }
     109             : 
     110         372 :         bool FillGraphicAttribute::isDefault() const
     111             :         {
     112         372 :             return mpFillGraphicAttribute.same_object(theGlobalDefault::get());
     113             :         }
     114             : 
     115           0 :         FillGraphicAttribute& FillGraphicAttribute::operator=(const FillGraphicAttribute& rCandidate)
     116             :         {
     117           0 :             mpFillGraphicAttribute = rCandidate.mpFillGraphicAttribute;
     118           0 :             return *this;
     119             :         }
     120             : 
     121           0 :         bool FillGraphicAttribute::operator==(const FillGraphicAttribute& rCandidate) const
     122             :         {
     123           0 :             return rCandidate.mpFillGraphicAttribute == mpFillGraphicAttribute;
     124             :         }
     125             : 
     126        1126 :         const Graphic& FillGraphicAttribute::getGraphic() const
     127             :         {
     128        1126 :             return mpFillGraphicAttribute->getGraphic();
     129             :         }
     130             : 
     131         406 :         const basegfx::B2DRange& FillGraphicAttribute::getGraphicRange() const
     132             :         {
     133         406 :             return mpFillGraphicAttribute->getGraphicRange();
     134             :         }
     135             : 
     136         248 :         bool FillGraphicAttribute::getTiling() const
     137             :         {
     138         248 :             return mpFillGraphicAttribute->getTiling();
     139             :         }
     140             : 
     141          86 :         double FillGraphicAttribute::getOffsetX() const
     142             :         {
     143          86 :             return mpFillGraphicAttribute->getOffsetX();
     144             :         }
     145             : 
     146          86 :         double FillGraphicAttribute::getOffsetY() const
     147             :         {
     148          86 :             return mpFillGraphicAttribute->getOffsetY();
     149             :         }
     150             : 
     151             :     } // end of namespace attribute
     152        1143 : } // end of namespace drawinglayer
     153             : 
     154             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10