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="script_XEventAttacherManager" script:language="StarBasic"> 4 5 6'************************************************************************* 7' 8' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 9' 10' Copyright 2000, 2010 Oracle and/or its affiliates. 11' 12' OpenOffice.org - a multi-platform office productivity suite 13' 14' This file is part of OpenOffice.org. 15' 16' OpenOffice.org is free software: you can redistribute it and/or modify 17' it under the terms of the GNU Lesser General Public License version 3 18' only, as published by the Free Software Foundation. 19' 20' OpenOffice.org is distributed in the hope that it will be useful, 21' but WITHOUT ANY WARRANTY; without even the implied warranty of 22' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23' GNU Lesser General Public License version 3 for more details 24' (a copy is included in the LICENSE file that accompanied this code). 25' 26' You should have received a copy of the GNU Lesser General Public License 27' version 3 along with OpenOffice.org. If not, see 28' <http://www.openoffice.org/license.html> 29' for a copy of the LGPLv3 License. 30' 31'************************************************************************* 32***** 33'************************************************************************* 34 35 36 37 38 39Sub RunTest() 40 41'************************************************************************* 42' INTERFACE: 43' com.sun.star.script.XEventAttacherManager 44'************************************************************************* 45On Error Goto ErrHndl 46 Dim bOK As Boolean 47 48 oObj.insertEntry(0) 49 50 Test.StartMethod("addScriptListener()") 51 bOK = true 52 Dim oListener1 As Object 53 Dim oListener2 As Object 54 55 oListener = createUnoListener("CB1_", "com.sun.star.script.XScriptListener") 56 57 oObj.addScriptListener(oListener) 58 59 Test.MethodTested("addScriptListener()", bOK) 60 61 62 Test.StartMethod("registerScriptEvent()") 63 bOK = true 64 65 Dim aScriptEvent1 As New com.sun.star.script.ScriptEventDescriptor 66 aScriptEvent1.ListenerType = "ScriptListener" 67 aScriptEvent1.EventMethod = "Test" 68 aScriptEvent1.AddListenerParam = "" 69 aScriptEvent1.ScriptType = "Basic" 70 aScriptEvent1.ScriptCode = "MsgBox ""Script1""" 71 oObj.registerScriptEvent(0, aScriptEvent1) 72 73 Test.MethodTested("registerScriptEvent()", bOK) 74 75 Test.StartMethod("registerScriptEvents()") 76 bOK = true 77 Dim aScriptEvent2 As New com.sun.star.script.ScriptEventDescriptor 78 aScriptEvent2.ListenerType = "ScriptListener" 79 aScriptEvent2.EventMethod = "Test" 80 aScriptEvent2.AddListenerParam = "" 81 aScriptEvent2.ScriptType = "Basic" 82 aScriptEvent2.ScriptCode = "MsgBox ""Script2""" 83 Dim aScriptEvent3 As New com.sun.star.script.ScriptEventDescriptor 84 aScriptEvent3.ListenerType = "ScriptListener" 85 aScriptEvent3.EventMethod = "Test" 86 aScriptEvent3.AddListenerParam = "" 87 aScriptEvent3.ScriptType = "Basic" 88 aScriptEvent3.ScriptCode = "MsgBox ""Script3""" 89 90 Dim aScripts(1) 91 aScripts(0) = aScriptEvent2 92 aScripts(1) = aScriptEvent3 93 94 oObj.registerScriptEvents(0, aScripts()) 95 96 Test.MethodTested("registerScriptEvents()", bOK) 97 98 Test.StartMethod("getScriptEvents()") 99 bOK = true 100 allScripts = oObj.getScriptEvents(0) 101 bOK = bOK AND ubound(allScripts) = 2 102 bOK = bOK AND allScripts(0).ScriptCode = "MsgBox ""Script1""" 103 bOK = bOK AND allScripts(1).ScriptCode = "MsgBox ""Script2""" 104 bOK = bOK AND allScripts(2).ScriptCode = "MsgBox ""Script3""" 105 Test.MethodTested("getScriptEvents()", bOK) 106 107 Test.StartMethod("insertEntry()") 108 bOK = true 109 oObj.insertEntry(0) 110 allScripts = oObj.getScriptEvents(0) 111 bOK = bOK AND ubound(allScripts) = -1 112 allScripts = oObj.getScriptEvents(1) 113 bOK = bOK AND ubound(allScripts) = 2 114 Test.MethodTested("insertEntry()", bOK) 115 116 Test.StartMethod("removeEntry()") 117 bOK = true 118 oObj.removeEntry(0) 119 allScripts = oObj.getScriptEvents(1) 120 bOK = bOK AND ubound(allScripts) = -1 121 allScripts = oObj.getScriptEvents(0) 122 bOK = bOK AND ubound(allScripts) = 2 123 Test.MethodTested("removeEntry()", bOK) 124 125 Test.StartMethod("attach()") 126 bOK = true 127 oObj.attach(0, oObj, "") 128 Test.MethodTested("attach()", bOK) 129 130 Test.StartMethod("detach()") 131 bOK = true 132 oObj.detach(0, oObj) 133 Test.MethodTested("detach()", bOK) 134 135 136 Test.StartMethod("revokeScriptEvent()") 137 bOK = true 138 oObj.revokeScriptEvent(0, "ScriptListener", "Test", "") 139 allScripts = oObj.getScriptEvents(0) 140 bOK = bOK AND ubound(allScripts) = 1 141 Test.MethodTested("revokeScriptEvent()", bOK) 142 143 Test.StartMethod("revokeScriptEvents()") 144 bOK = true 145 oObj.revokeScriptEvents(0) 146 allScripts = oObj.getScriptEvents(0) 147 bOK = bOK AND ubound(allScripts) = -1 148 Test.MethodTested("revokeScriptEvents()", bOK) 149 150 Test.StartMethod("removeScriptListener()") 151 bOK = true 152 oObj.removeScriptListener(oListener) 153 Test.MethodTested("removeScriptListener()", bOK) 154 155Exit Sub 156ErrHndl: 157 Test.Exception() 158 bOK = false 159 resume next 160End Sub 161</script:module> 162