LCOV - code coverage report
Current view: top level - xmloff/source/core - SvXMLAttrCollection.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 27 69 39.1 %
Date: 2012-08-25 Functions: 8 18 44.4 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 10 40 25.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*
       3                 :            :  * Version: MPL 1.1 / GPLv3+ / LGPLv3+
       4                 :            :  *
       5                 :            :  * The contents of this file are subject to the Mozilla Public License Version
       6                 :            :  * 1.1 (the "License"); you may not use this file except in compliance with
       7                 :            :  * the License or as specified alternatively below. You may obtain a copy of
       8                 :            :  * the License at http://www.mozilla.org/MPL/
       9                 :            :  *
      10                 :            :  * Software distributed under the License is distributed on an "AS IS" basis,
      11                 :            :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      12                 :            :  * for the specific language governing rights and limitations under the
      13                 :            :  * License.
      14                 :            :  *
      15                 :            :  * The Initial Developer of the Original Code is
      16                 :            :  *       Nigel Hawkins  - n.hawkins@gmx.com
      17                 :            :  * Portions created by the Initial Developer are Copyright (C) 2011 the
      18                 :            :  * Initial Developer. All Rights Reserved.
      19                 :            :  *
      20                 :            :  * Major Contributor(s):
      21                 :            :  *
      22                 :            :  * For minor contributions see the git repository.
      23                 :            :  *
      24                 :            :  * Alternatively, the contents of this file may be used under the terms of
      25                 :            :  * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
      26                 :            :  * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
      27                 :            :  * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
      28                 :            :  * instead of those above.
      29                 :            :  */
      30                 :            : 
      31                 :            : #include "SvXMLAttrCollection.hxx"
      32                 :            : #include <limits.h>   //USHRT_MAX
      33                 :            : 
      34                 :       7557 : bool SvXMLAttrCollection::operator ==( const SvXMLAttrCollection& rCmp ) const
      35                 :            : {
      36                 :       7557 :     return (rCmp.aNamespaceMap == aNamespaceMap) &&
      37 [ +  - ][ +  + ]:       7557 :            (rCmp.aAttrs == aAttrs);
      38                 :            : }
      39                 :            : 
      40                 :          0 : sal_Bool SvXMLAttrCollection::AddAttr( const rtl::OUString& rLName,
      41                 :            :                                        const rtl::OUString& rValue )
      42                 :            : {
      43         [ #  # ]:          0 :     aAttrs.push_back( SvXMLAttr(rLName, rValue) );
      44                 :          0 :     return sal_True;
      45                 :            : }
      46                 :            : 
      47                 :         16 : sal_Bool SvXMLAttrCollection::AddAttr( const rtl::OUString& rPrefix,
      48                 :            :                                        const rtl::OUString& rNamespace,
      49                 :            :                                        const rtl::OUString& rLName,
      50                 :            :                                        const rtl::OUString& rValue )
      51                 :            : {
      52                 :         16 :     sal_uInt16 nPos = aNamespaceMap.Add( rPrefix, rNamespace );
      53         [ +  - ]:         16 :     aAttrs.push_back( SvXMLAttr(nPos, rLName, rValue) );
      54                 :         16 :     return sal_True;
      55                 :            : }
      56                 :            : 
      57                 :          0 : sal_Bool SvXMLAttrCollection::AddAttr( const rtl::OUString& rPrefix,
      58                 :            :                                        const rtl::OUString& rLName,
      59                 :            :                                        const rtl::OUString& rValue )
      60                 :            : {
      61                 :          0 :     sal_uInt16 nPos = aNamespaceMap.GetIndexByPrefix( rPrefix );
      62         [ #  # ]:          0 :     if( USHRT_MAX == nPos )
      63                 :          0 :         return sal_False;
      64         [ #  # ]:          0 :     aAttrs.push_back( SvXMLAttr(nPos, rLName, rValue) );
      65                 :          0 :     return sal_True;
      66                 :            : }
      67                 :            : 
      68                 :          0 : sal_Bool SvXMLAttrCollection::SetAt( size_t i,
      69                 :            :                                      const rtl::OUString& rLName,
      70                 :            :                                      const rtl::OUString& rValue )
      71                 :            : {
      72         [ #  # ]:          0 :     if( i >= GetAttrCount() )
      73                 :          0 :         return sal_False;
      74                 :          0 :     aAttrs[i] = SvXMLAttr(rLName, rValue);
      75                 :          0 :     return sal_True;
      76                 :            : }
      77                 :            : 
      78                 :          0 : sal_Bool SvXMLAttrCollection::SetAt( size_t i,
      79                 :            :                                      const rtl::OUString& rPrefix,
      80                 :            :                                      const rtl::OUString& rNamespace,
      81                 :            :                                      const rtl::OUString& rLName,
      82                 :            :                                      const rtl::OUString& rValue )
      83                 :            : {
      84         [ #  # ]:          0 :     if( i >= GetAttrCount() )
      85                 :          0 :         return sal_False;
      86                 :            : 
      87                 :          0 :     sal_uInt16 nPos = aNamespaceMap.Add( rPrefix, rNamespace );
      88         [ #  # ]:          0 :     if( USHRT_MAX == nPos )
      89                 :          0 :         return sal_False;
      90                 :            : 
      91                 :          0 :     aAttrs[i] = SvXMLAttr(nPos, rLName, rValue);
      92                 :          0 :     return sal_True;
      93                 :            : }
      94                 :            : 
      95                 :          0 : sal_Bool SvXMLAttrCollection::SetAt( size_t i,
      96                 :            :                                      const rtl::OUString& rPrefix,
      97                 :            :                                      const rtl::OUString& rLName,
      98                 :            :                                      const rtl::OUString& rValue )
      99                 :            : {
     100         [ #  # ]:          0 :     if( i >= GetAttrCount() )
     101                 :          0 :         return sal_False;
     102                 :            : 
     103                 :          0 :     sal_uInt16 nPos = aNamespaceMap.GetIndexByPrefix( rPrefix );
     104         [ #  # ]:          0 :     if( USHRT_MAX == nPos )
     105                 :          0 :         return sal_False;
     106                 :            : 
     107                 :          0 :     aAttrs[i] = SvXMLAttr(nPos, rLName, rValue);
     108                 :          0 :     return sal_True;
     109                 :            : }
     110                 :            : 
     111                 :          0 : void SvXMLAttrCollection::Remove( size_t i )
     112                 :            : {
     113         [ #  # ]:          0 :     if( i < GetAttrCount() )
     114                 :            :     {
     115 [ #  # ][ #  # ]:          0 :         aAttrs.erase( aAttrs.begin() + i );
     116                 :            :     }
     117                 :            :     else
     118                 :            :     {
     119                 :            :         OSL_FAIL( "illegal index" );
     120                 :            :     }
     121                 :          0 : }
     122                 :            : 
     123                 :        151 : size_t SvXMLAttrCollection::GetAttrCount() const
     124                 :            : {
     125                 :        151 :     return aAttrs.size();
     126                 :            : }
     127                 :            : 
     128                 :         45 : const rtl::OUString& SvXMLAttrCollection::GetAttrLName(size_t i) const
     129                 :            : {
     130                 :            :     OSL_ENSURE( i < aAttrs.size(), "SvXMLAttrContainerData::GetLName: illegal index" );
     131                 :         45 :     return aAttrs[i].getLName();
     132                 :            : }
     133                 :            : 
     134                 :         15 : const rtl::OUString& SvXMLAttrCollection::GetAttrValue(size_t i) const
     135                 :            : {
     136                 :            :     OSL_ENSURE( i < aAttrs.size(), "SvXMLAttrContainerData::GetValue: illegal index" );
     137                 :         15 :     return aAttrs[i].getValue();
     138                 :            : }
     139                 :            : 
     140                 :         15 : const rtl::OUString SvXMLAttrCollection::GetAttrNamespace( size_t i ) const
     141                 :            : {
     142                 :         15 :     rtl::OUString sRet;
     143         [ +  - ]:         15 :     sal_uInt16 nPos = GetPrefixPos( i );
     144                 :            :     //Does this point to a valid namespace entry?
     145         [ +  - ]:         15 :     if( USHRT_MAX != nPos )
     146         [ +  - ]:         15 :         sRet = aNamespaceMap.GetNameByIndex( nPos );
     147                 :         15 :     return sRet;
     148                 :            : }
     149                 :            : 
     150                 :         45 : const rtl::OUString SvXMLAttrCollection::GetAttrPrefix( size_t i ) const
     151                 :            : {
     152                 :         45 :     rtl::OUString sRet;
     153         [ +  - ]:         45 :     sal_uInt16 nPos = GetPrefixPos( i );
     154                 :            :     //Does this point to a valid namespace entry?
     155         [ +  - ]:         45 :     if( USHRT_MAX != nPos )
     156         [ +  - ]:         45 :         sRet = aNamespaceMap.GetPrefixByIndex( nPos );
     157                 :         45 :     return sRet;
     158                 :            : }
     159                 :            : 
     160                 :          0 : const rtl::OUString& SvXMLAttrCollection::GetNamespace( sal_uInt16 i ) const
     161                 :            : {
     162                 :          0 :     return aNamespaceMap.GetNameByIndex( i );
     163                 :            : }
     164                 :            : 
     165                 :          0 : const rtl::OUString& SvXMLAttrCollection::GetPrefix( sal_uInt16 i ) const
     166                 :            : {
     167                 :          0 :     return aNamespaceMap.GetPrefixByIndex( i );
     168                 :            : }
     169                 :            : 
     170                 :          0 : sal_uInt16 SvXMLAttrCollection::GetFirstNamespaceIndex() const
     171                 :            : {
     172                 :          0 :     return aNamespaceMap.GetFirstIndex();
     173                 :            : }
     174                 :            : 
     175                 :          0 : sal_uInt16 SvXMLAttrCollection::GetNextNamespaceIndex( sal_uInt16 nIdx ) const
     176                 :            : {
     177                 :          0 :     return aNamespaceMap.GetNextIndex( nIdx );
     178                 :            : }
     179                 :            : 
     180                 :         60 : sal_uInt16 SvXMLAttrCollection::GetPrefixPos( size_t i ) const
     181                 :            : {
     182                 :            : //  DBG_ASSERT( i >= 0 && i < aAttrs.size(),
     183                 :            : //              "SvXMLAttrCollection::GetPrefixPos: illegal index" );
     184                 :         60 :     return aAttrs[i].getPrefixPos();
     185                 :            : }
     186                 :            : 
     187                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
     188                 :            : 

Generated by: LCOV version 1.10