ChainablePropertySet.cxx (dde7d3fa) ChainablePropertySet.cxx (d75c37ae)
1/**************************************************************
1/**************************************************************
2 *
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
19 *
20 *************************************************************/
21
22
23
24// MARKER(update_precomp.py): autogen include statement, do not remove
25#include "precompiled_comphelper.hxx"
26#include <comphelper/ChainablePropertySet.hxx>
27#include <comphelper/ChainablePropertySetInfo.hxx>
28#include <vos/mutex.hxx>
29
20 *************************************************************/
21
22
23
24// MARKER(update_precomp.py): autogen include statement, do not remove
25#include "precompiled_comphelper.hxx"
26#include <comphelper/ChainablePropertySet.hxx>
27#include <comphelper/ChainablePropertySetInfo.hxx>
28#include <vos/mutex.hxx>
29
30#include <memory> // STL auto_ptr
30#include <memory> // STL auto_ptr
31
32
33using namespace ::rtl;
34using namespace ::comphelper;
35using namespace ::com::sun::star;
36using namespace ::com::sun::star::uno;
37using namespace ::com::sun::star::lang;
38using namespace ::com::sun::star::beans;
39using ::vos::IMutex;
40
31
32
33using namespace ::rtl;
34using namespace ::comphelper;
35using namespace ::com::sun::star;
36using namespace ::com::sun::star::uno;
37using namespace ::com::sun::star::lang;
38using namespace ::com::sun::star::beans;
39using ::vos::IMutex;
40
41ChainablePropertySet::ChainablePropertySet( comphelper::ChainablePropertySetInfo* pInfo, vos::IMutex *pMutex )
41ChainablePropertySet::ChainablePropertySet( comphelper::ChainablePropertySetInfo* pInfo, vos::IMutex *pMutex )
42 throw()
43: mpInfo ( pInfo )
44, mpMutex ( pMutex )
45, mxInfo ( pInfo )
46{
47}
48
42 throw()
43: mpInfo ( pInfo )
44, mpMutex ( pMutex )
45, mxInfo ( pInfo )
46{
47}
48
49ChainablePropertySet::~ChainablePropertySet()
49ChainablePropertySet::~ChainablePropertySet()
50 throw()
51{
52}
53
54// XPropertySet
50 throw()
51{
52}
53
54// XPropertySet
55Reference< XPropertySetInfo > SAL_CALL ChainablePropertySet::getPropertySetInfo( )
55Reference< XPropertySetInfo > SAL_CALL ChainablePropertySet::getPropertySetInfo( )
56 throw(RuntimeException)
57{
58 return mxInfo;
59}
60
61void ChainablePropertySet::lockMutex()
62{
63 if (mpMutex)
64 mpMutex->acquire();
65}
66
67void ChainablePropertySet::unlockMutex()
68{
69 if (mpMutex)
70 mpMutex->release();
71}
72
56 throw(RuntimeException)
57{
58 return mxInfo;
59}
60
61void ChainablePropertySet::lockMutex()
62{
63 if (mpMutex)
64 mpMutex->acquire();
65}
66
67void ChainablePropertySet::unlockMutex()
68{
69 if (mpMutex)
70 mpMutex->release();
71}
72
73void SAL_CALL ChainablePropertySet::setPropertyValue( const ::rtl::OUString& rPropertyName, const Any& rValue )
73void SAL_CALL ChainablePropertySet::setPropertyValue( const ::rtl::OUString& rPropertyName, const Any& rValue )
74 throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException)
75{
74 throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException)
75{
76 // acquire mutex in c-tor and releases it in the d-tor (exception safe!).
77 std::auto_ptr< vos::OGuard > pMutexGuard;
78 if (mpMutex)
79 pMutexGuard.reset( new vos::OGuard(mpMutex) );
76 // acquire mutex in c-tor and releases it in the d-tor (exception safe!).
77 std::auto_ptr< vos::OGuard > pMutexGuard;
78 if (mpMutex)
79 pMutexGuard.reset( new vos::OGuard(mpMutex) );
80
81 PropertyInfoHash::const_iterator aIter = mpInfo->maMap.find ( rPropertyName );
82
83 if( aIter == mpInfo->maMap.end())
84 throw UnknownPropertyException( rPropertyName, static_cast< XPropertySet* >( this ) );
85
86 _preSetValues();
87 _setSingleValue( *((*aIter).second), rValue );
88 _postSetValues();
89}
90
80
81 PropertyInfoHash::const_iterator aIter = mpInfo->maMap.find ( rPropertyName );
82
83 if( aIter == mpInfo->maMap.end())
84 throw UnknownPropertyException( rPropertyName, static_cast< XPropertySet* >( this ) );
85
86 _preSetValues();
87 _setSingleValue( *((*aIter).second), rValue );
88 _postSetValues();
89}
90
91Any SAL_CALL ChainablePropertySet::getPropertyValue( const ::rtl::OUString& rPropertyName )
91Any SAL_CALL ChainablePropertySet::getPropertyValue( const ::rtl::OUString& rPropertyName )
92 throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
93{
92 throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
93{
94 // acquire mutex in c-tor and releases it in the d-tor (exception safe!).
95 std::auto_ptr< vos::OGuard > pMutexGuard;
96 if (mpMutex)
97 pMutexGuard.reset( new vos::OGuard(mpMutex) );
94 // acquire mutex in c-tor and releases it in the d-tor (exception safe!).
95 std::auto_ptr< vos::OGuard > pMutexGuard;
96 if (mpMutex)
97 pMutexGuard.reset( new vos::OGuard(mpMutex) );
98
99 PropertyInfoHash::const_iterator aIter = mpInfo->maMap.find ( rPropertyName );
100
101 if( aIter == mpInfo->maMap.end())
102 throw UnknownPropertyException( rPropertyName, static_cast< XPropertySet* >( this ) );
103
104 Any aAny;
105 _preGetValues ();
106 _getSingleValue( *((*aIter).second), aAny );
107 _postGetValues ();
108
109 return aAny;
110}
111
98
99 PropertyInfoHash::const_iterator aIter = mpInfo->maMap.find ( rPropertyName );
100
101 if( aIter == mpInfo->maMap.end())
102 throw UnknownPropertyException( rPropertyName, static_cast< XPropertySet* >( this ) );
103
104 Any aAny;
105 _preGetValues ();
106 _getSingleValue( *((*aIter).second), aAny );
107 _postGetValues ();
108
109 return aAny;
110}
111
112void SAL_CALL ChainablePropertySet::addPropertyChangeListener( const ::rtl::OUString&, const Reference< XPropertyChangeListener >& )
112void SAL_CALL ChainablePropertySet::addPropertyChangeListener( const ::rtl::OUString&, const Reference< XPropertyChangeListener >& )
113 throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
114{
115 // todo
116}
117
113 throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
114{
115 // todo
116}
117
118void SAL_CALL ChainablePropertySet::removePropertyChangeListener( const ::rtl::OUString&, const Reference< XPropertyChangeListener >& )
118void SAL_CALL ChainablePropertySet::removePropertyChangeListener( const ::rtl::OUString&, const Reference< XPropertyChangeListener >& )
119 throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
120{
121 // todo
122}
123
119 throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
120{
121 // todo
122}
123
124void SAL_CALL ChainablePropertySet::addVetoableChangeListener( const ::rtl::OUString&, const Reference< XVetoableChangeListener >& )
124void SAL_CALL ChainablePropertySet::addVetoableChangeListener( const ::rtl::OUString&, const Reference< XVetoableChangeListener >& )
125 throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
126{
127 // todo
128}
129
125 throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
126{
127 // todo
128}
129
130void SAL_CALL ChainablePropertySet::removeVetoableChangeListener( const ::rtl::OUString&, const Reference< XVetoableChangeListener >& )
130void SAL_CALL ChainablePropertySet::removeVetoableChangeListener( const ::rtl::OUString&, const Reference< XVetoableChangeListener >& )
131 throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
132{
133 // todo
134}
135
136// XMultiPropertySet
131 throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
132{
133 // todo
134}
135
136// XMultiPropertySet
137void SAL_CALL ChainablePropertySet::setPropertyValues( const Sequence< ::rtl::OUString >& aPropertyNames, const Sequence< Any >& aValues )
137void SAL_CALL ChainablePropertySet::setPropertyValues( const Sequence< ::rtl::OUString >& aPropertyNames, const Sequence< Any >& aValues )
138 throw(PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException)
139{
138 throw(PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException)
139{
140 // acquire mutex in c-tor and releases it in the d-tor (exception safe!).
141 std::auto_ptr< vos::OGuard > pMutexGuard;
142 if (mpMutex)
143 pMutexGuard.reset( new vos::OGuard(mpMutex) );
140 // acquire mutex in c-tor and releases it in the d-tor (exception safe!).
141 std::auto_ptr< vos::OGuard > pMutexGuard;
142 if (mpMutex)
143 pMutexGuard.reset( new vos::OGuard(mpMutex) );
144
144
145 const sal_Int32 nCount = aPropertyNames.getLength();
145 const sal_Int32 nCount = aPropertyNames.getLength();
146
147 if( nCount != aValues.getLength() )
148 throw IllegalArgumentException();
149
150 if( nCount )
151 {
152 _preSetValues();
153

--- 9 unchanged lines hidden (view full) ---

163
164 _setSingleValue ( *((*aIter).second), *pAny );
165 }
166
167 _postSetValues();
168 }
169}
170
146
147 if( nCount != aValues.getLength() )
148 throw IllegalArgumentException();
149
150 if( nCount )
151 {
152 _preSetValues();
153

--- 9 unchanged lines hidden (view full) ---

163
164 _setSingleValue ( *((*aIter).second), *pAny );
165 }
166
167 _postSetValues();
168 }
169}
170
171Sequence< Any > SAL_CALL ChainablePropertySet::getPropertyValues( const Sequence< ::rtl::OUString >& aPropertyNames )
171Sequence< Any > SAL_CALL ChainablePropertySet::getPropertyValues( const Sequence< ::rtl::OUString >& aPropertyNames )
172 throw(RuntimeException)
173{
172 throw(RuntimeException)
173{
174 // acquire mutex in c-tor and releases it in the d-tor (exception safe!).
175 std::auto_ptr< vos::OGuard > pMutexGuard;
176 if (mpMutex)
177 pMutexGuard.reset( new vos::OGuard(mpMutex) );
174 // acquire mutex in c-tor and releases it in the d-tor (exception safe!).
175 std::auto_ptr< vos::OGuard > pMutexGuard;
176 if (mpMutex)
177 pMutexGuard.reset( new vos::OGuard(mpMutex) );
178
179 const sal_Int32 nCount = aPropertyNames.getLength();
180
181 Sequence < Any > aValues ( nCount );
182
183 if( nCount )
184 {
185 _preGetValues();

--- 11 unchanged lines hidden (view full) ---

197 _getSingleValue ( *((*aIter).second), *pAny );
198 }
199
200 _postGetValues();
201 }
202 return aValues;
203}
204
178
179 const sal_Int32 nCount = aPropertyNames.getLength();
180
181 Sequence < Any > aValues ( nCount );
182
183 if( nCount )
184 {
185 _preGetValues();

--- 11 unchanged lines hidden (view full) ---

197 _getSingleValue ( *((*aIter).second), *pAny );
198 }
199
200 _postGetValues();
201 }
202 return aValues;
203}
204
205void SAL_CALL ChainablePropertySet::addPropertiesChangeListener( const Sequence< ::rtl::OUString >&, const Reference< XPropertiesChangeListener >& )
205void SAL_CALL ChainablePropertySet::addPropertiesChangeListener( const Sequence< ::rtl::OUString >&, const Reference< XPropertiesChangeListener >& )
206 throw(RuntimeException)
207{
208 // todo
209}
210
206 throw(RuntimeException)
207{
208 // todo
209}
210
211void SAL_CALL ChainablePropertySet::removePropertiesChangeListener( const Reference< XPropertiesChangeListener >& )
211void SAL_CALL ChainablePropertySet::removePropertiesChangeListener( const Reference< XPropertiesChangeListener >& )
212 throw(RuntimeException)
213{
214 // todo
215}
216
212 throw(RuntimeException)
213{
214 // todo
215}
216
217void SAL_CALL ChainablePropertySet::firePropertiesChangeEvent( const Sequence< ::rtl::OUString >&, const Reference< XPropertiesChangeListener >& )
217void SAL_CALL ChainablePropertySet::firePropertiesChangeEvent( const Sequence< ::rtl::OUString >&, const Reference< XPropertiesChangeListener >& )
218 throw(RuntimeException)
219{
220 // todo
221}
222
223// XPropertyState
218 throw(RuntimeException)
219{
220 // todo
221}
222
223// XPropertyState
224PropertyState SAL_CALL ChainablePropertySet::getPropertyState( const ::rtl::OUString& PropertyName )
224PropertyState SAL_CALL ChainablePropertySet::getPropertyState( const ::rtl::OUString& PropertyName )
225 throw(UnknownPropertyException, RuntimeException)
226{
225 throw(UnknownPropertyException, RuntimeException)
226{
227 PropertyInfoHash::const_iterator aIter = mpInfo->maMap.find( PropertyName );
227 PropertyInfoHash::const_iterator aIter = mpInfo->maMap.find( PropertyName );
228 if( aIter == mpInfo->maMap.end())
229 throw UnknownPropertyException( PropertyName, static_cast< XPropertySet* >( this ) );
230
231 PropertyState aState;
232
233 _preGetPropertyState();
234 _getPropertyState( *((*aIter).second), aState );
235 _postGetPropertyState();
236
237 return aState;
238}
239
228 if( aIter == mpInfo->maMap.end())
229 throw UnknownPropertyException( PropertyName, static_cast< XPropertySet* >( this ) );
230
231 PropertyState aState;
232
233 _preGetPropertyState();
234 _getPropertyState( *((*aIter).second), aState );
235 _postGetPropertyState();
236
237 return aState;
238}
239
240Sequence< PropertyState > SAL_CALL ChainablePropertySet::getPropertyStates( const Sequence< ::rtl::OUString >& rPropertyNames )
240Sequence< PropertyState > SAL_CALL ChainablePropertySet::getPropertyStates( const Sequence< ::rtl::OUString >& rPropertyNames )
241 throw(UnknownPropertyException, RuntimeException)
242{
243 const sal_Int32 nCount = rPropertyNames.getLength();
244
245 Sequence< PropertyState > aStates( nCount );
246 if( nCount )
247 {
248 PropertyState * pState = aStates.getArray();

--- 9 unchanged lines hidden (view full) ---

258
259 _getPropertyState ( *((*aIter).second), *pState );
260 }
261 _postGetPropertyState();
262 }
263 return aStates;
264}
265
241 throw(UnknownPropertyException, RuntimeException)
242{
243 const sal_Int32 nCount = rPropertyNames.getLength();
244
245 Sequence< PropertyState > aStates( nCount );
246 if( nCount )
247 {
248 PropertyState * pState = aStates.getArray();

--- 9 unchanged lines hidden (view full) ---

258
259 _getPropertyState ( *((*aIter).second), *pState );
260 }
261 _postGetPropertyState();
262 }
263 return aStates;
264}
265
266void SAL_CALL ChainablePropertySet::setPropertyToDefault( const ::rtl::OUString& rPropertyName )
266void SAL_CALL ChainablePropertySet::setPropertyToDefault( const ::rtl::OUString& rPropertyName )
267 throw(UnknownPropertyException, RuntimeException)
268{
269 PropertyInfoHash::const_iterator aIter = mpInfo->maMap.find ( rPropertyName );
270
271 if( aIter == mpInfo->maMap.end())
272 throw UnknownPropertyException( rPropertyName, static_cast< XPropertySet* >( this ) );
273 _setPropertyToDefault( *((*aIter).second) );
274}
275
267 throw(UnknownPropertyException, RuntimeException)
268{
269 PropertyInfoHash::const_iterator aIter = mpInfo->maMap.find ( rPropertyName );
270
271 if( aIter == mpInfo->maMap.end())
272 throw UnknownPropertyException( rPropertyName, static_cast< XPropertySet* >( this ) );
273 _setPropertyToDefault( *((*aIter).second) );
274}
275
276Any SAL_CALL ChainablePropertySet::getPropertyDefault( const ::rtl::OUString& rPropertyName )
276Any SAL_CALL ChainablePropertySet::getPropertyDefault( const ::rtl::OUString& rPropertyName )
277 throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
278{
279 PropertyInfoHash::const_iterator aIter = mpInfo->maMap.find ( rPropertyName );
280
281 if( aIter == mpInfo->maMap.end())
282 throw UnknownPropertyException( rPropertyName, static_cast< XPropertySet* >( this ) );
283 return _getPropertyDefault( *((*aIter).second) );
284}
285
286void ChainablePropertySet::_preGetPropertyState ()
287 throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException )
288{
289 OSL_ENSURE( sal_False, "you have to implement this yourself!");
290}
291
277 throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
278{
279 PropertyInfoHash::const_iterator aIter = mpInfo->maMap.find ( rPropertyName );
280
281 if( aIter == mpInfo->maMap.end())
282 throw UnknownPropertyException( rPropertyName, static_cast< XPropertySet* >( this ) );
283 return _getPropertyDefault( *((*aIter).second) );
284}
285
286void ChainablePropertySet::_preGetPropertyState ()
287 throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException )
288{
289 OSL_ENSURE( sal_False, "you have to implement this yourself!");
290}
291
292void ChainablePropertySet::_getPropertyState( const comphelper::PropertyInfo&, PropertyState& )
292void ChainablePropertySet::_getPropertyState( const comphelper::PropertyInfo&, PropertyState& )
293 throw(UnknownPropertyException )
294{
295 OSL_ENSURE( sal_False, "you have to implement this yourself!");
296}
297
298void ChainablePropertySet::_postGetPropertyState ()
299 throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException )
300{
301 OSL_ENSURE( sal_False, "you have to implement this yourself!");
302}
303
293 throw(UnknownPropertyException )
294{
295 OSL_ENSURE( sal_False, "you have to implement this yourself!");
296}
297
298void ChainablePropertySet::_postGetPropertyState ()
299 throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException )
300{
301 OSL_ENSURE( sal_False, "you have to implement this yourself!");
302}
303
304void ChainablePropertySet::_setPropertyToDefault( const comphelper::PropertyInfo& )
304void ChainablePropertySet::_setPropertyToDefault( const comphelper::PropertyInfo& )
305 throw(UnknownPropertyException )
306{
307 OSL_ENSURE( sal_False, "you have to implement this yourself!");
308}
309
305 throw(UnknownPropertyException )
306{
307 OSL_ENSURE( sal_False, "you have to implement this yourself!");
308}
309
310Any ChainablePropertySet::_getPropertyDefault( const comphelper::PropertyInfo& )
310Any ChainablePropertySet::_getPropertyDefault( const comphelper::PropertyInfo& )
311 throw(UnknownPropertyException, WrappedTargetException )
312{
313 OSL_ENSURE( sal_False, "you have to implement this yourself!");
314
315 Any aAny;
316 return aAny;
317}
311 throw(UnknownPropertyException, WrappedTargetException )
312{
313 OSL_ENSURE( sal_False, "you have to implement this yourself!");
314
315 Any aAny;
316 return aAny;
317}