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' 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' Be sure that all variables are dimensioned: 38option explicit 39 40'************************************************************************* 41' This Interface/Service test depends on the following GLOBAL variables, 42' which must be specified in the object creation: 43 44' - Global dispatchURL As String 45 46'************************************************************************* 47 48 49 50 51 52 53Sub RunTest() 54 55'************************************************************************* 56' INTERFACE: 57' com.sun.star.frame.XDispatch 58'************************************************************************* 59On Error Goto ErrHndl 60 Dim bOK As Boolean 61 Dim listener1 As Object, listener2 As Object 62 Dim URL As New com.sun.star.util.URL 63 64 URL.Complete = dispatchURL 65 66 Out.Log("Dispatch URL is '" + dispatchURL + "'") 67 if isNull(oObj) then Out.Log("Component is NULL !!!!") 68 69 Test.StartMethod("addStatusListener()") 70 listener1 = createUnoListener("SL1_", "com.sun.star.frame.XStatusListener") 71 listener2 = createUnoListener("SL2_", "com.sun.star.frame.XStatusListener") 72 73 if NOT(isNull(listener1) OR isNull(listener2)) then 74 Out.Log("Listeners were created") 75 else 76 Out.Log("Listeners were NOT created !!!") 77 EndIf 78 79 oObj.addStatusListener(listener1, URL) 80 oObj.addStatusListener(listener2, URL) 81 Out.Log("Listeners were added") 82 83 Test.StartMethod("removeStatusListener()") 84 oObj.removeStatusListener(listener1, URL) 85 86 Test.StartMethod("dispatch()") 87 88 SL1Called = false 89 SL2Called = false 90 91 Out.Log("Dispatching ...") 92 oObj.dispatch(URL, DimArray()) 93 wait(500) 94 Out.Log("Dispatched.") 95 Test.MethodTested("dispatch()", true) 96 97 bOK = SL2Called 98 Test.MethodTested("addStatusListener()", bOK) 99 bOK = bOK AND NOT SL1Called 100 Test.MethodTested("removeStatusListener()", bOK) 101 102Exit Sub 103ErrHndl: 104 Test.Exception() 105 bOK = false 106 resume next 107End Sub 108 109Dim SL1Called As Boolean 110Dim SL2Called As Boolean 111 112Sub SL1_StatusChanged(ev As Variant) 113 SL1Called = true 114 Out.Log("SL1_StatusChanged() called.") 115End Sub 116 117Sub SL2_StatusChanged(ev As Variant) 118 SL2Called = true 119 Out.Log("SL2_StatusChanged() called.") 120End Sub 121</script:module> 122