LCOV - code coverage report
Current view: top level - svgio/source/svgreader - svggnode.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 34 35 97.1 %
Date: 2014-11-03 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             : namespace svgio
      25             : {
      26             :     namespace svgreader
      27             :     {
      28        2159 :         SvgGNode::SvgGNode(
      29             :             SVGToken aType,
      30             :             SvgDocument& rDocument,
      31             :             SvgNode* pParent)
      32             :         :   SvgNode(aType, rDocument, pParent),
      33             :             maSvgStyleAttributes(*this),
      34        2159 :             mpaTransform(0)
      35             :         {
      36             :             OSL_ENSURE(aType == SVGTokenDefs || aType == SVGTokenG, "SvgGNode should ony be used for Group and Defs (!)");
      37        2159 :         }
      38             : 
      39        6477 :         SvgGNode::~SvgGNode()
      40             :         {
      41        2159 :             if(mpaTransform) delete mpaTransform;
      42        4318 :         }
      43             : 
      44       72093 :         const SvgStyleAttributes* SvgGNode::getSvgStyleAttributes() const
      45             :         {
      46       72093 :             if (SVGTokenDefs == getType())
      47             :             {
      48             :                 // #i125258# call parent for SVGTokenDefs
      49         391 :                 return SvgNode::getSvgStyleAttributes();
      50             :             }
      51             :             else
      52             :             {
      53             :                 // #i125258# for SVGTokenG take CssStyles into account
      54       71702 :                 return checkForCssStyle(OUString("g"), maSvgStyleAttributes);
      55             :             }
      56             :         }
      57             : 
      58         540 :         void SvgGNode::parseAttribute(const OUString& rTokenName, SVGToken aSVGToken, const OUString& aContent)
      59             :         {
      60             :             // call parent
      61         540 :             SvgNode::parseAttribute(rTokenName, aSVGToken, aContent);
      62             : 
      63             :             // read style attributes
      64         540 :             maSvgStyleAttributes.parseStyleAttribute(rTokenName, aSVGToken, aContent, false);
      65             : 
      66             :             // parse own
      67         540 :             switch(aSVGToken)
      68             :             {
      69             :                 case SVGTokenStyle:
      70             :                 {
      71           7 :                     readLocalCssStyle(aContent);
      72           7 :                     break;
      73             :                 }
      74             :                 case SVGTokenTransform:
      75             :                 {
      76          12 :                     const basegfx::B2DHomMatrix aMatrix(readTransform(aContent, *this));
      77             : 
      78          12 :                     if(!aMatrix.isIdentity())
      79             :                     {
      80          12 :                         setTransform(&aMatrix);
      81             :                     }
      82          12 :                     break;
      83             :                 }
      84             :                 default:
      85             :                 {
      86         521 :                     break;
      87             :                 }
      88             :             }
      89         540 :         }
      90             : 
      91        1825 :         void SvgGNode::decomposeSvgNode(drawinglayer::primitive2d::Primitive2DSequence& rTarget, bool bReferenced) const
      92             :         {
      93        1825 :             if(SVGTokenDefs == getType())
      94             :             {
      95             :                 // #i125258# no decompose needed for defs element, call parent for SVGTokenDefs
      96           0 :                 SvgNode::decomposeSvgNode(rTarget, bReferenced);
      97             :             }
      98             :             else
      99             :             {
     100             :                 // #i125258# for SVGTokenG decompose children
     101        1825 :                 const SvgStyleAttributes* pStyle = getSvgStyleAttributes();
     102             : 
     103        1825 :                 if(pStyle)
     104             :                 {
     105        1825 :                     const double fOpacity(pStyle->getOpacity().getNumber());
     106             : 
     107        1825 :                     if(fOpacity > 0.0 && Display_none != getDisplay())
     108             :                     {
     109        1825 :                         drawinglayer::primitive2d::Primitive2DSequence aContent;
     110             : 
     111             :                         // decompose children
     112        1825 :                         SvgNode::decomposeSvgNode(aContent, bReferenced);
     113             : 
     114        1825 :                         if(aContent.hasElements())
     115             :                         {
     116        1794 :                             pStyle->add_postProcess(rTarget, aContent, getTransform());
     117        1825 :                         }
     118             :                     }
     119             :                 }
     120             :             }
     121        1825 :         }
     122             :     } // end of namespace svgreader
     123             : } // end of namespace svgio
     124             : 
     125             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10