LCOV - code coverage report
Current view: top level - svgio/source/svgreader - svgdocument.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 29 34 85.3 %
Date: 2015-06-13 12:38:46 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         299 :         SvgDocument::SvgDocument(const OUString& rAbsolutePath)
      27             :         :   maNodes(),
      28             :             maAbsolutePath(rAbsolutePath),
      29             :             maIdTokenMapperList(),
      30         299 :             maIdStyleTokenMapperList()
      31             :         {
      32         299 :         }
      33             : 
      34         598 :         SvgDocument::~SvgDocument()
      35             :         {
      36         897 :             while(!maNodes.empty())
      37             :             {
      38         299 :                 SvgNode* pCandidate = maNodes[maNodes.size() - 1];
      39         299 :                 delete pCandidate;
      40         299 :                 maNodes.pop_back();
      41             :             }
      42         299 :         }
      43             : 
      44         299 :         void SvgDocument::appendNode(SvgNode* pNode)
      45             :         {
      46             :             OSL_ENSURE(pNode, "OOps, empty node added (!)");
      47         299 :             maNodes.push_back(pNode);
      48         299 :         }
      49             : 
      50        2311 :         void SvgDocument::addSvgNodeToMapper(const OUString& rStr, const SvgNode& rNode)
      51             :         {
      52        2311 :             if(!rStr.isEmpty())
      53             :             {
      54        2311 :                 maIdTokenMapperList.insert(IdTokenValueType(rStr, &rNode));
      55             :             }
      56        2311 :         }
      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           2 :         void SvgDocument::addSvgStyleAttributesToMapper(const OUString& rStr, const SvgStyleAttributes& rSvgStyleAttributes)
      81             :         {
      82           2 :             if(!rStr.isEmpty())
      83             :             {
      84           2 :                 maIdStyleTokenMapperList.insert(IdStyleTokenValueType(rStr, &rSvgStyleAttributes));
      85             :             }
      86           2 :         }
      87             : 
      88       10064 :         const SvgStyleAttributes* SvgDocument::findGlobalCssStyleAttributes(const OUString& rStr) const
      89             :         {
      90       10064 :             const IdStyleTokenMapper::const_iterator aResult(maIdStyleTokenMapperList.find(rStr));
      91             : 
      92       10064 :             if(aResult == maIdStyleTokenMapperList.end())
      93             :             {
      94       10061 :                 return 0;
      95             :             }
      96             :             else
      97             :             {
      98           3 :                 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.11