summaryrefslogtreecommitdiff
path: root/wizards
diff options
context:
space:
mode:
authorJean-Pierre Ledure <jp@ledure.be>2014-11-01 15:33:30 +0100
committerJean-Pierre Ledure <jp@ledure.be>2014-11-01 15:33:30 +0100
commita65308f307554cfd277f24af66df246814ad1b8b (patch)
tree83bb102c586625c8f97dbe144c713f4a11f88733 /wizards
parent87578eb519c6280c1d67083d4028f5cee5371113 (diff)
Access2Base - new ApplyFilter and SetOrderBy actions
Those actions are meaningful when applied on Table and Query datasheets. Forms and subforms (1 level) supported as well. Change-Id: Ic104559d84ff94f1e7e9bed3db1a13a286953314
Diffstat (limited to 'wizards')
-rw-r--r--wizards/source/access2base/Application.xba7
-rw-r--r--wizards/source/access2base/Database.xba2
-rw-r--r--wizards/source/access2base/DoCmd.xba157
-rw-r--r--wizards/source/access2base/L10N.xba4
-rw-r--r--wizards/source/access2base/Root_.xba8
-rw-r--r--wizards/source/access2base/acConstants.xba2
6 files changed, 167 insertions, 13 deletions
diff --git a/wizards/source/access2base/Application.xba b/wizards/source/access2base/Application.xba
index 441e2ee54698..162575c67ade 100644
--- a/wizards/source/access2base/Application.xba
+++ b/wizards/source/access2base/Application.xba
@@ -70,6 +70,7 @@ Global Const ERRQUERYDEFDELETED = 1549
Global Const ERRTABLEDEFDELETED = 1550
Global Const ERRTABLECREATION = 1551
Global Const ERRFIELDCREATION = 1552
+Global Const ERRSUBFORMNOTFOUND = 1553
REM -----------------------------------------------------------------------------------------------------------------------
Global Const DBCONNECTBASE = 1 &apos; Connection from Base document (OpenConnection)
@@ -1185,9 +1186,11 @@ Public Function _CurrentDb(ByVal Optional piDocEntry As Integer, ByVal Optional
REM Without arguments same as CurrentDb() except that it generates an error if database not connected (internal use)
REM With 2 arguments return the corresponding entry in Root
+Dim oCurrentDb As Object
If IsEmpty(_A2B_) Then GoTo Trace_Error
- If IsMissing(piDocEntry) Then Set _CurrentDb = Application.CurrentDb() _
- Else Set _CurrentDb = _A2B_._CurrentDb(piDocEntry, piDbEntry)
+ If IsMissing(piDocEntry) Then Set oCurrentDb = Application.CurrentDb() _
+ Else Set oCurrentDb = _A2B_._CurrentDb(piDocEntry, piDbEntry)
+ If IsNull(oCurrentDb) Then Goto Trace_Error Else Set _CurrentDb = oCurrentDb
Exit_Function:
Exit Function
diff --git a/wizards/source/access2base/Database.xba b/wizards/source/access2base/Database.xba
index d6b84c1ce163..a8fd3e263e42 100644
--- a/wizards/source/access2base/Database.xba
+++ b/wizards/source/access2base/Database.xba
@@ -545,7 +545,7 @@ Const cstNull = -1
If IsMissing(pvOption) Then
pvOption = cstNull
Else
- If Not Utils._CheckArgument(pvOption, 2, Utils._AddNumeric(), dbSQLPassThrough) Then Goto Exit_Function
+ If Not Utils._CheckArgument(pvOption, 2, Utils._AddNumeric(), Array(dbSQLPassThrough, cstNull)) Then Goto Exit_Function
End If
If _DbConnect &lt;&gt; DBCONNECTBASE And _DbConnect &lt;&gt; DBCONNECTFORM Then Goto Error_NotApplicable
diff --git a/wizards/source/access2base/DoCmd.xba b/wizards/source/access2base/DoCmd.xba
index b88dcefb446f..b1c06e155a8b 100644
--- a/wizards/source/access2base/DoCmd.xba
+++ b/wizards/source/access2base/DoCmd.xba
@@ -37,6 +37,66 @@ REM VBA allows call to actions with missing arguments e.g. OpenForm(&quot;aaa&qu
REM in StarBasic IsMissing requires Variant parameters
REM -----------------------------------------------------------------------------------------------------------------------
+Public Function ApplyFilter( _
+ ByVal Optional pvFilter As Variant _
+ , ByVal Optional pvSQL As Variant _
+ , ByVal Optional pvControlName As Variant _
+ ) As Boolean
+&apos; Set filter on open table, query, form or subform (if pvControlName present)
+
+ If _ErrorHandler() Then On Local Error Goto Error_Function
+Const cstThisSub = &quot;ApplyFilter&quot;
+ Utils._SetCalledSub(cstThisSub)
+ ApplyFilter = False
+
+ If IsMissing(pvFilter) And IsMissing(pvSQL) Then Call _TraceArguments()
+ If IsMissing(pvFilter) Then pvFilter = &quot;&quot;
+ If Not Utils._CheckArgument(pvFilter, 1, vbString) Then Goto Exit_Function
+ If IsMissing(pvSQL) Then pvSQL = &quot;&quot;
+ If Not Utils._CheckArgument(pvSQL, 1, vbString) Then Goto Exit_Function
+ If IsMissing(pvControlName) Then pvControlName = &quot;&quot;
+ If Not Utils._CheckArgument(pvControlName, 1, vbString) Then Goto Exit_Function
+
+Dim sFilter As String, oWindow As Object, oDatabase As Object, oTarget As Object
+ Set oDatabase = Application._CurrentDb()
+ If oDatabase._DbConnect &lt;&gt; DBCONNECTBASE Then Goto Error_NotApplicable
+
+ If pvSQL &lt;&gt; &quot;&quot; _
+ Then sFilter = oDatabase._ReplaceSquareBrackets(pvSQL) _
+ Else sFilter = oDatabase._ReplaceSquareBrackets(pvFilter)
+
+ Set oWindow = _SelectWindow()
+ With oWindow
+ Select Case .WindowType
+ Case acForm
+ Set oTarget = _DatabaseForm(._Name, pvControlName)
+ Case acQuery, acTable
+ If pvControlName &lt;&gt; &quot;&quot; Then Goto Exit_Function
+ Set oTarget = oWindow.Frame.Controller.FormOperations.Cursor
+ Case Else &apos; Ignore action
+ Goto Exit_Function
+ End Select
+ End With
+
+ With oTarget
+ .Filter = sFilter
+ .ApplyFilter = True
+ .reload()
+ End With
+ ApplyFilter = True
+
+Exit_Function:
+ Utils._ResetCalledSub(cstThisSub)
+ Exit Function
+Error_NotApplicable:
+ TraceError(TRACEFATAL, ERRACTION, Utils._CalledSub(), 0, 1, cstThisSub)
+ Goto Exit_Function
+Error_Function:
+ TraceError(TRACEABORT, Err, cstThisSub, Erl)
+ GoTo Exit_Function
+End Function &apos; ApplyFilter V1.2.0
+
+REM -----------------------------------------------------------------------------------------------------------------------
Public Function mClose(Optional ByVal pvObjectType As Variant _
, Optional ByVal pvObjectName As Variant _
, Optional ByVal pvSave As Variant _
@@ -1768,6 +1828,59 @@ Error_Function:
End Function &apos; SetHiddenAttribute V1.1.0
REM -----------------------------------------------------------------------------------------------------------------------
+Public Function SetOrderBy( _
+ ByVal Optional pvOrder As Variant _
+ , ByVal Optional pvControlName As Variant _
+ ) As Boolean
+&apos; Sort ann open table, query, form or subform (if pvControlName present)
+
+ If _ErrorHandler() Then On Local Error Goto Error_Function
+Const cstThisSub = &quot;SetOrderBy&quot;
+ Utils._SetCalledSub(cstThisSub)
+ SetOrderBy = False
+
+ If IsMissing(pvOrder) Then pvOrder = &quot;&quot;
+ If Not Utils._CheckArgument(pvOrder, 1, vbString) Then Goto Exit_Function
+ If IsMissing(pvControlName) Then pvControlName = &quot;&quot;
+ If Not Utils._CheckArgument(pvControlName, 1, vbString) Then Goto Exit_Function
+
+Dim sOrder As String, oWindow As Object, oDatabase As Object, oTarget As Object
+ Set oDatabase = Application._CurrentDb()
+ If oDatabase._DbConnect &lt;&gt; DBCONNECTBASE Then Goto Error_NotApplicable
+
+ sOrder = oDatabase._ReplaceSquareBrackets(pvOrder)
+
+ Set oWindow = _SelectWindow()
+ With oWindow
+ Select Case .WindowType
+ Case acForm
+ Set oTarget = _DatabaseForm(._Name, pvControlName)
+ Case acQuery, acTable
+ If pvControlName &lt;&gt; &quot;&quot; Then Goto Exit_Function
+ Set oTarget = oWindow.Frame.Controller.FormOperations.Cursor
+ Case Else &apos; Ignore action
+ Goto Exit_Function
+ End Select
+ End With
+
+ With oTarget
+ .Order = sOrder
+ .reload()
+ End With
+ SetOrderBy = True
+
+Exit_Function:
+ Utils._ResetCalledSub(cstThisSub)
+ Exit Function
+Error_NotApplicable:
+ TraceError(TRACEFATAL, ERRACTION, Utils._CalledSub(), 0, 1, cstThisSub)
+ Goto Exit_Function
+Error_Function:
+ TraceError(TRACEABORT, Err, cstThisSub, Erl)
+ GoTo Exit_Function
+End Function &apos; SetOrderBy V1.2.0
+
+REM -----------------------------------------------------------------------------------------------------------------------
Public Function ShowAllrecords() As Boolean
&apos; Removes any existing filter that exists on the current table, query or form
@@ -1825,6 +1938,50 @@ Dim bFound As Boolean
End Function &apos; _CheckColumnType V0.9.1
REM -----------------------------------------------------------------------------------------------------------------------
+Private Function _DatabaseForm(psForm As String, psControl As String)
+&apos;Return DatabaseForm element of Form object (based on psForm which is known as a real form name)
+&apos;or of SubForm object (based on psControl which is checked for being a subform)
+
+Dim oForm As Object, oControl As Object, sControls() As String, iControlCount As Integer
+Dim bFound As Boolean, i As Integer, sName As String
+
+ Set oForm = Application.Forms(psForm)
+ If psControl &lt;&gt; &quot;&quot; Then &apos; Search subform
+ With oForm.DatabaseForm
+ iControlCount = .getCount()
+ bFound = False
+ If iControlCount &gt; 0 Then
+ sControls() = .getElementNames()
+ sName = UCase(Utils._Trim(psControl))
+ For i = 0 To iControlCount - 1
+ If UCase(sControls(i)) = sName Then
+ bFound = True
+ Exit For
+ End If
+ Next i
+ End If
+ End With
+ If bFound Then sName = sControls(i) Else Goto Trace_NotFound
+ Set oControl = oForm.Controls(sName)
+ If oControl._SubType &lt;&gt; CTLSUBFORM Then Goto Trace_SubFormNotFound
+ Set _DatabaseForm = oControl.Form.DatabaseForm
+ Else
+ Set _DatabaseForm = oForm.DatabaseForm
+ End If
+
+Exit_Function:
+ Exit Function
+Trace_NotFound:
+ TraceError(TRACEFATAL, ERRCONTROLNOTFOUND, Utils._CalledSub(), 0, , Array(psControl, psForm))
+ Goto Exit_Function
+Trace_SubFormNotFound:
+ TraceError(TRACEFATAL, ERRSUBFORMNOTFOUND, Utils._CalledSub(), 0, , Array(psControl, psForm))
+ Goto Exit_Function
+End Function &apos; _DatabaseForm V1.2.0
+
+
+
+REM -----------------------------------------------------------------------------------------------------------------------
Private Function _getTempDirectoryURL() As String
&apos; Return the tempry directory defined in the OO Options (Paths)
Dim sDirectory As String, oSettings As Object, oPathSettings As Object
diff --git a/wizards/source/access2base/L10N.xba b/wizards/source/access2base/L10N.xba
index 3ec24d22b9c9..fce1ceef9d7e 100644
--- a/wizards/source/access2base/L10N.xba
+++ b/wizards/source/access2base/L10N.xba
@@ -76,6 +76,7 @@ Dim sLocal As String
Case &quot;ERR&quot; &amp; ERRTABLEDEFDELETED : sLocal = &quot;Pre-existing table &apos;%0&apos; has been deleted&quot;
Case &quot;ERR&quot; &amp; ERRTABLECREATION : sLocal = &quot;Table &apos;%0&apos; could not be created&quot;
Case &quot;ERR&quot; &amp; ERRFIELDCREATION : sLocal = &quot;Field &apos;%0&apos; could not be created&quot;
+ Case &quot;ERR&quot; &amp; ERRSUBFORMNOTFOUND : sLocal = &quot;Subform &apos;%0&apos; not found in parent form &apos;%1&apos;&quot;
&apos;----------------------------------------------------------------------------------------------------------------------
Case &quot;OBJECT&quot; : sLocal = &quot;Object&quot;
Case &quot;TABLE&quot; : sLocal = &quot;Table&quot;
@@ -144,7 +145,7 @@ Dim sLocal As String
Case &quot;ERR&quot; &amp; ERRINDEXVALUE : sLocal = &quot;Indice invalide ou dimension erronée du tableau pour la propriété &apos;%0&apos;&quot;
Case &quot;ERR&quot; &amp; ERRCOLLECTION : sLocal = &quot;Indice de tableau invalide&quot;
Case &quot;ERR&quot; &amp; ERRPROPERTYNOTARRAY : sLocal = &quot;L&apos;argument n°%0 doit être un tableau&quot;
- Case &quot;ERR&quot; &amp; ERRCONTROLNOTFOUND : sLocal = &quot;Contrôle &apos;%0&apos; non trouvé dans le parent (formulaire ou contrôle de table) &apos;%1&apos;&quot;
+ Case &quot;ERR&quot; &amp; ERRCONTROLNOTFOUND : sLocal = &quot;Contrôle &apos;%0&apos; non trouvé dans le parent (formulaire, contrôle de table ou dialogue) &apos;%1&apos;&quot;
Case &quot;ERR&quot; &amp; ERRNOACTIVEFORM : sLocal = &quot;Pas de formulaire ou de contrôle actif&quot;
Case &quot;ERR&quot; &amp; ERRDATABASEFORM : sLocal = &quot;Le formulaire &apos;%0&apos; n&apos;a pas de données sous-jacentes&quot;
Case &quot;ERR&quot; &amp; ERRFOCUSINGRID : sLocal = &quot;Contrôle &apos;%0&apos; non trouvé dans le contrôle de table &apos;%1&apos;&quot;
@@ -181,6 +182,7 @@ Dim sLocal As String
Case &quot;ERR&quot; &amp; ERRTABLEDEFDELETED : sLocal = &quot;La table existante &apos;%0&apos; a été supprimée&quot;
Case &quot;ERR&quot; &amp; ERRTABLECREATION : sLocal = &quot;La table &apos;%0&apos; n&apos;a pas pu être créée&quot;
Case &quot;ERR&quot; &amp; ERRFIELDCREATION : sLocal = &quot;Le champ &apos;%0&apos; n&apos;a pas pu être créé&quot;
+ Case &quot;ERR&quot; &amp; ERRSUBFORMNOTFOUND : sLocal = &quot;Sous-formulaire &apos;%0&apos; non trouvé dans le formulaire parent &apos;%1&apos;&quot;
&apos;----------------------------------------------------------------------------------------------------------------------
Case &quot;OBJECT&quot; : sLocal = &quot;Objet&quot;
Case &quot;TABLE&quot; : sLocal = &quot;Table&quot;
diff --git a/wizards/source/access2base/Root_.xba b/wizards/source/access2base/Root_.xba
index 052fbce80fb6..cee811b7df70 100644
--- a/wizards/source/access2base/Root_.xba
+++ b/wizards/source/access2base/Root_.xba
@@ -183,14 +183,6 @@ Const cstBase = &quot;com.sun.star.comp.dba.ODatabaseDocument&quot;
With CurrentDoc(0)
If Not .Active Then GoTo Trace_Error
If IsNull(.Document) Then GoTo Trace_Error
- If Not Utils._hasUNOProperty(ThisComponent, &quot;URL&quot;) Then Goto Trace_Error
- If Utils._ImplementationName(ThisComponent) &lt;&gt; cstBase Or .Document.URL &lt;&gt; ThisComponent.URL Then &apos; Give the parent a try
- If Not Utils._hasUNOProperty(ThisComponent, &quot;Parent&quot;) Then Goto Trace_Error
- If IsNull(ThisComponent.Parent) Then Goto Trace_Error
- If Utils._ImplementationName(ThisComponent.Parent) &lt;&gt; cstBase Then Goto Trace_Error
- If Not Utils._hasUNOProperty(ThisComponent.Parent, &quot;URL&quot;) Then Goto Trace_Error
- If .Document.URL &lt;&gt; ThisComponent.Parent.URL Then Goto Trace_Error
- End If
End With
CurrentDocIndex = 0
End If
diff --git a/wizards/source/access2base/acConstants.xba b/wizards/source/access2base/acConstants.xba
index 5f533febc20b..fab97890a53c 100644
--- a/wizards/source/access2base/acConstants.xba
+++ b/wizards/source/access2base/acConstants.xba
@@ -8,7 +8,7 @@ REM ============================================================================
Option Explicit
REM Access2Base -----------------------------------------------------
-Global Const Access2Base_Version = &quot;1.1.0h&quot;
+Global Const Access2Base_Version = &quot;1.2.0&quot;
REM AcCloseSave
REM -----------------------------------------------------------------