LCOV - code coverage report
Current view: top level - svgio/source/svgreader - svgpolynode.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 33 37 89.2 %
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/svgpolynode.hxx>
      21             : #include <basegfx/polygon/b2dpolygon.hxx>
      22             : #include <basegfx/polygon/b2dpolypolygontools.hxx>
      23             : #include <basegfx/polygon/b2dpolygontools.hxx>
      24             : 
      25             : namespace svgio
      26             : {
      27             :     namespace svgreader
      28             :     {
      29         710 :         SvgPolyNode::SvgPolyNode(
      30             :             SvgDocument& rDocument,
      31             :             SvgNode* pParent,
      32             :             bool bIsPolyline)
      33             :         :   SvgNode(SVGTokenPolygon, rDocument, pParent),
      34             :             maSvgStyleAttributes(*this),
      35             :             mpPolygon(0),
      36             :             mpaTransform(0),
      37         710 :             mbIsPolyline(bIsPolyline)
      38             :         {
      39         710 :         }
      40             : 
      41        2130 :         SvgPolyNode::~SvgPolyNode()
      42             :         {
      43         710 :             if(mpaTransform) delete mpaTransform;
      44         710 :             if(mpPolygon) delete mpPolygon;
      45        1420 :         }
      46             : 
      47        1390 :         const SvgStyleAttributes* SvgPolyNode::getSvgStyleAttributes() const
      48             :         {
      49        1390 :             return checkForCssStyle(mbIsPolyline? OUString("polyline") : OUString("polygon"), maSvgStyleAttributes);
      50             :         }
      51             : 
      52        1650 :         void SvgPolyNode::parseAttribute(const OUString& rTokenName, SVGToken aSVGToken, const OUString& aContent)
      53             :         {
      54             :             // call parent
      55        1650 :             SvgNode::parseAttribute(rTokenName, aSVGToken, aContent);
      56             : 
      57             :             // read style attributes
      58        1650 :             maSvgStyleAttributes.parseStyleAttribute(rTokenName, aSVGToken, aContent, false);
      59             : 
      60             :             // parse own
      61        1650 :             switch(aSVGToken)
      62             :             {
      63             :                 case SVGTokenStyle:
      64             :                 {
      65          27 :                     readLocalCssStyle(aContent);
      66          27 :                     break;
      67             :                 }
      68             :                 case SVGTokenPoints:
      69             :                 {
      70         710 :                     basegfx::B2DPolygon aPath;
      71             : 
      72         710 :                     if(basegfx::tools::importFromSvgPoints(aPath, aContent))
      73             :                     {
      74         710 :                         if(aPath.count())
      75             :                         {
      76         710 :                             if(!isPolyline())
      77             :                             {
      78         673 :                                 aPath.setClosed(true);
      79             :                             }
      80             : 
      81         710 :                             setPolygon(&aPath);
      82             :                         }
      83             :                     }
      84         710 :                     break;
      85             :                 }
      86             :                 case SVGTokenTransform:
      87             :                 {
      88           0 :                     const basegfx::B2DHomMatrix aMatrix(readTransform(aContent, *this));
      89             : 
      90           0 :                     if(!aMatrix.isIdentity())
      91             :                     {
      92           0 :                         setTransform(&aMatrix);
      93             :                     }
      94           0 :                     break;
      95             :                 }
      96             :                 default:
      97             :                 {
      98         913 :                     break;
      99             :                 }
     100             :             }
     101        1650 :         }
     102             : 
     103         698 :         void SvgPolyNode::decomposeSvgNode(drawinglayer::primitive2d::Primitive2DSequence& rTarget, bool /*bReferenced*/) const
     104             :         {
     105         698 :             const SvgStyleAttributes* pStyle = getSvgStyleAttributes();
     106             : 
     107         698 :             if(pStyle && getPolygon())
     108             :             {
     109         698 :                 drawinglayer::primitive2d::Primitive2DSequence aNewTarget;
     110             : 
     111         698 :                 pStyle->add_path(basegfx::B2DPolyPolygon(*getPolygon()), aNewTarget, 0);
     112             : 
     113         698 :                 if(aNewTarget.hasElements())
     114             :                 {
     115         697 :                     pStyle->add_postProcess(rTarget, aNewTarget, getTransform());
     116         698 :                 }
     117             :             }
     118         698 :         }
     119             :     } // end of namespace svgreader
     120             : } // end of namespace svgio
     121             : 
     122             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11