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