Kaydet (Commit) 83709f8a authored tarafından Jean-Pierre Ledure's avatar Jean-Pierre Ledure

Access2Base - Support hierarchical form names

So far, only a flat list of form names was implemented (by far the majority of cases).
Now, hierarchical form names (like "Folder1/Folder2/myForm") are accepted.

Impacts:
- on AllForms() and Forms() collections:
  - insertion of _GetAllHierarchicalNames() to make list of names
  - insertion of _CollectNames(): recursive function to walk thru folders
  - insertion of _GetHierarchicalName(persistent name) to establist correspondence
- on OpenForm action
- on SelectObject action: form windows are not identified by title anymore
- on form and control events
- on arguments check when argument is a form object

Change-Id: I2da73ac3d4fe2d90b2e526fe510207c0f8ec8386
üst 690cbe7a
......@@ -125,7 +125,7 @@ Dim oDatabase As Object
' Check existence of object and find its exact (case-sensitive) name
Select Case pvObjectType
Case acForm
sObjects = oDatabase.Document.getFormDocuments.ElementNames()
sObjects = Application._GetAllHierarchicalNames()
lComponent = com.sun.star.sdb.application.DatabaseObject.FORM
Case acTable
sObjects = oDatabase.Connection.getTables.ElementNames()
......@@ -149,7 +149,7 @@ Dim oDatabase As Object
Select Case pvObjectType
Case acForm
Set oController = oDatabase.Document.getFormDocuments.getByName(sObjectName)
Set oController = oDatabase.Document.getFormDocuments.getByHierarchicalName(sObjectName)
mClose = oController.close()
Case acTable, acQuery ' Not optimal but it works !!
Set oController = oDatabase.Document.CurrentController
......@@ -1140,6 +1140,8 @@ Dim sFilter As String, oForm As Object, oFormsCollection As Object
Else
sFilter = "(" & pvFilterName & ") And (" & pvWhereCondition & ")"
End If
Set oFormsCollection = oOpenForm.DrawPage.Forms
If oFormsCollection.getCount() > 0 Then Set oForm = oFormsCollection.getByIndex(0) Else Set oForm = Nothing
If Not IsNull(oForm) Then
If sFilter <> "" Then
oForm.Filter = oDatabase._ReplaceSquareBrackets(sFilter)
......@@ -1174,7 +1176,7 @@ Dim sFilter As String, oForm As Object, oFormsCollection As Object
End If
.Visible = ( pvWindowMode <> acHidden )
._OpenArgs = pvOpenArgs
'To avoid AOO 3,4 bug See http://user.services.openoffice.org/en/forum/viewtopic.php?f=13&t=53751
'To avoid AOO 3.4 bug See http://user.services.openoffice.org/en/forum/viewtopic.php?f=13&t=53751
.Component.CurrentController.ViewSettings.ShowOnlineLayout = True
End With
......@@ -2355,6 +2357,7 @@ Dim oEnum As Object, oDesk As Object, oComp As Object, oFrame As Object, i As In
Dim bFound As Boolean, bActive As Boolean, sName As String, iType As Integer, sDocumentType As String
Dim sImplementation As String, vLocation() As Variant
Dim oWindow As _Window
Dim vPersistent As Variant, oForm As Object
If _ErrorHandler() Then On Local Error Goto Error_Function
......@@ -2402,7 +2405,10 @@ Dim oWindow As _Window
iType = acDocument
sDocumentType = docWriter
End Select
If iType = acForm Or iType = acReport Then ' Identify Form or Report name
If iType = acForm Then ' Identify persistent Form name
vPersistent = Split(oComp.StringValue, "/")
sName = _GetHierarchicalName(vPersistent(UBound(vPersistent) - 1))
ElseIf iType = acReport Then ' Identify Report name
For i = 0 To UBound(oComp.Args())
If oComp.Args(i).Name = "DocumentTitle" Then
sName = oComp.Args(i).Value
......@@ -2448,7 +2454,7 @@ Dim oWindow As _Window
Set oFrame = oComp.Frame
iType = acDiagram
sName = ""
Case "com.sun.star.comp.sfx2.BackingComp" ' Welcome screen
Case "com.sun.star.comp.sfx2.BackingComp" ' Welcome screen
Set oFrame = oComp.Frame
iType = acWelcome
sName = ""
......
......@@ -248,6 +248,7 @@ Dim oObject As Object, i As Integer
Dim sShortcut As String, sAddShortcut As String, sArray() As String
Dim sImplementation As String, oSelection As Object
Dim iCurrentDoc As Integer, oDoc As Object
Dim vPersistent As Variant
Const cstDatabaseForm = "com.sun.star.comp.forms.ODatabaseForm"
If _ErrorHandler() Then On Local Error Goto Error_Function
......@@ -353,24 +354,18 @@ Const cstDatabaseForm = "com.sun.star.comp.forms.ODatabaseForm"
sImplementation = Utils._ImplementationName(oObject)
Loop
' Add Forms! prefix
' Select Case oDoc.DbConnect
' Case DBCONNECTBASE
If Utils._hasUNOProperty(oObject, "Args") Then ' Current object is a SwXTextDocument
For i = 0 To UBound(oObject.Args)
If oObject.Args(i).Name = "DocumentTitle" Then
sAddShortcut = Utils._Surround(oObject.Args(i).Value)
Exit For
End If
Next i
End If
Select Case oDoc.DbConnect
Case DBCONNECTBASE
vPersistent = Split(oObject.StringValue, "/")
sAddShortcut = Utils._Surround(_GetHierarchicalName(vPersistent(UBound(vPersistent) - 1)))
sShortcut = "Forms!" & sAddShortcut & "!" & sShortcut
' Case DBCONNECTFORM
' sShortcut = "Forms!0!" & sShortcut
' End Select
Case DBCONNECTFORM
sShortcut = "Forms!0!" & sShortcut
End Select
sArray = Split(sShortcut, "!")
' If presence of "Forms!myform!myform.Form", eliminate 2nd element
' Eliminate anyway blanco subcomponents (e.g; Forms!!myForm)
' Eliminate anyway blanco subcomponents (e.g. Forms!!myForm)
If UBound(sArray) >= 2 Then
If UCase(sArray(1)) & ".FORM" = UCase(sArray(2)) Then sArray(1) = ""
sArray = Utils._TrimArray(sArray)
......
......@@ -21,6 +21,7 @@ Private _Name As String
Private _DocEntry As Integer ' Doc- and DbContainer entries in Root structure
Private _DbEntry As Integer
Private _MainForms As Variant
Private _PersistentName As String
Private _IsLoaded As Boolean
Private _OpenArgs As Variant
Private _OrderBy As String
......@@ -39,6 +40,7 @@ Private Sub Class_Initialize()
_DocEntry = -1
_DbEntry = -1
_MainForms = Array()
_PersistentName = ""
_IsLoaded = False
_OpenArgs = ""
_OrderBy = ""
......@@ -160,28 +162,23 @@ Function IsLoaded(ByVal Optional pbForce As Boolean) As Boolean
End If
IsLoaded = False
Dim oDoc As Object, oDatabase As Object, oEnum As Object, oDesk As Object, oComp As Object, bFound As Boolean
Dim oDoc As Object, oDatabase As Object, oEnum As Object, oDesk As Object, oComp As Object, vPersistent As Variant
Dim i As Integer
Set oDoc = _A2B_.CurrentDocument()
Select Case oDoc.DbConnect
Case DBCONNECTBASE
Set oDesk = CreateUnoService("com.sun.star.frame.Desktop")
Set oEnum = oDesk.Components().createEnumeration
bFound = False
Do While oEnum.hasMoreElements And Not bFound ' Search in all open components if one corresponds with current form
Do While oEnum.hasMoreElements ' Search in all open components if one corresponds with current form
oComp = oEnum.nextElement
If HasUnoInterfaces(oComp, "com.sun.star.frame.XModule") Then
If _hasUNOProperty(oComp, "Identifier") Then
If oComp.Identifier = "com.sun.star.sdb.FormDesign" Then
For i = 0 To UBound(oComp.Args())
If oComp.Args(i).Name = "DocumentTitle" Then
bFound = ( oComp.Args(i).Value = _Name )
If bFound Then
_IsLoaded = True
Set Component = oComp
Exit For
End If
End If
Next i
vPersistent = Split(oComp.StringValue, "/")
If vPersistent(UBound(vPersistent) - 1) = _PersistentName Then
_IsLoaded = True
Set Component = oComp
Exit Do
End If
End If
End If
Loop
......@@ -230,6 +227,7 @@ End Property ' OnApproveParameter (get)
Property Let OnApproveParameter(ByVal pvValue As Variant)
Call _PropertySet("OnApproveParameter", pvValue)
End Property ' OnApproveParameter (set)
REM -----------------------------------------------------------------------------------------------------------------------
......@@ -464,7 +462,7 @@ Dim oDatabase As Object, oController As Object
Set oDatabase = Application._CurrentDb()
If oDatabase._DbConnect <> DBCONNECTBASE Then Goto Error_NotApplicable
Set oController = oDatabase.Document.getFormDocuments.getByName(_Name)
Set oController = oDatabase.Document.getFormDocuments.getByHierarchicalName(_Name)
oController.close()
Dispose()
mClose = True
......@@ -478,7 +476,7 @@ Error_NotApplicable:
Error_Function:
TraceError(TRACEABORT, Err, "Form.Close", Erl)
GoTo Exit_Function
End Function
End Function ' Close
REM -----------------------------------------------------------------------------------------------------------------------
Public Function Controls(Optional ByVal pvIndex As Variant) As Variant
......@@ -806,8 +804,9 @@ Dim oDoc As Object, oDatabase As Object
If _ErrorHandler() Then On Local Error Goto Trace_Error
_Name = psName
_Shortcut = "Forms!" & Utils._Surround(psName)
Set oDoc = _A2B_.CurrentDocument()
If oDoc.DbConnect = DBCONNECTBASE Then _PersistentName = oDoc.Document.getFormDocuments().getByHierarchicalName(psName).PersistentName
If IsLoaded Then
Set oDoc = _A2B_.CurrentDocument()
Select Case oDoc.DbConnect
Case DBCONNECTBASE
If Not IsNull(Component.CurrentController) Then ' A form opened then closed afterwards keeps a Component attribute
......@@ -856,7 +855,7 @@ End Sub ' _Initialize V1.1.0
REM -----------------------------------------------------------------------------------------------------------------------
Private Function _PropertiesList() As Variant
If IsLoaded Then
If _IsLoaded Then
_PropertiesList = Array("AllowAdditions", "AllowDeletions", "AllowEdits", "Bookmark" _
, "Caption", "CurrentRecord", "Filter", "FilterOn", "Height", "IsLoaded" _
, "Name", "ObjectType", "OnApproveCursorMove", "OnApproveParameter" _
......
......@@ -296,4 +296,4 @@ Error_Function:
GoTo Exit_Function
End Function ' _OptionGroup V1.1.0
</script:module>
</script:module>
\ No newline at end of file
......@@ -448,7 +448,7 @@ Dim oDoc As Object
Case OBJCOLLECTION
Select Case vCurrentObject._CollType
Case COLLFORMS
vCurrentObject = Application.Forms(sComponents(iCurrentIndex))
vCurrentObject = Application.AllForms(sComponents(iCurrentIndex))
Case COLLALLDIALOGS
sDialog = UCase(sComponents(iCurrentIndex))
vCurrentObject = Application.AllDialogs(sDialog)
......
......@@ -105,9 +105,9 @@ Dim vDbContainer As Variant, vDbContainers() As Variant, vDocContainer As Varian
iCurrentDoc = CurrentDocIndex( , False) &apos; False prevents error raising if not found
If iCurrentDoc &lt; 0 Then GoTo Exit_Sub &apos; If not found ignore
vDocContainer = CurrentDoc(iCurrentDoc)
vDocContainer = CurrentDocument(iCurrentDoc)
With vDocContainer
If Not .Active Then GoTo Exit_Sub &apos; e.g. if successive calls to CloseConnection()
If Not .Active Then GoTo Exit_Sub &apos; e.g. if multiple calls to CloseConnection()
For i = 0 To UBound(.DbContainers)
If Not IsNull(.DbContainers(i).Database) Then
.DbContainers(i).Database.Dispose()
......
......@@ -726,6 +726,7 @@ Dim bIsPseudo As Boolean, bPseudoExists As Boolean, vObject As Variant
If Not bIsPseudo Then Goto Exit_Function
Dim oDoc As Object, oForms As Variant
Const cstSeparator = &quot;\;&quot;
bPseudoExists = False
With vObject
......@@ -733,12 +734,7 @@ Dim oDoc As Object, oForms As Variant
Case OBJFORM
If ._Name &lt;&gt; &quot;&quot; Then &apos; Check validity of form name
Set oDoc = _A2B_.CurrentDocument()
If oDoc.DbConnect = DBCONNECTFORM Then
bPseudoExists = True
Else
Set oForms = oDoc.Document.getFormDocuments()
bPseudoExists = ( oForms.HasByName(._Name) )
End If
If oDoc.DbConnect = DBCONNECTFORM Then bPseudoExists = True Else bPseudoExists = _InList(._Name, Application._GetAllHierarchicalNames())
End If
Case OBJDATABASE
If ._DbConnect = DBCONNECTFORM Then bPseudoExists = True Else bPseudoExists = Not IsNull(.Connection)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment