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