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_OPatternModel" 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.OPatternModel
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("PatternField", 1000, 1000, 2000, 1000)
64    oObj = oShape.getControl()
65    oShape = toolkittools.addControlToDefaultForm("PatternField", 1000, 3000, 2000, 1000)
66    oComponentInstance = oShape.getControl()
67    oShape = toolkittools.addControlToDefaultForm("TextField", 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 = "Author"
79
80    oForm.load()
81
82    ' for XUpdateBroadcaster
83    bCustomUpdate = true
84
85Exit Sub
86ErrHndl:
87    Test.Exception()
88End Sub
89
90Global sChangedText As String
91
92' for XBoundComponent
93Sub prepareCommit()
94On Error Goto ErrHndl
95    Out.Log("prepareCommit() called.")
96    sChangedText = "_" + oObj.Text
97    oObj.Text = sChangedText
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 rowText As Variant
109
110    rowText = oForm.getString(oForm.findColumn("Author"))
111    checkCommit() = (rowText = sChangedText)
112
113    exit function
114ErrHndl:
115    Test.Exception()
116End Function
117
118' for XUpdateBroadcaster
119Sub UpdateComponent()
120    oObj.Text = "_" + oObj.Text
121    oObj.commit()
122End Sub
123</script:module>
124