wizards/source/scriptforge/SF_Root.xba        |    4 +-
 wizards/source/sfdialogs/SF_Dialog.xba        |   10 ++++++
 wizards/source/sfdialogs/SF_DialogControl.xba |    2 -
 wizards/source/sfdialogs/SF_Register.xba      |   41 ++++++++++++++++++++++++++
 4 files changed, 54 insertions(+), 3 deletions(-)

New commits:
commit 8e717facb376029e24dbf39c171234d67388d4d5
Author:     Jean-Pierre Ledure <j...@ledure.be>
AuthorDate: Fri Nov 27 14:25:51 2020 +0100
Commit:     Jean-Pierre Ledure <j...@ledure.be>
CommitDate: Sat Nov 28 11:29:11 2020 +0100

    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 <j...@ledure.be>
    Tested-by: Jenkins
    Reviewed-by: Jean-Pierre Ledure <j...@ledure.be>

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
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to