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="awt_XCheckBox" 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 35Dim bIL_itemStateChanged As Boolean 36 37 38Sub RunTest() 39 40'************************************************************************* 41' INTERFACE: 42' com.sun.star.awt.XCheckBox 43'************************************************************************* 44On Error Goto ErrHndl 45 Dim bOK As Boolean 46 Dim oListener As Object 47 48 bIL_itemStateChanged = False 49 out.log("create listener for item events") 50 oListener = createUnoListener("IL_", "com.sun.star.awt.XItemListener") 51 52 Test.StartMethod("addItemListener()") 53 oObj.addItemListener(oListener) 54 out.log("Can be checked only interactively !!!") 55 bOK = True 56 Test.MethodTested("addItemListener()", bOK) 57 58 Test.StartMethod("removeItemListener()") 59 oObj.removeItemListener(oListener) 60 bOK = True 61 Test.MethodTested("removeItemListener()", bOK) 62 63 Test.StartMethod("getState()") 64 Test.StartMethod("setState()") 65 Dim state, newState As Integer 66 state = oObj.getState() 67 Out.Log("current state of check-box: " + state) 68 newState = 0 69 If state = 0 Then 70 newState = 1 71 EndIf 72 Out.Log("set new state: " + newState) 73 oObj.setState(newState) 74 bOK = (newState = oObj.getState()) 75 Test.MethodTested("getState()", bOK) 76 Test.MethodTested("setState()", bOK) 77 78 Test.StartMethod("setLabel()") 79 oObj.setLabel("XCheckBox test") 80 bOK = true 81 Test.MethodTested("setLabel()", bOK) 82 83 Test.StartMethod("enableTriState()") 84 oObj.enableTriState(True) 85 bOK = true 86 Test.MethodTested("enableTriState()", bOK) 87 88Exit Sub 89ErrHndl: 90 Test.Exception() 91 bOK = false 92 resume next 93End Sub 94 95Sub IL_disposing 96End Sub 97 98Sub IL_itemStateChanged 99 Out.Log("CallBack for ItemListener itemStateChanged was called.") 100 bIL_itemStateChanged = true 101End Sub 102</script:module> 103