summaryrefslogtreecommitdiff
path: root/wizards/source/access2base/Application.xba
diff options
context:
space:
mode:
authorJean-Pierre Ledure <jp@ledure.be>2014-08-12 12:08:48 +0200
committerJean-Pierre Ledure <jp@ledure.be>2014-08-17 06:18:45 -0500
commit8393014898d67795f44835791aa0d9ed535be5d3 (patch)
tree56c5c25caa6746279461d416cb3bde0b52be31e7 /wizards/source/access2base/Application.xba
parent99b9e06b7cdfd1f3336226583d73aa49cc6ce305 (diff)
Access2Base - non-Base components
So far the first call to the API was a call to the OpenConnection method. Without an OpenConnection some methods issued a cryptic "Object variable not set" Basic run-time message. It is now intercepted to make it clearer. A number of features are not database related: error handling, events handling, windows move/resize, dialogs, ... They have been identified and adapted to be callable without database connection. As such they are callable from any LO component, not only Base. Change-Id: I99f408c8404a6192149747228b2b8493b9df5ae3 Reviewed-on: https://gerrit.libreoffice.org/10883 Reviewed-by: Jean-Pierre Ledure <jp@ledure.be> Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Diffstat (limited to 'wizards/source/access2base/Application.xba')
-rw-r--r--wizards/source/access2base/Application.xba23
1 files changed, 15 insertions, 8 deletions
diff --git a/wizards/source/access2base/Application.xba b/wizards/source/access2base/Application.xba
index 04dceb079b0b..8b2af9a392e6 100644
--- a/wizards/source/access2base/Application.xba
+++ b/wizards/source/access2base/Application.xba
@@ -291,7 +291,7 @@ Public Function AllForms(ByVal Optional pvIndex As Variant) As Variant
&apos; Easiest use for standalone forms: AllForms(0)
&apos; If no argument, return a Collection type
-If _ErrorHandler() Then On Local Error Goto Error_Function
+ If _ErrorHandler() Then On Local Error Goto Error_Function
Const cstThisSub = &quot;AllForms&quot;
Utils._SetCalledSub(cstThisSub)
Dim iIndex As Integer, vAllForms As Variant
@@ -443,10 +443,11 @@ Dim i As Integer, bFound As Boolean, sURL As String, iCurrentDoc As Integer, oCu
bFound = False
Set CurrentDb = Nothing
+ If IsEmpty(_A2B_) Then GoTo Exit_Function
With _A2B_
If Not IsArray(.CurrentDoc) Then Goto Exit_Function
If UBound(.CurrentDoc) &lt; 0 Then Goto Exit_Function
- iCurrentDoc = _CurrentDoc()
+ iCurrentDoc = _CurrentDoc(, False)
If iCurrentDoc &gt;= 0 Then Set CurrentDb = .CurrentDoc(iCurrentDoc).DbContainers(0).Database
End With
@@ -980,6 +981,7 @@ End Function &apos; OpenDatabase V1.1.0
REM -----------------------------------------------------------------------------------------------------------------------
Public Function ProductCode()
+ If IsEmpty(_A2B_) Then Call Application._RootInit() &apos; First use of Access2Base in current AOO/LibO session
ProductCode = &quot;Access2Base &quot; &amp; _A2B_.VersionNumber
End Function &apos; ProductCode V0.9.1
@@ -991,10 +993,10 @@ Public Function SysCmd(Optional pvAction As Variant _
&apos; Manage progress meter in the status bar
&apos; Other values supported by MSAccess are ignored
+ If _ErrorHandler() Then On Local Error Goto Error_Function
Const cstThisSub = &quot;SysCmd&quot;
Utils._SetCalledSub(cstThisSub)
SysCmd = False
- If _ErrorHandler() Then On Local Error Goto Error_Function
Const cstMissing = -1
Const cstBarLength = 350
@@ -1117,6 +1119,7 @@ REM Without arguments same as CurrentDb() except that it generates an error if d
REM With 2 arguments return the corresponding entry in Root
Dim odbDatabase As Variant
+ If IsEmpty(_A2B_) Then GoTo Trace_Error
If IsMissing(piDocEntry) Then
Set odbDatabase = Application.CurrentDb()
Else
@@ -1139,16 +1142,16 @@ Trace_Error:
End Function &apos; _CurrentDb V1.1.0
REM -----------------------------------------------------------------------------------------------------------------------
-Public Function _CurrentDoc(Optional pvURL As String) As Integer
+Public Function _CurrentDoc(Optional pvURL As String, Optional pbAbort As Boolean) As Integer
&apos; Returns the entry in _A2B_.CurrentDoc(...) referring to the current document
Dim i As Integer, bFound As Boolean, sURL As String
bFound = False
- _CurrentDoc = -1 &apos; Convention for _A2B_ not initalized or no entry found
+ If IsEmpty(_A2B_) Then GoTo Trace_Error
With _A2B_
- If Not IsArray(.CurrentDoc) Then Goto Exit_Function
- If UBound(.CurrentDoc) &lt; 0 Then Goto Exit_Function
+ If Not IsArray(.CurrentDoc) Then Goto Trace_Error
+ If UBound(.CurrentDoc) &lt; 0 Then Goto Trace_Error
For i = 1 To UBound(.CurrentDoc) &apos; [0] reserved to database .odb document
If IsMissing(pvURL) Then &apos; Not on 1 single line ?!?
If Utils._hasUNOProperty(ThisComponent, &quot;URL&quot;) Then
@@ -1166,12 +1169,16 @@ Dim i As Integer, bFound As Boolean, sURL As String
End If
Next i
If Not bFound Then
- If Not IsNull(.CurrentDoc(0)) Then _CurrentDoc = 0
+ If Not IsNull(.CurrentDoc(0)) Then _CurrentDoc = 0 Else GoTo Trace_Error
End If
End With
Exit_Function:
Exit Function
+Trace_Error:
+ If IsMissing(pbAbort) Then pbAbort = True
+ If pbAbort Then TraceError(TRACEABORT, ERRDBNOTCONNECTED, Utils._CalledSub(), 0, 1) Else _CurrentDoc = -1
+ Goto Exit_Function
End Function &apos; _CurrentDoc V1.1.0
REM -----------------------------------------------------------------------------------------------------------------------