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

Generated by: LCOV version 1.10