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_XDispatchProvider" 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
51Sub RunTest()
52
53'*************************************************************************
54' INTERFACE:
55' com.sun.star.frame.XDispatchProvider
56'*************************************************************************
57On Error Goto ErrHndl
58    Dim bOK As Boolean
59    Dim url As new com.sun.star.util.URL
60    Dim dispatcher As Object
61    Dim descriptors(1) As new com.sun.star.frame.DispatchDescriptor
62    Dim dispatchers As Variant
63
64    Out.Log("Using Url for dispatch : " + dispatchUrl)
65
66    url.Complete = dispatchUrl
67
68    Dim oURLTransformer As Object
69    oURLTransformer = createUnoService("com.sun.star.util.URLTransformer")
70    Dim aUrl As Variant
71    aUrl = Array(url)
72    oURLTransformer.parseStrict(aUrl)
73
74    Test.StartMethod("queryDispatch()")
75    dispatcher = oObj.queryDispatch(aUrl(0), "frame", _
76        com.sun.star.frame.FrameSearchFlag.ALL)
77    bOK = NOT isNull(dispatcher)
78    Out.Log("Dispatch is null : " + isNull(dispatcher))
79    bOK = bOK AND hasUnoInterfaces(dispatcher, "com.sun.star.frame.XDispatch")
80    Test.MethodTested("queryDispatch()", bOK)
81
82    Test.StartMethod("queryDispatches()")
83    bOK = true
84    descriptors(0).FeatureURL = url
85    descriptors(0).FrameName = "Frame1"
86    descriptors(0).SearchFlags = com.sun.star.frame.FrameSearchFlag.ALL
87    descriptors(1).FeatureURL = url
88    descriptors(1).FrameName = "Frame2"
89    descriptors(1).SearchFlags = com.sun.star.frame.FrameSearchFlag.ALL
90    dispatchers = oObj.queryDispatches(descriptors())
91    if isArray(dispatchers) then
92       if ubound(descriptors()) &lt;&gt; ubound(dispatchers()) then
93          bOK = false
94          Out.Log("Number of returned dispatchers : " + _
95              ubound(dispatchers()) + " - FAILED")
96       endIf
97    else
98       bOK = false
99       Out.Log("Returned value is not Array")
100    EndIf
101
102    Test.MethodTested("queryDispatches()", bOK)
103
104Exit Sub
105ErrHndl:
106    Test.Exception()
107    bOK = false
108    resume next
109End Sub
110</script:module>
111