summaryrefslogtreecommitdiff
path: root/wizards/source
diff options
context:
space:
mode:
authorJean-Pierre Ledure <jp@ledure.be>2020-12-08 15:06:31 +0100
committerJean-Pierre Ledure <jp@ledure.be>2020-12-08 16:31:11 +0100
commit5fa2182d3b5c79bc4cf8ec9621228ddc00283a1f (patch)
treeb0c259d753ec784e463d46841beec3af9c0658fc /wizards/source
parent73d592f963c4135b36c4417436bf14c87e1cf0d4 (diff)
ScriptForge - (SFDialogs) OnNodeSelected/Expanded for tree controls
OnNodeSelected and OnNodeExpanded cannot be defined thru the Basic IDE Those editable new properties are used to set up the relevant listeners on the control's view The listener Subs are garthered in a new module, SF_DialogListener The need to preserve these 2 properties required the existence of a cache of all control objects in the parent dialog instance This technique with listeners can be reused (mutatis mutandis) in other contexts to introduce additional event types Change-Id: I243808590e0534901e041a5f5abad64eb5e118d2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107420 Tested-by: Jean-Pierre Ledure <jp@ledure.be> Tested-by: Jenkins Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Diffstat (limited to 'wizards/source')
-rw-r--r--wizards/source/scriptforge/SF_Exception.xba2
-rw-r--r--wizards/source/scriptforge/SF_Session.xba46
-rw-r--r--wizards/source/sfdialogs/SF_Dialog.xba54
-rw-r--r--wizards/source/sfdialogs/SF_DialogControl.xba84
-rw-r--r--wizards/source/sfdialogs/SF_DialogListener.xba113
-rw-r--r--wizards/source/sfdialogs/SF_Register.xba11
-rw-r--r--wizards/source/sfdialogs/script.xlb1
7 files changed, 274 insertions, 37 deletions
diff --git a/wizards/source/scriptforge/SF_Exception.xba b/wizards/source/scriptforge/SF_Exception.xba
index a7dc6b418304..5a04fc0bca29 100644
--- a/wizards/source/scriptforge/SF_Exception.xba
+++ b/wizards/source/scriptforge/SF_Exception.xba
@@ -1104,4 +1104,4 @@ Private Function _Repr() As String
End Function &apos; ScriptForge.SF_Exception._Repr
REM ============================================ END OF SCRIPTFORGE.SF_EXCEPTION
-</script:module>
+</script:module> \ No newline at end of file
diff --git a/wizards/source/scriptforge/SF_Session.xba b/wizards/source/scriptforge/SF_Session.xba
index a41bffa51377..84351de24add 100644
--- a/wizards/source/scriptforge/SF_Session.xba
+++ b/wizards/source/scriptforge/SF_Session.xba
@@ -42,7 +42,7 @@ REM ============================================================ MODULE CONSTANT
&apos;&apos;&apos; ExecuteBasicScript()
&apos;&apos;&apos; ExecutePythonScript()
&apos;&apos;&apos; Example:
-&apos;&apos;&apos; session.ExecuteBasicScript(session.SCRIPTISEMBEDDED, &quot;Standard.myLib.myFunc&quot;, etc)
+&apos;&apos;&apos; session.ExecuteBasicScript(session.SCRIPTISEMBEDDED, &quot;Standard.myModule.myFunc&quot;, etc)
Const cstSCRIPTISEMBEDDED = &quot;document&quot; &apos; a library of the document (BASIC + PYTHON)
Const cstSCRIPTISAPPLICATION = &quot;application&quot; &apos; a shared library (BASIC)
@@ -52,6 +52,11 @@ Const cstSCRIPTISSHARED = &quot;share&quot; &apos; a library of LibreOffic
Const cstSCRIPTISSHAROXT = &quot;share:uno_packages&quot; &apos; an extension for all users (PYTHON)
Const cstSCRIPTISOXT = &quot;uno_packages&quot; &apos; an extension but install params are unknown (PYTHON)
+&apos;&apos;&apos; To build or to parse scripting framework URI&apos;s
+Const cstScript1 = &quot;vnd.sun.star.script:&quot;
+Const cstScript2 = &quot;?language=&quot;
+Const cstScript3 = &quot;&amp;location=&quot;
+
REM ===================================================== CONSTRUCTOR/DESTRUCTOR
REM -----------------------------------------------------------------------------
@@ -861,6 +866,42 @@ End Function &apos; ScriptForge.SF_Session.WebService
REM =========================================================== PRIVATE FUNCTIONS
REM -----------------------------------------------------------------------------
+Private Function _ExecuteScript(ByVal psScript As String _
+ , ByRef poEvent As Object _
+ ) As Variant
+&apos;&apos;&apos; Execute the script expressed in the scripting framework_URI notation
+&apos;&apos;&apos; Args:
+&apos;&apos;&apos; psScript: read https://wiki.openoffice.org/wiki/Documentation/DevGuide/Scripting/Scripting_Framework_URI_Specification
+&apos;&apos;&apos; poEvent: the event object which triggered the execution. It is given as argument to the called script
+&apos;&apos;&apos; Returns:
+&apos;&apos;&apos; The return value after the script execution. May be ignored for events
+
+Dim sScope As String &apos; The scope part of the script URI
+Dim sLanguage As String &apos; The language part of the script URI
+Dim sScript As String &apos; The script part of the script URI
+Dim vStrings As Variant &apos; Array of strings: (script, language, scope)
+Const cstComma = &quot;,&quot;
+
+Try:
+ If ScriptForge.SF_String.StartsWith(psScript, cstScript1) Then
+ &apos; Parse script
+ vStrings = Split( _
+ Replace( _
+ Replace(Mid(psScript, Len(cstScript1) + 1), cstScript2, cstComma) _
+ , cstScript3, cstComma) _
+ , cstComma)
+ sScript = vStrings(0) : sLanguage = vStrings(1) : sScope = vStrings(2)
+ &apos; Execute script
+ If UCase(sLanguage) = &quot;BASIC&quot; Then
+ _ExecuteScript = ExecuteBasicScript(sScope, sScript, poEvent)
+ Else &apos; Python
+ _ExecuteScript = ExecutePythonScript(sScope, sScript, poEvent)
+ End If
+ End If
+
+End Function &apos; ScriptForge.SF_Session._ExecuteScript
+
+REM -----------------------------------------------------------------------------
Private Function _GetScript(ByVal psLanguage As String _
, ByVal psScope As String _
, ByVal psScript As String _
@@ -881,9 +922,6 @@ Private Function _GetScript(ByVal psLanguage As String _
Dim sScript As String &apos; The complete script string
Dim oScriptProvider As Object &apos; Script provider singleton
Dim oScript As Object &apos; Return value
-Const cstScript1 = &quot;vnd.sun.star.script:&quot;
-Const cstScript2 = &quot;?language=&quot;
-Const cstScript3 = &quot;&amp;location=&quot;
Try:
&apos; Build script string
diff --git a/wizards/source/sfdialogs/SF_Dialog.xba b/wizards/source/sfdialogs/SF_Dialog.xba
index 3d293e77e125..88869534a581 100644
--- a/wizards/source/sfdialogs/SF_Dialog.xba
+++ b/wizards/source/sfdialogs/SF_Dialog.xba
@@ -70,20 +70,15 @@ Private _DialogModel As Object &apos; com.sun.star.awt.XControlModel - stardiv
Private _Displayed As Boolean &apos; True after Execute()
Private _Modal As Boolean &apos; Set by Execute()
-&apos; Cache for TreeControl events
-Private _TreeCache As Object &apos; Dictionary: key = control name, item = _TreeControl
-
-Type _TreeControl
- OnNodeSelected As String
- OnNodeExpanded As String
-End Type
+&apos; Persistent storage for controls
+Private _ControlCache As Variant &apos; Array of control objects sorted like ElementNames of the Dialog model
REM ============================================================ MODULE CONSTANTS
Private Const OKBUTTON = 1
Private Const CANCELBUTTON = 0
-REM ===================================================== CONSTRUCTOR/DESTRUCTOR
+REM ====================================================== CONSTRUCTOR/DESTRUCTOR
REM -----------------------------------------------------------------------------
Private Sub Class_Initialize()
@@ -100,7 +95,7 @@ Private Sub Class_Initialize()
Set _DialogModel = Nothing
_Displayed = False
_Modal = True
- Set _TreeCache = ScriptForge.SF_Services.CreateScriptService(&quot;Dictionary&quot;)
+ _ControlCache = Array()
End Sub &apos; SFDialogs.SF_Dialog Constructor
REM -----------------------------------------------------------------------------
@@ -381,7 +376,9 @@ Public Function Controls(Optional ByVal ControlName As Variant) As Variant
&apos;&apos;&apos; myList = myDialog.Controls()
&apos;&apos;&apos; Set myControl = myDialog.Controls(&quot;myTextBox&quot;)
-Dim oControl As Object &apos; The new control class instance
+Dim oControl As Object &apos; The new control class instance
+Dim lIndexOfNames As Long &apos; Index in ElementNames array. Used to access _ControlCache
+Dim vControl As Variant &apos; Alias of _ControlCache entry
Const cstThisSub = &quot;SFDialogs.Dialog.Controls&quot;
Const cstSubArgs = &quot;[ControlName]&quot;
@@ -399,17 +396,25 @@ Try:
Controls = _DialogModel.getElementNames()
Else
If Not _DialogModel.hasByName(ControlName) Then GoTo CatchNotFound
- &apos; Create the new dialog control class instance
- Set oControl = New SF_DialogControl
- With oControl
- ._Name = ControlName
- Set .[Me] = oControl
- Set .[_Parent] = [Me]
- ._DialogName = _Name
- Set ._ControlModel = _DialogModel.getByName(ControlName)
- Set ._ControlView = _DialogControl.getControl(ControlName)
- ._Initialize()
- End With
+ lIndexOfNames = ScriptForge.IndexOf(_DialogModel.getElementNames(), ControlName, CaseSensitive := True)
+ &apos; Reuse cache when relevant
+ vControl = _ControlCache(lIndexOfNames)
+ If IsEmpty(vControl) Then
+ &apos; Create the new dialog control class instance
+ Set oControl = New SF_DialogControl
+ With oControl
+ ._Name = ControlName
+ Set .[Me] = oControl
+ Set .[_Parent] = [Me]
+ ._IndexOfNames = ScriptForge.IndexOf(_DialogModel.getElementNames(), ControlName, CaseSensitive := True)
+ ._DialogName = _Name
+ Set ._ControlModel = _DialogModel.getByName(ControlName)
+ Set ._ControlView = _DialogControl.getControl(ControlName)
+ ._Initialize()
+ End With
+ Else
+ Set oControl = vControl
+ End If
Set Controls = oControl
End If
@@ -710,6 +715,7 @@ Public Sub _Initialize()
&apos;&apos;&apos; - Initialization of private members
&apos;&apos;&apos; - Creation of the dialog graphical interface
&apos;&apos;&apos; - Addition of the new object in the Dialogs buffer
+&apos;&apos;&apos; - Initialisation of persistent storage for controls
Try:
&apos; Create the graphical interface
@@ -718,7 +724,11 @@ Try:
&apos; Add dialog reference to cache
_CacheIndex = SF_Register._AddDialogToCache(_DialogControl, [Me])
- 85
+
+ &apos; Size the persistent storage
+ _ControlCache = Array()
+ ReDim _ControlCache(0 To UBound(_DialogModel.getElementNames()))
+
Finally:
Exit Sub
End Sub &apos; SFDialogs.SF_Dialog._Initialize
diff --git a/wizards/source/sfdialogs/SF_DialogControl.xba b/wizards/source/sfdialogs/SF_DialogControl.xba
index 95f99a245f33..f635043ac8b1 100644
--- a/wizards/source/sfdialogs/SF_DialogControl.xba
+++ b/wizards/source/sfdialogs/SF_DialogControl.xba
@@ -25,7 +25,7 @@ Option Explicit
&apos;&apos;&apos;
&apos;&apos;&apos; A special attention is given to controls with type TreeControl.
&apos;&apos;&apos; It is easy with the API proposed in the current class to populate a tree, either
-&apos;&apos;&apos; - branch by branch (CreateRoot and AddChild), or
+&apos;&apos;&apos; - branch by branch (CreateRoot and AddSubNode), or
&apos;&apos;&apos; - with a set of branches at once (AddSubtree)
&apos;&apos;&apos; Additionally populating a TreeControl can be done statically or dynamically
&apos;&apos;&apos;
@@ -54,6 +54,7 @@ Private ServiceName As String
&apos; Control naming
Private _Name As String
+Private _IndexOfNames As Long &apos; Index in ElementNames array. Used to access SF_Dialog._ControlCache
Private _DialogName As String &apos; Parent dialog name
&apos; Control UNO references
@@ -65,6 +66,13 @@ Private _TreeDataModel As Object &apos; com.sun.star.awt.tree.MutableTreeDataM
Private _ImplementationName As String
Private _ControlType As String &apos; One of the CTLxxx constants
+&apos; Tree control on-select and on-expand attributes
+&apos; Tree controls may be associated with events not defined in the Basic IDE
+Private _OnNodeSelected As String &apos; Script to invoke when a node is selected
+Private _OnNodeExpanded As String &apos; Script to invoke when a node is expanded
+Private _SelectListener As Object &apos; com.sun.star.view.XSelectionChangeListener
+Private _ExpandListener As Object &apos; com.sun.star.awt.tree.XTreeExpansionListener
+
REM ============================================================ MODULE CONSTANTS
Private Const CTLBUTTON = &quot;Button&quot;
@@ -88,7 +96,7 @@ Private Const CTLTEXTFIELD = &quot;TextField&quot;
Private Const CTLTIMEFIELD = &quot;TimeField&quot;
Private Const CTLTREECONTROL = &quot;TreeControl&quot;
-REM ===================================================== CONSTRUCTOR/DESTRUCTOR
+REM ====================================================== CONSTRUCTOR/DESTRUCTOR
REM -----------------------------------------------------------------------------
Private Sub Class_Initialize()
@@ -97,12 +105,17 @@ Private Sub Class_Initialize()
ObjectType = &quot;DIALOGCONTROL&quot;
ServiceName = &quot;SFDialogs.DialogControl&quot;
_Name = &quot;&quot;
+ _IndexOfNames = -1
_DialogName = &quot;&quot;
Set _ControlModel = Nothing
Set _ControlView = Nothing
Set _TreeDataModel = Nothing
_ImplementationName = &quot;&quot;
_ControlType = &quot;&quot;
+ _OnNodeSelected = &quot;&quot;
+ _OnNodeExpanded = &quot;&quot;
+ Set _SelectListener = Nothing
+ Set _ExpandListener = Nothing
End Sub &apos; SFDialogs.SF_DialogControl Constructor
REM -----------------------------------------------------------------------------
@@ -918,6 +931,8 @@ Public Function Properties() As Variant
, &quot;OnMouseMoved&quot; _
, &quot;OnMousePressed&quot; _
, &quot;OnMouseReleased&quot; _
+ , &quot;OnNodeExpanded&quot; _
+ , &quot;OnNodeSelected&quot; _
, &quot;OnTextChanged&quot; _
, &quot;Page&quot; _
, &quot;Parent&quot; _
@@ -1218,10 +1233,12 @@ REM ----------------------------------------------------------------------------
Public Sub _Initialize()
&apos;&apos;&apos; Complete the object creation process:
&apos;&apos;&apos; - Initialization of private members
-&apos;&apos;&apos; - Collection of main attributes
+&apos;&apos;&apos; - Collection of specific attributes
+&apos;&apos;&apos; - synchonization with parent dialog instance
Dim vServiceName As Variant &apos; Split service name
Dim sType As String &apos; Last component of service name
+
Try:
_ImplementationName = _ControlModel.getImplementationName()
@@ -1232,13 +1249,17 @@ Try:
Case &quot;UnoControlSpinButtonModel&quot;
_ControlType = &quot;&quot; &apos; Not supported
Case &quot;Edit&quot; : _ControlType = CTLTEXTFIELD
- Case &quot;TreeControlModel&quot; &apos; Initialize the data model
+ Case &quot;TreeControlModel&quot;
+ &apos; Initialize the data model
_ControlType = CTLTREECONTROL
Set _ControlModel.DataModel = ScriptForge.SF_Utils._GetUNOService(&quot;TreeDataModel&quot;)
_TreeDataModel = _ControlModel.DataModel
Case Else : _ControlType = sType
End Select
-
+
+ &apos; Store the SF_DialogControl object in the parent cache
+ Set _Parent._ControlCache(_IndexOfNames) = [Me]
+
Finally:
Exit Sub
End Sub &apos; SFDialogs.SF_DialogControl._Initialize
@@ -1380,6 +1401,18 @@ Const cstSubArgs = &quot;&quot;
Else
_PropertyGet = &quot;&quot;
End If
+ Case UCase(&quot;OnNodeExpanded&quot;)
+ Select Case _ControlType
+ Case CTLTREECONTROL
+ _PropertyGet = _OnNodeExpanded
+ Case Else : GoTo CatchType
+ End Select
+ Case UCase(&quot;OnNodeSelected&quot;)
+ Select Case _ControlType
+ Case CTLTREECONTROL
+ _PropertyGet = _OnNodeSelected
+ Case Else : GoTo CatchType
+ End Select
Case UCase(&quot;Page&quot;)
If oSession.HasUnoProperty(_ControlModel, &quot;Step&quot;) Then _PropertyGet = _ControlModel.Step
Case UCase(&quot;Parent&quot;)
@@ -1563,7 +1596,10 @@ Const cstSubArgs = &quot;Value&quot;
.clearSelection()
If Not IsNull(pvValue) Then
.addSelection(pvValue)
- .makeNodeVisible(pvValue) &apos; Expand parent nodes and put node in the display area
+ &apos; Suspending temporarily the expansion listener avoids conflicts
+ If Len(_OnNodeExpanded) &gt; 0 Then _ControlView.removeTreeExpansionListener(_ExpandListener)
+ .makeNodeVisible(pvValue) &apos; Expand parent nodes and put node in the display area
+ If Len(_OnNodeExpanded) &gt; 0 Then _ControlView.addTreeExpansionListener(_ExpandListener)
End If
End With
Case Else : GoTo CatchType
@@ -1650,6 +1686,42 @@ Const cstSubArgs = &quot;Value&quot;
, _GetListener(psProperty) _
, pvValue _
)
+ Case UCase(&quot;OnNodeExpanded&quot;)
+ Select Case _ControlType
+ Case CTLTREECONTROL
+ If Not ScriptForge.SF_Utils._Validate(pvValue, psProperty, V_STRING) Then GoTo Finally
+ &apos; If the listener was already set, then stop it
+ If Len(_OnNodeExpanded) &gt; 0 Then
+ _ControlView.removeTreeExpansionListener(_ExpandListener)
+ Set _ExpandListener = Nothing
+ _OnNodeExpanded = &quot;&quot;
+ End If
+ &apos; Setup a new fresh listener
+ If Len(pvValue) &gt; 0 Then
+ Set _ExpandListener = CreateUnoListener(&quot;_SFEXP_&quot;, &quot;com.sun.star.awt.tree.XTreeExpansionListener&quot;)
+ _ControlView.addTreeExpansionListener(_ExpandListener)
+ _OnNodeExpanded = pvValue
+ End If
+ Case Else : GoTo CatchType
+ End Select
+ Case UCase(&quot;OnNodeSelected&quot;)
+ Select Case _ControlType
+ Case CTLTREECONTROL
+ If Not ScriptForge.SF_Utils._Validate(pvValue, psProperty, V_STRING) Then GoTo Finally
+ &apos; If the listener was already set, then stop it
+ If Len(_OnNodeSelected) &gt; 0 Then
+ _ControlView.removeSelectionChangeListener(_SelectListener)
+ Set _SelectListener = Nothing
+ _OnNodeSelected = &quot;&quot;
+ End If
+ &apos; Setup a new fresh listener
+ If Len(pvValue) &gt; 0 Then
+ Set _SelectListener = CreateUnoListener(&quot;_SFSEL_&quot;, &quot;com.sun.star.view.XSelectionChangeListener&quot;)
+ _ControlView.addSelectionChangeListener(_SelectListener)
+ _OnNodeSelected = pvValue
+ End If
+ Case Else : GoTo CatchType
+ End Select
Case UCase(&quot;Page&quot;)
If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;Page&quot;, ScriptForge.V_NUMERIC) Then GoTo Finally
If oSession.HasUnoProperty(_ControlModel, &quot;Step&quot;) Then _ControlModel.Step = CLng(pvValue)
diff --git a/wizards/source/sfdialogs/SF_DialogListener.xba b/wizards/source/sfdialogs/SF_DialogListener.xba
new file mode 100644
index 000000000000..0f324b60963f
--- /dev/null
+++ b/wizards/source/sfdialogs/SF_DialogListener.xba
@@ -0,0 +1,113 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
+<script:module xmlns:script="http://openoffice.org/2000/script" script:name="SF_DialogListener" script:language="StarBasic" script:moduleType="normal">REM =======================================================================================================================
+REM === The ScriptForge library and its associated libraries are part of the LibreOffice project. ===
+REM === The SFDialogs library is one of the associated libraries. ===
+REM === Full documentation is available on https://help.libreoffice.org/ ===
+REM =======================================================================================================================
+
+Option Compatible
+Option Explicit
+
+&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;
+&apos;&apos;&apos; SF_Listener
+&apos;&apos;&apos; ===========
+&apos;&apos;&apos; The current module is dedicated to the management of dialog control events, triggered by user actions,
+&apos;&apos;&apos; which cannot be defined with the Basic IDE
+&apos;&apos;&apos;
+&apos;&apos;&apos; Concerned events:
+&apos;&apos;&apos; TreeControl control type
+&apos;&apos;&apos; -----------
+&apos;&apos;&apos; The OnNodeSelected event, triggered when a user selects a node
+&apos;&apos;&apos; A typical action is to display additional info about the selected item elsewhere in the dialog
+&apos;&apos;&apos; The OnNodeExpanded event, triggered when a user clicks on the expansion symbol
+&apos;&apos;&apos; A typical action is to create dynamically a subnode or a subtree below the expanded item
+&apos;&apos;&apos;
+&apos;&apos;&apos; The described events are processed thru UNO listeners
+&apos;&apos;&apos;
+&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;
+
+REM ================================================================= DEFINITIONS
+
+REM ================================================================== EXCEPTIONS
+
+REM ============================================================== PUBLIC METHODS
+
+REM -----------------------------------------------------------------------------
+Public Sub _SFEXP_requestChildNodes(Optional ByRef poEvent As Object)
+&apos;&apos;&apos; Triggered by the OnNodeExpanded event of a tree control
+&apos;&apos;&apos; The event is triggered thru a com.sun.star.view.XTreeExpansionListener
+&apos;&apos;&apos; The argument is passed to a user routine sstored in the SF_DialogControl instance
+&apos;&apos;&apos; as a scripting framework URI
+
+Dim oControl As Object &apos; The SF_DialogControl object having triggered the event
+
+ On Local Error GoTo Catch &apos; Avoid stopping event scripts
+
+Check:
+ &apos; Ensure there is a node
+ If IsNull(poEvent) Or IsMissing(poEvent) Then Exit Sub
+ If IsNull(poEvent.Node) Then Exit Sub
+
+Try:
+ Set oControl = ScriptForge.SF_Services.CreateScriptService(&quot;SFDialogs.DialogEvent&quot;, poEvent)
+ ScriptForge.SF_Session._ExecuteScript(oControl.OnNodeExpanded, poEvent)
+
+Finally:
+ Exit Sub
+Catch:
+ GoTo Finally
+End Sub
+
+Sub _SFEXP_disposing(ByRef poEvent As Object)
+End Sub
+
+Sub _SFEXP_treeExpanding(Optional ByRef poEvent As Object)
+End Sub
+
+Sub _SFEXP_treeCollapsing(ByRef poEvent As Object)
+End Sub
+
+Sub _SFEXP_treeExpanded(ByRef poEvent As Object)
+End Sub
+
+Sub _SFEXP_treeCollapsed(ByRef poEvent As Object)
+End Sub
+
+REM -----------------------------------------------------------------------------
+Public Sub _SFSEL_selectionChanged(Optional ByRef poEvent As Object)
+&apos;&apos;&apos; Triggered by the OnNodeSelected event of a tree control
+&apos;&apos;&apos; The event is triggered thru a com.sun.star.view.XSelectionChangeListener
+&apos;&apos;&apos; The argument is passed to a user routine sstored in the SF_DialogControl instance
+&apos;&apos;&apos; as a scripting framework URI
+&apos;&apos;&apos;
+&apos;&apos;&apos; Nothing happens if there are several selected nodes or none
+
+Dim vSelection As Variant &apos; Variant, not object !!
+Dim oControl As Object &apos; The SF_DialogControl object having triggered the event
+
+ On Local Error GoTo Catch &apos; Avoid stopping event scripts
+
+Check:
+ &apos; Ensure there is a selection
+ If IsNull(poEvent) Or IsMissing(poEvent) Then Exit Sub
+ vSelection = poEvent.Source.getSelection()
+ If IsEmpty(vSelection) Or IsArray(vSelection) Then Exit Sub
+
+Try:
+ Set oControl = ScriptForge.SF_Services.CreateScriptService(&quot;SFDialogs.DialogEvent&quot;, poEvent)
+ ScriptForge.SF_Session._ExecuteScript(oControl.OnNodeSelected, poEvent)
+
+Finally:
+ Exit Sub
+Catch:
+ GoTo Finally
+End Sub
+
+Sub _SFSEL_disposing(ByRef poEvent As Object)
+End Sub
+
+REM ============================================================= PRIVATE METHODS
+
+REM ============================================ END OF SFDIALOGS.SF_DIALOGLISTENER
+</script:module> \ No newline at end of file
diff --git a/wizards/source/sfdialogs/SF_Register.xba b/wizards/source/sfdialogs/SF_Register.xba
index 7018385a1442..ac19bdebff34 100644
--- a/wizards/source/sfdialogs/SF_Register.xba
+++ b/wizards/source/sfdialogs/SF_Register.xba
@@ -203,6 +203,8 @@ Dim oBasicDialog As Object &apos; Return value
Dim oCache As _DialogCache &apos; Entry in the cache
Set oBasicDialog = Nothing
+
+Try:
For Each oCache In _SF_.SFDialogs
If EqualUnoObjects(poDialog, oCache.XUnoDialog) And Not oCache.Terminated Then
Set oBasicDialog = oCache.BasicDialog
@@ -210,8 +212,9 @@ Dim oCache As _DialogCache &apos; Entry in the cache
End If
Next oCache
+Finally:
Set _FindDialogInCache = oBasicDialog
-
+ Exit Function
End Function &apos; SFDialogs.SF_Documents._FindDialogInCache
REM -----------------------------------------------------------------------------
@@ -231,7 +234,7 @@ Dim vLibrary As Variant &apos; Alias of pvArgs(1)
Dim vDialogName As Variant &apos; Alias of pvArgs(2)
Dim oLibraries As Object &apos; com.sun.star.comp.sfx2.DialogLibraryContainer
Dim oLibrary As Object &apos; com.sun.star.container.XNameAccess
-Dim o_DialogProvider As Object &apos; com.sun.star.io.XInputStreamProvider
+Dim oDialogProvider As Object &apos; com.sun.star.io.XInputStreamProvider
Dim oEnum As Object &apos; com.sun.star.container.XEnumeration
Dim oComp As Object &apos; com.sun.star.lang.XComponent
Dim vWindow As Window &apos; A single component
@@ -301,7 +304,7 @@ Try:
If Not .isLibraryLoaded(vLibrary) Then .loadLibrary(vLibrary)
Set oLibrary = .getByName(vLibrary)
If Not oLibrary.hasByName(vDialogName) Then GoTo CatchNotFound
- Set o_DialogProvider = oLibrary.getByName(vDialogName)
+ Set oDialogProvider = oLibrary.getByName(vDialogName)
End With
Set oDialog = New SF_Dialog
@@ -310,7 +313,7 @@ Try:
If VarType(vContainer) = V_STRING Then ._Container = vContainer Else ._Container = vWindow.WindowName
._Library = vLibrary
._Name = vDialogName
- Set ._DialogProvider = o_DialogProvider
+ Set ._DialogProvider = oDialogProvider
._Initialize()
End With
diff --git a/wizards/source/sfdialogs/script.xlb b/wizards/source/sfdialogs/script.xlb
index 1a171c326079..6dff54d872f5 100644
--- a/wizards/source/sfdialogs/script.xlb
+++ b/wizards/source/sfdialogs/script.xlb
@@ -5,4 +5,5 @@
<library:element library:name="SF_Register"/>
<library:element library:name="SF_Dialog"/>
<library:element library:name="SF_DialogControl"/>
+ <library:element library:name="SF_DialogListener"/>
</library:library> \ No newline at end of file