summaryrefslogtreecommitdiff
path: root/wizards/source/formwizard/FormWizard.xba
diff options
context:
space:
mode:
Diffstat (limited to 'wizards/source/formwizard/FormWizard.xba')
-rw-r--r--wizards/source/formwizard/FormWizard.xba94
1 files changed, 61 insertions, 33 deletions
diff --git a/wizards/source/formwizard/FormWizard.xba b/wizards/source/formwizard/FormWizard.xba
index 4cb509ed4188..0cfac5663106 100644
--- a/wizards/source/formwizard/FormWizard.xba
+++ b/wizards/source/formwizard/FormWizard.xba
@@ -34,7 +34,38 @@ Public Tablename as String
' Todo: Mit FS abschnacken, dass als CommandType Nur Queries und Tables zugelassen sind. Dabei müsste noch abgklärt werden
' wann ein Content ein 'Command' ist.
-Sub MainWithDefault(Optional DatasourceName as String, Optional CommandType as Integer, Optional sContent as String, Optional oConnection as Object)
+
+' The macro can be called in 4 possible scenarios:
+' Scenario 1. No parameters at given
+' Scenario 2: Only Datasourcename is given, but no connection and no Content
+' Scenario 3: a data source and a connection are given
+' Scenario 4: all parameters (data source name, connection, object type and object) are given
+
+Sub Main()
+Dim oLocDBContext as Object
+Dim oLocConnection as Object
+
+' Scenario 1. No parameters at given
+ MainWithDefault()
+
+' Scenario 2: Only Datasourcename is given, but no connection and no Content
+' MainWithDefault("Bibliography")
+
+' Scenario 3: a data source and a connection are given
+' oLocDBContext = CreateUnoService("com.sun.star.sdb.DatabaseContext")
+' oLocConnection = oLocDBContext.GetByName("Bibliography").GetConnection("","")
+' MainWithDefault("Bibliography", oLocConnection)
+
+' Scenario 4: all parameters (data source name, connection, object type and object) are given
+' oLocDBContext = CreateUnoService("com.sun.star.sdb.DatabaseContext")
+' oLocConnection = oLocDBContext.GetByName("Bibliography").GetConnection("","")
+' MainWithDefault("Bibliography", oLocConnection, com.sun.star.sdb.CommandType.TABLE, "biblio")
+End Sub
+
+
+Sub MainWithDefault(Optional DatasourceName as String, Optional oConnection as Object, Optional CommandType as Integer, Optional sContent as String)
+Dim i as Integer
+Dim SelCount as Integer
'On Local Error Goto GlobalError
BasicLibraries.LoadLibrary("Tools")
BasicLibraries.LoadLibrary("WebWizard")
@@ -57,21 +88,7 @@ Sub MainWithDefault(Optional DatasourceName as String, Optional CommandType as I
InitializeWidthList()
LoadLanguage
bNeedFieldRefresh = True
- If Not IsMissing(DataSourceName) Then
- CreateForm(DatasourceName, CommandType, sContent, oConnection)
- Else
- CreateForm()
- End If
-GlobalError:
- If Err <> 0 Then
- ToggleWindow(True)
- MsgBox(sMsgErrMsg , 16, sMsgWizardName)
- End If
-End Sub
-
-Sub CreateForm(Optional DatasourceName as String, Optional CommandType as Integer, Optional sContent as String, Optional oConnection as Object) as String
-Dim i as Integer
With oDialogModel
.optIgnoreBinaries.State = True
.cmdBack.Enabled = False
@@ -81,31 +98,43 @@ Dim i as Integer
.Step = 1
.lstDatabases.StringItemList()= sDatabaseList()' = AddItem(sDatabaseList(i)
End With
-
If Not IsMissing(DataSourceName) Then
DlgFormDB.GetControl("lstDatabases").SelectItem(DataSourceName, True)
- Set oDBConnection = oConnection
- If GetDBMetaData() Then
- oDialogModel.lstTables.StringItemList() = AddListToList(TableNames(), QueryNames())
- iCommandTypes() = CreateCommandTypeList()
- SelCount = CountItemsInArray()
- If SelCount = 1 Then
- DlgFormDB.GetControl("lstTables").SelectItem(sContent, True)
- Else ' Note here is no Error Handling in case that no valid content is transferred
- If CommandType = com.sun.star.sdb.CommandType.QUERY Then
- SelIndex = IndexInArray(sContent, QueryNames()
- DlgFormDB.GetControl("lstTables").SelectItemPos(SelIndex, True)
- ElseIf CommandType = com.sun.star.sdb.CommandType.TABLE Then
- SelIndex = IndexInArray(sContent, TableNames()
- DlgFormDB.GetControl("lstTables").SelectItemPos(Ubound(QueryNames()+1 + SelIndex, True)
+ If Not IsMissing(oConnection) Then
+ ' Scenario 3: a data source and a connection are given
+ Set oDBConnection = oConnection
+ oDialogModel.lstTables.Enabled = True
+ oDialogModel.lblTables.Enabled = True
+ If GetDBMetaData() Then
+ oDialogModel.lstTables.StringItemList() = AddListToList(TableNames(), QueryNames())
+ If Not IsMissing(sContent) Then
+ ' Scenario 4: all parameters (data source name, connection, object type and object) are given
+ iCommandTypes() = CreateCommandTypeList()
+ SelCount = CountItemsInArray(oDialogModel.lstTables.StringItemList(), sContent)
+ If SelCount = 1 Then
+ DlgFormDB.GetControl("lstTables").SelectItem(sContent, True)
+ Else ' Note: Here is no Error Handling in case that no valid content is transferred
+ If CommandType = com.sun.star.sdb.CommandType.QUERY Then
+ SelIndex = IndexInArray(sContent, QueryNames()
+ DlgFormDB.GetControl("lstTables").SelectItemPos(SelIndex, True)
+ ElseIf CommandType = com.sun.star.sdb.CommandType.TABLE Then
+ SelIndex = IndexInArray(sContent, TableNames()
+ DlgFormDB.GetControl("lstTables").SelectItemPos(Ubound(QueryNames()+1 + SelIndex, True)
+ End If
+ End If
+ CurCommandType = CommandType
+ FillUpFieldsListbox(False)
End If
End If
- CurCommandType = CommandType
- FillUpFieldsListbox(False)
+ Else
+ ' Scenario 2: Only Datasourcename is given, but no connection and no Content
+ GetSelectedDBMetaData()
End If
Else
+ ' Scenario 1: No parameters are given
ToggleListboxControls(oDialogModel, False)
End If
+
DlgFormDB.Title = WizardTitle(1)
NumberofStyles = FillupWebListbox(oUcb, "/stl", DlgFormDB, "lstStyles", Styles())
ImportStyles()
@@ -113,7 +142,6 @@ Dim i as Integer
oDialogModel.imgTheme.ImageURL = FormPath & "FormWizard_1.bmp"
DlgFormDB.Execute()
Exit Sub
-
GlobalError:
MsgBox(sMsgErrMsg , 16, sMsgWizardName)
ToggleWindow(True)