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