Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
5 : : * This Source Code Form is subject to the terms of the Mozilla Public
6 : : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
11 : : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : : * contributor license agreements. See the NOTICE file distributed
13 : : * with this work for additional information regarding copyright
14 : : * ownership. The ASF licenses this file to you under the Apache
15 : : * License, Version 2.0 (the "License"); you may not use this file
16 : : * except in compliance with the License. You may obtain a copy of
17 : : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : : */
19 : :
20 : :
21 : : #include "WrappedPropertySet.hxx"
22 : : #include "macros.hxx"
23 : :
24 : : // header for define DELETEZ
25 : : #include <tools/solar.h>
26 : :
27 : : //.............................................................................
28 : : namespace chart
29 : : {
30 : : //.............................................................................
31 : :
32 : : using namespace ::com::sun::star;
33 : : using ::com::sun::star::uno::Reference;
34 : : using ::com::sun::star::uno::Sequence;
35 : : using ::com::sun::star::uno::Any;
36 : : using ::rtl::OUString;
37 : :
38 : 482 : WrappedPropertySet::WrappedPropertySet()
39 : : : MutexContainer()
40 : : , m_xInfo(0)
41 : : , m_pPropertyArrayHelper(0)
42 [ + - ][ + - ]: 482 : , m_pWrappedPropertyMap(0)
43 : : {
44 : 482 : }
45 [ + - ]: 482 : WrappedPropertySet::~WrappedPropertySet()
46 : : {
47 [ + - ]: 482 : clearWrappedPropertySet();
48 [ - + ]: 482 : }
49 : :
50 : 14036 : Reference< beans::XPropertyState > WrappedPropertySet::getInnerPropertyState()
51 : : {
52 [ + - ]: 14036 : return Reference< beans::XPropertyState >( getInnerPropertySet(), uno::UNO_QUERY );
53 : : }
54 : :
55 : 746 : void WrappedPropertySet::clearWrappedPropertySet()
56 : : {
57 [ + - ][ + - ]: 746 : ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );//do not use different mutex than is already used for static property sequence
58 : :
59 : : //delete all wrapped properties
60 [ + + ]: 746 : if(m_pWrappedPropertyMap)
61 : : {
62 [ + - + - ]: 20098 : for( tWrappedPropertyMap::iterator aIt = m_pWrappedPropertyMap->begin()
[ + + ]
63 : 10049 : ; aIt!= m_pWrappedPropertyMap->end(); ++aIt )
64 : : {
65 [ + - ]: 9749 : const WrappedProperty* pWrappedProperty = (*aIt).second;
66 [ + - ][ + - ]: 9749 : DELETEZ(pWrappedProperty);
67 : : }
68 : : }
69 : :
70 [ + + ][ + - ]: 746 : DELETEZ(m_pPropertyArrayHelper);
71 [ + + ]: 746 : DELETEZ(m_pWrappedPropertyMap);
72 : :
73 [ + - ][ + - ]: 746 : m_xInfo = NULL;
74 : 746 : }
75 : :
76 : : //XPropertySet
77 : 10341 : Reference< beans::XPropertySetInfo > SAL_CALL WrappedPropertySet::getPropertySetInfo( )
78 : : throw (uno::RuntimeException)
79 : : {
80 : 10341 : Reference< beans::XPropertySetInfo > xInfo = m_xInfo;
81 [ + + ]: 10341 : if( !xInfo.is() )
82 : : {
83 [ + - ][ + - ]: 281 : ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );//do not use different mutex than is already used for static property sequence
84 [ + - ]: 281 : xInfo = m_xInfo;
85 [ + - ]: 281 : if( !xInfo.is() )
86 : : {
87 [ + - ][ + - ]: 281 : xInfo = ::cppu::OPropertySetHelper::createPropertySetInfo( getInfoHelper() );
[ + - ]
88 : : OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
89 [ + - ]: 281 : m_xInfo = xInfo;
90 [ + - ]: 281 : }
91 : : }
92 : : else
93 : : {
94 : : OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
95 : : }
96 : 10341 : return m_xInfo;
97 : : }
98 : :
99 : 2752 : void SAL_CALL WrappedPropertySet::setPropertyValue( const OUString& rPropertyName, const Any& rValue )
100 : : throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
101 : : {
102 : : try
103 : : {
104 [ + - ][ + - ]: 2752 : sal_Int32 nHandle = getInfoHelper().getHandleByName( rPropertyName );
105 [ + - ]: 2752 : const WrappedProperty* pWrappedProperty = getWrappedProperty( nHandle );
106 [ + - ]: 2752 : Reference< beans::XPropertySet > xInnerPropertySet( this->getInnerPropertySet() );
107 [ + + ]: 2752 : if( pWrappedProperty )
108 [ + - ]: 1498 : pWrappedProperty->setPropertyValue( rValue, xInnerPropertySet );
109 [ + - ]: 1254 : else if( xInnerPropertySet.is() )
110 [ + - ][ + - ]: 1254 : xInnerPropertySet->setPropertyValue( rPropertyName, rValue );
111 : : else
112 : : {
113 : : #if OSL_DEBUG_LEVEL > 1
114 : : OSL_FAIL("found no inner property set to map to");
115 : : #endif
116 : 2752 : }
117 : : }
118 : 0 : catch( const beans::UnknownPropertyException& )
119 : : {
120 : 0 : throw;
121 : : }
122 : 0 : catch( const beans::PropertyVetoException& )
123 : : {
124 : 0 : throw;
125 : : }
126 : 0 : catch( const lang::IllegalArgumentException& )
127 : : {
128 : 0 : throw;
129 : : }
130 : 0 : catch( const lang::WrappedTargetException& )
131 : : {
132 : 0 : throw;
133 : : }
134 : 0 : catch( const uno::RuntimeException& )
135 : : {
136 : 0 : throw;
137 : : }
138 [ # # # # : 0 : catch( const uno::Exception& ex )
# # # ]
139 : : {
140 : : OSL_FAIL("invalid exception caught in WrappedPropertySet::setPropertyValue");
141 [ # # ]: 0 : lang::WrappedTargetException aWrappedException;
142 [ # # ]: 0 : aWrappedException.TargetException = uno::makeAny( ex );
143 [ # # ]: 0 : throw aWrappedException;
144 : : }
145 : 2752 : }
146 : 17067 : Any SAL_CALL WrappedPropertySet::getPropertyValue( const OUString& rPropertyName )
147 : : throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
148 : : {
149 : 17067 : Any aRet;
150 : :
151 : : try
152 : : {
153 [ + - ][ + - ]: 17067 : sal_Int32 nHandle = getInfoHelper().getHandleByName( rPropertyName );
154 [ + - ]: 17067 : const WrappedProperty* pWrappedProperty = getWrappedProperty( nHandle );
155 [ + - ]: 17067 : Reference< beans::XPropertySet > xInnerPropertySet( this->getInnerPropertySet() );
156 [ + + ]: 17067 : if( pWrappedProperty )
157 [ + - ]: 15277 : aRet = pWrappedProperty->getPropertyValue( xInnerPropertySet );
158 [ + - ]: 1790 : else if( xInnerPropertySet.is() )
159 [ + - ][ + + ]: 1790 : aRet = xInnerPropertySet->getPropertyValue( rPropertyName );
160 : : else
161 : : {
162 : : #if OSL_DEBUG_LEVEL > 1
163 : : OSL_FAIL("found no inner property set to map to");
164 : : #endif
165 : 17067 : }
166 : : }
167 : 20 : catch( const beans::UnknownPropertyException& )
168 : : {
169 : 10 : throw;
170 : : }
171 : 0 : catch( const lang::WrappedTargetException& )
172 : : {
173 : 0 : throw;
174 : : }
175 : 0 : catch( const uno::RuntimeException& )
176 : : {
177 : 0 : throw;
178 : : }
179 [ - + - - : 10 : catch( const uno::Exception& ex )
- ]
180 : : {
181 : : OSL_FAIL("invalid exception caught in WrappedPropertySet::setPropertyValue");
182 [ # # ]: 0 : lang::WrappedTargetException aWrappedException;
183 [ # # ]: 0 : aWrappedException.TargetException = uno::makeAny( ex );
184 [ # # ]: 0 : throw aWrappedException;
185 : : }
186 : :
187 : 17067 : return aRet;
188 : : }
189 : :
190 : 340 : void SAL_CALL WrappedPropertySet::addPropertyChangeListener( const OUString& rPropertyName, const Reference< beans::XPropertyChangeListener >& xListener )
191 : : throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
192 : : {
193 [ + - ]: 340 : Reference< beans::XPropertySet > xInnerPropertySet( this->getInnerPropertySet() );
194 [ + - ]: 340 : if( xInnerPropertySet.is() )
195 : : {
196 [ + - ]: 340 : const WrappedProperty* pWrappedProperty = getWrappedProperty( rPropertyName );
197 [ + + ]: 340 : if( pWrappedProperty )
198 [ + - ][ + - ]: 96 : xInnerPropertySet->addPropertyChangeListener( pWrappedProperty->getInnerName(), xListener );
[ + - ]
199 : : else
200 [ + - ][ + - ]: 244 : xInnerPropertySet->addPropertyChangeListener( rPropertyName, xListener );
201 : 340 : }
202 : 340 : }
203 : 340 : void SAL_CALL WrappedPropertySet::removePropertyChangeListener( const OUString& rPropertyName, const Reference< beans::XPropertyChangeListener >& aListener )
204 : : throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
205 : : {
206 [ + - ]: 340 : Reference< beans::XPropertySet > xInnerPropertySet( this->getInnerPropertySet() );
207 [ + - ]: 340 : if( xInnerPropertySet.is() )
208 : : {
209 [ + - ]: 340 : const WrappedProperty* pWrappedProperty = getWrappedProperty( rPropertyName );
210 [ + + ]: 340 : if( pWrappedProperty )
211 [ + - ][ + - ]: 96 : xInnerPropertySet->removePropertyChangeListener( pWrappedProperty->getInnerName(), aListener );
[ + - ]
212 : : else
213 [ + - ][ + - ]: 244 : xInnerPropertySet->removePropertyChangeListener( rPropertyName, aListener );
214 : 340 : }
215 : 340 : }
216 : 0 : void SAL_CALL WrappedPropertySet::addVetoableChangeListener( const OUString& rPropertyName, const Reference< beans::XVetoableChangeListener >& aListener )
217 : : throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
218 : : {
219 [ # # ]: 0 : Reference< beans::XPropertySet > xInnerPropertySet( this->getInnerPropertySet() );
220 [ # # ]: 0 : if( xInnerPropertySet.is() )
221 : : {
222 [ # # ]: 0 : const WrappedProperty* pWrappedProperty = getWrappedProperty( rPropertyName );
223 [ # # ]: 0 : if( pWrappedProperty )
224 [ # # ][ # # ]: 0 : xInnerPropertySet->addVetoableChangeListener( pWrappedProperty->getInnerName(), aListener );
[ # # ]
225 : : else
226 [ # # ][ # # ]: 0 : xInnerPropertySet->addVetoableChangeListener( rPropertyName, aListener );
227 : 0 : }
228 : 0 : }
229 : 0 : void SAL_CALL WrappedPropertySet::removeVetoableChangeListener( const OUString& rPropertyName, const Reference< beans::XVetoableChangeListener >& aListener )
230 : : throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
231 : : {
232 [ # # ]: 0 : Reference< beans::XPropertySet > xInnerPropertySet( this->getInnerPropertySet() );
233 [ # # ]: 0 : if( xInnerPropertySet.is() )
234 : : {
235 [ # # ]: 0 : const WrappedProperty* pWrappedProperty = getWrappedProperty( rPropertyName );
236 [ # # ]: 0 : if( pWrappedProperty )
237 [ # # ][ # # ]: 0 : xInnerPropertySet->removeVetoableChangeListener( pWrappedProperty->getInnerName(), aListener );
[ # # ]
238 : : else
239 [ # # ][ # # ]: 0 : xInnerPropertySet->removeVetoableChangeListener( rPropertyName, aListener );
240 : 0 : }
241 : 0 : }
242 : :
243 : : //XMultiPropertySet
244 : 84 : void SAL_CALL WrappedPropertySet::setPropertyValues( const Sequence< OUString >& rNameSeq, const Sequence< Any >& rValueSeq )
245 : : throw (beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
246 : : {
247 : 84 : bool bUnknownProperty = false;
248 [ + - # # ]: 84 : sal_Int32 nMinCount = std::min( rValueSeq.getLength(), rNameSeq.getLength() );
249 [ + + ]: 1398 : for(sal_Int32 nN=0; nN<nMinCount; nN++)
250 : : {
251 : 1314 : ::rtl::OUString aPropertyName( rNameSeq[nN] );
252 : : try
253 : : {
254 [ + - ]: 1314 : this->setPropertyValue( aPropertyName, rValueSeq[nN] );
255 : : }
256 [ # # ]: 0 : catch( const beans::UnknownPropertyException& ex )
257 : : {
258 : : ASSERT_EXCEPTION( ex );
259 : 0 : bUnknownProperty = true;
260 : : }
261 : 1314 : }
262 : : //todo: store unknown properties elsewhere
263 : : OSL_ENSURE(!bUnknownProperty,"unknown property");
264 : : (void)bUnknownProperty;
265 : : // if( bUnknownProperty )
266 : : // throw beans::UnknownPropertyException();
267 : 84 : }
268 : 236 : Sequence< Any > SAL_CALL WrappedPropertySet::getPropertyValues( const Sequence< OUString >& rNameSeq )
269 : : throw (uno::RuntimeException)
270 : : {
271 : 236 : Sequence< Any > aRetSeq;
272 [ + - ]: 236 : if( rNameSeq.getLength() )
273 : : {
274 [ + - ]: 236 : aRetSeq.realloc( rNameSeq.getLength() );
275 [ + + ]: 1976 : for(sal_Int32 nN=0; nN<rNameSeq.getLength(); nN++)
276 : : {
277 : : try
278 : : {
279 : 1740 : ::rtl::OUString aPropertyName( rNameSeq[nN] );
280 [ + - ]: 1740 : aRetSeq[nN] = this->getPropertyValue( aPropertyName );
[ # # # ]
[ + - ]
281 : : }
282 [ # # ]: 0 : catch( const beans::UnknownPropertyException& ex )
283 : : {
284 : : ASSERT_EXCEPTION( ex );
285 : : }
286 [ # # ]: 0 : catch( const lang::WrappedTargetException& ex )
287 : : {
288 : : ASSERT_EXCEPTION( ex );
289 : : }
290 : : }
291 : : }
292 : 236 : return aRetSeq;
293 : : }
294 : 0 : void SAL_CALL WrappedPropertySet::addPropertiesChangeListener( const Sequence< OUString >& /* rNameSeq */, const Reference< beans::XPropertiesChangeListener >& /* xListener */ )
295 : : throw (uno::RuntimeException)
296 : : {
297 : : OSL_FAIL("not implemented yet");
298 : : //todo
299 : 0 : }
300 : 0 : void SAL_CALL WrappedPropertySet::removePropertiesChangeListener( const Reference< beans::XPropertiesChangeListener >& /* xListener */ )
301 : : throw (uno::RuntimeException)
302 : : {
303 : : OSL_FAIL("not implemented yet");
304 : : //todo
305 : 0 : }
306 : 0 : void SAL_CALL WrappedPropertySet::firePropertiesChangeEvent( const Sequence< OUString >& /* rNameSeq */, const Reference< beans::XPropertiesChangeListener >& /* xListener */ )
307 : : throw (uno::RuntimeException)
308 : : {
309 : : OSL_FAIL("not implemented yet");
310 : : //todo
311 : 0 : }
312 : :
313 : : //XPropertyState
314 : 14036 : beans::PropertyState SAL_CALL WrappedPropertySet::getPropertyState( const OUString& rPropertyName )
315 : : throw (beans::UnknownPropertyException, uno::RuntimeException)
316 : : {
317 : 14036 : beans::PropertyState aState( beans::PropertyState_DIRECT_VALUE );
318 : :
319 [ + - ]: 14036 : Reference< beans::XPropertyState > xInnerPropertyState( this->getInnerPropertyState() );
320 [ + - ]: 14036 : if( xInnerPropertyState.is() )
321 : : {
322 [ + - ]: 14036 : const WrappedProperty* pWrappedProperty = getWrappedProperty( rPropertyName );
323 [ + + ]: 14036 : if( pWrappedProperty )
324 [ + - ]: 5714 : aState = pWrappedProperty->getPropertyState( xInnerPropertyState );
325 : : else
326 [ + - ][ + - ]: 8322 : aState = xInnerPropertyState->getPropertyState( rPropertyName );
327 : : }
328 : 14036 : return aState;
329 : : }
330 : :
331 : 14716 : const WrappedProperty* WrappedPropertySet::getWrappedProperty( const ::rtl::OUString& rOuterName )
332 : : {
333 : 14716 : sal_Int32 nHandle = getInfoHelper().getHandleByName( rOuterName );
334 : 14716 : return getWrappedProperty( nHandle );
335 : : }
336 : :
337 : 35559 : const WrappedProperty* WrappedPropertySet::getWrappedProperty( sal_Int32 nHandle )
338 : : {
339 [ + - ][ + - ]: 35559 : tWrappedPropertyMap::const_iterator aFound( getWrappedPropertyMap().find( nHandle ) );
[ + - ]
340 [ + - ][ + - ]: 35559 : if( aFound != getWrappedPropertyMap().end() )
[ + - ][ + + ]
341 [ + - ]: 22789 : return (*aFound).second;
342 : 35559 : return 0;
343 : : }
344 : :
345 : 218 : Sequence< beans::PropertyState > SAL_CALL WrappedPropertySet::getPropertyStates( const Sequence< OUString >& rNameSeq )
346 : : throw (beans::UnknownPropertyException, uno::RuntimeException)
347 : : {
348 : 218 : Sequence< beans::PropertyState > aRetSeq;
349 [ + - ]: 218 : if( rNameSeq.getLength() )
350 : : {
351 [ + - ]: 218 : aRetSeq.realloc( rNameSeq.getLength() );
352 [ + + ]: 14254 : for(sal_Int32 nN=0; nN<rNameSeq.getLength(); nN++)
353 : : {
354 : 14036 : ::rtl::OUString aPropertyName( rNameSeq[nN] );
355 [ + - ][ + - ]: 14036 : aRetSeq[nN] = this->getPropertyState( aPropertyName );
356 : 14036 : }
357 : : }
358 : 218 : return aRetSeq;
359 : : }
360 : :
361 : 0 : void SAL_CALL WrappedPropertySet::setPropertyToDefault( const OUString& rPropertyName )
362 : : throw (beans::UnknownPropertyException, uno::RuntimeException)
363 : : {
364 [ # # ]: 0 : Reference< beans::XPropertyState > xInnerPropertyState( this->getInnerPropertyState() );
365 [ # # ]: 0 : if( xInnerPropertyState.is() )
366 : : {
367 [ # # ]: 0 : const WrappedProperty* pWrappedProperty = getWrappedProperty( rPropertyName );
368 [ # # ]: 0 : if( pWrappedProperty )
369 [ # # ]: 0 : pWrappedProperty->setPropertyToDefault( xInnerPropertyState );
370 : : else
371 [ # # ][ # # ]: 0 : xInnerPropertyState->setPropertyToDefault( rPropertyName );
372 : 0 : }
373 : 0 : }
374 : 0 : Any SAL_CALL WrappedPropertySet::getPropertyDefault( const OUString& rPropertyName )
375 : : throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
376 : : {
377 : 0 : Any aRet;
378 [ # # ]: 0 : Reference< beans::XPropertyState > xInnerPropertyState( this->getInnerPropertyState() );
379 [ # # ]: 0 : if( xInnerPropertyState.is() )
380 : : {
381 [ # # ]: 0 : const WrappedProperty* pWrappedProperty = getWrappedProperty( rPropertyName );
382 [ # # ]: 0 : if( pWrappedProperty )
383 [ # # ]: 0 : aRet = pWrappedProperty->getPropertyDefault(xInnerPropertyState);
384 : : else
385 [ # # ][ # # ]: 0 : aRet = xInnerPropertyState->getPropertyDefault( rPropertyName );
386 : : }
387 : 0 : return aRet;
388 : : }
389 : :
390 : : //XMultiPropertyStates
391 : 0 : void SAL_CALL WrappedPropertySet::setAllPropertiesToDefault( )
392 : : throw (uno::RuntimeException)
393 : : {
394 : 0 : const Sequence< beans::Property >& rPropSeq = getPropertySequence();
395 [ # # ]: 0 : for(sal_Int32 nN=0; nN<rPropSeq.getLength(); nN++)
396 : : {
397 : 0 : ::rtl::OUString aPropertyName( rPropSeq[nN].Name );
398 [ # # ]: 0 : this->setPropertyToDefault( aPropertyName );
399 : 0 : }
400 : 0 : }
401 : 0 : void SAL_CALL WrappedPropertySet::setPropertiesToDefault( const Sequence< OUString >& rNameSeq )
402 : : throw (beans::UnknownPropertyException, uno::RuntimeException)
403 : : {
404 [ # # ]: 0 : for(sal_Int32 nN=0; nN<rNameSeq.getLength(); nN++)
405 : : {
406 : 0 : ::rtl::OUString aPropertyName( rNameSeq[nN] );
407 [ # # ]: 0 : this->setPropertyToDefault( aPropertyName );
408 : 0 : }
409 : 0 : }
410 : 0 : Sequence< Any > SAL_CALL WrappedPropertySet::getPropertyDefaults( const Sequence< OUString >& rNameSeq )
411 : : throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
412 : : {
413 : 0 : Sequence< Any > aRetSeq;
414 [ # # ]: 0 : if( rNameSeq.getLength() )
415 : : {
416 [ # # ]: 0 : aRetSeq.realloc( rNameSeq.getLength() );
417 [ # # ]: 0 : for(sal_Int32 nN=0; nN<rNameSeq.getLength(); nN++)
418 : : {
419 : 0 : ::rtl::OUString aPropertyName( rNameSeq[nN] );
420 [ # # ][ # # ]: 0 : aRetSeq[nN] = this->getPropertyDefault( aPropertyName );
421 : 0 : }
422 : : }
423 : 0 : return aRetSeq;
424 : : }
425 : :
426 : : //-----------------------------------------------------------------------------
427 : : //-----------------------------------------------------------------------------
428 : :
429 : 47029 : ::cppu::IPropertyArrayHelper& WrappedPropertySet::getInfoHelper()
430 : : {
431 : 47029 : ::cppu::OPropertyArrayHelper* p = m_pPropertyArrayHelper;
432 [ + + ]: 47029 : if(!p)
433 : : {
434 [ + - ][ + - ]: 300 : ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );//do not use different mutex than is already used for static property sequence
435 : 300 : p = m_pPropertyArrayHelper;
436 [ + - ]: 300 : if(!p)
437 : : {
438 [ + - ][ + - ]: 300 : p = new ::cppu::OPropertyArrayHelper( getPropertySequence(), sal_True );
439 : : OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
440 : 300 : m_pPropertyArrayHelper = p;
441 [ + - ]: 300 : }
442 : : }
443 : : else
444 : : {
445 : : OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
446 : : }
447 : 47029 : return *m_pPropertyArrayHelper;
448 : : }
449 : :
450 : : //-----------------------------------------------------------------------------
451 : :
452 : 71118 : tWrappedPropertyMap& WrappedPropertySet::getWrappedPropertyMap()
453 : : {
454 : 71118 : tWrappedPropertyMap* p = m_pWrappedPropertyMap;
455 [ + + ]: 71118 : if(!p)
456 : : {
457 [ + - ][ + - ]: 300 : ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );//do not use different mutex than is already used for static property sequence
458 : 300 : p = m_pWrappedPropertyMap;
459 [ + - ]: 300 : if(!p)
460 : : {
461 [ + - ]: 300 : std::vector< WrappedProperty* > aPropList( createWrappedProperties() );
462 [ + - ][ + - ]: 300 : p = new tWrappedPropertyMap();
463 : :
464 [ + - ][ + - ]: 10049 : for( std::vector< WrappedProperty* >::const_iterator aIt = aPropList.begin(); aIt!=aPropList.end(); ++aIt )
[ + - ][ + + ]
465 : : {
466 [ + - ]: 9749 : WrappedProperty* pProperty = *aIt;
467 [ + - ]: 9749 : if(pProperty)
468 : : {
469 [ + - ][ + - ]: 9749 : sal_Int32 nHandle = getInfoHelper().getHandleByName( pProperty->getOuterName() );
[ + - ]
470 : :
471 [ - + ]: 9749 : if( nHandle == -1 )
472 : : {
473 : : OSL_FAIL( "missing property in property list" );
474 [ # # ][ # # ]: 0 : delete pProperty;//we are owner or the created WrappedProperties
475 : : }
476 [ + - ][ + - ]: 9749 : else if( p->find( nHandle ) != p->end() )
[ - + ]
477 : : {
478 : : //duplicate Wrapped property
479 : : OSL_FAIL( "duplicate Wrapped property" );
480 [ # # ][ # # ]: 0 : delete pProperty;//we are owner or the created WrappedProperties
481 : : }
482 : : else
483 [ + - ]: 9749 : (*p)[ nHandle ] = pProperty;
484 : : }
485 : : }
486 : :
487 : : OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
488 : 300 : m_pWrappedPropertyMap = p;
489 [ + - ]: 300 : }
490 : : }
491 : : else
492 : : {
493 : : OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
494 : : }
495 : 71118 : return *m_pWrappedPropertyMap;
496 : : }
497 : :
498 : : //.............................................................................
499 : : } //namespace chart
500 : : //.............................................................................
501 : :
502 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|