LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/xmloff/source/core - SvXMLAttrCollection.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 34 69 49.3 %
Date: 2013-07-09 Functions: 10 18 55.6 %
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             : 
      10             : #include "SvXMLAttrCollection.hxx"
      11             : #include <limits.h>   //USHRT_MAX
      12             : 
      13        3603 : bool SvXMLAttrCollection::operator ==( const SvXMLAttrCollection& rCmp ) const
      14             : {
      15        6466 :     return (rCmp.aNamespaceMap == aNamespaceMap) &&
      16        6466 :            (rCmp.aAttrs == aAttrs);
      17             : }
      18             : 
      19           5 : sal_Bool SvXMLAttrCollection::AddAttr( const OUString& rLName,
      20             :                                        const OUString& rValue )
      21             : {
      22           5 :     aAttrs.push_back( SvXMLAttr(rLName, rValue) );
      23           5 :     return sal_True;
      24             : }
      25             : 
      26           8 : sal_Bool SvXMLAttrCollection::AddAttr( const OUString& rPrefix,
      27             :                                        const OUString& rNamespace,
      28             :                                        const OUString& rLName,
      29             :                                        const OUString& rValue )
      30             : {
      31           8 :     sal_uInt16 nPos = aNamespaceMap.Add( rPrefix, rNamespace );
      32           8 :     aAttrs.push_back( SvXMLAttr(nPos, rLName, rValue) );
      33           8 :     return sal_True;
      34             : }
      35             : 
      36           0 : sal_Bool SvXMLAttrCollection::AddAttr( const OUString& rPrefix,
      37             :                                        const OUString& rLName,
      38             :                                        const OUString& rValue )
      39             : {
      40           0 :     sal_uInt16 nPos = aNamespaceMap.GetIndexByPrefix( rPrefix );
      41           0 :     if( USHRT_MAX == nPos )
      42           0 :         return sal_False;
      43           0 :     aAttrs.push_back( SvXMLAttr(nPos, rLName, rValue) );
      44           0 :     return sal_True;
      45             : }
      46             : 
      47           0 : sal_Bool SvXMLAttrCollection::SetAt( size_t i,
      48             :                                      const OUString& rLName,
      49             :                                      const OUString& rValue )
      50             : {
      51           0 :     if( i >= GetAttrCount() )
      52           0 :         return sal_False;
      53           0 :     aAttrs[i] = SvXMLAttr(rLName, rValue);
      54           0 :     return sal_True;
      55             : }
      56             : 
      57           0 : sal_Bool SvXMLAttrCollection::SetAt( size_t i,
      58             :                                      const OUString& rPrefix,
      59             :                                      const OUString& rNamespace,
      60             :                                      const OUString& rLName,
      61             :                                      const OUString& rValue )
      62             : {
      63           0 :     if( i >= GetAttrCount() )
      64           0 :         return sal_False;
      65             : 
      66           0 :     sal_uInt16 nPos = aNamespaceMap.Add( rPrefix, rNamespace );
      67           0 :     if( USHRT_MAX == nPos )
      68           0 :         return sal_False;
      69             : 
      70           0 :     aAttrs[i] = SvXMLAttr(nPos, rLName, rValue);
      71           0 :     return sal_True;
      72             : }
      73             : 
      74           0 : sal_Bool SvXMLAttrCollection::SetAt( size_t i,
      75             :                                      const OUString& rPrefix,
      76             :                                      const OUString& rLName,
      77             :                                      const OUString& rValue )
      78             : {
      79           0 :     if( i >= GetAttrCount() )
      80           0 :         return sal_False;
      81             : 
      82           0 :     sal_uInt16 nPos = aNamespaceMap.GetIndexByPrefix( rPrefix );
      83           0 :     if( USHRT_MAX == nPos )
      84           0 :         return sal_False;
      85             : 
      86           0 :     aAttrs[i] = SvXMLAttr(nPos, rLName, rValue);
      87           0 :     return sal_True;
      88             : }
      89             : 
      90           4 : void SvXMLAttrCollection::Remove( size_t i )
      91             : {
      92           4 :     if( i < GetAttrCount() )
      93             :     {
      94           4 :         aAttrs.erase( aAttrs.begin() + i );
      95             :     }
      96             :     else
      97             :     {
      98             :         OSL_FAIL( "illegal index" );
      99             :     }
     100           4 : }
     101             : 
     102         130 : size_t SvXMLAttrCollection::GetAttrCount() const
     103             : {
     104         130 :     return aAttrs.size();
     105             : }
     106             : 
     107          68 : const OUString& SvXMLAttrCollection::GetAttrLName(size_t i) const
     108             : {
     109             :     OSL_ENSURE( i < aAttrs.size(), "SvXMLAttrContainerData::GetLName: illegal index" );
     110          68 :     return aAttrs[i].getLName();
     111             : }
     112             : 
     113          22 : const OUString& SvXMLAttrCollection::GetAttrValue(size_t i) const
     114             : {
     115             :     OSL_ENSURE( i < aAttrs.size(), "SvXMLAttrContainerData::GetValue: illegal index" );
     116          22 :     return aAttrs[i].getValue();
     117             : }
     118             : 
     119          22 : const OUString SvXMLAttrCollection::GetAttrNamespace( size_t i ) const
     120             : {
     121          22 :     OUString sRet;
     122          22 :     sal_uInt16 nPos = GetPrefixPos( i );
     123             :     //Does this point to a valid namespace entry?
     124          22 :     if( USHRT_MAX != nPos )
     125           8 :         sRet = aNamespaceMap.GetNameByIndex( nPos );
     126          22 :     return sRet;
     127             : }
     128             : 
     129          60 : const OUString SvXMLAttrCollection::GetAttrPrefix( size_t i ) const
     130             : {
     131          60 :     OUString sRet;
     132          60 :     sal_uInt16 nPos = GetPrefixPos( i );
     133             :     //Does this point to a valid namespace entry?
     134          60 :     if( USHRT_MAX != nPos )
     135          24 :         sRet = aNamespaceMap.GetPrefixByIndex( nPos );
     136          60 :     return sRet;
     137             : }
     138             : 
     139           0 : const OUString& SvXMLAttrCollection::GetNamespace( sal_uInt16 i ) const
     140             : {
     141           0 :     return aNamespaceMap.GetNameByIndex( i );
     142             : }
     143             : 
     144           0 : const OUString& SvXMLAttrCollection::GetPrefix( sal_uInt16 i ) const
     145             : {
     146           0 :     return aNamespaceMap.GetPrefixByIndex( i );
     147             : }
     148             : 
     149           0 : sal_uInt16 SvXMLAttrCollection::GetFirstNamespaceIndex() const
     150             : {
     151           0 :     return aNamespaceMap.GetFirstIndex();
     152             : }
     153             : 
     154           0 : sal_uInt16 SvXMLAttrCollection::GetNextNamespaceIndex( sal_uInt16 nIdx ) const
     155             : {
     156           0 :     return aNamespaceMap.GetNextIndex( nIdx );
     157             : }
     158             : 
     159          82 : sal_uInt16 SvXMLAttrCollection::GetPrefixPos( size_t i ) const
     160             : {
     161             : //  DBG_ASSERT( i >= 0 && i < aAttrs.size(),
     162             : //              "SvXMLAttrCollection::GetPrefixPos: illegal index" );
     163          82 :     return aAttrs[i].getPrefixPos();
     164             : }
     165             : 
     166             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
     167             : 

Generated by: LCOV version 1.10