LCOV - code coverage report
Current view: top level - libreoffice/framework/source/fwe/helper - propertysetcontainer.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 62 0.0 %
Date: 2012-12-27 Functions: 0 12 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 <helper/propertysetcontainer.hxx>
      21             : #include <threadhelp/resetableguard.hxx>
      22             : 
      23             : #include <vcl/svapp.hxx>
      24             : 
      25             : #define WRONG_TYPE_EXCEPTION    "Only XPropertSet allowed!"
      26             : 
      27             : using ::rtl::OUString;
      28             : using namespace cppu;
      29             : using namespace com::sun::star::uno;
      30             : using namespace com::sun::star::container;
      31             : using namespace com::sun::star::lang;
      32             : using namespace com::sun::star::beans;
      33             : 
      34             : namespace framework
      35             : {
      36             : 
      37           0 : PropertySetContainer::PropertySetContainer( const Reference< XMultiServiceFactory >& )
      38           0 :         :   ThreadHelpBase( &Application::GetSolarMutex() )
      39           0 :         ,   OWeakObject()
      40             : 
      41             : {
      42           0 : }
      43             : 
      44             : 
      45           0 : PropertySetContainer::~PropertySetContainer()
      46             : {
      47           0 : }
      48             : 
      49             : 
      50             : // XInterface
      51           0 : void SAL_CALL PropertySetContainer::acquire() throw ()
      52             : {
      53           0 :     OWeakObject::acquire();
      54           0 : }
      55             : 
      56           0 : void SAL_CALL PropertySetContainer::release() throw ()
      57             : {
      58           0 :     OWeakObject::release();
      59           0 : }
      60             : 
      61           0 : Any SAL_CALL PropertySetContainer::queryInterface( const Type& rType )
      62             : throw ( RuntimeException )
      63             : {
      64             :     Any a = ::cppu::queryInterface(
      65             :                 rType ,
      66             :                 (static_cast< XIndexContainer* >(this)),
      67             :                 (static_cast< XIndexReplace* >(this)),
      68             :                 (static_cast< XIndexAccess* >(this)),
      69           0 :                 (static_cast< XElementAccess* >(this)) );
      70             : 
      71           0 :     if( a.hasValue() )
      72             :     {
      73           0 :         return a;
      74             :     }
      75             : 
      76           0 :     return OWeakObject::queryInterface( rType );
      77             : }
      78             : 
      79             : // XIndexContainer
      80           0 : void SAL_CALL PropertySetContainer::insertByIndex( sal_Int32 Index, const ::com::sun::star::uno::Any& Element )
      81             :     throw ( IllegalArgumentException, IndexOutOfBoundsException, WrappedTargetException, RuntimeException )
      82             : {
      83           0 :     ResetableGuard aGuard( m_aLock );
      84             : 
      85           0 :     sal_Int32 nSize = m_aPropertySetVector.size();
      86             : 
      87           0 :     if ( nSize >= Index )
      88             :     {
      89           0 :         Reference< XPropertySet > aPropertySetElement;
      90             : 
      91           0 :         if ( Element >>= aPropertySetElement )
      92             :         {
      93           0 :             if ( nSize == Index )
      94           0 :                 m_aPropertySetVector.push_back( aPropertySetElement );
      95             :             else
      96             :             {
      97           0 :                 PropertySetVector::iterator aIter = m_aPropertySetVector.begin();
      98           0 :                 aIter += Index;
      99           0 :                 m_aPropertySetVector.insert( aIter, aPropertySetElement );
     100             :             }
     101             :         }
     102             :         else
     103             :         {
     104             :             throw IllegalArgumentException(
     105             :                 OUString( RTL_CONSTASCII_USTRINGPARAM( WRONG_TYPE_EXCEPTION )),
     106           0 :                 (OWeakObject *)this, 2 );
     107           0 :         }
     108             :     }
     109             :     else
     110           0 :         throw IndexOutOfBoundsException( OUString(), (OWeakObject *)this );
     111           0 : }
     112             : 
     113           0 : void SAL_CALL PropertySetContainer::removeByIndex( sal_Int32 Index )
     114             :     throw ( IndexOutOfBoundsException, WrappedTargetException, RuntimeException )
     115             : {
     116           0 :     ResetableGuard aGuard( m_aLock );
     117             : 
     118           0 :     if ( (sal_Int32)m_aPropertySetVector.size() > Index )
     119             :     {
     120           0 :         PropertySetVector::iterator aIter = m_aPropertySetVector.begin();
     121           0 :         aIter += Index;
     122           0 :         m_aPropertySetVector.erase( aIter );
     123             :     }
     124             :     else
     125           0 :         throw IndexOutOfBoundsException( OUString(), (OWeakObject *)this );
     126           0 : }
     127             : 
     128             : // XIndexReplace
     129           0 : void SAL_CALL PropertySetContainer::replaceByIndex( sal_Int32 Index, const ::com::sun::star::uno::Any& Element )
     130             :     throw ( IllegalArgumentException, IndexOutOfBoundsException, WrappedTargetException, RuntimeException)
     131             : {
     132           0 :     if ( (sal_Int32)m_aPropertySetVector.size() > Index )
     133             :     {
     134           0 :         Reference< XPropertySet > aPropertySetElement;
     135             : 
     136           0 :         if ( Element >>= aPropertySetElement )
     137             :         {
     138           0 :             m_aPropertySetVector[ Index ] = aPropertySetElement;
     139             :         }
     140             :         else
     141             :         {
     142             :             throw IllegalArgumentException(
     143             :                 OUString( RTL_CONSTASCII_USTRINGPARAM( WRONG_TYPE_EXCEPTION )),
     144           0 :                 (OWeakObject *)this, 2 );
     145           0 :         }
     146             :     }
     147             :     else
     148           0 :         throw IndexOutOfBoundsException( OUString(), (OWeakObject *)this );
     149           0 : }
     150             : 
     151             : // XIndexAccess
     152           0 : sal_Int32 SAL_CALL PropertySetContainer::getCount()
     153             :     throw ( RuntimeException )
     154             : {
     155           0 :     ResetableGuard aGuard( m_aLock );
     156             : 
     157           0 :     return m_aPropertySetVector.size();
     158             : }
     159             : 
     160           0 : Any SAL_CALL PropertySetContainer::getByIndex( sal_Int32 Index )
     161             :     throw ( IndexOutOfBoundsException, WrappedTargetException, RuntimeException )
     162             : {
     163           0 :     ResetableGuard aGuard( m_aLock );
     164             : 
     165           0 :     if ( (sal_Int32)m_aPropertySetVector.size() > Index )
     166             :     {
     167           0 :         Any a;
     168             : 
     169           0 :         a <<= m_aPropertySetVector[ Index ];
     170           0 :         return a;
     171             :     }
     172             :     else
     173           0 :         throw IndexOutOfBoundsException( OUString(), (OWeakObject *)this );
     174             : }
     175             : 
     176             : // XElementAccess
     177           0 : sal_Bool SAL_CALL PropertySetContainer::hasElements()
     178             :     throw (::com::sun::star::uno::RuntimeException)
     179             : {
     180           0 :     ResetableGuard aGuard( m_aLock );
     181             : 
     182           0 :     return !( m_aPropertySetVector.empty() );
     183             : }
     184             : 
     185             : }
     186             : 
     187             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10