LCOV - code coverage report
Current view: top level - xmloff/source/transform - MutableAttrList.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 53 65 81.5 %
Date: 2014-11-03 Functions: 18 20 90.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 <string.h>
      21             : 
      22             : #include <osl/mutex.hxx>
      23             : #include <xmloff/xmltoken.hxx>
      24             : #include <xmloff/attrlist.hxx>
      25             : #include <comphelper/servicehelper.hxx>
      26             : #include "MutableAttrList.hxx"
      27             : 
      28             : 
      29             : using namespace ::osl;
      30             : using namespace ::com::sun::star::uno;
      31             : using namespace ::com::sun::star::lang;
      32             : using namespace ::com::sun::star::util;
      33             : 
      34        6406 : SvXMLAttributeList *XMLMutableAttributeList::GetMutableAttrList()
      35             : {
      36        6406 :     if( !m_pMutableAttrList )
      37             :     {
      38        1202 :         m_pMutableAttrList = new SvXMLAttributeList( m_xAttrList );
      39        1202 :         m_xAttrList = m_pMutableAttrList;
      40             :     }
      41             : 
      42        6406 :     return m_pMutableAttrList;
      43             : }
      44             : 
      45         618 : XMLMutableAttributeList::XMLMutableAttributeList() :
      46         618 :     m_pMutableAttrList( new SvXMLAttributeList )
      47             : {
      48         618 :     m_xAttrList = m_pMutableAttrList;
      49         618 : }
      50             : 
      51        1798 : XMLMutableAttributeList::XMLMutableAttributeList( const Reference<
      52             :         XAttributeList> & rAttrList, bool bClone ) :
      53        1798 :     m_xAttrList( rAttrList.is() ? rAttrList : new SvXMLAttributeList ),
      54        3596 :     m_pMutableAttrList( 0 )
      55             : {
      56        1798 :     if( bClone )
      57         318 :         GetMutableAttrList();
      58        1798 : }
      59             : 
      60             : 
      61        7248 : XMLMutableAttributeList::~XMLMutableAttributeList()
      62             : {
      63        2416 :     m_xAttrList = 0;
      64        4832 : }
      65             : 
      66             : namespace
      67             : {
      68             :     class theXMLMutableAttributeListUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theXMLMutableAttributeListUnoTunnelId> {};
      69             : }
      70             : 
      71             : // XUnoTunnel & co
      72         154 : const Sequence< sal_Int8 > & XMLMutableAttributeList::getUnoTunnelId() throw()
      73             : {
      74         154 :     return theXMLMutableAttributeListUnoTunnelId::get().getSeq();
      75             : }
      76             : 
      77             : // XUnoTunnel
      78         154 : sal_Int64 SAL_CALL XMLMutableAttributeList::getSomething(
      79             :         const Sequence< sal_Int8 >& rId )
      80             :     throw( RuntimeException, std::exception )
      81             : {
      82         308 :     if( rId.getLength() == 16 &&
      83         154 :         0 == memcmp( getUnoTunnelId().getConstArray(),
      84         308 :                                 rId.getConstArray(), 16 ) )
      85             :     {
      86           0 :         return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_uIntPtr>(this));
      87             :     }
      88         154 :     return 0;
      89             : }
      90             : 
      91        6604 : sal_Int16 SAL_CALL XMLMutableAttributeList::getLength(void)
      92             :         throw( RuntimeException, std::exception )
      93             : {
      94        6604 :     return m_xAttrList->getLength();
      95             : }
      96             : 
      97             : 
      98       25696 : OUString SAL_CALL XMLMutableAttributeList::getNameByIndex(sal_Int16 i)
      99             :         throw( RuntimeException, std::exception )
     100             : {
     101       25696 :     return m_xAttrList->getNameByIndex( i );
     102             : }
     103             : 
     104             : 
     105        1436 : OUString SAL_CALL XMLMutableAttributeList::getTypeByIndex(sal_Int16 i)
     106             :         throw( RuntimeException, std::exception )
     107             : {
     108        1436 :     return m_xAttrList->getTypeByIndex( i );
     109             : }
     110             : 
     111       17568 : OUString SAL_CALL  XMLMutableAttributeList::getValueByIndex(sal_Int16 i)
     112             :     throw( RuntimeException, std::exception )
     113             : {
     114       17568 :     return m_xAttrList->getValueByIndex( i );
     115             : }
     116             : 
     117           0 : OUString SAL_CALL XMLMutableAttributeList::getTypeByName(
     118             :         const OUString& rName )
     119             :         throw( RuntimeException, std::exception )
     120             : {
     121           0 :     return m_xAttrList->getTypeByName( rName );
     122             : }
     123             : 
     124          58 : OUString SAL_CALL XMLMutableAttributeList::getValueByName(
     125             :         const OUString& rName)
     126             :         throw( RuntimeException, std::exception )
     127             : {
     128          58 :     return m_xAttrList->getValueByName( rName );
     129             : }
     130             : 
     131             : 
     132          10 : Reference< XCloneable > XMLMutableAttributeList::createClone()
     133             :         throw( RuntimeException, std::exception )
     134             : {
     135             :     // A cloned list will be a read only list!
     136          10 :     Reference< XCloneable >  r = new SvXMLAttributeList( m_xAttrList );
     137          10 :     return r;
     138             : }
     139             : 
     140        1230 : void XMLMutableAttributeList::SetValueByIndex( sal_Int16 i,
     141             :                                                const OUString& rValue )
     142             : {
     143        1230 :     GetMutableAttrList()->SetValueByIndex( i, rValue );
     144        1230 : }
     145             : 
     146        4032 : void XMLMutableAttributeList::AddAttribute( const OUString &rName ,
     147             :                                             const OUString &rValue )
     148             : {
     149        4032 :     GetMutableAttrList()->AddAttribute( rName, rValue );
     150        4032 : }
     151             : 
     152         134 : void XMLMutableAttributeList::RemoveAttributeByIndex( sal_Int16 i )
     153             : {
     154         134 :     GetMutableAttrList()->RemoveAttributeByIndex( i );
     155         134 : }
     156             : 
     157         646 : void XMLMutableAttributeList::RenameAttributeByIndex( sal_Int16 i,
     158             :                                                       const OUString& rNewName )
     159             : {
     160         646 :     GetMutableAttrList()->RenameAttributeByIndex( i, rNewName );
     161         646 : }
     162             : 
     163          46 : void XMLMutableAttributeList::AppendAttributeList(
     164             :         const Reference< ::com::sun::star::xml::sax::XAttributeList >& r )
     165             : {
     166          46 :     GetMutableAttrList()->AppendAttributeList( r );
     167          46 : }
     168             : 
     169           0 : sal_Int16 XMLMutableAttributeList::GetIndexByName( const OUString& rName ) const
     170             : {
     171           0 :     sal_Int16 nIndex = -1;
     172           0 :     if( m_pMutableAttrList )
     173             :     {
     174           0 :         nIndex = m_pMutableAttrList->GetIndexByName( rName );
     175             :     }
     176             :     else
     177             :     {
     178           0 :         sal_Int16 nCount = m_xAttrList->getLength();
     179           0 :         for( sal_Int16 i=0; nIndex==-1 && i<nCount ; ++i )
     180             :         {
     181           0 :             if( m_xAttrList->getNameByIndex(i) == rName )
     182           0 :                 nIndex = i;
     183             :         }
     184             :     }
     185           0 :     return nIndex;
     186             : }
     187             : 
     188             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10