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

Generated by: LCOV version 1.10