From d3a48ab9c41bd4c7ba6b48fb70ce6b55026c9b20 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Fri, 24 Sep 2010 09:36:58 +0200 Subject: dba34a: #i114698# when a property is present in both the aggregate and the delegatee, expose it only once, and route access to it to the delegatee --- comphelper/source/property/propagg.cxx | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'comphelper/source/property') diff --git a/comphelper/source/property/propagg.cxx b/comphelper/source/property/propagg.cxx index e796c29eba90..9c2fd868d973 100644 --- a/comphelper/source/property/propagg.cxx +++ b/comphelper/source/property/propagg.cxx @@ -87,20 +87,36 @@ OPropertyArrayAggregationHelper::OPropertyArrayAggregationHelper( const Property* pDelegateProps = _rProperties.getConstArray(); Property* pMergedProps = m_aProperties.getArray(); + // if properties are present both at the delegatee and the aggregate, then the former are supposed to win. + // So, we'll need an existence check. + ::std::set< ::rtl::OUString > aDelegatorProps; + // create the map for the delegator properties sal_Int32 nMPLoop = 0; for ( ; nMPLoop < nDelegatorProps; ++nMPLoop, ++pDelegateProps ) + { m_aPropertyAccessors[ pDelegateProps->Handle ] = OPropertyAccessor( -1, nMPLoop, sal_False ); + OSL_ENSURE( aDelegatorProps.find( pDelegateProps->Name ) == aDelegatorProps.end(), + "OPropertyArrayAggregationHelper::OPropertyArrayAggregationHelper: duplicate delegatee property!" ); + aDelegatorProps.insert( pDelegateProps->Name ); + } // create the map for the aggregate properties sal_Int32 nAggregateHandle = _nFirstAggregateId; pMergedProps += nDelegatorProps; - for ( ; nMPLoop < nMergedProps; ++nMPLoop, ++pMergedProps, ++pAggregateProps ) + for ( ; nMPLoop < nMergedProps; ++pAggregateProps ) { + // if the aggregate property is present at the delegatee already, ignore it + if ( aDelegatorProps.find( pAggregateProps->Name ) != aDelegatorProps.end() ) + { + --nMergedProps; + continue; + } + // next aggregate property - remember it *pMergedProps = *pAggregateProps; - // determine the handle for the property which we will expose to the ourside world + // determine the handle for the property which we will expose to the outside world sal_Int32 nHandle = -1; // ask the infor service first if ( _pInfoService ) @@ -123,7 +139,11 @@ OPropertyArrayAggregationHelper::OPropertyArrayAggregationHelper( // remember the accessor for this property m_aPropertyAccessors[ nHandle ] = OPropertyAccessor( pMergedProps->Handle, nMPLoop, sal_True ); pMergedProps->Handle = nHandle; + + ++nMPLoop; + ++pMergedProps; } + m_aProperties.realloc( nMergedProps ); pMergedProps = m_aProperties.getArray(); // reset, needed again below // sortieren der Properties nach Namen -- cgit