merge the formfield patch from ooo-build
[ooovba.git] / cppuhelper / test / testpropshlp.cxx
blob88669d1430470e1de5f091af50893a44518b8e71
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: testpropshlp.cxx,v $
10 * $Revision: 1.9 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #if !defined(OSL_DEBUG_LEVEL) || OSL_DEBUG_LEVEL == 0
32 # undef OSL_DEBUG_LEVEL
33 # define OSL_DEBUG_LEVEL 2
34 #endif
37 // MARKER(update_precomp.py): autogen include statement, do not remove
38 #include "precompiled_cppuhelper.hxx"
39 #include <osl/mutex.hxx>
40 #include <osl/diagnose.h>
42 #include <cppuhelper/propshlp.hxx>
43 #include <cppuhelper/weak.hxx>
45 #include <cppuhelper/proptypehlp.hxx>
47 #include <com/sun/star/uno/Any.hxx>
48 #include <com/sun/star/beans/PropertyAttribute.hpp>
50 #include <cppuhelper/implbase3.hxx>
52 using namespace ::cppu;
53 using namespace ::rtl;
54 using namespace ::osl;
55 using namespace ::com::sun::star::uno;
56 using namespace ::com::sun::star::beans;
57 using namespace ::com::sun::star::lang;
61 /**********************
63 **********************/
64 static Property * getPropertyTable1()
66 static Property *pTable = 0;
68 if( ! pTable ) {
69 MutexGuard guard( Mutex::getGlobalMutex() );
70 if( ! pTable ) {
71 static Property aTable[] =
73 Property( OUString( RTL_CONSTASCII_USTRINGPARAM("a") ), 0, getCppuType( (OUString *)0) ,
74 PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), //OUString
75 Property( OUString( RTL_CONSTASCII_USTRINGPARAM("b") ), 1, getCppuCharType( ) ,
76 PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), //Char
77 Property( OUString( RTL_CONSTASCII_USTRINGPARAM("c") ), 2, getCppuType( (sal_Int32*)0) ,
78 PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), //sal_Int32
79 Property( OUString( RTL_CONSTASCII_USTRINGPARAM("d") ), 5, getCppuType( (double*)0) ,
80 PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), //double
81 Property( OUString( RTL_CONSTASCII_USTRINGPARAM("e") ), 7, getCppuBooleanType() ,
82 PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), //BOOL
83 Property( OUString( RTL_CONSTASCII_USTRINGPARAM("f") ), 8, getCppuType( (Any*)0) ,
84 PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ) //Any
86 pTable = aTable;
89 return pTable;
93 static Property * getPropertyTable2()
95 static Property *pTable = 0;
97 if( ! pTable ) {
98 MutexGuard guard( ::osl::Mutex::getGlobalMutex() );
99 if( ! pTable ) {
100 static Property aTable[] =
102 Property( OUString( RTL_CONSTASCII_USTRINGPARAM("f") ), 8, getCppuType( (Any *)0) ,
103 PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), // Any
104 Property( OUString( RTL_CONSTASCII_USTRINGPARAM("b") ), 1, getCppuCharType( ),
105 PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), // Char
106 Property( OUString( RTL_CONSTASCII_USTRINGPARAM("a") ), 0, getCppuType( (OUString*)0),
107 PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), // OUString
108 Property( OUString( RTL_CONSTASCII_USTRINGPARAM("d") ), 5, getCppuType( (double*)0) ,
109 PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), // Double
110 Property( OUString( RTL_CONSTASCII_USTRINGPARAM("c") ), 2, getCppuType( (sal_Int32*)0),
111 PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), // sal_Int32
112 Property( OUString( RTL_CONSTASCII_USTRINGPARAM("e") ), 7, getCppuBooleanType() ,
113 PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ) // Bool
115 pTable = aTable;
118 return pTable;
121 static Property * getPropertyTable3()
123 static Property *pTable = 0;
125 if( ! pTable ) {
126 MutexGuard guard( ::osl::Mutex::getGlobalMutex() );
127 if( ! pTable ) {
128 static Property aTable[] =
130 Property( OUString( RTL_CONSTASCII_USTRINGPARAM("b") ), 1, getCppuCharType( ),
131 PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), // Char
132 Property( OUString( RTL_CONSTASCII_USTRINGPARAM("f") ), 8, getCppuType( (Any *)0) ,
133 PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), // any
134 Property( OUString( RTL_CONSTASCII_USTRINGPARAM("a") ), 0, getCppuType( (OUString*)0),
135 PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ) // OUString
137 pTable = aTable;
140 return pTable;
144 static Property * getPropertyTable4()
146 static Property *pTable = 0;
148 if( ! pTable ) {
149 MutexGuard guard( ::osl::Mutex::getGlobalMutex() );
150 if( ! pTable ) {
151 static Property aTable[] =
153 Property( OUString( RTL_CONSTASCII_USTRINGPARAM("a") ), 0, getCppuType( (OUString*)0),
154 PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), // OUString
155 Property( OUString( RTL_CONSTASCII_USTRINGPARAM("b") ), 1, getCppuCharType( ),
156 PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), // Char
157 Property( OUString( RTL_CONSTASCII_USTRINGPARAM("f") ), 2, getCppuType( (Any *)0) ,
158 PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ) // Any
160 pTable = aTable;
163 return pTable;
168 /**********************
170 * Note : all Property names must be in the 127 ASCII subset !
172 **********************/
175 void test_PropertyArrayHelper()
177 // Test getProperties() and getCount()
179 OPropertyArrayHelper a1( getPropertyTable1(), 6 );
180 OSL_ENSURE( 6 == a1.getCount(), "not all properties inserted" );
181 Sequence< Property > aProps = a1.getProperties();
182 Property * pP = aProps.getArray();
183 OSL_ENSURE( 6 == aProps.getLength(), "getProperties() gives not all properties" );
184 for( int i = 0; i < 6; i++ )
186 OSL_ENSURE( pP[i].Name == getPropertyTable1()[i].Name , "Name not correct" );
187 OSL_ENSURE( pP[i].Handle == getPropertyTable1()[i].Handle, "Handle not correct" );
188 OSL_ENSURE( pP[i].Attributes == getPropertyTable1()[i].Attributes, "Attributes not correct" );
189 OSL_ENSURE( pP[i].Type == getPropertyTable1()[i].Type, "Type not correct" );
193 // Test sorting
195 OPropertyArrayHelper a1( getPropertyTable2(), 6, sal_False );
196 Sequence< Property > aProps = a1.getProperties();
197 Property * pP = aProps.getArray();
198 OSL_ENSURE( 6 == aProps.getLength(), "getProperties() gives not all properties" );
200 // table to switch to sorted
201 int a[] = { 2 , 1 , 4, 3, 5, 0 };
202 for( int i = 0; i < 6; i++ )
204 OSL_ENSURE( pP[i].Name == getPropertyTable2()[a[i]].Name , "Name not correct" );
205 OSL_ENSURE( pP[i].Handle == getPropertyTable2()[a[i]].Handle, "Handle not correct" );
206 OSL_ENSURE( pP[i].Attributes == getPropertyTable2()[a[i]].Attributes, "Attributes not correct" );
207 OSL_ENSURE( pP[i].Type == getPropertyTable2()[a[i]].Type, "Type not correct" );
211 // Test sorting
213 OPropertyArrayHelper a1( getPropertyTable3(), 3, sal_False );
214 Sequence< Property > aProps = a1.getProperties();
215 Property * pP = aProps.getArray();
216 OSL_ENSURE( 3 == aProps.getLength(), "getProperties() gives not all properties" );
217 // table to switch to sorted
218 int a[] = { 2 , 0 , 1 };
219 for( int i = 0; i < 3; i++ )
221 OSL_ENSURE( pP[i].Name == getPropertyTable3()[a[i]].Name , "Name not correct" );
222 OSL_ENSURE( pP[i].Handle == getPropertyTable3()[a[i]].Handle, "Handle not correct" );
223 OSL_ENSURE( pP[i].Attributes == getPropertyTable3()[a[i]].Attributes, "Attributes not correct" );
224 OSL_ENSURE( pP[i].Type == getPropertyTable3()[a[i]].Type, "Type not correct" );
228 // Test getPropertyByName and hasPropertyByName
230 OPropertyArrayHelper a1( getPropertyTable1(), 6 );
231 for( int i = 0; i < 6; i++ )
233 OSL_ENSURE( a1.hasPropertyByName( getPropertyTable1()[i].Name ), "hasPropertyByName not correct" );
234 Property aP = a1.getPropertyByName( getPropertyTable1()[i].Name );
235 OSL_ENSURE( aP.Name == getPropertyTable1()[i].Name , "Name not correct" );
236 OSL_ENSURE( aP.Handle == getPropertyTable1()[i].Handle, "Handle not correct" );
237 OSL_ENSURE( aP.Attributes == getPropertyTable1()[i].Attributes, "Attributes not correct" );
238 OSL_ENSURE( aP.Type == getPropertyTable1()[i].Type, "Type not correct" );
241 OSL_ENSURE( !a1.hasPropertyByName( OUString( RTL_CONSTASCII_USTRINGPARAM("never exist") ) ), "hasPropertyByName not correct" );
244 a1.getPropertyByName( OUString( RTL_CONSTASCII_USTRINGPARAM("never exist") ) );
245 OSL_ENSURE( sal_False, "exeption not thrown" );
247 catch( UnknownPropertyException & )
252 // Test getHandleByName
254 OPropertyArrayHelper a1( getPropertyTable1(), 6 );
255 for( int i = 0; i < 6; i++ )
257 sal_Int32 Handle = a1.getHandleByName( getPropertyTable1()[i].Name );
258 OSL_ENSURE( Handle == getPropertyTable1()[i].Handle, "Handle not correct" );
260 sal_Int32 Handle = a1.getHandleByName( OUString( RTL_CONSTASCII_USTRINGPARAM("asdaf") ) );
261 OSL_ENSURE( Handle == -1, "Handle not correct" );
264 // Test fillPropertyMembersByHandle
266 OPropertyArrayHelper a1( getPropertyTable1(), 6 );
267 int i;
268 for( i = 0; i < 6; i++ )
270 sal_Int16 nAttributes;
271 OUString aPropName;
272 sal_Bool b = a1.fillPropertyMembersByHandle( &aPropName, &nAttributes, getPropertyTable1()[i].Handle );
273 OSL_ENSURE( b, "fillPropertyMembersByHandle: handle not found" );
274 OSL_ENSURE( nAttributes == getPropertyTable1()[i].Attributes, "fillPropertyMembersByHandle: Attributes not correct" );
275 OSL_ENSURE( aPropName == getPropertyTable1()[i].Name , "fillPropertyMembersByHandle: Name not correct" );
277 OSL_ENSURE( !a1.fillPropertyMembersByHandle( NULL, NULL, 66666 ), "fillPropertyMembersByHandle: handle found" );
278 // optimized table
279 OPropertyArrayHelper a4( getPropertyTable4(), 3 );
280 for( i = 0; i < 3; i++ )
282 sal_Int16 nAttributes;
283 OUString aPropName;
284 sal_Bool b = a1.fillPropertyMembersByHandle( &aPropName, &nAttributes, getPropertyTable4()[i].Handle );
285 OSL_ENSURE( b, "fillPropertyMembersByHandle: handle not found" );
286 OSL_ENSURE( nAttributes == getPropertyTable1()[i].Attributes, "fillPropertyMembersByHandle: Attributes not correct" );
287 OSL_ENSURE( aPropName == getPropertyTable1()[i].Name , "fillPropertyMembersByHandle: Name not correct" );
289 OSL_ENSURE( !a4.fillPropertyMembersByHandle( NULL, NULL, 66666 ), "fillPropertyMembersByHandle: handle found" );
292 // Test fillHandles
294 OPropertyArrayHelper a1( getPropertyTable1(), 6 );
295 Sequence< OUString > aS( 4 );
296 sal_Int32 Handles[4];
297 // muss sortiert sein
298 aS.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM("a") );
299 aS.getArray()[1] = OUString( RTL_CONSTASCII_USTRINGPARAM("d") );
300 aS.getArray()[2] = OUString( RTL_CONSTASCII_USTRINGPARAM("f") );
301 aS.getArray()[3] = OUString( RTL_CONSTASCII_USTRINGPARAM("t") );
302 sal_Int32 nHitCount = a1.fillHandles( Handles, aS );
303 OSL_ENSURE( nHitCount == 3, "wrong number of hits " );
304 OSL_ENSURE( Handles[0] == getPropertyTable1()[0].Handle, "Handle not correct" );
305 OSL_ENSURE( Handles[1] == getPropertyTable1()[3].Handle, "Handle not correct" );
306 OSL_ENSURE( Handles[2] == getPropertyTable1()[5].Handle, "Handle not correct" );
307 OSL_ENSURE( Handles[3] == -1, "Handle not correct" );
314 //----------------------------------------------------
315 // test_OPropertySetHelper
316 //----------------------------------------------------
317 struct MutexContainer
319 Mutex aMutex;
321 class test_OPropertySetHelper :
322 public MutexContainer,
323 public OBroadcastHelper ,
324 public OPropertySetHelper,
325 public OWeakObject
327 public:
329 test_OPropertySetHelper( Property * p, sal_Int32 n )
330 : MutexContainer()
331 , OBroadcastHelper( ((MutexContainer *)this)->aMutex )
332 // , OPropertySetHelper( *SAL_STATIC_CAST(OBroadcastHelper *,this))
333 // MSCI 4 bug ! :
334 // OBroadcastHelper == OBroadcastHelperVar<OMultiTypeInterfaceContainerHelper>
335 , OPropertySetHelper(
336 *SAL_STATIC_CAST(OBroadcastHelper *,this))
337 , bBOOL( sal_False )
338 , nINT16( 0 )
339 , nINT32( 0 )
340 , pBasicProps( p )
341 , nPropCount( n )
346 ~test_OPropertySetHelper()
350 void dispose()
352 // see comphlp.cxx
353 sal_Bool bDoDispose = sal_False;
355 MutexGuard aGuard( rBHelper.rMutex );
356 if( !rBHelper.bDisposed && !rBHelper.bInDispose )
358 rBHelper.bInDispose = sal_True;
359 bDoDispose = sal_True;
362 if( bDoDispose )
364 disposing();
365 EventObject aEvt;
366 aEvt.Source = Reference < XInterface > ( SAL_STATIC_CAST( OWeakObject * ,this) );
368 rBHelper.aLC.disposeAndClear( aEvt );
369 rBHelper.bDisposed = sal_True;
370 rBHelper.bInDispose = sal_False;
374 // XInterface
375 Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(RuntimeException)
377 Any aRet( OPropertySetHelper::queryInterface( rType ) );
378 return (aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType ));
380 void SAL_CALL acquire() throw()
381 { OWeakObject::acquire(); }
382 void SAL_CALL release() throw()
383 { OWeakObject::release(); }
385 // XPropertySet
386 Reference < XPropertySetInfo > SAL_CALL getPropertySetInfo()throw(RuntimeException);
388 using OPropertySetHelper::getFastPropertyValue;
390 sal_Bool bBOOL;
391 sal_Int16 nINT16;
392 sal_Int32 nINT32;
393 Property * pBasicProps;
394 sal_Int32 nPropCount;
395 protected:
396 IPropertyArrayHelper & SAL_CALL getInfoHelper() throw(RuntimeException);
397 sal_Bool SAL_CALL convertFastPropertyValue(
398 Any & rConvertedValue, Any & rOldValue,
399 sal_Int32 nHandle, const Any& rValue )
400 throw(IllegalArgumentException);
401 void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const Any& rValue ) throw(RuntimeException);
402 void SAL_CALL getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const throw(RuntimeException);
405 //----------------------------------------------------------------------
406 //------ The Properties of this implementation -------------------------
407 //----------------------------------------------------------------------
408 // Id must be the index into the array
409 #define PROPERTY_BOOL 0
410 #define PROPERTY_INT16 1
411 #define PROPERTY_INT32 2
413 // Max number of properties
414 #define PROPERTY_COUNT 4
415 // Names of Properties
417 * All Properties of this implementation. Must be sorted by name.
419 Property * getBasicProps()
421 static Property *pTable = 0;
423 if( ! pTable ) {
424 MutexGuard guard( ::osl::Mutex::getGlobalMutex() );
425 if( ! pTable ) {
427 static Property aBasicProps[PROPERTY_COUNT] =
429 Property( OUString( RTL_CONSTASCII_USTRINGPARAM("BOOL") ) , PROPERTY_BOOL , getCppuBooleanType(), PropertyAttribute::READONLY ),
430 Property( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ) , PROPERTY_INT16,
431 getCppuType( (sal_Int16*)0 ), PropertyAttribute::BOUND | PropertyAttribute::CONSTRAINED ),
432 Property( OUString( RTL_CONSTASCII_USTRINGPARAM("INT32") ) , PROPERTY_INT32, getCppuType( (sal_Int32*)0 ), PropertyAttribute::BOUND ),
433 Property( OUString( RTL_CONSTASCII_USTRINGPARAM("TEST") ) , 55 , getCppuType( (sal_Int32*)0), PropertyAttribute::BOUND )
435 pTable = aBasicProps;
438 return pTable;
442 //----------------------------------------------------
443 // test_OPropertySetHelper_Listener
444 //----------------------------------------------------
445 class test_OPropertySetHelper_Listener
446 : public WeakImplHelper3< XPropertyChangeListener, XPropertiesChangeListener, XVetoableChangeListener >
448 public:
449 sal_Int32 nDisposing;
450 Mutex aMutex;
451 Any * pExceptedListenerValues;
452 sal_Int32 nCount;
453 sal_Int32 nCurrent;
455 test_OPropertySetHelper_Listener( Any * p = 0, sal_Int32 n = 0 )
456 : nDisposing( 0 )
457 , pExceptedListenerValues( p )
458 , nCount( n )
459 , nCurrent( 0 )
462 ~test_OPropertySetHelper_Listener()
466 sal_Int32 getRefCount()
467 { return m_refCount; }
469 // XEventListener
470 void SAL_CALL disposing(const EventObject& /*evt*/) throw ( RuntimeException)
472 MutexGuard aGuard( aMutex );
473 nDisposing++;
476 // XPropertyChangeListener
477 void SAL_CALL propertyChange(const PropertyChangeEvent& evt) throw (RuntimeException)
479 if( !pExceptedListenerValues )
480 return;
481 MutexGuard aGuard( aMutex );
482 OSL_ENSURE( nCurrent +1 < nCount, "PropertySetHelper: too many listener calls" );
484 switch( evt.PropertyHandle )
486 case PROPERTY_BOOL:
488 OSL_ENSURE( sal_False , "PropertySetHelper: BOOL cannot change" );
489 OSL_ENSURE( evt.PropertyName == OUString( RTL_CONSTASCII_USTRINGPARAM("BOOL") ), "PropertySetHelper: wrong name" );
491 break;
493 case PROPERTY_INT16:
495 OSL_ENSURE( evt.PropertyName == OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), "PropertySetHelper: wrong name" );
497 OSL_ENSURE( pExceptedListenerValues[nCurrent].getValueType().getTypeClass() == TypeClass_SHORT ,
498 "PropertySetHelper: wrong data type" );
500 sal_Int16 nInt16, nOldInt16;
501 pExceptedListenerValues[nCurrent] >>= nInt16;
502 evt.OldValue >>= nOldInt16;
503 OSL_ENSURE( nInt16 == nOldInt16, "PropertySetHelper: wrong old value" );
506 pExceptedListenerValues[nCurrent+1] >>= nInt16;
507 evt.NewValue >>= nOldInt16;
508 OSL_ENSURE( nInt16 == nOldInt16 , "PropertySetHelper: wrong new value" );
510 break;
512 case PROPERTY_INT32:
514 OSL_ENSURE( evt.PropertyName == OUString( RTL_CONSTASCII_USTRINGPARAM("INT32") ), "PropertySetHelper: wrong name" );
516 sal_Int32 nInt32,nOldInt32;
518 pExceptedListenerValues[nCurrent] >>= nInt32;
519 evt.OldValue >>= nOldInt32;
520 OSL_ENSURE( nInt32 == nOldInt32 , "PropertySetHelper: wrong old value" );
522 pExceptedListenerValues[nCurrent+1] >>= nInt32;
523 evt.NewValue >>= nOldInt32;
524 OSL_ENSURE( nInt32 == nOldInt32 , "PropertySetHelper: wrong new value" );
526 break;
528 default:
529 OSL_ENSURE( sal_False, "XPropeSetHelper: invalid property handle" );
531 nCurrent += 2;
534 // XVetoableChangeListener
535 void SAL_CALL vetoableChange(const PropertyChangeEvent& evt) throw (PropertyVetoException, RuntimeException)
537 if( !pExceptedListenerValues )
538 return;
539 MutexGuard aGuard( aMutex );
540 OSL_ENSURE( nCurrent +1 < nCount, "PropertySetHelper: too many listener calls" );
542 switch( evt.PropertyHandle )
544 case PROPERTY_BOOL:
546 OSL_ENSURE( sal_False , "PropertySetHelper: BOOL cannot change" );
547 OSL_ENSURE( evt.PropertyName == OUString( RTL_CONSTASCII_USTRINGPARAM("BOOL") ), "PropertySetHelper: wrong name" );
549 break;
551 case PROPERTY_INT16:
553 OSL_ENSURE( evt.PropertyName == OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), "PropertySetHelper: wrong name" );
555 sal_Int16 nInt16, nOldInt16;
556 pExceptedListenerValues[nCurrent] >>= nInt16;
557 evt.OldValue >>= nOldInt16;
559 OSL_ENSURE( nInt16 == nOldInt16,"PropertySetHelper: wrong old value" );
561 pExceptedListenerValues[nCurrent+1] >>= nInt16;
562 evt.NewValue >>= nOldInt16;
563 OSL_ENSURE( nInt16 == nOldInt16 , "PropertySetHelper: wrong new value" );
565 if( nOldInt16 == 100 )
567 nCurrent += 2;
568 throw PropertyVetoException();
571 break;
573 case PROPERTY_INT32:
575 OSL_ENSURE( evt.PropertyName == OUString( RTL_CONSTASCII_USTRINGPARAM("INT32") ), "PropertySetHelper: wrong name" );
577 sal_Int32 nInt32,nOldInt32;
578 pExceptedListenerValues[nCurrent] >>= nInt32;
579 evt.OldValue >>= nOldInt32;
580 OSL_ENSURE( nInt32 == nOldInt32 , "PropertySetHelper: wrong old value" );
582 pExceptedListenerValues[nCurrent+1] >>= nInt32;
583 evt.NewValue >>= nOldInt32;
584 OSL_ENSURE( nInt32 == nOldInt32 , "PropertySetHelper: wrong new value" );
586 break;
588 default:
589 OSL_ENSURE( sal_False, "XPropeSetHelper: invalid property handle" );
591 nCurrent += 2;
594 // XPropertiesChangeListener
595 void SAL_CALL propertiesChange(const Sequence< PropertyChangeEvent >& evtSeq) throw (RuntimeException)
597 if( !pExceptedListenerValues )
598 return;
599 MutexGuard aGuard( aMutex );
600 for( sal_Int32 i = 0; i < evtSeq.getLength(); i++ )
602 const PropertyChangeEvent & evt = evtSeq.getConstArray()[i];
603 OSL_ENSURE( nCurrent +1 < nCount, "PropertySetHelper: too many listener calls" );
605 switch( evt.PropertyHandle )
607 case PROPERTY_BOOL:
609 OSL_ENSURE( sal_False, "PropertySetHelper: BOOL cannot change" );
610 OSL_ENSURE( evt.PropertyName == OUString( RTL_CONSTASCII_USTRINGPARAM("BOOL") ), "PropertySetHelper: wrong name" );
612 break;
614 case PROPERTY_INT16:
616 OSL_ENSURE( evt.PropertyName == OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), "PropertySetHelper: wrong name" );
618 sal_Int16 nInt16, nOldInt16;
619 pExceptedListenerValues[nCurrent] >>= nInt16;
620 evt.OldValue >>= nOldInt16;
621 OSL_ENSURE( nInt16 == nOldInt16 , "PropertySetHelper: wrong old value" );
624 pExceptedListenerValues[nCurrent+1] >>= nInt16;
625 evt.NewValue >>= nOldInt16;
626 OSL_ENSURE( nInt16 == nOldInt16 , "PropertySetHelper: wrong new value" );
628 break;
630 case PROPERTY_INT32:
632 OSL_ENSURE( evt.PropertyName == OUString( RTL_CONSTASCII_USTRINGPARAM("INT32") ), "PropertySetHelper: wrong name" );
635 sal_Int32 nInt32,nOldInt32;
636 pExceptedListenerValues[nCurrent] >>= nInt32;
637 evt.OldValue >>= nOldInt32;
638 OSL_ENSURE( nInt32 == nOldInt32 , "PropertySetHelper: wrong old value" );
640 pExceptedListenerValues[nCurrent+1] >>= nInt32;
641 evt.NewValue >>= nOldInt32;
642 OSL_ENSURE( nInt32 == nOldInt32 , "PropertySetHelper: wrong new value" );
644 break;
646 default:
647 OSL_ENSURE( sal_False, "XPropeSetHelper: invalid property handle" );
649 nCurrent += 2;
655 * Create a table that map names to index values.
657 IPropertyArrayHelper & test_OPropertySetHelper::getInfoHelper() throw(RuntimeException)
659 // no multi thread protection
660 static OPropertyArrayHelper aInfo( pBasicProps, nPropCount );
661 return aInfo;
664 // XPropertySet
665 Reference < XPropertySetInfo > test_OPropertySetHelper::getPropertySetInfo()
666 throw(RuntimeException)
668 // no multi thread protection
669 static Reference < XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
670 return xInfo;
673 // Return sal_True, value changed
674 sal_Bool test_OPropertySetHelper::convertFastPropertyValue
676 Any & rConvertedValue,
677 Any & rOldValue,
678 sal_Int32 nHandle,
679 const Any& rValue
680 )throw(IllegalArgumentException)
682 switch( nHandle )
684 case PROPERTY_BOOL:
686 sal_Bool b;
687 convertPropertyValue( b , rValue );
688 if( b != bBOOL )
691 rConvertedValue.setValue( &b , ::getCppuBooleanType() );
692 rOldValue.setValue( & bBOOL , ::getCppuBooleanType() );
693 return sal_True;
695 else
696 return sal_False;
699 case PROPERTY_INT16:
701 sal_Int16 n16;
702 convertPropertyValue( n16 , rValue );
704 if( n16 != nINT16 )
706 rConvertedValue <<= n16;
707 rOldValue <<= nINT16;
708 return sal_True;
710 else
711 return sal_False;
714 case PROPERTY_INT32:
716 sal_Int32 n32;
717 convertPropertyValue( n32 , rValue );
718 if( n32 != nINT32 )
720 rConvertedValue <<= n32;
721 rOldValue <<= nINT32;
722 return sal_True;
724 else
725 return sal_False;
728 default:
729 OSL_ENSURE( nHandle == -1, "invalid property handle" );
730 return sal_False;
734 /**
735 * only set the value.
737 void test_OPropertySetHelper::setFastPropertyValue_NoBroadcast
739 sal_Int32 nHandle,
740 const Any& rValue
741 )throw(RuntimeException)
743 switch( nHandle )
745 case PROPERTY_BOOL:
746 OSL_ENSURE( rValue.getValueType().getTypeClass() == TypeClass_BOOLEAN, "invalid type" );
747 bBOOL = *((sal_Bool*)rValue.getValue());
748 break;
750 case PROPERTY_INT16:
751 OSL_ENSURE( rValue.getValueType().getTypeClass() == TypeClass_SHORT, "invalid type" );
752 rValue >>= nINT16;
753 break;
755 case PROPERTY_INT32:
756 OSL_ENSURE( rValue.getValueType().getTypeClass() == TypeClass_LONG, "invalid type" );
757 rValue >>= nINT32;
758 break;
760 default:
761 OSL_ENSURE( nHandle == -1, "invalid property handle" );
765 //--------------------------
766 void test_OPropertySetHelper::getFastPropertyValue( Any & rRet, sal_Int32 nHandle ) const
767 throw(RuntimeException)
769 switch( nHandle )
771 case PROPERTY_BOOL:
772 rRet.setValue( &bBOOL , getCppuBooleanType() );
773 break;
775 case PROPERTY_INT16:
776 rRet <<= nINT16;
777 break;
779 case PROPERTY_INT32:
780 rRet <<= nINT32;
781 break;
783 default:
784 OSL_ENSURE( nHandle == -1, "invalid property handle" );
789 void test_PropertySetHelper()
791 test_PropertyArrayHelper();
793 test_OPropertySetHelper * pPS;
795 Reference < XPropertySet > xPS;
796 Reference < XPropertyChangeListener > xPS_L;
797 test_OPropertySetHelper_Listener * pPS_L;
799 Reference < XInterface > x;
801 for( int z = 0; z < 2; z++ )
803 // first test aBasicProps Handles are { 0, 1, 2, 55 }
804 // first test getBasicProps() Handles are { 0, 1, 2 }
805 xPS = pPS = new test_OPropertySetHelper( getBasicProps(), PROPERTY_COUNT - z );
806 xPS_L = static_cast< XPropertyChangeListener * >( pPS_L = new test_OPropertySetHelper_Listener() );
808 // Test queryInterface
809 Reference < XPropertySet > rProp( xPS , UNO_QUERY );
810 OSL_ENSURE( rProp.is() , "PropertySetHelper: XPropertySet nor supported" );
812 Reference < XMultiPropertySet > rMulti( xPS , UNO_QUERY );
813 OSL_ENSURE( rMulti.is() , "PropertySetHelper: XMultiPropertySet nor supported" );
815 Reference < XFastPropertySet > rFast( xPS , UNO_QUERY );
816 OSL_ENSURE( rFast.is() , "PropertySetHelper: XFastPropertySet nor supported" );
818 x = Reference < XInterface > ();
820 // Test add-remove listener
822 Reference < XPropertiesChangeListener > x1( xPS_L, UNO_QUERY );
823 Reference < XVetoableChangeListener > x2( xPS_L, UNO_QUERY );
825 xPS->addPropertyChangeListener( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), xPS_L );
826 Sequence<OUString> szPN( 3 );
827 szPN.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM("BOOL") );
828 szPN.getArray()[1] = OUString( RTL_CONSTASCII_USTRINGPARAM("INT32") );
829 szPN.getArray()[2] = OUString( RTL_CONSTASCII_USTRINGPARAM("Does not exist") ); // must ne ignored by the addPropertiesChangeListener method
830 pPS->addPropertiesChangeListener( szPN, x1 );
832 szPN = Sequence<OUString>();
833 pPS->addPropertiesChangeListener( szPN, x1 );
834 pPS->addVetoableChangeListener( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), x2 );
836 xPS->removePropertyChangeListener( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), xPS_L );
837 pPS->removePropertiesChangeListener( x1 );
838 pPS->removePropertiesChangeListener( x1 );
839 pPS->removeVetoableChangeListener( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), x2 );
841 // this exception must thrown
844 xPS->addPropertyChangeListener( OUString( RTL_CONSTASCII_USTRINGPARAM("Does not exist") ), xPS_L );
845 OSL_ENSURE( sal_False, "PropertySetHelper: exeption not thrown" );
847 catch( UnknownPropertyException & /*e*/ )
854 xPS->addVetoableChangeListener( OUString( RTL_CONSTASCII_USTRINGPARAM("Does not exist") ), x2 );
855 OSL_ENSURE( sal_False, "PropertySetHelper: exeption not thrown" );
857 catch( UnknownPropertyException & /*e*/ )
863 OSL_ENSURE( pPS_L->getRefCount() == 1, "PropertySetHelper: wrong reference count" );
865 // Test disposing
867 Reference < XPropertiesChangeListener > x1( xPS_L, UNO_QUERY );
868 Reference < XVetoableChangeListener > x2( xPS_L, UNO_QUERY );
870 xPS->addPropertyChangeListener( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), xPS_L );
871 Sequence<OUString> szPN( 2 );
872 szPN.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM("BOOL") );
873 szPN.getArray()[1] = OUString( RTL_CONSTASCII_USTRINGPARAM("INT32") );
874 pPS->addPropertiesChangeListener( szPN, x1 );
875 szPN = Sequence<OUString>();
876 pPS->addPropertiesChangeListener( szPN, x1 );
877 pPS->addVetoableChangeListener( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), x2 );
878 pPS->dispose();
880 OSL_ENSURE( pPS_L->nDisposing == 4 , "PropertySetHelper: wrong disposing count" );
881 OSL_ENSURE( pPS_L->getRefCount() == 1 , "PropertySetHelper: wrong reference count" );
882 pPS_L->nDisposing = 0;
883 xPS = pPS = new test_OPropertySetHelper( getBasicProps(), PROPERTY_COUNT - z );
885 // Test set- and get- (Fast) propertyValue
887 // set read only property
890 // Readonly raises a vetoable exception
891 sal_Bool b = sal_True;
892 Any aBool;
893 aBool.setValue( &b , getCppuBooleanType() );
894 xPS->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("BOOL") ), aBool );
895 OSL_ENSURE( sal_False, "PropertySetHelper: exeption not thrown" );
897 catch( PropertyVetoException & /*e*/ )
903 // Readonly raises a vetoable exception
904 sal_Bool b = sal_True;
905 Any aBool;
906 aBool.setValue( &b , getCppuBooleanType() );
907 // BOOL i s0
908 pPS->setFastPropertyValue( PROPERTY_BOOL, aBool );
909 OSL_ENSURE( sal_False, "PropertySetHelper: exeption not thrown" );
911 catch( PropertyVetoException & /*e*/ )
915 // set unknown property
918 sal_Bool b = sal_True;
919 Any aBool;
920 aBool.setValue( &b , getCppuBooleanType() );
921 xPS->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("Does not exist") ), aBool );
922 OSL_ENSURE( sal_False, "PropertySetHelper: exeption not thrown" );
924 catch( UnknownPropertyException & /*e*/ )
930 sal_Bool b = sal_True;
931 Any aBool;
932 aBool.setValue( &b , getCppuBooleanType() );
933 pPS->setFastPropertyValue( 3, aBool );
934 OSL_ENSURE( sal_False, "PropertySetHelper: exeption not thrown" );
936 catch( UnknownPropertyException & /*e*/ )
940 // get unknown property
943 Any aBool;
944 aBool = xPS->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("Does not exist") ) );
945 OSL_ENSURE( sal_False, "PropertySetHelper: exeption not thrown" );
947 catch( UnknownPropertyException & /*e*/ )
951 try
953 Any aBool;
954 aBool = ((XFastPropertySet *)pPS)->getFastPropertyValue( 3 );
955 OSL_ENSURE( sal_False, "PropertySetHelper: exeption not thrown" );
957 catch( UnknownPropertyException & /*e*/ )
961 // set property with invalid type
964 Any aBool;
965 xPS->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("INT32") ), aBool );
966 OSL_ENSURE( sal_False, "PropertySetHelper: exeption not thrown" );
968 catch( IllegalArgumentException & /*e*/ )
974 Any aBool;
975 pPS->setFastPropertyValue( PROPERTY_INT32, aBool );
976 OSL_ENSURE( sal_False, "PropertySetHelper: exeption not thrown" );
978 catch( IllegalArgumentException & /*e*/ )
982 // narrowing conversion is not allowed!
985 Any aINT32;
986 aINT32 <<= (sal_Int32 ) 16;
987 xPS->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), aINT32 );
988 OSL_ENSURE( sal_False, "PropertySetHelper: exeption not thrown" );
990 catch( IllegalArgumentException & /*e*/ )
997 Any aINT32;
998 aINT32 <<= (sal_Int32) 16;
999 pPS->setFastPropertyValue( PROPERTY_INT16, aINT32 );
1000 OSL_ENSURE( sal_False, "PropertySetHelper: exeption not thrown" );
1002 catch( IllegalArgumentException & /*e*/ )
1007 Any aValue;
1008 aValue = xPS->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("BOOL") ) );
1009 sal_Bool b = *( (sal_Bool*)aValue.getValue());
1010 OSL_ENSURE( ! b, "PropertySetHelper: wrong BOOL value" );
1011 aValue = ((XFastPropertySet *)pPS)->getFastPropertyValue( PROPERTY_BOOL );
1013 b = *((sal_Bool*)aValue.getValue());
1014 OSL_ENSURE( !b, "PropertySetHelper: wrong BOOL value" );
1016 sal_Int16 n16;
1017 aValue <<=(sal_Int16)22;
1018 xPS->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), aValue );
1019 aValue = xPS->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ) );
1020 aValue >>= n16;
1021 OSL_ENSURE( 22 == n16 , "PropertySetHelper: wrong INT16 value" );
1022 aValue <<= (sal_Int16)44;
1023 ((XFastPropertySet *)pPS)->setFastPropertyValue( PROPERTY_INT16, aValue );
1025 aValue = ((XFastPropertySet *)pPS)->getFastPropertyValue( PROPERTY_INT16 );
1026 aValue >>= n16;
1027 OSL_ENSURE( 44 == n16, "PropertySetHelper: wrong INT16 value" );
1029 // widening conversion
1030 aValue <<= (sal_Int16)55;
1031 xPS->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("INT32") ), aValue );
1032 aValue = xPS->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("INT32") ) );
1033 sal_Int32 n32;
1034 aValue >>= n32;
1035 OSL_ENSURE( 55 == n32 , "PropertySetHelper: wrong INT32 value" );
1036 aValue <<= (sal_Int16)66;
1037 ((XFastPropertySet *)pPS)->setFastPropertyValue( PROPERTY_INT32, aValue );
1038 aValue = ((XFastPropertySet *)pPS)->getFastPropertyValue( PROPERTY_INT32 );
1039 aValue >>= n32;
1040 OSL_ENSURE( 66 == n32, "PropertySetHelper: wrong INT32 value" );
1042 Sequence< OUString >valueNames = Sequence<OUString>( 3 );
1043 valueNames.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM("BOOL") );
1044 valueNames.getArray()[1] = OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") );
1045 valueNames.getArray()[2] = OUString( RTL_CONSTASCII_USTRINGPARAM("INT32") );
1046 Sequence< Any > aValues = pPS->getPropertyValues( valueNames );
1048 b = *((sal_Bool*)aValues.getConstArray()[0].getValue());
1049 aValues.getConstArray()[1] >>= n16;
1050 aValues.getConstArray()[2] >>= n32;
1052 OSL_ENSURE( !b, "PropertySetHelper: wrong BOOL value" );
1053 OSL_ENSURE( 44 == n16, "PropertySetHelper: wrong INT16 value" );
1054 OSL_ENSURE( 66 == n32, "PropertySetHelper: wrong INT32 value" );
1056 pPS->nINT32 = 0;
1057 pPS->nINT16 = 0;
1059 // Test add-remove listener
1061 Reference < XVetoableChangeListener > x2( xPS_L, UNO_QUERY );
1063 xPS->addPropertyChangeListener( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), xPS_L );
1064 pPS->addVetoableChangeListener( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), x2 );
1066 pPS_L->nCount = 10;
1067 Sequence< Any > aSeq( pPS_L->nCount );
1068 pPS_L->nCurrent = 0;
1070 pPS_L->pExceptedListenerValues = aSeq.getArray();
1072 pPS_L->pExceptedListenerValues[0] <<= (sal_Int16) 0; // old value vetoable
1073 pPS_L->pExceptedListenerValues[1] <<= (sal_Int16) 22; // new value vetoable
1074 pPS_L->pExceptedListenerValues[2] <<= (sal_Int16) 0; // old value bound
1075 pPS_L->pExceptedListenerValues[3] <<= (sal_Int16) 22; // new value bound
1076 pPS_L->pExceptedListenerValues[4] <<= (sal_Int16) 22; // old value vetoable
1077 pPS_L->pExceptedListenerValues[5] <<= (sal_Int16) 44; // new value vetoable
1078 pPS_L->pExceptedListenerValues[6] <<= (sal_Int16) 22; // old value bound
1079 pPS_L->pExceptedListenerValues[7] <<= (sal_Int16) 44; // new value bound
1080 pPS_L->pExceptedListenerValues[8] <<= (sal_Int16) 44; // old value vetoable
1081 pPS_L->pExceptedListenerValues[9] <<= (sal_Int16) 100; // new value vetoable exception
1083 Any aValue;
1084 aValue <<= (sal_Int16)22;
1085 xPS->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), aValue );
1086 aValue <<= (sal_Int16) 44;
1087 ((XFastPropertySet *)pPS)->setFastPropertyValue( PROPERTY_INT16, aValue );
1088 aValue <<= (sal_Int16)100;// exception
1092 ((XFastPropertySet *)pPS)->setFastPropertyValue( PROPERTY_INT16, aValue );
1093 OSL_ENSURE( sal_False, "PropertySetHelper: exeption not thrown" );
1095 catch( PropertyVetoException & /*e*/ )
1099 OSL_ENSURE( pPS_L->nCount == pPS_L->nCurrent, "not all listeners called" );
1100 pPS->nINT32 = 0;
1101 pPS->nINT16 = 0;
1102 pPS_L->nCount = 0;
1103 pPS_L->nCurrent = 0;
1104 pPS_L->pExceptedListenerValues = NULL;
1105 xPS->removePropertyChangeListener( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), xPS_L );
1106 pPS->removeVetoableChangeListener( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), x2 );
1109 // Test multi property set listener
1111 Reference < XPropertiesChangeListener > x1( xPS_L, UNO_QUERY );
1112 Reference < XVetoableChangeListener > x2( xPS_L, UNO_QUERY );
1114 pPS->addVetoableChangeListener( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ) , x2 );
1115 Sequence<OUString> szPN( 4 );
1116 szPN.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM("BOOL") );
1117 szPN.getArray()[1] = OUString( RTL_CONSTASCII_USTRINGPARAM("INT32") );
1118 szPN.getArray()[2] = OUString( RTL_CONSTASCII_USTRINGPARAM("Does not exist") ); // must ne ignored by the addPropertiesChangeListener method
1119 szPN.getArray()[3] = OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") );
1120 pPS->addPropertiesChangeListener( szPN, x1 );
1122 pPS_L->nCount = 6;
1123 Sequence< Any > aSeq( pPS_L->nCount );
1124 pPS_L->nCurrent = 0;
1125 pPS_L->pExceptedListenerValues = aSeq.getArray();
1126 pPS_L->pExceptedListenerValues[0] <<= (sal_Int16) 0; // old value vetoable
1127 pPS_L->pExceptedListenerValues[1] <<= (sal_Int16 ) 22; // new value vetoable
1128 // INT32 is not constrained
1129 pPS_L->pExceptedListenerValues[2] <<= (sal_Int16) 0; // old value bound
1130 pPS_L->pExceptedListenerValues[3] <<= (sal_Int16) 22; // new value bound
1131 pPS_L->pExceptedListenerValues[4] <<= (sal_Int32) 0; // old value bound
1132 pPS_L->pExceptedListenerValues[5] <<= (sal_Int32) 44; // new value bound
1134 szPN = Sequence<OUString>( 2 );
1135 szPN.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") );
1136 szPN.getArray()[1] = OUString( RTL_CONSTASCII_USTRINGPARAM("INT32") );
1137 Sequence< Any > aValues( 2 );
1138 aValues.getArray()[0] <<= (sal_Int16) 22;
1139 aValues.getArray()[1] <<= (sal_Int16) 44;
1140 pPS->setPropertyValues( szPN, aValues );
1141 OSL_ENSURE( pPS_L->nCount == pPS_L->nCurrent, "not all listeners called" );
1143 //firePropertiesChangeEvent
1144 pPS->nINT16 = 8;
1145 pPS->nINT32 = 5;
1146 pPS_L->nCount = 4;
1147 pPS_L->nCurrent = 0;
1148 pPS_L->pExceptedListenerValues[0] <<= (sal_Int16) 8; // old value
1149 pPS_L->pExceptedListenerValues[1] <<= (sal_Int16) 8; // new value
1150 pPS_L->pExceptedListenerValues[2] <<= (sal_Int32) 5; // old value
1151 pPS_L->pExceptedListenerValues[3] <<= (sal_Int32) 5; // new value
1152 pPS->firePropertiesChangeEvent( szPN, pPS_L );
1153 OSL_ENSURE( pPS_L->nCount == pPS_L->nCurrent, "not all listeners called" );
1156 //vetoable exception with multible
1157 szPN.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") );
1158 szPN.getArray()[1] = OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") );
1159 pPS->nINT32 = 0;
1160 pPS->nINT16 = 0;
1161 pPS_L->nCount = 4;
1162 pPS_L->nCurrent = 0;
1163 pPS_L->pExceptedListenerValues[0] <<= (sal_Int16) 0; // old value vetoable
1164 pPS_L->pExceptedListenerValues[1] <<= (sal_Int16) 44; // new value vetoable
1165 pPS_L->pExceptedListenerValues[2] <<= (sal_Int16) 0; // old value vetoable
1166 pPS_L->pExceptedListenerValues[3] <<= (sal_Int16) 100; // new value vetoable
1170 aValues.getArray()[0] <<= (sal_Int16)44;
1171 aValues.getArray()[1] <<= (sal_Int16)100;
1172 pPS->setPropertyValues( szPN, aValues );
1173 OSL_ENSURE( sal_False, "PropertySetHelper: exeption not thrown" );
1175 catch ( PropertyVetoException & /*e*/ )
1179 OSL_ENSURE( pPS_L->nCount == pPS_L->nCurrent, "not all listeners called" );
1180 pPS->removePropertiesChangeListener( x1 );
1181 pPS->removeVetoableChangeListener( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), x2 );