diff options
author | Jean-Pierre Ledure <jp@ledure.be> | 2020-12-04 16:02:12 +0100 |
---|---|---|
committer | Jean-Pierre Ledure <jp@ledure.be> | 2020-12-04 17:48:05 +0100 |
commit | d087459826212867e72a0031d3b2e91941140f60 (patch) | |
tree | 28cfe9d0832d3945f178827ef6f189c98da9ffc2 /wizards | |
parent | 3d0084770923ed8c17e496965abae862a4796e63 (diff) |
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 <jp@ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Diffstat (limited to 'wizards')
-rw-r--r-- | wizards/source/sfdialogs/SF_DialogControl.xba | 55 |
1 files changed, 53 insertions, 2 deletions
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 @@ -149,6 +149,20 @@ Property Get ControlType() As String 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. Default = _PropertyGet("Default", False) @@ -460,6 +474,12 @@ Property Let Picture(Optional ByVal pvPicture As Variant) 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 ''' as a zero-based array of string values @@ -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 |