1 /*
2  * This file is part of the LibreOffice project.
3  *
4  * This Source Code Form is subject to the terms of the Mozilla Public
5  * License, v. 2.0. If a copy of the MPL was not distributed with this
6  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7  *
8  * This file incorporates work covered by the following license notice:
9  *
10  *   Licensed to the Apache Software Foundation (ASF) under one or more
11  *   contributor license agreements. See the NOTICE file distributed
12  *   with this work for additional information regarding copyright
13  *   ownership. The ASF licenses this file to you under the Apache
14  *   License, Version 2.0 (the "License"); you may not use this file
15  *   except in compliance with the License. You may obtain a copy of
16  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
17  */
18 
19 package com.sun.star.lib.uno.helper;
20 
21 import com.sun.star.lang.EventObject;
22 import com.sun.star.lang.DisposedException;
23 import com.sun.star.uno.Type;
24 import com.sun.star.uno.TypeClass;
25 import com.sun.star.uno.XInterface;
26 import com.sun.star.uno.Any;
27 import com.sun.star.uno.XWeak;
28 import com.sun.star.beans.UnknownPropertyException;
29 import com.sun.star.beans.Property;
30 import com.sun.star.beans.PropertyAttribute;
31 import com.sun.star.beans.XPropertyChangeListener;
32 import com.sun.star.beans.PropertyVetoException;
33 import com.sun.star.beans.PropertyChangeEvent;
34 import com.sun.star.beans.XVetoableChangeListener;
35 import com.sun.star.beans.XPropertySetInfo;
36 import com.sun.star.beans.XPropertiesChangeListener;
37 
38 import java.util.logging.Level;
39 import java.util.logging.Logger;
40 
41 import static org.junit.Assert.assertEquals;
42 import static org.junit.Assert.assertNull;
43 import static org.junit.Assert.assertSame;
44 import static org.junit.Assert.assertTrue;
45 import static org.junit.Assert.fail;
46 import org.junit.Test;
47 
48 public class PropertySet_Test
49 {
50 
51     private static final Logger logger = Logger.getLogger(PropertySet_Test.class.getName());
52 
convertPropertyValue()53     @Test public void convertPropertyValue() throws Exception
54     {
55         logger.log(Level.INFO, "PropertySet.convertPropertyValue");
56         TestClass cl= new TestClass();
57         cl.test_convertPropertyValue();
58     }
59 
setPropertyValueNoBroadcast()60     @Test public void setPropertyValueNoBroadcast() throws Exception
61     {
62         logger.log(Level.INFO, "PropertySet.setValueNoBroadcast");
63         TestClass cl= new TestClass();
64         cl.test_setPropertyValueNoBroadcast();
65     }
66 
setPropertyValue()67     @Test public void setPropertyValue() throws Exception
68     {
69         logger.log(Level.INFO, "PropertySet.setPropertyValue");
70         TestClass cl= new TestClass();
71         cl.resetPropertyMembers();
72         Object value;
73         Object ret;
74 
75         value= Boolean.TRUE;
76         cl.setPropertyValue("PropBoolA", value);
77         assertEquals(cl.getPropertyValue("PropBoolA"), value);
78 
79         value= new Character('A');
80         cl.setPropertyValue("PropCharA",value);
81         assertEquals(cl.getPropertyValue("PropCharA"), value);
82 
83         value= Byte.valueOf((byte) 111);
84         cl.setPropertyValue("PropByteA",value);
85         assertEquals(cl.getPropertyValue("PropByteA"), value);
86 
87         value= Short.valueOf((short)112);
88         cl.setPropertyValue("PropShortA", value);
89         assertEquals(cl.getPropertyValue("PropShortA"), value);
90 
91         value= Integer.valueOf(113);
92         cl.setPropertyValue("PropIntA", value);
93         assertEquals(cl.getPropertyValue("PropIntA"), value);
94 
95         value= Long.valueOf(115);
96         cl.setPropertyValue("PropLongA", value);
97         assertEquals(cl.getPropertyValue("PropLongA"), value);
98 
99         value= new Float(3.14);
100         cl.setPropertyValue("PropFloatA", value);
101         assertEquals(cl.getPropertyValue("PropFloatA"), value);
102 
103         value= new Double(3.145);
104         cl.setPropertyValue("PropDoubleA",value);
105         assertEquals(cl.getPropertyValue("PropDoubleA"), value);
106 
107         value= "string";
108         cl.setPropertyValue("PropStringA",value);
109         assertEquals(cl.getPropertyValue("PropStringA"), value);
110 
111         value= new ComponentBase();
112         cl.setPropertyValue("PropXInterfaceA",value);
113         assertEquals(cl.getPropertyValue("PropXInterfaceA"), value);
114 
115         value= new ComponentBase();
116         cl.setPropertyValue("PropXWeakA",value);
117         assertEquals(cl.getPropertyValue("PropXWeakA"), value);
118 
119         value = com.sun.star.beans.PropertyState.AMBIGUOUS_VALUE;
120         cl.setPropertyValue("PropEnum",value);
121         assertSame(cl.getPropertyValue("PropEnum"), value);
122 
123         value= new byte[]{1,2,3};
124         cl.setPropertyValue("PropArrayByteA", value);
125         assertEquals(cl.getPropertyValue("PropArrayByteA"), value);
126 
127         value= new Type(String.class);
128         cl.setPropertyValue("PropTypeA", value);
129         assertEquals(cl.getPropertyValue("PropTypeA"), value);
130 
131         // test protected,package,private members
132         value= Boolean.TRUE;
133         cl.setPropertyValue("PropBoolB", value);
134         assertEquals(cl.getPropertyValue("PropBoolB"), value);
135 
136         cl.setPropertyValue("PropBoolC", value);
137         assertEquals(cl.getPropertyValue("PropBoolC"), value);
138 
139         try {
140             cl.setPropertyValue("PropBoolD", value);
141             fail("com.sun.star.lang.WrappedTargetException expected");
142         } catch(com.sun.star.lang.WrappedTargetException e) {
143             logger.log(Level.FINE, "com.sun.star.lang.WrappedTargetException caught");
144         }
145 
146         cl.resetPropertyMembers();
147 
148         value= Boolean.TRUE;
149         cl.setPropertyValue("PropObjectA", value);
150         assertEquals(cl.getPropertyValue("PropObjectA"), value);
151 
152         value= new Character('A');
153         cl.setPropertyValue("PropObjectA",value);
154         assertEquals(cl.getPropertyValue("PropObjectA"), value);
155 
156         value= Byte.valueOf((byte) 111);
157         cl.setPropertyValue("PropObjectA",value);
158         assertEquals(cl.getPropertyValue("PropObjectA"), value);
159 
160         value= Short.valueOf((short)112);
161         cl.setPropertyValue("PropObjectA", value);
162         assertEquals(cl.getPropertyValue("PropObjectA"), value);
163 
164         value= Integer.valueOf(113);
165         cl.setPropertyValue("PropObjectA", value);
166         assertEquals(cl.getPropertyValue("PropObjectA"), value);
167 
168         value= Long.valueOf(115);
169         cl.setPropertyValue("PropObjectA", value);
170         assertEquals(cl.getPropertyValue("PropObjectA"), value);
171 
172         value= new Float(3.14);
173         cl.setPropertyValue("PropObjectA", value);
174         assertEquals(cl.getPropertyValue("PropObjectA"), value);
175 
176         value= new Double(3.145);
177         cl.setPropertyValue("PropObjectA",value);
178         assertEquals(cl.getPropertyValue("PropObjectA"), value);
179 
180         value= "string";
181         cl.setPropertyValue("PropObjectA",value);
182         assertEquals(cl.getPropertyValue("PropObjectA"), value);
183 
184         value= new ComponentBase();
185         cl.setPropertyValue("PropObjectA",value);
186         assertEquals(cl.getPropertyValue("PropObjectA"), value);
187 
188         value= new ComponentBase();
189         cl.setPropertyValue("PropObjectA",value);
190         assertEquals(cl.getPropertyValue("PropObjectA"), value);
191 
192         value= new byte[]{1,2,3};
193         cl.setPropertyValue("PropObjectA", value);
194         assertEquals(cl.getPropertyValue("PropObjectA"), value);
195 
196         value= new Type(String.class);
197         cl.setPropertyValue("PropObjectA", value);
198         assertEquals(cl.getPropertyValue("PropObjectA"), value);
199 
200         cl.setPropertyValue("PropObjectA", new Any( new Type(byte.class), Byte.valueOf((byte)1)));
201         assertEquals(((Byte) cl.getPropertyValue("PropObjectA")).byteValue(), 1);
202 
203         cl.resetPropertyMembers();
204 
205         value= Boolean.TRUE;
206         cl.setPropertyValue("PropAnyA", value);
207         ret= cl.getPropertyValue("PropAnyA");
208         assertTrue(ret instanceof Any);
209         assertTrue(util.anyEquals(value, ret));
210 
211         value= new Character('A');
212         cl.setPropertyValue("PropAnyA",value);
213         ret= cl.getPropertyValue("PropAnyA");
214         assertTrue(ret instanceof Any);
215         assertTrue(util.anyEquals(value, ret));
216 
217         value= Byte.valueOf((byte) 111);
218         cl.setPropertyValue("PropAnyA",value);
219         ret= cl.getPropertyValue("PropAnyA");
220         assertTrue(ret instanceof Any);
221         assertTrue(util.anyEquals(value, ret));
222 
223         value= Short.valueOf((short)112);
224         cl.setPropertyValue("PropAnyA", value);
225         ret= cl.getPropertyValue("PropAnyA");
226         assertTrue(ret instanceof Any);
227         assertTrue(util.anyEquals(value, ret));
228 
229         value= Integer.valueOf(113);
230         cl.setPropertyValue("PropAnyA", value);
231         ret= cl.getPropertyValue("PropAnyA");
232         assertTrue(ret instanceof Any);
233         assertTrue(util.anyEquals(value, ret));
234 
235         value= Long.valueOf(115);
236         cl.setPropertyValue("PropAnyA", value);
237         ret= cl.getPropertyValue("PropAnyA");
238         assertTrue(ret instanceof Any);
239         assertTrue(util.anyEquals(value, ret));
240 
241         value= new Float(3.14);
242         cl.setPropertyValue("PropAnyA", value);
243         ret= cl.getPropertyValue("PropAnyA");
244         assertTrue(ret instanceof Any);
245         assertTrue(util.anyEquals(value, ret));
246 
247         value= new Double(3.145);
248         cl.setPropertyValue("PropAnyA",value);
249         ret= cl.getPropertyValue("PropAnyA");
250         assertTrue(ret instanceof Any);
251         assertTrue(util.anyEquals(value, ret));
252 
253         value= "string";
254         cl.setPropertyValue("PropAnyA",value);
255         ret= cl.getPropertyValue("PropAnyA");
256         assertTrue(ret instanceof Any);
257         assertTrue(util.anyEquals(value, ret));
258 
259         value= new ComponentBase();
260         cl.setPropertyValue("PropAnyA",value);
261         ret= cl.getPropertyValue("PropAnyA");
262         assertTrue(ret instanceof Any);
263         assertTrue(util.anyEquals(value, ret));
264 
265         value= new ComponentBase();
266         cl.setPropertyValue("PropAnyA",value);
267         ret= cl.getPropertyValue("PropAnyA");
268         assertTrue(ret instanceof Any);
269         assertTrue(util.anyEquals(value, ret));
270 
271         value= new byte[]{1,2,3};
272         cl.setPropertyValue("PropAnyA", value);
273         ret= cl.getPropertyValue("PropAnyA");
274         assertTrue(ret instanceof Any);
275         assertTrue(util.anyEquals(value, ret));
276 
277         value= new Type(String.class);
278         cl.setPropertyValue("PropAnyA", value);
279         ret= cl.getPropertyValue("PropAnyA");
280         assertTrue(ret instanceof Any);
281         assertTrue(util.anyEquals(value, ret));
282 
283         cl.resetPropertyMembers();
284 
285         value= new Any(new Type(boolean.class), Boolean.TRUE);
286         cl.setPropertyValue("PropBoolA", value);
287         ret= cl.getPropertyValue("PropBoolA");
288         assertTrue(ret instanceof Boolean);
289         assertTrue(util.anyEquals(value, ret));
290 
291         value= new Any (new Type(char.class), new Character('A'));
292         cl.setPropertyValue("PropCharA",value);
293         ret= cl.getPropertyValue("PropCharA");
294         assertTrue(ret instanceof Character);
295         assertTrue(util.anyEquals(value, ret));
296 
297         value= new Any(new Type(byte.class), Byte.valueOf((byte) 111));
298         cl.setPropertyValue("PropByteA",value);
299         ret= cl.getPropertyValue("PropByteA");
300         assertTrue(ret instanceof Byte);
301         assertTrue(util.anyEquals(value, ret));
302 
303         value= new Any(new Type(short.class), Short.valueOf((short)112));
304         cl.setPropertyValue("PropShortA", value);
305         ret= cl.getPropertyValue("PropShortA");
306         assertTrue(ret instanceof Short);
307         assertTrue(util.anyEquals(value, ret));
308 
309         value= new Any(new Type(int.class), Integer.valueOf(113));
310         cl.setPropertyValue("PropIntA", value);
311         ret= cl.getPropertyValue("PropIntA");
312         assertTrue(ret instanceof Integer);
313         assertTrue(util.anyEquals(value, ret));
314 
315         value= new Any(new  Type(long.class), Long.valueOf(115));
316         cl.setPropertyValue("PropLongA", value);
317         ret= cl.getPropertyValue("PropLongA");
318         assertTrue(ret instanceof Long);
319         assertTrue(util.anyEquals(value, ret));
320 
321         value= new Any(new Type(float.class), new Float(3.14));
322         cl.setPropertyValue("PropFloatA", value);
323         ret= cl.getPropertyValue("PropFloatA");
324         assertTrue(ret instanceof Float);
325         assertTrue(util.anyEquals(value, ret));
326 
327         value= new Any(new Type(double.class),new Double(3.145));
328         cl.setPropertyValue("PropDoubleA",value);
329         ret= cl.getPropertyValue("PropDoubleA");
330         assertTrue(ret instanceof Double);
331         assertTrue(util.anyEquals(value, ret));
332 
333         value= new Any(new Type(String.class), "string");
334         cl.setPropertyValue("PropStringA",value);
335         ret= cl.getPropertyValue("PropStringA");
336         assertTrue(ret instanceof String);
337         assertTrue(util.anyEquals(value, ret));
338 
339         value= new Any(new Type(ComponentBase.class), new ComponentBase());
340         cl.setPropertyValue("PropXInterfaceA",value);
341         ret= cl.getPropertyValue("PropXInterfaceA");
342         assertTrue(ret instanceof ComponentBase);
343         assertTrue(util.anyEquals(value, ret));
344 
345         value= new Any( new Type(ComponentBase.class), new ComponentBase());
346         cl.setPropertyValue("PropXWeakA",value);
347         ret= cl.getPropertyValue("PropXWeakA");
348         assertTrue(ret instanceof ComponentBase);
349         assertTrue(util.anyEquals(value, ret));
350 
351         value= new Any(new Type(byte[].class), new byte[]{1,2,3});
352         cl.setPropertyValue("PropArrayByteA", value);
353         ret= cl.getPropertyValue("PropArrayByteA");
354         assertTrue(ret instanceof byte[]);
355         assertTrue(util.anyEquals(value, ret));
356 
357         value= new Any(new Type(Type.class), new Type(String.class));
358         cl.setPropertyValue("PropTypeA", value);
359         ret= cl.getPropertyValue("PropTypeA");
360         assertTrue(ret instanceof Type);
361         assertTrue(util.anyEquals(value, ret));
362 
363         cl.resetPropertyMembers();
364 
365         value= new Any(new Type(boolean.class), Boolean.TRUE);
366         cl.setPropertyValue("PropAnyA", value);
367         ret= cl.getPropertyValue("PropAnyA");
368         assertTrue(ret instanceof Any);
369         assertTrue(util.anyEquals(value, ret));
370 
371         value= new Any (new Type(char.class), new Character('A'));
372         cl.setPropertyValue("PropAnyA",value);
373         ret= cl.getPropertyValue("PropAnyA");
374         assertTrue(ret instanceof Any);
375         assertTrue(util.anyEquals(value, ret));
376 
377         value= new Any(new Type(byte.class), Byte.valueOf((byte) 111));
378         cl.setPropertyValue("PropAnyA",value);
379         ret= cl.getPropertyValue("PropAnyA");
380         assertTrue(ret instanceof Any);
381         assertTrue(util.anyEquals(value, ret));
382 
383         value= new Any(new Type(short.class), Short.valueOf((short)112));
384         cl.setPropertyValue("PropAnyA", value);
385         ret= cl.getPropertyValue("PropAnyA");
386         assertTrue(ret instanceof Any);
387         assertTrue(util.anyEquals(value, ret));
388 
389         value= new Any(new Type(int.class), Integer.valueOf(113));
390         cl.setPropertyValue("PropAnyA", value);
391         ret= cl.getPropertyValue("PropAnyA");
392         assertTrue(ret instanceof Any);
393         assertTrue(util.anyEquals(value, ret));
394 
395         value= new Any(new  Type(long.class), Long.valueOf(115));
396         cl.setPropertyValue("PropAnyA", value);
397         ret= cl.getPropertyValue("PropAnyA");
398         assertTrue(ret instanceof Any);
399         assertTrue(util.anyEquals(value, ret));
400 
401         value= new Any(new Type(float.class), new Float(3.14));
402         cl.setPropertyValue("PropAnyA", value);
403         ret= cl.getPropertyValue("PropAnyA");
404         assertTrue(ret instanceof Any);
405         assertTrue(util.anyEquals(value, ret));
406 
407         value= new Any(new Type(double.class),new Double(3.145));
408         cl.setPropertyValue("PropAnyA",value);
409         ret= cl.getPropertyValue("PropAnyA");
410         assertTrue(ret instanceof Any);
411         assertTrue(util.anyEquals(value, ret));
412 
413         value= new Any(new Type(String.class), "string");
414         cl.setPropertyValue("PropAnyA",value);
415         ret= cl.getPropertyValue("PropAnyA");
416         assertTrue(ret instanceof Any);
417         assertTrue(util.anyEquals(value, ret));
418 
419         value= new Any(new Type(ComponentBase.class), new ComponentBase());
420         cl.setPropertyValue("PropAnyA",value);
421         ret= cl.getPropertyValue("PropAnyA");
422         assertTrue(ret instanceof Any);
423         assertTrue(util.anyEquals(value, ret));
424 
425         value= new Any( new Type(ComponentBase.class), new ComponentBase());
426         cl.setPropertyValue("PropAnyA",value);
427         ret= cl.getPropertyValue("PropAnyA");
428         assertTrue(ret instanceof Any);
429         assertTrue(util.anyEquals(value, ret));
430 
431         value= new Any(new Type(byte[].class), new byte[]{1,2,3});
432         cl.setPropertyValue("PropAnyA", value);
433         ret= cl.getPropertyValue("PropAnyA");
434         assertTrue(ret instanceof Any);
435         assertTrue(util.anyEquals(value, ret));
436 
437         value= new Any(new Type(Type.class), new Type(String.class));
438         cl.setPropertyValue("PropAnyA", value);
439         ret= cl.getPropertyValue("PropAnyA");
440         assertTrue(ret instanceof Any);
441         assertTrue(util.anyEquals(value, ret));
442 
443         cl.resetPropertyMembers();
444 
445         value= Boolean.TRUE;
446         cl.setPropertyValue("PropBoolClass", value);
447         assertEquals(cl.getPropertyValue("PropBoolClass"), value);
448 
449         value= new Character('A');
450         cl.setPropertyValue("PropCharClass",value);
451         assertEquals(cl.getPropertyValue("PropCharClass"), value);
452 
453         value= Byte.valueOf((byte) 111);
454         cl.setPropertyValue("PropByteClass",value);
455         assertEquals(cl.getPropertyValue("PropByteClass"), value);
456 
457         value= Short.valueOf((short)112);
458         cl.setPropertyValue("PropShortClass", value);
459         assertEquals(cl.getPropertyValue("PropShortClass"), value);
460 
461         value= Integer.valueOf(113);
462         cl.setPropertyValue("PropIntClass", value);
463         assertEquals(cl.getPropertyValue("PropIntClass"), value);
464 
465         value= Long.valueOf(115);
466         cl.setPropertyValue("PropLongClass", value);
467         assertEquals(cl.getPropertyValue("PropLongClass"), value);
468 
469         value= new Float(3.14);
470         cl.setPropertyValue("PropFloatClass", value);
471         assertEquals(cl.getPropertyValue("PropFloatClass"), value);
472 
473         value= new Double(3.145);
474         cl.setPropertyValue("PropDoubleClass",value);
475         assertEquals(cl.getPropertyValue("PropDoubleClass"), value);
476 
477         cl.resetPropertyMembers();
478 
479         cl.resetPropertyMembers();
480 
481         value= new Any(new Type(boolean.class), Boolean.TRUE);
482         cl.setPropertyValue("PropBoolClass", value);
483         ret= cl.getPropertyValue("PropBoolClass");
484         assertTrue(ret instanceof Boolean);
485         assertTrue(util.anyEquals(value, ret));
486 
487         value= new Any (new Type(char.class), new Character('A'));
488         cl.setPropertyValue("PropCharClass",value);
489         ret= cl.getPropertyValue("PropCharClass");
490         assertTrue(ret instanceof Character);
491         assertTrue(util.anyEquals(value, ret));
492 
493         value= new Any(new Type(byte.class), Byte.valueOf((byte) 111));
494         cl.setPropertyValue("PropByteClass",value);
495         ret= cl.getPropertyValue("PropByteClass");
496         assertTrue(ret instanceof Byte);
497         assertTrue(util.anyEquals(value, ret));
498 
499         value= new Any(new Type(short.class), Short.valueOf((short)112));
500         cl.setPropertyValue("PropShortClass", value);
501         ret= cl.getPropertyValue("PropShortClass");
502         assertTrue(ret instanceof Short);
503         assertTrue(util.anyEquals(value, ret));
504 
505         value= new Any(new Type(int.class), Integer.valueOf(113));
506         cl.setPropertyValue("PropIntClass", value);
507         ret= cl.getPropertyValue("PropIntClass");
508         assertTrue(ret instanceof Integer);
509         assertTrue(util.anyEquals(value, ret));
510 
511         value= new Any(new  Type(long.class), Long.valueOf(115));
512         cl.setPropertyValue("PropLongClass", value);
513         ret= cl.getPropertyValue("PropLongClass");
514         assertTrue(ret instanceof Long);
515         assertTrue(util.anyEquals(value, ret));
516 
517         value= new Any(new Type(float.class), new Float(3.14));
518         cl.setPropertyValue("PropFloatClass", value);
519         ret= cl.getPropertyValue("PropFloatClass");
520         assertTrue(ret instanceof Float);
521         assertTrue(util.anyEquals(value, ret));
522 
523         value= new Any(new Type(double.class),new Double(3.145));
524         cl.setPropertyValue("PropDoubleClass",value);
525         ret= cl.getPropertyValue("PropDoubleClass");
526         assertTrue(ret instanceof Double);
527         assertTrue(util.anyEquals(value, ret));
528 
529         value= new Any(new Type(String.class), "string");
530 
531         // PropertyAttribute.READONLY
532         cl.propBoolA.Attributes= PropertyAttribute.READONLY;
533         try {
534             cl.setPropertyValue("PropBoolA", Boolean.TRUE);
535             fail("com.sun.star.beans.PropertyVetoException expected");
536         } catch (com.sun.star.beans.PropertyVetoException e) {
537             logger.log(Level.FINE, "com.sun.star.beans.PropertyVetoException caught");
538         }
539         cl.propBoolA.Attributes= 0;
540 
541         // MAYBEVOID
542         cl.resetPropertyMembers();
543         // first MAYBEVOID not set
544 
545         //primitive members: must not work
546 
547         cl.boolPropA= false;
548         try {
549             cl.setPropertyValue("PropBoolA", null);
550             fail("com.sun.star.lang.IllegalArgumentException expected");
551         } catch (com.sun.star.lang.IllegalArgumentException e) {
552             logger.log(Level.FINE, "com.sun.star.lang.IllegalArgumentException caught");
553         }
554 
555         try {
556             cl.setPropertyValue("PropBoolA", new Any(new Type(boolean.class), null));
557             fail("com.sun.star.lang.IllegalArgumentException expected");
558         } catch (com.sun.star.lang.IllegalArgumentException e) {
559             logger.log(Level.FINE, "com.sun.star.lang.IllegalArgumentException caught");
560         }
561 
562         cl.propBoolA.Attributes= PropertyAttribute.MAYBEVOID;
563         try {
564             cl.setPropertyValue("PropBoolA", null);
565             fail("com.sun.star.lang.IllegalArgumentException expected");
566         } catch (com.sun.star.lang.IllegalArgumentException e) {
567             logger.log(Level.FINE, "com.sun.star.lang.IllegalArgumentException caught");
568         }
569 
570         cl.propBoolA.Attributes= 0;
571 
572         cl.propBoolClass.Attributes= PropertyAttribute.MAYBEVOID;
573         cl.boolClassProp= null;
574         cl.setPropertyValue("PropBoolClass", null);
575         assertNull(cl.boolClassProp);
576 
577         // the returned value must be a void any
578         Object objAny= cl.getPropertyValue("PropBoolClass");
579         assertTrue(util.isVoidAny( objAny));
580 
581         cl.boolClassProp= Boolean.TRUE;
582         cl.setPropertyValue("PropBoolClass", null);
583         assertNull(cl.boolClassProp);
584 
585         cl.boolClassProp= Boolean.FALSE;
586         cl.setPropertyValue("PropBoolClass", new Any(new Type(boolean.class),null));
587         assertNull(cl.boolClassProp);
588 
589         cl.propXWeakA.Attributes= PropertyAttribute.MAYBEVOID;
590         cl.setPropertyValue("PropXWeakA", null);
591         assertTrue(util.isVoidAny(cl.getPropertyValue("PropXWeakA")));
592 
593         cl.propXWeakA.Attributes= 0;
594 
595         cl.anyPropA= null;
596         try {
597             cl.setPropertyValue("PropAnyA", null);
598             fail("com.sun.star.lang.IllegalArgumentException expected");
599         } catch (com.sun.star.lang.IllegalArgumentException e) {
600             logger.log(Level.FINE, "com.sun.star.lang.IllegalArgumentException caught");
601         }
602         cl.anyPropA= null;
603         cl.propAnyA.Attributes= PropertyAttribute.MAYBEVOID;
604 
605         new Type(Object.class);
606         cl.setPropertyValue("PropAnyA", null);
607         assertEquals(cl.anyPropA.getType(), new Type(void.class));
608         assertNull(cl.anyPropA.getObject());
609 
610         cl.anyPropA= new Any(new Type(byte.class),Byte.valueOf((byte) 111));
611         cl.setPropertyValue("PropAnyA", null);
612         assertEquals(cl.anyPropA.getType(), new Type(byte.class));
613         assertNull(cl.anyPropA.getObject());
614 
615         cl.anyPropA= null;
616         try {
617             cl.setPropertyValue("PropAnyA", new Object());
618             fail("com.sun.star.lang.IllegalArgumentException expected");
619         }catch (com.sun.star.lang.IllegalArgumentException e) {
620             logger.log(Level.FINE, "com.sun.star.lang.IllegalArgumentException caught");
621         }
622 
623         cl.propObjectA.Attributes= 0;
624         try {
625             cl.setPropertyValue("PropObjectA", null);
626             fail("com.sun.star.lang.IllegalArgumentException expected");
627         } catch (com.sun.star.lang.IllegalArgumentException e) {
628             logger.log(Level.FINE, "com.sun.star.lang.IllegalArgumentException caught");
629         }
630 
631         try {
632             cl.setPropertyValue("PropObjectA", new Any( new Type(byte.class), null));
633             fail("com.sun.star.lang.IllegalArgumentException expected");
634         } catch (com.sun.star.lang.IllegalArgumentException e) {
635             logger.log(Level.FINE, "com.sun.star.lang.IllegalArgumentException caught");
636         }
637 
638         cl.propObjectA.Attributes= PropertyAttribute.MAYBEVOID;
639         cl.propObjectA= null;
640         cl.setPropertyValue("PropObjectA", null);
641         assertNull(cl.propObjectA);
642 
643         cl.propObjectA= null;
644         cl.setPropertyValue("PropObjectA", new Any( new Type(byte.class), null));
645         assertNull(cl.propObjectA);
646     }
647 
addPropertyChangeListener()648     @Test public void addPropertyChangeListener() throws Exception
649     {
650         logger.log(Level.INFO, "PropertySet.addPropertyChangeListener,\n" +
651                                "PropertySet.removePropertChangeListener," +
652                                "PropertySet.addVetoableChangeListener, \n" +
653                                "PropertySet.removeVetoableChangeListener" +
654                                "Notification of listeners");
655         TestClass cl= new TestClass();
656         Listener li= new Listener();
657 
658         cl.addPropertyChangeListener("PropByteA", li);
659         Byte val1= Byte.valueOf((byte)115);
660         cl.setPropertyValue("PropByteA", val1);
661         assertEquals(li.nChangeCalled, 0);
662         assertEquals(li.nVetoCalled, 0);
663 
664         cl.propByteA.Attributes = PropertyAttribute.BOUND;
665         cl.addPropertyChangeListener("PropByteA", li);
666         Byte val2= Byte.valueOf((byte)116);
667         cl.setPropertyValue("PropByteA", val2);
668         assertEquals(li.nChangeCalled, 1);
669         assertEquals(li.nVetoCalled, 0);
670         assertEquals(li.evt.OldValue, val1);
671         assertEquals(li.evt.NewValue, val2);
672         assertSame(li.evt.Source, cl);
673 
674         li.reset();
675         Listener li2= new Listener();
676         cl.addPropertyChangeListener("PropByteA", li2);
677         Byte val3= Byte.valueOf((byte) 117);
678         cl.setPropertyValue("PropByteA", val3);
679         assertEquals(li.nChangeCalled, 1);
680         assertEquals(li.nVetoCalled, 0);
681         assertEquals(li2.nChangeCalled, 1);
682         assertEquals(li2.nVetoCalled, 0);
683         assertEquals(li.evt.OldValue, val2);
684         assertEquals(li.evt.NewValue,val3);
685         assertSame(li.evt.Source, cl);
686         assertEquals(li2.evt.OldValue, val2);
687         assertEquals(li2.evt.NewValue, val3);
688         assertSame(li2.evt.Source, cl);
689 
690         li.reset();
691         li2.reset();
692         Listener li3= new Listener();
693         val1= Byte.valueOf((byte)118);
694         cl.addPropertyChangeListener("", li3);
695         cl.setPropertyValue("PropByteA", val1);
696         assertEquals(li.nChangeCalled, 1);
697         assertEquals(li.nVetoCalled, 0);
698         assertEquals(li2.nChangeCalled, 1);
699         assertEquals(li2.nVetoCalled, 0);
700         assertEquals(li3.nChangeCalled, 1);
701         assertEquals(li3.nVetoCalled, 0);
702         assertEquals(li.evt.OldValue, val3);
703         assertEquals(li.evt.NewValue, val1);
704         assertSame(li.evt.Source, cl);
705         assertEquals(li2.evt.OldValue, val3);
706         assertEquals(li2.evt.NewValue, val1);
707         assertSame(li2.evt.Source, cl);
708         assertEquals(li3.evt.OldValue, val3);
709         assertEquals(li3.evt.NewValue, val1);
710         assertSame(li3.evt.Source, cl);
711 
712         li.reset();
713         li2.reset();
714         li3.reset();
715         cl.removePropertyChangeListener("PropByteA",li);
716         cl.setPropertyValue("PropByteA", val1);
717         assertEquals(li.nChangeCalled, 0);
718         assertEquals(li.nVetoCalled, 0);
719         assertEquals(li2.nChangeCalled, 1);
720         assertEquals(li2.nVetoCalled, 0);
721         assertEquals(li3.nChangeCalled, 1);
722         assertEquals(li3.nVetoCalled, 0);
723 
724         cl.removePropertyChangeListener("PropByteA", li2);
725         li.reset();
726         li2.reset();
727         li3.reset();
728         cl.setPropertyValue("PropByteA", val1);
729         assertEquals(li.nChangeCalled, 0);
730         assertEquals(li.nVetoCalled, 0);
731         assertEquals(li2.nChangeCalled, 0);
732         assertEquals(li2.nVetoCalled, 0);
733         assertEquals(li3.nChangeCalled, 1);
734         assertEquals(li3.nVetoCalled, 0);
735 
736         cl.removePropertyChangeListener("", li3);
737         li.reset();
738         li2.reset();
739         li3.reset();
740         cl.setPropertyValue("PropByteA", val2);
741         assertEquals(li.nChangeCalled, 0);
742         assertEquals(li.nVetoCalled, 0);
743         assertEquals(li2.nChangeCalled, 0);
744         assertEquals(li2.nVetoCalled, 0);
745         assertEquals(li3.nChangeCalled, 0);
746         assertEquals(li3.nVetoCalled, 0);
747 
748         cl.addPropertyChangeListener("PropByteA", li);
749         cl.addPropertyChangeListener("PropByteA", li2);
750         cl.addPropertyChangeListener("", li3);
751         cl.dispose();
752         li.reset();
753         li2.reset();
754         li3.reset();
755         try {
756             cl.setPropertyValue("PropByteA", val2);
757             fail("DisposedException expected");
758         } catch (DisposedException e) {
759             logger.log(Level.FINE, "DisposedException caught");
760         }
761 
762         //Vetoable tests
763         cl= new TestClass();
764         li.reset();
765         li2.reset();
766         li3.reset();
767         cl.addVetoableChangeListener("PropByteA", li);
768         val1= Byte.valueOf((byte)115);
769         cl.setPropertyValue("PropByteA", val1);
770         assertEquals(li.nChangeCalled,  0);
771         assertEquals(li.nVetoCalled, 0);
772 
773         cl.propByteA.Attributes = PropertyAttribute.CONSTRAINED;
774         cl.addVetoableChangeListener("PropByteA", li);
775         val2= Byte.valueOf((byte)116);
776         li.reset();
777         cl.setPropertyValue("PropByteA", val2);
778         assertEquals(li.nChangeCalled, 0);
779         assertEquals(li.nVetoCalled, 1);
780         assertEquals(li.evt.OldValue, val1);
781         assertEquals(li.evt.NewValue, val2);
782         assertSame(li.evt.Source, cl);
783 
784         li.reset();
785         li2.reset();
786         li3.reset();
787         cl.addVetoableChangeListener("PropByteA", li2);
788         val3= Byte.valueOf((byte) 117);
789         cl.setPropertyValue("PropByteA", val3);
790         assertEquals(li.nChangeCalled, 0);
791         assertEquals(li.nVetoCalled, 1);
792         assertEquals(li2.nChangeCalled, 0);
793         assertEquals(li2.nVetoCalled, 1);
794         assertEquals(li.evt.OldValue, val2);
795         assertEquals(li.evt.NewValue, val3);
796         assertSame(li.evt.Source, cl);
797         assertEquals(li2.evt.OldValue, val2);
798         assertEquals(li2.evt.NewValue, val3);
799         assertSame(li2.evt.Source, cl);
800 
801         li.reset();
802         li2.reset();
803         li3.reset();
804         val1= Byte.valueOf((byte)118);
805         cl.addVetoableChangeListener("", li3);
806         cl.setPropertyValue("PropByteA", val1);
807         assertEquals(li.nChangeCalled, 0);
808         assertEquals(li.nVetoCalled, 1);
809         assertEquals(li2.nChangeCalled, 0);
810         assertEquals(li2.nVetoCalled, 1);
811         assertEquals(li3.nChangeCalled, 0);
812         assertEquals(li3.nVetoCalled, 1);
813         assertEquals(li.evt.OldValue, val3);
814         assertEquals(li.evt.NewValue, val1);
815         assertSame(li.evt.Source, cl);
816         assertEquals(li2.evt.OldValue, val3);
817         assertEquals(li2.evt.NewValue, val1);
818         assertSame(li2.evt.Source, cl);
819         assertEquals(li3.evt.OldValue, val3);
820         assertEquals(li3.evt.NewValue, val1);
821         assertSame(li3.evt.Source, cl);
822 
823         li.reset();
824         li2.reset();
825         li3.reset();
826         // Test Veto Exception
827         cl.setPropertyValue("PropByteA", val1);
828         li.bVeto= true;
829         try {
830             cl.setPropertyValue("PropByteA", val2);
831             fail("PropertyVetoException expected");
832         } catch (PropertyVetoException e) {
833             logger.log(Level.FINE, "PropertyVetoException caught");
834         }
835         assertSame(cl.bytePropA, val1.byteValue());
836         li.bVeto= false;
837 
838         li.reset();
839         li2.reset();
840         li3.reset();
841         cl.removeVetoableChangeListener("PropByteA",li);
842         cl.setPropertyValue("PropByteA", val1);
843         assertEquals(li.nChangeCalled, 0);
844         assertEquals(li.nVetoCalled, 0);
845         assertEquals(li2.nChangeCalled, 0);
846         assertEquals(li2.nVetoCalled, 1);
847         assertEquals(li3.nChangeCalled, 0);
848         assertEquals(li3.nVetoCalled, 1);
849 
850         cl.removeVetoableChangeListener("PropByteA", li2);
851         li.reset();
852         li2.reset();
853         li3.reset();
854         cl.setPropertyValue("PropByteA", val1);
855         assertEquals(li.nChangeCalled, 0);
856         assertEquals(li.nVetoCalled, 0);
857         assertEquals(li2.nChangeCalled, 0);
858         assertEquals(li2.nVetoCalled, 0);
859         assertEquals(li3.nChangeCalled, 0);
860         assertEquals(li3.nVetoCalled, 1);
861 
862         cl.removeVetoableChangeListener("", li3);
863         li.reset();
864         li2.reset();
865         li3.reset();
866         cl.setPropertyValue("PropByteA", val2);
867         assertEquals(li.nChangeCalled, 0);
868         assertEquals(li.nVetoCalled, 0);
869         assertEquals(li2.nChangeCalled, 0);
870         assertEquals(li2.nVetoCalled, 0);
871         assertEquals(li3.nChangeCalled, 0);
872         assertEquals(li3.nVetoCalled, 0);
873 
874         cl.addVetoableChangeListener("PropByteA", li);
875         cl.addVetoableChangeListener("PropByteA", li2);
876         cl.addVetoableChangeListener("", li3);
877         cl.dispose();
878         li.reset();
879         li2.reset();
880         li3.reset();
881         try {
882             cl.setPropertyValue("PropByteA", val2);
883             fail("DisposedException expected");
884         } catch (DisposedException e) {
885             logger.log(Level.FINE, "DisposedException caught");
886         }
887     }
888 
getPropertySetInfo()889     @Test public void getPropertySetInfo() throws Exception
890     {
891         logger.log(Level.INFO, "PropertySet.getPropertySetInfo");
892         TestClass cl= new TestClass();
893         XPropertySetInfo info= cl.getPropertySetInfo();
894         Property[] arProps= info.getProperties();
895         Property[] arRegProps= cl.getRegisteredProperties();
896         assertEquals(arProps.length, arRegProps.length);
897 
898         for (int j= 0; j < arProps.length; j++)
899         {
900             boolean bFound= false;
901             for (int k= 0; k < arRegProps.length; k++)
902             {
903                 if (arProps[j] == arRegProps[k])
904                 {
905                     bFound= true;
906                     break;
907                 }
908             }
909             assertTrue(bFound);
910         }
911 
912         for (int j= 0; j < arRegProps.length; j++)
913         {
914             Property prop= info.getPropertyByName(arRegProps[j].Name);
915             assertSame(prop, arRegProps[j]);
916             assertTrue(info.hasPropertyByName(arRegProps[j].Name));
917         }
918     }
919 
setFastPropertyValue()920     @Test public void setFastPropertyValue() throws Exception
921     {
922         logger.log(Level.INFO, "PropertySet.setFastPropertyValue");
923         TestClass cl= new TestClass();
924         cl.setFastPropertyValue(5, Integer.valueOf(111));
925         assertEquals(cl.intPropA,111);
926         try {
927             cl.setFastPropertyValue(-1, Integer.valueOf(1));
928             fail("UnknownPropertyException expected");
929         } catch(UnknownPropertyException e) {
930             logger.log(Level.FINE, "UnknownPropertyException caught");
931         }
932     }
933 
getFastPropertyValue()934     @Test public void getFastPropertyValue() throws Exception
935     {
936         logger.log(Level.INFO, "PropertySet.setFastPropertyValue");
937         TestClass cl= new TestClass();
938         cl.setFastPropertyValue(5, Integer.valueOf(111));
939         Integer aInt= (Integer) cl.getFastPropertyValue(5);
940         assertEquals(aInt.intValue(), 111);
941     }
942 
setPropertyValues()943     @Test public void setPropertyValues() throws Exception
944     {
945         logger.log(Level.INFO, "PropertySet.setPropertyValues");
946         TestClass cl= new TestClass();
947         cl.setPropertyValues(new String[0], new Object[0]);
948         String[] arNames= new String[] {"PropCharA","PropIntClass","PropObjectA"};
949         Character aChar= new Character('A');
950         Integer aInt= Integer.valueOf(111);
951         Byte aByte= Byte.valueOf((byte)11);
952         Object[] values= new Object[]{aChar, aInt, aByte};
953         cl.setPropertyValues(arNames, values);
954         assertEquals(cl.charPropA, 'A');
955         assertEquals(cl.intClassProp.intValue(), 111);
956         assertEquals(((Byte)cl.objectPropA).byteValue(), 11);
957 
958         arNames= new String[] {"blabla","PropIntClass","PropObjectA"};
959         cl.resetPropertyMembers();
960         cl.setPropertyValues(arNames, values);
961         assertEquals(cl.intClassProp.intValue(), 111);
962         assertEquals(((Byte)cl.objectPropA).byteValue(), 11);
963     }
964 
getPropertyValues()965     @Test public void getPropertyValues() throws Exception
966     {
967         logger.log(Level.INFO, "PropertySet.getPropertyValues");
968         TestClass cl= new TestClass();
969         cl.charPropA= 'A';
970         cl.intClassProp= Integer.valueOf(111);
971         cl.objectPropA= Byte.valueOf((byte)11);
972         Object[] values= cl.getPropertyValues(new String[] {"PropCharA","PropIntClass","PropObjectA"});
973         assertEquals(((Character) values[0]).charValue(), 'A');
974         assertEquals(((Integer) values[1]).intValue(), 111);
975         assertEquals(((Byte) values[2]).byteValue(), 11);
976     }
977 
978     // Currently the listeners are always notified if one of properties has changed.
979     // The property names in the first argument are ignored.
addPropertiesChangeListener()980     @Test public void addPropertiesChangeListener() throws Exception
981     {
982         logger.log(Level.INFO, "PropertySet.addPropertiesChangeListener\n" +
983                                "PropertySet.removePropertiesChangeListener\n" +
984                                "notification of such listeners");
985         TestClass cl= new TestClass();
986         Listener li1= new Listener();
987 
988         cl.addPropertiesChangeListener(new String[]{"PropCharA"}, li1);
989         cl.setPropertyValue("PropCharA", new Character('B'));
990         assertEquals(li1.nPropertiesChange, 0);
991 
992         cl.propCharA.Attributes= PropertyAttribute.BOUND;
993         cl.setPropertyValue("PropCharA", new Character('C'));
994         assertEquals(li1.nPropertiesChange, 1);
995 
996         PropertyChangeEvent evt= li1.arEvt[0];
997         assertEquals(evt.PropertyName, "PropCharA");
998         assertEquals(((Character)evt.OldValue).charValue(), 'B');
999         assertEquals(((Character) evt.NewValue).charValue(), 'C');
1000 
1001         li1.reset();
1002         cl.removePropertiesChangeListener(li1);
1003         cl.setPropertyValue("PropCharA", new Character('F'));
1004         assertEquals(li1.nPropertiesChange, 0);
1005     }
1006 
firePropertiesChangeEvent()1007     @Test public void firePropertiesChangeEvent() throws Exception
1008     {
1009         logger.log(Level.INFO, "PropertySet.firePropertiesChangeEvent");
1010         TestClass cl= new TestClass();
1011         Listener li1= new Listener();
1012 
1013         cl.intClassProp= Integer.valueOf(111);
1014         cl.charPropA= 'A';
1015         cl.firePropertiesChangeEvent(new String[]{"PropCharA","PropIntClass"},  li1);
1016         assertEquals(li1.nPropertiesChange, 1);
1017 
1018         PropertyChangeEvent[] arEvt= li1.arEvt;
1019         assertEquals(arEvt[0].PropertyName, "PropCharA");
1020         assertEquals(((Character) arEvt[0].OldValue).charValue(), 'A');
1021         assertEquals(((Character) arEvt[0].NewValue).charValue(), 'A');
1022         assertEquals(arEvt[1].PropertyName, "PropIntClass");
1023         assertEquals(((Integer) arEvt[1].OldValue).intValue(), 111);
1024         assertEquals(((Integer) arEvt[1].NewValue).intValue(), 111);
1025     }
1026 
registerProperty1()1027     @Test public void registerProperty1() throws Exception
1028     {
1029         TestClass2 cl= new TestClass2();
1030         cl.test_registerProperty1();
1031     }
1032 
registerProperty2()1033     @Test public void registerProperty2() throws Exception
1034     {
1035         TestClass2 cl= new TestClass2();
1036         cl.test_registerProperty2();
1037     }
1038 }
1039 
1040 class TestClass extends PropertySet
1041 {
1042     private static final Logger logger = Logger.getLogger(TestClass.class.getName());
1043 
1044     public Property propBoolA= new Property("PropBoolA", 1, new Type(Boolean.TYPE), (short)0);
1045     public boolean boolPropA;
1046     public Property propCharA= new Property("PropCharA", 2, new Type(Character.TYPE), (short) 0);
1047     public char charPropA;
1048     public Property propByteA= new Property("PropByteA", 3, new Type(Byte.TYPE), (short) 0);
1049     public byte bytePropA;
1050     public Property propShortA= new Property("PropShortA", 4, new Type(Short.TYPE), (short) 0);
1051     public short shortPropA;
1052     public Property propIntA= new Property("PropIntA", 5, new Type(Integer.TYPE), (short) 0);
1053     public int intPropA;
1054     public Property propLongA= new Property("PropLongA", 6, new Type(Long.TYPE), (short) 0);
1055     public long longPropA;
1056     public Property propFloatA= new Property("PropFloatA", 7, new Type(Float.TYPE), (short) 0);
1057     public float floatPropA;
1058     public Property propDoubleA= new Property("PropDoubleA", 8, new Type(Double.TYPE), (short) 0);
1059     public double doublePropA;
1060     public Property propStringA= new Property("PropStringA", 9, new Type(String.class), (short) 0);
1061     public String stringPropA;
1062     public Property propArrayByteA= new Property("PropArrayByteA", 10, new Type(byte[].class), (short) 0);
1063     public byte[] arBytePropA;
1064     public Property propTypeA= new Property("PropTypeA", 11, new Type(Type.class), (short) 0);
1065     public Type typePropA;
1066     public Property propObjectA= new Property("PropObjectA",12, new Type(Object.class), (short) 0);
1067     public Object objectPropA;
1068     public Property propAnyA= new Property("PropAnyA", 13, new Type(Any.class), (short) 0);
1069     public Any anyPropA;
1070     public Property propXInterfaceA= new Property("PropXInterfaceA", 13, new Type(Any.class), (short) 0);
1071     public XInterface xInterfacePropA;
1072     public Property propXWeakA= new Property("PropXWeakA", 13, new Type(Any.class), (short) 0);
1073     public XWeak xWeakPropA;
1074     public Property propEnum =
1075         new Property("PropEnum", 14, new Type("com.sun.star.beans.PropertyState", TypeClass.ENUM), (short)0);
1076     public com.sun.star.beans.PropertyState enumPropertyState = com.sun.star.beans.PropertyState.DEFAULT_VALUE;
1077     // Test private, protected, package access, Anys as arguments and members, members with a value
1078 
1079     public Property propBoolB= new Property("PropBoolB", 101, new Type(Boolean.TYPE), (short) 0);
1080     protected boolean boolPropB;
1081 
1082     public Property propBoolC= new Property("PropBoolC", 201, new Type(Boolean.TYPE), (short) 0);
1083     boolean boolPropC;
1084 
1085     public Property propBoolD= new Property("PropBoolD", 301, new Type(Boolean.TYPE), (short) 0);
1086 
1087     public Property propBoolClass= new Property("PropBoolClass", 1001, new Type(Boolean.class), (short) 0);
1088     public Boolean boolClassProp;
1089     public Property propCharClass= new Property("PropCharClass", 1002, new Type(Character.class), (short) 0);
1090     public Character charClassProp;
1091     public Property propByteClass= new Property("PropByteClass", 1003, new Type(Byte.class), (short) 0);
1092     public Byte byteClassProp;
1093     public Property propShortClass= new Property("PropShortClass", 1004, new Type(Short.class), (short) 0);
1094     public Short shortClassProp;
1095     public Property propIntClass= new Property("PropIntClass", 1005, new Type(Integer.class), (short) 0);
1096     public Integer intClassProp;
1097     public Property propLongClass= new Property("PropLongClass", 1006, new Type(Long.class), (short) 0);
1098     public Long longClassProp;
1099     public Property propFloatClass= new Property("PropFloatClass", 1007, new Type(Float.class), (short) 0);
1100     public Float floatClassProp;
1101     public Property propDoubleClass= new Property("PropDoubleClass", 1008, new Type(Double.class), (short) 0);
1102     public Double doubleClassProp;
1103 
1104 
TestClass()1105     public TestClass()
1106     {
1107 
1108         super();
1109         // When adding properties then modify the getRegisteredProperties method
1110         // registerProperty(String name, int handle, Type type, short attributes, String memberName)
1111         registerProperty(propBoolA, "boolPropA");
1112         registerProperty(propCharA, "charPropA");
1113         registerProperty(propByteA, "bytePropA");
1114         registerProperty(propShortA, "shortPropA");
1115         registerProperty(propIntA, "intPropA");
1116         registerProperty(propLongA, "longPropA");
1117         registerProperty(propFloatA, "floatPropA");
1118         registerProperty(propDoubleA, "doublePropA");
1119         registerProperty(propStringA, "stringPropA");
1120         registerProperty(propArrayByteA, "arBytePropA");
1121         registerProperty(propTypeA, "typePropA");
1122         registerProperty(propObjectA, "objectPropA");
1123         registerProperty(propAnyA, "anyPropA");
1124         registerProperty(propXInterfaceA, "xInterfacePropA");
1125         registerProperty(propXWeakA, "xWeakPropA");
1126         registerProperty(propEnum,"enumPropertyState");
1127         registerProperty(propBoolB, "boolPropB");
1128         registerProperty(propBoolC, "boolPropC");
1129         registerProperty(propBoolD, "boolPropD");
1130         registerProperty(propBoolClass, "boolClassProp");
1131         registerProperty(propCharClass, "charClassProp");
1132         registerProperty(propByteClass, "byteClassProp");
1133         registerProperty(propShortClass, "shortClassProp");
1134         registerProperty(propIntClass, "intClassProp");
1135         registerProperty(propLongClass, "longClassProp");
1136         registerProperty(propFloatClass, "floatClassProp");
1137         registerProperty(propDoubleClass, "doubleClassProp");
1138     }
1139 
1140     /** When adding properties then modify the getRegisteredProperties method
1141      */
getRegisteredProperties()1142     public Property[] getRegisteredProperties()
1143     {
1144         return new Property[] {
1145                     propBoolA, propCharA, propByteA, propShortA,
1146                     propIntA, propLongA, propFloatA, propDoubleA,
1147                     propStringA, propArrayByteA, propTypeA, propObjectA,
1148                     propAnyA, propXInterfaceA, propXWeakA, propEnum, propBoolB,
1149                     propBoolC, propBoolD, propBoolClass, propCharClass,
1150                     propByteClass, propShortClass, propIntClass, propLongClass,
1151                     propFloatClass, propDoubleClass
1152         };
1153 
1154     }
1155 
test_convertPropertyValue()1156     public void test_convertPropertyValue() throws Exception
1157     {
1158         resetPropertyMembers();
1159         Object[] outOldVal= new Object[1];
1160         Object[] outNewVal= new Object[1];
1161 
1162         Object value= Boolean.TRUE;
1163         assertTrue(convertPropertyValue(propBoolA,  outNewVal, outOldVal, value));
1164         assertTrue(outNewVal[0] instanceof Boolean);
1165         assertEquals(outNewVal[0], value);
1166         assertEquals(outOldVal[0], Boolean.FALSE);
1167 
1168         value= new Character('A');
1169         assertTrue(convertPropertyValue(propCharA, outNewVal, outOldVal, value));
1170         assertTrue(outNewVal[0] instanceof Character);
1171         assertEquals(outNewVal[0], value);
1172         assertEquals(outOldVal[0], new Character((char)0));
1173 
1174         charPropA= 'B';
1175         assertTrue(convertPropertyValue(propCharA, outNewVal, outOldVal, value));
1176         assertTrue(outNewVal[0] instanceof Character);
1177         assertEquals(outNewVal[0], value);
1178         assertEquals(outOldVal[0], new Character('B'));
1179 
1180         value= Byte.valueOf((byte) 111);
1181         assertTrue(convertPropertyValue(propByteA, outNewVal, outOldVal, value));
1182         assertTrue(outNewVal[0] instanceof Byte);
1183         assertEquals(outNewVal[0], value);
1184 
1185         value= Short.valueOf((short) 112);
1186         assertTrue(convertPropertyValue(propShortA, outNewVal, outOldVal, value));
1187         assertTrue(outNewVal[0] instanceof Short);
1188         assertEquals(outNewVal[0], value);
1189 
1190         value= Integer.valueOf( 113);
1191         assertTrue(convertPropertyValue(propIntA, outNewVal, outOldVal, value));
1192         assertTrue(outNewVal[0] instanceof Integer);
1193         assertEquals(outNewVal[0], value);
1194 
1195         value= Long.valueOf(114);
1196         assertTrue(convertPropertyValue(propLongA, outNewVal, outOldVal, value));
1197         assertTrue(outNewVal[0] instanceof Long);
1198         assertEquals(outNewVal[0], value);
1199 
1200         value= new Float(3.14);
1201         assertTrue(convertPropertyValue(propFloatA, outNewVal, outOldVal, value));
1202         assertTrue(outNewVal[0] instanceof Float);
1203         assertEquals(outNewVal[0], value);
1204 
1205         value= new Double(3.145);
1206         assertTrue(convertPropertyValue(propDoubleA, outNewVal, outOldVal, value));
1207         assertTrue(outNewVal[0] instanceof Double);
1208         assertEquals(outNewVal[0], value);
1209 
1210         value= "string";
1211         assertTrue(convertPropertyValue(propStringA, outNewVal, outOldVal, value));
1212         assertTrue(outNewVal[0] instanceof String);
1213         assertEquals(outNewVal[0], value);
1214 
1215         value= new byte[]{1,2,3};
1216         arBytePropA= null;
1217         assertTrue(convertPropertyValue(propArrayByteA, outNewVal, outOldVal, value));
1218         assertTrue(outNewVal[0] instanceof byte[]);
1219         assertEquals(outNewVal[0], value);
1220         assertNull(outOldVal[0]);
1221 
1222         assertTrue(convertPropertyValue(propArrayByteA, outNewVal, outOldVal, value));
1223         assertNull(outOldVal[0]);
1224 
1225         value= new Type(XInterface.class);
1226         assertTrue(convertPropertyValue(propTypeA, outNewVal, outOldVal, value));
1227         assertTrue(outNewVal[0] instanceof Type);
1228         assertEquals(outNewVal[0], value);
1229 
1230         value= new Object(); // TypeClass.VOID
1231         assertTrue(convertPropertyValue(propObjectA, outNewVal, outOldVal, value));
1232         assertEquals(outNewVal[0], value);
1233 
1234         value= Integer.valueOf(111);
1235         assertTrue(convertPropertyValue(propObjectA, outNewVal, outOldVal, value));
1236         assertTrue(outNewVal[0] instanceof Integer);
1237         assertEquals(outNewVal[0], value);
1238 
1239         value= new ComponentBase();
1240         assertTrue(convertPropertyValue(propObjectA, outNewVal, outOldVal, value));
1241         assertEquals(outNewVal[0], value);
1242 
1243         value= Integer.valueOf(111);
1244         assertTrue(convertPropertyValue(propAnyA, outNewVal, outOldVal, value));
1245         assertTrue(outNewVal[0] instanceof Any);
1246         assertEquals(((Any)outNewVal[0]).getType(), new Type(Integer.class));
1247         assertEquals(((Any)outNewVal[0]).getObject(), value);
1248 
1249         XWeak oWeak= new ComponentBase();
1250         value= oWeak;
1251         // The returned Any must contain an XInterface
1252         assertTrue(convertPropertyValue(propAnyA, outNewVal, outOldVal, value));
1253         assertEquals(((Any) outNewVal[0]).getType(), new Type(XInterface.class));
1254         assertSame(((Any) outNewVal[0]).getObject(), oWeak);
1255 
1256         value= new ComponentBase();
1257         assertTrue(convertPropertyValue(propXInterfaceA, outNewVal, outOldVal, value));
1258         assertTrue(outNewVal[0] instanceof XInterface);
1259         assertEquals(outNewVal[0], value);
1260         assertTrue(convertPropertyValue(propXWeakA, outNewVal, outOldVal, value));
1261         assertTrue(outNewVal[0] instanceof XWeak);
1262         assertEquals(outNewVal[0], value);
1263 
1264         value = com.sun.star.beans.PropertyState.DIRECT_VALUE;
1265         assertTrue(convertPropertyValue(propEnum, outNewVal, outOldVal, value));
1266         assertTrue(outNewVal[0] instanceof com.sun.star.uno.Enum);
1267         assertEquals(outNewVal[0], value);
1268 
1269         // Any arguments ------------------------------------------------------------------
1270         value= new Any( new Type(Integer.class),Integer.valueOf(111));
1271         assertTrue(convertPropertyValue(propIntA, outNewVal, outOldVal, value));
1272         assertTrue(outNewVal[0] instanceof Integer);
1273         assertEquals(outNewVal[0], ((Any) value).getObject());
1274 
1275         value= new Any(new Type(Boolean.class), Boolean.TRUE);
1276         assertTrue(convertPropertyValue(propBoolA, outNewVal, outOldVal, value));
1277         assertTrue(outNewVal[0] instanceof Boolean);
1278         assertEquals(outNewVal[0], ((Any) value).getObject());
1279 
1280         //Character, Byte, Short, Long
1281         // must fail
1282         try {
1283             value= new Any(new Type(Object.class), new Object());
1284             fail("java.lang.IllegalArgumentException expected");
1285             assertTrue(convertPropertyValue(propObjectA, outNewVal, outOldVal, value));
1286             assertTrue(convertPropertyValue(propAnyA, outNewVal, outOldVal, value));
1287         } catch (java.lang.IllegalArgumentException e) {
1288             logger.log(Level.FINE, "java.lang.IllegalArgumentException caught");
1289         }
1290 
1291         value= new Any(new Type(Integer.class), Integer.valueOf(111));
1292         assertTrue(convertPropertyValue(propObjectA, outNewVal, outOldVal, value));
1293         assertTrue(outNewVal[0] instanceof Integer);
1294         assertEquals(outNewVal[0], ((Any)value).getObject());
1295         assertTrue(convertPropertyValue(propAnyA, outNewVal, outOldVal, value));
1296         assertTrue(outNewVal[0] instanceof Any);
1297         assertEquals(((Any) outNewVal[0]).getType(), ((Any) value).getType());
1298         assertEquals(((Any) outNewVal[0]).getObject(), ((Any) value).getObject());
1299 
1300         value= new Any(new Type(XInterface.class), new ComponentBase());
1301         assertTrue(convertPropertyValue(propObjectA, outNewVal, outOldVal, value));
1302         assertTrue(outNewVal[0] instanceof XInterface);
1303         assertSame(outNewVal[0], ((Any) value).getObject());
1304         assertTrue(convertPropertyValue(propXInterfaceA, outNewVal, outOldVal, value));
1305         assertSame(outNewVal[0], ((Any) value).getObject());
1306 
1307         value= new Any(new Type(byte[].class), new byte[]{1,2,3});
1308         assertTrue(convertPropertyValue(propArrayByteA, outNewVal, outOldVal, value));
1309         assertTrue(outNewVal[0] instanceof byte[]);
1310 
1311         // test private, protected, package fields
1312         value= Boolean.TRUE;
1313         assertTrue(convertPropertyValue(propBoolB, outNewVal, outOldVal, value));
1314         assertEquals(((Boolean)value).booleanValue(), ((Boolean) outNewVal[0]).booleanValue());
1315         assertTrue(convertPropertyValue(propBoolC, outNewVal,  outOldVal, value));
1316         assertEquals(((Boolean)value).booleanValue(), ((Boolean) outNewVal[0]).booleanValue());
1317         // must fail because the member boolPropD is private
1318         try{
1319             convertPropertyValue(propBoolD, outNewVal,  outOldVal, value);
1320             fail("com.sun.star.lang.WrappedTargetException expected");
1321         } catch (com.sun.star.lang.WrappedTargetException e) {
1322             logger.log(Level.FINE, "com.sun.star.lang.WrappedTargetException caught");
1323         }
1324 
1325         // Properties member of type Byte,Short etc.
1326         value= Boolean.TRUE;
1327         assertTrue(convertPropertyValue(propBoolClass, outNewVal, outOldVal, value));
1328         assertTrue(outNewVal[0] instanceof Boolean);
1329         assertEquals(outNewVal[0], value);
1330 
1331         value= new Character('A');
1332         assertTrue(convertPropertyValue(propCharClass, outNewVal, outOldVal, value));
1333         assertTrue(outNewVal[0] instanceof Character);
1334         assertEquals(outNewVal[0], value);
1335 
1336         value= Byte.valueOf((byte) 111);
1337         assertTrue(convertPropertyValue(propByteClass, outNewVal, outOldVal, value));
1338         assertTrue(outNewVal[0] instanceof Byte);
1339         assertEquals(outNewVal[0], value);
1340 
1341         value= Short.valueOf((short) 112);
1342         assertTrue(convertPropertyValue(propShortClass, outNewVal, outOldVal, value));
1343         assertTrue(outNewVal[0] instanceof Short);
1344         assertEquals(outNewVal[0], value);
1345 
1346         value= Integer.valueOf(113);
1347         assertTrue(convertPropertyValue(propIntClass, outNewVal, outOldVal, value));
1348         assertTrue(outNewVal[0] instanceof Integer);
1349         assertEquals(outNewVal[0], value);
1350 
1351         value= Long.valueOf(114);
1352         assertTrue(convertPropertyValue(propLongClass, outNewVal, outOldVal, value));
1353         assertTrue(outNewVal[0] instanceof Long);
1354         assertEquals(outNewVal[0], value);
1355 
1356         value= new Float(3.14);
1357         assertTrue(convertPropertyValue(propFloatClass, outNewVal, outOldVal, value));
1358         assertTrue(outNewVal[0] instanceof Float);
1359         assertEquals(outNewVal[0], value);
1360 
1361         value= new Double(3.145);
1362         assertTrue(convertPropertyValue(propDoubleA, outNewVal, outOldVal, value));
1363         assertTrue(outNewVal[0] instanceof Double);
1364         assertEquals(outNewVal[0], value);
1365     }
1366 
test_setPropertyValueNoBroadcast()1367     public void test_setPropertyValueNoBroadcast() throws Exception
1368     {
1369         resetPropertyMembers();
1370 
1371         Object value= Boolean.TRUE;
1372         setPropertyValueNoBroadcast(propBoolA, value);
1373         assertEquals(boolPropA, ((Boolean) value).booleanValue());
1374 
1375         value= new Character('A');
1376         setPropertyValueNoBroadcast(propCharA, value);
1377         assertEquals(charPropA, ((Character) value).charValue());
1378 
1379         value= Byte.valueOf((byte) 111);
1380         setPropertyValueNoBroadcast(propByteA, value);
1381         assertEquals(bytePropA, ((Byte)value).byteValue());
1382 
1383         value= Short.valueOf((short) 112);
1384         setPropertyValueNoBroadcast(propShortA, value);
1385         assertEquals(shortPropA, ((Short) value).shortValue());
1386 
1387         value= Integer.valueOf( 113);
1388         setPropertyValueNoBroadcast(propIntA, value);
1389         assertEquals(intPropA, ((Integer) value).intValue());
1390 
1391         value= Long.valueOf(114);
1392         setPropertyValueNoBroadcast(propLongA, value);
1393         assertEquals(longPropA, ((Long) value).longValue());
1394 
1395         value= new Float(3.14);
1396         setPropertyValueNoBroadcast(propFloatA,  value);
1397         assertEquals(floatPropA, ((Float) value).floatValue(), 0.0f);
1398 
1399         value= new Double(3.145);
1400         setPropertyValueNoBroadcast(propDoubleA, value);
1401         assertEquals(doublePropA, ((Double) value).doubleValue(), 0.0f);
1402 
1403         value= "string";
1404         setPropertyValueNoBroadcast(propStringA, value);
1405         assertEquals(stringPropA, value);
1406 
1407         value= new byte[]{1,2,3};
1408         setPropertyValueNoBroadcast(propArrayByteA, value);
1409         assertEquals(arBytePropA, value);
1410 
1411         value= new Type(XInterface.class);
1412         setPropertyValueNoBroadcast(propTypeA, value);
1413         assertEquals(typePropA, value);
1414 
1415         value= Integer.valueOf(111);
1416         setPropertyValueNoBroadcast(propObjectA, value);
1417         assertEquals(objectPropA, value);
1418 
1419         value= new ComponentBase();
1420         setPropertyValueNoBroadcast(propObjectA, value);
1421         assertEquals(objectPropA, value);
1422 
1423         value= new Any( new Type(Integer.TYPE), Integer.valueOf(111));
1424         setPropertyValueNoBroadcast(propAnyA, value);
1425         assertTrue(util.anyEquals(anyPropA, value));
1426 
1427         value= new ComponentBase();
1428         setPropertyValueNoBroadcast(propXInterfaceA, value);
1429         assertTrue(xInterfacePropA instanceof XInterface);
1430         assertEquals(xInterfacePropA, value);
1431 
1432         setPropertyValueNoBroadcast(propXWeakA, value);
1433         assertTrue(xInterfacePropA instanceof XWeak);
1434         assertEquals(xInterfacePropA, value);
1435 
1436         value = com.sun.star.beans.PropertyState.AMBIGUOUS_VALUE;
1437         setPropertyValueNoBroadcast(propEnum, value);
1438         assertSame(enumPropertyState, value);
1439 
1440         value= Boolean.TRUE;
1441         setPropertyValueNoBroadcast(propBoolB, value);
1442         assertEquals(boolPropB, ((Boolean) value).booleanValue());
1443 
1444         setPropertyValueNoBroadcast(propBoolC, value);
1445         assertEquals(boolPropC, ((Boolean) value).booleanValue());
1446 
1447         // must fail because the member boolPropD is private
1448         try {
1449             setPropertyValueNoBroadcast(propBoolD, value);
1450             fail("com.sun.star.lang.WrappedTargetException expected");
1451         } catch (com.sun.star.lang.WrappedTargetException e) {
1452             logger.log(Level.FINE, "com.sun.star.lang.WrappedTargetException caught");
1453         }
1454     }
1455 
resetPropertyMembers()1456     void resetPropertyMembers()
1457     {
1458         boolPropA= false;
1459         charPropA= (char) 0;
1460         bytePropA= 0;
1461         shortPropA= 0;
1462         intPropA= 0;
1463         longPropA= 0;
1464         floatPropA= 0;
1465         doublePropA= 0.;
1466         stringPropA= null;
1467         arBytePropA= null;
1468         typePropA= null;
1469         objectPropA= null;
1470         anyPropA= null;
1471         xInterfacePropA= null;
1472         xWeakPropA= null;
1473         enumPropertyState = com.sun.star.beans.PropertyState.DEFAULT_VALUE;
1474         boolPropB= false;
1475         boolPropC= false;
1476         boolClassProp= null;
1477         charClassProp= null;
1478         byteClassProp= null;
1479         shortClassProp= null;
1480         intClassProp= null;
1481         longClassProp= null;
1482         floatClassProp= null;
1483         doubleClassProp= null;
1484     }
1485 }
1486 
1487 class TestClass2 extends PropertySet
1488 {
1489 
1490     public char charA;
1491     protected char charB;
1492     char charC;
1493 
1494     int intMemberA;
1495 
1496     public Character charClassA;
1497     protected Character charClassB;
1498     Character charClassC;
1499 
test_registerProperty1()1500     void test_registerProperty1() throws Exception
1501     {
1502         registerProperty("PropChar", new Type(char.class), (short) 0, "PropChar");
1503         registerProperty("PropInt", new Type(int.class), (short) 0, "PropInt");
1504         registerProperty("PropString", new Type(String.class), (short) 0, "PropString");
1505 
1506         XPropertySetInfo info= getPropertySetInfo();
1507         Property[] props= info.getProperties();
1508         for (int j= 0; j < props.length; j++)
1509         {
1510            boolean result= false;
1511            Property aProp= props[j];
1512            if (aProp.Name.equals("PropChar") && aProp.Type.equals(new Type(char.class)) &&
1513                 aProp.Attributes == 0)
1514                result= true;
1515            else if (aProp.Name.equals("PropInt") && aProp.Type.equals(new Type(int.class)) &&
1516                 aProp.Attributes == 0)
1517                result= true;
1518            else if (aProp.Name.equals("PropString") && aProp.Type.equals(new Type(String.class)) &&
1519                 aProp.Attributes == 0)
1520                result= true;
1521            assertTrue(result);
1522         }
1523     }
1524 
test_registerProperty2()1525     void test_registerProperty2() throws Exception
1526     {
1527         System.out.println("registerProperty Test 2");
1528 
1529         registerProperty("charA", "charA", (short) 0);
1530         registerProperty("charB", "charB", (short) 0);
1531         registerProperty("charC", "charC", (short) 0);
1532         registerProperty("charClassB", "charClassB", PropertyAttribute.MAYBEVOID);
1533         registerProperty("IntProp", "intMemberA", (short) 0);
1534 
1535         XPropertySetInfo info= getPropertySetInfo();
1536         Property[] props= info.getProperties();
1537         for (int j= 0; j < props.length; j++)
1538         {
1539            boolean result= false;
1540            Property aProp= props[j];
1541            if (aProp.Name.equals("charA") && aProp.Type.equals(new Type(char.class)) &&
1542                 aProp.Attributes == 0)
1543                result= true;
1544            else if (aProp.Name.equals("charB") && aProp.Type.equals(new Type(char.class)) &&
1545                 aProp.Attributes == 0)
1546                result= true;
1547            else if (aProp.Name.equals("charC") && aProp.Type.equals(new Type(char.class)) &&
1548                 aProp.Attributes == 0)
1549                result= true;
1550            else if (aProp.Name.equals("charClassB") && aProp.Type.equals(new Type(char.class)) &&
1551                 aProp.Attributes == PropertyAttribute.MAYBEVOID)
1552                result= true;
1553            else if (aProp.Name.equals("IntProp") && aProp.Type.equals(new Type(int.class)) &&
1554                 aProp.Attributes == 0)
1555                result= true;
1556            assertTrue(result);
1557         }
1558         Object val= new Character('A');
1559         setPropertyValue("charA", val);
1560         assertEquals(val, getPropertyValue("charA"));
1561         setPropertyValue("charClassB",val);
1562         assertEquals(val, getPropertyValue("charClassB"));
1563         val= Integer.valueOf(111);
1564         setPropertyValue("IntProp",val);
1565         assertEquals(val, getPropertyValue("IntProp"));
1566     }
1567 }
1568 
1569 class util
1570 {
1571     // An Object is considered an Any with TypeClass.VOID and no value.
anyEquals(Object val1, Object val2)1572     static boolean anyEquals(Object val1, Object val2)
1573     {
1574         Object obj1= null;
1575         Object obj2= null;
1576         Type t1= null;
1577         Type t2= null;
1578         if (val1 instanceof Any)
1579         {
1580             obj1= ((Any) val1).getObject();
1581             t1= ((Any) val1).getType();
1582         }
1583         else
1584             obj1= val1;
1585 
1586         if (val2 instanceof Any)
1587         {
1588             obj2= ((Any) val2).getObject();
1589             t2= ((Any) val2).getType();
1590         }
1591         else
1592             obj2= val2;
1593 
1594         if (obj1 != null && obj1.equals(obj2))
1595             return true;
1596         else if ((obj1 == null && obj2 == null) && t1 != null && t1.equals(t2))
1597             return true;
1598         return false;
1599     }
1600 
1601     // returns true if obj is an any that contains a void or interface type and the
1602     // object is null
isVoidAny(Object obj)1603     static boolean isVoidAny(Object obj)
1604     {
1605         boolean ret= false;
1606         if(obj instanceof Any)
1607         {
1608             Any a= (Any) obj;
1609             if( a.getType().getTypeClass().equals( TypeClass.INTERFACE)
1610                 && a.getObject() == null) {
1611                 ret= true;
1612             }
1613             else if( a.getType().equals( new Type(void.class)) && a.getObject() == null) {
1614                 ret= true;
1615             }
1616         }
1617         return ret;
1618     }
1619 }
1620 
1621 class Listener implements XPropertyChangeListener, XVetoableChangeListener,
1622 XPropertiesChangeListener
1623 {
1624     int nChangeCalled;
1625     int nPropertiesChange;
1626     int nVetoCalled;
1627     boolean bVeto= false;
1628     PropertyChangeEvent evt;
1629     PropertyChangeEvent[] arEvt;
1630     // XPropertyChangeListener
propertyChange(PropertyChangeEvent evt )1631     public void propertyChange(PropertyChangeEvent evt )
1632     {
1633         nChangeCalled++;
1634         this.evt= evt;
1635     }
1636 
1637     //VetoableChangeListener
vetoableChange(PropertyChangeEvent evt )1638     public void vetoableChange(PropertyChangeEvent evt ) throws PropertyVetoException
1639     {
1640         nVetoCalled++;
1641          this.evt= evt;
1642          if (bVeto)
1643              throw new PropertyVetoException();
1644     }
1645 
disposing( EventObject Source )1646     public void disposing( /*IN*/EventObject Source )
1647     {
1648     }
1649 
reset()1650     public void reset()
1651     {
1652         nChangeCalled= 0;
1653         nPropertiesChange= 0;
1654         nVetoCalled= 0;
1655         evt= null;
1656         arEvt= null;
1657         bVeto= false;
1658     }
1659     // XPropertiesChangeListener
propertiesChange(PropertyChangeEvent[] propertyChangeEvent)1660     public void propertiesChange(PropertyChangeEvent[] propertyChangeEvent)
1661     {
1662         nPropertiesChange++;
1663         arEvt= propertyChangeEvent;
1664     }
1665 
1666 }
1667