LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/xmlscript/source/xml_helper - xml_element.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 27 36 75.0 %
Date: 2013-07-09 Functions: 8 11 72.7 %
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 <xmlscript/xml_helper.hxx>
      21             : 
      22             : 
      23             : using namespace com::sun::star;
      24             : using namespace com::sun::star::uno;
      25             : 
      26             : namespace xmlscript
      27             : {
      28             : 
      29             : //__________________________________________________________________________________________________
      30         144 : void XMLElement::addAttribute( OUString const & rAttrName, OUString const & rValue )
      31             :     SAL_THROW(())
      32             : {
      33         144 :     _attrNames.push_back( rAttrName );
      34         144 :     _attrValues.push_back( rValue );
      35         144 : }
      36             : //__________________________________________________________________________________________________
      37          12 : void XMLElement::addSubElement( Reference< xml::sax::XAttributeList > const & xElem )
      38             :     SAL_THROW(())
      39             : {
      40          12 :     _subElems.push_back( xElem );
      41          12 : }
      42             : //__________________________________________________________________________________________________
      43           0 : Reference< xml::sax::XAttributeList > XMLElement::getSubElement( sal_Int32 nIndex )
      44             :     SAL_THROW(())
      45             : {
      46           0 :     return _subElems[ (size_t)nIndex ];
      47             : }
      48             : //__________________________________________________________________________________________________
      49          24 : void XMLElement::dumpSubElements( Reference< xml::sax::XDocumentHandler > const & xOut )
      50             : {
      51          36 :     for ( size_t nPos = 0; nPos < _subElems.size(); ++nPos )
      52             :     {
      53          12 :         XMLElement * pElem = static_cast< XMLElement * >( _subElems[ nPos ].get() );
      54          12 :         pElem->dump( xOut );
      55             :     }
      56          24 : }
      57             : //__________________________________________________________________________________________________
      58          20 : void XMLElement::dump( Reference< xml::sax::XDocumentHandler > const & xOut )
      59             : {
      60          20 :     xOut->ignorableWhitespace( OUString() );
      61          20 :     xOut->startElement( _name, static_cast< xml::sax::XAttributeList * >( this ) );
      62             :     // write sub elements
      63          20 :     dumpSubElements( xOut );
      64          20 :     xOut->ignorableWhitespace( OUString() );
      65          20 :     xOut->endElement( _name );
      66          20 : }
      67             : 
      68             : // XAttributeList
      69             : //__________________________________________________________________________________________________
      70          35 : sal_Int16 XMLElement::getLength()
      71             :     throw (RuntimeException)
      72             : {
      73          35 :     return static_cast<sal_Int16>(_attrNames.size());
      74             : }
      75             : //__________________________________________________________________________________________________
      76         154 : OUString XMLElement::getNameByIndex( sal_Int16 nPos )
      77             :     throw (RuntimeException)
      78             : {
      79             :     OSL_ASSERT( (size_t)nPos < _attrNames.size() );
      80         154 :     return _attrNames[ nPos ];
      81             : }
      82             : //__________________________________________________________________________________________________
      83           8 : OUString XMLElement::getTypeByIndex( sal_Int16 nPos )
      84             :     throw (RuntimeException)
      85             : {
      86             :     OSL_ASSERT( (size_t)nPos < _attrNames.size() );
      87             :     static_cast<void>(nPos);
      88             :     // xxx todo
      89           8 :     return OUString();
      90             : }
      91             : //__________________________________________________________________________________________________
      92           0 : OUString XMLElement::getTypeByName( OUString const & /*rName*/ )
      93             :     throw (RuntimeException)
      94             : {
      95             :     // xxx todo
      96           0 :     return OUString();
      97             : }
      98             : //__________________________________________________________________________________________________
      99         154 : OUString XMLElement::getValueByIndex( sal_Int16 nPos )
     100             :     throw (RuntimeException)
     101             : {
     102             :     OSL_ASSERT( (size_t)nPos < _attrNames.size() );
     103         154 :     return _attrValues[ nPos ];
     104             : }
     105             : //__________________________________________________________________________________________________
     106           0 : OUString XMLElement::getValueByName( OUString const & rName )
     107             :     throw (RuntimeException)
     108             : {
     109           0 :     for ( size_t nPos = 0; nPos < _attrNames.size(); ++nPos )
     110             :     {
     111           0 :         if (_attrNames[ nPos ] == rName)
     112             :         {
     113           0 :             return _attrValues[ nPos ];
     114             :         }
     115             :     }
     116           0 :     return OUString();
     117             : }
     118             : 
     119             : }
     120             : 
     121             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10