merge the formfield patch from ooo-build
[ooovba.git] / qadevOOo / tests / basic / mod / forms / OCurrencyModel / forms_OCurrencyModel.xba
blob365250ef61565ee9b81b1651e5a647f86a5b2dfb
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">
6 '*************************************************************************
8 ' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
9 '
10 ' Copyright 2008 by Sun Microsystems, Inc.
12 ' OpenOffice.org - a multi-platform office productivity suite
14 ' $RCSfile: forms_OCurrencyModel.xba,v $
16 ' $Revision: 1.3 $
18 ' This file is part of OpenOffice.org.
20 ' OpenOffice.org is free software: you can redistribute it and/or modify
21 ' it under the terms of the GNU Lesser General Public License version 3
22 ' only, as published by the Free Software Foundation.
24 ' OpenOffice.org is distributed in the hope that it will be useful,
25 ' but WITHOUT ANY WARRANTY; without even the implied warranty of
26 ' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 ' GNU Lesser General Public License version 3 for more details
28 ' (a copy is included in the LICENSE file that accompanied this code).
30 ' You should have received a copy of the GNU Lesser General Public License
31 ' version 3 along with OpenOffice.org. If not, see
32 ' <http://www.openoffice.org/license.html>
33 ' for a copy of the LGPLv3 License.
35 '*************************************************************************
36 '*************************************************************************
40 ' Be sure that all variables are dimensioned:
41 option explicit
44 ' REQUIRED VARIABLES for interface/service tests:
46 ' for XComponent
47 Global oComponentInstance As Object
49 ' for XPersistObject
50 Global oPersistInstance As Object
52 ' for XUpdateBroadcaster
53 Global bCustomUpdate As Boolean
55 Global oForm As Object
58 Sub CreateObj()
60 '*************************************************************************
61 ' COMPONENT:
62 ' forms.OCurrencyModel
63 '*************************************************************************
64 On Error Goto ErrHndl
66 Dim bOK As Boolean
67 Dim oShape As Object, oDrawPage As Object
69 bOK = true
70 ' --- create a document if needed
72 oDoc = utils.createDocument("swriter", cObjectName)
74 oShape = toolkittools.addControlToDefaultForm("CurrencyField", 1000, 1000, 2000, 1000)
75 oObj = oShape.getControl()
76 oShape = toolkittools.addControlToDefaultForm("CurrencyField", 1000, 3000, 2000, 1000)
77 oComponentInstance = oShape.getControl()
78 oShape = toolkittools.addControlToDefaultForm("CurrencyField", 1000, 5000, 2000, 1000)
79 oPersistInstance = oShape.getControl()
81 'get control from document
82 oDrawPage = oDoc.DrawPage
83 oForm = oDrawPage.Forms.getByName("Standard")
85 oForm.DataSourceName = "Bibliography"
86 oForm.Command = "biblio"
87 oForm.CommandType = com.sun.star.sdb.CommandType.TABLE
89 oObj.DataField = "Pages"
91 oForm.load()
93 ' for XUpdateBroadcaster
94 bCustomUpdate = true
97 Exit Sub
98 ErrHndl:
99 Test.Exception()
100 End Sub
102 Global aChangedValue As Double
104 ' for XBoundComponent
105 Sub prepareCommit()
106 On Error Goto ErrHndl
107 Out.Log("prepareCommit() called.")
108 if NOT (isNull(oObj.Value) OR isEmpty(oObj.Value)) then
109 aChangedValue = oObj.Value + 1
110 else
111 aChangedValue = 1
112 end if
113 oObj.Value = aChangedValue
115 exit sub
116 ErrHndl:
117 Test.Exception()
118 End Sub
120 ' for XBoundComponent
121 Function checkCommit() As Boolean
122 On Error Goto ErrHndl
123 Out.Log("checkCommit() called.")
124 Dim rowValue As Variant
126 rowValue = oForm.getDouble(oForm.findColumn("Pages"))
127 Out.Log("Value was set to " + aChangedValue )
128 Out.Log("the value in current row is " + rowValue)
129 checkCommit() = (rowValue = aChangedValue)
131 exit function
132 ErrHndl:
133 Test.Exception()
134 End Function
136 ' for XUpdateBroadcaster
137 Sub UpdateComponent()
138 oObj.Value = oObj.Value + 1
139 oObj.commit()
140 End Sub
141 </script:module>