LCOV - code coverage report
Current view: top level - svgio/source/svgreader - svgdocument.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 29 34 85.3 %
Date: 2014-11-03 Functions: 7 8 87.5 %
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/svgdocument.hxx>
      21             : 
      22             : namespace svgio
      23             : {
      24             :     namespace svgreader
      25             :     {
      26         300 :         SvgDocument::SvgDocument(const OUString& rAbsolutePath)
      27             :         :   maNodes(),
      28             :             maAbsolutePath(rAbsolutePath),
      29             :             maIdTokenMapperList(),
      30         300 :             maIdStyleTokenMapperList()
      31             :         {
      32         300 :         }
      33             : 
      34         600 :         SvgDocument::~SvgDocument()
      35             :         {
      36         900 :             while(!maNodes.empty())
      37             :             {
      38         300 :                 SvgNode* pCandidate = maNodes[maNodes.size() - 1];
      39         300 :                 delete pCandidate;
      40         300 :                 maNodes.pop_back();
      41             :             }
      42         300 :         }
      43             : 
      44         300 :         void SvgDocument::appendNode(SvgNode* pNode)
      45             :         {
      46             :             OSL_ENSURE(pNode, "OOps, empty node added (!)");
      47         300 :             maNodes.push_back(pNode);
      48         300 :         }
      49             : 
      50        2308 :         void SvgDocument::addSvgNodeToMapper(const OUString& rStr, const SvgNode& rNode)
      51             :         {
      52        2308 :             if(!rStr.isEmpty())
      53             :             {
      54        2308 :                 maIdTokenMapperList.insert(IdTokenValueType(rStr, &rNode));
      55             :             }
      56        2308 :         }
      57             : 
      58           0 :         void SvgDocument::removeSvgNodeFromMapper(const OUString& rStr)
      59             :         {
      60           0 :             if(!rStr.isEmpty())
      61             :             {
      62           0 :                 maIdTokenMapperList.erase(rStr);
      63             :             }
      64           0 :         }
      65             : 
      66        1785 :         const SvgNode* SvgDocument::findSvgNodeById(const OUString& rStr) const
      67             :         {
      68        1785 :             const IdTokenMapper::const_iterator aResult(maIdTokenMapperList.find(rStr));
      69             : 
      70        1785 :             if(aResult == maIdTokenMapperList.end())
      71             :             {
      72           0 :                 return 0;
      73             :             }
      74             :             else
      75             :             {
      76        1785 :                 return aResult->second;
      77             :             }
      78             :         }
      79             : 
      80           4 :         void SvgDocument::addSvgStyleAttributesToMapper(const OUString& rStr, const SvgStyleAttributes& rSvgStyleAttributes)
      81             :         {
      82           4 :             if(!rStr.isEmpty())
      83             :             {
      84           4 :                 maIdStyleTokenMapperList.insert(IdStyleTokenValueType(rStr, &rSvgStyleAttributes));
      85             :             }
      86           4 :         }
      87             : 
      88       10075 :         const SvgStyleAttributes* SvgDocument::findGlobalCssStyleAttributes(const OUString& rStr) const
      89             :         {
      90       10075 :             const IdStyleTokenMapper::const_iterator aResult(maIdStyleTokenMapperList.find(rStr));
      91             : 
      92       10075 :             if(aResult == maIdStyleTokenMapperList.end())
      93             :             {
      94       10069 :                 return 0;
      95             :             }
      96             :             else
      97             :             {
      98           6 :                 return aResult->second;
      99             :             }
     100             :         }
     101             : 
     102             :     } // end of namespace svgreader
     103             : } // end of namespace svgio
     104             : 
     105             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10