[Libreoffice-commits] core.git: wizards/source

Jean-Pierre Ledure jp at ledure.be
Sun Nov 2 07:37:21 PST 2014


 wizards/source/access2base/DoCmd.xba |   53 ++++++++++++++++++-----------------
 1 file changed, 28 insertions(+), 25 deletions(-)

New commits:
commit 5c7413feb8a612453be9a1d906411ca204695b3a
Author: Jean-Pierre Ledure <jp at ledure.be>
Date:   Sun Nov 2 16:34:07 2014 +0100

    Access2Base - Extension of GoTorecord action to table/query datasheets
    
    Change-Id: I334491e2c75e666bde9db25a01abd5f71a993153

diff --git a/wizards/source/access2base/DoCmd.xba b/wizards/source/access2base/DoCmd.xba
index b1c06e1..4a31284 100644
--- a/wizards/source/access2base/DoCmd.xba
+++ b/wizards/source/access2base/DoCmd.xba
@@ -72,7 +72,7 @@ Dim sFilter As String, oWindow As Object, oDatabase As Object, oTarget As Object
 				Set oTarget = _DatabaseForm(._Name, pvControlName)
 			Case acQuery, acTable
 				If pvControlName <> "" Then Goto Exit_Function
-				Set oTarget = oWindow.Frame.Controller.FormOperations.Cursor
+				Set oTarget = .Frame.Controller.FormOperations.Cursor
 			Case Else		'	Ignore action
 				Goto Exit_Function
 		End Select
@@ -764,13 +764,14 @@ Public Function GoToRecord(Optional ByVal pvObjectType As Variant _
 	
 	Utils._SetCalledSub("GoToRecord")
 	If IsMissing(pvObjectName) Then pvObjectName = ""
-	If IsMissing(pvObjectType) Then
-		If pvObjectName <> "" Then pvObjectType = acDataForm Else pvObjectType = acActiveDataObject
-	End If
+	If IsMissing(pvObjectType) Then pvObjectType = acActiveDataObject
+'	If IsMissing(pvObjectType) Then
+'		If pvObjectName <> "" Then pvObjectType = acDataForm Else pvObjectType = acActiveDataObject
+'	End If
 	If IsMissing(pvRecord) Then pvRecord = acNext
 	If IsMissing(pvOffset) Then pvOffset = 1
 	If Not (Utils._CheckArgument(pvObjectType, 1, Utils._AddNumeric() _
-				, Array(acActiveDataObject, acDataForm)) _
+				, Array(acActiveDataObject, acDataForm, acDataQuery, acDataTable)) _
 		And Utils._CheckArgument(pvObjectName, 2, vbString) _
 		And Utils._CheckArgument(pvRecord, 3, Utils._AddNumeric() _
 				, Array(acFirst, acGoTo, acLast, acNewRec, acNext, acPrevious)) _
@@ -779,22 +780,22 @@ Public Function GoToRecord(Optional ByVal pvObjectType As Variant _
 	If pvObjectType = acActiveDataObject And pvObjectName <> "" Then Goto Error_Target
 	If pvOffset < 0 And pvRecord <> acGoTo Then Goto Error_Offset
 	
-Dim ofForm As Object, oGeneric As Object
+Dim ofForm As Object, oGeneric As Object, oResultSet As Object, oWindow As Object
 Dim i As Integer, iCount As Integer, bFound As Boolean, lOffset As Long
 Dim sObjectName, iLengthName As Integer
 	Select Case pvObjectType
-		Case acActiveDataObject			'	Determine active form
-			iCount = Application._CountOpenForms()
-			If iCount = 0 Then Goto Error_ActiveForm
-			bFound = False
-			For i = 0 To iCount - 1			'	Determine form having the focus
-				Set ofForm = Application.Forms(i)
-				If ofForm.Component.CurrentController.Frame.IsActive() Then
-					bFound = True
-					Exit For
-				End If
-			Next i
-			If Not bFound Then Goto Error_ActiveForm
+		Case acActiveDataObject
+			Set oWindow = _SelectWindow()
+			With oWindow
+				Select Case .WindowType
+					Case acForm
+						Set oResultSet = _DatabaseForm(._Name, "")
+					Case acQuery, acTable
+						Set oResultSet = .Frame.Controller.FormOperations.Cursor
+					Case Else		'	Ignore action
+						Goto Exit_Function
+				End Select
+			End With
 		Case acDataForm
 			'	pvObjectName can be "myForm", "Forms!myForm", "Forms!myForm!mySubform" or "Forms!myForm!mySubform.Form"
 			sObjectName = UCase(pvObjectName)
@@ -816,12 +817,17 @@ Dim sObjectName, iLengthName As Integer
 				Case Else
 					Set ofForm = Application.Forms(pvObjectName)						
 			End Select
-		Case Else						'	Not supported
+			Set oResultSet = ofForm.DatabaseForm
+		Case acDataQuery
+			Set oWindow = _SelectWindow(acQuery, pvObjectName)
+			Set oResultSet = oWindow.Frame.Controller.FormOperations.Cursor
+		Case acDataTable
+			Set oWindow = _SelectWindow(acTable, pvObjectName)
+			Set oResultSet = oWindow.Frame.Controller.FormOperations.Cursor
+		Case Else
 	End Select
 	
 	'	Check if current row updated => Save it
-Dim oResultSet As Object
-	Set oResultSet = ofForm.DatabaseForm
 	If oResultSet.IsNew Then
 		oResultSet.insertRow()
 	ElseIf oResultSet.IsModified Then
@@ -857,9 +863,6 @@ Exit_Function:
 Error_Function:
 	TraceError(TRACEABORT, Err, "GoToRecord", Erl)
 	GoTo Exit_Function
-Error_ActiveForm:
-	TraceError(TRACEERRORS, ERRNOACTIVEFORM, Utils._CalledSub(), 0)
-	Goto Exit_Function
 Error_Target:
 	TraceError(TRACEFATAL, ERRWRONGARGUMENT, Utils._CalledSub(), 0, 1, Array(2, pvObjectName))
 	Goto Exit_Function
@@ -1857,7 +1860,7 @@ Dim sOrder As String, oWindow As Object, oDatabase As Object, oTarget As Object
 				Set oTarget = _DatabaseForm(._Name, pvControlName)
 			Case acQuery, acTable
 				If pvControlName <> "" Then Goto Exit_Function
-				Set oTarget = oWindow.Frame.Controller.FormOperations.Cursor
+				Set oTarget = .Frame.Controller.FormOperations.Cursor
 			Case Else		'	Ignore action
 				Goto Exit_Function
 		End Select


More information about the Libreoffice-commits mailing list