Version 3.6.0.2, tag libreoffice-3.6.0.2
[LibreOffice.git] / cppuhelper / test / testpropshlp.cxx
blob2c3cc5a7e22aea8237705db70298e847677134a6
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #if !defined(OSL_DEBUG_LEVEL) || OSL_DEBUG_LEVEL == 0
30 # undef OSL_DEBUG_LEVEL
31 # define OSL_DEBUG_LEVEL 2
32 #endif
35 #include <osl/mutex.hxx>
36 #include <osl/diagnose.h>
38 #include <cppuhelper/propshlp.hxx>
39 #include <cppuhelper/weak.hxx>
41 #include <cppuhelper/proptypehlp.hxx>
43 #include <com/sun/star/uno/Any.hxx>
44 #include <com/sun/star/beans/PropertyAttribute.hpp>
46 #include <cppuhelper/implbase3.hxx>
48 using namespace ::cppu;
49 using namespace ::rtl;
50 using namespace ::osl;
51 using namespace ::com::sun::star::uno;
52 using namespace ::com::sun::star::beans;
53 using namespace ::com::sun::star::lang;
57 /**********************
59 **********************/
60 static Property * getPropertyTable1()
62 static Property *pTable = 0;
64 if( ! pTable ) {
65 MutexGuard guard( Mutex::getGlobalMutex() );
66 if( ! pTable ) {
67 static Property aTable[] =
69 Property( OUString( RTL_CONSTASCII_USTRINGPARAM("a") ), 0, getCppuType( (OUString *)0) ,
70 PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), //OUString
71 Property( OUString( RTL_CONSTASCII_USTRINGPARAM("b") ), 1, getCppuCharType( ) ,
72 PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), //Char
73 Property( OUString( RTL_CONSTASCII_USTRINGPARAM("c") ), 2, getCppuType( (sal_Int32*)0) ,
74 PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), //sal_Int32
75 Property( OUString( RTL_CONSTASCII_USTRINGPARAM("d") ), 5, getCppuType( (double*)0) ,
76 PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), //double
77 Property( OUString( RTL_CONSTASCII_USTRINGPARAM("e") ), 7, getCppuBooleanType() ,
78 PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), //BOOL
79 Property( OUString( RTL_CONSTASCII_USTRINGPARAM("f") ), 8, getCppuType( (Any*)0) ,
80 PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ) //Any
82 pTable = aTable;
85 return pTable;
89 static Property * getPropertyTable2()
91 static Property *pTable = 0;
93 if( ! pTable ) {
94 MutexGuard guard( ::osl::Mutex::getGlobalMutex() );
95 if( ! pTable ) {
96 static Property aTable[] =
98 Property( OUString( RTL_CONSTASCII_USTRINGPARAM("f") ), 8, getCppuType( (Any *)0) ,
99 PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), // Any
100 Property( OUString( RTL_CONSTASCII_USTRINGPARAM("b") ), 1, getCppuCharType( ),
101 PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), // Char
102 Property( OUString( RTL_CONSTASCII_USTRINGPARAM("a") ), 0, getCppuType( (OUString*)0),
103 PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), // OUString
104 Property( OUString( RTL_CONSTASCII_USTRINGPARAM("d") ), 5, getCppuType( (double*)0) ,
105 PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), // Double
106 Property( OUString( RTL_CONSTASCII_USTRINGPARAM("c") ), 2, getCppuType( (sal_Int32*)0),
107 PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), // sal_Int32
108 Property( OUString( RTL_CONSTASCII_USTRINGPARAM("e") ), 7, getCppuBooleanType() ,
109 PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ) // Bool
111 pTable = aTable;
114 return pTable;
117 static Property * getPropertyTable3()
119 static Property *pTable = 0;
121 if( ! pTable ) {
122 MutexGuard guard( ::osl::Mutex::getGlobalMutex() );
123 if( ! pTable ) {
124 static Property aTable[] =
126 Property( OUString( RTL_CONSTASCII_USTRINGPARAM("b") ), 1, getCppuCharType( ),
127 PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), // Char
128 Property( OUString( RTL_CONSTASCII_USTRINGPARAM("f") ), 8, getCppuType( (Any *)0) ,
129 PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), // any
130 Property( OUString( RTL_CONSTASCII_USTRINGPARAM("a") ), 0, getCppuType( (OUString*)0),
131 PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ) // OUString
133 pTable = aTable;
136 return pTable;
140 static Property * getPropertyTable4()
142 static Property *pTable = 0;
144 if( ! pTable ) {
145 MutexGuard guard( ::osl::Mutex::getGlobalMutex() );
146 if( ! pTable ) {
147 static Property aTable[] =
149 Property( OUString( RTL_CONSTASCII_USTRINGPARAM("a") ), 0, getCppuType( (OUString*)0),
150 PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), // OUString
151 Property( OUString( RTL_CONSTASCII_USTRINGPARAM("b") ), 1, getCppuCharType( ),
152 PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), // Char
153 Property( OUString( RTL_CONSTASCII_USTRINGPARAM("f") ), 2, getCppuType( (Any *)0) ,
154 PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ) // Any
156 pTable = aTable;
159 return pTable;
164 /**********************
166 * Note : all Property names must be in the 127 ASCII subset !
168 **********************/
171 void test_PropertyArrayHelper()
173 // Test getProperties() and getCount()
175 OPropertyArrayHelper a1( getPropertyTable1(), 6 );
176 OSL_ENSURE( 6 == a1.getCount(), "not all properties inserted" );
177 Sequence< Property > aProps = a1.getProperties();
178 Property * pP = aProps.getArray();
179 OSL_ENSURE( 6 == aProps.getLength(), "getProperties() gives not all properties" );
180 for( int i = 0; i < 6; i++ )
182 OSL_ENSURE( pP[i].Name == getPropertyTable1()[i].Name , "Name not correct" );
183 OSL_ENSURE( pP[i].Handle == getPropertyTable1()[i].Handle, "Handle not correct" );
184 OSL_ENSURE( pP[i].Attributes == getPropertyTable1()[i].Attributes, "Attributes not correct" );
185 OSL_ENSURE( pP[i].Type == getPropertyTable1()[i].Type, "Type not correct" );
189 // Test sorting
191 OPropertyArrayHelper a1( getPropertyTable2(), 6, sal_False );
192 Sequence< Property > aProps = a1.getProperties();
193 Property * pP = aProps.getArray();
194 OSL_ENSURE( 6 == aProps.getLength(), "getProperties() gives not all properties" );
196 // table to switch to sorted
197 int a[] = { 2 , 1 , 4, 3, 5, 0 };
198 for( int i = 0; i < 6; i++ )
200 OSL_ENSURE( pP[i].Name == getPropertyTable2()[a[i]].Name , "Name not correct" );
201 OSL_ENSURE( pP[i].Handle == getPropertyTable2()[a[i]].Handle, "Handle not correct" );
202 OSL_ENSURE( pP[i].Attributes == getPropertyTable2()[a[i]].Attributes, "Attributes not correct" );
203 OSL_ENSURE( pP[i].Type == getPropertyTable2()[a[i]].Type, "Type not correct" );
207 // Test sorting
209 OPropertyArrayHelper a1( getPropertyTable3(), 3, sal_False );
210 Sequence< Property > aProps = a1.getProperties();
211 Property * pP = aProps.getArray();
212 OSL_ENSURE( 3 == aProps.getLength(), "getProperties() gives not all properties" );
213 // table to switch to sorted
214 int a[] = { 2 , 0 , 1 };
215 for( int i = 0; i < 3; i++ )
217 OSL_ENSURE( pP[i].Name == getPropertyTable3()[a[i]].Name , "Name not correct" );
218 OSL_ENSURE( pP[i].Handle == getPropertyTable3()[a[i]].Handle, "Handle not correct" );
219 OSL_ENSURE( pP[i].Attributes == getPropertyTable3()[a[i]].Attributes, "Attributes not correct" );
220 OSL_ENSURE( pP[i].Type == getPropertyTable3()[a[i]].Type, "Type not correct" );
224 // Test getPropertyByName and hasPropertyByName
226 OPropertyArrayHelper a1( getPropertyTable1(), 6 );
227 for( int i = 0; i < 6; i++ )
229 OSL_ENSURE( a1.hasPropertyByName( getPropertyTable1()[i].Name ), "hasPropertyByName not correct" );
230 Property aP = a1.getPropertyByName( getPropertyTable1()[i].Name );
231 OSL_ENSURE( aP.Name == getPropertyTable1()[i].Name , "Name not correct" );
232 OSL_ENSURE( aP.Handle == getPropertyTable1()[i].Handle, "Handle not correct" );
233 OSL_ENSURE( aP.Attributes == getPropertyTable1()[i].Attributes, "Attributes not correct" );
234 OSL_ENSURE( aP.Type == getPropertyTable1()[i].Type, "Type not correct" );
237 OSL_ENSURE( !a1.hasPropertyByName( OUString( RTL_CONSTASCII_USTRINGPARAM("never exist") ) ), "hasPropertyByName not correct" );
240 a1.getPropertyByName( OUString( RTL_CONSTASCII_USTRINGPARAM("never exist") ) );
241 OSL_FAIL( "exeption not thrown" );
243 catch( UnknownPropertyException & )
248 // Test getHandleByName
250 OPropertyArrayHelper a1( getPropertyTable1(), 6 );
251 for( int i = 0; i < 6; i++ )
253 sal_Int32 Handle = a1.getHandleByName( getPropertyTable1()[i].Name );
254 OSL_ENSURE( Handle == getPropertyTable1()[i].Handle, "Handle not correct" );
256 sal_Int32 Handle = a1.getHandleByName( OUString( RTL_CONSTASCII_USTRINGPARAM("asdaf") ) );
257 OSL_ENSURE( Handle == -1, "Handle not correct" );
260 // Test fillPropertyMembersByHandle
262 OPropertyArrayHelper a1( getPropertyTable1(), 6 );
263 int i;
264 for( i = 0; i < 6; i++ )
266 sal_Int16 nAttributes;
267 OUString aPropName;
268 sal_Bool b = a1.fillPropertyMembersByHandle( &aPropName, &nAttributes, getPropertyTable1()[i].Handle );
269 OSL_ENSURE( b, "fillPropertyMembersByHandle: handle not found" );
270 OSL_ENSURE( nAttributes == getPropertyTable1()[i].Attributes, "fillPropertyMembersByHandle: Attributes not correct" );
271 OSL_ENSURE( aPropName == getPropertyTable1()[i].Name , "fillPropertyMembersByHandle: Name not correct" );
273 OSL_ENSURE( !a1.fillPropertyMembersByHandle( NULL, NULL, 66666 ), "fillPropertyMembersByHandle: handle found" );
274 // optimized table
275 OPropertyArrayHelper a4( getPropertyTable4(), 3 );
276 for( i = 0; i < 3; i++ )
278 sal_Int16 nAttributes;
279 OUString aPropName;
280 sal_Bool b = a1.fillPropertyMembersByHandle( &aPropName, &nAttributes, getPropertyTable4()[i].Handle );
281 OSL_ENSURE( b, "fillPropertyMembersByHandle: handle not found" );
282 OSL_ENSURE( nAttributes == getPropertyTable1()[i].Attributes, "fillPropertyMembersByHandle: Attributes not correct" );
283 OSL_ENSURE( aPropName == getPropertyTable1()[i].Name , "fillPropertyMembersByHandle: Name not correct" );
285 OSL_ENSURE( !a4.fillPropertyMembersByHandle( NULL, NULL, 66666 ), "fillPropertyMembersByHandle: handle found" );
288 // Test fillHandles
290 OPropertyArrayHelper a1( getPropertyTable1(), 6 );
291 Sequence< OUString > aS( 4 );
292 sal_Int32 Handles[4];
293 // muss sortiert sein
294 aS.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM("a") );
295 aS.getArray()[1] = OUString( RTL_CONSTASCII_USTRINGPARAM("d") );
296 aS.getArray()[2] = OUString( RTL_CONSTASCII_USTRINGPARAM("f") );
297 aS.getArray()[3] = OUString( RTL_CONSTASCII_USTRINGPARAM("t") );
298 sal_Int32 nHitCount = a1.fillHandles( Handles, aS );
299 OSL_ENSURE( nHitCount == 3, "wrong number of hits " );
300 OSL_ENSURE( Handles[0] == getPropertyTable1()[0].Handle, "Handle not correct" );
301 OSL_ENSURE( Handles[1] == getPropertyTable1()[3].Handle, "Handle not correct" );
302 OSL_ENSURE( Handles[2] == getPropertyTable1()[5].Handle, "Handle not correct" );
303 OSL_ENSURE( Handles[3] == -1, "Handle not correct" );
310 //----------------------------------------------------
311 // test_OPropertySetHelper
312 //----------------------------------------------------
313 struct MutexContainer
315 Mutex aMutex;
317 class test_OPropertySetHelper :
318 public MutexContainer,
319 public OBroadcastHelper ,
320 public OPropertySetHelper,
321 public OWeakObject
323 public:
325 test_OPropertySetHelper( Property * p, sal_Int32 n )
326 : MutexContainer()
327 , OBroadcastHelper( ((MutexContainer *)this)->aMutex )
328 // , OPropertySetHelper( *(static_cast< OBroadcastHelper * >(this)))
329 // MSCI 4 bug ! :
330 // OBroadcastHelper == OBroadcastHelperVar<OMultiTypeInterfaceContainerHelper>
331 , OPropertySetHelper(
332 *(static_cast< OBroadcastHelper * >(this)))
333 , bBOOL( sal_False )
334 , nINT16( 0 )
335 , nINT32( 0 )
336 , pBasicProps( p )
337 , nPropCount( n )
342 ~test_OPropertySetHelper()
346 void dispose()
348 // see comphlp.cxx
349 sal_Bool bDoDispose = sal_False;
351 MutexGuard aGuard( rBHelper.rMutex );
352 if( !rBHelper.bDisposed && !rBHelper.bInDispose )
354 rBHelper.bInDispose = sal_True;
355 bDoDispose = sal_True;
358 if( bDoDispose )
360 disposing();
361 EventObject aEvt;
362 aEvt.Source = Reference < XInterface > ( (static_cast< OWeakObject * >(this)) );
364 rBHelper.aLC.disposeAndClear( aEvt );
365 rBHelper.bDisposed = sal_True;
366 rBHelper.bInDispose = sal_False;
370 // XInterface
371 Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(RuntimeException)
373 Any aRet( OPropertySetHelper::queryInterface( rType ) );
374 return (aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType ));
376 void SAL_CALL acquire() throw()
377 { OWeakObject::acquire(); }
378 void SAL_CALL release() throw()
379 { OWeakObject::release(); }
381 // XPropertySet
382 Reference < XPropertySetInfo > SAL_CALL getPropertySetInfo()throw(RuntimeException);
384 using OPropertySetHelper::getFastPropertyValue;
386 sal_Bool bBOOL;
387 sal_Int16 nINT16;
388 sal_Int32 nINT32;
389 Property * pBasicProps;
390 sal_Int32 nPropCount;
391 protected:
392 IPropertyArrayHelper & SAL_CALL getInfoHelper() throw(RuntimeException);
393 sal_Bool SAL_CALL convertFastPropertyValue(
394 Any & rConvertedValue, Any & rOldValue,
395 sal_Int32 nHandle, const Any& rValue )
396 throw(IllegalArgumentException);
397 void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const Any& rValue ) throw(RuntimeException);
398 void SAL_CALL getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const throw(RuntimeException);
401 //----------------------------------------------------------------------
402 //------ The Properties of this implementation -------------------------
403 //----------------------------------------------------------------------
404 // Id must be the index into the array
405 #define PROPERTY_BOOL 0
406 #define PROPERTY_INT16 1
407 #define PROPERTY_INT32 2
409 // Max number of properties
410 #define PROPERTY_COUNT 4
411 // Names of Properties
413 * All Properties of this implementation. Must be sorted by name.
415 Property * getBasicProps()
417 static Property *pTable = 0;
419 if( ! pTable ) {
420 MutexGuard guard( ::osl::Mutex::getGlobalMutex() );
421 if( ! pTable ) {
423 static Property aBasicProps[PROPERTY_COUNT] =
425 Property( OUString( RTL_CONSTASCII_USTRINGPARAM("BOOL") ) , PROPERTY_BOOL , getCppuBooleanType(), PropertyAttribute::READONLY ),
426 Property( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ) , PROPERTY_INT16,
427 getCppuType( (sal_Int16*)0 ), PropertyAttribute::BOUND | PropertyAttribute::CONSTRAINED ),
428 Property( OUString( RTL_CONSTASCII_USTRINGPARAM("INT32") ) , PROPERTY_INT32, getCppuType( (sal_Int32*)0 ), PropertyAttribute::BOUND ),
429 Property( OUString( RTL_CONSTASCII_USTRINGPARAM("TEST") ) , 55 , getCppuType( (sal_Int32*)0), PropertyAttribute::BOUND )
431 pTable = aBasicProps;
434 return pTable;
438 //----------------------------------------------------
439 // test_OPropertySetHelper_Listener
440 //----------------------------------------------------
441 class test_OPropertySetHelper_Listener
442 : public WeakImplHelper3< XPropertyChangeListener, XPropertiesChangeListener, XVetoableChangeListener >
444 public:
445 sal_Int32 nDisposing;
446 Mutex aMutex;
447 Any * pExceptedListenerValues;
448 sal_Int32 nCount;
449 sal_Int32 nCurrent;
451 test_OPropertySetHelper_Listener( Any * p = 0, sal_Int32 n = 0 )
452 : nDisposing( 0 )
453 , pExceptedListenerValues( p )
454 , nCount( n )
455 , nCurrent( 0 )
458 ~test_OPropertySetHelper_Listener()
462 sal_Int32 getRefCount() const
463 { return m_refCount; }
465 // XEventListener
466 void SAL_CALL disposing(const EventObject& /*evt*/) throw ( RuntimeException)
468 MutexGuard aGuard( aMutex );
469 nDisposing++;
472 // XPropertyChangeListener
473 void SAL_CALL propertyChange(const PropertyChangeEvent& evt) throw (RuntimeException)
475 if( !pExceptedListenerValues )
476 return;
477 MutexGuard aGuard( aMutex );
478 OSL_ENSURE( nCurrent +1 < nCount, "PropertySetHelper: too many listener calls" );
480 switch( evt.PropertyHandle )
482 case PROPERTY_BOOL:
484 OSL_FAIL( "PropertySetHelper: BOOL cannot change" );
485 OSL_ENSURE( evt.PropertyName == OUString( RTL_CONSTASCII_USTRINGPARAM("BOOL") ), "PropertySetHelper: wrong name" );
487 break;
489 case PROPERTY_INT16:
491 OSL_ENSURE( evt.PropertyName == OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), "PropertySetHelper: wrong name" );
493 OSL_ENSURE( pExceptedListenerValues[nCurrent].getValueType().getTypeClass() == TypeClass_SHORT ,
494 "PropertySetHelper: wrong data type" );
496 sal_Int16 nInt16(0), nOldInt16(0);
497 pExceptedListenerValues[nCurrent] >>= nInt16;
498 evt.OldValue >>= nOldInt16;
499 OSL_ENSURE( nInt16 == nOldInt16, "PropertySetHelper: wrong old value" );
502 pExceptedListenerValues[nCurrent+1] >>= nInt16;
503 evt.NewValue >>= nOldInt16;
504 OSL_ENSURE( nInt16 == nOldInt16 , "PropertySetHelper: wrong new value" );
506 break;
508 case PROPERTY_INT32:
510 OSL_ENSURE( evt.PropertyName == OUString( RTL_CONSTASCII_USTRINGPARAM("INT32") ), "PropertySetHelper: wrong name" );
512 sal_Int32 nInt32(0),nOldInt32(0);
514 pExceptedListenerValues[nCurrent] >>= nInt32;
515 evt.OldValue >>= nOldInt32;
516 OSL_ENSURE( nInt32 == nOldInt32 , "PropertySetHelper: wrong old value" );
518 pExceptedListenerValues[nCurrent+1] >>= nInt32;
519 evt.NewValue >>= nOldInt32;
520 OSL_ENSURE( nInt32 == nOldInt32 , "PropertySetHelper: wrong new value" );
522 break;
524 default:
525 OSL_FAIL( "XPropeSetHelper: invalid property handle" );
527 nCurrent += 2;
530 // XVetoableChangeListener
531 void SAL_CALL vetoableChange(const PropertyChangeEvent& evt) throw (PropertyVetoException, RuntimeException)
533 if( !pExceptedListenerValues )
534 return;
535 MutexGuard aGuard( aMutex );
536 OSL_ENSURE( nCurrent +1 < nCount, "PropertySetHelper: too many listener calls" );
538 switch( evt.PropertyHandle )
540 case PROPERTY_BOOL:
542 OSL_FAIL( "PropertySetHelper: BOOL cannot change" );
543 OSL_ENSURE( evt.PropertyName == OUString( RTL_CONSTASCII_USTRINGPARAM("BOOL") ), "PropertySetHelper: wrong name" );
545 break;
547 case PROPERTY_INT16:
549 OSL_ENSURE( evt.PropertyName == OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), "PropertySetHelper: wrong name" );
551 sal_Int16 nInt16(0), nOldInt16(0);
552 pExceptedListenerValues[nCurrent] >>= nInt16;
553 evt.OldValue >>= nOldInt16;
555 OSL_ENSURE( nInt16 == nOldInt16,"PropertySetHelper: wrong old value" );
557 pExceptedListenerValues[nCurrent+1] >>= nInt16;
558 evt.NewValue >>= nOldInt16;
559 OSL_ENSURE( nInt16 == nOldInt16 , "PropertySetHelper: wrong new value" );
561 if( nOldInt16 == 100 )
563 nCurrent += 2;
564 throw PropertyVetoException();
567 break;
569 case PROPERTY_INT32:
571 OSL_ENSURE( evt.PropertyName == OUString( RTL_CONSTASCII_USTRINGPARAM("INT32") ), "PropertySetHelper: wrong name" );
573 sal_Int32 nInt32(0),nOldInt32(0);
574 pExceptedListenerValues[nCurrent] >>= nInt32;
575 evt.OldValue >>= nOldInt32;
576 OSL_ENSURE( nInt32 == nOldInt32 , "PropertySetHelper: wrong old value" );
578 pExceptedListenerValues[nCurrent+1] >>= nInt32;
579 evt.NewValue >>= nOldInt32;
580 OSL_ENSURE( nInt32 == nOldInt32 , "PropertySetHelper: wrong new value" );
582 break;
584 default:
585 OSL_FAIL( "XPropeSetHelper: invalid property handle" );
587 nCurrent += 2;
590 // XPropertiesChangeListener
591 void SAL_CALL propertiesChange(const Sequence< PropertyChangeEvent >& evtSeq) throw (RuntimeException)
593 if( !pExceptedListenerValues )
594 return;
595 MutexGuard aGuard( aMutex );
596 for( sal_Int32 i = 0; i < evtSeq.getLength(); i++ )
598 const PropertyChangeEvent & evt = evtSeq.getConstArray()[i];
599 OSL_ENSURE( nCurrent +1 < nCount, "PropertySetHelper: too many listener calls" );
601 switch( evt.PropertyHandle )
603 case PROPERTY_BOOL:
605 OSL_FAIL( "PropertySetHelper: BOOL cannot change" );
606 OSL_ENSURE( evt.PropertyName == OUString( RTL_CONSTASCII_USTRINGPARAM("BOOL") ), "PropertySetHelper: wrong name" );
608 break;
610 case PROPERTY_INT16:
612 OSL_ENSURE( evt.PropertyName == OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), "PropertySetHelper: wrong name" );
614 sal_Int16 nInt16(0), nOldInt16(0);
615 pExceptedListenerValues[nCurrent] >>= nInt16;
616 evt.OldValue >>= nOldInt16;
617 OSL_ENSURE( nInt16 == nOldInt16 , "PropertySetHelper: wrong old value" );
620 pExceptedListenerValues[nCurrent+1] >>= nInt16;
621 evt.NewValue >>= nOldInt16;
622 OSL_ENSURE( nInt16 == nOldInt16 , "PropertySetHelper: wrong new value" );
624 break;
626 case PROPERTY_INT32:
628 OSL_ENSURE( evt.PropertyName == OUString( RTL_CONSTASCII_USTRINGPARAM("INT32") ), "PropertySetHelper: wrong name" );
631 sal_Int32 nInt32(0),nOldInt32(0);
632 pExceptedListenerValues[nCurrent] >>= nInt32;
633 evt.OldValue >>= nOldInt32;
634 OSL_ENSURE( nInt32 == nOldInt32 , "PropertySetHelper: wrong old value" );
636 pExceptedListenerValues[nCurrent+1] >>= nInt32;
637 evt.NewValue >>= nOldInt32;
638 OSL_ENSURE( nInt32 == nOldInt32 , "PropertySetHelper: wrong new value" );
640 break;
642 default:
643 OSL_FAIL( "XPropeSetHelper: invalid property handle" );
645 nCurrent += 2;
651 * Create a table that map names to index values.
653 IPropertyArrayHelper & test_OPropertySetHelper::getInfoHelper() throw(RuntimeException)
655 // no multi thread protection
656 static OPropertyArrayHelper aInfo( pBasicProps, nPropCount );
657 return aInfo;
660 // XPropertySet
661 Reference < XPropertySetInfo > test_OPropertySetHelper::getPropertySetInfo()
662 throw(RuntimeException)
664 // no multi thread protection
665 static Reference < XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
666 return xInfo;
669 // Return sal_True, value changed
670 sal_Bool test_OPropertySetHelper::convertFastPropertyValue
672 Any & rConvertedValue,
673 Any & rOldValue,
674 sal_Int32 nHandle,
675 const Any& rValue
676 )throw(IllegalArgumentException)
678 switch( nHandle )
680 case PROPERTY_BOOL:
682 sal_Bool b;
683 convertPropertyValue( b , rValue );
684 if( b != bBOOL )
687 rConvertedValue.setValue( &b , ::getCppuBooleanType() );
688 rOldValue.setValue( & bBOOL , ::getCppuBooleanType() );
689 return sal_True;
691 else
692 return sal_False;
695 case PROPERTY_INT16:
697 sal_Int16 n16;
698 convertPropertyValue( n16 , rValue );
700 if( n16 != nINT16 )
702 rConvertedValue <<= n16;
703 rOldValue <<= nINT16;
704 return sal_True;
706 else
707 return sal_False;
710 case PROPERTY_INT32:
712 sal_Int32 n32;
713 convertPropertyValue( n32 , rValue );
714 if( n32 != nINT32 )
716 rConvertedValue <<= n32;
717 rOldValue <<= nINT32;
718 return sal_True;
720 else
721 return sal_False;
724 default:
725 OSL_ENSURE( nHandle == -1, "invalid property handle" );
726 return sal_False;
731 * only set the value.
733 void test_OPropertySetHelper::setFastPropertyValue_NoBroadcast
735 sal_Int32 nHandle,
736 const Any& rValue
737 )throw(RuntimeException)
739 switch( nHandle )
741 case PROPERTY_BOOL:
742 OSL_ENSURE( rValue.getValueType().getTypeClass() == TypeClass_BOOLEAN, "invalid type" );
743 bBOOL = *((sal_Bool*)rValue.getValue());
744 break;
746 case PROPERTY_INT16:
747 OSL_ENSURE( rValue.getValueType().getTypeClass() == TypeClass_SHORT, "invalid type" );
748 rValue >>= nINT16;
749 break;
751 case PROPERTY_INT32:
752 OSL_ENSURE( rValue.getValueType().getTypeClass() == TypeClass_LONG, "invalid type" );
753 rValue >>= nINT32;
754 break;
756 default:
757 OSL_ENSURE( nHandle == -1, "invalid property handle" );
761 //--------------------------
762 void test_OPropertySetHelper::getFastPropertyValue( Any & rRet, sal_Int32 nHandle ) const
763 throw(RuntimeException)
765 switch( nHandle )
767 case PROPERTY_BOOL:
768 rRet.setValue( &bBOOL , getCppuBooleanType() );
769 break;
771 case PROPERTY_INT16:
772 rRet <<= nINT16;
773 break;
775 case PROPERTY_INT32:
776 rRet <<= nINT32;
777 break;
779 default:
780 OSL_ENSURE( nHandle == -1, "invalid property handle" );
785 void test_PropertySetHelper()
787 test_PropertyArrayHelper();
789 test_OPropertySetHelper * pPS;
791 Reference < XPropertySet > xPS;
792 Reference < XPropertyChangeListener > xPS_L;
793 test_OPropertySetHelper_Listener * pPS_L;
795 Reference < XInterface > x;
797 for( int z = 0; z < 2; z++ )
799 // first test aBasicProps Handles are { 0, 1, 2, 55 }
800 // first test getBasicProps() Handles are { 0, 1, 2 }
801 xPS = pPS = new test_OPropertySetHelper( getBasicProps(), PROPERTY_COUNT - z );
802 xPS_L = static_cast< XPropertyChangeListener * >( pPS_L = new test_OPropertySetHelper_Listener() );
804 // Test queryInterface
805 Reference < XPropertySet > rProp( xPS , UNO_QUERY );
806 OSL_ENSURE( rProp.is() , "PropertySetHelper: XPropertySet nor supported" );
808 Reference < XMultiPropertySet > rMulti( xPS , UNO_QUERY );
809 OSL_ENSURE( rMulti.is() , "PropertySetHelper: XMultiPropertySet nor supported" );
811 Reference < XFastPropertySet > rFast( xPS , UNO_QUERY );
812 OSL_ENSURE( rFast.is() , "PropertySetHelper: XFastPropertySet nor supported" );
814 x = Reference < XInterface > ();
816 // Test add-remove listener
818 Reference < XPropertiesChangeListener > x1( xPS_L, UNO_QUERY );
819 Reference < XVetoableChangeListener > x2( xPS_L, UNO_QUERY );
821 xPS->addPropertyChangeListener( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), xPS_L );
822 Sequence<OUString> szPN( 3 );
823 szPN.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM("BOOL") );
824 szPN.getArray()[1] = OUString( RTL_CONSTASCII_USTRINGPARAM("INT32") );
825 szPN.getArray()[2] = OUString( RTL_CONSTASCII_USTRINGPARAM("Does not exist") ); // must ne ignored by the addPropertiesChangeListener method
826 pPS->addPropertiesChangeListener( szPN, x1 );
828 szPN = Sequence<OUString>();
829 pPS->addPropertiesChangeListener( szPN, x1 );
830 pPS->addVetoableChangeListener( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), x2 );
832 xPS->removePropertyChangeListener( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), xPS_L );
833 pPS->removePropertiesChangeListener( x1 );
834 pPS->removePropertiesChangeListener( x1 );
835 pPS->removeVetoableChangeListener( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), x2 );
837 // this exception must thrown
840 xPS->addPropertyChangeListener( OUString( RTL_CONSTASCII_USTRINGPARAM("Does not exist") ), xPS_L );
841 OSL_FAIL( "PropertySetHelper: exeption not thrown" );
843 catch( UnknownPropertyException & /*e*/ )
850 xPS->addVetoableChangeListener( OUString( RTL_CONSTASCII_USTRINGPARAM("Does not exist") ), x2 );
851 OSL_FAIL( "PropertySetHelper: exeption not thrown" );
853 catch( UnknownPropertyException & /*e*/ )
859 OSL_ENSURE( pPS_L->getRefCount() == 1, "PropertySetHelper: wrong reference count" );
861 // Test disposing
863 Reference < XPropertiesChangeListener > x1( xPS_L, UNO_QUERY );
864 Reference < XVetoableChangeListener > x2( xPS_L, UNO_QUERY );
866 xPS->addPropertyChangeListener( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), xPS_L );
867 Sequence<OUString> szPN( 2 );
868 szPN.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM("BOOL") );
869 szPN.getArray()[1] = OUString( RTL_CONSTASCII_USTRINGPARAM("INT32") );
870 pPS->addPropertiesChangeListener( szPN, x1 );
871 szPN = Sequence<OUString>();
872 pPS->addPropertiesChangeListener( szPN, x1 );
873 pPS->addVetoableChangeListener( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), x2 );
874 pPS->dispose();
876 OSL_ENSURE( pPS_L->nDisposing == 4 , "PropertySetHelper: wrong disposing count" );
877 OSL_ENSURE( pPS_L->getRefCount() == 1 , "PropertySetHelper: wrong reference count" );
878 pPS_L->nDisposing = 0;
879 xPS = pPS = new test_OPropertySetHelper( getBasicProps(), PROPERTY_COUNT - z );
881 // Test set- and get- (Fast) propertyValue
883 // set read only property
886 // Readonly raises a vetoable exception
887 sal_Bool b = sal_True;
888 Any aBool;
889 aBool.setValue( &b , getCppuBooleanType() );
890 xPS->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("BOOL") ), aBool );
891 OSL_FAIL( "PropertySetHelper: exeption not thrown" );
893 catch( PropertyVetoException & /*e*/ )
899 // Readonly raises a vetoable exception
900 sal_Bool b = sal_True;
901 Any aBool;
902 aBool.setValue( &b , getCppuBooleanType() );
903 // BOOL i s0
904 pPS->setFastPropertyValue( PROPERTY_BOOL, aBool );
905 OSL_FAIL( "PropertySetHelper: exeption not thrown" );
907 catch( PropertyVetoException & /*e*/ )
911 // set unknown property
914 sal_Bool b = sal_True;
915 Any aBool;
916 aBool.setValue( &b , getCppuBooleanType() );
917 xPS->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("Does not exist") ), aBool );
918 OSL_FAIL( "PropertySetHelper: exeption not thrown" );
920 catch( UnknownPropertyException & /*e*/ )
926 sal_Bool b = sal_True;
927 Any aBool;
928 aBool.setValue( &b , getCppuBooleanType() );
929 pPS->setFastPropertyValue( 3, aBool );
930 OSL_FAIL( "PropertySetHelper: exeption not thrown" );
932 catch( UnknownPropertyException & /*e*/ )
936 // get unknown property
939 Any aBool;
940 aBool = xPS->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("Does not exist") ) );
941 OSL_FAIL( "PropertySetHelper: exeption not thrown" );
943 catch( UnknownPropertyException & /*e*/ )
949 Any aBool;
950 aBool = ((XFastPropertySet *)pPS)->getFastPropertyValue( 3 );
951 OSL_FAIL( "PropertySetHelper: exeption not thrown" );
953 catch( UnknownPropertyException & /*e*/ )
957 // set property with invalid type
960 Any aBool;
961 xPS->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("INT32") ), aBool );
962 OSL_FAIL( "PropertySetHelper: exeption not thrown" );
964 catch( IllegalArgumentException & /*e*/ )
970 Any aBool;
971 pPS->setFastPropertyValue( PROPERTY_INT32, aBool );
972 OSL_FAIL( "PropertySetHelper: exeption not thrown" );
974 catch( IllegalArgumentException & /*e*/ )
978 // narrowing conversion is not allowed!
981 Any aINT32;
982 aINT32 <<= (sal_Int32 ) 16;
983 xPS->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), aINT32 );
984 OSL_FAIL( "PropertySetHelper: exeption not thrown" );
986 catch( IllegalArgumentException & /*e*/ )
993 Any aINT32;
994 aINT32 <<= (sal_Int32) 16;
995 pPS->setFastPropertyValue( PROPERTY_INT16, aINT32 );
996 OSL_FAIL( "PropertySetHelper: exeption not thrown" );
998 catch( IllegalArgumentException & /*e*/ )
1003 Any aValue;
1004 aValue = xPS->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("BOOL") ) );
1005 sal_Bool b = *( (sal_Bool*)aValue.getValue());
1006 OSL_ENSURE( ! b, "PropertySetHelper: wrong BOOL value" );
1007 aValue = ((XFastPropertySet *)pPS)->getFastPropertyValue( PROPERTY_BOOL );
1009 b = *((sal_Bool*)aValue.getValue());
1010 OSL_ENSURE( !b, "PropertySetHelper: wrong BOOL value" );
1012 sal_Int16 n16(0);
1013 aValue <<=(sal_Int16)22;
1014 xPS->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), aValue );
1015 aValue = xPS->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ) );
1016 aValue >>= n16;
1017 OSL_ENSURE( 22 == n16 , "PropertySetHelper: wrong INT16 value" );
1018 aValue <<= (sal_Int16)44;
1019 ((XFastPropertySet *)pPS)->setFastPropertyValue( PROPERTY_INT16, aValue );
1021 aValue = ((XFastPropertySet *)pPS)->getFastPropertyValue( PROPERTY_INT16 );
1022 aValue >>= n16;
1023 OSL_ENSURE( 44 == n16, "PropertySetHelper: wrong INT16 value" );
1025 // widening conversion
1026 aValue <<= (sal_Int16)55;
1027 xPS->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("INT32") ), aValue );
1028 aValue = xPS->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("INT32") ) );
1029 sal_Int32 n32(0);
1030 aValue >>= n32;
1031 OSL_ENSURE( 55 == n32 , "PropertySetHelper: wrong INT32 value" );
1032 aValue <<= (sal_Int16)66;
1033 ((XFastPropertySet *)pPS)->setFastPropertyValue( PROPERTY_INT32, aValue );
1034 aValue = ((XFastPropertySet *)pPS)->getFastPropertyValue( PROPERTY_INT32 );
1035 aValue >>= n32;
1036 OSL_ENSURE( 66 == n32, "PropertySetHelper: wrong INT32 value" );
1038 Sequence< OUString >valueNames = Sequence<OUString>( 3 );
1039 valueNames.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM("BOOL") );
1040 valueNames.getArray()[1] = OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") );
1041 valueNames.getArray()[2] = OUString( RTL_CONSTASCII_USTRINGPARAM("INT32") );
1042 Sequence< Any > aValues = pPS->getPropertyValues( valueNames );
1044 b = *((sal_Bool*)aValues.getConstArray()[0].getValue());
1045 aValues.getConstArray()[1] >>= n16;
1046 aValues.getConstArray()[2] >>= n32;
1048 OSL_ENSURE( !b, "PropertySetHelper: wrong BOOL value" );
1049 OSL_ENSURE( 44 == n16, "PropertySetHelper: wrong INT16 value" );
1050 OSL_ENSURE( 66 == n32, "PropertySetHelper: wrong INT32 value" );
1052 pPS->nINT32 = 0;
1053 pPS->nINT16 = 0;
1055 // Test add-remove listener
1057 Reference < XVetoableChangeListener > x2( xPS_L, UNO_QUERY );
1059 xPS->addPropertyChangeListener( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), xPS_L );
1060 pPS->addVetoableChangeListener( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), x2 );
1062 pPS_L->nCount = 10;
1063 Sequence< Any > aSeq( pPS_L->nCount );
1064 pPS_L->nCurrent = 0;
1066 pPS_L->pExceptedListenerValues = aSeq.getArray();
1068 pPS_L->pExceptedListenerValues[0] <<= (sal_Int16) 0; // old value vetoable
1069 pPS_L->pExceptedListenerValues[1] <<= (sal_Int16) 22; // new value vetoable
1070 pPS_L->pExceptedListenerValues[2] <<= (sal_Int16) 0; // old value bound
1071 pPS_L->pExceptedListenerValues[3] <<= (sal_Int16) 22; // new value bound
1072 pPS_L->pExceptedListenerValues[4] <<= (sal_Int16) 22; // old value vetoable
1073 pPS_L->pExceptedListenerValues[5] <<= (sal_Int16) 44; // new value vetoable
1074 pPS_L->pExceptedListenerValues[6] <<= (sal_Int16) 22; // old value bound
1075 pPS_L->pExceptedListenerValues[7] <<= (sal_Int16) 44; // new value bound
1076 pPS_L->pExceptedListenerValues[8] <<= (sal_Int16) 44; // old value vetoable
1077 pPS_L->pExceptedListenerValues[9] <<= (sal_Int16) 100; // new value vetoable exception
1079 Any aValue;
1080 aValue <<= (sal_Int16)22;
1081 xPS->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), aValue );
1082 aValue <<= (sal_Int16) 44;
1083 ((XFastPropertySet *)pPS)->setFastPropertyValue( PROPERTY_INT16, aValue );
1084 aValue <<= (sal_Int16)100;// exception
1088 ((XFastPropertySet *)pPS)->setFastPropertyValue( PROPERTY_INT16, aValue );
1089 OSL_FAIL( "PropertySetHelper: exeption not thrown" );
1091 catch( PropertyVetoException & /*e*/ )
1095 OSL_ENSURE( pPS_L->nCount == pPS_L->nCurrent, "not all listeners called" );
1096 pPS->nINT32 = 0;
1097 pPS->nINT16 = 0;
1098 pPS_L->nCount = 0;
1099 pPS_L->nCurrent = 0;
1100 pPS_L->pExceptedListenerValues = NULL;
1101 xPS->removePropertyChangeListener( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), xPS_L );
1102 pPS->removeVetoableChangeListener( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), x2 );
1105 // Test multi property set listener
1107 Reference < XPropertiesChangeListener > x1( xPS_L, UNO_QUERY );
1108 Reference < XVetoableChangeListener > x2( xPS_L, UNO_QUERY );
1110 pPS->addVetoableChangeListener( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ) , x2 );
1111 Sequence<OUString> szPN( 4 );
1112 szPN.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM("BOOL") );
1113 szPN.getArray()[1] = OUString( RTL_CONSTASCII_USTRINGPARAM("INT32") );
1114 szPN.getArray()[2] = OUString( RTL_CONSTASCII_USTRINGPARAM("Does not exist") ); // must ne ignored by the addPropertiesChangeListener method
1115 szPN.getArray()[3] = OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") );
1116 pPS->addPropertiesChangeListener( szPN, x1 );
1118 pPS_L->nCount = 6;
1119 Sequence< Any > aSeq( pPS_L->nCount );
1120 pPS_L->nCurrent = 0;
1121 pPS_L->pExceptedListenerValues = aSeq.getArray();
1122 pPS_L->pExceptedListenerValues[0] <<= (sal_Int16) 0; // old value vetoable
1123 pPS_L->pExceptedListenerValues[1] <<= (sal_Int16 ) 22; // new value vetoable
1124 // INT32 is not constrained
1125 pPS_L->pExceptedListenerValues[2] <<= (sal_Int16) 0; // old value bound
1126 pPS_L->pExceptedListenerValues[3] <<= (sal_Int16) 22; // new value bound
1127 pPS_L->pExceptedListenerValues[4] <<= (sal_Int32) 0; // old value bound
1128 pPS_L->pExceptedListenerValues[5] <<= (sal_Int32) 44; // new value bound
1130 szPN = Sequence<OUString>( 2 );
1131 szPN.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") );
1132 szPN.getArray()[1] = OUString( RTL_CONSTASCII_USTRINGPARAM("INT32") );
1133 Sequence< Any > aValues( 2 );
1134 aValues.getArray()[0] <<= (sal_Int16) 22;
1135 aValues.getArray()[1] <<= (sal_Int16) 44;
1136 pPS->setPropertyValues( szPN, aValues );
1137 OSL_ENSURE( pPS_L->nCount == pPS_L->nCurrent, "not all listeners called" );
1139 //firePropertiesChangeEvent
1140 pPS->nINT16 = 8;
1141 pPS->nINT32 = 5;
1142 pPS_L->nCount = 4;
1143 pPS_L->nCurrent = 0;
1144 pPS_L->pExceptedListenerValues[0] <<= (sal_Int16) 8; // old value
1145 pPS_L->pExceptedListenerValues[1] <<= (sal_Int16) 8; // new value
1146 pPS_L->pExceptedListenerValues[2] <<= (sal_Int32) 5; // old value
1147 pPS_L->pExceptedListenerValues[3] <<= (sal_Int32) 5; // new value
1148 pPS->firePropertiesChangeEvent( szPN, pPS_L );
1149 OSL_ENSURE( pPS_L->nCount == pPS_L->nCurrent, "not all listeners called" );
1152 //vetoable exception with multible
1153 szPN.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") );
1154 szPN.getArray()[1] = OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") );
1155 pPS->nINT32 = 0;
1156 pPS->nINT16 = 0;
1157 pPS_L->nCount = 4;
1158 pPS_L->nCurrent = 0;
1159 pPS_L->pExceptedListenerValues[0] <<= (sal_Int16) 0; // old value vetoable
1160 pPS_L->pExceptedListenerValues[1] <<= (sal_Int16) 44; // new value vetoable
1161 pPS_L->pExceptedListenerValues[2] <<= (sal_Int16) 0; // old value vetoable
1162 pPS_L->pExceptedListenerValues[3] <<= (sal_Int16) 100; // new value vetoable
1166 aValues.getArray()[0] <<= (sal_Int16)44;
1167 aValues.getArray()[1] <<= (sal_Int16)100;
1168 pPS->setPropertyValues( szPN, aValues );
1169 OSL_FAIL( "PropertySetHelper: exeption not thrown" );
1171 catch ( PropertyVetoException & /*e*/ )
1175 OSL_ENSURE( pPS_L->nCount == pPS_L->nCurrent, "not all listeners called" );
1176 pPS->removePropertiesChangeListener( x1 );
1177 pPS->removeVetoableChangeListener( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), x2 );
1182 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */