LCOV - code coverage report
Current view: top level - drawinglayer/source/attribute - strokeattribute.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 38 38 100.0 %
Date: 2014-11-03 Functions: 16 16 100.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/strokeattribute.hxx>
      21             : #include <rtl/instance.hxx>
      22             : #include <numeric>
      23             : 
      24             : 
      25             : 
      26             : namespace drawinglayer
      27             : {
      28             :     namespace attribute
      29             :     {
      30      109548 :         class ImpStrokeAttribute
      31             :         {
      32             :         public:
      33             :             // data definitions
      34             :             ::std::vector< double >                     maDotDashArray;         // array of double which defines the dot-dash pattern
      35             :             double                                      mfFullDotDashLen;       // sum of maDotDashArray (for convenience)
      36             : 
      37       36773 :             ImpStrokeAttribute(
      38             :                 const ::std::vector< double >& rDotDashArray,
      39             :                 double fFullDotDashLen)
      40             :             :   maDotDashArray(rDotDashArray),
      41       36773 :                 mfFullDotDashLen(fFullDotDashLen)
      42             :             {
      43       36773 :             }
      44             : 
      45         107 :             ImpStrokeAttribute()
      46             :             :   maDotDashArray(std::vector< double >()),
      47         107 :                 mfFullDotDashLen(0.0)
      48             :             {
      49         107 :             }
      50             : 
      51             :             // data read access
      52        6698 :             const ::std::vector< double >& getDotDashArray() const { return maDotDashArray; }
      53       36329 :             double getFullDotDashLen() const
      54             :             {
      55       36329 :                 if(0.0 == mfFullDotDashLen && maDotDashArray.size())
      56             :                 {
      57             :                     // calculate length on demand
      58         252 :                     const double fAccumulated(::std::accumulate(maDotDashArray.begin(), maDotDashArray.end(), 0.0));
      59         252 :                     const_cast< ImpStrokeAttribute* >(this)->mfFullDotDashLen = fAccumulated;
      60             :                 }
      61             : 
      62       36329 :                 return mfFullDotDashLen;
      63             :             }
      64             : 
      65          40 :             bool operator==(const ImpStrokeAttribute& rCandidate) const
      66             :             {
      67          40 :                 return (getDotDashArray() == rCandidate.getDotDashArray()
      68          40 :                     && getFullDotDashLen() == rCandidate.getFullDotDashLen());
      69             :             }
      70             :         };
      71             : 
      72             :         namespace
      73             :         {
      74             :             struct theGlobalDefault :
      75             :                 public rtl::Static< StrokeAttribute::ImplType, theGlobalDefault > {};
      76             :         }
      77             : 
      78       36773 :         StrokeAttribute::StrokeAttribute(
      79             :             const ::std::vector< double >& rDotDashArray,
      80             :             double fFullDotDashLen)
      81             :         :   mpStrokeAttribute(ImpStrokeAttribute(
      82       36773 :                 rDotDashArray, fFullDotDashLen))
      83             :         {
      84       36773 :         }
      85             : 
      86        5487 :         StrokeAttribute::StrokeAttribute()
      87        5487 :         :   mpStrokeAttribute(theGlobalDefault::get())
      88             :         {
      89        5487 :         }
      90             : 
      91       42293 :         StrokeAttribute::StrokeAttribute(const StrokeAttribute& rCandidate)
      92       42293 :         :   mpStrokeAttribute(rCandidate.mpStrokeAttribute)
      93             :         {
      94       42293 :         }
      95             : 
      96       83675 :         StrokeAttribute::~StrokeAttribute()
      97             :         {
      98       83675 :         }
      99             : 
     100       28223 :         bool StrokeAttribute::isDefault() const
     101             :         {
     102       28223 :             return mpStrokeAttribute.same_object(theGlobalDefault::get());
     103             :         }
     104             : 
     105         309 :         StrokeAttribute& StrokeAttribute::operator=(const StrokeAttribute& rCandidate)
     106             :         {
     107         309 :             mpStrokeAttribute = rCandidate.mpStrokeAttribute;
     108         309 :             return *this;
     109             :         }
     110             : 
     111          46 :         bool StrokeAttribute::operator==(const StrokeAttribute& rCandidate) const
     112             :         {
     113          46 :             return rCandidate.mpStrokeAttribute == mpStrokeAttribute;
     114             :         }
     115             : 
     116        6618 :         const ::std::vector< double >& StrokeAttribute::getDotDashArray() const
     117             :         {
     118        6618 :             return mpStrokeAttribute->getDotDashArray();
     119             :         }
     120             : 
     121       36249 :         double StrokeAttribute::getFullDotDashLen() const
     122             :         {
     123       36249 :             return mpStrokeAttribute->getFullDotDashLen();
     124             :         }
     125             :     } // end of namespace attribute
     126             : } // end of namespace drawinglayer
     127             : 
     128             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10