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'
7'  Licensed to the Apache Software Foundation (ASF) under one
8'  or more contributor license agreements.  See the NOTICE file
9'  distributed with this work for additional information
10'  regarding copyright ownership.  The ASF licenses this file
11'  to you under the Apache License, Version 2.0 (the
12'  "License"); you may not use this file except in compliance
13'  with the License.  You may obtain a copy of the License at
14'
15'    http://www.apache.org/licenses/LICENSE-2.0
16'
17'  Unless required by applicable law or agreed to in writing,
18'  software distributed under the License is distributed on an
19'  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
20'  KIND, either express or implied.  See the License for the
21'  specific language governing permissions and limitations
22'  under the License.
23'
24&apos;*************************************************************************
25&apos;*************************************************************************
26
27
28
29&apos; Be sure that all variables are dimensioned:
30option explicit
31
32&apos;*************************************************************************
33&apos; This Interface/Service test depends on the following GLOBAL variables,
34&apos; which must be specified in the object creation:
35
36&apos; fireEvent() precedure
37&apos; located in component test
38
39&apos;*************************************************************************
40
41
42
43
44
45Dim oListener1 As Object
46Dim oListener2 As Object
47Dim bL1called As Boolean
48Dim bL2called As Boolean
49
50
51Sub RunTest()
52
53&apos;*************************************************************************
54&apos; INTERFACE:
55&apos; com.sun.star.accessibility.XAccessibleEventBroadcaster
56&apos;*************************************************************************
57On Error Goto ErrHndl
58    Dim bOK As Boolean
59    Dim isTransient As Boolean
60    Dim stateSet As Variant
61    bOK = true
62
63    &apos;out.log(&quot;Creating Listeners...&quot;)
64    oListener1 = createUNOListener(&quot;EL1_&quot;,&quot;com.sun.star.accessibility.XAccessibleEventListener&quot;)
65    oListener2 = createUNOListener(&quot;EL2_&quot;,&quot;com.sun.star.accessibility.XAccessibleEventListener&quot;)
66    bOK = bOK AND NOT isNULL(oListener1) AND NOT isNULL(oListener2)
67    if NOT bOK then out.log( &quot;ERROR: Cannot create listeners...&quot;)
68
69    if NOT hasUNOInterfaces(oObj,&quot;com.sun.star.accessibility.XAccessibleContext&quot;) then
70        &apos;out.log(&quot;Object does not implement XAccessibleContext.&quot;)
71        isTransient = false
72    else
73        stateSet = oObj.getAccessibleStateSet()
74        isTransient = stateSet.contains(27)
75    End If
76
77    Test.StartMethod(&quot;addEventListener()&quot;)
78    bOK = true
79    bL1called = false
80    bL2called = false
81    &apos;out.log(&quot;Adding two listeners...&quot;)
82    oObj.com_sun_star_accessibility_XAccessibleEventBroadcaster_addEventListener(oListener1)
83    oObj.com_sun_star_accessibility_XAccessibleEventBroadcaster_addEventListener(oListener2)
84    &apos;out.log(&quot;fire event&quot;)
85    fireEvent()
86    wait(500)
87    out.log(&quot;Listener1 called: &quot;+bL1called)
88    out.log(&quot;Listener2 called: &quot;+bL2called)
89    if NOT isTransient then
90        bOK = bOK AND bL1called AND bL2called
91    else
92        &apos;out.log(&quot;Object is transient, listeners aren&apos;t expected to call.&quot;)
93        bOK = true
94    End If
95    Test.MethodTested(&quot;addEventListener()&quot;,bOK)
96
97
98    Test.StartMethod(&quot;removeEventListener()&quot;)
99    bOK = true
100    bL1called = false
101    bL2called = false
102    &apos;out.log(&quot;Removing one listener...&quot;)
103    oObj.com_sun_star_accessibility_XAccessibleEventBroadcaster_removeEventListener(oListener1)
104    &apos;out.log(&quot;fire event&quot;)
105    fireEvent()
106    wait(500)
107    out.log(&quot;Listener1 called: &quot;+bL1called)
108    out.log(&quot;Listener2 called: &quot;+bL2called)
109    if NOT isTransient then
110        bOK = bOK AND NOT bL1called AND bL2called
111    else
112        &apos;out.log(&quot;Object is transient, listeners aren&apos;t expected to call.&quot;)
113        bOK = true
114    End If
115    Test.MethodTested(&quot;removeEventListener()&quot;,bOK)
116
117    &apos; Removing the second listener...
118    oObj.com_sun_star_accessibility_XAccessibleEventBroadcaster_removeEventListener(oListener2)
119
120
121Exit Sub
122ErrHndl:
123    Test.Exception()
124    bOK = false
125    resume next
126End Sub
127
128Sub EL1_notifyEvent(ev As Variant)
129    &apos;out.log(&quot;CallBack for Listener1 notifyEvent was called.&quot;)
130    bL1called = true
131End Sub
132
133Sub EL1_disposing()
134End Sub
135
136Sub EL2_notifyEvent(ev As Variant)
137    &apos;out.log(&quot;CallBack for Listener2 notifyEvent was called.&quot;)
138    bL2called = true
139End Sub
140
141Sub EL2_disposing()
142End Sub
143
144</script:module>
145