summaryrefslogtreecommitdiff
path: root/wizards
diff options
context:
space:
mode:
authorJean-Pierre Ledure <jp@ledure.be>2020-12-04 16:02:12 +0100
committerJean-Pierre Ledure <jp@ledure.be>2020-12-04 17:48:05 +0100
commitd087459826212867e72a0031d3b2e91941140f60 (patch)
tree28cfe9d0832d3945f178827ef6f189c98da9ffc2 /wizards
parent3d0084770923ed8c17e496965abae862a4796e63 (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.xba55
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 &apos; SFDialogs.SF_DialogControl.ControlType
REM -----------------------------------------------------------------------------
+Property Get CurrentNode() As Variant
+&apos;&apos;&apos; The CurrentNode property returns the currently selected node
+&apos;&apos;&apos; It returns Empty when there is no node selected
+&apos;&apos;&apos; When there are several selections, it returns the topmost node among the selected ones
+ CurrentNode = _PropertyGet(&quot;CurrentNode&quot;, &quot;&quot;)
+End Property &apos; SFDialogs.SF_DialogControl.CurrentNode (get)
+
+REM -----------------------------------------------------------------------------
+Property Let CurrentNode(Optional ByVal pvCurrentNode As Variant)
+&apos;&apos;&apos; Set a single selection in a tree control
+ _PropertySet(&quot;CurrentNode&quot;, pvCurrentNode)
+End Property &apos; SFDialogs.SF_DialogControl.CurrentNode (let)
+
+REM -----------------------------------------------------------------------------
Property Get Default() As Variant
&apos;&apos;&apos; The Default property specifies whether a command button is the default (OK) button.
Default = _PropertyGet(&quot;Default&quot;, False)
@@ -460,6 +474,12 @@ Property Let Picture(Optional ByVal pvPicture As Variant)
End Property &apos; SFDialogs.SF_DialogControl.Picture (let)
REM -----------------------------------------------------------------------------
+Property Get RootNode() As Variant
+&apos;&apos;&apos; The RootNode property returns the last root node of a tree control
+ RootNode = _PropertyGet(&quot;RootNode&quot;, &quot;&quot;)
+End Property &apos; SFDialogs.SF_DialogControl.RootNode (get)
+
+REM -----------------------------------------------------------------------------
Property Get RowSource() As Variant
&apos;&apos;&apos; The RowSource property specifies the data contained in a combobox or a listbox
&apos;&apos;&apos; as a zero-based array of string values
@@ -1105,7 +1125,7 @@ Private Function _PropertyGet(Optional ByVal psProperty As String _
Dim vGet As Variant &apos; Return value
Static oSession As Object &apos; Alias of SF_Session
-Dim vSelection As Variant &apos; Alias of Model.SelectedItems
+Dim vSelection As Variant &apos; Alias of Model.SelectedItems or Model.Selection
Dim vList As Variant &apos; Alias of Model.StringItemList
Dim lIndex As Long &apos; Index in StringItemList
Dim sItem As String &apos; A single item
@@ -1142,6 +1162,22 @@ Const cstSubArgs = &quot;&quot;
End Select
Case UCase(&quot;ControlType&quot;)
_PropertyGet = _ControlType
+ Case UCase(&quot;CurrentNode&quot;)
+ Select Case _ControlType
+ Case CTLTREECONTROL
+ If oSession.HasUNOMethod(_ControlView, &quot;getSelection&quot;) Then
+ _PropertyGet = Empty
+ If _ControlModel.SelectionType &lt;&gt; com.sun.star.view.SelectionType.NONE Then
+ vSelection = _ControlView.getSelection()
+ If IsArray(vSelection) Then
+ If UBound(vSelection) &gt;= 0 Then Set _PropertyGet = vSelection(0)
+ Else
+ Set _PropertyGet = vSelection
+ End If
+ End If
+ End If
+ Case Else : GoTo CatchType
+ End Select
Case UCase(&quot;Default&quot;)
Select Case _ControlType
Case CTLBUTTON
@@ -1223,6 +1259,12 @@ Const cstSubArgs = &quot;&quot;
If oSession.HasUnoProperty(_ControlModel, &quot;ImageURL&quot;) Then _PropertyGet = ScriptForge.SF_FileSystem._ConvertFromUrl(_ControlModel.ImageURL)
Case Else : GoTo CatchType
End Select
+ Case UCase(&quot;RootNode&quot;)
+ Select Case _ControlType
+ Case CTLTREECONTROL
+ _PropertyGet = _TreeDataModel.getRoot()
+ Case Else : GoTo CatchType
+ End Select
Case UCase(&quot;RowSource&quot;)
Select Case _ControlType
Case CTLCOMBOBOX, CTLLISTBOX
@@ -1381,6 +1423,15 @@ Const cstSubArgs = &quot;Value&quot;
If oSession.HasUNOProperty(_ControlModel, &quot;Label&quot;) Then _ControlModel.Label = pvValue
Case Else : GoTo CatchType
End Select
+ Case UCAse(&quot;CurrentNode&quot;)
+ Select Case _ControlType
+ Case CTLTREECONTROL
+ If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;Selection&quot;, ScriptForge.V_OBJECT) Then GoTo Finally
+ If oSession.UnoObjectType(pvValue) &lt;&gt; &quot;toolkit.MutableTreeNode&quot; Then GoTo CatchType
+ _ControlView.clearSelection()
+ _ControlView.addSelection(pvValue)
+ Case Else : GoTo CatchType
+ End Select
Case UCase(&quot;Default&quot;)
Select Case _ControlType
Case CTLBUTTON
@@ -1613,4 +1664,4 @@ Private Function _Repr() As String
End Function &apos; SFDialogs.SF_DialogControl._Repr
REM ============================================ END OF SFDIALOGS.SF_DIALOGCONTROL
-</script:module>
+</script:module> \ No newline at end of file