Revert "new change in helpcontent2"
[LibreOffice.git] / cppuhelper / test / testpropshlp.cxx
blobc7aff9e8971ef9601707b5224f55847708033151
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;
55 static Property * getPropertyTable1()
57 static Property *pTable = 0;
59 if( ! pTable ) {
60 MutexGuard guard( Mutex::getGlobalMutex() );
61 if( ! pTable ) {
62 static Property aTable[] =
64 Property( OUString( RTL_CONSTASCII_USTRINGPARAM("a") ), 0, getCppuType( (OUString *)0) ,
65 PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), //OUString
66 Property( OUString( RTL_CONSTASCII_USTRINGPARAM("b") ), 1, getCppuCharType( ) ,
67 PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), //Char
68 Property( OUString( RTL_CONSTASCII_USTRINGPARAM("c") ), 2, getCppuType( (sal_Int32*)0) ,
69 PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), //sal_Int32
70 Property( OUString( RTL_CONSTASCII_USTRINGPARAM("d") ), 5, getCppuType( (double*)0) ,
71 PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), //double
72 Property( OUString( RTL_CONSTASCII_USTRINGPARAM("e") ), 7, getCppuBooleanType() ,
73 PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), //BOOL
74 Property( OUString( RTL_CONSTASCII_USTRINGPARAM("f") ), 8, getCppuType( (Any*)0) ,
75 PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ) //Any
77 pTable = aTable;
80 return pTable;
84 static Property * getPropertyTable2()
86 static Property *pTable = 0;
88 if( ! pTable ) {
89 MutexGuard guard( ::osl::Mutex::getGlobalMutex() );
90 if( ! pTable ) {
91 static Property aTable[] =
93 Property( OUString( RTL_CONSTASCII_USTRINGPARAM("f") ), 8, getCppuType( (Any *)0) ,
94 PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), // Any
95 Property( OUString( RTL_CONSTASCII_USTRINGPARAM("b") ), 1, getCppuCharType( ),
96 PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), // Char
97 Property( OUString( RTL_CONSTASCII_USTRINGPARAM("a") ), 0, getCppuType( (OUString*)0),
98 PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), // OUString
99 Property( OUString( RTL_CONSTASCII_USTRINGPARAM("d") ), 5, getCppuType( (double*)0) ,
100 PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), // Double
101 Property( OUString( RTL_CONSTASCII_USTRINGPARAM("c") ), 2, getCppuType( (sal_Int32*)0),
102 PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), // sal_Int32
103 Property( OUString( RTL_CONSTASCII_USTRINGPARAM("e") ), 7, getCppuBooleanType() ,
104 PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ) // Bool
106 pTable = aTable;
109 return pTable;
112 static Property * getPropertyTable3()
114 static Property *pTable = 0;
116 if( ! pTable ) {
117 MutexGuard guard( ::osl::Mutex::getGlobalMutex() );
118 if( ! pTable ) {
119 static Property aTable[] =
121 Property( OUString( RTL_CONSTASCII_USTRINGPARAM("b") ), 1, getCppuCharType( ),
122 PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), // Char
123 Property( OUString( RTL_CONSTASCII_USTRINGPARAM("f") ), 8, getCppuType( (Any *)0) ,
124 PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), // any
125 Property( OUString( RTL_CONSTASCII_USTRINGPARAM("a") ), 0, getCppuType( (OUString*)0),
126 PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ) // OUString
128 pTable = aTable;
131 return pTable;
135 static Property * getPropertyTable4()
137 static Property *pTable = 0;
139 if( ! pTable ) {
140 MutexGuard guard( ::osl::Mutex::getGlobalMutex() );
141 if( ! pTable ) {
142 static Property aTable[] =
144 Property( OUString( RTL_CONSTASCII_USTRINGPARAM("a") ), 0, getCppuType( (OUString*)0),
145 PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), // OUString
146 Property( OUString( RTL_CONSTASCII_USTRINGPARAM("b") ), 1, getCppuCharType( ),
147 PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), // Char
148 Property( OUString( RTL_CONSTASCII_USTRINGPARAM("f") ), 2, getCppuType( (Any *)0) ,
149 PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ) // Any
151 pTable = aTable;
154 return pTable;
159 /**********************
161 * Note : all Property names must be in the 127 ASCII subset !
163 **********************/
166 void test_PropertyArrayHelper()
168 // Test getProperties() and getCount()
170 OPropertyArrayHelper a1( getPropertyTable1(), 6 );
171 OSL_ENSURE( 6 == a1.getCount(), "not all properties inserted" );
172 Sequence< Property > aProps = a1.getProperties();
173 Property * pP = aProps.getArray();
174 OSL_ENSURE( 6 == aProps.getLength(), "getProperties() gives not all properties" );
175 for( int i = 0; i < 6; i++ )
177 OSL_ENSURE( pP[i].Name == getPropertyTable1()[i].Name , "Name not correct" );
178 OSL_ENSURE( pP[i].Handle == getPropertyTable1()[i].Handle, "Handle not correct" );
179 OSL_ENSURE( pP[i].Attributes == getPropertyTable1()[i].Attributes, "Attributes not correct" );
180 OSL_ENSURE( pP[i].Type == getPropertyTable1()[i].Type, "Type not correct" );
184 // Test sorting
186 OPropertyArrayHelper a1( getPropertyTable2(), 6, sal_False );
187 Sequence< Property > aProps = a1.getProperties();
188 Property * pP = aProps.getArray();
189 OSL_ENSURE( 6 == aProps.getLength(), "getProperties() gives not all properties" );
191 // table to switch to sorted
192 int a[] = { 2 , 1 , 4, 3, 5, 0 };
193 for( int i = 0; i < 6; i++ )
195 OSL_ENSURE( pP[i].Name == getPropertyTable2()[a[i]].Name , "Name not correct" );
196 OSL_ENSURE( pP[i].Handle == getPropertyTable2()[a[i]].Handle, "Handle not correct" );
197 OSL_ENSURE( pP[i].Attributes == getPropertyTable2()[a[i]].Attributes, "Attributes not correct" );
198 OSL_ENSURE( pP[i].Type == getPropertyTable2()[a[i]].Type, "Type not correct" );
202 // Test sorting
204 OPropertyArrayHelper a1( getPropertyTable3(), 3, sal_False );
205 Sequence< Property > aProps = a1.getProperties();
206 Property * pP = aProps.getArray();
207 OSL_ENSURE( 3 == aProps.getLength(), "getProperties() gives not all properties" );
208 // table to switch to sorted
209 int a[] = { 2 , 0 , 1 };
210 for( int i = 0; i < 3; i++ )
212 OSL_ENSURE( pP[i].Name == getPropertyTable3()[a[i]].Name , "Name not correct" );
213 OSL_ENSURE( pP[i].Handle == getPropertyTable3()[a[i]].Handle, "Handle not correct" );
214 OSL_ENSURE( pP[i].Attributes == getPropertyTable3()[a[i]].Attributes, "Attributes not correct" );
215 OSL_ENSURE( pP[i].Type == getPropertyTable3()[a[i]].Type, "Type not correct" );
219 // Test getPropertyByName and hasPropertyByName
221 OPropertyArrayHelper a1( getPropertyTable1(), 6 );
222 for( int i = 0; i < 6; i++ )
224 OSL_ENSURE( a1.hasPropertyByName( getPropertyTable1()[i].Name ), "hasPropertyByName not correct" );
225 Property aP = a1.getPropertyByName( getPropertyTable1()[i].Name );
226 OSL_ENSURE( aP.Name == getPropertyTable1()[i].Name , "Name not correct" );
227 OSL_ENSURE( aP.Handle == getPropertyTable1()[i].Handle, "Handle not correct" );
228 OSL_ENSURE( aP.Attributes == getPropertyTable1()[i].Attributes, "Attributes not correct" );
229 OSL_ENSURE( aP.Type == getPropertyTable1()[i].Type, "Type not correct" );
232 OSL_ENSURE( !a1.hasPropertyByName( OUString( RTL_CONSTASCII_USTRINGPARAM("never exist") ) ), "hasPropertyByName not correct" );
235 a1.getPropertyByName( OUString( RTL_CONSTASCII_USTRINGPARAM("never exist") ) );
236 OSL_FAIL( "exeption not thrown" );
238 catch( UnknownPropertyException & )
243 // Test getHandleByName
245 OPropertyArrayHelper a1( getPropertyTable1(), 6 );
246 for( int i = 0; i < 6; i++ )
248 sal_Int32 Handle = a1.getHandleByName( getPropertyTable1()[i].Name );
249 OSL_ENSURE( Handle == getPropertyTable1()[i].Handle, "Handle not correct" );
251 sal_Int32 Handle = a1.getHandleByName( OUString( RTL_CONSTASCII_USTRINGPARAM("asdaf") ) );
252 OSL_ENSURE( Handle == -1, "Handle not correct" );
255 // Test fillPropertyMembersByHandle
257 OPropertyArrayHelper a1( getPropertyTable1(), 6 );
258 int i;
259 for( i = 0; i < 6; i++ )
261 sal_Int16 nAttributes;
262 OUString aPropName;
263 sal_Bool b = a1.fillPropertyMembersByHandle( &aPropName, &nAttributes, getPropertyTable1()[i].Handle );
264 OSL_ENSURE( b, "fillPropertyMembersByHandle: handle not found" );
265 OSL_ENSURE( nAttributes == getPropertyTable1()[i].Attributes, "fillPropertyMembersByHandle: Attributes not correct" );
266 OSL_ENSURE( aPropName == getPropertyTable1()[i].Name , "fillPropertyMembersByHandle: Name not correct" );
268 OSL_ENSURE( !a1.fillPropertyMembersByHandle( NULL, NULL, 66666 ), "fillPropertyMembersByHandle: handle found" );
269 // optimized table
270 OPropertyArrayHelper a4( getPropertyTable4(), 3 );
271 for( i = 0; i < 3; i++ )
273 sal_Int16 nAttributes;
274 OUString aPropName;
275 sal_Bool b = a1.fillPropertyMembersByHandle( &aPropName, &nAttributes, getPropertyTable4()[i].Handle );
276 OSL_ENSURE( b, "fillPropertyMembersByHandle: handle not found" );
277 OSL_ENSURE( nAttributes == getPropertyTable1()[i].Attributes, "fillPropertyMembersByHandle: Attributes not correct" );
278 OSL_ENSURE( aPropName == getPropertyTable1()[i].Name , "fillPropertyMembersByHandle: Name not correct" );
280 OSL_ENSURE( !a4.fillPropertyMembersByHandle( NULL, NULL, 66666 ), "fillPropertyMembersByHandle: handle found" );
283 // Test fillHandles
285 OPropertyArrayHelper a1( getPropertyTable1(), 6 );
286 Sequence< OUString > aS( 4 );
287 sal_Int32 Handles[4];
288 // muss sortiert sein
289 aS.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM("a") );
290 aS.getArray()[1] = OUString( RTL_CONSTASCII_USTRINGPARAM("d") );
291 aS.getArray()[2] = OUString( RTL_CONSTASCII_USTRINGPARAM("f") );
292 aS.getArray()[3] = OUString( RTL_CONSTASCII_USTRINGPARAM("t") );
293 sal_Int32 nHitCount = a1.fillHandles( Handles, aS );
294 OSL_ENSURE( nHitCount == 3, "wrong number of hits " );
295 OSL_ENSURE( Handles[0] == getPropertyTable1()[0].Handle, "Handle not correct" );
296 OSL_ENSURE( Handles[1] == getPropertyTable1()[3].Handle, "Handle not correct" );
297 OSL_ENSURE( Handles[2] == getPropertyTable1()[5].Handle, "Handle not correct" );
298 OSL_ENSURE( Handles[3] == -1, "Handle not correct" );
305 //----------------------------------------------------
306 // test_OPropertySetHelper
307 //----------------------------------------------------
308 struct MutexContainer
310 Mutex aMutex;
312 class test_OPropertySetHelper :
313 public MutexContainer,
314 public OBroadcastHelper ,
315 public OPropertySetHelper,
316 public OWeakObject
318 public:
320 test_OPropertySetHelper( Property * p, sal_Int32 n )
321 : MutexContainer()
322 , OBroadcastHelper( ((MutexContainer *)this)->aMutex )
323 // , OPropertySetHelper( *(static_cast< OBroadcastHelper * >(this)))
324 // MSCI 4 bug ! :
325 // OBroadcastHelper == OBroadcastHelperVar<OMultiTypeInterfaceContainerHelper>
326 , OPropertySetHelper(
327 *(static_cast< OBroadcastHelper * >(this)))
328 , bBOOL( sal_False )
329 , nINT16( 0 )
330 , nINT32( 0 )
331 , pBasicProps( p )
332 , nPropCount( n )
337 ~test_OPropertySetHelper()
341 void dispose()
343 // see comphlp.cxx
344 sal_Bool bDoDispose = sal_False;
346 MutexGuard aGuard( rBHelper.rMutex );
347 if( !rBHelper.bDisposed && !rBHelper.bInDispose )
349 rBHelper.bInDispose = sal_True;
350 bDoDispose = sal_True;
353 if( bDoDispose )
355 disposing();
356 EventObject aEvt;
357 aEvt.Source = Reference < XInterface > ( (static_cast< OWeakObject * >(this)) );
359 rBHelper.aLC.disposeAndClear( aEvt );
360 rBHelper.bDisposed = sal_True;
361 rBHelper.bInDispose = sal_False;
365 // XInterface
366 Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(RuntimeException)
368 Any aRet( OPropertySetHelper::queryInterface( rType ) );
369 return (aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType ));
371 void SAL_CALL acquire() throw()
372 { OWeakObject::acquire(); }
373 void SAL_CALL release() throw()
374 { OWeakObject::release(); }
376 // XPropertySet
377 Reference < XPropertySetInfo > SAL_CALL getPropertySetInfo()throw(RuntimeException);
379 using OPropertySetHelper::getFastPropertyValue;
381 sal_Bool bBOOL;
382 sal_Int16 nINT16;
383 sal_Int32 nINT32;
384 Property * pBasicProps;
385 sal_Int32 nPropCount;
386 protected:
387 IPropertyArrayHelper & SAL_CALL getInfoHelper() throw(RuntimeException);
388 sal_Bool SAL_CALL convertFastPropertyValue(
389 Any & rConvertedValue, Any & rOldValue,
390 sal_Int32 nHandle, const Any& rValue )
391 throw(IllegalArgumentException);
392 void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const Any& rValue ) throw(RuntimeException);
393 void SAL_CALL getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const throw(RuntimeException);
396 //----------------------------------------------------------------------
397 //------ The Properties of this implementation -------------------------
398 //----------------------------------------------------------------------
399 // Id must be the index into the array
400 #define PROPERTY_BOOL 0
401 #define PROPERTY_INT16 1
402 #define PROPERTY_INT32 2
404 // Max number of properties
405 #define PROPERTY_COUNT 4
406 // Names of Properties
408 * All Properties of this implementation. Must be sorted by name.
410 Property * getBasicProps()
412 static Property *pTable = 0;
414 if( ! pTable ) {
415 MutexGuard guard( ::osl::Mutex::getGlobalMutex() );
416 if( ! pTable ) {
418 static Property aBasicProps[PROPERTY_COUNT] =
420 Property( OUString( RTL_CONSTASCII_USTRINGPARAM("BOOL") ) , PROPERTY_BOOL , getCppuBooleanType(), PropertyAttribute::READONLY ),
421 Property( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ) , PROPERTY_INT16,
422 getCppuType( (sal_Int16*)0 ), PropertyAttribute::BOUND | PropertyAttribute::CONSTRAINED ),
423 Property( OUString( RTL_CONSTASCII_USTRINGPARAM("INT32") ) , PROPERTY_INT32, getCppuType( (sal_Int32*)0 ), PropertyAttribute::BOUND ),
424 Property( OUString( RTL_CONSTASCII_USTRINGPARAM("TEST") ) , 55 , getCppuType( (sal_Int32*)0), PropertyAttribute::BOUND )
426 pTable = aBasicProps;
429 return pTable;
433 //----------------------------------------------------
434 // test_OPropertySetHelper_Listener
435 //----------------------------------------------------
436 class test_OPropertySetHelper_Listener
437 : public WeakImplHelper3< XPropertyChangeListener, XPropertiesChangeListener, XVetoableChangeListener >
439 public:
440 sal_Int32 nDisposing;
441 Mutex aMutex;
442 Any * pExceptedListenerValues;
443 sal_Int32 nCount;
444 sal_Int32 nCurrent;
446 test_OPropertySetHelper_Listener( Any * p = 0, sal_Int32 n = 0 )
447 : nDisposing( 0 )
448 , pExceptedListenerValues( p )
449 , nCount( n )
450 , nCurrent( 0 )
453 ~test_OPropertySetHelper_Listener()
457 sal_Int32 getRefCount() const
458 { return m_refCount; }
460 // XEventListener
461 void SAL_CALL disposing(const EventObject& /*evt*/) throw ( RuntimeException)
463 MutexGuard aGuard( aMutex );
464 nDisposing++;
467 // XPropertyChangeListener
468 void SAL_CALL propertyChange(const PropertyChangeEvent& evt) throw (RuntimeException)
470 if( !pExceptedListenerValues )
471 return;
472 MutexGuard aGuard( aMutex );
473 OSL_ENSURE( nCurrent +1 < nCount, "PropertySetHelper: too many listener calls" );
475 switch( evt.PropertyHandle )
477 case PROPERTY_BOOL:
479 OSL_FAIL( "PropertySetHelper: BOOL cannot change" );
480 OSL_ENSURE( evt.PropertyName == OUString( RTL_CONSTASCII_USTRINGPARAM("BOOL") ), "PropertySetHelper: wrong name" );
482 break;
484 case PROPERTY_INT16:
486 OSL_ENSURE( evt.PropertyName == OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), "PropertySetHelper: wrong name" );
488 OSL_ENSURE( pExceptedListenerValues[nCurrent].getValueType().getTypeClass() == TypeClass_SHORT ,
489 "PropertySetHelper: wrong data type" );
491 sal_Int16 nInt16(0), nOldInt16(0);
492 pExceptedListenerValues[nCurrent] >>= nInt16;
493 evt.OldValue >>= nOldInt16;
494 OSL_ENSURE( nInt16 == nOldInt16, "PropertySetHelper: wrong old value" );
497 pExceptedListenerValues[nCurrent+1] >>= nInt16;
498 evt.NewValue >>= nOldInt16;
499 OSL_ENSURE( nInt16 == nOldInt16 , "PropertySetHelper: wrong new value" );
501 break;
503 case PROPERTY_INT32:
505 OSL_ENSURE( evt.PropertyName == OUString( RTL_CONSTASCII_USTRINGPARAM("INT32") ), "PropertySetHelper: wrong name" );
507 sal_Int32 nInt32(0),nOldInt32(0);
509 pExceptedListenerValues[nCurrent] >>= nInt32;
510 evt.OldValue >>= nOldInt32;
511 OSL_ENSURE( nInt32 == nOldInt32 , "PropertySetHelper: wrong old value" );
513 pExceptedListenerValues[nCurrent+1] >>= nInt32;
514 evt.NewValue >>= nOldInt32;
515 OSL_ENSURE( nInt32 == nOldInt32 , "PropertySetHelper: wrong new value" );
517 break;
519 default:
520 OSL_FAIL( "XPropeSetHelper: invalid property handle" );
522 nCurrent += 2;
525 // XVetoableChangeListener
526 void SAL_CALL vetoableChange(const PropertyChangeEvent& evt) throw (PropertyVetoException, RuntimeException)
528 if( !pExceptedListenerValues )
529 return;
530 MutexGuard aGuard( aMutex );
531 OSL_ENSURE( nCurrent +1 < nCount, "PropertySetHelper: too many listener calls" );
533 switch( evt.PropertyHandle )
535 case PROPERTY_BOOL:
537 OSL_FAIL( "PropertySetHelper: BOOL cannot change" );
538 OSL_ENSURE( evt.PropertyName == OUString( RTL_CONSTASCII_USTRINGPARAM("BOOL") ), "PropertySetHelper: wrong name" );
540 break;
542 case PROPERTY_INT16:
544 OSL_ENSURE( evt.PropertyName == OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), "PropertySetHelper: wrong name" );
546 sal_Int16 nInt16(0), nOldInt16(0);
547 pExceptedListenerValues[nCurrent] >>= nInt16;
548 evt.OldValue >>= nOldInt16;
550 OSL_ENSURE( nInt16 == nOldInt16,"PropertySetHelper: wrong old value" );
552 pExceptedListenerValues[nCurrent+1] >>= nInt16;
553 evt.NewValue >>= nOldInt16;
554 OSL_ENSURE( nInt16 == nOldInt16 , "PropertySetHelper: wrong new value" );
556 if( nOldInt16 == 100 )
558 nCurrent += 2;
559 throw PropertyVetoException();
562 break;
564 case PROPERTY_INT32:
566 OSL_ENSURE( evt.PropertyName == OUString( RTL_CONSTASCII_USTRINGPARAM("INT32") ), "PropertySetHelper: wrong name" );
568 sal_Int32 nInt32(0),nOldInt32(0);
569 pExceptedListenerValues[nCurrent] >>= nInt32;
570 evt.OldValue >>= nOldInt32;
571 OSL_ENSURE( nInt32 == nOldInt32 , "PropertySetHelper: wrong old value" );
573 pExceptedListenerValues[nCurrent+1] >>= nInt32;
574 evt.NewValue >>= nOldInt32;
575 OSL_ENSURE( nInt32 == nOldInt32 , "PropertySetHelper: wrong new value" );
577 break;
579 default:
580 OSL_FAIL( "XPropeSetHelper: invalid property handle" );
582 nCurrent += 2;
585 // XPropertiesChangeListener
586 void SAL_CALL propertiesChange(const Sequence< PropertyChangeEvent >& evtSeq) throw (RuntimeException)
588 if( !pExceptedListenerValues )
589 return;
590 MutexGuard aGuard( aMutex );
591 for( sal_Int32 i = 0; i < evtSeq.getLength(); i++ )
593 const PropertyChangeEvent & evt = evtSeq.getConstArray()[i];
594 OSL_ENSURE( nCurrent +1 < nCount, "PropertySetHelper: too many listener calls" );
596 switch( evt.PropertyHandle )
598 case PROPERTY_BOOL:
600 OSL_FAIL( "PropertySetHelper: BOOL cannot change" );
601 OSL_ENSURE( evt.PropertyName == OUString( RTL_CONSTASCII_USTRINGPARAM("BOOL") ), "PropertySetHelper: wrong name" );
603 break;
605 case PROPERTY_INT16:
607 OSL_ENSURE( evt.PropertyName == OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), "PropertySetHelper: wrong name" );
609 sal_Int16 nInt16(0), nOldInt16(0);
610 pExceptedListenerValues[nCurrent] >>= nInt16;
611 evt.OldValue >>= nOldInt16;
612 OSL_ENSURE( nInt16 == nOldInt16 , "PropertySetHelper: wrong old value" );
615 pExceptedListenerValues[nCurrent+1] >>= nInt16;
616 evt.NewValue >>= nOldInt16;
617 OSL_ENSURE( nInt16 == nOldInt16 , "PropertySetHelper: wrong new value" );
619 break;
621 case PROPERTY_INT32:
623 OSL_ENSURE( evt.PropertyName == OUString( RTL_CONSTASCII_USTRINGPARAM("INT32") ), "PropertySetHelper: wrong name" );
626 sal_Int32 nInt32(0),nOldInt32(0);
627 pExceptedListenerValues[nCurrent] >>= nInt32;
628 evt.OldValue >>= nOldInt32;
629 OSL_ENSURE( nInt32 == nOldInt32 , "PropertySetHelper: wrong old value" );
631 pExceptedListenerValues[nCurrent+1] >>= nInt32;
632 evt.NewValue >>= nOldInt32;
633 OSL_ENSURE( nInt32 == nOldInt32 , "PropertySetHelper: wrong new value" );
635 break;
637 default:
638 OSL_FAIL( "XPropeSetHelper: invalid property handle" );
640 nCurrent += 2;
646 * Create a table that map names to index values.
648 IPropertyArrayHelper & test_OPropertySetHelper::getInfoHelper() throw(RuntimeException)
650 // no multi thread protection
651 static OPropertyArrayHelper aInfo( pBasicProps, nPropCount );
652 return aInfo;
655 // XPropertySet
656 Reference < XPropertySetInfo > test_OPropertySetHelper::getPropertySetInfo()
657 throw(RuntimeException)
659 // no multi thread protection
660 static Reference < XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
661 return xInfo;
664 // Return sal_True, value changed
665 sal_Bool test_OPropertySetHelper::convertFastPropertyValue
667 Any & rConvertedValue,
668 Any & rOldValue,
669 sal_Int32 nHandle,
670 const Any& rValue
671 )throw(IllegalArgumentException)
673 switch( nHandle )
675 case PROPERTY_BOOL:
677 sal_Bool b;
678 convertPropertyValue( b , rValue );
679 if( b != bBOOL )
682 rConvertedValue.setValue( &b , ::getCppuBooleanType() );
683 rOldValue.setValue( & bBOOL , ::getCppuBooleanType() );
684 return sal_True;
686 else
687 return sal_False;
690 case PROPERTY_INT16:
692 sal_Int16 n16;
693 convertPropertyValue( n16 , rValue );
695 if( n16 != nINT16 )
697 rConvertedValue <<= n16;
698 rOldValue <<= nINT16;
699 return sal_True;
701 else
702 return sal_False;
705 case PROPERTY_INT32:
707 sal_Int32 n32;
708 convertPropertyValue( n32 , rValue );
709 if( n32 != nINT32 )
711 rConvertedValue <<= n32;
712 rOldValue <<= nINT32;
713 return sal_True;
715 else
716 return sal_False;
719 default:
720 OSL_ENSURE( nHandle == -1, "invalid property handle" );
721 return sal_False;
726 * only set the value.
728 void test_OPropertySetHelper::setFastPropertyValue_NoBroadcast
730 sal_Int32 nHandle,
731 const Any& rValue
732 )throw(RuntimeException)
734 switch( nHandle )
736 case PROPERTY_BOOL:
737 OSL_ENSURE( rValue.getValueType().getTypeClass() == TypeClass_BOOLEAN, "invalid type" );
738 bBOOL = *((sal_Bool*)rValue.getValue());
739 break;
741 case PROPERTY_INT16:
742 OSL_ENSURE( rValue.getValueType().getTypeClass() == TypeClass_SHORT, "invalid type" );
743 rValue >>= nINT16;
744 break;
746 case PROPERTY_INT32:
747 OSL_ENSURE( rValue.getValueType().getTypeClass() == TypeClass_LONG, "invalid type" );
748 rValue >>= nINT32;
749 break;
751 default:
752 OSL_ENSURE( nHandle == -1, "invalid property handle" );
756 //--------------------------
757 void test_OPropertySetHelper::getFastPropertyValue( Any & rRet, sal_Int32 nHandle ) const
758 throw(RuntimeException)
760 switch( nHandle )
762 case PROPERTY_BOOL:
763 rRet.setValue( &bBOOL , getCppuBooleanType() );
764 break;
766 case PROPERTY_INT16:
767 rRet <<= nINT16;
768 break;
770 case PROPERTY_INT32:
771 rRet <<= nINT32;
772 break;
774 default:
775 OSL_ENSURE( nHandle == -1, "invalid property handle" );
780 void test_PropertySetHelper()
782 test_PropertyArrayHelper();
784 test_OPropertySetHelper * pPS;
786 Reference < XPropertySet > xPS;
787 Reference < XPropertyChangeListener > xPS_L;
788 test_OPropertySetHelper_Listener * pPS_L;
790 Reference < XInterface > x;
792 for( int z = 0; z < 2; z++ )
794 // first test aBasicProps Handles are { 0, 1, 2, 55 }
795 // first test getBasicProps() Handles are { 0, 1, 2 }
796 xPS = pPS = new test_OPropertySetHelper( getBasicProps(), PROPERTY_COUNT - z );
797 xPS_L = static_cast< XPropertyChangeListener * >( pPS_L = new test_OPropertySetHelper_Listener() );
799 // Test queryInterface
800 Reference < XPropertySet > rProp( xPS , UNO_QUERY );
801 OSL_ENSURE( rProp.is() , "PropertySetHelper: XPropertySet nor supported" );
803 Reference < XMultiPropertySet > rMulti( xPS , UNO_QUERY );
804 OSL_ENSURE( rMulti.is() , "PropertySetHelper: XMultiPropertySet nor supported" );
806 Reference < XFastPropertySet > rFast( xPS , UNO_QUERY );
807 OSL_ENSURE( rFast.is() , "PropertySetHelper: XFastPropertySet nor supported" );
809 x = Reference < XInterface > ();
811 // Test add-remove listener
813 Reference < XPropertiesChangeListener > x1( xPS_L, UNO_QUERY );
814 Reference < XVetoableChangeListener > x2( xPS_L, UNO_QUERY );
816 xPS->addPropertyChangeListener( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), xPS_L );
817 Sequence<OUString> szPN( 3 );
818 szPN.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM("BOOL") );
819 szPN.getArray()[1] = OUString( RTL_CONSTASCII_USTRINGPARAM("INT32") );
820 szPN.getArray()[2] = OUString( RTL_CONSTASCII_USTRINGPARAM("Does not exist") ); // must ne ignored by the addPropertiesChangeListener method
821 pPS->addPropertiesChangeListener( szPN, x1 );
823 szPN = Sequence<OUString>();
824 pPS->addPropertiesChangeListener( szPN, x1 );
825 pPS->addVetoableChangeListener( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), x2 );
827 xPS->removePropertyChangeListener( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), xPS_L );
828 pPS->removePropertiesChangeListener( x1 );
829 pPS->removePropertiesChangeListener( x1 );
830 pPS->removeVetoableChangeListener( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), x2 );
832 // this exception must thrown
835 xPS->addPropertyChangeListener( OUString( RTL_CONSTASCII_USTRINGPARAM("Does not exist") ), xPS_L );
836 OSL_FAIL( "PropertySetHelper: exeption not thrown" );
838 catch( UnknownPropertyException & /*e*/ )
845 xPS->addVetoableChangeListener( OUString( RTL_CONSTASCII_USTRINGPARAM("Does not exist") ), x2 );
846 OSL_FAIL( "PropertySetHelper: exeption not thrown" );
848 catch( UnknownPropertyException & /*e*/ )
854 OSL_ENSURE( pPS_L->getRefCount() == 1, "PropertySetHelper: wrong reference count" );
856 // Test disposing
858 Reference < XPropertiesChangeListener > x1( xPS_L, UNO_QUERY );
859 Reference < XVetoableChangeListener > x2( xPS_L, UNO_QUERY );
861 xPS->addPropertyChangeListener( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), xPS_L );
862 Sequence<OUString> szPN( 2 );
863 szPN.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM("BOOL") );
864 szPN.getArray()[1] = OUString( RTL_CONSTASCII_USTRINGPARAM("INT32") );
865 pPS->addPropertiesChangeListener( szPN, x1 );
866 szPN = Sequence<OUString>();
867 pPS->addPropertiesChangeListener( szPN, x1 );
868 pPS->addVetoableChangeListener( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), x2 );
869 pPS->dispose();
871 OSL_ENSURE( pPS_L->nDisposing == 4 , "PropertySetHelper: wrong disposing count" );
872 OSL_ENSURE( pPS_L->getRefCount() == 1 , "PropertySetHelper: wrong reference count" );
873 pPS_L->nDisposing = 0;
874 xPS = pPS = new test_OPropertySetHelper( getBasicProps(), PROPERTY_COUNT - z );
876 // Test set- and get- (Fast) propertyValue
878 // set read only property
881 // Readonly raises a vetoable exception
882 sal_Bool b = sal_True;
883 Any aBool;
884 aBool.setValue( &b , getCppuBooleanType() );
885 xPS->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("BOOL") ), aBool );
886 OSL_FAIL( "PropertySetHelper: exeption not thrown" );
888 catch( PropertyVetoException & /*e*/ )
894 // Readonly raises a vetoable exception
895 sal_Bool b = sal_True;
896 Any aBool;
897 aBool.setValue( &b , getCppuBooleanType() );
898 // BOOL i s0
899 pPS->setFastPropertyValue( PROPERTY_BOOL, aBool );
900 OSL_FAIL( "PropertySetHelper: exeption not thrown" );
902 catch( PropertyVetoException & /*e*/ )
906 // set unknown property
909 sal_Bool b = sal_True;
910 Any aBool;
911 aBool.setValue( &b , getCppuBooleanType() );
912 xPS->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("Does not exist") ), aBool );
913 OSL_FAIL( "PropertySetHelper: exeption not thrown" );
915 catch( UnknownPropertyException & /*e*/ )
921 sal_Bool b = sal_True;
922 Any aBool;
923 aBool.setValue( &b , getCppuBooleanType() );
924 pPS->setFastPropertyValue( 3, aBool );
925 OSL_FAIL( "PropertySetHelper: exeption not thrown" );
927 catch( UnknownPropertyException & /*e*/ )
931 // get unknown property
934 Any aBool;
935 aBool = xPS->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("Does not exist") ) );
936 OSL_FAIL( "PropertySetHelper: exeption not thrown" );
938 catch( UnknownPropertyException & /*e*/ )
944 Any aBool;
945 aBool = ((XFastPropertySet *)pPS)->getFastPropertyValue( 3 );
946 OSL_FAIL( "PropertySetHelper: exeption not thrown" );
948 catch( UnknownPropertyException & /*e*/ )
952 // set property with invalid type
955 Any aBool;
956 xPS->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("INT32") ), aBool );
957 OSL_FAIL( "PropertySetHelper: exeption not thrown" );
959 catch( IllegalArgumentException & /*e*/ )
965 Any aBool;
966 pPS->setFastPropertyValue( PROPERTY_INT32, aBool );
967 OSL_FAIL( "PropertySetHelper: exeption not thrown" );
969 catch( IllegalArgumentException & /*e*/ )
973 // narrowing conversion is not allowed!
976 Any aINT32;
977 aINT32 <<= (sal_Int32 ) 16;
978 xPS->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), aINT32 );
979 OSL_FAIL( "PropertySetHelper: exeption not thrown" );
981 catch( IllegalArgumentException & /*e*/ )
988 Any aINT32;
989 aINT32 <<= (sal_Int32) 16;
990 pPS->setFastPropertyValue( PROPERTY_INT16, aINT32 );
991 OSL_FAIL( "PropertySetHelper: exeption not thrown" );
993 catch( IllegalArgumentException & /*e*/ )
998 Any aValue;
999 aValue = xPS->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("BOOL") ) );
1000 sal_Bool b = *( (sal_Bool*)aValue.getValue());
1001 OSL_ENSURE( ! b, "PropertySetHelper: wrong BOOL value" );
1002 aValue = ((XFastPropertySet *)pPS)->getFastPropertyValue( PROPERTY_BOOL );
1004 b = *((sal_Bool*)aValue.getValue());
1005 OSL_ENSURE( !b, "PropertySetHelper: wrong BOOL value" );
1007 sal_Int16 n16(0);
1008 aValue <<=(sal_Int16)22;
1009 xPS->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), aValue );
1010 aValue = xPS->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ) );
1011 aValue >>= n16;
1012 OSL_ENSURE( 22 == n16 , "PropertySetHelper: wrong INT16 value" );
1013 aValue <<= (sal_Int16)44;
1014 ((XFastPropertySet *)pPS)->setFastPropertyValue( PROPERTY_INT16, aValue );
1016 aValue = ((XFastPropertySet *)pPS)->getFastPropertyValue( PROPERTY_INT16 );
1017 aValue >>= n16;
1018 OSL_ENSURE( 44 == n16, "PropertySetHelper: wrong INT16 value" );
1020 // widening conversion
1021 aValue <<= (sal_Int16)55;
1022 xPS->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("INT32") ), aValue );
1023 aValue = xPS->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("INT32") ) );
1024 sal_Int32 n32(0);
1025 aValue >>= n32;
1026 OSL_ENSURE( 55 == n32 , "PropertySetHelper: wrong INT32 value" );
1027 aValue <<= (sal_Int16)66;
1028 ((XFastPropertySet *)pPS)->setFastPropertyValue( PROPERTY_INT32, aValue );
1029 aValue = ((XFastPropertySet *)pPS)->getFastPropertyValue( PROPERTY_INT32 );
1030 aValue >>= n32;
1031 OSL_ENSURE( 66 == n32, "PropertySetHelper: wrong INT32 value" );
1033 Sequence< OUString >valueNames = Sequence<OUString>( 3 );
1034 valueNames.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM("BOOL") );
1035 valueNames.getArray()[1] = OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") );
1036 valueNames.getArray()[2] = OUString( RTL_CONSTASCII_USTRINGPARAM("INT32") );
1037 Sequence< Any > aValues = pPS->getPropertyValues( valueNames );
1039 b = *((sal_Bool*)aValues.getConstArray()[0].getValue());
1040 aValues.getConstArray()[1] >>= n16;
1041 aValues.getConstArray()[2] >>= n32;
1043 OSL_ENSURE( !b, "PropertySetHelper: wrong BOOL value" );
1044 OSL_ENSURE( 44 == n16, "PropertySetHelper: wrong INT16 value" );
1045 OSL_ENSURE( 66 == n32, "PropertySetHelper: wrong INT32 value" );
1047 pPS->nINT32 = 0;
1048 pPS->nINT16 = 0;
1050 // Test add-remove listener
1052 Reference < XVetoableChangeListener > x2( xPS_L, UNO_QUERY );
1054 xPS->addPropertyChangeListener( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), xPS_L );
1055 pPS->addVetoableChangeListener( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), x2 );
1057 pPS_L->nCount = 10;
1058 Sequence< Any > aSeq( pPS_L->nCount );
1059 pPS_L->nCurrent = 0;
1061 pPS_L->pExceptedListenerValues = aSeq.getArray();
1063 pPS_L->pExceptedListenerValues[0] <<= (sal_Int16) 0; // old value vetoable
1064 pPS_L->pExceptedListenerValues[1] <<= (sal_Int16) 22; // new value vetoable
1065 pPS_L->pExceptedListenerValues[2] <<= (sal_Int16) 0; // old value bound
1066 pPS_L->pExceptedListenerValues[3] <<= (sal_Int16) 22; // new value bound
1067 pPS_L->pExceptedListenerValues[4] <<= (sal_Int16) 22; // old value vetoable
1068 pPS_L->pExceptedListenerValues[5] <<= (sal_Int16) 44; // new value vetoable
1069 pPS_L->pExceptedListenerValues[6] <<= (sal_Int16) 22; // old value bound
1070 pPS_L->pExceptedListenerValues[7] <<= (sal_Int16) 44; // new value bound
1071 pPS_L->pExceptedListenerValues[8] <<= (sal_Int16) 44; // old value vetoable
1072 pPS_L->pExceptedListenerValues[9] <<= (sal_Int16) 100; // new value vetoable exception
1074 Any aValue;
1075 aValue <<= (sal_Int16)22;
1076 xPS->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), aValue );
1077 aValue <<= (sal_Int16) 44;
1078 ((XFastPropertySet *)pPS)->setFastPropertyValue( PROPERTY_INT16, aValue );
1079 aValue <<= (sal_Int16)100;// exception
1083 ((XFastPropertySet *)pPS)->setFastPropertyValue( PROPERTY_INT16, aValue );
1084 OSL_FAIL( "PropertySetHelper: exeption not thrown" );
1086 catch( PropertyVetoException & /*e*/ )
1090 OSL_ENSURE( pPS_L->nCount == pPS_L->nCurrent, "not all listeners called" );
1091 pPS->nINT32 = 0;
1092 pPS->nINT16 = 0;
1093 pPS_L->nCount = 0;
1094 pPS_L->nCurrent = 0;
1095 pPS_L->pExceptedListenerValues = NULL;
1096 xPS->removePropertyChangeListener( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), xPS_L );
1097 pPS->removeVetoableChangeListener( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), x2 );
1100 // Test multi property set listener
1102 Reference < XPropertiesChangeListener > x1( xPS_L, UNO_QUERY );
1103 Reference < XVetoableChangeListener > x2( xPS_L, UNO_QUERY );
1105 pPS->addVetoableChangeListener( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ) , x2 );
1106 Sequence<OUString> szPN( 4 );
1107 szPN.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM("BOOL") );
1108 szPN.getArray()[1] = OUString( RTL_CONSTASCII_USTRINGPARAM("INT32") );
1109 szPN.getArray()[2] = OUString( RTL_CONSTASCII_USTRINGPARAM("Does not exist") ); // must ne ignored by the addPropertiesChangeListener method
1110 szPN.getArray()[3] = OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") );
1111 pPS->addPropertiesChangeListener( szPN, x1 );
1113 pPS_L->nCount = 6;
1114 Sequence< Any > aSeq( pPS_L->nCount );
1115 pPS_L->nCurrent = 0;
1116 pPS_L->pExceptedListenerValues = aSeq.getArray();
1117 pPS_L->pExceptedListenerValues[0] <<= (sal_Int16) 0; // old value vetoable
1118 pPS_L->pExceptedListenerValues[1] <<= (sal_Int16 ) 22; // new value vetoable
1119 // INT32 is not constrained
1120 pPS_L->pExceptedListenerValues[2] <<= (sal_Int16) 0; // old value bound
1121 pPS_L->pExceptedListenerValues[3] <<= (sal_Int16) 22; // new value bound
1122 pPS_L->pExceptedListenerValues[4] <<= (sal_Int32) 0; // old value bound
1123 pPS_L->pExceptedListenerValues[5] <<= (sal_Int32) 44; // new value bound
1125 szPN = Sequence<OUString>( 2 );
1126 szPN.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") );
1127 szPN.getArray()[1] = OUString( RTL_CONSTASCII_USTRINGPARAM("INT32") );
1128 Sequence< Any > aValues( 2 );
1129 aValues.getArray()[0] <<= (sal_Int16) 22;
1130 aValues.getArray()[1] <<= (sal_Int16) 44;
1131 pPS->setPropertyValues( szPN, aValues );
1132 OSL_ENSURE( pPS_L->nCount == pPS_L->nCurrent, "not all listeners called" );
1134 //firePropertiesChangeEvent
1135 pPS->nINT16 = 8;
1136 pPS->nINT32 = 5;
1137 pPS_L->nCount = 4;
1138 pPS_L->nCurrent = 0;
1139 pPS_L->pExceptedListenerValues[0] <<= (sal_Int16) 8; // old value
1140 pPS_L->pExceptedListenerValues[1] <<= (sal_Int16) 8; // new value
1141 pPS_L->pExceptedListenerValues[2] <<= (sal_Int32) 5; // old value
1142 pPS_L->pExceptedListenerValues[3] <<= (sal_Int32) 5; // new value
1143 pPS->firePropertiesChangeEvent( szPN, pPS_L );
1144 OSL_ENSURE( pPS_L->nCount == pPS_L->nCurrent, "not all listeners called" );
1147 //vetoable exception with multible
1148 szPN.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") );
1149 szPN.getArray()[1] = OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") );
1150 pPS->nINT32 = 0;
1151 pPS->nINT16 = 0;
1152 pPS_L->nCount = 4;
1153 pPS_L->nCurrent = 0;
1154 pPS_L->pExceptedListenerValues[0] <<= (sal_Int16) 0; // old value vetoable
1155 pPS_L->pExceptedListenerValues[1] <<= (sal_Int16) 44; // new value vetoable
1156 pPS_L->pExceptedListenerValues[2] <<= (sal_Int16) 0; // old value vetoable
1157 pPS_L->pExceptedListenerValues[3] <<= (sal_Int16) 100; // new value vetoable
1161 aValues.getArray()[0] <<= (sal_Int16)44;
1162 aValues.getArray()[1] <<= (sal_Int16)100;
1163 pPS->setPropertyValues( szPN, aValues );
1164 OSL_FAIL( "PropertySetHelper: exeption not thrown" );
1166 catch ( PropertyVetoException & /*e*/ )
1170 OSL_ENSURE( pPS_L->nCount == pPS_L->nCurrent, "not all listeners called" );
1171 pPS->removePropertiesChangeListener( x1 );
1172 pPS->removeVetoableChangeListener( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), x2 );
1177 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */