wizards/source/sfdialogs/SF_DialogControl.xba | 55 +++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 2 deletions(-)
New commits: commit d087459826212867e72a0031d3b2e91941140f60 Author: Jean-Pierre Ledure <j...@ledure.be> AuthorDate: Fri Dec 4 16:02:12 2020 +0100 Commit: Jean-Pierre Ledure <j...@ledure.be> CommitDate: Fri Dec 4 17:48:05 2020 +0100 ScriptForge: RootNode/CurrentNode for tree controls RootNode returns the root node CurrentNode is for getting or setting a unique selected node Change-Id: Ie92761f57fe18b188769870ed7d2e0340a9e146c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107227 Tested-by: Jean-Pierre Ledure <j...@ledure.be> Tested-by: Jenkins Reviewed-by: Jean-Pierre Ledure <j...@ledure.be> diff --git a/wizards/source/sfdialogs/SF_DialogControl.xba b/wizards/source/sfdialogs/SF_DialogControl.xba index 3a85149f3e93..d7bfd7d6f44d 100644 --- a/wizards/source/sfdialogs/SF_DialogControl.xba +++ b/wizards/source/sfdialogs/SF_DialogControl.xba @@ -148,6 +148,20 @@ Property Get ControlType() As String ControlType = _PropertyGet("ControlType") End Property ' SFDialogs.SF_DialogControl.ControlType +REM ----------------------------------------------------------------------------- +Property Get CurrentNode() As Variant +''' The CurrentNode property returns the currently selected node +''' It returns Empty when there is no node selected +''' When there are several selections, it returns the topmost node among the selected ones + CurrentNode = _PropertyGet("CurrentNode", "") +End Property ' SFDialogs.SF_DialogControl.CurrentNode (get) + +REM ----------------------------------------------------------------------------- +Property Let CurrentNode(Optional ByVal pvCurrentNode As Variant) +''' Set a single selection in a tree control + _PropertySet("CurrentNode", pvCurrentNode) +End Property ' SFDialogs.SF_DialogControl.CurrentNode (let) + REM ----------------------------------------------------------------------------- Property Get Default() As Variant ''' The Default property specifies whether a command button is the default (OK) button. @@ -459,6 +473,12 @@ Property Let Picture(Optional ByVal pvPicture As Variant) _PropertySet("Picture", pvPicture) End Property ' SFDialogs.SF_DialogControl.Picture (let) +REM ----------------------------------------------------------------------------- +Property Get RootNode() As Variant +''' The RootNode property returns the last root node of a tree control + RootNode = _PropertyGet("RootNode", "") +End Property ' SFDialogs.SF_DialogControl.RootNode (get) + REM ----------------------------------------------------------------------------- Property Get RowSource() As Variant ''' The RowSource property specifies the data contained in a combobox or a listbox @@ -1105,7 +1125,7 @@ Private Function _PropertyGet(Optional ByVal psProperty As String _ Dim vGet As Variant ' Return value Static oSession As Object ' Alias of SF_Session -Dim vSelection As Variant ' Alias of Model.SelectedItems +Dim vSelection As Variant ' Alias of Model.SelectedItems or Model.Selection Dim vList As Variant ' Alias of Model.StringItemList Dim lIndex As Long ' Index in StringItemList Dim sItem As String ' A single item @@ -1142,6 +1162,22 @@ Const cstSubArgs = "" End Select Case UCase("ControlType") _PropertyGet = _ControlType + Case UCase("CurrentNode") + Select Case _ControlType + Case CTLTREECONTROL + If oSession.HasUNOMethod(_ControlView, "getSelection") Then + _PropertyGet = Empty + If _ControlModel.SelectionType <> com.sun.star.view.SelectionType.NONE Then + vSelection = _ControlView.getSelection() + If IsArray(vSelection) Then + If UBound(vSelection) >= 0 Then Set _PropertyGet = vSelection(0) + Else + Set _PropertyGet = vSelection + End If + End If + End If + Case Else : GoTo CatchType + End Select Case UCase("Default") Select Case _ControlType Case CTLBUTTON @@ -1223,6 +1259,12 @@ Const cstSubArgs = "" If oSession.HasUnoProperty(_ControlModel, "ImageURL") Then _PropertyGet = ScriptForge.SF_FileSystem._ConvertFromUrl(_ControlModel.ImageURL) Case Else : GoTo CatchType End Select + Case UCase("RootNode") + Select Case _ControlType + Case CTLTREECONTROL + _PropertyGet = _TreeDataModel.getRoot() + Case Else : GoTo CatchType + End Select Case UCase("RowSource") Select Case _ControlType Case CTLCOMBOBOX, CTLLISTBOX @@ -1381,6 +1423,15 @@ Const cstSubArgs = "Value" If oSession.HasUNOProperty(_ControlModel, "Label") Then _ControlModel.Label = pvValue Case Else : GoTo CatchType End Select + Case UCAse("CurrentNode") + Select Case _ControlType + 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) + Case Else : GoTo CatchType + End Select Case UCase("Default") Select Case _ControlType Case CTLBUTTON @@ -1613,4 +1664,4 @@ Private Function _Repr() As String End Function ' SFDialogs.SF_DialogControl._Repr REM ============================================ END OF SFDIALOGS.SF_DIALOGCONTROL -</script:module> +</script:module> \ No newline at end of file _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits