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

Generated by: LCOV version 1.10