LCOV - code coverage report
Current view: top level - libreoffice/svgio/source/svgreader - svgpathnode.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 40 0.0 %
Date: 2012-12-27 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/svgpathnode.hxx>
      21             : #include <basegfx/polygon/b2dpolypolygontools.hxx>
      22             : 
      23             : //////////////////////////////////////////////////////////////////////////////
      24             : 
      25             : namespace svgio
      26             : {
      27             :     namespace svgreader
      28             :     {
      29           0 :         SvgPathNode::SvgPathNode(
      30             :             SvgDocument& rDocument,
      31             :             SvgNode* pParent)
      32             :         :   SvgNode(SVGTokenPath, rDocument, pParent),
      33             :             maSvgStyleAttributes(*this),
      34             :             mpPolyPolygon(0),
      35             :             mpaTransform(0),
      36           0 :             maPathLength()
      37             :         {
      38           0 :         }
      39             : 
      40           0 :         SvgPathNode::~SvgPathNode()
      41             :         {
      42           0 :             if(mpPolyPolygon) delete mpPolyPolygon;
      43           0 :             if(mpaTransform) delete mpaTransform;
      44           0 :         }
      45             : 
      46           0 :         const SvgStyleAttributes* SvgPathNode::getSvgStyleAttributes() const
      47             :         {
      48           0 :             static rtl::OUString aClassStr(rtl::OUString::createFromAscii("path"));
      49           0 :             maSvgStyleAttributes.checkForCssStyle(aClassStr);
      50             : 
      51           0 :             return &maSvgStyleAttributes;
      52             :         }
      53             : 
      54           0 :         void SvgPathNode::parseAttribute(const rtl::OUString& rTokenName, SVGToken aSVGToken, const rtl::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 SVGTokenD:
      71             :                 {
      72           0 :                     basegfx::B2DPolyPolygon aPath;
      73             : 
      74           0 :                     if(basegfx::tools::importFromSvgD(aPath, aContent))
      75             :                     {
      76           0 :                         if(aPath.count())
      77             :                         {
      78           0 :                             setPath(&aPath);
      79             :                         }
      80             :                     }
      81           0 :                     break;
      82             :                 }
      83             :                 case SVGTokenTransform:
      84             :                 {
      85           0 :                     const basegfx::B2DHomMatrix aMatrix(readTransform(aContent, *this));
      86             : 
      87           0 :                     if(!aMatrix.isIdentity())
      88             :                     {
      89           0 :                         setTransform(&aMatrix);
      90             :                     }
      91           0 :                     break;
      92             :                 }
      93             :                 case SVGTokenPathLength:
      94             :                 {
      95           0 :                     SvgNumber aNum;
      96             : 
      97           0 :                     if(readSingleNumber(aContent, aNum))
      98             :                     {
      99           0 :                         setPathLength(aNum);
     100             :                     }
     101             :                     break;
     102             :                 }
     103             :                 default:
     104             :                 {
     105           0 :                     break;
     106             :                 }
     107             :             }
     108           0 :         }
     109             : 
     110           0 :         void SvgPathNode::decomposeSvgNode(drawinglayer::primitive2d::Primitive2DSequence& rTarget, bool /*bReferenced*/) const
     111             :         {
     112             :             // fill and/or stroke needed, also a path
     113           0 :             const SvgStyleAttributes* pStyle = getSvgStyleAttributes();
     114             : 
     115           0 :             if(pStyle && getPath())
     116             :             {
     117           0 :                 drawinglayer::primitive2d::Primitive2DSequence aNewTarget;
     118             : 
     119           0 :                 pStyle->add_path(*getPath(), aNewTarget);
     120             : 
     121           0 :                 if(aNewTarget.hasElements())
     122             :                 {
     123           0 :                     pStyle->add_postProcess(rTarget, aNewTarget, getTransform());
     124           0 :                 }
     125             :             }
     126           0 :         }
     127             :     } // end of namespace svgreader
     128             : } // end of namespace svgio
     129             : 
     130             : //////////////////////////////////////////////////////////////////////////////
     131             : // eof
     132             : 
     133             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10