LCOV - code coverage report
Current view: top level - xmloff/source/transform - MutableAttrList.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 65 0.0 %
Date: 2014-04-14 Functions: 0 20 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 <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           0 : SvXMLAttributeList *XMLMutableAttributeList::GetMutableAttrList()
      35             : {
      36           0 :     if( !m_pMutableAttrList )
      37             :     {
      38           0 :         m_pMutableAttrList = new SvXMLAttributeList( m_xAttrList );
      39           0 :         m_xAttrList = m_pMutableAttrList;
      40             :     }
      41             : 
      42           0 :     return m_pMutableAttrList;
      43             : }
      44             : 
      45           0 : XMLMutableAttributeList::XMLMutableAttributeList() :
      46           0 :     m_pMutableAttrList( new SvXMLAttributeList )
      47             : {
      48           0 :     m_xAttrList = m_pMutableAttrList;
      49           0 : }
      50             : 
      51           0 : XMLMutableAttributeList::XMLMutableAttributeList( const Reference<
      52             :         XAttributeList> & rAttrList, sal_Bool bClone ) :
      53           0 :     m_xAttrList( rAttrList.is() ? rAttrList : new SvXMLAttributeList ),
      54           0 :     m_pMutableAttrList( 0 )
      55             : {
      56           0 :     if( bClone )
      57           0 :         GetMutableAttrList();
      58           0 : }
      59             : 
      60             : 
      61           0 : XMLMutableAttributeList::~XMLMutableAttributeList()
      62             : {
      63           0 :     m_xAttrList = 0;
      64           0 : }
      65             : 
      66             : namespace
      67             : {
      68             :     class theXMLMutableAttributeListUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theXMLMutableAttributeListUnoTunnelId> {};
      69             : }
      70             : 
      71             : // XUnoTunnel & co
      72           0 : const Sequence< sal_Int8 > & XMLMutableAttributeList::getUnoTunnelId() throw()
      73             : {
      74           0 :     return theXMLMutableAttributeListUnoTunnelId::get().getSeq();
      75             : }
      76             : 
      77             : // XUnoTunnel
      78           0 : sal_Int64 SAL_CALL XMLMutableAttributeList::getSomething(
      79             :         const Sequence< sal_Int8 >& rId )
      80             :     throw( RuntimeException, std::exception )
      81             : {
      82           0 :     if( rId.getLength() == 16 &&
      83           0 :         0 == memcmp( getUnoTunnelId().getConstArray(),
      84           0 :                                 rId.getConstArray(), 16 ) )
      85             :     {
      86           0 :         return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_uIntPtr>(this));
      87             :     }
      88           0 :     return 0;
      89             : }
      90             : 
      91           0 : sal_Int16 SAL_CALL XMLMutableAttributeList::getLength(void)
      92             :         throw( RuntimeException, std::exception )
      93             : {
      94           0 :     return m_xAttrList->getLength();
      95             : }
      96             : 
      97             : 
      98           0 : OUString SAL_CALL XMLMutableAttributeList::getNameByIndex(sal_Int16 i)
      99             :         throw( RuntimeException, std::exception )
     100             : {
     101           0 :     return m_xAttrList->getNameByIndex( i );
     102             : }
     103             : 
     104             : 
     105           0 : OUString SAL_CALL XMLMutableAttributeList::getTypeByIndex(sal_Int16 i)
     106             :         throw( RuntimeException, std::exception )
     107             : {
     108           0 :     return m_xAttrList->getTypeByIndex( i );
     109             : }
     110             : 
     111           0 : OUString SAL_CALL  XMLMutableAttributeList::getValueByIndex(sal_Int16 i)
     112             :     throw( RuntimeException, std::exception )
     113             : {
     114           0 :     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           0 : OUString SAL_CALL XMLMutableAttributeList::getValueByName(
     125             :         const OUString& rName)
     126             :         throw( RuntimeException, std::exception )
     127             : {
     128           0 :     return m_xAttrList->getValueByName( rName );
     129             : }
     130             : 
     131             : 
     132           0 : Reference< XCloneable > XMLMutableAttributeList::createClone()
     133             :         throw( RuntimeException, std::exception )
     134             : {
     135             :     // A cloned list will be a read only list!
     136           0 :     Reference< XCloneable >  r = new SvXMLAttributeList( m_xAttrList );
     137           0 :     return r;
     138             : }
     139             : 
     140           0 : void XMLMutableAttributeList::SetValueByIndex( sal_Int16 i,
     141             :                                                const OUString& rValue )
     142             : {
     143           0 :     GetMutableAttrList()->SetValueByIndex( i, rValue );
     144           0 : }
     145             : 
     146           0 : void XMLMutableAttributeList::AddAttribute( const OUString &rName ,
     147             :                                             const OUString &rValue )
     148             : {
     149           0 :     GetMutableAttrList()->AddAttribute( rName, rValue );
     150           0 : }
     151             : 
     152           0 : void XMLMutableAttributeList::RemoveAttributeByIndex( sal_Int16 i )
     153             : {
     154           0 :     GetMutableAttrList()->RemoveAttributeByIndex( i );
     155           0 : }
     156             : 
     157           0 : void XMLMutableAttributeList::RenameAttributeByIndex( sal_Int16 i,
     158             :                                                       const OUString& rNewName )
     159             : {
     160           0 :     GetMutableAttrList()->RenameAttributeByIndex( i, rNewName );
     161           0 : }
     162             : 
     163           0 : void XMLMutableAttributeList::AppendAttributeList(
     164             :         const Reference< ::com::sun::star::xml::sax::XAttributeList >& r )
     165             : {
     166           0 :     GetMutableAttrList()->AppendAttributeList( r );
     167           0 : }
     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