LCOV - code coverage report
Current view: top level - svgio/source/svgreader - svgpathnode.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 31 39 79.5 %
Date: 2015-06-13 12:38:46 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        1819 :         SvgPathNode::SvgPathNode(
      28             :             SvgDocument& rDocument,
      29             :             SvgNode* pParent)
      30             :         :   SvgNode(SVGTokenPath, rDocument, pParent),
      31             :             maSvgStyleAttributes(*this),
      32             :             mpPolyPolygon(0),
      33             :             mpaTransform(0),
      34        1819 :             maPathLength()
      35             :         {
      36        1819 :         }
      37             : 
      38        5457 :         SvgPathNode::~SvgPathNode()
      39             :         {
      40        1819 :             if(mpPolyPolygon) delete mpPolyPolygon;
      41        1819 :             if(mpaTransform) delete mpaTransform;
      42        3638 :         }
      43             : 
      44        3575 :         const SvgStyleAttributes* SvgPathNode::getSvgStyleAttributes() const
      45             :         {
      46        3575 :             return checkForCssStyle(OUString("path"), maSvgStyleAttributes);
      47             :         }
      48             : 
      49        4366 :         void SvgPathNode::parseAttribute(const OUString& rTokenName, SVGToken aSVGToken, const OUString& aContent)
      50             :         {
      51             :             // call parent
      52        4366 :             SvgNode::parseAttribute(rTokenName, aSVGToken, aContent);
      53             : 
      54             :             // read style attributes
      55        4366 :             maSvgStyleAttributes.parseStyleAttribute(rTokenName, aSVGToken, aContent, false);
      56             : 
      57             :             // parse own
      58        4366 :             switch(aSVGToken)
      59             :             {
      60             :                 case SVGTokenStyle:
      61             :                 {
      62          64 :                     readLocalCssStyle(aContent);
      63          64 :                     break;
      64             :                 }
      65             :                 case SVGTokenD:
      66             :                 {
      67        1819 :                     basegfx::B2DPolyPolygon aPath;
      68             : 
      69        1819 :                     if(basegfx::tools::importFromSvgD(aPath, aContent, false, &maHelpPointIndices))
      70             :                     {
      71        1819 :                         if(aPath.count())
      72             :                         {
      73        1819 :                             setPath(&aPath);
      74             :                         }
      75             :                     }
      76        1819 :                     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        2483 :                     break;
     101             :                 }
     102             :             }
     103        4366 :         }
     104             : 
     105        1823 :         void SvgPathNode::decomposeSvgNode(drawinglayer::primitive2d::Primitive2DSequence& rTarget, bool /*bReferenced*/) const
     106             :         {
     107             :             // fill and/or stroke needed, also a path
     108        1823 :             const SvgStyleAttributes* pStyle = getSvgStyleAttributes();
     109             : 
     110        1823 :             if(pStyle && getPath())
     111             :             {
     112        1823 :                 drawinglayer::primitive2d::Primitive2DSequence aNewTarget;
     113             : 
     114        1823 :                 pStyle->add_path(*getPath(), aNewTarget, &maHelpPointIndices);
     115             : 
     116        1823 :                 if(aNewTarget.hasElements())
     117             :                 {
     118        1823 :                     pStyle->add_postProcess(rTarget, aNewTarget, getTransform());
     119        1823 :                 }
     120             :             }
     121        1823 :         }
     122             :     } // end of namespace svgreader
     123             : } // end of namespace svgio
     124             : 
     125             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11