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_ORadioButtonModel" 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' REQUIRED VARIABLES for interface/service tests: 36 37' for XComponent 38Global oComponentInstance As Object 39 40' for XPersistObject 41Global oPersistInstance As Object 42 43' for XUpdateBroadcaster 44Global bCustomUpdate As Boolean 45 46Global oForm As Object 47 48 49Sub CreateObj() 50 51'************************************************************************* 52' COMPONENT: 53' forms.ORadioButtonModel 54'************************************************************************* 55On Error Goto ErrHndl 56 Dim bOK As Boolean 57 Dim oShape As Object, oDrawPage As Object 58 59 bOK = true 60 61 oDoc = utils.createDocument("swriter", cObjectName) 62 63 oShape = toolkittools.addControlToDefaultForm("RadioButton", 1000, 1000, 2000, 1000) 64 oObj = oShape.getControl() 65 oShape = toolkittools.addControlToDefaultForm("RadioButton", 1000, 3000, 2000, 1000) 66 oComponentInstance = oShape.getControl() 67 oShape = toolkittools.addControlToDefaultForm("RadioButton", 1000, 5000, 2000, 1000) 68 oPersistInstance = oShape.getControl() 69 70 'get control from document 71 oDrawPage = oDoc.DrawPage 72 oForm = oDrawPage.Forms.getByName("Standard") 73 74 oForm.DataSourceName = "Bibliography" 75 oForm.Command = "biblio" 76 oForm.CommandType = com.sun.star.sdb.CommandType.TABLE 77 78 oObj.DataField = "Custom3" 79 80 oForm.load() 81 82 ' for XUpdateBroadcaster 83 bCustomUpdate = true 84 85Exit Sub 86ErrHndl: 87 Test.Exception() 88End Sub 89 90Global aChangedVal As String 91 92' for XBoundComponent 93Sub prepareCommit() 94On Error Goto ErrHndl 95 Out.Log("prepareCommit() called.") 96 aChangedVal = 1 - oObj.State 97 oObj.State = aChangedVal 98 99 exit sub 100ErrHndl: 101 Test.Exception() 102End Sub 103 104' for XBoundComponent 105Function checkCommit() As Boolean 106On Error Goto ErrHndl 107 Out.Log("checkCommit() called.") 108 Dim rowVal As Variant 109 110 rowVal = oForm.getBoolean(oForm.findColumn("Custom3")) 111 if rowVal = true then 112 checkCommit() = (aChangedVal = 1) 113 else 114 checkCommit() = (aChangedVal = 0) 115 end if 116 117 exit function 118ErrHndl: 119 Test.Exception() 120End Function 121 122' for XUpdateBroadcaster 123Sub UpdateComponent() 124 oObj.State = 1 - oObj.State 125 oObj.commit() 126End Sub 127</script:module> 128