summaryrefslogtreecommitdiff
path: root/wizards
diff options
context:
space:
mode:
authorJean-Pierre Ledure <jp@ledure.be>2020-11-27 14:25:51 +0100
committerJean-Pierre Ledure <jp@ledure.be>2020-11-28 11:29:11 +0100
commit8e717facb376029e24dbf39c171234d67388d4d5 (patch)
tree8cad0d752f4f8cdd7179ba33684d0bec44b0dccb /wizards
parent1ca8bc9248119ee82afccbff3329f80317667a90 (diff)
ScriptForge - (SF_Dialog) set OnEvent properties
Applied on Dialog class: Assign the triggered script as a string to the OnXxx properties or as a zero-length string to remove any trigger Change-Id: I91169a761ece7bf464f58bd3f3415d1b023c71a7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106775 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/scriptforge/SF_Root.xba4
-rw-r--r--wizards/source/sfdialogs/SF_Dialog.xba10
-rw-r--r--wizards/source/sfdialogs/SF_DialogControl.xba2
-rw-r--r--wizards/source/sfdialogs/SF_Register.xba41
4 files changed, 54 insertions, 3 deletions
diff --git a/wizards/source/scriptforge/SF_Root.xba b/wizards/source/scriptforge/SF_Root.xba
index 5be7766e03b9..2af6ca463dcb 100644
--- a/wizards/source/scriptforge/SF_Root.xba
+++ b/wizards/source/scriptforge/SF_Root.xba
@@ -777,7 +777,7 @@ Try:
, MsgId := &quot;An SQL statement could not be interpreted or executed by the database system.\n&quot; _
&amp; &quot;Check its syntax, table and/or field names, ...\n\n&quot; _
&amp; &quot;SQL Statement : « %1 »&quot; _
- , Comment := &quot;SF_Database can't interpret SQL statement\n&quot; _
+ , Comment := &quot;SF_Database can&apos;t interpret SQL statement\n&quot; _
&amp; &quot;%1: The statement&quot; _
)
End With
@@ -819,4 +819,4 @@ Public Sub _StackReset()
End Sub &apos; ScriptForge.SF_Root._StackReset
REM ================================================== END OF SCRIPTFORGE.SF_ROOT
-</script:module>
+</script:module> \ No newline at end of file
diff --git a/wizards/source/sfdialogs/SF_Dialog.xba b/wizards/source/sfdialogs/SF_Dialog.xba
index a508505f372f..5adfd515c33d 100644
--- a/wizards/source/sfdialogs/SF_Dialog.xba
+++ b/wizards/source/sfdialogs/SF_Dialog.xba
@@ -835,6 +835,16 @@ Const cstSubArgs = &quot;Value&quot;
Case UCase(&quot;Height&quot;)
If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;Height&quot;, ScriptForge.V_NUMERIC) Then GoTo Finally
If oSession.HasUNOProperty(_DialogModel, &quot;Height&quot;) Then _DialogModel.Height = pvValue
+ Case UCase(&quot;OnFocusGained&quot;), UCase(&quot;OnFocusLost&quot;), UCase(&quot;OnKeyPressed&quot;), UCase(&quot;OnKeyReleased&quot;) _
+ , UCase(&quot;OnMouseDragged&quot;), UCase(&quot;OnMouseEntered&quot;), UCase(&quot;OnMouseExited&quot;), UCase(&quot;OnMouseMoved&quot;) _
+ , UCase(&quot;OnMousePressed&quot;), UCase(&quot;OnMouseReleased&quot;)
+ If Not ScriptForge.SF_Utils._Validate(pvValue, psProperty, V_STRING) Then GoTo Finally
+ SFDialogs.SF_Register._SetEventScript( _
+ _DialogModel _
+ , _GetEventName(psProperty) _
+ , _GetListener(psProperty) _
+ , pvValue _
+ )
Case UCase(&quot;Page&quot;)
If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;Page&quot;, ScriptForge.V_NUMERIC) Then GoTo Finally
If oSession.HasUNOProperty(_DialogModel, &quot;Step&quot;) Then _DialogModel.Step = CLng(pvValue)
diff --git a/wizards/source/sfdialogs/SF_DialogControl.xba b/wizards/source/sfdialogs/SF_DialogControl.xba
index 2b23fed76331..0559d8c036d4 100644
--- a/wizards/source/sfdialogs/SF_DialogControl.xba
+++ b/wizards/source/sfdialogs/SF_DialogControl.xba
@@ -1096,4 +1096,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
diff --git a/wizards/source/sfdialogs/SF_Register.xba b/wizards/source/sfdialogs/SF_Register.xba
index a1a454c8f006..7018385a1442 100644
--- a/wizards/source/sfdialogs/SF_Register.xba
+++ b/wizards/source/sfdialogs/SF_Register.xba
@@ -325,5 +325,46 @@ CatchNotFound:
GoTo Finally
End Function &apos; SFDialogs.SF_Register._NewDialog
+REM -----------------------------------------------------------------------------
+Public Sub _SetEventScript(poObject As Object _
+ , ByVal psEvent As String _
+ , ByVal psListener As String _
+ , ByVal psScriptCode As String _
+ )
+&apos;&apos;&apos; Set/replace a script event in a Dialog or DialogControl model
+&apos;&apos;&apos; Args:
+&apos;&apos;&apos; poObject: the Dialog or DialogControl model
+&apos;&apos;&apos; psEvent: the name of the event which triggers the script
+&apos;&apos;&apos; psListener: getting/Setting macros triggered by events requires a Listener-EventName pair
+&apos;&apos;&apos; psScriptCode: the script to associate with the event as a string
+&apos;&apos;&apos; If = &quot;&quot;, then the event is completely removed
+
+Dim oEvents As Object &apos; The set of events of the model
+Dim sEventName As String &apos; The full name of the event
+Dim oEvent As Object &apos; com.sun.star.script.ScriptEventDescriptor
+
+Check:
+ If Not SF_Session.HasUnoMethod(poObject, &quot;getEvents&quot;) Then GoTo Finally
+
+Try:
+ &apos; Remove existing event, if any, then store the new script code if &lt;&gt; &quot;&quot;
+ Set oEvents = poObject.getEvents()
+ sEventName = &quot;com.sun.star.awt.&quot; &amp; psListener &amp; &quot;::&quot; &amp; psEvent
+ If oEvents.hasByName(sEventName) Then oEvents.removeByName(sEventName)
+ If Len(psScriptCode) &gt; 0 Then
+ Set oEvent = CreateUnoStruct(&quot;com.sun.star.script.ScriptEventDescriptor&quot;)
+ With oEvent
+ .ListenerType = psListener
+ .EventMethod = psEvent
+ .ScriptType = &quot;Script&quot; &apos; Better than &quot;Basic&quot;
+ .ScriptCode = psScriptCode
+ End With
+ oEvents.insertByName(sEventName, oEvent)
+ End If
+
+Finally:
+ Exit Sub
+End Sub &apos; SFDialogs.SF_Register._SetEventScript
+
REM ============================================== END OF SFDIALOGS.SF_REGISTER
</script:module> \ No newline at end of file