LCOV - code coverage report
Current view: top level - libreoffice/comphelper/source/property - ChainablePropertySet.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 17 128 13.3 %
Date: 2012-12-27 Functions: 3 24 12.5 %
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 <comphelper/ChainablePropertySet.hxx>
      21             : #include <comphelper/ChainablePropertySetInfo.hxx>
      22             : #include <osl/mutex.hxx>
      23             : 
      24             : #include <boost/scoped_ptr.hpp>
      25             : 
      26             : 
      27             : using namespace ::rtl;
      28             : using namespace ::comphelper;
      29             : using namespace ::com::sun::star;
      30             : using namespace ::com::sun::star::uno;
      31             : using namespace ::com::sun::star::lang;
      32             : using namespace ::com::sun::star::beans;
      33             : 
      34         419 : ChainablePropertySet::ChainablePropertySet( comphelper::ChainablePropertySetInfo* pInfo, osl::SolarMutex* pMutex )
      35             :     throw()
      36             : : mpInfo ( pInfo )
      37             : , mpMutex ( pMutex )
      38         419 : , mxInfo ( pInfo )
      39             : {
      40         419 : }
      41             : 
      42         418 : ChainablePropertySet::~ChainablePropertySet()
      43         418 :     throw()
      44             : {
      45         418 : }
      46             : 
      47             : // XPropertySet
      48           0 : Reference< XPropertySetInfo > SAL_CALL ChainablePropertySet::getPropertySetInfo(  )
      49             :     throw(RuntimeException)
      50             : {
      51           0 :     return mxInfo;
      52             : }
      53             : 
      54           0 : void SAL_CALL ChainablePropertySet::setPropertyValue( const ::rtl::OUString& rPropertyName, const Any& rValue )
      55             :     throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException)
      56             : {
      57             :     // acquire mutex in c-tor and releases it in the d-tor (exception safe!).
      58           0 :     boost::scoped_ptr< osl::SolarGuard > pMutexGuard;
      59           0 :     if (mpMutex)
      60           0 :         pMutexGuard.reset( new osl::SolarGuard(mpMutex) );
      61             : 
      62           0 :     PropertyInfoHash::const_iterator aIter = mpInfo->maMap.find ( rPropertyName );
      63             : 
      64           0 :     if( aIter == mpInfo->maMap.end())
      65           0 :         throw UnknownPropertyException( rPropertyName, static_cast< XPropertySet* >( this ) );
      66             : 
      67           0 :     _preSetValues();
      68           0 :     _setSingleValue( *((*aIter).second), rValue );
      69           0 :     _postSetValues();
      70           0 : }
      71             : 
      72           2 : Any SAL_CALL ChainablePropertySet::getPropertyValue( const ::rtl::OUString& rPropertyName )
      73             :     throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
      74             : {
      75             :     // acquire mutex in c-tor and releases it in the d-tor (exception safe!).
      76           2 :     boost::scoped_ptr< osl::SolarGuard > pMutexGuard;
      77           2 :     if (mpMutex)
      78           2 :         pMutexGuard.reset( new osl::SolarGuard(mpMutex) );
      79             : 
      80           2 :     PropertyInfoHash::const_iterator aIter = mpInfo->maMap.find ( rPropertyName );
      81             : 
      82           2 :     if( aIter == mpInfo->maMap.end())
      83           0 :         throw UnknownPropertyException( rPropertyName, static_cast< XPropertySet* >( this ) );
      84             : 
      85           2 :     Any aAny;
      86           2 :     _preGetValues ();
      87           2 :     _getSingleValue( *((*aIter).second), aAny );
      88           2 :     _postGetValues ();
      89             : 
      90           2 :     return aAny;
      91             : }
      92             : 
      93           0 : void SAL_CALL ChainablePropertySet::addPropertyChangeListener( const ::rtl::OUString&, const Reference< XPropertyChangeListener >& )
      94             :     throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
      95             : {
      96             :     // todo
      97           0 : }
      98             : 
      99           0 : void SAL_CALL ChainablePropertySet::removePropertyChangeListener( const ::rtl::OUString&, const Reference< XPropertyChangeListener >& )
     100             :     throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
     101             : {
     102             :     // todo
     103           0 : }
     104             : 
     105           0 : void SAL_CALL ChainablePropertySet::addVetoableChangeListener( const ::rtl::OUString&, const Reference< XVetoableChangeListener >& )
     106             :     throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
     107             : {
     108             :     // todo
     109           0 : }
     110             : 
     111           0 : void SAL_CALL ChainablePropertySet::removeVetoableChangeListener( const ::rtl::OUString&, const Reference< XVetoableChangeListener >& )
     112             :     throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
     113             : {
     114             :     // todo
     115           0 : }
     116             : 
     117             : // XMultiPropertySet
     118           0 : void SAL_CALL ChainablePropertySet::setPropertyValues( const Sequence< ::rtl::OUString >& aPropertyNames, const Sequence< Any >& aValues )
     119             :     throw(PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException)
     120             : {
     121             :     // acquire mutex in c-tor and releases it in the d-tor (exception safe!).
     122           0 :     boost::scoped_ptr< osl::SolarGuard > pMutexGuard;
     123           0 :     if (mpMutex)
     124           0 :         pMutexGuard.reset( new osl::SolarGuard(mpMutex) );
     125             : 
     126           0 :     const sal_Int32 nCount = aPropertyNames.getLength();
     127             : 
     128           0 :     if( nCount != aValues.getLength() )
     129           0 :         throw IllegalArgumentException();
     130             : 
     131           0 :     if( nCount )
     132             :     {
     133           0 :         _preSetValues();
     134             : 
     135           0 :         const Any * pAny = aValues.getConstArray();
     136           0 :         const OUString * pString = aPropertyNames.getConstArray();
     137           0 :         PropertyInfoHash::const_iterator aEnd = mpInfo->maMap.end(), aIter;
     138             : 
     139           0 :         for ( sal_Int32 i = 0; i < nCount; ++i, ++pString, ++pAny )
     140             :         {
     141           0 :             aIter = mpInfo->maMap.find ( *pString );
     142           0 :             if ( aIter == aEnd )
     143           0 :                 throw UnknownPropertyException( *pString, static_cast< XPropertySet* >( this ) );
     144             : 
     145           0 :             _setSingleValue ( *((*aIter).second), *pAny );
     146             :         }
     147             : 
     148           0 :         _postSetValues();
     149           0 :     }
     150           0 : }
     151             : 
     152           0 : Sequence< Any > SAL_CALL ChainablePropertySet::getPropertyValues( const Sequence< ::rtl::OUString >& aPropertyNames )
     153             :     throw(RuntimeException)
     154             : {
     155             :     // acquire mutex in c-tor and releases it in the d-tor (exception safe!).
     156           0 :     boost::scoped_ptr< osl::SolarGuard > pMutexGuard;
     157           0 :     if (mpMutex)
     158           0 :         pMutexGuard.reset( new osl::SolarGuard(mpMutex) );
     159             : 
     160           0 :     const sal_Int32 nCount = aPropertyNames.getLength();
     161             : 
     162           0 :     Sequence < Any > aValues ( nCount );
     163             : 
     164           0 :     if( nCount )
     165             :     {
     166           0 :         _preGetValues();
     167             : 
     168           0 :         Any * pAny = aValues.getArray();
     169           0 :         const OUString * pString = aPropertyNames.getConstArray();
     170           0 :         PropertyInfoHash::const_iterator aEnd = mpInfo->maMap.end(), aIter;
     171             : 
     172           0 :         for ( sal_Int32 i = 0; i < nCount; ++i, ++pString, ++pAny )
     173             :         {
     174           0 :             aIter = mpInfo->maMap.find ( *pString );
     175           0 :             if ( aIter == aEnd )
     176           0 :                 throw UnknownPropertyException( *pString, static_cast< XPropertySet* >( this ) );
     177             : 
     178           0 :             _getSingleValue ( *((*aIter).second), *pAny );
     179             :         }
     180             : 
     181           0 :         _postGetValues();
     182             :     }
     183           0 :     return aValues;
     184             : }
     185             : 
     186           0 : void SAL_CALL ChainablePropertySet::addPropertiesChangeListener( const Sequence< ::rtl::OUString >&, const Reference< XPropertiesChangeListener >& )
     187             :     throw(RuntimeException)
     188             : {
     189             :     // todo
     190           0 : }
     191             : 
     192           0 : void SAL_CALL ChainablePropertySet::removePropertiesChangeListener( const Reference< XPropertiesChangeListener >& )
     193             :     throw(RuntimeException)
     194             : {
     195             :     // todo
     196           0 : }
     197             : 
     198           0 : void SAL_CALL ChainablePropertySet::firePropertiesChangeEvent( const Sequence< ::rtl::OUString >&, const Reference< XPropertiesChangeListener >& )
     199             :     throw(RuntimeException)
     200             : {
     201             :     // todo
     202           0 : }
     203             : 
     204             : // XPropertyState
     205           0 : PropertyState SAL_CALL ChainablePropertySet::getPropertyState( const ::rtl::OUString& PropertyName )
     206             :     throw(UnknownPropertyException, RuntimeException)
     207             : {
     208           0 :     PropertyInfoHash::const_iterator aIter =  mpInfo->maMap.find( PropertyName );
     209           0 :     if( aIter == mpInfo->maMap.end())
     210           0 :         throw UnknownPropertyException( PropertyName, static_cast< XPropertySet* >( this ) );
     211             : 
     212             :     PropertyState aState;
     213             : 
     214           0 :     _preGetPropertyState();
     215           0 :     _getPropertyState( *((*aIter).second), aState );
     216           0 :     _postGetPropertyState();
     217             : 
     218           0 :     return aState;
     219             : }
     220             : 
     221           0 : Sequence< PropertyState > SAL_CALL ChainablePropertySet::getPropertyStates( const Sequence< ::rtl::OUString >& rPropertyNames )
     222             :     throw(UnknownPropertyException, RuntimeException)
     223             : {
     224           0 :     const sal_Int32 nCount = rPropertyNames.getLength();
     225             : 
     226           0 :     Sequence< PropertyState > aStates( nCount );
     227           0 :     if( nCount )
     228             :     {
     229           0 :         PropertyState * pState = aStates.getArray();
     230           0 :         const OUString * pString = rPropertyNames.getConstArray();
     231           0 :         PropertyInfoHash::const_iterator aEnd = mpInfo->maMap.end(), aIter;
     232           0 :         _preGetPropertyState();
     233             : 
     234           0 :         for ( sal_Int32 i = 0; i < nCount; ++i, ++pString, ++pState )
     235             :         {
     236           0 :             aIter = mpInfo->maMap.find ( *pString );
     237           0 :             if ( aIter == aEnd )
     238           0 :                 throw UnknownPropertyException( *pString, static_cast< XPropertySet* >( this ) );
     239             : 
     240           0 :             _getPropertyState ( *((*aIter).second), *pState );
     241             :         }
     242           0 :         _postGetPropertyState();
     243             :     }
     244           0 :     return aStates;
     245             : }
     246             : 
     247           0 : void SAL_CALL ChainablePropertySet::setPropertyToDefault( const ::rtl::OUString& rPropertyName )
     248             :     throw(UnknownPropertyException, RuntimeException)
     249             : {
     250           0 :     PropertyInfoHash::const_iterator aIter = mpInfo->maMap.find ( rPropertyName );
     251             : 
     252           0 :     if( aIter == mpInfo->maMap.end())
     253           0 :         throw UnknownPropertyException( rPropertyName, static_cast< XPropertySet* >( this ) );
     254           0 :     _setPropertyToDefault( *((*aIter).second) );
     255           0 : }
     256             : 
     257           0 : Any SAL_CALL ChainablePropertySet::getPropertyDefault( const ::rtl::OUString& rPropertyName )
     258             :     throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
     259             : {
     260           0 :     PropertyInfoHash::const_iterator aIter = mpInfo->maMap.find ( rPropertyName );
     261             : 
     262           0 :     if( aIter == mpInfo->maMap.end())
     263           0 :         throw UnknownPropertyException( rPropertyName, static_cast< XPropertySet* >( this ) );
     264           0 :     return _getPropertyDefault( *((*aIter).second) );
     265             : }
     266             : 
     267           0 : void ChainablePropertySet::_preGetPropertyState ()
     268             :     throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException )
     269             : {
     270             :     OSL_FAIL( "you have to implement this yourself!");
     271           0 : }
     272             : 
     273           0 : void ChainablePropertySet::_getPropertyState( const comphelper::PropertyInfo&, PropertyState& )
     274             :     throw(UnknownPropertyException )
     275             : {
     276             :     OSL_FAIL( "you have to implement this yourself!");
     277           0 : }
     278             : 
     279           0 : void ChainablePropertySet::_postGetPropertyState ()
     280             :     throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException )
     281             : {
     282             :     OSL_FAIL( "you have to implement this yourself!");
     283           0 : }
     284             : 
     285           0 : void ChainablePropertySet::_setPropertyToDefault( const comphelper::PropertyInfo& )
     286             :     throw(UnknownPropertyException )
     287             : {
     288             :     OSL_FAIL( "you have to implement this yourself!");
     289           0 : }
     290             : 
     291           0 : Any ChainablePropertySet::_getPropertyDefault( const comphelper::PropertyInfo& )
     292             :     throw(UnknownPropertyException, WrappedTargetException )
     293             : {
     294             :     OSL_FAIL( "you have to implement this yourself!");
     295             : 
     296           0 :     Any aAny;
     297           0 :     return aAny;
     298             : }
     299             : 
     300             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10