summaryrefslogtreecommitdiff
path: root/wizards/source/scriptforge
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/scriptforge
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/scriptforge')
-rw-r--r--wizards/source/scriptforge/SF_Exception.xba2
-rw-r--r--wizards/source/scriptforge/SF_Session.xba46
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 &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