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