LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/chart2/source/tools - NameContainer.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 13 60 21.7 %
Date: 2013-07-09 Functions: 5 17 29.4 %
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             : 
      21             : #include "NameContainer.hxx"
      22             : 
      23             : #include <com/sun/star/uno/Any.hxx>
      24             : 
      25             : using namespace ::com::sun::star;
      26             : using ::com::sun::star::uno::Sequence;
      27             : using ::com::sun::star::uno::Any;
      28             : 
      29             : 
      30             : //.............................................................................
      31             : namespace chart
      32             : {
      33             : //.............................................................................
      34             : 
      35          89 : uno::Reference< container::XNameContainer > createNameContainer(
      36             :         const ::com::sun::star::uno::Type& rType, const OUString& rServicename, const OUString& rImplementationName )
      37             : {
      38          89 :     return new NameContainer( rType, rServicename, rImplementationName );
      39             : }
      40             : 
      41          89 : NameContainer::NameContainer( const ::com::sun::star::uno::Type& rType, const OUString& rServicename, const OUString& rImplementationName )
      42             :     : m_aType( rType )
      43             :     , m_aServicename( rServicename )
      44             :     , m_aImplementationName( rImplementationName )
      45          89 :     , m_aMap()
      46             : {
      47          89 : }
      48             : 
      49           0 : NameContainer::NameContainer(
      50             :     const NameContainer & rOther )
      51             :     : impl::NameContainer_Base()
      52             :     , m_aType( rOther.m_aType )
      53             :     , m_aServicename( rOther.m_aServicename )
      54             :     , m_aImplementationName( rOther.m_aImplementationName )
      55           0 :     , m_aMap( rOther.m_aMap )
      56             : {
      57           0 : }
      58             : 
      59         178 : NameContainer::~NameContainer()
      60             : {
      61         178 : }
      62             : 
      63             : //XServiceInfo
      64           0 : OUString SAL_CALL NameContainer::getImplementationName()
      65             :     throw( ::com::sun::star::uno::RuntimeException )
      66             : {
      67           0 :     return m_aImplementationName;
      68             : }
      69             : 
      70           0 : sal_Bool SAL_CALL NameContainer::supportsService( const OUString& ServiceName )
      71             :     throw( ::com::sun::star::uno::RuntimeException )
      72             : {
      73           0 :     Sequence< OUString > aSNL = getSupportedServiceNames();
      74           0 :     const OUString* pArray = aSNL.getArray();
      75           0 :     for( sal_Int32 i = 0; i < aSNL.getLength(); i++ )
      76             :     {
      77           0 :         if( pArray[ i ] == ServiceName )
      78           0 :             return sal_True;
      79             :     }
      80           0 :     return sal_False;
      81             : }
      82             : 
      83           0 : Sequence< OUString > SAL_CALL NameContainer::getSupportedServiceNames()
      84             :     throw( ::com::sun::star::uno::RuntimeException )
      85             : {
      86           0 :     Sequence< OUString > aSNS( 1 );
      87           0 :     aSNS.getArray()[ 0 ] = m_aServicename;
      88           0 :     return aSNS;
      89             : }
      90             : 
      91             : //-----------------------------------------------------------------
      92             : //-----------------------------------------------------------------
      93             : //-----------------------------------------------------------------
      94             : 
      95             : // XNameContainer
      96           0 : void SAL_CALL NameContainer::insertByName( const OUString& rName, const Any& rElement )
      97             :     throw( lang::IllegalArgumentException, container::ElementExistException, lang::WrappedTargetException, uno::RuntimeException )
      98             : {
      99           0 :     if( m_aMap.find( rName ) != m_aMap.end() )
     100           0 :         throw container::ElementExistException();
     101           0 :     m_aMap.insert( tContentMap::value_type( rName, rElement ));
     102           0 : }
     103             : 
     104             : 
     105             : 
     106           0 : void SAL_CALL NameContainer::removeByName( const OUString& Name )
     107             :     throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
     108             : {
     109           0 :     tContentMap::iterator aIt( m_aMap.find( Name ));
     110           0 :     if( aIt == m_aMap.end())
     111           0 :         throw container::NoSuchElementException();
     112           0 :     m_aMap.erase( aIt );
     113           0 : }
     114             : 
     115             : // XNameReplace
     116           0 : void SAL_CALL NameContainer::replaceByName( const OUString& rName, const Any& rElement )
     117             :     throw( lang::IllegalArgumentException, container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException )
     118             : {
     119           0 :     tContentMap::iterator aIt( m_aMap.find( rName ));
     120           0 :     if( aIt == m_aMap.end() )
     121           0 :         throw container::NoSuchElementException();
     122           0 :     aIt->second = rElement;
     123           0 : }
     124             : 
     125             : // XNameAccess
     126           0 : Any SAL_CALL NameContainer::getByName( const OUString& rName )
     127             :     throw( container::NoSuchElementException,  lang::WrappedTargetException, uno::RuntimeException)
     128             : {
     129           0 :     tContentMap::iterator aIter( m_aMap.find( rName ) );
     130           0 :     if( aIter == m_aMap.end() )
     131           0 :         throw container::NoSuchElementException();
     132           0 :     return aIter->second;
     133             : }
     134             : 
     135          15 : Sequence< OUString > SAL_CALL NameContainer::getElementNames()
     136             :     throw( uno::RuntimeException )
     137             : {
     138          15 :     sal_Int32 nCount = m_aMap.size();
     139          15 :     Sequence< OUString > aSeq(nCount);
     140          15 :     sal_Int32 nN = 0;
     141          15 :     for( tContentMap::iterator aIter = m_aMap.begin(); aIter != m_aMap.end() && nN < nCount; ++aIter, ++nN )
     142           0 :         aSeq[nN]=aIter->first;
     143          15 :     return aSeq;
     144             : }
     145             : 
     146           0 : sal_Bool SAL_CALL NameContainer::hasByName( const OUString& rName )
     147             :     throw( uno::RuntimeException )
     148             : {
     149           0 :     return ( m_aMap.find( rName ) != m_aMap.end() );
     150             : }
     151             : 
     152             : // XElementAccess
     153           0 : sal_Bool SAL_CALL NameContainer::hasElements()
     154             :     throw( uno::RuntimeException )
     155             : {
     156           0 :     return ! m_aMap.empty();
     157             : }
     158             : 
     159           0 : uno::Type SAL_CALL NameContainer::getElementType()
     160             :     throw( uno::RuntimeException )
     161             : {
     162           0 :     return m_aType;
     163             : }
     164             : 
     165             : // XCloneable
     166           0 : uno::Reference< util::XCloneable > SAL_CALL NameContainer::createClone()
     167             :     throw ( uno::RuntimeException )
     168             : {
     169           0 :     return uno::Reference< util::XCloneable >( new NameContainer( *this ));
     170             : }
     171             : 
     172             : //.............................................................................
     173             : } //namespace chart
     174             : //.............................................................................
     175             : 
     176             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10