LCOV - code coverage report
Current view: top level - drawinglayer/source/attribute - fillgraphicattribute.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 33 46 71.7 %
Date: 2015-06-13 12:38:46 Functions: 18 21 85.7 %
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        1245 :         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         413 :             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         413 :                 mfOffsetY(fOffsetY)
      53             :             {
      54         413 :             }
      55             : 
      56           9 :             ImpFillGraphicAttribute()
      57             :             :   maGraphic(Graphic()),
      58             :                 maGraphicRange(basegfx::B2DRange()),
      59             :                 mbTiling(false),
      60             :                 mfOffsetX(0.0),
      61           9 :                 mfOffsetY(0.0)
      62             :             {
      63           9 :             }
      64             : 
      65             :             // data read access
      66        2604 :             const Graphic& getGraphic() const { return maGraphic; }
      67         467 :             const basegfx::B2DRange& getGraphicRange() const { return maGraphicRange; }
      68         385 :             bool getTiling() const { return mbTiling; }
      69         301 :             double getOffsetX() const { return mfOffsetX; }
      70         301 :             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         413 :         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         826 :                     basegfx::clamp(fOffsetX, 0.0, 1.0),
      97        1239 :                     basegfx::clamp(fOffsetY, 0.0, 1.0)))
      98             :         {
      99         413 :         }
     100             : 
     101         820 :         FillGraphicAttribute::FillGraphicAttribute(const FillGraphicAttribute& rCandidate)
     102         820 :         :   mpFillGraphicAttribute(rCandidate.mpFillGraphicAttribute)
     103             :         {
     104         820 :         }
     105             : 
     106        1227 :         FillGraphicAttribute::~FillGraphicAttribute()
     107             :         {
     108        1227 :         }
     109             : 
     110         454 :         bool FillGraphicAttribute::isDefault() const
     111             :         {
     112         454 :             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             :             // tdf#87509 default attr is always != non-default attr, even with same values
     124           0 :             if(rCandidate.isDefault() != isDefault())
     125           0 :                 return false;
     126             : 
     127           0 :             return rCandidate.mpFillGraphicAttribute == mpFillGraphicAttribute;
     128             :         }
     129             : 
     130        2604 :         const Graphic& FillGraphicAttribute::getGraphic() const
     131             :         {
     132        2604 :             return mpFillGraphicAttribute->getGraphic();
     133             :         }
     134             : 
     135         467 :         const basegfx::B2DRange& FillGraphicAttribute::getGraphicRange() const
     136             :         {
     137         467 :             return mpFillGraphicAttribute->getGraphicRange();
     138             :         }
     139             : 
     140         385 :         bool FillGraphicAttribute::getTiling() const
     141             :         {
     142         385 :             return mpFillGraphicAttribute->getTiling();
     143             :         }
     144             : 
     145         301 :         double FillGraphicAttribute::getOffsetX() const
     146             :         {
     147         301 :             return mpFillGraphicAttribute->getOffsetX();
     148             :         }
     149             : 
     150         301 :         double FillGraphicAttribute::getOffsetY() const
     151             :         {
     152         301 :             return mpFillGraphicAttribute->getOffsetY();
     153             :         }
     154             : 
     155             :     } // end of namespace attribute
     156             : } // end of namespace drawinglayer
     157             : 
     158             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11