LCOV - code coverage report
Current view: top level - comphelper/source/property - propagg.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 378 421 89.8 %
Date: 2014-04-11 Functions: 41 46 89.1 %
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/propagg.hxx"
      21             : #include "comphelper/property.hxx"
      22             : #include <cppuhelper/queryinterface.hxx>
      23             : #include <osl/diagnose.h>
      24             : #include <com/sun/star/beans/PropertyAttribute.hpp>
      25             : 
      26             : #if OSL_DEBUG_LEVEL > 0
      27             : #include <typeinfo>
      28             : #include <rtl/strbuf.hxx>
      29             : #endif
      30             : 
      31             : #include <algorithm>
      32             : #include <set>
      33             : #include <boost/scoped_array.hpp>
      34             : 
      35             : 
      36             : namespace comphelper
      37             : {
      38             : 
      39             : 
      40             :     using namespace ::com::sun::star::uno;
      41             :     using namespace ::com::sun::star::lang;
      42             :     using namespace ::com::sun::star::beans;
      43             : 
      44             :     using namespace internal;
      45             : 
      46             : 
      47             :     namespace
      48             :     {
      49       98728 :         const Property* lcl_findPropertyByName( const Sequence< Property >& _rProps, const OUString& _rName )
      50             :         {
      51       98728 :             sal_Int32 nLen = _rProps.getLength();
      52       98728 :             const Property* pProperties = _rProps.getConstArray();
      53       98728 :             Property aNameProp(_rName, 0, Type(), 0);
      54       98728 :             const Property* pResult = ::std::lower_bound(pProperties, pProperties + nLen, aNameProp, PropertyCompareByName());
      55       98728 :             if ( pResult && ( pResult == pProperties + nLen || pResult->Name != _rName) )
      56         256 :                 pResult = NULL;
      57             : 
      58       98728 :             return pResult;
      59             :         }
      60             :     }
      61             : 
      62             : //= OPropertyArrayAggregationHelper
      63             : 
      64             : 
      65             : 
      66         762 : OPropertyArrayAggregationHelper::OPropertyArrayAggregationHelper(
      67             :         const  Sequence< Property >& _rProperties, const  Sequence< Property >& _rAggProperties,
      68             :         IPropertyInfoService* _pInfoService, sal_Int32 _nFirstAggregateId )
      69         762 :     :m_aProperties( _rProperties )
      70             : {
      71         762 :     sal_Int32 nDelegatorProps = _rProperties.getLength();
      72         762 :     sal_Int32 nAggregateProps = _rAggProperties.getLength();
      73             : 
      74             :     // make room for all properties
      75         762 :     sal_Int32 nMergedProps = nDelegatorProps + nAggregateProps;
      76         762 :     m_aProperties.realloc( nMergedProps );
      77             : 
      78         762 :     const   Property* pAggregateProps   = _rAggProperties.getConstArray();
      79         762 :     const   Property* pDelegateProps    = _rProperties.getConstArray();
      80         762 :             Property* pMergedProps = m_aProperties.getArray();
      81             : 
      82             :     // if properties are present both at the delegatee and the aggregate, then the former are supposed to win.
      83             :     // So, we'll need an existence check.
      84         762 :     ::std::set< OUString > aDelegatorProps;
      85             : 
      86             :     // create the map for the delegator properties
      87         762 :     sal_Int32 nMPLoop = 0;
      88       17584 :     for ( ; nMPLoop < nDelegatorProps; ++nMPLoop, ++pDelegateProps )
      89             :     {
      90       16822 :         m_aPropertyAccessors[ pDelegateProps->Handle ] = OPropertyAccessor( -1, nMPLoop, false );
      91             :         OSL_ENSURE( aDelegatorProps.find( pDelegateProps->Name ) == aDelegatorProps.end(),
      92             :             "OPropertyArrayAggregationHelper::OPropertyArrayAggregationHelper: duplicate delegatee property!" );
      93       16822 :         aDelegatorProps.insert( pDelegateProps->Name );
      94             :     }
      95             : 
      96             :     // create the map for the aggregate properties
      97         762 :     sal_Int32 nAggregateHandle = _nFirstAggregateId;
      98         762 :     pMergedProps += nDelegatorProps;
      99       38979 :     for ( ; nMPLoop < nMergedProps; ++pAggregateProps )
     100             :     {
     101             :         // if the aggregate property is present at the delegatee already, ignore it
     102       38217 :         if ( aDelegatorProps.find( pAggregateProps->Name ) != aDelegatorProps.end() )
     103             :         {
     104         321 :             --nMergedProps;
     105         321 :             continue;
     106             :         }
     107             : 
     108             :         // next aggregate property - remember it
     109       37896 :         *pMergedProps = *pAggregateProps;
     110             : 
     111             :         // determine the handle for the property which we will expose to the outside world
     112       37896 :         sal_Int32 nHandle = -1;
     113             :         // ask the infor service first
     114       37896 :         if ( _pInfoService )
     115       36781 :             nHandle = _pInfoService->getPreferredPropertyId( pMergedProps->Name );
     116             : 
     117       37896 :         if ( -1 == nHandle )
     118             :             // no handle from the info service -> default
     119       22532 :             nHandle = nAggregateHandle++;
     120             :         else
     121             :         {   // check if we alread have a property with the given handle
     122       15364 :             const  Property* pPropsTilNow = m_aProperties.getConstArray();
     123      728625 :             for ( sal_Int32 nCheck = 0; nCheck < nMPLoop; ++nCheck, ++pPropsTilNow )
     124      713261 :                 if ( pPropsTilNow->Handle == nHandle )
     125             :                 {   // conflicts -> use another one (which we don't check anymore, assuming _nFirstAggregateId was large enough)
     126           0 :                     nHandle = nAggregateHandle++;
     127           0 :                     break;
     128             :                 }
     129             :         }
     130             : 
     131             :         // remember the accessor for this property
     132       37896 :         m_aPropertyAccessors[ nHandle ] = OPropertyAccessor( pMergedProps->Handle, nMPLoop, true );
     133       37896 :         pMergedProps->Handle = nHandle;
     134             : 
     135       37896 :         ++nMPLoop;
     136       37896 :         ++pMergedProps;
     137             :     }
     138         762 :     m_aProperties.realloc( nMergedProps );
     139         762 :     pMergedProps = m_aProperties.getArray();    // reset, needed again below
     140             : 
     141             :     // sort the properties by name
     142         762 :     ::std::sort( pMergedProps, pMergedProps+nMergedProps, PropertyCompareByName());
     143             : 
     144         762 :     pMergedProps = m_aProperties.getArray();
     145             : 
     146             :     // sync the map positions
     147       55480 :     for ( nMPLoop = 0; nMPLoop < nMergedProps; ++nMPLoop, ++pMergedProps )
     148       55480 :         m_aPropertyAccessors[ pMergedProps->Handle ].nPos = nMPLoop;
     149         762 : }
     150             : 
     151             : 
     152       57994 : OPropertyArrayAggregationHelper::PropertyOrigin OPropertyArrayAggregationHelper::classifyProperty( const OUString& _rName )
     153             : {
     154       57994 :     PropertyOrigin eOrigin = UNKNOWN_PROPERTY;
     155             :     // look up the name
     156       57994 :     const Property* pPropertyDescriptor = lcl_findPropertyByName( m_aProperties, _rName );
     157       57994 :     if ( pPropertyDescriptor )
     158             :     {
     159             :         // look up the handle for this name
     160       57992 :         ConstPropertyAccessorMapIterator aPos = m_aPropertyAccessors.find( pPropertyDescriptor->Handle );
     161             :         OSL_ENSURE( m_aPropertyAccessors.end() != aPos, "OPropertyArrayAggregationHelper::classifyProperty: should have this handle in my map!" );
     162       57992 :         if ( m_aPropertyAccessors.end() != aPos )
     163             :         {
     164       57992 :             eOrigin = aPos->second.bAggregate ? AGGREGATE_PROPERTY : DELEGATOR_PROPERTY;
     165             :         }
     166             :     }
     167       57994 :     return eOrigin;
     168             : }
     169             : 
     170             : 
     171           0 : Property OPropertyArrayAggregationHelper::getPropertyByName( const OUString& _rPropertyName ) throw( UnknownPropertyException )
     172             : {
     173           0 :     const Property* pProperty = findPropertyByName( _rPropertyName );
     174             : 
     175           0 :     if ( !pProperty )
     176           0 :         throw  UnknownPropertyException();
     177             : 
     178           0 :     return *pProperty;
     179             : }
     180             : 
     181             : 
     182         133 : sal_Bool OPropertyArrayAggregationHelper::hasPropertyByName(const OUString& _rPropertyName)
     183             : {
     184         133 :     return NULL != findPropertyByName( _rPropertyName );
     185             : }
     186             : 
     187             : 
     188       40734 : const Property* OPropertyArrayAggregationHelper::findPropertyByName(const :: OUString& _rName ) const
     189             : {
     190       40734 :     return lcl_findPropertyByName( m_aProperties, _rName );
     191             : }
     192             : 
     193             : 
     194       40601 : sal_Int32 OPropertyArrayAggregationHelper::getHandleByName(const OUString& _rPropertyName)
     195             : {
     196       40601 :     const Property* pProperty = findPropertyByName( _rPropertyName );
     197       40601 :     return pProperty ? pProperty->Handle : -1;
     198             : }
     199             : 
     200             : 
     201       45387 : sal_Bool OPropertyArrayAggregationHelper::fillPropertyMembersByHandle(
     202             :             OUString* _pPropName, sal_Int16* _pAttributes, sal_Int32 _nHandle)
     203             : {
     204       45387 :     ConstPropertyAccessorMapIterator i = m_aPropertyAccessors.find(_nHandle);
     205       45387 :     bool bRet = i != m_aPropertyAccessors.end();
     206       45387 :     if (bRet)
     207             :     {
     208       45152 :         const  ::com::sun::star::beans::Property& rProperty = m_aProperties.getConstArray()[(*i).second.nPos];
     209       45152 :         if (_pPropName)
     210        9672 :             *_pPropName = rProperty.Name;
     211       45152 :         if (_pAttributes)
     212       25626 :             *_pAttributes = rProperty.Attributes;
     213             :     }
     214       45387 :     return bRet;
     215             : }
     216             : 
     217             : 
     218         736 : bool OPropertyArrayAggregationHelper::getPropertyByHandle( sal_Int32 _nHandle, Property& _rProperty ) const
     219             : {
     220         736 :     ConstPropertyAccessorMapIterator pos = m_aPropertyAccessors.find(_nHandle);
     221         736 :     if ( pos != m_aPropertyAccessors.end() )
     222             :     {
     223         736 :         _rProperty = m_aProperties[ pos->second.nPos ];
     224         736 :         return true;
     225             :     }
     226           0 :     return false;
     227             : }
     228             : 
     229             : 
     230       95925 : bool OPropertyArrayAggregationHelper::fillAggregatePropertyInfoByHandle(
     231             :             OUString* _pPropName, sal_Int32* _pOriginalHandle, sal_Int32 _nHandle) const
     232             : {
     233       95925 :     ConstPropertyAccessorMapIterator i = m_aPropertyAccessors.find(_nHandle);
     234       95925 :     bool bRet = i != m_aPropertyAccessors.end() && (*i).second.bAggregate;
     235       95925 :     if (bRet)
     236             :     {
     237       71368 :         if (_pOriginalHandle)
     238       71368 :             *_pOriginalHandle = (*i).second.nOriginalHandle;
     239       71368 :         if (_pPropName)
     240             :         {
     241             :             OSL_ENSURE((*i).second.nPos < m_aProperties.getLength(),"Invalid index for sequence!");
     242       71070 :             const  ::com::sun::star::beans::Property& rProperty = m_aProperties.getConstArray()[(*i).second.nPos];
     243       71070 :             *_pPropName = rProperty.Name;
     244             :         }
     245             :     }
     246       95925 :     return bRet;
     247             : }
     248             : 
     249             : 
     250             : 
     251       22660 :  ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property> OPropertyArrayAggregationHelper::getProperties()
     252             : {
     253       22660 :     return m_aProperties;
     254             : }
     255             : 
     256             : 
     257             : 
     258        2935 : sal_Int32 OPropertyArrayAggregationHelper::fillHandles(
     259             :         sal_Int32* _pHandles, const  ::com::sun::star::uno::Sequence< OUString >& _rPropNames )
     260             : {
     261        2935 :     sal_Int32 nHitCount = 0;
     262        2935 :     const OUString* pReqProps = _rPropNames.getConstArray();
     263        2935 :     sal_Int32 nReqLen = _rPropNames.getLength();
     264             : 
     265             : #if OSL_DEBUG_LEVEL > 0
     266             :     // assure that the sequence is sorted
     267             :     {
     268             :         const OUString* pLookup = _rPropNames.getConstArray();
     269             :         const OUString* pEnd = _rPropNames.getConstArray() + _rPropNames.getLength() - 1;
     270             :         for (; pLookup < pEnd; ++pLookup)
     271             :         {
     272             :             const OUString* pCompare = pLookup + 1;
     273             :             const OUString* pCompareEnd = pEnd + 1;
     274             :             for (; pCompare < pCompareEnd; ++pCompare)
     275             :             {
     276             :                 OSL_ENSURE(pLookup->compareTo(*pCompare) < 0, "OPropertyArrayAggregationHelper::fillHandles : property names are not sorted!");
     277             :             }
     278             :         }
     279             :     }
     280             : #endif
     281             : 
     282        2935 :     const  ::com::sun::star::beans::Property* pCur = m_aProperties.getConstArray();
     283        2935 :     const  ::com::sun::star::beans::Property* pEnd = m_aProperties.getConstArray() + m_aProperties.getLength();
     284             : 
     285       71235 :     for( sal_Int32 i = 0; i < nReqLen; ++i )
     286             :     {
     287             :         // determine the logarithm
     288       68300 :         sal_uInt32 n = (sal_uInt32)(pEnd - pCur);
     289       68300 :         sal_Int32 nLog = 0;
     290      497172 :         while( n )
     291             :         {
     292      360572 :             nLog += 1;
     293      360572 :             n = n >> 1;
     294             :         }
     295             : 
     296             :         // (Number of properties yet to be found) * (Log2 of properties yet to be searched)
     297       68300 :         if( (nReqLen - i) * nLog >= pEnd - pCur )
     298             :         {
     299             :             // linear search is better
     300      214429 :             while( pCur < pEnd && pReqProps[i] > pCur->Name )
     301             :             {
     302       87041 :                 pCur++;
     303             :             }
     304       63694 :             if( pCur < pEnd && pReqProps[i] == pCur->Name )
     305             :             {
     306       63694 :                 _pHandles[i] = pCur->Handle;
     307       63694 :                 nHitCount++;
     308             :             }
     309             :             else
     310           0 :                 _pHandles[i] = -1;
     311             :         }
     312             :         else
     313             :         {
     314             :             // binary search is better
     315        4606 :             sal_Int32   nCompVal = 1;
     316        4606 :             const  ::com::sun::star::beans::Property*  pOldEnd = pEnd--;
     317        4606 :             const  ::com::sun::star::beans::Property*  pMid = pCur;
     318             : 
     319       26892 :             while( nCompVal != 0 && pCur <= pEnd )
     320             :             {
     321       17680 :                 pMid = (pEnd - pCur) / 2 + pCur;
     322             : 
     323       17680 :                 nCompVal = pReqProps[i].compareTo( pMid->Name );
     324             : 
     325       17680 :                 if( nCompVal > 0 )
     326        5465 :                     pCur = pMid + 1;
     327             :                 else
     328       12215 :                     pEnd = pMid - 1;
     329             :             }
     330             : 
     331        4606 :             if( nCompVal == 0 )
     332             :             {
     333        4606 :                 _pHandles[i] = pMid->Handle;
     334        4606 :                 nHitCount++;
     335        4606 :                 pCur = pMid +1;
     336             :             }
     337           0 :             else if( nCompVal > 0 )
     338             :             {
     339           0 :                 _pHandles[i] = -1;
     340           0 :                 pCur = pMid + 1;
     341             :             }
     342             :             else
     343             :             {
     344           0 :                 _pHandles[i] = -1;
     345           0 :                 pCur = pMid;
     346             :             }
     347        4606 :             pEnd = pOldEnd;
     348             :         }
     349             :     }
     350        2935 :     return nHitCount;
     351             : }
     352             : 
     353             : 
     354             : //= PropertyForwarder
     355             : 
     356             : namespace internal
     357             : {
     358             :     class PropertyForwarder
     359             :     {
     360             :     private:
     361             :         OPropertySetAggregationHelper&  m_rAggregationHelper;
     362             :         ::std::set< sal_Int32 >         m_aProperties;
     363             :         sal_Int32                       m_nCurrentlyForwarding;
     364             : 
     365             :     public:
     366             :         PropertyForwarder( OPropertySetAggregationHelper& _rAggregationHelper );
     367             :         ~PropertyForwarder();
     368             : 
     369             :         /** declares that the forwarder should be responsible for the given property
     370             : 
     371             :         @param _nHandle
     372             :             the public handle (<em>not</em> the original handle!) of the property
     373             :         */
     374             :         void    takeResponsibilityFor( sal_Int32 _nHandle );
     375             : 
     376             :         /** checks whether the forwarder is responsible for the given property
     377             :         */
     378             :         bool    isResponsibleFor( sal_Int32 _nHandle );
     379             : 
     380             :         /// actually forwards a property value to the aggregate
     381             :         void    doForward( sal_Int32 _nHandle, const Any& _rValue ) throw ( Exception );
     382             : 
     383        5118 :         sal_Int32 getCurrentlyForwardedProperty( ) const { return m_nCurrentlyForwarding; }
     384             :     };
     385             : 
     386             : 
     387         886 :     PropertyForwarder::PropertyForwarder( OPropertySetAggregationHelper& _rAggregationHelper )
     388             :         :m_rAggregationHelper( _rAggregationHelper )
     389         886 :         ,m_nCurrentlyForwarding( -1 )
     390             :     {
     391         886 :     }
     392             : 
     393             : 
     394         806 :     PropertyForwarder::~PropertyForwarder()
     395             :     {
     396         806 :     }
     397             : 
     398             : 
     399         162 :     void PropertyForwarder::takeResponsibilityFor( sal_Int32 _nHandle )
     400             :     {
     401         162 :         m_aProperties.insert( _nHandle );
     402         162 :     }
     403             : 
     404             : 
     405         736 :     bool PropertyForwarder::isResponsibleFor( sal_Int32 _nHandle )
     406             :     {
     407         736 :         return m_aProperties.find( _nHandle ) != m_aProperties.end();
     408             :     }
     409             : 
     410             : 
     411         162 :     void PropertyForwarder::doForward( sal_Int32 _nHandle, const Any& _rValue ) throw ( Exception )
     412             :     {
     413             :         OSL_ENSURE( m_rAggregationHelper.m_xAggregateSet.is(), "PropertyForwarder::doForward: no property set!" );
     414         162 :         if ( m_rAggregationHelper.m_xAggregateSet.is() )
     415             :         {
     416         162 :             m_rAggregationHelper.forwardingPropertyValue( _nHandle );
     417             : 
     418             :             OSL_ENSURE( m_nCurrentlyForwarding == -1, "PropertyForwarder::doForward: reentrance?" );
     419         162 :             m_nCurrentlyForwarding = _nHandle;
     420             : 
     421             :             try
     422             :             {
     423         162 :                 m_rAggregationHelper.m_xAggregateSet->setPropertyValue( m_rAggregationHelper.getPropertyName( _nHandle ), _rValue );
     424             :                     // TODO: cache the property name? (it's a O(log n) search)
     425             :             }
     426           0 :             catch( const Exception& )
     427             :             {
     428           0 :                 m_rAggregationHelper.forwardedPropertyValue( _nHandle );
     429           0 :                 throw;
     430             :             }
     431             : 
     432         162 :             m_nCurrentlyForwarding = -1;
     433             : 
     434         162 :             m_rAggregationHelper.forwardedPropertyValue( _nHandle );
     435             :         }
     436         162 :     }
     437             : }
     438             : 
     439             : 
     440             : //= OPropertySetAggregationHelper
     441             : 
     442             : 
     443             : 
     444         886 : OPropertySetAggregationHelper::OPropertySetAggregationHelper( ::cppu::OBroadcastHelper& rBHlp )
     445             :     :OPropertyStateHelper( rBHlp )
     446         886 :     ,m_bListening( false )
     447             : {
     448         886 :     m_pForwarder = new PropertyForwarder( *this );
     449         886 : }
     450             : 
     451             : 
     452        1612 : OPropertySetAggregationHelper::~OPropertySetAggregationHelper()
     453             : {
     454         806 :     delete m_pForwarder;
     455         806 : }
     456             : 
     457             : 
     458       88194 :  ::com::sun::star::uno::Any SAL_CALL OPropertySetAggregationHelper::queryInterface(const  ::com::sun::star::uno::Type& _rType) throw( ::com::sun::star::uno::RuntimeException, std::exception)
     459             : {
     460       88194 :      ::com::sun::star::uno::Any aReturn = OPropertyStateHelper::queryInterface(_rType);
     461             : 
     462       88194 :     if ( !aReturn.hasValue() )
     463      105816 :         aReturn = cppu::queryInterface(_rType
     464             :         ,static_cast< ::com::sun::star::beans::XPropertiesChangeListener*>(this)
     465             :         ,static_cast< ::com::sun::star::beans::XVetoableChangeListener*>(this)
     466             :         ,static_cast< ::com::sun::star::lang::XEventListener*>(static_cast< ::com::sun::star::beans::XPropertiesChangeListener*>(this))
     467       52908 :         );
     468             : 
     469       88194 :     return aReturn;
     470             : }
     471             : 
     472             : 
     473         781 : void OPropertySetAggregationHelper::disposing()
     474             : {
     475         781 :     osl::MutexGuard aGuard(rBHelper.rMutex);
     476             : 
     477         781 :     if ( m_xAggregateSet.is() && m_bListening )
     478             :     {
     479             :         // register as a single listener
     480         626 :         m_xAggregateMultiSet->removePropertiesChangeListener(this);
     481         626 :         m_xAggregateSet->removeVetoableChangeListener(OUString(), this);
     482         626 :         m_bListening = false;
     483             :     }
     484             : 
     485         781 :     OPropertyStateHelper::disposing();
     486         781 : }
     487             : 
     488             : 
     489         145 : void SAL_CALL OPropertySetAggregationHelper::disposing(const  ::com::sun::star::lang::EventObject& _rSource) throw ( ::com::sun::star::uno::RuntimeException, std::exception)
     490             : {
     491             :     OSL_ENSURE(m_xAggregateSet.is(), "OPropertySetAggregationHelper::disposing : don't have an aggregate anymore !");
     492         145 :     if (_rSource.Source == m_xAggregateSet)
     493           0 :         m_bListening = false;
     494         145 : }
     495             : 
     496             : 
     497        4480 : void SAL_CALL OPropertySetAggregationHelper::propertiesChange(const  ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyChangeEvent>& _rEvents) throw( ::com::sun::star::uno::RuntimeException, std::exception)
     498             : {
     499             :     OSL_ENSURE(m_xAggregateSet.is(), "OPropertySetAggregationHelper::propertiesChange : have no aggregate !");
     500             : 
     501        4480 :     sal_Int32 nLen = _rEvents.getLength();
     502        4480 :     cppu::IPropertyArrayHelper& rPH = getInfoHelper();
     503             : 
     504        4480 :     if (1 == nLen)
     505             :     {
     506        4267 :         const  ::com::sun::star::beans::PropertyChangeEvent& evt = _rEvents.getConstArray()[0];
     507             :         OSL_ENSURE(!evt.PropertyName.isEmpty(), "OPropertySetAggregationHelper::propertiesChange : invalid event !");
     508             :             // we had a bug where this assertion would have us saved a whole day :) (72514)
     509        4267 :         sal_Int32 nHandle = rPH.getHandleByName( evt.PropertyName );
     510             : 
     511             :         // If nHandle is -1 the event marks a (aggregate) property which we hide to callers
     512             :         // If isCurrentlyForwardingProperty( nHandle ) is <TRUE/>, then we ourself triggered
     513             :         // setting this property. In this case, it will be notified later (by the OPropertySetHelper
     514             :         // implementation)
     515             : 
     516        4267 :         if ( ( nHandle != -1 ) && !isCurrentlyForwardingProperty( nHandle ) )
     517        4116 :             fire(&nHandle, &evt.NewValue, &evt.OldValue, 1, sal_False);
     518             :     }
     519             :     else
     520             :     {
     521         213 :         boost::scoped_array<sal_Int32> pHandles(new sal_Int32[nLen]);
     522         426 :         boost::scoped_array< ::com::sun::star::uno::Any> pNewValues(new ::com::sun::star::uno::Any[nLen]);
     523         426 :         boost::scoped_array< ::com::sun::star::uno::Any> pOldValues(new ::com::sun::star::uno::Any[nLen]);
     524             : 
     525         213 :         const  ::com::sun::star::beans::PropertyChangeEvent* pEvents = _rEvents.getConstArray();
     526         213 :         sal_Int32 nDest = 0;
     527        1064 :         for (sal_Int32 nSource=0; nSource<nLen; ++nSource, ++pEvents)
     528             :         {
     529         851 :             sal_Int32 nHandle = rPH.getHandleByName(pEvents->PropertyName);
     530         851 :             if ( ( nHandle != -1 ) && !isCurrentlyForwardingProperty( nHandle ) )
     531             :             {   // same as above : -1 is valid (73247) ...
     532         851 :                 pHandles[nDest] = nHandle;
     533         851 :                 pNewValues[nDest] = pEvents->NewValue;
     534         851 :                 pOldValues[nDest] = pEvents->OldValue;
     535         851 :                 ++nDest;
     536             :             }
     537             :         }
     538             : 
     539         213 :         if (nDest)
     540         414 :             fire(pHandles.get(), pNewValues.get(), pOldValues.get(), nDest, sal_False);
     541             :     }
     542        4480 : }
     543             : 
     544             : 
     545           0 : void SAL_CALL OPropertySetAggregationHelper::vetoableChange(const  ::com::sun::star::beans::PropertyChangeEvent& _rEvent) throw( ::com::sun::star::beans::PropertyVetoException,  ::com::sun::star::uno::RuntimeException, std::exception)
     546             : {
     547             :     OSL_ENSURE(m_xAggregateSet.is(), "OPropertySetAggregationHelper::vetoableChange : have no aggregate !");
     548             : 
     549           0 :     cppu::IPropertyArrayHelper& rPH = getInfoHelper();
     550             : 
     551           0 :     sal_Int32 nHandle = rPH.getHandleByName(_rEvent.PropertyName);
     552           0 :     fire(&nHandle, &_rEvent.NewValue, &_rEvent.OldValue, 1, sal_True);
     553           0 : }
     554             : 
     555             : 
     556         861 : void OPropertySetAggregationHelper::setAggregation(const  ::com::sun::star::uno::Reference<  ::com::sun::star::uno::XInterface >& _rxDelegate)
     557             :         throw(  ::com::sun::star::lang::IllegalArgumentException )
     558             : {
     559         861 :     osl::MutexGuard aGuard(rBHelper.rMutex);
     560             : 
     561         861 :     if (m_bListening && m_xAggregateSet.is())
     562             :     {
     563           0 :         m_xAggregateMultiSet->removePropertiesChangeListener(this);
     564           0 :         m_xAggregateSet->removeVetoableChangeListener(OUString(), this);
     565           0 :         m_bListening = false;
     566             :     }
     567             : 
     568         861 :     m_xAggregateState       =  m_xAggregateState.query( _rxDelegate );
     569         861 :     m_xAggregateSet         =  m_xAggregateSet.query( _rxDelegate );
     570         861 :     m_xAggregateMultiSet    =  m_xAggregateMultiSet.query( _rxDelegate );
     571         861 :     m_xAggregateFastSet     =  m_xAggregateFastSet.query( _rxDelegate );
     572             : 
     573             :     // must support XPropertySet and XMultiPropertySet
     574         861 :     if ( m_xAggregateSet.is() && !m_xAggregateMultiSet.is() )
     575           0 :         throw  ::com::sun::star::lang::IllegalArgumentException();
     576         861 : }
     577             : 
     578             : 
     579         986 : void OPropertySetAggregationHelper::startListening()
     580             : {
     581         986 :     osl::MutexGuard aGuard(rBHelper.rMutex);
     582             : 
     583         986 :     if (!m_bListening && m_xAggregateSet.is())
     584             :     {
     585             :         // register as a single listener
     586         687 :          ::com::sun::star::uno::Sequence< OUString > aPropertyNames;
     587         687 :         m_xAggregateMultiSet->addPropertiesChangeListener(aPropertyNames, this);
     588         687 :         m_xAggregateSet->addVetoableChangeListener(OUString(), this);
     589             : 
     590         687 :         m_bListening = true;
     591         986 :     }
     592         986 : }
     593             : 
     594             : 
     595         132 : void SAL_CALL OPropertySetAggregationHelper::addVetoableChangeListener(const OUString& _rPropertyName,
     596             :                                                                        const  ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener>& _rxListener)
     597             :                                                                        throw( ::com::sun::star::beans::UnknownPropertyException,  ::com::sun::star::lang::WrappedTargetException,  ::com::sun::star::uno::RuntimeException, std::exception)
     598             : {
     599         132 :     OPropertySetHelper::addVetoableChangeListener(_rPropertyName, _rxListener);
     600         132 :     if (!m_bListening)
     601           0 :         startListening();
     602         132 : }
     603             : 
     604             : 
     605        4635 : void SAL_CALL OPropertySetAggregationHelper::addPropertyChangeListener(const OUString& _rPropertyName,
     606             :                                                                        const  ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener>& _rxListener)
     607             :                                                                        throw( ::com::sun::star::beans::UnknownPropertyException,  ::com::sun::star::lang::WrappedTargetException,  ::com::sun::star::uno::RuntimeException, std::exception)
     608             : {
     609        4635 :     OPropertySetHelper::addPropertyChangeListener(_rPropertyName, _rxListener);
     610        4635 :     if (!m_bListening)
     611         893 :         startListening();
     612        4635 : }
     613             : 
     614             : 
     615         549 : void SAL_CALL OPropertySetAggregationHelper::addPropertiesChangeListener(const  ::com::sun::star::uno::Sequence< OUString >& _rPropertyNames,
     616             :                                                                          const  ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener>& _rxListener)
     617             :                                                                          throw( ::com::sun::star::uno::RuntimeException, std::exception)
     618             : {
     619         549 :     OPropertySetHelper::addPropertiesChangeListener(_rPropertyNames, _rxListener);
     620         549 :     if (!m_bListening)
     621          93 :         startListening();
     622         549 : }
     623             : 
     624             : 
     625         298 : sal_Int32 OPropertySetAggregationHelper::getOriginalHandle(sal_Int32 nHandle) const
     626             : {
     627         298 :     OPropertyArrayAggregationHelper& rPH = (OPropertyArrayAggregationHelper&)const_cast<OPropertySetAggregationHelper*>(this)->getInfoHelper();
     628         298 :     sal_Int32 nOriginalHandle = -1;
     629         298 :     rPH.fillAggregatePropertyInfoByHandle(NULL, &nOriginalHandle, nHandle);
     630         298 :     return nOriginalHandle;
     631             : }
     632             : 
     633             : 
     634         562 : OUString OPropertySetAggregationHelper::getPropertyName( sal_Int32 _nHandle ) const
     635             : {
     636         562 :     OPropertyArrayAggregationHelper& rPH = static_cast< OPropertyArrayAggregationHelper& >( const_cast<OPropertySetAggregationHelper*>(this)->getInfoHelper() );
     637         562 :     Property aProperty;
     638         562 :     OSL_VERIFY( rPH.getPropertyByHandle( _nHandle, aProperty ) );
     639         562 :     return aProperty.Name;
     640             : }
     641             : 
     642             : 
     643        8923 : void SAL_CALL OPropertySetAggregationHelper::setFastPropertyValue(sal_Int32 _nHandle, const  ::com::sun::star::uno::Any& _rValue)
     644             :         throw(   ::com::sun::star::beans::UnknownPropertyException,  ::com::sun::star::beans::PropertyVetoException,
     645             :                  ::com::sun::star::lang::IllegalArgumentException,  ::com::sun::star::lang::WrappedTargetException,
     646             :                  ::com::sun::star::uno::RuntimeException, std::exception)
     647             : {
     648        8923 :     OPropertyArrayAggregationHelper& rPH = static_cast< OPropertyArrayAggregationHelper& >( getInfoHelper() );
     649        8923 :     OUString aPropName;
     650        8923 :     sal_Int32   nOriginalHandle = -1;
     651             : 
     652             :     // does the handle belong to the aggregation ?
     653        8923 :     if (rPH.fillAggregatePropertyInfoByHandle(&aPropName, &nOriginalHandle, _nHandle))
     654        5293 :         if (m_xAggregateFastSet.is())
     655        5001 :             m_xAggregateFastSet->setFastPropertyValue(nOriginalHandle, _rValue);
     656             :         else
     657         292 :             m_xAggregateSet->setPropertyValue(aPropName, _rValue);
     658             :     else
     659        3670 :         OPropertySetHelper::setFastPropertyValue(_nHandle, _rValue);
     660        8883 : }
     661             : 
     662             : 
     663       45172 : void OPropertySetAggregationHelper::getFastPropertyValue( ::com::sun::star::uno::Any& rValue, sal_Int32 nHandle) const
     664             : {
     665       45172 :     OPropertyArrayAggregationHelper& rPH = (OPropertyArrayAggregationHelper&)const_cast<OPropertySetAggregationHelper*>(this)->getInfoHelper();
     666       45172 :     OUString aPropName;
     667       45172 :     sal_Int32   nOriginalHandle = -1;
     668             : 
     669       45172 :     if (rPH.fillAggregatePropertyInfoByHandle(&aPropName, &nOriginalHandle, nHandle))
     670             :     {
     671       44772 :         if (m_xAggregateFastSet.is())
     672       44772 :             rValue = m_xAggregateFastSet->getFastPropertyValue(nOriginalHandle);
     673             :         else
     674           0 :             rValue = m_xAggregateSet->getPropertyValue(aPropName);
     675             :     }
     676         400 :     else if ( m_pForwarder->isResponsibleFor( nHandle ) )
     677             :     {
     678             :         // this is a property which has been "overwritten" in our instance (thus
     679             :         // fillAggregatePropertyInfoByHandle didn't find it)
     680         400 :         rValue = m_xAggregateSet->getPropertyValue( getPropertyName( nHandle ) );
     681       45172 :     }
     682       45172 : }
     683             : 
     684             : 
     685       37618 :  ::com::sun::star::uno::Any SAL_CALL OPropertySetAggregationHelper::getFastPropertyValue(sal_Int32 nHandle)
     686             :         throw(   ::com::sun::star::beans::UnknownPropertyException,
     687             :                  ::com::sun::star::lang::WrappedTargetException,
     688             :                  ::com::sun::star::uno::RuntimeException, std::exception)
     689             : {
     690       37618 :     OPropertyArrayAggregationHelper& rPH = static_cast< OPropertyArrayAggregationHelper& >( getInfoHelper() );
     691       37618 :     OUString aPropName;
     692       37618 :     sal_Int32   nOriginalHandle = -1;
     693       37618 :      ::com::sun::star::uno::Any  aValue;
     694             : 
     695       37618 :     if (rPH.fillAggregatePropertyInfoByHandle(&aPropName, &nOriginalHandle, nHandle))
     696             :     {
     697       18176 :         if (m_xAggregateFastSet.is())
     698       11921 :             aValue = m_xAggregateFastSet->getFastPropertyValue(nOriginalHandle);
     699             :         else
     700        6255 :             aValue = m_xAggregateSet->getPropertyValue(aPropName);
     701             :     }
     702             :     else
     703       19442 :         aValue = OPropertySetHelper::getFastPropertyValue(nHandle);
     704             : 
     705       37442 :     return aValue;
     706             : }
     707             : 
     708             : 
     709         878 : void SAL_CALL OPropertySetAggregationHelper::setPropertyValues(
     710             :         const Sequence< OUString >& _rPropertyNames, const Sequence< Any >& _rValues )
     711             :     throw ( PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException, std::exception )
     712             : {
     713             :     OSL_ENSURE( !rBHelper.bInDispose, "OPropertySetAggregationHelper::setPropertyValues : do not use within the dispose call !");
     714             :     OSL_ENSURE( !rBHelper.bDisposed, "OPropertySetAggregationHelper::setPropertyValues : object is disposed" );
     715             : 
     716             :     // check where the properties come from
     717         878 :     if (!m_xAggregateSet.is())
     718          51 :         OPropertySetHelper::setPropertyValues(_rPropertyNames, _rValues);
     719         827 :     else if (_rPropertyNames.getLength() == 1) // use the more efficient way
     720             :     {
     721             :         try
     722             :         {
     723          49 :             setPropertyValue( _rPropertyNames[0], _rValues[0] );
     724             :         }
     725           0 :         catch( const UnknownPropertyException& )
     726             :         {
     727             :             // by definition of XMultiPropertySet::setPropertyValues, unknown properties are to be ignored
     728             :         #if OSL_DEBUG_LEVEL > 0
     729             :             OStringBuffer aMessage;
     730             :             aMessage.append( "OPropertySetAggregationHelper::setPropertyValues: unknown property '" );
     731             :             aMessage.append( OUStringToOString( _rPropertyNames[0], RTL_TEXTENCODING_ASCII_US ) );
     732             :             aMessage.append( "'" );
     733             :             aMessage.append( "\n(implementation " );
     734             :             aMessage.append( typeid( *this ).name() );
     735             :             aMessage.append( ")" );
     736             :             OSL_FAIL( aMessage.getStr() );
     737             :         #endif
     738             :         }
     739             :     }
     740             :     else
     741             :     {
     742         778 :         OPropertyArrayAggregationHelper& rPH = static_cast< OPropertyArrayAggregationHelper& >( getInfoHelper() );
     743             : 
     744             :         // determine which properties belong to the aggregate, and which ones to the delegator
     745         778 :         const OUString* pNames = _rPropertyNames.getConstArray();
     746         778 :         sal_Int32 nAggCount(0);
     747         778 :         sal_Int32 nLen(_rPropertyNames.getLength());
     748             : 
     749       30285 :         for ( sal_Int32 i = 0; i < nLen; ++i, ++pNames )
     750             :         {
     751       29509 :             OPropertyArrayAggregationHelper::PropertyOrigin ePropOrg = rPH.classifyProperty( *pNames );
     752       29509 :             if ( OPropertyArrayAggregationHelper::UNKNOWN_PROPERTY == ePropOrg )
     753           2 :                 throw WrappedTargetException( OUString(), static_cast< XMultiPropertySet* >( this ), makeAny( UnknownPropertyException( ) ) );
     754             :                 // due to a flaw in the API design, this method is not allowed to throw an UnknownPropertyException
     755             :                 // so we wrap it into a WrappedTargetException
     756             : 
     757       29507 :             if ( OPropertyArrayAggregationHelper::AGGREGATE_PROPERTY == ePropOrg )
     758       22186 :                 ++nAggCount;
     759             :         }
     760             : 
     761         776 :         pNames = _rPropertyNames.getConstArray();   // reset, we'll need it again below ...
     762             : 
     763             :         // all properties belong to the aggregate
     764         776 :         if (nAggCount == nLen)
     765          21 :             m_xAggregateMultiSet->setPropertyValues(_rPropertyNames, _rValues);
     766             : 
     767             :         // all properties belong to the aggregating object
     768         755 :         else if (nAggCount == 0)
     769          40 :             OPropertySetHelper::setPropertyValues(_rPropertyNames, _rValues);
     770             : 
     771             :         // mixed
     772             :         else
     773             :         {
     774         715 :             const  ::com::sun::star::uno::Any* pValues = _rValues.getConstArray();
     775             : 
     776             :             try
     777             :             {
     778             :                 // dividing the Names and _rValues
     779             : 
     780             :                 // aggregate's names
     781         715 :                 Sequence< OUString > AggPropertyNames( nAggCount );
     782         715 :                 OUString* pAggNames = AggPropertyNames.getArray();
     783             :                 // aggregate's values
     784        1430 :                 Sequence< Any >  AggValues( nAggCount );
     785         715 :                 Any* pAggValues = AggValues.getArray();
     786             : 
     787             :                 // delegator names
     788        1430 :                 Sequence< OUString > DelPropertyNames( nLen - nAggCount );
     789         715 :                 OUString* pDelNames = DelPropertyNames.getArray();
     790             : 
     791             :                 // delegator values
     792        1430 :                 Sequence< Any > DelValues( nLen - nAggCount );
     793         715 :                 Any* pDelValues = DelValues.getArray();
     794             : 
     795       29200 :                 for ( sal_Int32 i = 0; i < nLen; ++i, ++pNames, ++pValues )
     796             :                 {
     797       28485 :                     if ( OPropertyArrayAggregationHelper::AGGREGATE_PROPERTY == rPH.classifyProperty( *pNames ) )
     798             :                     {
     799       22028 :                         *pAggNames++ = *pNames;
     800       22028 :                         *pAggValues++ = *pValues;
     801             :                     }
     802             :                     else
     803             :                     {
     804        6457 :                         *pDelNames++ = *pNames;
     805        6457 :                         *pDelValues++ = *pValues;
     806             :                     }
     807             :                 }
     808             : 
     809             :                 // reset, needed below
     810         715 :                 pDelValues = DelValues.getArray();
     811             : 
     812        1430 :                 boost::scoped_array<sal_Int32> pHandles(new sal_Int32[ nLen - nAggCount ]);
     813             : 
     814             :                 // get the map table
     815         715 :                 cppu::IPropertyArrayHelper& rPH2 = getInfoHelper();
     816             : 
     817             :                 // fill the handle array
     818         715 :                 sal_Int32 nHitCount = rPH2.fillHandles( pHandles.get(), DelPropertyNames );
     819         715 :                 if (nHitCount != 0)
     820             :                 {
     821         715 :                     boost::scoped_array< ::com::sun::star::uno::Any> pConvertedValues(new  ::com::sun::star::uno::Any[ nHitCount ]);
     822        1430 :                     boost::scoped_array< ::com::sun::star::uno::Any> pOldValues(new  ::com::sun::star::uno::Any[ nHitCount ]);
     823         715 :                     nHitCount = 0;
     824             :                     sal_Int32 i;
     825             : 
     826             :                     {
     827             :                     // must lock the mutex outside the loop. So all values are consistent.
     828         715 :                         osl::MutexGuard aGuard( rBHelper.rMutex );
     829        7172 :                         for( i = 0; i < (nLen - nAggCount); ++i )
     830             :                         {
     831        6457 :                             if( pHandles[i] != -1 )
     832             :                             {
     833             :                                 sal_Int16 nAttributes;
     834        6457 :                                 rPH2.fillPropertyMembersByHandle( NULL, &nAttributes, pHandles[i] );
     835        6457 :                                 if( nAttributes &  ::com::sun::star::beans::PropertyAttribute::READONLY )
     836           0 :                                     throw  ::com::sun::star::beans::PropertyVetoException();
     837             :                                 // Will the property change?
     838       12914 :                                 if( convertFastPropertyValue( pConvertedValues[ nHitCount ], pOldValues[nHitCount],
     839       12914 :                                                             pHandles[i], pDelValues[i] ) )
     840             :                                 {
     841             :                                     // only increment if the property really change
     842         518 :                                     pHandles[nHitCount]         = pHandles[i];
     843         518 :                                     nHitCount++;
     844             :                                 }
     845             :                             }
     846         715 :                         }
     847             :                     // release guard to fire events
     848             :                     }
     849             : 
     850             :                     // fire vetoable events
     851         715 :                     fire( pHandles.get(), pConvertedValues.get(), pOldValues.get(), nHitCount, sal_True );
     852             : 
     853             :                     // setting the agg Properties
     854         715 :                     m_xAggregateMultiSet->setPropertyValues(AggPropertyNames, AggValues);
     855             : 
     856             :                     {
     857             :                     // must lock the mutex outside the loop.
     858         714 :                         osl::MutexGuard aGuard( rBHelper.rMutex );
     859             :                         // Loop over all changed properties
     860        1226 :                         for( i = 0; i < nHitCount; i++ )
     861             :                         {
     862             :                             // Will the property change?
     863         512 :                             setFastPropertyValue_NoBroadcast( pHandles[i], pConvertedValues[i] );
     864         714 :                         }
     865             :                     // release guard to fire events
     866             :                     }
     867             : 
     868             :                     // fire change events
     869        1429 :                     fire( pHandles.get(), pConvertedValues.get(), pOldValues.get(), nHitCount, sal_False );
     870             :                 }
     871             :                 else
     872         715 :                     m_xAggregateMultiSet->setPropertyValues(AggPropertyNames, AggValues);
     873             : 
     874             :             }
     875           1 :             catch(::com::sun::star::uno::Exception&)
     876             :             {
     877           1 :                 throw;
     878             :             }
     879             :         }
     880             :     }
     881         856 : }
     882             : 
     883             : // XPropertyState
     884             : 
     885         320 :  ::com::sun::star::beans::PropertyState SAL_CALL OPropertySetAggregationHelper::getPropertyState(const OUString& _rPropertyName)
     886             :             throw( ::com::sun::star::beans::UnknownPropertyException,  ::com::sun::star::uno::RuntimeException, std::exception)
     887             : {
     888         320 :     OPropertyArrayAggregationHelper& rPH = static_cast< OPropertyArrayAggregationHelper& >( getInfoHelper() );
     889         320 :     sal_Int32 nHandle = rPH.getHandleByName( _rPropertyName );
     890             : 
     891         320 :     if (nHandle == -1)
     892             :     {
     893           0 :         throw  ::com::sun::star::beans::UnknownPropertyException();
     894             :     }
     895             : 
     896         320 :     OUString aPropName;
     897         320 :     sal_Int32   nOriginalHandle = -1;
     898         320 :     if (rPH.fillAggregatePropertyInfoByHandle(&aPropName, &nOriginalHandle, nHandle))
     899             :     {
     900         282 :         if (m_xAggregateState.is())
     901         282 :             return m_xAggregateState->getPropertyState(_rPropertyName);
     902             :         else
     903           0 :             return  ::com::sun::star::beans::PropertyState_DIRECT_VALUE;
     904             :     }
     905             :     else
     906          38 :         return getPropertyStateByHandle(nHandle);
     907             : }
     908             : 
     909             : 
     910          19 : void SAL_CALL OPropertySetAggregationHelper::setPropertyToDefault(const OUString& _rPropertyName)
     911             :         throw( ::com::sun::star::beans::UnknownPropertyException,  ::com::sun::star::uno::RuntimeException, std::exception)
     912             : {
     913          19 :     OPropertyArrayAggregationHelper& rPH = static_cast< OPropertyArrayAggregationHelper& >( getInfoHelper() );
     914          19 :     sal_Int32 nHandle = rPH.getHandleByName(_rPropertyName);
     915          19 :     if (nHandle == -1)
     916             :     {
     917           0 :         throw  ::com::sun::star::beans::UnknownPropertyException();
     918             :     }
     919             : 
     920          19 :     OUString aPropName;
     921          19 :     sal_Int32   nOriginalHandle = -1;
     922          19 :     if (rPH.fillAggregatePropertyInfoByHandle(&aPropName, &nOriginalHandle, nHandle))
     923             :     {
     924          16 :         if (m_xAggregateState.is())
     925          16 :             m_xAggregateState->setPropertyToDefault(_rPropertyName);
     926             :     }
     927             :     else
     928             :     {
     929             :         try
     930             :         {
     931           3 :             setPropertyToDefaultByHandle( nHandle );
     932             :         }
     933           0 :         catch( const UnknownPropertyException& ) { throw; }
     934           0 :         catch( const RuntimeException& ) { throw; }
     935           0 :         catch( const Exception& )
     936             :         {
     937             :             OSL_FAIL( "OPropertySetAggregationHelper::setPropertyToDefault: caught an exception which is not allowed to leave here!" );
     938             :         }
     939          19 :     }
     940          19 : }
     941             : 
     942             : 
     943          19 :  ::com::sun::star::uno::Any SAL_CALL OPropertySetAggregationHelper::getPropertyDefault(const OUString& aPropertyName)
     944             :         throw( ::com::sun::star::beans::UnknownPropertyException,  ::com::sun::star::lang::WrappedTargetException,  ::com::sun::star::uno::RuntimeException, std::exception)
     945             : {
     946          19 :     OPropertyArrayAggregationHelper& rPH = static_cast< OPropertyArrayAggregationHelper& >( getInfoHelper() );
     947          19 :     sal_Int32 nHandle = rPH.getHandleByName( aPropertyName );
     948             : 
     949          19 :     if ( nHandle == -1 )
     950           0 :         throw  ::com::sun::star::beans::UnknownPropertyException();
     951             : 
     952          19 :     OUString aPropName;
     953          19 :     sal_Int32   nOriginalHandle = -1;
     954          19 :     if (rPH.fillAggregatePropertyInfoByHandle(&aPropName, &nOriginalHandle, nHandle))
     955             :     {
     956          16 :         if (m_xAggregateState.is())
     957          16 :             return m_xAggregateState->getPropertyDefault(aPropertyName);
     958             :         else
     959           0 :             return  ::com::sun::star::uno::Any();
     960             :     }
     961             :     else
     962           3 :         return getPropertyDefaultByHandle(nHandle);
     963             : }
     964             : 
     965             : 
     966         174 : sal_Bool SAL_CALL OPropertySetAggregationHelper::convertFastPropertyValue( Any& _rConvertedValue, Any& _rOldValue, sal_Int32 _nHandle, const Any& _rValue ) throw(IllegalArgumentException)
     967             : {
     968         174 :     bool bModified = false;
     969             : 
     970             :     OSL_ENSURE( m_pForwarder->isResponsibleFor( _nHandle ), "OPropertySetAggregationHelper::convertFastPropertyValue: this is no forwarded property - did you use declareForwardedProperty for it?" );
     971         174 :     if ( m_pForwarder->isResponsibleFor( _nHandle ) )
     972             :     {
     973             :         // need to determine the type of the property for conversion
     974         174 :         OPropertyArrayAggregationHelper& rPH = static_cast< OPropertyArrayAggregationHelper& >( getInfoHelper() );
     975         174 :         Property aProperty;
     976         174 :         OSL_VERIFY( rPH.getPropertyByHandle( _nHandle, aProperty ) );
     977             : 
     978         348 :         Any aCurrentValue;
     979         174 :         getFastPropertyValue( aCurrentValue, _nHandle );
     980         348 :         bModified = tryPropertyValue( _rConvertedValue, _rOldValue, _rValue, aCurrentValue, aProperty.Type );
     981             :     }
     982             : 
     983         174 :     return bModified;
     984             : }
     985             : 
     986             : 
     987         162 : void SAL_CALL OPropertySetAggregationHelper::setFastPropertyValue_NoBroadcast( sal_Int32 _nHandle, const Any& _rValue ) throw ( Exception, std::exception )
     988             : {
     989             :     OSL_ENSURE( m_pForwarder->isResponsibleFor( _nHandle ), "OPropertySetAggregationHelper::setFastPropertyValue_NoBroadcast: this is no forwarded property - did you use declareForwardedProperty for it?" );
     990         162 :     if ( m_pForwarder->isResponsibleFor( _nHandle ) )
     991         162 :         m_pForwarder->doForward( _nHandle, _rValue );
     992         162 : }
     993             : 
     994             : 
     995         162 : void OPropertySetAggregationHelper::declareForwardedProperty( sal_Int32 _nHandle )
     996             : {
     997             :     OSL_ENSURE( !m_pForwarder->isResponsibleFor( _nHandle ), "OPropertySetAggregationHelper::declareForwardedProperty: already declared!" );
     998         162 :     m_pForwarder->takeResponsibilityFor( _nHandle );
     999         162 : }
    1000             : 
    1001             : 
    1002           0 : void OPropertySetAggregationHelper::forwardingPropertyValue( sal_Int32 )
    1003             : {
    1004             :     // not interested in
    1005           0 : }
    1006             : 
    1007             : 
    1008           0 : void OPropertySetAggregationHelper::forwardedPropertyValue( sal_Int32 )
    1009             : {
    1010             :     // not interested in
    1011           0 : }
    1012             : 
    1013             : 
    1014        5118 : bool OPropertySetAggregationHelper::isCurrentlyForwardingProperty( sal_Int32 _nHandle ) const
    1015             : {
    1016        5118 :     return m_pForwarder->getCurrentlyForwardedProperty() == _nHandle;
    1017             : }
    1018             : 
    1019             : 
    1020             : }   // namespace comphelper
    1021             : 
    1022             : 
    1023             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10