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_OCurrencyModel" 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' Be sure that all variables are dimensioned:
37option explicit
38
39
40' REQUIRED VARIABLES for interface/service tests:
41
42' for XComponent
43Global oComponentInstance As Object
44
45' for XPersistObject
46Global oPersistInstance As Object
47
48' for XUpdateBroadcaster
49Global bCustomUpdate As Boolean
50
51Global oForm As Object
52
53
54Sub CreateObj()
55
56'*************************************************************************
57' COMPONENT:
58' forms.OCurrencyModel
59'*************************************************************************
60On Error Goto ErrHndl
61
62    Dim bOK As Boolean
63    Dim oShape As Object, oDrawPage As Object
64
65    bOK = true
66' --- create a document if needed
67
68    oDoc = utils.createDocument("swriter", cObjectName)
69
70    oShape = toolkittools.addControlToDefaultForm("CurrencyField", 1000, 1000, 2000, 1000)
71    oObj = oShape.getControl()
72    oShape = toolkittools.addControlToDefaultForm("CurrencyField", 1000, 3000, 2000, 1000)
73    oComponentInstance = oShape.getControl()
74    oShape = toolkittools.addControlToDefaultForm("CurrencyField", 1000, 5000, 2000, 1000)
75    oPersistInstance = oShape.getControl()
76
77    'get control from document
78    oDrawPage = oDoc.DrawPage
79    oForm = oDrawPage.Forms.getByName("Standard")
80
81	oForm.DataSourceName = "Bibliography"
82	oForm.Command = "biblio"
83	oForm.CommandType = com.sun.star.sdb.CommandType.TABLE
84
85    oObj.DataField = "Pages"
86
87    oForm.load()
88
89    ' for XUpdateBroadcaster
90    bCustomUpdate = true
91
92
93Exit Sub
94ErrHndl:
95    Test.Exception()
96End Sub
97
98Global aChangedValue As Double
99
100' for XBoundComponent
101Sub prepareCommit()
102On Error Goto ErrHndl
103    Out.Log("prepareCommit() called.")
104    if NOT (isNull(oObj.Value) OR isEmpty(oObj.Value)) then
105        aChangedValue = oObj.Value + 1
106    else
107        aChangedValue = 1
108    end if
109    oObj.Value = aChangedValue
110
111    exit sub
112ErrHndl:
113    Test.Exception()
114End Sub
115
116' for XBoundComponent
117Function checkCommit() As Boolean
118On Error Goto ErrHndl
119    Out.Log("checkCommit() called.")
120    Dim rowValue As Variant
121
122    rowValue = oForm.getDouble(oForm.findColumn("Pages"))
123    Out.Log("Value was set to " + aChangedValue )
124    Out.Log("the value in current row is " + rowValue)
125    checkCommit() = (rowValue = aChangedValue)
126
127    exit function
128ErrHndl:
129    Test.Exception()
130End Function
131
132' for XUpdateBroadcaster
133Sub UpdateComponent()
134    oObj.Value = oObj.Value + 1
135    oObj.commit()
136End Sub
137</script:module>
138