diff options
author | Jean-Pierre Ledure <jp@ledure.be> | 2014-05-16 14:55:36 +0200 |
---|---|---|
committer | Lionel Elie Mamane <lionel@mamane.lu> | 2014-05-16 16:55:29 +0000 |
commit | 6e60f1a69c87f5c443014f14027cca77a719586a (patch) | |
tree | dfc900614df00e88330ffdf0a7dab71abc724ffe /wizards | |
parent | 4a9a10d169653e42028d32ee8e260692ead8cc36 (diff) |
Access2Base - solve compatibility issues
1) AOO <> LO
"Append" is a reserved word in AOO Basic, not in LO
=> Append method replaced with Add
2) Windows <> Linux
ActiveConnection not ready under Windows for standalone forms when database is (user/password) protected
=> Connection may be postponed to first use of form
Change-Id: I8ba409191ba2a2a4c057480ec3287d7d48262073
Reviewed-on: https://gerrit.libreoffice.org/9372
Reviewed-by: Lionel Elie Mamane <lionel@mamane.lu>
Tested-by: Lionel Elie Mamane <lionel@mamane.lu>
Diffstat (limited to 'wizards')
-rw-r--r-- | wizards/source/access2base/Application.xba | 43 | ||||
-rw-r--r-- | wizards/source/access2base/Collect.xba | 11 | ||||
-rw-r--r-- | wizards/source/access2base/Form.xba | 14 |
3 files changed, 38 insertions, 30 deletions
diff --git a/wizards/source/access2base/Application.xba b/wizards/source/access2base/Application.xba index 9de68cd4e110..13504648a37d 100644 --- a/wizards/source/access2base/Application.xba +++ b/wizards/source/access2base/Application.xba @@ -750,7 +750,7 @@ Dim vCurrentDoc() As Variant Dim oBaseContext As Object, sDbNames() As String, oBaseSource As Object Dim sDatabaseURL As String, oHandler As Object Dim vDbContainer As Variant, vDbContainers() As Variant, vDocContainer As Variant -Dim sFormName As String, oConnection As Object +Dim sFormName As String If IsEmpty(_A2B_) Then Call Application._RootInit() ' First use of Access2Base in current AOO/LibO session Set OpenConnection = Nothing @@ -844,29 +844,26 @@ Const cstThisSub = "OpenConnection" For i = 0 To oForms.Count - 1 vDbContainer = New DbContainer ' To make distinct entries !! sFormName = oForms.ElementNames(i) - Set oConnection = oForms.getByName(sFormName).ActiveConnection - If IsNull(oConnection) Then - Set vDbContainer.Database = Nothing ' Form is not data-aware - Else - Set vDbContainer.Database = New Database - Set vDbContainer.Database._This = vDbContainer.Database - With vDbContainer.Database - .FormName = sFormName - vDbContainer.FormName = sFormName - Set .Form = oForms.getByName(sFormName) - Set .Connection = oConnection - Set .MetaData = oConnection.MetaData - ._ReadOnly = oConnection.isReadOnly() - Set .Document = oComponent - .Title = oComponent.Title - .URL = .Form.DataSourceName - ._DbConnect = DBCONNECTFORM - Set vDbContainers(i) = vDbContainer - vDbContainers(i).FormName = sFormName + Set vDbContainer.Database = New Database + Set vDbContainer.Database._This = vDbContainer.Database + With vDbContainer.Database + .FormName = sFormName + vDbContainer.FormName = sFormName + Set .Form = oForms.getByName(sFormName) + Set .Connection = .Form.ActiveConnection ' Might be Nothing in Windows at AOO/LO startup (not met in Linux) + If Not IsNull(.Connection) Then + Set .MetaData = .Connection.MetaData + ._ReadOnly = .Connection.isReadOnly() TraceLog(TRACEANY, .MetaData.getDatabaseProductName() & " " & .MetaData.getDatabaseProductVersion, False) - TraceLog(TRACEANY, UCase(cstThisSub) & " " & .URL & " Form=" & vDbContainer.FormName, False) - End With - End If + End If + Set .Document = oComponent + .Title = oComponent.Title + .URL = .Form.DataSourceName + ._DbConnect = DBCONNECTFORM + Set vDbContainers(i) = vDbContainer + vDbContainers(i).FormName = sFormName + TraceLog(TRACEANY, UCase(cstThisSub) & " " & .URL & " Form=" & vDbContainer.FormName, False) + End With Next i vDocContainer.DbConnect = DBCONNECTFORM End Select diff --git a/wizards/source/access2base/Collect.xba b/wizards/source/access2base/Collect.xba index 80c53a0966ab..96da04d6f7ed 100644 --- a/wizards/source/access2base/Collect.xba +++ b/wizards/source/access2base/Collect.xba @@ -31,6 +31,7 @@ Private Sub Class_Initialize() _CollType = "" _ParentType = "" _ParentName = "" + Set _ParentDatabase = Nothing _Count = 0 End Sub ' Constructor @@ -161,15 +162,15 @@ REM ---------------------------------------------------------------------------- REM --- CLASS METHODS --- REM ----------------------------------------------------------------------------------------------------------------------- -Public Function Append(Optional pvObject As Variant) As Boolean +Public Function Add(Optional pvObject As Variant) As Boolean ' Append a new TableDef or Field object to the TableDefs/Fields collections -Const cstThisSub = "Collection.Append" +Const cstThisSub = "Collection.Add" Utils._SetCalledSub(cstThisSub) If _ErrorHandler() Then On Local Error Goto Error_Function Dim odbDatabase As Object, oConnection As Object, oTables As Object, sName As String, oTable As Object - Append = False + Add = False If IsMissing(pvObject) Then Call _TraceArguments() If Not Utils._CheckArgument(pvObject, 1, vbObject) Then Goto Exit_Function @@ -192,7 +193,7 @@ Dim odbDatabase As Object, oConnection As Object, oTables As Object, sName As St End Select End With - Append = True + Add = True Exit_Function: Utils._ResetCalledSub(cstThisSub) @@ -206,7 +207,7 @@ Error_NotApplicable: Error_Sequence: TraceError(TRACEFATAL, ERRTABLECREATION, Utils._CalledSub(), 0, 1, pvObject._Name) Goto Exit_Function -End Function ' Append V1.1.0 +End Function ' Add V1.1.0 REM ----------------------------------------------------------------------------------------------------------------------- Public Function Delete(ByVal Optional pvName As Variant) As Boolean diff --git a/wizards/source/access2base/Form.xba b/wizards/source/access2base/Form.xba index 5768674b6d4c..578200bffd56 100644 --- a/wizards/source/access2base/Form.xba +++ b/wizards/source/access2base/Form.xba @@ -564,7 +564,7 @@ REM ---------------------------------------------------------------------------- Public Sub _Initialize(psName As String) ' Set pointers to UNO objects -Dim oDoc As Object, oFormsCollection As Object +Dim oDoc As Object, oFormsCollection As Object, oDatabase As Object If _ErrorHandler() Then On Local Error Goto Trace_Error _Name = psName _Shortcut = "Forms!" & Utils._Surround(psName) @@ -587,7 +587,17 @@ Dim oDoc As Object, oFormsCollection As Object End If Case DBCONNECTFORM Set ContainerWindow = oDoc.Document.CurrentController.Frame.ContainerWindow - Set DatabaseForm = Application._CurrentDb(_DocEntry, _DbEntry).Form + Set oDatabase = Application._CurrentDb(_DocEntry, _DbEntry) + With oDatabase + Set DatabaseForm = .Form + If IsNull(.Connection) Then + Set .Connection = DatabaseForm.ActiveConnection + If Not IsNull(.Connection) Then + Set .MetaData = .Connection.MetaData + oDatabase._ReadOnly = .Connection.isReadOnly() + End If + End If + End With End Select Else Set Component = Nothing |