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

Generated by: LCOV version 1.10