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="form_XFormController" 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 otherWin As Object 39 40'************************************************************************* 41 42 43 44 45 46 47Sub RunTest() 48 49'************************************************************************* 50' INTERFACE: 51' com.sun.star.form.XFormController 52'************************************************************************* 53On Error Goto ErrHndl 54 Dim bOK As Boolean 55 Dim cntrl As Object 56 Dim list1 As Object, list2 As Object 57 58 Test.StartMethod("getCurrentControl()") 59 bOK = true 60 cntrl = oObj.getCurrentControl() 61 bOK = bOK AND NOT isNull(cntrl) 62 Test.MethodTested("getCurrentControl()", bOK) 63 64 Test.StartMethod("addActivateListener()") 65 bOK = true 66 list1 = createUnoListener("L1_", "com.sun.star.form.XFormControllerListener") 67 list2 = createUnoListener("L2_", "com.sun.star.form.XFormControllerListener") 68 oObj.addActivateListener(list1) 69 oObj.addActivateListener(list2) 70 71 Test.StartMethod("removeActivateListener()") 72 oObj.removeActivateListener(list1) 73 74 if NOT hasUnoInterfaces(cntrl, "com.sun.star.awt.XWindow") then 75 Out.Log("The oObj.getCurrentControl() return object doesn't support") 76 Out.Log("com.sun.star.awt.XWindow interface required for testing !!!") 77 Out.Log("Interface test must be redesigned thus !!!") 78 else 79 cntrl.setFocus() 80 wait(500) 81 otherWin.setFocus() 82 wait(500) 83 end if 84 85 Test.MethodTested("addActivateListener()", L2called) 86 Test.MethodTested("removeActivateListener()", _ 87 L2called AND NOT L1called) 88 89Exit Sub 90ErrHndl: 91 Test.Exception() 92 bOK = false 93 resume next 94End Sub 95 96Dim L1called As Boolean 97Dim L2called As Boolean 98 99Sub L1_formActivated(ev As Object) 100 L1called = true 101 Out.Log("L1 activated Called !!!!!!!!!") 102end Sub 103 104Sub L1_formDeactivated(ev As Object) 105 L1called = true 106 Out.Log("L1 deactivated Called !!!!!!!!!") 107end Sub 108 109Sub L2_formActivated() 110 L2called = true 111 Out.Log("L2 activated Called !!!!!!!!!") 112end Sub 113 114Sub L2_formDeactivated() 115 L2called = true 116 Out.Log("L2 deactivated Called !!!!!!!!!") 117end Sub 118</script:module> 119