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