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="frame_XDispatch" script:language="StarBasic"> 4 5 6 '************************************************************************* 7 ' 8 ' Licensed to the Apache Software Foundation (ASF) under one 9 ' or more contributor license agreements. See the NOTICE file 10 ' distributed with this work for additional information 11 ' regarding copyright ownership. The ASF licenses this file 12 ' to you under the Apache License, Version 2.0 (the 13 ' "License"); you may not use this file except in compliance 14 ' with the License. You may obtain a copy of the License at 15 ' 16 ' http://www.apache.org/licenses/LICENSE-2.0 17 ' 18 ' Unless required by applicable law or agreed to in writing, 19 ' software distributed under the License is distributed on an 20 ' "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 21 ' KIND, either express or implied. See the License for the 22 ' specific language governing permissions and limitations 23 ' under the License. 24 ' 25 '************************************************************************* 26 27 28 29 30 31 ' Be sure that all variables are dimensioned: 32 option explicit 33 34 '************************************************************************* 35 ' This Interface/Service test depends on the following GLOBAL variables, 36 ' which must be specified in the object creation: 37 38 ' - Global dispatchURL As String 39 40 '************************************************************************* 41 42 43 44 45 46 47 Sub RunTest() 48 49 '************************************************************************* 50 ' INTERFACE: 51 ' com.sun.star.frame.XDispatch 52 '************************************************************************* 53 On Error Goto ErrHndl 54 Dim bOK As Boolean 55 Dim listener1 As Object, listener2 As Object 56 Dim URL As New com.sun.star.util.URL 57 58 URL.Complete = dispatchURL 59 60 Out.Log("Dispatch URL is '" + dispatchURL + "'") 61 if isNull(oObj) then Out.Log("Component is NULL !!!!") 62 63 Test.StartMethod("addStatusListener()") 64 listener1 = createUnoListener("SL1_", "com.sun.star.frame.XStatusListener") 65 listener2 = createUnoListener("SL2_", "com.sun.star.frame.XStatusListener") 66 67 if NOT(isNull(listener1) OR isNull(listener2)) then 68 Out.Log("Listeners were created") 69 else 70 Out.Log("Listeners were NOT created !!!") 71 EndIf 72 73 oObj.addStatusListener(listener1, URL) 74 oObj.addStatusListener(listener2, URL) 75 Out.Log("Listeners were added") 76 77 Test.StartMethod("removeStatusListener()") 78 oObj.removeStatusListener(listener1, URL) 79 80 Test.StartMethod("dispatch()") 81 82 SL1Called = false 83 SL2Called = false 84 85 Out.Log("Dispatching ...") 86 oObj.dispatch(URL, DimArray()) 87 wait(500) 88 Out.Log("Dispatched.") 89 Test.MethodTested("dispatch()", true) 90 91 bOK = SL2Called 92 Test.MethodTested("addStatusListener()", bOK) 93 bOK = bOK AND NOT SL1Called 94 Test.MethodTested("removeStatusListener()", bOK) 95 96 Exit Sub 97 ErrHndl: 98 Test.Exception() 99 bOK = false 100 resume next 101 End Sub 102 103 Dim SL1Called As Boolean 104 Dim SL2Called As Boolean 105 106 Sub SL1_StatusChanged(ev As Variant) 107 SL1Called = true 108 Out.Log("SL1_StatusChanged() called.") 109 End Sub 110 111 Sub SL2_StatusChanged(ev As Variant) 112 SL2Called = true 113 Out.Log("SL2_StatusChanged() called.") 114 End Sub 115 </script:module> 116