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