LCOV - code coverage report
Current view: top level - drawinglayer/source/attribute - linestartendattribute.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 30 44 68.2 %
Date: 2015-06-13 12:38:46 Functions: 15 19 78.9 %
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/linestartendattribute.hxx>
      21             : #include <basegfx/polygon/b2dpolygon.hxx>
      22             : #include <basegfx/polygon/b2dpolypolygon.hxx>
      23             : #include <rtl/instance.hxx>
      24             : 
      25             : 
      26             : 
      27             : namespace drawinglayer
      28             : {
      29             :     namespace attribute
      30             :     {
      31        2545 :         class ImpLineStartEndAttribute
      32             :         {
      33             :         public:
      34             :             // data definitions
      35             :             double                                  mfWidth;                // absolute line StartEndGeometry base width
      36             :             basegfx::B2DPolyPolygon                 maPolyPolygon;          // the StartEndGeometry PolyPolygon
      37             : 
      38             :             // bitfield
      39             :             bool                                    mbCentered : 1;         // use centered to ineStart/End point?
      40             : 
      41         842 :             ImpLineStartEndAttribute(
      42             :                 double fWidth,
      43             :                 const basegfx::B2DPolyPolygon& rPolyPolygon,
      44             :                 bool bCentered)
      45             :             :   mfWidth(fWidth),
      46             :                 maPolyPolygon(rPolyPolygon),
      47         842 :                 mbCentered(bCentered)
      48             :             {
      49         842 :             }
      50             : 
      51          19 :             ImpLineStartEndAttribute()
      52             :             :   mfWidth(0.0),
      53             :                 maPolyPolygon(basegfx::B2DPolyPolygon()),
      54          19 :                 mbCentered(false)
      55             :             {
      56          19 :             }
      57             : 
      58             :             // data read access
      59        2255 :             double getWidth() const { return mfWidth; }
      60        3083 :             const basegfx::B2DPolyPolygon& getB2DPolyPolygon() const { return maPolyPolygon; }
      61         351 :             bool isCentered() const { return mbCentered; }
      62             : 
      63           0 :             bool operator==(const ImpLineStartEndAttribute& rCandidate) const
      64             :             {
      65           0 :                 return (basegfx::fTools::equal(getWidth(), rCandidate.getWidth())
      66           0 :                     && getB2DPolyPolygon() == rCandidate.getB2DPolyPolygon()
      67           0 :                     && isCentered() == rCandidate.isCentered());
      68             :             }
      69             :         };
      70             : 
      71             :         namespace
      72             :         {
      73             :             struct theGlobalDefault :
      74             :                 public rtl::Static< LineStartEndAttribute::ImplType, theGlobalDefault > {};
      75             :         }
      76             : 
      77         842 :         LineStartEndAttribute::LineStartEndAttribute(
      78             :             double fWidth,
      79             :             const basegfx::B2DPolyPolygon& rPolyPolygon,
      80             :             bool bCentered)
      81             :         :   mpLineStartEndAttribute(ImpLineStartEndAttribute(
      82         842 :                 fWidth, rPolyPolygon, bCentered))
      83             :         {
      84         842 :         }
      85             : 
      86           0 :         LineStartEndAttribute::LineStartEndAttribute()
      87           0 :         :   mpLineStartEndAttribute(theGlobalDefault::get())
      88             :         {
      89           0 :         }
      90             : 
      91         862 :         LineStartEndAttribute::LineStartEndAttribute(const LineStartEndAttribute& rCandidate)
      92         862 :         :   mpLineStartEndAttribute(rCandidate.mpLineStartEndAttribute)
      93             :         {
      94         862 :         }
      95             : 
      96        1704 :         LineStartEndAttribute::~LineStartEndAttribute()
      97             :         {
      98        1704 :         }
      99             : 
     100         364 :         bool LineStartEndAttribute::isDefault() const
     101             :         {
     102         364 :             return mpLineStartEndAttribute.same_object(theGlobalDefault::get());
     103             :         }
     104             : 
     105           0 :         LineStartEndAttribute& LineStartEndAttribute::operator=(const LineStartEndAttribute& rCandidate)
     106             :         {
     107           0 :             mpLineStartEndAttribute = rCandidate.mpLineStartEndAttribute;
     108           0 :             return *this;
     109             :         }
     110             : 
     111           0 :         bool LineStartEndAttribute::operator==(const LineStartEndAttribute& rCandidate) const
     112             :         {
     113             :             // tdf#87509 default attr is always != non-default attr, even with same values
     114           0 :             if(rCandidate.isDefault() != isDefault())
     115           0 :                 return false;
     116             : 
     117           0 :             return rCandidate.mpLineStartEndAttribute == mpLineStartEndAttribute;
     118             :         }
     119             : 
     120        2255 :         double LineStartEndAttribute::getWidth() const
     121             :         {
     122        2255 :             return mpLineStartEndAttribute->getWidth();
     123             :         }
     124             : 
     125        3083 :         const basegfx::B2DPolyPolygon& LineStartEndAttribute::getB2DPolyPolygon() const
     126             :         {
     127        3083 :             return mpLineStartEndAttribute->getB2DPolyPolygon();
     128             :         }
     129             : 
     130         351 :         bool LineStartEndAttribute::isCentered() const
     131             :         {
     132         351 :             return mpLineStartEndAttribute->isCentered();
     133             :         }
     134             : 
     135        1654 :         bool LineStartEndAttribute::isActive() const
     136             :         {
     137        1654 :             return (0.0 != getWidth()
     138        1651 :                 && 0 != getB2DPolyPolygon().count()
     139        4389 :                 && 0 != getB2DPolyPolygon().getB2DPolygon(0).count());
     140             :         }
     141             :     } // end of namespace attribute
     142             : } // end of namespace drawinglayer
     143             : 
     144             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11