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