From e8fbdff47aae1ab16226aac08cdc46ecd0602a82 Mon Sep 17 00:00:00 2001 From: Behrend Cornelius Date: Fri, 10 Aug 2001 10:13:29 +0000 Subject: #88813# handling of optional parmeters improved --- wizards/source/formwizard/DlgFormDB.xdl | 6 +- wizards/source/formwizard/FormWizard.xba | 94 +++++++++++++++++++++----------- wizards/source/formwizard/tools.xba | 3 +- 3 files changed, 67 insertions(+), 36 deletions(-) (limited to 'wizards/source/formwizard') diff --git a/wizards/source/formwizard/DlgFormDB.xdl b/wizards/source/formwizard/DlgFormDB.xdl index 8e24ae8aa749..3adaf08fa8c8 100644 --- a/wizards/source/formwizard/DlgFormDB.xdl +++ b/wizards/source/formwizard/DlgFormDB.xdl @@ -1,6 +1,6 @@ - + @@ -13,7 +13,9 @@ - + + + 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) diff --git a/wizards/source/formwizard/tools.xba b/wizards/source/formwizard/tools.xba index e715b07b9547..d19512bb0aa2 100644 --- a/wizards/source/formwizard/tools.xba +++ b/wizards/source/formwizard/tools.xba @@ -204,7 +204,8 @@ Dim i as Integer Dim MaxIndex as Integer Dim ResCount as Integer ResCount = 0 - For i = o To MaxIndex + MaxIndex = Ubound(BigArray()) + For i = 0 To MaxIndex If SearchItem = BigArray(i) Then ResCount = ResCount + 1 End If -- cgit v1.2.3