LCOV - code coverage report
Current view: top level - svgio/source/svgreader - svggnode.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 31 31 100.0 %
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/svggnode.hxx>
      21             : #include <drawinglayer/primitive2d/transformprimitive2d.hxx>
      22             : #include <drawinglayer/primitive2d/unifiedtransparenceprimitive2d.hxx>
      23             : 
      24             : 
      25             : 
      26             : namespace svgio
      27             : {
      28             :     namespace svgreader
      29             :     {
      30        2155 :         SvgGNode::SvgGNode(
      31             :             SVGToken aType,
      32             :             SvgDocument& rDocument,
      33             :             SvgNode* pParent)
      34             :         :   SvgNode(aType, rDocument, pParent),
      35             :             maSvgStyleAttributes(*this),
      36        2155 :             mpaTransform(0)
      37             :         {
      38             :             OSL_ENSURE(aType == SVGTokenDefs || aType == SVGTokenG, "SvgGNode should ony be used for Group and Defs (!)");
      39        2155 :         }
      40             : 
      41        6465 :         SvgGNode::~SvgGNode()
      42             :         {
      43        2155 :             if(mpaTransform) delete mpaTransform;
      44        4310 :         }
      45             : 
      46       70158 :         const SvgStyleAttributes* SvgGNode::getSvgStyleAttributes() const
      47             :         {
      48       70158 :             return checkForCssStyle(OUString("g"), maSvgStyleAttributes);
      49             :         }
      50             : 
      51         540 :         void SvgGNode::parseAttribute(const OUString& rTokenName, SVGToken aSVGToken, const OUString& aContent)
      52             :         {
      53             :             // call parent
      54         540 :             SvgNode::parseAttribute(rTokenName, aSVGToken, aContent);
      55             : 
      56             :             // read style attributes
      57         540 :             maSvgStyleAttributes.parseStyleAttribute(rTokenName, aSVGToken, aContent);
      58             : 
      59             :             // parse own
      60         540 :             switch(aSVGToken)
      61             :             {
      62             :                 case SVGTokenStyle:
      63             :                 {
      64           7 :                     maSvgStyleAttributes.readStyle(aContent);
      65           7 :                     break;
      66             :                 }
      67             :                 case SVGTokenTransform:
      68             :                 {
      69          12 :                     const basegfx::B2DHomMatrix aMatrix(readTransform(aContent, *this));
      70             : 
      71          12 :                     if(!aMatrix.isIdentity())
      72             :                     {
      73          12 :                         setTransform(&aMatrix);
      74             :                     }
      75          12 :                     break;
      76             :                 }
      77             :                 default:
      78             :                 {
      79         521 :                     break;
      80             :                 }
      81             :             }
      82         540 :         }
      83             : 
      84        2122 :         void SvgGNode::decomposeSvgNode(drawinglayer::primitive2d::Primitive2DSequence& rTarget, bool bReferenced) const
      85             :         {
      86        2122 :             const SvgStyleAttributes* pStyle = getSvgStyleAttributes();
      87             : 
      88        2122 :             if(pStyle)
      89             :             {
      90        2122 :                 const double fOpacity(pStyle->getOpacity().getNumber());
      91             : 
      92        2122 :                 if(fOpacity > 0.0 && Display_none != getDisplay())
      93             :                 {
      94        2122 :                     drawinglayer::primitive2d::Primitive2DSequence aContent;
      95             : 
      96             :                     // decompose children
      97        2122 :                     SvgNode::decomposeSvgNode(aContent, bReferenced);
      98             : 
      99        2122 :                     if(aContent.hasElements())
     100             :                     {
     101        1795 :                         pStyle->add_postProcess(rTarget, aContent, getTransform());
     102        2122 :                     }
     103             :                 }
     104             :             }
     105        2122 :         }
     106             :     } // end of namespace svgreader
     107             : } // end of namespace svgio
     108             : 
     109             : 
     110             : // eof
     111             : 
     112             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10