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_XDispatchRecorder" 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 dispRecFrame As Object 39 40'************************************************************************* 41 42 43 44 45 46Sub RunTest() 47 48'************************************************************************* 49' INTERFACE: 50' com.sun.star.frame.XDispatchRecorder 51'************************************************************************* 52On Error Goto ErrHndl 53 Dim bOK As Boolean 54 55 Test.StartMethod("startRecording()") 56 bOK = true 57 oObj.startRecording(dispRecFrame) 58 Test.MethodTested("startRecording()", bOK) 59 60 Test.StartMethod("endRecording()") 61 bOK = true 62 Dim dispURL As com.sun.star.util.URL 63 dispURL = parseURL(".uno:InsertText") 64 Dim dispArgs(0) As new com.sun.star.beans.PropertyValue 65 dispArgs(0).Name = "Text" 66 dispArgs(0).Value = "XDispatchRecorder.endRecording()" 67 Out.log("Dispatching event for frame ...") 68 Dim disp As Object 69 disp = dispRecFrame.queryDispatch(dispURL, "", 0) 70 disp.dispatch(dispURL, dispArgs()) 71 wait(2000) 72 Out.log("Ending record ...") 73 oObj.endRecording() 74 Out.log("Getting macro ... :") 75 Dim macro As String 76 macro = oObj.getRecordedMacro() 77 Out.log("'" + macro + "'") 78 if (len(macro) <> 0) then 79 bOK = instr(macro, dispURL.Complete) > -1 and _ 80 instr(macro, dispArgs(0).Value) > -1 81 if (Not bOK) then 82 Out.log("Dispatch URL '" + dispURL.Complete _ 83 + "' or its argument '" + dispArgs(0).Value _ 84 + "' was not found in macro returned - FAILED") 85 end if 86 else 87 bOK = false 88 end if 89 Test.MethodTested("endRecording()", bOK) 90 91 Test.StartMethod("recordDispatch()") 92 bOK = true 93 Out.log("Recording dispatch ...") 94 oObj.recordDispatch(dispURL, dispArgs()) 95 Out.log("Getting macro ... :") 96 macro = oObj.getRecordedMacro() 97 Out.log("'" + macro + "'") 98 if (len(macro) <> 0) then 99 bOK = instr(macro, dispURL.Complete) > -1 and _ 100 instr(macro, dispArgs(0).Value) > -1 101 if (Not bOK) then 102 Out.log("Dispatch URL '" + dispURL.Complete _ 103 + "' or its argument '" + dispArgs(0).Value _ 104 + "' was not found in macro returned - FAILED") 105 end if 106 else 107 bOK = false 108 end if 109 Test.MethodTested("recordDispatch()", bOK) 110 111 Test.StartMethod("recordDispatchAsComment()") 112 bOK = true 113 Out.log("Recording dispatch ...") 114 oObj.recordDispatchAsComment(dispURL, dispArgs()) 115 Out.log("Getting macro ... :") 116 macro = oObj.getRecordedMacro() 117 Out.log("'" + macro + "'") 118 if (len(macro) <> 0) then 119 bOK = instr(macro, dispURL.Complete) > -1 and _ 120 instr(macro, dispArgs(0).Value) > -1 121 if (Not bOK) then 122 Out.log("Dispatch URL '" + dispURL.Complete _ 123 + "' or its argument '" + dispArgs(0).Value _ 124 + "' was not found in macro returned - FAILED") 125 end if 126 else 127 bOK = false 128 end if 129 Test.MethodTested("recordDispatchAsComment()", bOK) 130 131 Test.StartMethod("getRecordedMacro()") 132 bOK = true 133 Test.MethodTested("getRecordedMacro()", bOK) 134Exit Sub 135ErrHndl: 136 Test.Exception() 137 bOK = false 138 resume next 139End Sub 140 141Function parseURL(complURL As String) As com.sun.star.util.URL 142 Dim url As new com.sun.star.util.URL 143 url.Complete = complURL 144 Dim urlTrans As Object 145 urlTrans = createUnoService("com.sun.star.util.URLTransformer") 146 urlTrans.parseStrict(url) 147 parseURL = url 148End Function 149</script:module> 150