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

Generated by: LCOV version 1.10