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="forms_OCheckBoxControl" 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 36' REQUIRED VARIABLES for interface/service tests: 37 38' Required for com.sun.star.awt.XView: 39 Global oGraphics as Object 40 41' Required for com.sun.star.lang.XComponent: 42 Global oComponentInstance As Object ' it will be disposed 43 44' Required for com.sun.star.awt.XControl: 45 Global oContext As Object 46 Global oWinpeer As Object 47 Global oToolkit As Object 48 Global oModel As Object 49 50' Required for com.sun.star.awt.XWindow: 51 Global oXWindow as Object 52 Global oCtrlShape As Variant 53 54' Required for awt.XItemListener 55 Global bIL_itemStateChanged As Boolean 56 Global oEventItemListener As Object 57 58 59Sub CreateObj() 60 61'************************************************************************* 62' COMPONENT: 63' forms.OCheckBoxControl 64'************************************************************************* 65On Error Goto ErrHndl 66 67 Dim bOK As Boolean 68 Dim oShape1 As Object 69 Dim oShape2 As Object 70 Dim oShape3 As Object 71 Dim oCurrCtrl As Object 72 Dim oWin As Object 73 Dim oKit As Object 74 Dim oDevice As Object 75 Dim oDoc2 As Object 76 Dim oIListener As Object 77 78 bOK = true 79 80 oDoc = utils.createDocument("swriter", cObjectName) 81' oDoc2 = utils.createDocument("swriter", cObjectName + "2") 82 83 oShape1 = toolkittools.addControlToDefaultForm("CheckBox", 1000, 1000, 2000, 1000) 84 oShape2 = toolkittools.addControlToDefaultForm("CheckBox", 1000, 3000, 2000, 1000) 85 oShape3 = toolkittools.addControlToDefaultForm("TextField", 1000, 5000, 2000, 1000) 86 87 oModel = oShape1.getControl() 88 oCurrCtrl = oDoc.getCurrentController() 89 oWin = oCurrCtrl.getControl(oModel).getPeer() 90 oKit = oWin.getToolkit() 91 oDevice = oKit.createScreenCompatibleDevice(200,200) 92 oGraphics = oDevice.createGraphics() 93 94 oObj = oCurrCtrl.getControl(oModel) 95 oComponentInstance = oCurrCtrl.getControl(oShape2.getControl()) 96 oContext = oDoc 97 oWinpeer = oWin 98 oToolkit = oKit 99 oXWindow = oCurrCtrl.getControl(oShape3.getControl()) 100 oCtrlShape = oShape1 101 102 oIListener = createUnoListener("IL_", "com.sun.star.awt.XItemListener") 103 oObj.addItemListener(oIListener) 104 105Exit Sub 106ErrHndl: 107 Test.Exception() 108End Sub 109 110Sub IL_itemStateChanged(rEvent As Object) 111 bIL_itemStateChanged = True 112 Out.Log("CallBack for ItemListener itemStateChanged was called.") 113 oEventItemListener = rEvent 114End Sub 115 116 117'Sub DisposeObj() 118' 'Re-open this document to close it successfully 119' oDoc2 = utils.createDocument("swriter", cObjectName + "2") 120' oDoc2.Dispose() 121'End Sub 122</script:module> 123