[Libreoffice-commits] core.git: wizards/source
Jean-Pierre Ledure (via logerrit)
logerrit at kemper.freedesktop.org
Sat Nov 28 10:29:48 UTC 2020
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 <jp at ledure.be>
AuthorDate: Fri Nov 27 14:25:51 2020 +0100
Commit: Jean-Pierre Ledure <jp at 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 <jp at ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp at 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 := "An SQL statement could not be interpreted or executed by the database system.\n" _
& "Check its syntax, table and/or field names, ...\n\n" _
& "SQL Statement : « %1 »" _
- , Comment := "SF_Database can't interpret SQL statement\n" _
+ , Comment := "SF_Database can't interpret SQL statement\n" _
& "%1: The statement" _
)
End With
@@ -819,4 +819,4 @@ Public Sub _StackReset()
End Sub ' 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 = "Value"
Case UCase("Height")
If Not ScriptForge.SF_Utils._Validate(pvValue, "Height", ScriptForge.V_NUMERIC) Then GoTo Finally
If oSession.HasUNOProperty(_DialogModel, "Height") Then _DialogModel.Height = pvValue
+ Case UCase("OnFocusGained"), UCase("OnFocusLost"), UCase("OnKeyPressed"), UCase("OnKeyReleased") _
+ , UCase("OnMouseDragged"), UCase("OnMouseEntered"), UCase("OnMouseExited"), UCase("OnMouseMoved") _
+ , UCase("OnMousePressed"), UCase("OnMouseReleased")
+ 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("Page")
If Not ScriptForge.SF_Utils._Validate(pvValue, "Page", ScriptForge.V_NUMERIC) Then GoTo Finally
If oSession.HasUNOProperty(_DialogModel, "Step") 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 ' 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 ' SFDialogs.SF_Register._NewDialog
+REM -----------------------------------------------------------------------------
+Public Sub _SetEventScript(poObject As Object _
+ , ByVal psEvent As String _
+ , ByVal psListener As String _
+ , ByVal psScriptCode As String _
+ )
+''' Set/replace a script event in a Dialog or DialogControl model
+''' Args:
+''' poObject: the Dialog or DialogControl model
+''' psEvent: the name of the event which triggers the script
+''' psListener: getting/Setting macros triggered by events requires a Listener-EventName pair
+''' psScriptCode: the script to associate with the event as a string
+''' If = "", then the event is completely removed
+
+Dim oEvents As Object ' The set of events of the model
+Dim sEventName As String ' The full name of the event
+Dim oEvent As Object ' com.sun.star.script.ScriptEventDescriptor
+
+Check:
+ If Not SF_Session.HasUnoMethod(poObject, "getEvents") Then GoTo Finally
+
+Try:
+ ' Remove existing event, if any, then store the new script code if <> ""
+ Set oEvents = poObject.getEvents()
+ sEventName = "com.sun.star.awt." & psListener & "::" & psEvent
+ If oEvents.hasByName(sEventName) Then oEvents.removeByName(sEventName)
+ If Len(psScriptCode) > 0 Then
+ Set oEvent = CreateUnoStruct("com.sun.star.script.ScriptEventDescriptor")
+ With oEvent
+ .ListenerType = psListener
+ .EventMethod = psEvent
+ .ScriptType = "Script" ' Better than "Basic"
+ .ScriptCode = psScriptCode
+ End With
+ oEvents.insertByName(sEventName, oEvent)
+ End If
+
+Finally:
+ Exit Sub
+End Sub ' SFDialogs.SF_Register._SetEventScript
+
REM ============================================== END OF SFDIALOGS.SF_REGISTER
</script:module>
\ No newline at end of file
More information about the Libreoffice-commits
mailing list