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

Generated by: LCOV version 1.10