LCOV - code coverage report
Current view: top level - xmloff/source/transform - MutableAttrList.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 53 65 81.5 %
Date: 2012-08-25 Functions: 18 20 90.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 19 50 38.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include <string.h>
      30                 :            : 
      31                 :            : #include <osl/mutex.hxx>
      32                 :            : #include <xmloff/xmltoken.hxx>
      33                 :            : #include <xmloff/attrlist.hxx>
      34                 :            : #include <comphelper/servicehelper.hxx>
      35                 :            : #include "MutableAttrList.hxx"
      36                 :            : 
      37                 :            : using ::rtl::OUString;
      38                 :            : 
      39                 :            : using namespace ::osl;
      40                 :            : using namespace ::com::sun::star::uno;
      41                 :            : using namespace ::com::sun::star::lang;
      42                 :            : using namespace ::com::sun::star::util;
      43                 :            : 
      44                 :      11149 : SvXMLAttributeList *XMLMutableAttributeList::GetMutableAttrList()
      45                 :            : {
      46         [ +  + ]:      11149 :     if( !m_pMutableAttrList )
      47                 :            :     {
      48         [ +  - ]:       1756 :         m_pMutableAttrList = new SvXMLAttributeList( m_xAttrList );
      49         [ +  - ]:       1756 :         m_xAttrList = m_pMutableAttrList;
      50                 :            :     }
      51                 :            : 
      52                 :      11149 :     return m_pMutableAttrList;
      53                 :            : }
      54                 :            : 
      55                 :       1352 : XMLMutableAttributeList::XMLMutableAttributeList() :
      56         [ +  - ]:       1352 :     m_pMutableAttrList( new SvXMLAttributeList )
      57                 :            : {
      58 [ +  - ][ +  - ]:       1352 :     m_xAttrList = m_pMutableAttrList;
      59                 :       1352 : }
      60                 :            : 
      61                 :       2589 : XMLMutableAttributeList::XMLMutableAttributeList( const Reference<
      62                 :            :         XAttributeList> & rAttrList, sal_Bool bClone ) :
      63 [ #  # ][ #  # ]:       2589 :     m_xAttrList( rAttrList.is() ? rAttrList : new SvXMLAttributeList ),
      64 [ +  - ][ #  # ]:       5178 :     m_pMutableAttrList( 0 )
      65                 :            : {
      66         [ +  + ]:       2589 :     if( bClone )
      67         [ +  - ]:        585 :         GetMutableAttrList();
      68                 :       2589 : }
      69                 :            : 
      70                 :            : 
      71                 :       3941 : XMLMutableAttributeList::~XMLMutableAttributeList()
      72                 :            : {
      73         [ +  - ]:       3941 :     m_xAttrList = 0;
      74         [ -  + ]:       7882 : }
      75                 :            : 
      76                 :            : namespace
      77                 :            : {
      78                 :            :     class theXMLMutableAttributeListUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theXMLMutableAttributeListUnoTunnelId> {};
      79                 :            : }
      80                 :            : 
      81                 :            : // XUnoTunnel & co
      82                 :        170 : const Sequence< sal_Int8 > & XMLMutableAttributeList::getUnoTunnelId() throw()
      83                 :            : {
      84                 :        170 :     return theXMLMutableAttributeListUnoTunnelId::get().getSeq();
      85                 :            : }
      86                 :            : 
      87                 :            : // XUnoTunnel
      88                 :        170 : sal_Int64 SAL_CALL XMLMutableAttributeList::getSomething(
      89                 :            :         const Sequence< sal_Int8 >& rId )
      90                 :            :     throw( RuntimeException )
      91                 :            : {
      92   [ +  -  -  + ]:        340 :     if( rId.getLength() == 16 &&
                 [ -  + ]
      93                 :        170 :         0 == memcmp( getUnoTunnelId().getConstArray(),
      94                 :        170 :                                 rId.getConstArray(), 16 ) )
      95                 :            :     {
      96                 :          0 :         return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_uIntPtr>(this));
      97                 :            :     }
      98                 :        170 :     return 0;
      99                 :            : }
     100                 :            : 
     101                 :       8861 : sal_Int16 SAL_CALL XMLMutableAttributeList::getLength(void)
     102                 :            :         throw( RuntimeException )
     103                 :            : {
     104                 :       8861 :     return m_xAttrList->getLength();
     105                 :            : }
     106                 :            : 
     107                 :            : 
     108                 :      37142 : OUString SAL_CALL XMLMutableAttributeList::getNameByIndex(sal_Int16 i)
     109                 :            :         throw( RuntimeException )
     110                 :            : {
     111                 :      37142 :     return m_xAttrList->getNameByIndex( i );
     112                 :            : }
     113                 :            : 
     114                 :            : 
     115                 :       1368 : OUString SAL_CALL XMLMutableAttributeList::getTypeByIndex(sal_Int16 i)
     116                 :            :         throw( RuntimeException )
     117                 :            : {
     118                 :       1368 :     return m_xAttrList->getTypeByIndex( i );
     119                 :            : }
     120                 :            : 
     121                 :      27375 : OUString SAL_CALL  XMLMutableAttributeList::getValueByIndex(sal_Int16 i)
     122                 :            :     throw( RuntimeException )
     123                 :            : {
     124                 :      27375 :     return m_xAttrList->getValueByIndex( i );
     125                 :            : }
     126                 :            : 
     127                 :          0 : OUString SAL_CALL XMLMutableAttributeList::getTypeByName(
     128                 :            :         const OUString& rName )
     129                 :            :         throw( RuntimeException )
     130                 :            : {
     131                 :          0 :     return m_xAttrList->getTypeByName( rName );
     132                 :            : }
     133                 :            : 
     134                 :         33 : OUString SAL_CALL XMLMutableAttributeList::getValueByName(
     135                 :            :         const OUString& rName)
     136                 :            :         throw( RuntimeException )
     137                 :            : {
     138                 :         33 :     return m_xAttrList->getValueByName( rName );
     139                 :            : }
     140                 :            : 
     141                 :            : 
     142                 :         17 : Reference< XCloneable > XMLMutableAttributeList::createClone()
     143                 :            :         throw( RuntimeException )
     144                 :            : {
     145                 :            :     // A cloned list will be a read only list!
     146 [ +  - ][ +  - ]:         17 :     Reference< XCloneable >  r = new SvXMLAttributeList( m_xAttrList );
                 [ +  - ]
     147                 :         17 :     return r;
     148                 :            : }
     149                 :            : 
     150                 :       1889 : void XMLMutableAttributeList::SetValueByIndex( sal_Int16 i,
     151                 :            :                                                const ::rtl::OUString& rValue )
     152                 :            : {
     153                 :       1889 :     GetMutableAttrList()->SetValueByIndex( i, rValue );
     154                 :       1889 : }
     155                 :            : 
     156                 :       7840 : void XMLMutableAttributeList::AddAttribute( const OUString &rName ,
     157                 :            :                                             const OUString &rValue )
     158                 :            : {
     159                 :       7840 :     GetMutableAttrList()->AddAttribute( rName, rValue );
     160                 :       7840 : }
     161                 :            : 
     162                 :        180 : void XMLMutableAttributeList::RemoveAttributeByIndex( sal_Int16 i )
     163                 :            : {
     164                 :        180 :     GetMutableAttrList()->RemoveAttributeByIndex( i );
     165                 :        180 : }
     166                 :            : 
     167                 :        617 : void XMLMutableAttributeList::RenameAttributeByIndex( sal_Int16 i,
     168                 :            :                                                       const OUString& rNewName )
     169                 :            : {
     170                 :        617 :     GetMutableAttrList()->RenameAttributeByIndex( i, rNewName );
     171                 :        617 : }
     172                 :            : 
     173                 :         38 : void XMLMutableAttributeList::AppendAttributeList(
     174                 :            :         const Reference< ::com::sun::star::xml::sax::XAttributeList >& r )
     175                 :            : {
     176                 :         38 :     GetMutableAttrList()->AppendAttributeList( r );
     177                 :         38 : }
     178                 :            : 
     179                 :          0 : sal_Int16 XMLMutableAttributeList::GetIndexByName( const OUString& rName ) const
     180                 :            : {
     181                 :          0 :     sal_Int16 nIndex = -1;
     182         [ #  # ]:          0 :     if( m_pMutableAttrList )
     183                 :            :     {
     184                 :          0 :         nIndex = m_pMutableAttrList->GetIndexByName( rName );
     185                 :            :     }
     186                 :            :     else
     187                 :            :     {
     188                 :          0 :         sal_Int16 nCount = m_xAttrList->getLength();
     189 [ #  # ][ #  # ]:          0 :         for( sal_Int16 i=0; nIndex==-1 && i<nCount ; ++i )
                 [ #  # ]
     190                 :            :         {
     191         [ #  # ]:          0 :             if( m_xAttrList->getNameByIndex(i) == rName )
     192                 :          0 :                 nIndex = i;
     193                 :            :         }
     194                 :            :     }
     195                 :          0 :     return nIndex;
     196                 :            : }
     197                 :            : 
     198                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10