diff options
author | Behrend Cornelius <bc@openoffice.org> | 2001-08-10 10:13:29 +0000 |
---|---|---|
committer | Behrend Cornelius <bc@openoffice.org> | 2001-08-10 10:13:29 +0000 |
commit | e8fbdff47aae1ab16226aac08cdc46ecd0602a82 (patch) | |
tree | e6639e33b0df611b675c14ffbb26b20009c0b792 /wizards | |
parent | 35810e46bbf6d9632cc1d8c3a8048d924d1031a1 (diff) |
#88813# handling of optional parmeters improved
Diffstat (limited to 'wizards')
-rw-r--r-- | wizards/source/formwizard/DlgFormDB.xdl | 6 | ||||
-rw-r--r-- | wizards/source/formwizard/FormWizard.xba | 94 | ||||
-rw-r--r-- | wizards/source/formwizard/tools.xba | 3 |
3 files changed, 67 insertions, 36 deletions
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 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE dlg:window PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "dialog.dtd"> -<dlg:window xmlns:dlg="http://openoffice.org/2000/dialog" dlg:id="DlgFormDB" dlg:left="96" dlg:top="28" dlg:width="270" dlg:height="210" dlg:page="2" dlg:help-url="HID:34400"> +<dlg:window xmlns:dlg="http://openoffice.org/2000/dialog" dlg:id="DlgFormDB" dlg:left="96" dlg:top="28" dlg:width="270" dlg:height="210" dlg:page="1" dlg:help-url="HID:34400"> <dlg:bulletinboard> <dlg:text dlg:id="lblSelFields" dlg:tab-index="0" dlg:left="154" dlg:top="70" dlg:width="110" dlg:height="8" dlg:page="1" dlg:value="lblSelFields"/> <dlg:menulist dlg:id="lstDatabases" dlg:tab-index="1" dlg:left="6" dlg:top="51" dlg:width="110" dlg:height="12" dlg:page="1" dlg:help-url="HID:34410" dlg:spin="true"> @@ -13,7 +13,9 @@ <dlg:button dlg:id="cmdCancel" dlg:tab-index="4" dlg:left="6" dlg:top="190" dlg:width="53" dlg:height="14" dlg:help-url="HID:34401" dlg:value="cmdCancel"> <dlg:event dlg:listener-type="com.sun.star.awt.XActionListener" dlg:event-method="actionPerformed" dlg:script-type="StarBasic" dlg:script-code="FormWizard.FormWizard.CancelFormWizard"/> </dlg:button> - <dlg:button dlg:id="cmdHelp" dlg:tab-index="5" dlg:left="63" dlg:top="190" dlg:width="53" dlg:height="14" dlg:help-url="HiD:34400" dlg:value="cmdHelp"/> + <dlg:button dlg:id="cmdHelp" dlg:tab-index="5" dlg:left="63" dlg:top="190" dlg:width="53" dlg:height="14" dlg:tag="34400" dlg:help-url="HiD:34400" dlg:value="cmdHelp"> + <dlg:event dlg:listener-type="com.sun.star.awt.XActionListener" dlg:event-method="actionPerformed" dlg:script-type="StarBasic" dlg:script-code="Tools.Recursive.ShowHelperDialog"/> + </dlg:button> <dlg:button dlg:id="cmdBack" dlg:tab-index="6" dlg:left="155" dlg:top="190" dlg:width="53" dlg:height="14" dlg:help-url="HID:34401" dlg:value="cmdBack"> <dlg:event dlg:listener-type="com.sun.star.awt.XActionListener" dlg:event-method="actionPerformed" dlg:script-type="StarBasic" dlg:script-code="FormWizard.FormWizard.PreviousStep"/> </dlg:button> 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 |