1cdf0e10cSrcweir<?xml version="1.0" encoding="UTF-8"?> 2cdf0e10cSrcweir<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd"> 3cdf0e10cSrcweir<script:module xmlns:script="http://openoffice.org/2000/script" script:name="script_XEventAttacherManager" script:language="StarBasic"> 4cdf0e10cSrcweir 5cdf0e10cSrcweir 6cdf0e10cSrcweir'************************************************************************* 7cdf0e10cSrcweir' 8*3709053cSAndrew Rist' Licensed to the Apache Software Foundation (ASF) under one 9*3709053cSAndrew Rist' or more contributor license agreements. See the NOTICE file 10*3709053cSAndrew Rist' distributed with this work for additional information 11*3709053cSAndrew Rist' regarding copyright ownership. The ASF licenses this file 12*3709053cSAndrew Rist' to you under the Apache License, Version 2.0 (the 13*3709053cSAndrew Rist' "License"); you may not use this file except in compliance 14*3709053cSAndrew Rist' with the License. You may obtain a copy of the License at 15*3709053cSAndrew Rist' 16*3709053cSAndrew Rist' http://www.apache.org/licenses/LICENSE-2.0 17*3709053cSAndrew Rist' 18*3709053cSAndrew Rist' Unless required by applicable law or agreed to in writing, 19*3709053cSAndrew Rist' software distributed under the License is distributed on an 20*3709053cSAndrew Rist' "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 21*3709053cSAndrew Rist' KIND, either express or implied. See the License for the 22*3709053cSAndrew Rist' specific language governing permissions and limitations 23*3709053cSAndrew Rist' under the License. 24cdf0e10cSrcweir' 25cdf0e10cSrcweir'************************************************************************* 26cdf0e10cSrcweir 27cdf0e10cSrcweir 28cdf0e10cSrcweir 29cdf0e10cSrcweir 30cdf0e10cSrcweir 31*3709053cSAndrew Rist 32*3709053cSAndrew Rist 33cdf0e10cSrcweirSub RunTest() 34cdf0e10cSrcweir 35cdf0e10cSrcweir'************************************************************************* 36cdf0e10cSrcweir' INTERFACE: 37cdf0e10cSrcweir' com.sun.star.script.XEventAttacherManager 38cdf0e10cSrcweir'************************************************************************* 39cdf0e10cSrcweirOn Error Goto ErrHndl 40cdf0e10cSrcweir Dim bOK As Boolean 41cdf0e10cSrcweir 42cdf0e10cSrcweir oObj.insertEntry(0) 43cdf0e10cSrcweir 44cdf0e10cSrcweir Test.StartMethod("addScriptListener()") 45cdf0e10cSrcweir bOK = true 46cdf0e10cSrcweir Dim oListener1 As Object 47cdf0e10cSrcweir Dim oListener2 As Object 48cdf0e10cSrcweir 49cdf0e10cSrcweir oListener = createUnoListener("CB1_", "com.sun.star.script.XScriptListener") 50cdf0e10cSrcweir 51cdf0e10cSrcweir oObj.addScriptListener(oListener) 52cdf0e10cSrcweir 53cdf0e10cSrcweir Test.MethodTested("addScriptListener()", bOK) 54cdf0e10cSrcweir 55cdf0e10cSrcweir 56cdf0e10cSrcweir Test.StartMethod("registerScriptEvent()") 57cdf0e10cSrcweir bOK = true 58cdf0e10cSrcweir 59cdf0e10cSrcweir Dim aScriptEvent1 As New com.sun.star.script.ScriptEventDescriptor 60cdf0e10cSrcweir aScriptEvent1.ListenerType = "ScriptListener" 61cdf0e10cSrcweir aScriptEvent1.EventMethod = "Test" 62cdf0e10cSrcweir aScriptEvent1.AddListenerParam = "" 63cdf0e10cSrcweir aScriptEvent1.ScriptType = "Basic" 64cdf0e10cSrcweir aScriptEvent1.ScriptCode = "MsgBox ""Script1""" 65cdf0e10cSrcweir oObj.registerScriptEvent(0, aScriptEvent1) 66cdf0e10cSrcweir 67cdf0e10cSrcweir Test.MethodTested("registerScriptEvent()", bOK) 68cdf0e10cSrcweir 69cdf0e10cSrcweir Test.StartMethod("registerScriptEvents()") 70cdf0e10cSrcweir bOK = true 71cdf0e10cSrcweir Dim aScriptEvent2 As New com.sun.star.script.ScriptEventDescriptor 72cdf0e10cSrcweir aScriptEvent2.ListenerType = "ScriptListener" 73cdf0e10cSrcweir aScriptEvent2.EventMethod = "Test" 74cdf0e10cSrcweir aScriptEvent2.AddListenerParam = "" 75cdf0e10cSrcweir aScriptEvent2.ScriptType = "Basic" 76cdf0e10cSrcweir aScriptEvent2.ScriptCode = "MsgBox ""Script2""" 77cdf0e10cSrcweir Dim aScriptEvent3 As New com.sun.star.script.ScriptEventDescriptor 78cdf0e10cSrcweir aScriptEvent3.ListenerType = "ScriptListener" 79cdf0e10cSrcweir aScriptEvent3.EventMethod = "Test" 80cdf0e10cSrcweir aScriptEvent3.AddListenerParam = "" 81cdf0e10cSrcweir aScriptEvent3.ScriptType = "Basic" 82cdf0e10cSrcweir aScriptEvent3.ScriptCode = "MsgBox ""Script3""" 83cdf0e10cSrcweir 84cdf0e10cSrcweir Dim aScripts(1) 85cdf0e10cSrcweir aScripts(0) = aScriptEvent2 86cdf0e10cSrcweir aScripts(1) = aScriptEvent3 87cdf0e10cSrcweir 88cdf0e10cSrcweir oObj.registerScriptEvents(0, aScripts()) 89cdf0e10cSrcweir 90cdf0e10cSrcweir Test.MethodTested("registerScriptEvents()", bOK) 91cdf0e10cSrcweir 92cdf0e10cSrcweir Test.StartMethod("getScriptEvents()") 93cdf0e10cSrcweir bOK = true 94cdf0e10cSrcweir allScripts = oObj.getScriptEvents(0) 95cdf0e10cSrcweir bOK = bOK AND ubound(allScripts) = 2 96cdf0e10cSrcweir bOK = bOK AND allScripts(0).ScriptCode = "MsgBox ""Script1""" 97cdf0e10cSrcweir bOK = bOK AND allScripts(1).ScriptCode = "MsgBox ""Script2""" 98cdf0e10cSrcweir bOK = bOK AND allScripts(2).ScriptCode = "MsgBox ""Script3""" 99cdf0e10cSrcweir Test.MethodTested("getScriptEvents()", bOK) 100cdf0e10cSrcweir 101cdf0e10cSrcweir Test.StartMethod("insertEntry()") 102cdf0e10cSrcweir bOK = true 103cdf0e10cSrcweir oObj.insertEntry(0) 104cdf0e10cSrcweir allScripts = oObj.getScriptEvents(0) 105cdf0e10cSrcweir bOK = bOK AND ubound(allScripts) = -1 106cdf0e10cSrcweir allScripts = oObj.getScriptEvents(1) 107cdf0e10cSrcweir bOK = bOK AND ubound(allScripts) = 2 108cdf0e10cSrcweir Test.MethodTested("insertEntry()", bOK) 109cdf0e10cSrcweir 110cdf0e10cSrcweir Test.StartMethod("removeEntry()") 111cdf0e10cSrcweir bOK = true 112cdf0e10cSrcweir oObj.removeEntry(0) 113cdf0e10cSrcweir allScripts = oObj.getScriptEvents(1) 114cdf0e10cSrcweir bOK = bOK AND ubound(allScripts) = -1 115cdf0e10cSrcweir allScripts = oObj.getScriptEvents(0) 116cdf0e10cSrcweir bOK = bOK AND ubound(allScripts) = 2 117cdf0e10cSrcweir Test.MethodTested("removeEntry()", bOK) 118cdf0e10cSrcweir 119cdf0e10cSrcweir Test.StartMethod("attach()") 120cdf0e10cSrcweir bOK = true 121cdf0e10cSrcweir oObj.attach(0, oObj, "") 122cdf0e10cSrcweir Test.MethodTested("attach()", bOK) 123cdf0e10cSrcweir 124cdf0e10cSrcweir Test.StartMethod("detach()") 125cdf0e10cSrcweir bOK = true 126cdf0e10cSrcweir oObj.detach(0, oObj) 127cdf0e10cSrcweir Test.MethodTested("detach()", bOK) 128cdf0e10cSrcweir 129cdf0e10cSrcweir 130cdf0e10cSrcweir Test.StartMethod("revokeScriptEvent()") 131cdf0e10cSrcweir bOK = true 132cdf0e10cSrcweir oObj.revokeScriptEvent(0, "ScriptListener", "Test", "") 133cdf0e10cSrcweir allScripts = oObj.getScriptEvents(0) 134cdf0e10cSrcweir bOK = bOK AND ubound(allScripts) = 1 135cdf0e10cSrcweir Test.MethodTested("revokeScriptEvent()", bOK) 136cdf0e10cSrcweir 137cdf0e10cSrcweir Test.StartMethod("revokeScriptEvents()") 138cdf0e10cSrcweir bOK = true 139cdf0e10cSrcweir oObj.revokeScriptEvents(0) 140cdf0e10cSrcweir allScripts = oObj.getScriptEvents(0) 141cdf0e10cSrcweir bOK = bOK AND ubound(allScripts) = -1 142cdf0e10cSrcweir Test.MethodTested("revokeScriptEvents()", bOK) 143cdf0e10cSrcweir 144cdf0e10cSrcweir Test.StartMethod("removeScriptListener()") 145cdf0e10cSrcweir bOK = true 146cdf0e10cSrcweir oObj.removeScriptListener(oListener) 147cdf0e10cSrcweir Test.MethodTested("removeScriptListener()", bOK) 148cdf0e10cSrcweir 149cdf0e10cSrcweirExit Sub 150cdf0e10cSrcweirErrHndl: 151cdf0e10cSrcweir Test.Exception() 152cdf0e10cSrcweir bOK = false 153cdf0e10cSrcweir resume next 154cdf0e10cSrcweirEnd Sub 155cdf0e10cSrcweir</script:module> 156