diff options
author | Jean-Pierre Ledure <jp@ledure.be> | 2020-12-08 15:06:31 +0100 |
---|---|---|
committer | Jean-Pierre Ledure <jp@ledure.be> | 2020-12-08 16:31:11 +0100 |
commit | 5fa2182d3b5c79bc4cf8ec9621228ddc00283a1f (patch) | |
tree | b0c259d753ec784e463d46841beec3af9c0658fc /wizards/source/scriptforge | |
parent | 73d592f963c4135b36c4417436bf14c87e1cf0d4 (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/scriptforge')
-rw-r--r-- | wizards/source/scriptforge/SF_Exception.xba | 2 | ||||
-rw-r--r-- | wizards/source/scriptforge/SF_Session.xba | 46 |
2 files changed, 43 insertions, 5 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 ' 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 ''' ExecuteBasicScript() ''' ExecutePythonScript() ''' Example: -''' session.ExecuteBasicScript(session.SCRIPTISEMBEDDED, "Standard.myLib.myFunc", etc) +''' session.ExecuteBasicScript(session.SCRIPTISEMBEDDED, "Standard.myModule.myFunc", etc) Const cstSCRIPTISEMBEDDED = "document" ' a library of the document (BASIC + PYTHON) Const cstSCRIPTISAPPLICATION = "application" ' a shared library (BASIC) @@ -52,6 +52,11 @@ Const cstSCRIPTISSHARED = "share" ' a library of LibreOffic Const cstSCRIPTISSHAROXT = "share:uno_packages" ' an extension for all users (PYTHON) Const cstSCRIPTISOXT = "uno_packages" ' an extension but install params are unknown (PYTHON) +''' To build or to parse scripting framework URI's +Const cstScript1 = "vnd.sun.star.script:" +Const cstScript2 = "?language=" +Const cstScript3 = "&location=" + REM ===================================================== CONSTRUCTOR/DESTRUCTOR REM ----------------------------------------------------------------------------- @@ -861,6 +866,42 @@ End Function ' ScriptForge.SF_Session.WebService REM =========================================================== PRIVATE FUNCTIONS REM ----------------------------------------------------------------------------- +Private Function _ExecuteScript(ByVal psScript As String _ + , ByRef poEvent As Object _ + ) As Variant +''' Execute the script expressed in the scripting framework_URI notation +''' Args: +''' psScript: read https://wiki.openoffice.org/wiki/Documentation/DevGuide/Scripting/Scripting_Framework_URI_Specification +''' poEvent: the event object which triggered the execution. It is given as argument to the called script +''' Returns: +''' The return value after the script execution. May be ignored for events + +Dim sScope As String ' The scope part of the script URI +Dim sLanguage As String ' The language part of the script URI +Dim sScript As String ' The script part of the script URI +Dim vStrings As Variant ' Array of strings: (script, language, scope) +Const cstComma = "," + +Try: + If ScriptForge.SF_String.StartsWith(psScript, cstScript1) Then + ' 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) + ' Execute script + If UCase(sLanguage) = "BASIC" Then + _ExecuteScript = ExecuteBasicScript(sScope, sScript, poEvent) + Else ' Python + _ExecuteScript = ExecutePythonScript(sScope, sScript, poEvent) + End If + End If + +End Function ' 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 ' The complete script string Dim oScriptProvider As Object ' Script provider singleton Dim oScript As Object ' Return value -Const cstScript1 = "vnd.sun.star.script:" -Const cstScript2 = "?language=" -Const cstScript3 = "&location=" Try: ' Build script string |