1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
3<script:module xmlns:script="http://openoffice.org/2000/script" script:name="accessibility_XAccessibleEventBroadcaster" script:language="StarBasic">
4&apos;*************************************************************************
5&apos;*
6' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7'
8' Copyright 2000, 2010 Oracle and/or its affiliates.
9'
10' OpenOffice.org - a multi-platform office productivity suite
11'
12' This file is part of OpenOffice.org.
13'
14' OpenOffice.org is free software: you can redistribute it and/or modify
15' it under the terms of the GNU Lesser General Public License version 3
16' only, as published by the Free Software Foundation.
17'
18' OpenOffice.org is distributed in the hope that it will be useful,
19' but WITHOUT ANY WARRANTY; without even the implied warranty of
20' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21' GNU Lesser General Public License version 3 for more details
22' (a copy is included in the LICENSE file that accompanied this code).
23'
24' You should have received a copy of the GNU Lesser General Public License
25' version 3 along with OpenOffice.org.  If not, see
26' <http://www.openoffice.org/license.html>
27' for a copy of the LGPLv3 License.
28'
29&apos;*************************************************************************
30&apos;*************************************************************************
31
32
33
34&apos; Be sure that all variables are dimensioned:
35option explicit
36
37&apos;*************************************************************************
38&apos; This Interface/Service test depends on the following GLOBAL variables,
39&apos; which must be specified in the object creation:
40
41&apos; fireEvent() precedure
42&apos; located in component test
43
44&apos;*************************************************************************
45
46
47
48
49
50Dim oListener1 As Object
51Dim oListener2 As Object
52Dim bL1called As Boolean
53Dim bL2called As Boolean
54
55
56Sub RunTest()
57
58&apos;*************************************************************************
59&apos; INTERFACE:
60&apos; com.sun.star.accessibility.XAccessibleEventBroadcaster
61&apos;*************************************************************************
62On Error Goto ErrHndl
63    Dim bOK As Boolean
64    Dim isTransient As Boolean
65    Dim stateSet As Variant
66    bOK = true
67
68    &apos;out.log(&quot;Creating Listeners...&quot;)
69    oListener1 = createUNOListener(&quot;EL1_&quot;,&quot;com.sun.star.accessibility.XAccessibleEventListener&quot;)
70    oListener2 = createUNOListener(&quot;EL2_&quot;,&quot;com.sun.star.accessibility.XAccessibleEventListener&quot;)
71    bOK = bOK AND NOT isNULL(oListener1) AND NOT isNULL(oListener2)
72    if NOT bOK then out.log( &quot;ERROR: Cannot create listeners...&quot;)
73
74    if NOT hasUNOInterfaces(oObj,&quot;com.sun.star.accessibility.XAccessibleContext&quot;) then
75        &apos;out.log(&quot;Object does not implement XAccessibleContext.&quot;)
76        isTransient = false
77    else
78        stateSet = oObj.getAccessibleStateSet()
79        isTransient = stateSet.contains(27)
80    End If
81
82    Test.StartMethod(&quot;addEventListener()&quot;)
83    bOK = true
84    bL1called = false
85    bL2called = false
86    &apos;out.log(&quot;Adding two listeners...&quot;)
87    oObj.com_sun_star_accessibility_XAccessibleEventBroadcaster_addEventListener(oListener1)
88    oObj.com_sun_star_accessibility_XAccessibleEventBroadcaster_addEventListener(oListener2)
89    &apos;out.log(&quot;fire event&quot;)
90    fireEvent()
91    wait(500)
92    out.log(&quot;Listener1 called: &quot;+bL1called)
93    out.log(&quot;Listener2 called: &quot;+bL2called)
94    if NOT isTransient then
95        bOK = bOK AND bL1called AND bL2called
96    else
97        &apos;out.log(&quot;Object is transient, listeners aren&apos;t expected to call.&quot;)
98        bOK = true
99    End If
100    Test.MethodTested(&quot;addEventListener()&quot;,bOK)
101
102
103    Test.StartMethod(&quot;removeEventListener()&quot;)
104    bOK = true
105    bL1called = false
106    bL2called = false
107    &apos;out.log(&quot;Removing one listener...&quot;)
108    oObj.com_sun_star_accessibility_XAccessibleEventBroadcaster_removeEventListener(oListener1)
109    &apos;out.log(&quot;fire event&quot;)
110    fireEvent()
111    wait(500)
112    out.log(&quot;Listener1 called: &quot;+bL1called)
113    out.log(&quot;Listener2 called: &quot;+bL2called)
114    if NOT isTransient then
115        bOK = bOK AND NOT bL1called AND bL2called
116    else
117        &apos;out.log(&quot;Object is transient, listeners aren&apos;t expected to call.&quot;)
118        bOK = true
119    End If
120    Test.MethodTested(&quot;removeEventListener()&quot;,bOK)
121
122    &apos; Removing the second listener...
123    oObj.com_sun_star_accessibility_XAccessibleEventBroadcaster_removeEventListener(oListener2)
124
125
126Exit Sub
127ErrHndl:
128    Test.Exception()
129    bOK = false
130    resume next
131End Sub
132
133Sub EL1_notifyEvent(ev As Variant)
134    &apos;out.log(&quot;CallBack for Listener1 notifyEvent was called.&quot;)
135    bL1called = true
136End Sub
137
138Sub EL1_disposing()
139End Sub
140
141Sub EL2_notifyEvent(ev As Variant)
142    &apos;out.log(&quot;CallBack for Listener2 notifyEvent was called.&quot;)
143    bL2called = true
144End Sub
145
146Sub EL2_disposing()
147End Sub
148
149</script:module>