LCOV - code coverage report
Current view: top level - svgio/source/svgreader - svggnode.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 35 35 100.0 %
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/svggnode.hxx>
      21             : #include <drawinglayer/primitive2d/transformprimitive2d.hxx>
      22             : #include <drawinglayer/primitive2d/unifiedtransparenceprimitive2d.hxx>
      23             : 
      24             : namespace svgio
      25             : {
      26             :     namespace svgreader
      27             :     {
      28        2157 :         SvgGNode::SvgGNode(
      29             :             SVGToken aType,
      30             :             SvgDocument& rDocument,
      31             :             SvgNode* pParent)
      32             :         :   SvgNode(aType, rDocument, pParent),
      33             :             maSvgStyleAttributes(*this),
      34        2157 :             mpaTransform(0)
      35             :         {
      36             :             OSL_ENSURE(aType == SVGTokenDefs || aType == SVGTokenG, "SvgGNode should ony be used for Group and Defs (!)");
      37        2157 :         }
      38             : 
      39        6471 :         SvgGNode::~SvgGNode()
      40             :         {
      41        2157 :             if(mpaTransform) delete mpaTransform;
      42        4314 :         }
      43             : 
      44       74738 :         const SvgStyleAttributes* SvgGNode::getSvgStyleAttributes() const
      45             :         {
      46       74738 :             if (SVGTokenDefs == getType())
      47             :             {
      48             :                 // #i125258# call parent for SVGTokenDefs
      49         390 :                 return SvgNode::getSvgStyleAttributes();
      50             :             }
      51             :             else
      52             :             {
      53             :                 // #i125258# for SVGTokenG take CssStyles into account
      54       74348 :                 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        1918 :         void SvgGNode::decomposeSvgNode(drawinglayer::primitive2d::Primitive2DSequence& rTarget, bool bReferenced) const
      92             :         {
      93        1918 :             if(SVGTokenDefs == getType())
      94             :             {
      95             :                 // #i125258# no decompose needed for defs element, call parent for SVGTokenDefs
      96          94 :                 SvgNode::decomposeSvgNode(rTarget, bReferenced);
      97             :             }
      98             :             else
      99             :             {
     100             :                 // #i125258# for SVGTokenG decompose children
     101        1824 :                 const SvgStyleAttributes* pStyle = getSvgStyleAttributes();
     102             : 
     103        1824 :                 if(pStyle)
     104             :                 {
     105        1824 :                     const double fOpacity(pStyle->getOpacity().getNumber());
     106             : 
     107        1824 :                     if(fOpacity > 0.0 && Display_none != getDisplay())
     108             :                     {
     109        1824 :                         drawinglayer::primitive2d::Primitive2DSequence aContent;
     110             : 
     111             :                         // decompose children
     112        1824 :                         SvgNode::decomposeSvgNode(aContent, bReferenced);
     113             : 
     114        1824 :                         if(aContent.hasElements())
     115             :                         {
     116        1793 :                             pStyle->add_postProcess(rTarget, aContent, getTransform());
     117        1824 :                         }
     118             :                     }
     119             :                 }
     120             :             }
     121        1918 :         }
     122             :     } // end of namespace svgreader
     123             : } // end of namespace svgio
     124             : 
     125             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11