LCOV - code coverage report
Current view: top level - drawinglayer/source/attribute - lineattribute.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 40 44 90.9 %
Date: 2015-06-13 12:38:46 Functions: 19 20 95.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/lineattribute.hxx>
      21             : #include <basegfx/color/bcolor.hxx>
      22             : #include <rtl/instance.hxx>
      23             : 
      24             : 
      25             : 
      26             : namespace drawinglayer
      27             : {
      28             :     namespace attribute
      29             :     {
      30      125127 :         class ImpLineAttribute
      31             :         {
      32             :         public:
      33             :             // data definitions
      34             :             basegfx::BColor                         maColor;                // color
      35             :             double                                  mfWidth;                // absolute line width
      36             :             basegfx::B2DLineJoin                    meLineJoin;             // type of LineJoin
      37             :             com::sun::star::drawing::LineCap        meLineCap;              // BUTT, ROUND, or SQUARE
      38             : 
      39       41851 :             ImpLineAttribute(
      40             :                 const basegfx::BColor& rColor,
      41             :                 double fWidth,
      42             :                 basegfx::B2DLineJoin aB2DLineJoin,
      43             :                 com::sun::star::drawing::LineCap aLineCap)
      44             :             :   maColor(rColor),
      45             :                 mfWidth(fWidth),
      46             :                 meLineJoin(aB2DLineJoin),
      47       41851 :                 meLineCap(aLineCap)
      48             :             {
      49       41851 :             }
      50             : 
      51          68 :             ImpLineAttribute()
      52             :             :   maColor(basegfx::BColor()),
      53             :                 mfWidth(0.0),
      54             :                 meLineJoin(basegfx::B2DLineJoin::Round),
      55          68 :                 meLineCap(com::sun::star::drawing::LineCap_BUTT)
      56             :             {
      57          68 :             }
      58             : 
      59             :             // data read access
      60       99402 :             const basegfx::BColor& getColor() const { return maColor; }
      61      502892 :             double getWidth() const { return mfWidth; }
      62      193228 :             basegfx::B2DLineJoin getLineJoin() const { return meLineJoin; }
      63      191781 :             com::sun::star::drawing::LineCap getLineCap() const { return meLineCap; }
      64             : 
      65          42 :             bool operator==(const ImpLineAttribute& rCandidate) const
      66             :             {
      67          42 :                 return (getColor() == rCandidate.getColor()
      68          42 :                     && getWidth() == rCandidate.getWidth()
      69          42 :                     && getLineJoin() == rCandidate.getLineJoin()
      70          84 :                     && getLineCap() == rCandidate.getLineCap());
      71             :             }
      72             :         };
      73             : 
      74             :         namespace
      75             :         {
      76             :             struct theGlobalDefault :
      77             :                 public rtl::Static< LineAttribute::ImplType, theGlobalDefault > {};
      78             :         }
      79             : 
      80       41851 :         LineAttribute::LineAttribute(
      81             :             const basegfx::BColor& rColor,
      82             :             double fWidth,
      83             :             basegfx::B2DLineJoin aB2DLineJoin,
      84             :             com::sun::star::drawing::LineCap aLineCap)
      85             :         :   mpLineAttribute(
      86             :                 ImpLineAttribute(
      87             :                     rColor,
      88             :                     fWidth,
      89             :                     aB2DLineJoin,
      90       41851 :                     aLineCap))
      91             :         {
      92       41851 :         }
      93             : 
      94          64 :         LineAttribute::LineAttribute()
      95          64 :         :   mpLineAttribute(theGlobalDefault::get())
      96             :         {
      97          64 :         }
      98             : 
      99       43340 :         LineAttribute::LineAttribute(const LineAttribute& rCandidate)
     100       43340 :         :   mpLineAttribute(rCandidate.mpLineAttribute)
     101             :         {
     102       43340 :         }
     103             : 
     104       84761 :         LineAttribute::~LineAttribute()
     105             :         {
     106       84761 :         }
     107             : 
     108       21946 :         bool LineAttribute::isDefault() const
     109             :         {
     110       21946 :             return mpLineAttribute.same_object(theGlobalDefault::get());
     111             :         }
     112             : 
     113           0 :         LineAttribute& LineAttribute::operator=(const LineAttribute& rCandidate)
     114             :         {
     115           0 :             mpLineAttribute = rCandidate.mpLineAttribute;
     116           0 :             return *this;
     117             :         }
     118             : 
     119          42 :         bool LineAttribute::operator==(const LineAttribute& rCandidate) const
     120             :         {
     121             :             // tdf#87509 default attr is always != non-default attr, even with same values
     122          42 :             if(rCandidate.isDefault() != isDefault())
     123           0 :                 return false;
     124             : 
     125          42 :             return rCandidate.mpLineAttribute == mpLineAttribute;
     126             :         }
     127             : 
     128       99318 :         const basegfx::BColor& LineAttribute::getColor() const
     129             :         {
     130       99318 :             return mpLineAttribute->getColor();
     131             :         }
     132             : 
     133      502808 :         double LineAttribute::getWidth() const
     134             :         {
     135      502808 :             return mpLineAttribute->getWidth();
     136             :         }
     137             : 
     138      193144 :         basegfx::B2DLineJoin LineAttribute::getLineJoin() const
     139             :         {
     140      193144 :             return mpLineAttribute->getLineJoin();
     141             :         }
     142             : 
     143      191697 :         com::sun::star::drawing::LineCap LineAttribute::getLineCap() const
     144             :         {
     145      191697 :             return mpLineAttribute->getLineCap();
     146             :         }
     147             : 
     148             :     } // end of namespace attribute
     149             : } // end of namespace drawinglayer
     150             : 
     151             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11