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