LCOV - code coverage report
Current view: top level - drawinglayer/source/attribute - linestartendattribute.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 30 42 71.4 %
Date: 2014-11-03 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        4742 :         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        1572 :             ImpLineStartEndAttribute(
      42             :                 double fWidth,
      43             :                 const basegfx::B2DPolyPolygon& rPolyPolygon,
      44             :                 bool bCentered)
      45             :             :   mfWidth(fWidth),
      46             :                 maPolyPolygon(rPolyPolygon),
      47        1572 :                 mbCentered(bCentered)
      48             :             {
      49        1572 :             }
      50             : 
      51          26 :             ImpLineStartEndAttribute()
      52             :             :   mfWidth(0.0),
      53             :                 maPolyPolygon(basegfx::B2DPolyPolygon()),
      54          26 :                 mbCentered(false)
      55             :             {
      56          26 :             }
      57             : 
      58             :             // data read access
      59        4344 :             double getWidth() const { return mfWidth; }
      60        6114 :             const basegfx::B2DPolyPolygon& getB2DPolyPolygon() const { return maPolyPolygon; }
      61         536 :             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        1572 :         LineStartEndAttribute::LineStartEndAttribute(
      78             :             double fWidth,
      79             :             const basegfx::B2DPolyPolygon& rPolyPolygon,
      80             :             bool bCentered)
      81             :         :   mpLineStartEndAttribute(ImpLineStartEndAttribute(
      82        1572 :                 fWidth, rPolyPolygon, bCentered))
      83             :         {
      84        1572 :         }
      85             : 
      86           0 :         LineStartEndAttribute::LineStartEndAttribute()
      87           0 :         :   mpLineStartEndAttribute(theGlobalDefault::get())
      88             :         {
      89           0 :         }
      90             : 
      91        1572 :         LineStartEndAttribute::LineStartEndAttribute(const LineStartEndAttribute& rCandidate)
      92        1572 :         :   mpLineStartEndAttribute(rCandidate.mpLineStartEndAttribute)
      93             :         {
      94        1572 :         }
      95             : 
      96        3144 :         LineStartEndAttribute::~LineStartEndAttribute()
      97             :         {
      98        3144 :         }
      99             : 
     100         576 :         bool LineStartEndAttribute::isDefault() const
     101             :         {
     102         576 :             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           0 :             return rCandidate.mpLineStartEndAttribute == mpLineStartEndAttribute;
     114             :         }
     115             : 
     116        4344 :         double LineStartEndAttribute::getWidth() const
     117             :         {
     118        4344 :             return mpLineStartEndAttribute->getWidth();
     119             :         }
     120             : 
     121        6114 :         const basegfx::B2DPolyPolygon& LineStartEndAttribute::getB2DPolyPolygon() const
     122             :         {
     123        6114 :             return mpLineStartEndAttribute->getB2DPolyPolygon();
     124             :         }
     125             : 
     126         536 :         bool LineStartEndAttribute::isCentered() const
     127             :         {
     128         536 :             return mpLineStartEndAttribute->isCentered();
     129             :         }
     130             : 
     131        3448 :         bool LineStartEndAttribute::isActive() const
     132             :         {
     133        3448 :             return (0.0 != getWidth()
     134        3442 :                 && 0 != getB2DPolyPolygon().count()
     135        9032 :                 && 0 != getB2DPolyPolygon().getB2DPolygon(0).count());
     136             :         }
     137             :     } // end of namespace attribute
     138             : } // end of namespace drawinglayer
     139             : 
     140             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10