1cdf0e10cSrcweir<?xml version="1.0" encoding="UTF-8"?>
2cdf0e10cSrcweir<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
3*3e02b54dSAndrew Rist<!--***********************************************************
4*3e02b54dSAndrew Rist *
5*3e02b54dSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
6*3e02b54dSAndrew Rist * or more contributor license agreements.  See the NOTICE file
7*3e02b54dSAndrew Rist * distributed with this work for additional information
8*3e02b54dSAndrew Rist * regarding copyright ownership.  The ASF licenses this file
9*3e02b54dSAndrew Rist * to you under the Apache License, Version 2.0 (the
10*3e02b54dSAndrew Rist * "License"); you may not use this file except in compliance
11*3e02b54dSAndrew Rist * with the License.  You may obtain a copy of the License at
12*3e02b54dSAndrew Rist *
13*3e02b54dSAndrew Rist *   http://www.apache.org/licenses/LICENSE-2.0
14*3e02b54dSAndrew Rist *
15*3e02b54dSAndrew Rist * Unless required by applicable law or agreed to in writing,
16*3e02b54dSAndrew Rist * software distributed under the License is distributed on an
17*3e02b54dSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18*3e02b54dSAndrew Rist * KIND, either express or implied.  See the License for the
19*3e02b54dSAndrew Rist * specific language governing permissions and limitations
20*3e02b54dSAndrew Rist * under the License.
21*3e02b54dSAndrew Rist *
22*3e02b54dSAndrew Rist ***********************************************************-->
23cdf0e10cSrcweir<script:module xmlns:script="http://openoffice.org/2000/script" script:name="FormWizard" script:language="StarBasic">Option Explicit
24cdf0e10cSrcweir
25cdf0e10cSrcweirPublic DocumentName as String
26cdf0e10cSrcweirPublic FormPath as String
27cdf0e10cSrcweirPublic WizardPath as String
28cdf0e10cSrcweirPublic WebWizardPath as String
29cdf0e10cSrcweirPublic WorkPath as String
30cdf0e10cSrcweirPublic TempPath as String
31cdf0e10cSrcweirPublic TexturePath as String
32cdf0e10cSrcweirPublic sQueryName as String
33cdf0e10cSrcweirPublic oDBConnection as Object
34cdf0e10cSrcweirPublic bWithBackGraphic as Boolean
35cdf0e10cSrcweirPublic bNeedFieldRefresh as Boolean
36cdf0e10cSrcweirPublic oDBForm as Object
37cdf0e10cSrcweirPublic oColumns() as Object
38cdf0e10cSrcweirPublic sDatabaseList() as String
39cdf0e10cSrcweirPublic TableNames() as String
40cdf0e10cSrcweirPublic QueryNames() as String
41cdf0e10cSrcweirPublic FieldNames() as String
42cdf0e10cSrcweirPublic ImgFieldNames() as String
43cdf0e10cSrcweirPublic oDBContext as Object
44cdf0e10cSrcweirPublic oUcb as Object
45cdf0e10cSrcweirPublic oDocInfo as Object
46cdf0e10cSrcweirPublic WidthList(15,3)
47cdf0e10cSrcweirPublic ImgWidthList(3,3)
48cdf0e10cSrcweirPublic sDBName as String
49cdf0e10cSrcweirPublic Tablename as String
50cdf0e10cSrcweirPublic Const SBSIZETEXT = &quot;The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.&quot;
51cdf0e10cSrcweirPublic bDisposeDoc as Boolean
52cdf0e10cSrcweirPublic bDebug as Boolean
53cdf0e10cSrcweir&apos;Public bStartUp as Boolean
54cdf0e10cSrcweirPublic bConnectionIsovergiven as Boolean
55cdf0e10cSrcweirPublic FormName As String
56cdf0e10cSrcweirPublic sFormUrl as String
57cdf0e10cSrcweirPublic oFormDocuments
58cdf0e10cSrcweir
59cdf0e10cSrcweir
60cdf0e10cSrcweir&apos; The macro can be called in 4 possible scenarios:
61cdf0e10cSrcweir&apos; Scenario 1. No parameters at given
62cdf0e10cSrcweir&apos; Scenario 2: Only Datasourcename is given, but no connection and no Content
63cdf0e10cSrcweir&apos; Scenario 3: a data source and a connection are given
64cdf0e10cSrcweir&apos; Scenario 4: all parameters (data source name, connection, object type and object) are given
65cdf0e10cSrcweir
66cdf0e10cSrcweirSub Main()
67cdf0e10cSrcweirDim oLocDBContext as Object
68cdf0e10cSrcweirDim oLocConnection as Object
69cdf0e10cSrcweir
70cdf0e10cSrcweir&apos; Scenario 1. No parameters at given
71cdf0e10cSrcweir	MainWithDefault()
72cdf0e10cSrcweir
73cdf0e10cSrcweir&apos; Scenario 2: Only Datasourcename is given, but no connection and no Content
74cdf0e10cSrcweir&apos;	MainWithDefault(&quot;Bibliography&quot;)
75cdf0e10cSrcweir
76cdf0e10cSrcweir&apos; Scenario 3: a data source and a connection are given
77cdf0e10cSrcweir&apos;	oLocDBContext = CreateUnoService(&quot;com.sun.star.sdb.DatabaseContext&quot;)
78cdf0e10cSrcweir&apos;	oLocConnection = oLocDBContext.GetByName(&quot;Bibliography&quot;).GetConnection(&quot;&quot;,&quot;&quot;)
79cdf0e10cSrcweir&apos;	MainWithDefault(&quot;Bibliography&quot;, oLocConnection)
80cdf0e10cSrcweir
81cdf0e10cSrcweir&apos; Scenario 4: all parameters (data source name, connection, object type and object) are given
82cdf0e10cSrcweir&apos;	oLocDBContext = CreateUnoService(&quot;com.sun.star.sdb.DatabaseContext&quot;)
83cdf0e10cSrcweir&apos;	oLocConnection = oLocDBContext.GetByName(&quot;Bibliography&quot;).GetConnection(&quot;&quot;,&quot;&quot;)
84cdf0e10cSrcweir&apos;	MainWithDefault(&quot;Bibliography&quot;, oLocConnection, com.sun.star.sdb.CommandType.TABLE, &quot;biblio&quot;)
85cdf0e10cSrcweirEnd Sub
86cdf0e10cSrcweir
87cdf0e10cSrcweir
88cdf0e10cSrcweirSub MainWithDefault(Optional DatasourceName as String, Optional oConnection as Object, Optional CommandType as Integer, Optional sContent as String)
89cdf0e10cSrcweirDim i as Integer
90cdf0e10cSrcweirDim SelCount as Integer
91cdf0e10cSrcweirDim RetValue as Integer
92cdf0e10cSrcweirDim SelList(0) as Integer
93cdf0e10cSrcweirDim LocList() as String
94cdf0e10cSrcweir	SelList(0) = 0
95cdf0e10cSrcweir	BasicLibraries.LoadLibrary(&quot;Tools&quot;)
96cdf0e10cSrcweir	BasicLibraries.LoadLibrary(&quot;WebWizard&quot;)
97cdf0e10cSrcweir	bDebug = False
98cdf0e10cSrcweir	If Not bDebug Then
99cdf0e10cSrcweir		On Local Error GoTo WIZARDERROR
100cdf0e10cSrcweir	End If
101cdf0e10cSrcweir	OpenFormDocument()
102cdf0e10cSrcweir	CurArrangement = 0
103cdf0e10cSrcweir	bControlsareCreated = False
104cdf0e10cSrcweir	bEnableBinaryOptionGroup = False
105cdf0e10cSrcweir	bDisposeDoc = True
106cdf0e10cSrcweir	MaxIndex = -1
107cdf0e10cSrcweir	If Not InitResources(&quot;Formwizard&quot;,&quot;dbw&quot;) Then
108cdf0e10cSrcweir		Exit Sub
109cdf0e10cSrcweir	End If
110cdf0e10cSrcweir	oDBContext = CreateUnoService(&quot;com.sun.star.sdb.DatabaseContext&quot;)
111cdf0e10cSrcweir	oUcb = createUnoService(&quot;com.sun.star.ucb.SimpleFileAccess&quot;)
112cdf0e10cSrcweir	If GetFormWizardPaths() = False Then
113cdf0e10cSrcweir		Exit Sub
114cdf0e10cSrcweir	End If
115cdf0e10cSrcweir	oDocument.GetCurrentController().Frame.ComponentWindow.Enable = False
116cdf0e10cSrcweir	oProgressBar.Value = 10
117cdf0e10cSrcweir	LoadLanguage()
118cdf0e10cSrcweir	oProgressBar.Value = 20
119cdf0e10cSrcweir	InitializeWidthList()
120cdf0e10cSrcweir	oProgressBar.Value = 30
121cdf0e10cSrcweir	Styles() = getListBoxArrays(oUcb, &quot;/stl&quot;)
122cdf0e10cSrcweir	CurIndex = GetCurIndex(DialogModel, Styles(), 2)
123cdf0e10cSrcweir	oProgressBar.Value = 40
124cdf0e10cSrcweir	ConfigurePageStyle()
125cdf0e10cSrcweir	oProgressBar.Value = 50
126cdf0e10cSrcweir	InitializeLabelValues()
127cdf0e10cSrcweir	bNeedFieldRefresh = True
128cdf0e10cSrcweir	SetDialogLanguage()
129cdf0e10cSrcweir&apos;	bStartUp = true
130cdf0e10cSrcweir	With DialogModel
131cdf0e10cSrcweir		.cmdBack.Enabled = False
132cdf0e10cSrcweir		.cmdGoOn.Enabled = False
133cdf0e10cSrcweir		.lblTables.Enabled = False
134cdf0e10cSrcweir		.lstSelFields.Tag = False
135cdf0e10cSrcweir		.Step = 1
136cdf0e10cSrcweir	End With
137cdf0e10cSrcweir	oProgressBar.Value = 60
138cdf0e10cSrcweir	bConnectionIsovergiven = Not IsMissing(oConnection)
139cdf0e10cSrcweir	If Not IsMissing(DataSourceName) Then
140cdf0e10cSrcweir		sDBName = DataSourceName
141cdf0e10cSrcweir		If Not IsMissing(oConnection) Then
142cdf0e10cSrcweir			&apos; Scenario 3: a data source and a connection are given
143cdf0e10cSrcweir			Set oDBConnection = oConnection
144cdf0e10cSrcweir			oDataSource = oDBContext.GetByName(DataSourceName)
145cdf0e10cSrcweir			DialogModel.lstTables.Enabled = True
146cdf0e10cSrcweir			DialogModel.lblTables.Enabled = True
147cdf0e10cSrcweir			If GetDBMetaData() Then
148cdf0e10cSrcweir				LocList() = AddListToList(TableNames(), QueryNames())
149cdf0e10cSrcweir				iCommandTypes = CreateCommandTypeList()
150cdf0e10cSrcweir				If Not IsMissing(sContent) Then
151cdf0e10cSrcweir					&apos; Scenario 4: all parameters (data source name, connection, object type and object) are given
152cdf0e10cSrcweir					DialogModel.lstTables.StringItemList() = LocList()
153cdf0e10cSrcweir					iCommandTypes() = CreateCommandTypeList()
154cdf0e10cSrcweir					SelCount = CountItemsInArray(DialogModel.lstTables.StringItemList(), sContent)
155cdf0e10cSrcweir					If SelCount = 1 Then
156cdf0e10cSrcweir						DlgFormDB.GetControl(&quot;lstTables&quot;).SelectItem(sContent, True)
157cdf0e10cSrcweir					Else
158cdf0e10cSrcweir						If CommandType = com.sun.star.sdb.CommandType.QUERY Then
159cdf0e10cSrcweir							SelIndex = IndexInArray(sContent, QueryNames()
160cdf0e10cSrcweir							DlgFormDB.GetControl(&quot;lstTables&quot;).SelectItemPos(SelIndex, True)
161cdf0e10cSrcweir						ElseIf CommandType = com.sun.star.sdb.CommandType.TABLE Then
162cdf0e10cSrcweir							SelIndex = IndexInArray(sContent, TableNames()
163cdf0e10cSrcweir							DlgFormDB.GetControl(&quot;lstTables&quot;).SelectItemPos(Ubound(QueryNames()+1 + SelIndex, True)
164cdf0e10cSrcweir						End If
165cdf0e10cSrcweir					End If
166cdf0e10cSrcweir					CurCommandType = CommandType
167cdf0e10cSrcweir					FillUpFieldsListbox(False)
168cdf0e10cSrcweir				Else
169cdf0e10cSrcweir					LocList() = AddListToList(Array(sSelectDBTable), LocList())
170cdf0e10cSrcweir					DialogModel.lstTables.StringItemList() = LocList()
171cdf0e10cSrcweir&apos;					bSelectContent = True
172cdf0e10cSrcweir					DialogModel.lstTables.SelectedItems() = Array(0)
173cdf0e10cSrcweir
174cdf0e10cSrcweir				End If
175cdf0e10cSrcweir			End If
176cdf0e10cSrcweir		Else
177cdf0e10cSrcweir			&apos; Scenario 2: Only Datasourcename is given, but no connection and no Content
178cdf0e10cSrcweir			GetSelectedDBMetaData(sDBName)
179cdf0e10cSrcweir		End If
180cdf0e10cSrcweir	Else
181cdf0e10cSrcweir		&apos; Scenario 1: No parameters are given
182cdf0e10cSrcweir		ToggleListboxControls(DialogModel, False)
183cdf0e10cSrcweir	End If
184cdf0e10cSrcweir	oProgressBar.Value = 80
185cdf0e10cSrcweir	bWithBackGraphic = LoadNewStyles(oDocument, DialogModel, CurIndex, Styles(CurIndex, 8), Styles(), TexturePath)
186cdf0e10cSrcweir	DlgFormDB.Title = WizardTitle(1)
187cdf0e10cSrcweir	DialogModel.lstStyles.StringItemList() = ArrayfromMultiArray(Styles, 1)
188cdf0e10cSrcweir	DialogModel.lstStyles.SelectedItems() = SelList()
189cdf0e10cSrcweir	ControlCaptionsToStandardLayout()
190cdf0e10cSrcweir	oDocument.GetCurrentController().Frame.ComponentWindow.Enable = True
191cdf0e10cSrcweir	oProgressBar.Value = 90
192cdf0e10cSrcweir	DialogModel.imgTheme.ImageURL = FormPath &amp; &quot;FormWizard_1.bmp&quot;
193cdf0e10cSrcweir	DialogModel.imgTheme.BackGroundColor = RGB(0,60,126)
194cdf0e10cSrcweir	ToggleDatabasePage(True)
195cdf0e10cSrcweir	oProgressBar.Value = 100
196cdf0e10cSrcweir	DlgFormDB.GetControl(&quot;lstTables&quot;).SetFocus()
197cdf0e10cSrcweir	oProgressbar.End
198cdf0e10cSrcweir	RetValue = DlgFormDB.Execute()
199cdf0e10cSrcweir	DlgFormDB.Dispose()
200cdf0e10cSrcweir	If bDisposeDoc Then
201cdf0e10cSrcweir		Dim aPropertyValues(2) as new com.sun.star.beans.PropertyValue
202cdf0e10cSrcweir		oFormDocuments = oDataSource.getFormDocuments()
203cdf0e10cSrcweir		DlgFormDB.Dispose()
204cdf0e10cSrcweir		oDocument.dispose()
205cdf0e10cSrcweir		Dim	bLinkExists as Boolean
206cdf0e10cSrcweir		i = 1
207cdf0e10cSrcweir		Dim FormBaseName  as String
208cdf0e10cSrcweir		FormBaseName = FormName
209cdf0e10cSrcweir		Do
210cdf0e10cSrcweir			bLinkExists = oFormDocuments.HasbyHierarchicalName(FormName)
211cdf0e10cSrcweir			If bLinkExists Then
212cdf0e10cSrcweir				i = i + 1
213cdf0e10cSrcweir				FormName = FormBaseName &amp; &quot;_&quot; &amp; i
214cdf0e10cSrcweir			End If
215cdf0e10cSrcweir		Loop Until Not bLinkExists
216cdf0e10cSrcweir		aPropertyValues(0).Name = &quot;Name&quot;
217cdf0e10cSrcweir		aPropertyValues(0).Value = FormName
218cdf0e10cSrcweir		aPropertyValues(1).Name = &quot;Parent&quot;
219cdf0e10cSrcweir		aPropertyValues(1).Value = oFormDocuments()
220cdf0e10cSrcweir		aPropertyValues(2).Name = &quot;URL&quot;
221cdf0e10cSrcweir		aPropertyValues(2).Value = sFormUrl
222cdf0e10cSrcweir		Dim oDBDocument
223cdf0e10cSrcweir		oDBDocument = oFormDocuments.createInstanceWithArguments(&quot;com.sun.star.sdb.DocumentDefinition&quot;, aPropertyValues())
224cdf0e10cSrcweir		oFormDocuments.insertbyName(FormName, oDBDocument)
225cdf0e10cSrcweir	ElseIf RetValue = 0 Then
226cdf0e10cSrcweir		RemoveNirwanaShapes()
227cdf0e10cSrcweir	End If
228cdf0e10cSrcweir	If ((Not IsNull(oDBConnection)) And (Not bConnectionIsovergiven)) Then
229cdf0e10cSrcweir		oDBConnection.Dispose()
230cdf0e10cSrcweir	End If
231cdf0e10cSrcweirWIZARDERROR:
232cdf0e10cSrcweir	If Err &lt;&gt; 0 Then
233cdf0e10cSrcweir		Msgbox(sMsgErrMsg, 16, GetProductName())
234cdf0e10cSrcweir		Resume LOCERROR
235cdf0e10cSrcweir		LOCERROR:
236cdf0e10cSrcweir	End If
237cdf0e10cSrcweirEnd Sub
238cdf0e10cSrcweir
239cdf0e10cSrcweir
240cdf0e10cSrcweirSub FormGetFields()
241cdf0e10cSrcweirDim i as Integer
242cdf0e10cSrcweir&apos;	If bSelectContent Then
243cdf0e10cSrcweir&apos;		bSelectContent = False
244cdf0e10cSrcweir&apos;		Exit Sub
245cdf0e10cSrcweir&apos;	End If
246cdf0e10cSrcweir	DeleteFirstListBoxEntry(&quot;lstTables&quot;, sSelectDBTable)
247cdf0e10cSrcweir	ToggleDatabasePage(False)
248cdf0e10cSrcweir	FillUpFieldsListbox(True)
249cdf0e10cSrcweir	ToggleDatabasePage(True)
250cdf0e10cSrcweirEnd Sub
251cdf0e10cSrcweir
252cdf0e10cSrcweir
253cdf0e10cSrcweirSub FillUpFieldsListbox(bGetCommandType as Boolean)
254cdf0e10cSrcweirDim SelIndex as Integer
255cdf0e10cSrcweirDim QueryIndex as Integer
256cdf0e10cSrcweir	If Not bDebug Then
257cdf0e10cSrcweir		On Local Error GoTo NOFIELDS
258cdf0e10cSrcweir	End If
259cdf0e10cSrcweir	SelIndex = DlgFormDB.GetControl(&quot;lstTables&quot;).getSelectedItemPos() &apos;.SelectedItems())
260cdf0e10cSrcweir	If SelIndex &gt; -1 Then
261cdf0e10cSrcweir		If bGetCommandType Then
262cdf0e10cSrcweir			CurCommandType = iCommandTypes(SelIndex)
263cdf0e10cSrcweir		End If
264cdf0e10cSrcweir		If CurCommandType = com.sun.star.sdb.CommandType.QUERY Then
265cdf0e10cSrcweir			QueryIndex = SelIndex  - Ubound(Tablenames()) - 1
266cdf0e10cSrcweir			Tablename = QueryNames(QueryIndex)
267cdf0e10cSrcweir			oColumns = oDBConnection.Queries.GetByName(TableName).Columns
268cdf0e10cSrcweir		Else
269cdf0e10cSrcweir			Tablename = Tablenames(SelIndex)
270cdf0e10cSrcweir			oColumns = oDBConnection.Tables.GetByName(Tablename).Columns
271cdf0e10cSrcweir		End If
272cdf0e10cSrcweir		If GetSpecificFieldNames() &lt;&gt; -1 Then
273cdf0e10cSrcweir			ToggleListboxControls(DialogModel, True)
274cdf0e10cSrcweir			Exit Sub
275cdf0e10cSrcweir		End If
276cdf0e10cSrcweir	End If
277cdf0e10cSrcweir	EmptyFieldsListboxes()
278cdf0e10cSrcweirNOFIELDS:
279cdf0e10cSrcweir	If Err &lt;&gt; 0 Then
280cdf0e10cSrcweir		MsgBox sMsgErrCouldNotOpenObject, 16, sMsgWizardName
281cdf0e10cSrcweir	End If
282cdf0e10cSrcweirEnd Sub
283cdf0e10cSrcweir
284cdf0e10cSrcweir
285cdf0e10cSrcweirSub PreviousStep()
286cdf0e10cSrcweir	If Not bDebug Then
287cdf0e10cSrcweir		On Local Error GoTo WIZARDERROR
288cdf0e10cSrcweir	End If
289cdf0e10cSrcweir	With DialogModel
290cdf0e10cSrcweir		.Step = 1
291cdf0e10cSrcweir		.cmdBack.Enabled = False
292cdf0e10cSrcweir		.cmdGoOn.Enabled = True
293cdf0e10cSrcweir		.lstSelFields.Tag = Not bControlsareCreated
294cdf0e10cSrcweir		.cmdGoOn.Label = sGoOn
295cdf0e10cSrcweir		.imgTheme.ImageUrl = FormPath &amp; &quot;FormWizard_1.bmp&quot;
296cdf0e10cSrcweir	End With
297cdf0e10cSrcweir	FormSetMoveRights()
298cdf0e10cSrcweirWIZARDERROR:
299cdf0e10cSrcweir	If Err &lt;&gt; 0 Then
300cdf0e10cSrcweir		Msgbox(sMsgErrMsg, 16, GetProductName())
301cdf0e10cSrcweir		Resume LOCERROR
302cdf0e10cSrcweir		LOCERROR:
303cdf0e10cSrcweir	End If
304cdf0e10cSrcweirEnd Sub
305cdf0e10cSrcweir
306cdf0e10cSrcweir
307cdf0e10cSrcweirSub NextStep()
308cdf0e10cSrcweir	If Not bDebug Then
309cdf0e10cSrcweir		On Local Error GoTo WIZARDERROR
310cdf0e10cSrcweir	End If
311cdf0e10cSrcweir	Select Case DialogModel.Step
312cdf0e10cSrcweir		Case 1
313cdf0e10cSrcweir			bControlsAreCreated = Not (cBool(DialogModel.lstSelFields.Tag))
314cdf0e10cSrcweir			If Not bControlsAreCreated Then
315cdf0e10cSrcweir				GetTableMetaData()
316cdf0e10cSrcweir				CreateDBForm()
317cdf0e10cSrcweir				RemoveShapes()
318cdf0e10cSrcweir				InitializeLayoutSettings()
319cdf0e10cSrcweir				oDBForm.Load
320cdf0e10cSrcweir			End If
321cdf0e10cSrcweir			DialogModel.cmdGoOn.Label = sReady
322cdf0e10cSrcweir			DialogModel.cmdBack.Enabled = True
323cdf0e10cSrcweir			DialogModel.Step = 2
324cdf0e10cSrcweir			bDisposeDoc = False
325cdf0e10cSrcweir		Case 2
326cdf0e10cSrcweir			StoreForm()
327cdf0e10cSrcweir			DlgFormDB.EndExecute()
328cdf0e10cSrcweir			exit Sub
329cdf0e10cSrcweir	End Select
330cdf0e10cSrcweir	DialogModel.imgTheme.ImageUrl = FormPath &amp; &quot;FormWizard_&quot; &amp; DialogModel.Step &amp; &quot;.bmp&quot;
331cdf0e10cSrcweir	DlgFormDB.Title = WizardTitle(DialogModel.Step)
332cdf0e10cSrcweirWIZARDERROR:
333cdf0e10cSrcweir	If Err &lt;&gt; 0 Then
334cdf0e10cSrcweir		Msgbox(sMsgErrMsg, 16, GetProductName())
335cdf0e10cSrcweir		Resume LOCERROR
336cdf0e10cSrcweir		LOCERROR:
337cdf0e10cSrcweir	End If
338cdf0e10cSrcweirEnd Sub
339cdf0e10cSrcweir
340cdf0e10cSrcweir
341cdf0e10cSrcweirSub InitializeLayoutSettings()
342cdf0e10cSrcweir	SwitchArrangementButtons(cTabled)
343cdf0e10cSrcweir	SwitchAlignMode(SBALIGNLEFT)
344cdf0e10cSrcweir	SwitchBorderMode(SB3DBORDER)
345cdf0e10cSrcweir	ToggleBorderGroup(bControlsAreCreated)
346cdf0e10cSrcweir	ToggleAlignGroup(bControlsAreCreated)
347cdf0e10cSrcweir	ArrangeControls()
348cdf0e10cSrcweir	If OldAlignMode &lt;&gt; 0 Then
349cdf0e10cSrcweir		DlgFormDB.GetControl(&quot;optAlign2&quot;).Model.State = 0
350cdf0e10cSrcweir	End If
351cdf0e10cSrcweirEnd Sub
352cdf0e10cSrcweir
353cdf0e10cSrcweir
354cdf0e10cSrcweirSub ToggleDatabasePage(bDoEnable as Boolean)
355cdf0e10cSrcweir	With DialogModel
356cdf0e10cSrcweir		.cmdBack.Enabled = False
357cdf0e10cSrcweir		.cmdHelp.Enabled = bDoEnable
358cdf0e10cSrcweir		.cmdGoOn.Enabled = Ubound(DialogModel.lstSelFields.StringItemList()) &lt;&gt; -1
359cdf0e10cSrcweir		.hlnBinaries.Enabled = ((bDoEnable = True) And (bEnableBinaryOptionGroup = True))
360cdf0e10cSrcweir		.optIgnoreBinaries.Enabled = ((bDoEnable = True) And (bEnableBinaryOptionGroup = True))
361cdf0e10cSrcweir		.optBinariesasGraphics.Enabled = ((bDoEnable = True) And (bEnableBinaryOptionGroup = True))
362cdf0e10cSrcweir	End With
363cdf0e10cSrcweirEnd Sub
364cdf0e10cSrcweir
365cdf0e10cSrcweir
366cdf0e10cSrcweir&apos; This Sub is called from the Procedure &quot;StoreDocument&quot; in the &quot;Tools&quot; Library
367cdf0e10cSrcweirSub CommitLastDocumentChanges(sTargetPath as String)
368cdf0e10cSrcweirDim i as Integer
369cdf0e10cSrcweirDim sBookmarkName as String
370cdf0e10cSrcweirDim oDBBookmarks as Object
371cdf0e10cSrcweirDim bLinkExists as Boolean
372cdf0e10cSrcweirDim sBaseBookmarkName as String
373cdf0e10cSrcweir	sBookmarkName = GetFileNamewithoutExtension(FileNameoutofPath(sTargetPath))
374cdf0e10cSrcweir	sBaseBookmarkName = sBookmarkName
375cdf0e10cSrcweir	oDBBookmarks = oDataSource.GetBookmarks()
376cdf0e10cSrcweir	i = 1
377cdf0e10cSrcweir	Do
378cdf0e10cSrcweir		bLinkExists = oDBBookmarks.HasbyName(sBookmarkName)
379cdf0e10cSrcweir		If bLinkExists Then
380cdf0e10cSrcweir			i = i + 1
381cdf0e10cSrcweir			sBookmarkName = sBaseBookmarkName &amp; &quot;_&quot; &amp; i
382cdf0e10cSrcweir		Else
383cdf0e10cSrcweir			oDBBookmarks.insertByName(sBookmarkName, sTargetPath)
384cdf0e10cSrcweir		End If
385cdf0e10cSrcweir	Loop Until Not bLinkExists
386cdf0e10cSrcweir	bDisposeDoc = False
387cdf0e10cSrcweir	GroupShapesTogether()
388cdf0e10cSrcweir	ToggleDesignMode(oDocument)
389cdf0e10cSrcweir	oDBForm.Reload()
390cdf0e10cSrcweirEnd Sub
391cdf0e10cSrcweir
392cdf0e10cSrcweir
393cdf0e10cSrcweirSub StoreFormInDatabase()
394cdf0e10cSrcweir	Dim NoArgs() as new com.sun.star.beans.PropertyValue
395cdf0e10cSrcweir	FormName = &quot;Form_&quot; &amp; sDBName &amp; &quot;_&quot; &amp; TableName &amp; &quot;.sxw&quot;
396cdf0e10cSrcweir	sFormUrl = TempPath &amp; &quot;/&quot; &amp; FormName
397cdf0e10cSrcweir	oDocument.StoreAsUrl(sFormUrl, NoArgs())
398cdf0e10cSrcweir	bdisposeDoc = true
399cdf0e10cSrcweir	DlgFormDB.Endexecute()
400cdf0e10cSrcweirEnd Sub
401cdf0e10cSrcweir
402cdf0e10cSrcweir
403cdf0e10cSrcweir
404cdf0e10cSrcweirSub StoreForm()
405cdf0e10cSrcweirDim sTargetPath as String
406cdf0e10cSrcweirDim TypeNames(0,2) as String
407cdf0e10cSrcweirDim oMasterKey as Object
408cdf0e10cSrcweirDim oTypes() as Object
409cdf0e10cSrcweir	oMasterKey = GetRegistryKeyContent(&quot;org.openoffice.TypeDetection.Types/&quot;)
410cdf0e10cSrcweir	oTypes() = oMasterKey.Types
411cdf0e10cSrcweir	TypeNames(0,0) = GetFilterName(&quot;StarOffice XML (Writer)&quot;)
412cdf0e10cSrcweir	TypeNames(0,1) = &quot;*.sxw&quot;
413cdf0e10cSrcweir	TypeNames(0,2) = &quot;&quot;
414cdf0e10cSrcweir	StoreFormInDatabase()
415cdf0e10cSrcweir&apos;	sTargetPath = StoreDocument(oDocument, TypeNames(), &quot;Form_&quot; &amp; sDBName &amp; &quot;_&quot; &amp; TableName &amp; &quot;.sxw&quot;, WorkPath, 1)
416cdf0e10cSrcweirEnd Sub
417cdf0e10cSrcweir
418cdf0e10cSrcweir
419cdf0e10cSrcweir
420cdf0e10cSrcweirSub EmptyFieldsListboxes()
421cdf0e10cSrcweirDim NullList() as String
422cdf0e10cSrcweir	ToggleListboxControls(DialogModel, False)
423cdf0e10cSrcweir	DialogModel.lstFields.StringItemList() = NullList()
424cdf0e10cSrcweir	DialogModel.lstSelFields.StringItemList() = NullList()
425cdf0e10cSrcweir	bEnableBinaryOptionGroup = False
426cdf0e10cSrcweirEnd Sub
427cdf0e10cSrcweir
428cdf0e10cSrcweir
429cdf0e10cSrcweirSub DeleteFirstTableListBoxEntry()
430cdf0e10cSrcweir	DeleteFirstListBoxEntry(&quot;lstTables&quot;, sSelectDBTable)
431cdf0e10cSrcweirEnd Sub
432cdf0e10cSrcweir
433cdf0e10cSrcweirSub DeleteFirstListboxEntry(ListBoxName as String, DelEntryName as String)
434cdf0e10cSrcweirDim oListbox as Object
435cdf0e10cSrcweirDim sFirstItem as String
436cdf0e10cSrcweirdim iSelPos as Integer
437cdf0e10cSrcweir	oListBox = DlgFormDB.getControl(ListBoxName)
438cdf0e10cSrcweir	sFirstItem = oListBox.getItem(0)
439cdf0e10cSrcweir	If sFirstItem = DelEntryName Then
440cdf0e10cSrcweir		iSelPos = oListBox.getSelectedItemPos()
441cdf0e10cSrcweir	    oListBox.removeItems(0, 1)
442cdf0e10cSrcweir		If iSelPos &gt; 0 Then
443cdf0e10cSrcweir		    oListBox.selectItemPos(iSelPos-1, True)
444cdf0e10cSrcweir		End If
445cdf0e10cSrcweir	End If
446cdf0e10cSrcweirEnd Sub
447*3e02b54dSAndrew Rist</script:module>
448