LCOV - code coverage report
Current view: top level - svgio/source/svgreader - svgpathnode.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 31 39 79.5 %
Date: 2014-11-03 Functions: 6 6 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 <svgio/svgreader/svgpathnode.hxx>
      21             : #include <basegfx/polygon/b2dpolypolygontools.hxx>
      22             : 
      23             : namespace svgio
      24             : {
      25             :     namespace svgreader
      26             :     {
      27        1816 :         SvgPathNode::SvgPathNode(
      28             :             SvgDocument& rDocument,
      29             :             SvgNode* pParent)
      30             :         :   SvgNode(SVGTokenPath, rDocument, pParent),
      31             :             maSvgStyleAttributes(*this),
      32             :             mpPolyPolygon(0),
      33             :             mpaTransform(0),
      34        1816 :             maPathLength()
      35             :         {
      36        1816 :         }
      37             : 
      38        5448 :         SvgPathNode::~SvgPathNode()
      39             :         {
      40        1816 :             if(mpPolyPolygon) delete mpPolyPolygon;
      41        1816 :             if(mpaTransform) delete mpaTransform;
      42        3632 :         }
      43             : 
      44        3569 :         const SvgStyleAttributes* SvgPathNode::getSvgStyleAttributes() const
      45             :         {
      46        3569 :             return checkForCssStyle(OUString("path"), maSvgStyleAttributes);
      47             :         }
      48             : 
      49        4360 :         void SvgPathNode::parseAttribute(const OUString& rTokenName, SVGToken aSVGToken, const OUString& aContent)
      50             :         {
      51             :             // call parent
      52        4360 :             SvgNode::parseAttribute(rTokenName, aSVGToken, aContent);
      53             : 
      54             :             // read style attributes
      55        4360 :             maSvgStyleAttributes.parseStyleAttribute(rTokenName, aSVGToken, aContent, false);
      56             : 
      57             :             // parse own
      58        4360 :             switch(aSVGToken)
      59             :             {
      60             :                 case SVGTokenStyle:
      61             :                 {
      62          64 :                     readLocalCssStyle(aContent);
      63          64 :                     break;
      64             :                 }
      65             :                 case SVGTokenD:
      66             :                 {
      67        1816 :                     basegfx::B2DPolyPolygon aPath;
      68             : 
      69        1816 :                     if(basegfx::tools::importFromSvgD(aPath, aContent, false, &maHelpPointIndices))
      70             :                     {
      71        1816 :                         if(aPath.count())
      72             :                         {
      73        1816 :                             setPath(&aPath);
      74             :                         }
      75             :                     }
      76        1816 :                     break;
      77             :                 }
      78             :                 case SVGTokenTransform:
      79             :                 {
      80           0 :                     const basegfx::B2DHomMatrix aMatrix(readTransform(aContent, *this));
      81             : 
      82           0 :                     if(!aMatrix.isIdentity())
      83             :                     {
      84           0 :                         setTransform(&aMatrix);
      85             :                     }
      86           0 :                     break;
      87             :                 }
      88             :                 case SVGTokenPathLength:
      89             :                 {
      90           0 :                     SvgNumber aNum;
      91             : 
      92           0 :                     if(readSingleNumber(aContent, aNum))
      93             :                     {
      94           0 :                         setPathLength(aNum);
      95             :                     }
      96           0 :                     break;
      97             :                 }
      98             :                 default:
      99             :                 {
     100        2480 :                     break;
     101             :                 }
     102             :             }
     103        4360 :         }
     104             : 
     105        1820 :         void SvgPathNode::decomposeSvgNode(drawinglayer::primitive2d::Primitive2DSequence& rTarget, bool /*bReferenced*/) const
     106             :         {
     107             :             // fill and/or stroke needed, also a path
     108        1820 :             const SvgStyleAttributes* pStyle = getSvgStyleAttributes();
     109             : 
     110        1820 :             if(pStyle && getPath())
     111             :             {
     112        1820 :                 drawinglayer::primitive2d::Primitive2DSequence aNewTarget;
     113             : 
     114        1820 :                 pStyle->add_path(*getPath(), aNewTarget, &maHelpPointIndices);
     115             : 
     116        1820 :                 if(aNewTarget.hasElements())
     117             :                 {
     118        1820 :                     pStyle->add_postProcess(rTarget, aNewTarget, getTransform());
     119        1820 :                 }
     120             :             }
     121        1820 :         }
     122             :     } // end of namespace svgreader
     123             : } // end of namespace svgio
     124             : 
     125             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10