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