1*dde7d3faSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*dde7d3faSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*dde7d3faSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*dde7d3faSAndrew Rist  * distributed with this work for additional information
6*dde7d3faSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*dde7d3faSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*dde7d3faSAndrew Rist  * "License"); you may not use this file except in compliance
9*dde7d3faSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*dde7d3faSAndrew Rist  *
11*dde7d3faSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*dde7d3faSAndrew Rist  *
13*dde7d3faSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*dde7d3faSAndrew Rist  * software distributed under the License is distributed on an
15*dde7d3faSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*dde7d3faSAndrew Rist  * KIND, either express or implied.  See the License for the
17*dde7d3faSAndrew Rist  * specific language governing permissions and limitations
18*dde7d3faSAndrew Rist  * under the License.
19*dde7d3faSAndrew Rist  *
20*dde7d3faSAndrew Rist  *************************************************************/
21*dde7d3faSAndrew Rist 
22*dde7d3faSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_comphelper.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #ifndef _COMPHELPER_MASTERPROPERTYSET_HXX_
28cdf0e10cSrcweir #include <comphelper/MasterPropertySet.hxx>
29cdf0e10cSrcweir #endif
30cdf0e10cSrcweir #include <comphelper/MasterPropertySetInfo.hxx>
31cdf0e10cSrcweir #include <comphelper/ChainablePropertySet.hxx>
32cdf0e10cSrcweir #include <comphelper/ChainablePropertySetInfo.hxx>
33cdf0e10cSrcweir #include <vos/mutex.hxx>
34cdf0e10cSrcweir 
35cdf0e10cSrcweir #include <memory>       // STL auto_ptr
36cdf0e10cSrcweir 
37cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////
38cdf0e10cSrcweir 
39cdf0e10cSrcweir class AutoOGuardArray
40cdf0e10cSrcweir {
41cdf0e10cSrcweir     sal_Int32                       nSize;
42cdf0e10cSrcweir     std::auto_ptr< vos::OGuard > *  pGuardArray;
43cdf0e10cSrcweir 
44cdf0e10cSrcweir public:
45cdf0e10cSrcweir     AutoOGuardArray( sal_Int32 nNumElements );
46cdf0e10cSrcweir     ~AutoOGuardArray();
47cdf0e10cSrcweir 
operator [](sal_Int32 i)48cdf0e10cSrcweir     std::auto_ptr< vos::OGuard > &  operator[] ( sal_Int32 i ) { return pGuardArray[i]; }
49cdf0e10cSrcweir };
50cdf0e10cSrcweir 
AutoOGuardArray(sal_Int32 nNumElements)51cdf0e10cSrcweir AutoOGuardArray::AutoOGuardArray( sal_Int32 nNumElements )
52cdf0e10cSrcweir {
53cdf0e10cSrcweir     nSize       = nNumElements;
54cdf0e10cSrcweir     pGuardArray = new std::auto_ptr< vos::OGuard >[ nSize ];
55cdf0e10cSrcweir }
56cdf0e10cSrcweir 
~AutoOGuardArray()57cdf0e10cSrcweir AutoOGuardArray::~AutoOGuardArray()
58cdf0e10cSrcweir {
59cdf0e10cSrcweir     //!! release auto_ptr's and thus the mutexes locks
60cdf0e10cSrcweir     delete [] pGuardArray;
61cdf0e10cSrcweir 
62cdf0e10cSrcweir }
63cdf0e10cSrcweir 
64cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////
65cdf0e10cSrcweir 
66cdf0e10cSrcweir using namespace ::rtl;
67cdf0e10cSrcweir using namespace ::comphelper;
68cdf0e10cSrcweir using namespace ::com::sun::star;
69cdf0e10cSrcweir using namespace ::com::sun::star::uno;
70cdf0e10cSrcweir using namespace ::com::sun::star::lang;
71cdf0e10cSrcweir using namespace ::com::sun::star::beans;
72cdf0e10cSrcweir using vos::IMutex;
73cdf0e10cSrcweir 
SlaveData(ChainablePropertySet * pSlave)74cdf0e10cSrcweir SlaveData::SlaveData ( ChainablePropertySet *pSlave)
75cdf0e10cSrcweir : mpSlave ( pSlave )
76cdf0e10cSrcweir , mxSlave ( pSlave )
77cdf0e10cSrcweir , mbInit ( sal_False )
78cdf0e10cSrcweir {
79cdf0e10cSrcweir }
80cdf0e10cSrcweir 
MasterPropertySet(comphelper::MasterPropertySetInfo * pInfo,IMutex * pMutex)81cdf0e10cSrcweir MasterPropertySet::MasterPropertySet( comphelper::MasterPropertySetInfo* pInfo, IMutex *pMutex )
82cdf0e10cSrcweir 	throw()
83cdf0e10cSrcweir : mpInfo ( pInfo )
84cdf0e10cSrcweir , mpMutex ( pMutex )
85cdf0e10cSrcweir , mnLastId ( 0 )
86cdf0e10cSrcweir , mxInfo ( pInfo )
87cdf0e10cSrcweir {
88cdf0e10cSrcweir }
89cdf0e10cSrcweir 
lockMutex()90cdf0e10cSrcweir void MasterPropertySet::lockMutex()
91cdf0e10cSrcweir {
92cdf0e10cSrcweir 	if (mpMutex)
93cdf0e10cSrcweir 		mpMutex->acquire();
94cdf0e10cSrcweir }
unlockMutex()95cdf0e10cSrcweir void MasterPropertySet::unlockMutex()
96cdf0e10cSrcweir {
97cdf0e10cSrcweir 	if (mpMutex)
98cdf0e10cSrcweir 		mpMutex->release();
99cdf0e10cSrcweir }
100cdf0e10cSrcweir 
~MasterPropertySet()101cdf0e10cSrcweir MasterPropertySet::~MasterPropertySet()
102cdf0e10cSrcweir 	throw()
103cdf0e10cSrcweir {
104cdf0e10cSrcweir 	SlaveMap::iterator aEnd = maSlaveMap.end(), aIter = maSlaveMap.begin();
105cdf0e10cSrcweir 	while (aIter != aEnd )
106cdf0e10cSrcweir 	{
107cdf0e10cSrcweir 		delete (*aIter).second;
108cdf0e10cSrcweir 		aIter++;
109cdf0e10cSrcweir 	}
110cdf0e10cSrcweir }
111cdf0e10cSrcweir 
112cdf0e10cSrcweir // XPropertySet
getPropertySetInfo()113cdf0e10cSrcweir Reference< XPropertySetInfo > SAL_CALL MasterPropertySet::getPropertySetInfo(  )
114cdf0e10cSrcweir 	throw(RuntimeException)
115cdf0e10cSrcweir {
116cdf0e10cSrcweir 	return mxInfo;
117cdf0e10cSrcweir }
118cdf0e10cSrcweir 
registerSlave(ChainablePropertySet * pNewSet)119cdf0e10cSrcweir void MasterPropertySet::registerSlave ( ChainablePropertySet *pNewSet )
120cdf0e10cSrcweir 	throw()
121cdf0e10cSrcweir {
122cdf0e10cSrcweir 	maSlaveMap [ ++mnLastId ] = new SlaveData ( pNewSet );
123cdf0e10cSrcweir 	mpInfo->add ( pNewSet->mpInfo->maMap, mnLastId );
124cdf0e10cSrcweir }
125cdf0e10cSrcweir 
setPropertyValue(const::rtl::OUString & rPropertyName,const Any & rValue)126cdf0e10cSrcweir void SAL_CALL MasterPropertySet::setPropertyValue( const ::rtl::OUString& rPropertyName, const Any& rValue )
127cdf0e10cSrcweir 	throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException)
128cdf0e10cSrcweir {
129cdf0e10cSrcweir     // acquire mutex in c-tor and releases it in the d-tor (exception safe!).
130cdf0e10cSrcweir     std::auto_ptr< vos::OGuard > pMutexGuard;
131cdf0e10cSrcweir     if (mpMutex)
132cdf0e10cSrcweir         pMutexGuard.reset( new vos::OGuard(mpMutex) );
133cdf0e10cSrcweir 
134cdf0e10cSrcweir     PropertyDataHash::const_iterator aIter = mpInfo->maMap.find ( rPropertyName );
135cdf0e10cSrcweir 
136cdf0e10cSrcweir 	if( aIter == mpInfo->maMap.end())
137cdf0e10cSrcweir 		throw UnknownPropertyException( rPropertyName, static_cast< XPropertySet* >( this ) );
138cdf0e10cSrcweir 
139cdf0e10cSrcweir 	if ( (*aIter).second->mnMapId == 0 ) // 0 means it's one of ours !
140cdf0e10cSrcweir 	{
141cdf0e10cSrcweir 		_preSetValues();
142cdf0e10cSrcweir 		_setSingleValue( *((*aIter).second->mpInfo), rValue );
143cdf0e10cSrcweir 		_postSetValues();
144cdf0e10cSrcweir 	}
145cdf0e10cSrcweir 	else
146cdf0e10cSrcweir 	{
147cdf0e10cSrcweir         ChainablePropertySet * pSlave = maSlaveMap [ (*aIter).second->mnMapId ]->mpSlave;
148cdf0e10cSrcweir 
149cdf0e10cSrcweir         // acquire mutex in c-tor and releases it in the d-tor (exception safe!).
150cdf0e10cSrcweir         std::auto_ptr< vos::OGuard > pMutexGuard2;
151cdf0e10cSrcweir         if (pSlave->mpMutex)
152cdf0e10cSrcweir             pMutexGuard2.reset( new vos::OGuard(pSlave->mpMutex) );
153cdf0e10cSrcweir 
154cdf0e10cSrcweir 		pSlave->_preSetValues();
155cdf0e10cSrcweir 		pSlave->_setSingleValue( *((*aIter).second->mpInfo), rValue );
156cdf0e10cSrcweir 		pSlave->_postSetValues();
157cdf0e10cSrcweir 	}
158cdf0e10cSrcweir }
159cdf0e10cSrcweir 
getPropertyValue(const::rtl::OUString & rPropertyName)160cdf0e10cSrcweir Any SAL_CALL MasterPropertySet::getPropertyValue( const ::rtl::OUString& rPropertyName )
161cdf0e10cSrcweir 	throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
162cdf0e10cSrcweir {
163cdf0e10cSrcweir     // acquire mutex in c-tor and releases it in the d-tor (exception safe!).
164cdf0e10cSrcweir     std::auto_ptr< vos::OGuard > pMutexGuard;
165cdf0e10cSrcweir     if (mpMutex)
166cdf0e10cSrcweir         pMutexGuard.reset( new vos::OGuard(mpMutex) );
167cdf0e10cSrcweir 
168cdf0e10cSrcweir     PropertyDataHash::const_iterator aIter = mpInfo->maMap.find ( rPropertyName );
169cdf0e10cSrcweir 
170cdf0e10cSrcweir 	if( aIter == mpInfo->maMap.end())
171cdf0e10cSrcweir 		throw UnknownPropertyException( rPropertyName, static_cast< XPropertySet* >( this ) );
172cdf0e10cSrcweir 
173cdf0e10cSrcweir 	Any aAny;
174cdf0e10cSrcweir 	if ( (*aIter).second->mnMapId == 0 ) // 0 means it's one of ours !
175cdf0e10cSrcweir 	{
176cdf0e10cSrcweir 		_preGetValues();
177cdf0e10cSrcweir 		_getSingleValue( *((*aIter).second->mpInfo), aAny );
178cdf0e10cSrcweir 		_postGetValues();
179cdf0e10cSrcweir 	}
180cdf0e10cSrcweir 	else
181cdf0e10cSrcweir 	{
182cdf0e10cSrcweir 		ChainablePropertySet * pSlave = maSlaveMap [ (*aIter).second->mnMapId ]->mpSlave;
183cdf0e10cSrcweir 
184cdf0e10cSrcweir         // acquire mutex in c-tor and releases it in the d-tor (exception safe!).
185cdf0e10cSrcweir         std::auto_ptr< vos::OGuard > pMutexGuard2;
186cdf0e10cSrcweir         if (pSlave->mpMutex)
187cdf0e10cSrcweir             pMutexGuard2.reset( new vos::OGuard(pSlave->mpMutex) );
188cdf0e10cSrcweir 
189cdf0e10cSrcweir 		pSlave->_preGetValues();
190cdf0e10cSrcweir 		pSlave->_getSingleValue( *((*aIter).second->mpInfo), aAny );
191cdf0e10cSrcweir 		pSlave->_postGetValues();
192cdf0e10cSrcweir 	}
193cdf0e10cSrcweir 	return aAny;
194cdf0e10cSrcweir }
195cdf0e10cSrcweir 
addPropertyChangeListener(const::rtl::OUString &,const Reference<XPropertyChangeListener> &)196cdf0e10cSrcweir void SAL_CALL MasterPropertySet::addPropertyChangeListener( const ::rtl::OUString&, const Reference< XPropertyChangeListener >& )
197cdf0e10cSrcweir 	throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
198cdf0e10cSrcweir {
199cdf0e10cSrcweir 	// todo
200cdf0e10cSrcweir }
201cdf0e10cSrcweir 
removePropertyChangeListener(const::rtl::OUString &,const Reference<XPropertyChangeListener> &)202cdf0e10cSrcweir void SAL_CALL MasterPropertySet::removePropertyChangeListener( const ::rtl::OUString&, const Reference< XPropertyChangeListener >& )
203cdf0e10cSrcweir 	throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
204cdf0e10cSrcweir {
205cdf0e10cSrcweir 	// todo
206cdf0e10cSrcweir }
207cdf0e10cSrcweir 
addVetoableChangeListener(const::rtl::OUString &,const Reference<XVetoableChangeListener> &)208cdf0e10cSrcweir void SAL_CALL MasterPropertySet::addVetoableChangeListener( const ::rtl::OUString&, const Reference< XVetoableChangeListener >& )
209cdf0e10cSrcweir 	throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
210cdf0e10cSrcweir {
211cdf0e10cSrcweir 	// todo
212cdf0e10cSrcweir }
213cdf0e10cSrcweir 
removeVetoableChangeListener(const::rtl::OUString &,const Reference<XVetoableChangeListener> &)214cdf0e10cSrcweir void SAL_CALL MasterPropertySet::removeVetoableChangeListener( const ::rtl::OUString&, const Reference< XVetoableChangeListener >& )
215cdf0e10cSrcweir 	throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
216cdf0e10cSrcweir {
217cdf0e10cSrcweir 	// todo
218cdf0e10cSrcweir }
219cdf0e10cSrcweir 
220cdf0e10cSrcweir // XMultiPropertySet
setPropertyValues(const Sequence<::rtl::OUString> & aPropertyNames,const Sequence<Any> & aValues)221cdf0e10cSrcweir void SAL_CALL MasterPropertySet::setPropertyValues( const Sequence< ::rtl::OUString >& aPropertyNames, const Sequence< Any >& aValues )
222cdf0e10cSrcweir 	throw(PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException)
223cdf0e10cSrcweir {
224cdf0e10cSrcweir     // acquire mutex in c-tor and releases it in the d-tor (exception safe!).
225cdf0e10cSrcweir     std::auto_ptr< vos::OGuard > pMutexGuard;
226cdf0e10cSrcweir     if (mpMutex)
227cdf0e10cSrcweir         pMutexGuard.reset( new vos::OGuard(mpMutex) );
228cdf0e10cSrcweir 
229cdf0e10cSrcweir     const sal_Int32 nCount = aPropertyNames.getLength();
230cdf0e10cSrcweir 
231cdf0e10cSrcweir 	if( nCount != aValues.getLength() )
232cdf0e10cSrcweir 		throw IllegalArgumentException();
233cdf0e10cSrcweir 
234cdf0e10cSrcweir 	if( nCount )
235cdf0e10cSrcweir 	{
236cdf0e10cSrcweir 		_preSetValues();
237cdf0e10cSrcweir 
238cdf0e10cSrcweir 		const Any * pAny = aValues.getConstArray();
239cdf0e10cSrcweir 		const OUString * pString = aPropertyNames.getConstArray();
240cdf0e10cSrcweir 		PropertyDataHash::const_iterator aEnd = mpInfo->maMap.end(), aIter;
241cdf0e10cSrcweir 
242cdf0e10cSrcweir         //!! have an auto_ptr to an array of OGuards in order to have the
243cdf0e10cSrcweir         //!! allocated memory properly freed (exception safe!).
244cdf0e10cSrcweir         //!! Since the array itself has auto_ptrs as members we have to use a
245cdf0e10cSrcweir         //!! helper class 'AutoOGuardArray' in order to have
246cdf0e10cSrcweir         //!! the acquired locks properly released.
247cdf0e10cSrcweir         AutoOGuardArray aOGuardArray( nCount );
248cdf0e10cSrcweir 
249cdf0e10cSrcweir 		for ( sal_Int32 i = 0; i < nCount; ++i, ++pString, ++pAny )
250cdf0e10cSrcweir 		{
251cdf0e10cSrcweir 			aIter = mpInfo->maMap.find ( *pString );
252cdf0e10cSrcweir 			if ( aIter == aEnd )
253cdf0e10cSrcweir 				throw UnknownPropertyException( *pString, static_cast< XPropertySet* >( this ) );
254cdf0e10cSrcweir 
255cdf0e10cSrcweir 			if ( (*aIter).second->mnMapId == 0 ) // 0 means it's one of ours !
256cdf0e10cSrcweir 				_setSingleValue( *((*aIter).second->mpInfo), *pAny );
257cdf0e10cSrcweir 			else
258cdf0e10cSrcweir 			{
259cdf0e10cSrcweir 				SlaveData * pSlave = maSlaveMap [ (*aIter).second->mnMapId ];
260cdf0e10cSrcweir 				if (!pSlave->IsInit())
261cdf0e10cSrcweir 				{
262cdf0e10cSrcweir                     // acquire mutex in c-tor and releases it in the d-tor (exception safe!).
263cdf0e10cSrcweir                     if (pSlave->mpSlave->mpMutex)
264cdf0e10cSrcweir                         aOGuardArray[i].reset( new vos::OGuard(pSlave->mpSlave->mpMutex) );
265cdf0e10cSrcweir 
266cdf0e10cSrcweir 					pSlave->mpSlave->_preSetValues();
267cdf0e10cSrcweir 					pSlave->SetInit ( sal_True );
268cdf0e10cSrcweir 				}
269cdf0e10cSrcweir 				pSlave->mpSlave->_setSingleValue( *((*aIter).second->mpInfo), *pAny );
270cdf0e10cSrcweir 			}
271cdf0e10cSrcweir 		}
272cdf0e10cSrcweir 
273cdf0e10cSrcweir 		_postSetValues();
274cdf0e10cSrcweir 		SlaveMap::const_iterator aSlaveIter = maSlaveMap.begin(), aSlaveEnd = maSlaveMap.end();
275cdf0e10cSrcweir 		while (aSlaveIter != aSlaveEnd)
276cdf0e10cSrcweir 		{
277cdf0e10cSrcweir 			if ( (*aSlaveIter).second->IsInit())
278cdf0e10cSrcweir 			{
279cdf0e10cSrcweir 				(*aSlaveIter).second->mpSlave->_postSetValues();
280cdf0e10cSrcweir 				(*aSlaveIter).second->SetInit ( sal_False );
281cdf0e10cSrcweir 			}
282cdf0e10cSrcweir 			++aSlaveIter;
283cdf0e10cSrcweir 		}
284cdf0e10cSrcweir 	}
285cdf0e10cSrcweir }
286cdf0e10cSrcweir 
getPropertyValues(const Sequence<::rtl::OUString> & aPropertyNames)287cdf0e10cSrcweir Sequence< Any > SAL_CALL MasterPropertySet::getPropertyValues( const Sequence< ::rtl::OUString >& aPropertyNames )
288cdf0e10cSrcweir 	throw(RuntimeException)
289cdf0e10cSrcweir {
290cdf0e10cSrcweir     // acquire mutex in c-tor and releases it in the d-tor (exception safe!).
291cdf0e10cSrcweir     std::auto_ptr< vos::OGuard > pMutexGuard;
292cdf0e10cSrcweir     if (mpMutex)
293cdf0e10cSrcweir         pMutexGuard.reset( new vos::OGuard(mpMutex) );
294cdf0e10cSrcweir 
295cdf0e10cSrcweir     const sal_Int32 nCount = aPropertyNames.getLength();
296cdf0e10cSrcweir 
297cdf0e10cSrcweir 	Sequence < Any > aValues ( nCount );
298cdf0e10cSrcweir 
299cdf0e10cSrcweir 	if( nCount )
300cdf0e10cSrcweir 	{
301cdf0e10cSrcweir 		_preGetValues();
302cdf0e10cSrcweir 
303cdf0e10cSrcweir 		Any * pAny = aValues.getArray();
304cdf0e10cSrcweir 		const OUString * pString = aPropertyNames.getConstArray();
305cdf0e10cSrcweir 		PropertyDataHash::const_iterator aEnd = mpInfo->maMap.end(), aIter;
306cdf0e10cSrcweir 
307cdf0e10cSrcweir         //!! have an auto_ptr to an array of OGuards in order to have the
308cdf0e10cSrcweir         //!! allocated memory properly freed (exception safe!).
309cdf0e10cSrcweir         //!! Since the array itself has auto_ptrs as members we have to use a
310cdf0e10cSrcweir         //!! helper class 'AutoOGuardArray' in order to have
311cdf0e10cSrcweir         //!! the acquired locks properly released.
312cdf0e10cSrcweir         AutoOGuardArray aOGuardArray( nCount );
313cdf0e10cSrcweir 
314cdf0e10cSrcweir 		for ( sal_Int32 i = 0; i < nCount; ++i, ++pString, ++pAny )
315cdf0e10cSrcweir 		{
316cdf0e10cSrcweir 			aIter = mpInfo->maMap.find ( *pString );
317cdf0e10cSrcweir 			if ( aIter == aEnd )
318cdf0e10cSrcweir 				throw UnknownPropertyException( *pString, static_cast< XPropertySet* >( this ) );
319cdf0e10cSrcweir 
320cdf0e10cSrcweir 			if ( (*aIter).second->mnMapId == 0 ) // 0 means it's one of ours !
321cdf0e10cSrcweir 				_getSingleValue( *((*aIter).second->mpInfo), *pAny );
322cdf0e10cSrcweir 			else
323cdf0e10cSrcweir 			{
324cdf0e10cSrcweir 				SlaveData * pSlave = maSlaveMap [ (*aIter).second->mnMapId ];
325cdf0e10cSrcweir 				if (!pSlave->IsInit())
326cdf0e10cSrcweir 				{
327cdf0e10cSrcweir                     // acquire mutex in c-tor and releases it in the d-tor (exception safe!).
328cdf0e10cSrcweir                     if (pSlave->mpSlave->mpMutex)
329cdf0e10cSrcweir                         aOGuardArray[i].reset( new vos::OGuard(pSlave->mpSlave->mpMutex) );
330cdf0e10cSrcweir 
331cdf0e10cSrcweir 					pSlave->mpSlave->_preGetValues();
332cdf0e10cSrcweir 					pSlave->SetInit ( sal_True );
333cdf0e10cSrcweir 				}
334cdf0e10cSrcweir 				pSlave->mpSlave->_getSingleValue( *((*aIter).second->mpInfo), *pAny );
335cdf0e10cSrcweir 			}
336cdf0e10cSrcweir 		}
337cdf0e10cSrcweir 
338cdf0e10cSrcweir 		_postSetValues();
339cdf0e10cSrcweir 		SlaveMap::const_iterator aSlaveIter = maSlaveMap.begin(), aSlaveEnd = maSlaveMap.end();
340cdf0e10cSrcweir 		while (aSlaveIter != aSlaveEnd)
341cdf0e10cSrcweir 		{
342cdf0e10cSrcweir 			if ( (*aSlaveIter).second->IsInit())
343cdf0e10cSrcweir 			{
344cdf0e10cSrcweir 				(*aSlaveIter).second->mpSlave->_postSetValues();
345cdf0e10cSrcweir 				(*aSlaveIter).second->SetInit ( sal_False );
346cdf0e10cSrcweir 			}
347cdf0e10cSrcweir 			++aSlaveIter;
348cdf0e10cSrcweir 		}
349cdf0e10cSrcweir 	}
350cdf0e10cSrcweir 	return aValues;
351cdf0e10cSrcweir }
352cdf0e10cSrcweir 
addPropertiesChangeListener(const Sequence<::rtl::OUString> &,const Reference<XPropertiesChangeListener> &)353cdf0e10cSrcweir void SAL_CALL MasterPropertySet::addPropertiesChangeListener( const Sequence< ::rtl::OUString >&, const Reference< XPropertiesChangeListener >& )
354cdf0e10cSrcweir 	throw(RuntimeException)
355cdf0e10cSrcweir {
356cdf0e10cSrcweir 	// todo
357cdf0e10cSrcweir }
358cdf0e10cSrcweir 
removePropertiesChangeListener(const Reference<XPropertiesChangeListener> &)359cdf0e10cSrcweir void SAL_CALL MasterPropertySet::removePropertiesChangeListener( const Reference< XPropertiesChangeListener >& )
360cdf0e10cSrcweir 	throw(RuntimeException)
361cdf0e10cSrcweir {
362cdf0e10cSrcweir 	// todo
363cdf0e10cSrcweir }
364cdf0e10cSrcweir 
firePropertiesChangeEvent(const Sequence<::rtl::OUString> &,const Reference<XPropertiesChangeListener> &)365cdf0e10cSrcweir void SAL_CALL MasterPropertySet::firePropertiesChangeEvent( const Sequence< ::rtl::OUString >&, const Reference< XPropertiesChangeListener >& )
366cdf0e10cSrcweir 	throw(RuntimeException)
367cdf0e10cSrcweir {
368cdf0e10cSrcweir 	// todo
369cdf0e10cSrcweir }
370cdf0e10cSrcweir 
371cdf0e10cSrcweir // XPropertyState
getPropertyState(const::rtl::OUString & PropertyName)372cdf0e10cSrcweir PropertyState SAL_CALL MasterPropertySet::getPropertyState( const ::rtl::OUString& PropertyName )
373cdf0e10cSrcweir 	throw(UnknownPropertyException, RuntimeException)
374cdf0e10cSrcweir {
375cdf0e10cSrcweir 	PropertyDataHash::const_iterator aIter =  mpInfo->maMap.find( PropertyName );
376cdf0e10cSrcweir 	if( aIter == mpInfo->maMap.end())
377cdf0e10cSrcweir 		throw UnknownPropertyException( PropertyName, static_cast< XPropertySet* >( this ) );
378cdf0e10cSrcweir 
379cdf0e10cSrcweir 	PropertyState aState;
380cdf0e10cSrcweir 
381cdf0e10cSrcweir 	if ( (*aIter).second->mnMapId == 0 ) // 0 means it's one of ours !
382cdf0e10cSrcweir 	{
383cdf0e10cSrcweir 		_preGetPropertyState();
384cdf0e10cSrcweir 		_getPropertyState( *((*aIter).second->mpInfo), aState );
385cdf0e10cSrcweir 		_postGetPropertyState();
386cdf0e10cSrcweir 	}
387cdf0e10cSrcweir 	else
388cdf0e10cSrcweir 	{
389cdf0e10cSrcweir 		ChainablePropertySet * pSlave = maSlaveMap [ (*aIter).second->mnMapId ]->mpSlave;
390cdf0e10cSrcweir 
391cdf0e10cSrcweir         // acquire mutex in c-tor and releases it in the d-tor (exception safe!).
392cdf0e10cSrcweir         std::auto_ptr< vos::OGuard > pMutexGuard;
393cdf0e10cSrcweir         if (pSlave->mpMutex)
394cdf0e10cSrcweir             pMutexGuard.reset( new vos::OGuard(pSlave->mpMutex) );
395cdf0e10cSrcweir 
396cdf0e10cSrcweir 		pSlave->_preGetPropertyState();
397cdf0e10cSrcweir 		pSlave->_getPropertyState( *((*aIter).second->mpInfo), aState );
398cdf0e10cSrcweir 		pSlave->_postGetPropertyState();
399cdf0e10cSrcweir 	}
400cdf0e10cSrcweir 
401cdf0e10cSrcweir 	return aState;
402cdf0e10cSrcweir }
403cdf0e10cSrcweir 
getPropertyStates(const Sequence<::rtl::OUString> & rPropertyNames)404cdf0e10cSrcweir Sequence< PropertyState > SAL_CALL MasterPropertySet::getPropertyStates( const Sequence< ::rtl::OUString >& rPropertyNames )
405cdf0e10cSrcweir 	throw(UnknownPropertyException, RuntimeException)
406cdf0e10cSrcweir {
407cdf0e10cSrcweir 	const sal_Int32 nCount = rPropertyNames.getLength();
408cdf0e10cSrcweir 
409cdf0e10cSrcweir 	Sequence< PropertyState > aStates( nCount );
410cdf0e10cSrcweir 	if( nCount )
411cdf0e10cSrcweir 	{
412cdf0e10cSrcweir 		PropertyState * pState = aStates.getArray();
413cdf0e10cSrcweir 		const OUString * pString = rPropertyNames.getConstArray();
414cdf0e10cSrcweir 		PropertyDataHash::const_iterator aEnd = mpInfo->maMap.end(), aIter;
415cdf0e10cSrcweir 		_preGetPropertyState();
416cdf0e10cSrcweir 
417cdf0e10cSrcweir 		for ( sal_Int32 i = 0; i < nCount; ++i, ++pString, ++pState )
418cdf0e10cSrcweir 		{
419cdf0e10cSrcweir 			aIter = mpInfo->maMap.find ( *pString );
420cdf0e10cSrcweir 			if ( aIter == aEnd )
421cdf0e10cSrcweir 				throw UnknownPropertyException( *pString, static_cast< XPropertySet* >( this ) );
422cdf0e10cSrcweir 
423cdf0e10cSrcweir 			if ( (*aIter).second->mnMapId == 0 ) // 0 means it's one of ours !
424cdf0e10cSrcweir 				_getPropertyState( *((*aIter).second->mpInfo), *pState );
425cdf0e10cSrcweir 			else
426cdf0e10cSrcweir 			{
427cdf0e10cSrcweir 				SlaveData * pSlave = maSlaveMap [ (*aIter).second->mnMapId ];
428cdf0e10cSrcweir 				if (!pSlave->IsInit())
429cdf0e10cSrcweir 				{
430cdf0e10cSrcweir 					pSlave->mpSlave->_preGetPropertyState();
431cdf0e10cSrcweir 					pSlave->SetInit ( sal_True );
432cdf0e10cSrcweir 				}
433cdf0e10cSrcweir 				pSlave->mpSlave->_getPropertyState( *((*aIter).second->mpInfo), *pState );
434cdf0e10cSrcweir 			}
435cdf0e10cSrcweir 		}
436cdf0e10cSrcweir 		_postGetPropertyState();
437cdf0e10cSrcweir 		SlaveMap::const_iterator aSlaveIter = maSlaveMap.begin(), aSlaveEnd = maSlaveMap.end();
438cdf0e10cSrcweir 		while (aSlaveIter != aSlaveEnd)
439cdf0e10cSrcweir 		{
440cdf0e10cSrcweir 			if ( (*aSlaveIter).second->IsInit())
441cdf0e10cSrcweir 			{
442cdf0e10cSrcweir 				(*aSlaveIter).second->mpSlave->_postGetPropertyState();
443cdf0e10cSrcweir 				(*aSlaveIter).second->SetInit ( sal_False );
444cdf0e10cSrcweir 			}
445cdf0e10cSrcweir 			++aSlaveIter;
446cdf0e10cSrcweir 		}
447cdf0e10cSrcweir 	}
448cdf0e10cSrcweir 	return aStates;
449cdf0e10cSrcweir }
450cdf0e10cSrcweir 
setPropertyToDefault(const::rtl::OUString & rPropertyName)451cdf0e10cSrcweir void SAL_CALL MasterPropertySet::setPropertyToDefault( const ::rtl::OUString& rPropertyName )
452cdf0e10cSrcweir 	throw(UnknownPropertyException, RuntimeException)
453cdf0e10cSrcweir {
454cdf0e10cSrcweir 	PropertyDataHash::const_iterator aIter = mpInfo->maMap.find ( rPropertyName );
455cdf0e10cSrcweir 
456cdf0e10cSrcweir 	if( aIter == mpInfo->maMap.end())
457cdf0e10cSrcweir 		throw UnknownPropertyException( rPropertyName, static_cast< XPropertySet* >( this ) );
458cdf0e10cSrcweir 	_setPropertyToDefault( *((*aIter).second->mpInfo) );
459cdf0e10cSrcweir }
460cdf0e10cSrcweir 
getPropertyDefault(const::rtl::OUString & rPropertyName)461cdf0e10cSrcweir Any SAL_CALL MasterPropertySet::getPropertyDefault( const ::rtl::OUString& rPropertyName )
462cdf0e10cSrcweir 	throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
463cdf0e10cSrcweir {
464cdf0e10cSrcweir 	PropertyDataHash::const_iterator aIter = mpInfo->maMap.find ( rPropertyName );
465cdf0e10cSrcweir 
466cdf0e10cSrcweir 	if( aIter == mpInfo->maMap.end())
467cdf0e10cSrcweir 		throw UnknownPropertyException( rPropertyName, static_cast< XPropertySet* >( this ) );
468cdf0e10cSrcweir 	return _getPropertyDefault( *((*aIter).second->mpInfo) );
469cdf0e10cSrcweir }
470cdf0e10cSrcweir 
_preGetPropertyState()471cdf0e10cSrcweir void MasterPropertySet::_preGetPropertyState ()
472cdf0e10cSrcweir 	throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException )
473cdf0e10cSrcweir {
474cdf0e10cSrcweir 	OSL_ENSURE( sal_False, "you have to implement this yourself!");
475cdf0e10cSrcweir }
476cdf0e10cSrcweir 
_getPropertyState(const comphelper::PropertyInfo &,PropertyState &)477cdf0e10cSrcweir void MasterPropertySet::_getPropertyState( const comphelper::PropertyInfo&, PropertyState& )
478cdf0e10cSrcweir 	throw(UnknownPropertyException )
479cdf0e10cSrcweir {
480cdf0e10cSrcweir 	OSL_ENSURE( sal_False, "you have to implement this yourself!");
481cdf0e10cSrcweir }
482cdf0e10cSrcweir 
_postGetPropertyState()483cdf0e10cSrcweir void MasterPropertySet::_postGetPropertyState ()
484cdf0e10cSrcweir 	throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException )
485cdf0e10cSrcweir {
486cdf0e10cSrcweir 	OSL_ENSURE( sal_False, "you have to implement this yourself!");
487cdf0e10cSrcweir }
488cdf0e10cSrcweir 
_setPropertyToDefault(const comphelper::PropertyInfo &)489cdf0e10cSrcweir void MasterPropertySet::_setPropertyToDefault( const comphelper::PropertyInfo& )
490cdf0e10cSrcweir 	throw(UnknownPropertyException )
491cdf0e10cSrcweir {
492cdf0e10cSrcweir 	OSL_ENSURE( sal_False, "you have to implement this yourself!");
493cdf0e10cSrcweir }
494cdf0e10cSrcweir 
_getPropertyDefault(const comphelper::PropertyInfo &)495cdf0e10cSrcweir Any MasterPropertySet::_getPropertyDefault( const comphelper::PropertyInfo& )
496cdf0e10cSrcweir 	throw(UnknownPropertyException, WrappedTargetException )
497cdf0e10cSrcweir {
498cdf0e10cSrcweir 	OSL_ENSURE( sal_False, "you have to implement this yourself!");
499cdf0e10cSrcweir 	Any aAny;
500cdf0e10cSrcweir 	return aAny;
501cdf0e10cSrcweir }
502