[Libreoffice-commits] core.git: wizards/source
Jean-Pierre Ledure (via logerrit)
logerrit at kemper.freedesktop.org
Sun Dec 6 15:55:10 UTC 2020
wizards/source/scriptforge/SF_Root.xba | 2
wizards/source/scriptforge/po/ScriptForge.pot | 6 -
wizards/source/scriptforge/po/en.po | 6 -
wizards/source/sfdialogs/SF_DialogControl.xba | 142 +++++++++++++++++++++++++-
4 files changed, 146 insertions(+), 10 deletions(-)
New commits:
commit 7fad2ed06ecd61d2752e676dfe4b3822b993e495
Author: Jean-Pierre Ledure <jp at ledure.be>
AuthorDate: Sun Dec 6 14:15:03 2020 +0100
Commit: Jean-Pierre Ledure <jp at ledure.be>
CommitDate: Sun Dec 6 16:54:29 2020 +0100
ScriptForge - (SF_DialogControl) FindNode() for tree controls
FindNode() traverses a tree recursively and stops at the 1st node
meeting either:
- DisplayValue is like a given string pattern
- DataValue is equal to a given scalar value
The returned node can easily be made current
The commit includes a check on the control type
of all methods reserved for tree controls
This has a minor impact on po files
The version number of the po files is incremented
Change-Id: I9f418df35bd4e58e0bfccc0606f5e0a5e7ac955e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107288
Tested-by: Jean-Pierre Ledure <jp at ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp at ledure.be>
diff --git a/wizards/source/scriptforge/SF_Root.xba b/wizards/source/scriptforge/SF_Root.xba
index 339cc9db81bc..74154285f551 100644
--- a/wizards/source/scriptforge/SF_Root.xba
+++ b/wizards/source/scriptforge/SF_Root.xba
@@ -752,7 +752,7 @@ Try:
' SF_DialogControl._SetProperty
.AddText( Context := "CONTROLTYPE" _
, MsgId := "The control '%1' in dialog '%2' is of type '%3'.\n" _
- & "The property '%4' is not applicable on that type of dialog controls." _
+ & "The property or method '%4' is not applicable on that type of dialog controls." _
, Comment := "SF_DialogControl property setting\n" _
& "%1: An identifier\n" _
& "%2: An identifier\n" _
diff --git a/wizards/source/scriptforge/po/ScriptForge.pot b/wizards/source/scriptforge/po/ScriptForge.pot
index 0741eff67d62..ea7209881cb7 100644
--- a/wizards/source/scriptforge/po/ScriptForge.pot
+++ b/wizards/source/scriptforge/po/ScriptForge.pot
@@ -7,14 +7,14 @@
# *** are part of the LibreOffice project. ***
# *********************************************************************
#
-# ScriptForge Release 7.1
+# ScriptForge Release 7.2
# -----------------------
#
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: https://bugs.libreoffice.org/enter_bug.cgi?product=LibreOffice&bug_status=UNCONFIRMED&component=UI\n"
-"POT-Creation-Date: 2020-10-10 16:05:30\n"
+"POT-Creation-Date: 2020-12-06 12:16:30\n"
"PO-Revision-Date: YYYY-MM-DD HH:MM:SS\n"
"Last-Translator: FULL NAME <EMAIL at ADDRESS>\n"
"Language-Team: LANGUAGE <EMAIL at ADDRESS>\n"
@@ -766,7 +766,7 @@ msgstr ""
msgctxt "CONTROLTYPE"
msgid ""
"The control '%1' in dialog '%2' is of type '%3'.\n"
-"The property '%4' is not applicable on that type of dialog controls."
+"The property or method '%4' is not applicable on that type of dialog controls."
msgstr ""
#. SF_DialogControl add line in textbox
diff --git a/wizards/source/scriptforge/po/en.po b/wizards/source/scriptforge/po/en.po
index 0741eff67d62..ea7209881cb7 100644
--- a/wizards/source/scriptforge/po/en.po
+++ b/wizards/source/scriptforge/po/en.po
@@ -7,14 +7,14 @@
# *** are part of the LibreOffice project. ***
# *********************************************************************
#
-# ScriptForge Release 7.1
+# ScriptForge Release 7.2
# -----------------------
#
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: https://bugs.libreoffice.org/enter_bug.cgi?product=LibreOffice&bug_status=UNCONFIRMED&component=UI\n"
-"POT-Creation-Date: 2020-10-10 16:05:30\n"
+"POT-Creation-Date: 2020-12-06 12:16:30\n"
"PO-Revision-Date: YYYY-MM-DD HH:MM:SS\n"
"Last-Translator: FULL NAME <EMAIL at ADDRESS>\n"
"Language-Team: LANGUAGE <EMAIL at ADDRESS>\n"
@@ -766,7 +766,7 @@ msgstr ""
msgctxt "CONTROLTYPE"
msgid ""
"The control '%1' in dialog '%2' is of type '%3'.\n"
-"The property '%4' is not applicable on that type of dialog controls."
+"The property or method '%4' is not applicable on that type of dialog controls."
msgstr ""
#. SF_DialogControl add line in textbox
diff --git a/wizards/source/sfdialogs/SF_DialogControl.xba b/wizards/source/sfdialogs/SF_DialogControl.xba
index d7bfd7d6f44d..95f99a245f33 100644
--- a/wizards/source/sfdialogs/SF_DialogControl.xba
+++ b/wizards/source/sfdialogs/SF_DialogControl.xba
@@ -596,6 +596,7 @@ Const cstSubArgs = "ParentNode, DisplayValue, [DataValue=Empty]"
Check:
If IsMissing(DataValue) Then DataValue = Empty
If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
+ If _ControlType <> CTLTREECONTROL Then GoTo CatchType
If Not ScriptForge.SF_Utils._Validate(ParentNode, "ParentNode", V_OBJECT) Then GoTo Catch
If ScriptForge.SF_Session.UnoObjectType(ParentNode) <> "toolkit.MutableTreeNode" Then GoTo Catch
If Not ScriptForge.SF_Utils._Validate(DisplayValue, "DisplayValue", V_STRING) Then GoTo Catch
@@ -614,6 +615,9 @@ Finally:
Exit Function
Catch:
GoTo Finally
+CatchType:
+ ScriptForge.SF_Exception.RaiseFatal(CONTROLTYPEERROR, _Name, _DialogName, _ControlType, "AddSubNode")
+ GoTo Finally
End Function ' SFDialogs.SF_DialogControl.AddSubNode
REM -----------------------------------------------------------------------------
@@ -676,6 +680,7 @@ Const cstSubArgs = "ParentNode, FlatTree, [WithDataValue=False]"
Check:
If IsMissing(WithDataValue) Or IsEmpty(WithDataValue) Then WithDataValue = False
If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
+ If _ControlType <> CTLTREECONTROL Then GoTo CatchType
If Not ScriptForge.SF_Utils._Validate(ParentNode, "ParentNode", V_OBJECT) Then GoTo Catch
If ScriptForge.SF_Session.UnoObjectType(ParentNode) <> "toolkit.MutableTreeNode" Then GoTo Catch
If Not ScriptForge.SF_Utils._ValidateArray(FlatTree, "FlatTree", 2) Then GoTo Catch
@@ -725,6 +730,9 @@ Finally:
Exit Function
Catch:
GoTo Finally
+CatchType:
+ ScriptForge.SF_Exception.RaiseFatal(CONTROLTYPEERROR, _Name, _DialogName, _ControlType, "AddSubTree")
+ GoTo Finally
End Function ' SFDialogs.SF_DialogControl.AddSubTree
REM -----------------------------------------------------------------------------
@@ -752,6 +760,7 @@ Const cstSubArgs = "DisplayValue, [DataValue=Empty]"
Check:
If IsMissing(DataValue) Then DataValue = Empty
If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
+ If _ControlType <> CTLTREECONTROL Then GoTo CatchType
If Not ScriptForge.SF_Utils._Validate(DisplayValue, "DisplayValue", V_STRING) Then GoTo Catch
End If
@@ -772,8 +781,65 @@ Finally:
Exit Function
Catch:
GoTo Finally
+CatchType:
+ ScriptForge.SF_Exception.RaiseFatal(CONTROLTYPEERROR, _Name, _DialogName, _ControlType, "CreateRoot")
+ GoTo Finally
End Function ' SFDialogs.SF_DialogControl.CreateRoot
+REM -----------------------------------------------------------------------------
+Public Function FindNode(Optional ByVal DisplayValue As String _
+ , Optional ByRef DataValue As Variant _
+ , Optional ByVal CaseSensitive As Boolean _
+ ) As Object
+''' Traverses the tree and find recursively, starting from the root, a node meeting some criteria
+''' Either (1 match is enough):
+''' having its DisplayValue like DisplayValue
+''' having its DataValue = DataValue
+''' Comparisons may be or not case-sensitive
+''' The first matching occurrence is returned
+''' Args:
+''' DisplayValue: the pattern to be matched
+''' DataValue: a string, a numeric value or a date or Empty (if not applicable)
+''' CaseSensitive: applicable on both criteria. Default = False
+''' Returns:
+''' The found node of type com.sun.star.awt.tree.XMutableTreeNode or Nothing if not found
+''' Examples:
+''' Dim myTree As Object, myNode As Object
+''' Set myTree = myDialog.Controls("myTreeControl")
+''' Set myNode = myTree.FindNode("*Sophie*", CaseSensitive := True)
+
+
+Dim oNode As Object ' Return value
+Const cstThisSub = "SFDialogs.DialogControl.FindNode"
+Const cstSubArgs = "[DisplayValue=""""], [DataValue=Empty], [CaseSensitive=False]"
+
+ If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
+ Set oNode = Nothing
+
+Check:
+ If IsMissing(DisplayValue) Or IsEmpty(DisplayValue) Then DisplayValue = ""
+ If IsMissing(DataValue) Then DataValue = Empty
+ If IsMissing(CaseSensitive) Or IsEmpty(CaseSensitive) Then CaseSensitive = False
+ If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
+ If _ControlType <> CTLTREECONTROL Then GoTo CatchType
+ If Not ScriptForge.SF_Utils._Validate(DisplayValue, "DisplayValue", V_STRING) Then GoTo Catch
+ If Not ScriptForge.SF_Utils._Validate(CaseSensitive, "CaseSensitive", ScriptForge.V_BOOLEAN) Then GoTo Catch
+ End If
+
+Try:
+ Set oNode = _FindNode(_TreeDataModel.getRoot(), DisplayValue, DataValue, CaseSensitive)
+
+Finally:
+ Set FindNode = oNode
+ ScriptForge.SF_Utils._ExitFunction(cstThisSub)
+ Exit Function
+Catch:
+ GoTo Finally
+CatchType:
+ ScriptForge.SF_Exception.RaiseFatal(CONTROLTYPEERROR, _Name, _DialogName, _ControlType, "FindNode")
+ GoTo Finally
+End Function ' SFDialogs.SF_DialogControl.FindNode
+
REM -----------------------------------------------------------------------------
Public Function GetProperty(Optional ByVal PropertyName As Variant) As Variant
''' Return the actual value of the given property
@@ -813,7 +879,11 @@ Public Function Methods() As Variant
''' Return the list of public methods of the Model service as an array
Methods = Array( _
- "SetFocus" _
+ "AddSubNode" _
+ , "AddSubTree" _
+ , "CreateRoot" _
+ , "FindNode" _
+ , "SetFocus" _
, "WriteLine" _
)
@@ -1002,6 +1072,67 @@ End Function ' SFControls.SF_DialogControl.WriteLine
REM =========================================================== PRIVATE FUNCTIONS
+REM -----------------------------------------------------------------------------
+Private Function _FindNode(ByRef poNode As Object _
+ , ByVal psDisplayValue As String _
+ , ByRef pvDataValue As Variant _
+ , ByVal pbCaseSensitive As Boolean _
+ ) As Object
+''' Traverses the tree and find recursively, starting from the root, a node meeting some criteria
+''' Either (1 match is enough):
+''' having its DisplayValue like psDisplayValue
+''' having its DataValue = pvDataValue
+''' Comparisons may be or not case-sensitive
+''' The first matching occurrence is returned
+''' Args:
+''' poNode: the current node, the root at 1st call
+''' psDisplayValue: the pattern to be matched
+''' pvDataValue: a string, a numeric value or a date or Empty (if not applicable)
+''' pbCaseSensitive: applicable on both criteria
+''' Returns:
+''' The found node of type com.sun.star.awt.tree.XMutableTreeNode
+
+Dim oChild As Object ' Child node com.sun.star.awt.tree.XMutableTreeNode
+Dim oFind As Object ' Found node com.sun.star.awt.tree.XMutableTreeNode
+Dim lChildCount As Long ' Number of children of a node
+Dim bFound As Boolean ' True when node found
+Dim i As Long
+
+ Set _FindNode = Nothing
+ On Local Error GoTo Finally ' Better not found than raise an error
+
+Check:
+ ' Does the actual node match the criteria ?
+ bFound = False
+ If Len(psDisplayValue) > 0 Then
+ bFound = ScriptForge.SF_String.IsLike(poNode.DisplayValue, psDisplayValue, pbCaseSensitive)
+ End If
+ If Not bFound And Not IsEmpty(poNode.DataValue) Then
+ If Not IsEmpty(pvdataValue) Then bFound = ( ScriptForge.SF_Array._ValCompare(poNode.DataValue, pvDataB-Value, pbCaseSensitive) = 0 )
+ End If
+ If bFound Then
+ Set _FindNode = poNode
+ Exit Function
+ End If
+
+Try:
+ ' Explore sub-branches
+ lChildCount = poNode.getChildCount
+ If lChildCount > 0 Then
+ For i = 0 To lChildCount - 1
+ Set oChild = poNode.getChildAt(i)
+ Set oFind = _FindNode(oChild, psDisplayValue, pvDataValue, pbCaseSensitive) ' Recursive call
+ If Not IsNull(oFind) Then
+ Set _FindNode = oFind
+ Exit For
+ End If
+ Next i
+ End If
+
+Finally:
+ Exit Function
+End Function ' SFDialogs.SF_DialogControl._FindNode
+
REM -----------------------------------------------------------------------------
Private Function _FormatsList() As Variant
''' Return the allowed format entries as a zero-based array for Date and Time control types
@@ -1428,8 +1559,13 @@ Const cstSubArgs = "Value"
Case CTLTREECONTROL
If Not ScriptForge.SF_Utils._Validate(pvValue, "Selection", ScriptForge.V_OBJECT) Then GoTo Finally
If oSession.UnoObjectType(pvValue) <> "toolkit.MutableTreeNode" Then GoTo CatchType
- _ControlView.clearSelection()
- _ControlView.addSelection(pvValue)
+ With _ControlView
+ .clearSelection()
+ If Not IsNull(pvValue) Then
+ .addSelection(pvValue)
+ .makeNodeVisible(pvValue) ' Expand parent nodes and put node in the display area
+ End If
+ End With
Case Else : GoTo CatchType
End Select
Case UCase("Default")
More information about the Libreoffice-commits
mailing list