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_ONumericModel" 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.ONumericModel
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("NumericField", 1000, 1000, 2000, 1000)
64    oObj = oShape.getControl()
65    oShape = toolkittools.addControlToDefaultForm("NumericField", 1000, 3000, 2000, 1000)
66    oComponentInstance = oShape.getControl()
67    oShape = toolkittools.addControlToDefaultForm("TextField", 1000, 5000, 2000, 1000)
68    oPersistInstance = oShape.getControl()
69
70    oDrawPage = oDoc.DrawPage
71    oForm = oDrawPage.Forms.getByName("Standard")
72
73	oForm.DataSourceName = "Bibliography"
74	oForm.Command = "biblio"
75	oForm.CommandType = com.sun.star.sdb.CommandType.TABLE
76
77    oObj.DataField = "Pages"
78
79    oForm.load()
80
81    ' for XUpdateBroadcaster
82    bCustomUpdate = true
83
84Exit Sub
85ErrHndl:
86    Test.Exception()
87End Sub
88
89Global nChangedVal As Variant
90
91' for XBoundComponent
92Sub prepareCommit()
93On Error Goto ErrHndl
94    Out.Log("prepareCommit() called.")
95    nChangedVal = oObj.Value + 1
96    oObj.Value = nChangedVal
97
98    exit sub
99ErrHndl:
100    Test.Exception()
101End Sub
102
103' for XBoundComponent
104Function checkCommit() As Boolean
105On Error Goto ErrHndl
106    Out.Log("checkCommit() called.")
107    Dim rowVal As Variant
108
109    rowVal = oForm.getInt(oForm.findColumn("Pages"))
110    checkCommit() = (rowVal = nChangedVal)
111
112    exit function
113ErrHndl:
114    Test.Exception()
115End Function
116
117' for XUpdateBroadcaster
118Sub UpdateComponent()
119    oObj.Value = oObj.Value + 1
120    oObj.commit()
121End Sub
122</script:module>
123