ScriptForge (SFDialogs) make On properties editable
A dialog box and its controls may be associated
with scripts triggered by events (mouse moved,
key pressed, ...).
The link is usually preset in the Basic IDE when
the dialog is designed.
So far, ScriptForge did not offer the setting of
a link event-script by code.
The actual commit removes this limitation: every
On-property related to either a dialog or a dialog
control is now editbale.
With the important precision that such a property
may be updated ONLY IF it was NOT PRESET in the
Basic IDE.
Static (IDE) and dynamic (by code) definition of
a specific On property on a specific dialog or on
a specific dialog control are mutually exclusive.
The new capacity may be used both in Basic and Python scripts.
A short update of the help texts (dialog and dialogcontrol)
is needed with mention of above restriction.
Change-Id: Ia078aaab317ced7ade7ce69694504013f8e768a1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148800
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
diff --git a/wizards/source/scriptforge/SF_UI.xba b/wizards/source/scriptforge/SF_UI.xba
index 392eeb2..3bde6c2 100644
--- a/wizards/source/scriptforge/SF_UI.xba
+++ b/wizards/source/scriptforge/SF_UI.xba
@@ -1506,4 +1506,4 @@ Private Function _Repr() As String
End Function ' ScriptForge.SF_UI._Repr
REM ============================================ END OF SCRIPTFORGE.SF_UI
</script:module>
</script:module>
\ No newline at end of file
diff --git a/wizards/source/scriptforge/python/scriptforge.py b/wizards/source/scriptforge/python/scriptforge.py
index 7208ff81..531b0da 100644
--- a/wizards/source/scriptforge/python/scriptforge.py
+++ b/wizards/source/scriptforge/python/scriptforge.py
@@ -1840,10 +1840,10 @@ class SFDialogs:
servicename = 'SFDialogs.Dialog'
servicesynonyms = ('dialog', 'sfdialogs.dialog')
serviceproperties = dict(Caption = True, Height = True, Modal = False, Name = False,
OnFocusGained = False, OnFocusLost = False, OnKeyPressed = False,
OnKeyReleased = False, OnMouseDragged = False, OnMouseEntered = False,
OnMouseExited = False, OnMouseMoved = False, OnMousePressed = False,
OnMouseReleased = False,
OnFocusGained = True, OnFocusLost = True, OnKeyPressed = True,
OnKeyReleased = True, OnMouseDragged = True, OnMouseEntered = True,
OnMouseExited = True, OnMouseMoved = True, OnMousePressed = True,
OnMouseReleased = True,
Page = True, Visible = True, Width = True, XDialogModel = False, XDialogView = False)
# Class constants used together with the Execute() method
OKBUTTON, CANCELBUTTON = 1, 0
@@ -1906,12 +1906,12 @@ class SFDialogs:
serviceproperties = dict(Cancel = True, Caption = True, ControlType = False, CurrentNode = True,
Default = True, Enabled = True, Format = True, ListCount = False,
ListIndex = True, Locked = True, MultiSelect = True, Name = False,
OnActionPerformed = False, OnAdjustmentValueChanged = False, OnFocusGained = False,
OnFocusLost = False, OnItemStateChanged = False, OnKeyPressed = False,
OnKeyReleased = False, OnMouseDragged = False, OnMouseEntered = False,
OnMouseExited = False, OnMouseMoved = False, OnMousePressed = False,
OnMouseReleased = False, OnNodeExpanded = True, OnNodeSelected = True,
OnTextChanged = False, Page = True, Parent = False, Picture = True,
OnActionPerformed = True, OnAdjustmentValueChanged = True, OnFocusGained = True,
OnFocusLost = True, OnItemStateChanged = True, OnKeyPressed = True,
OnKeyReleased = True, OnMouseDragged = True, OnMouseEntered = True,
OnMouseExited = True, OnMouseMoved = True, OnMousePressed = True,
OnMouseReleased = True, OnNodeExpanded = True, OnNodeSelected = True,
OnTextChanged = True, Page = True, Parent = False, Picture = True,
RootNode = False, RowSource = True, Text = False, TipText = True,
TripleState = True, Value = True, Visible = True,
XControlModel = False, XControlView = False, XGridColumnModel = False,
diff --git a/wizards/source/sfdialogs/SF_Dialog.xba b/wizards/source/sfdialogs/SF_Dialog.xba
index 081584f..430b29d 100644
--- a/wizards/source/sfdialogs/SF_Dialog.xba
+++ b/wizards/source/sfdialogs/SF_Dialog.xba
@@ -93,6 +93,30 @@ Private _ItemListener As Object ' com.sun.star.awt.XItemListener
Private _ActionListener As Object ' com.sun.star.awt.XActionListener
Private _LastPage As Long ' When > 0, the last page in a tabbed dialog
' Updatable events
' Next identifiers MUST be identical in both SF_Dialog and SF_DialogControl class modules
Private _FocusListener As Object ' com.sun.star.awt.XFocusListener
Private _OnFocusGained As String ' Script to invoke when dialog gets focus
Private _OnFocusLost As String ' Script to invoke when dialog loses focus
Private _FocusCounter As Integer ' Counts the number of events set on the listener
' ---
Private _KeyListener As Object ' com.sun.star.awt.XKeyListener
Private _OnKeyPressed As String ' Script to invoke when Key clicked in dialog
Private _OnKeyReleased As String ' Script to invoke when Key released in dialog
Private _KeyCounter As Integer ' Counts the number of events set on the listener
' ---
Private _MouseListener As Object ' com.sun.star.awt.XMouseListener
Private _OnMouseEntered As String ' Script to invoke when mouse enters dialog
Private _OnMouseExited As String ' Script to invoke when mouse leaves dialog
Private _OnMousePressed As String ' Script to invoke when mouse clicked in dialog
Private _OnMouseReleased As String ' Script to invoke when mouse released in dialog
Private _MouseCounter As Integer ' Counts the number of events set on the listener
' ---
Private _MouseMotionListener As Object ' com.sun.star.awt.XMouseMotionListener
Private _OnMouseDragged As String ' Script to invoke when mouse is dragged from the dialog
Private _OnMouseMoved As String ' Script to invoke when mouse is moved across the dialog
Private _MouseMotionCounter As Integer ' Counts the number of events set on the listener
' Persistent storage for controls
Private _ControlCache As Variant ' Array of control objects sorted like ElementNames of the Dialog model
@@ -135,6 +159,24 @@ Private Sub Class_Initialize()
Set _ItemListener = Nothing
Set _ActionListener = Nothing
_LastPage = 0
Set _FocusListener = Nothing
_OnFocusGained = ""
_OnFocusLost = ""
_FocusCounter = 0
Set _KeyListener = Nothing
_OnKeyPressed = ""
_OnKeyReleased = ""
_KeyCounter = 0
Set _MouseListener = Nothing
_OnMouseEntered = ""
_OnMouseExited = ""
_OnMousePressed = ""
_OnMouseReleased = ""
_MouseCounter = 0
Set _MouseMotionListener = Nothing
_OnMouseDragged = ""
_OnMouseMoved = ""
_MouseMotionCounter = 0
_ControlCache = Array()
End Sub ' SFDialogs.SF_Dialog Constructor
@@ -205,60 +247,120 @@ Property Get OnFocusGained() As Variant
End Property ' SFDialogs.SF_Dialog.OnFocusGained (get)
REM -----------------------------------------------------------------------------
Property Let OnFocusGained(Optional ByVal pvOnFocusGained As Variant)
''' Set the updatable property OnFocusGained
_PropertySet("OnFocusGained", pvOnFocusGained)
End Property ' SFDialogs.SF_Dialog.OnFocusGained (let)
REM -----------------------------------------------------------------------------
Property Get OnFocusLost() As Variant
''' Get the script associated with the OnFocusLost event
OnFocusLost = _PropertyGet("OnFocusLost")
End Property ' SFDialogs.SF_Dialog.OnFocusLost (get)
REM -----------------------------------------------------------------------------
Property Let OnFocusLost(Optional ByVal pvOnFocusLost As Variant)
''' Set the updatable property OnFocusLost
_PropertySet("OnFocusLost", pvOnFocusLost)
End Property ' SFDialogs.SF_Dialog.OnFocusLost (let)
REM -----------------------------------------------------------------------------
Property Get OnKeyPressed() As Variant
''' Get the script associated with the OnKeyPressed event
OnKeyPressed = _PropertyGet("OnKeyPressed")
End Property ' SFDialogs.SF_Dialog.OnKeyPressed (get)
REM -----------------------------------------------------------------------------
Property Let OnKeyPressed(Optional ByVal pvOnKeyPressed As Variant)
''' Set the updatable property OnKeyPressed
_PropertySet("OnKeyPressed", pvOnKeyPressed)
End Property ' SFDialogs.SF_Dialog.OnKeyPressed (let)
REM -----------------------------------------------------------------------------
Property Get OnKeyReleased() As Variant
''' Get the script associated with the OnKeyReleased event
OnKeyReleased = _PropertyGet("OnKeyReleased")
End Property ' SFDialogs.SF_Dialog.OnKeyReleased (get)
REM -----------------------------------------------------------------------------
Property Let OnKeyReleased(Optional ByVal pvOnKeyReleased As Variant)
''' Set the updatable property OnKeyReleased
_PropertySet("OnKeyReleased", pvOnKeyReleased)
End Property ' SFDialogs.SF_Dialog.OnKeyReleased (let)
REM -----------------------------------------------------------------------------
Property Get OnMouseDragged() As Variant
''' Get the script associated with the OnMouseDragged event
OnMouseDragged = _PropertyGet("OnMouseDragged")
End Property ' SFDialogs.SF_Dialog.OnMouseDragged (get)
REM -----------------------------------------------------------------------------
Property Let OnMouseDragged(Optional ByVal pvOnMouseDragged As Variant)
''' Set the updatable property OnMouseDragged
_PropertySet("OnMouseDragged", pvOnMouseDragged)
End Property ' SFDialogs.SF_Dialog.OnMouseDragged (let)
REM -----------------------------------------------------------------------------
Property Get OnMouseEntered() As Variant
''' Get the script associated with the OnMouseEntered event
OnMouseEntered = _PropertyGet("OnMouseEntered")
End Property ' SFDialogs.SF_Dialog.OnMouseEntered (get)
REM -----------------------------------------------------------------------------
Property Let OnMouseEntered(Optional ByVal pvOnMouseEntered As Variant)
''' Set the updatable property OnMouseEntered
_PropertySet("OnMouseEntered", pvOnMouseEntered)
End Property ' SFDialogs.SF_Dialog.OnMouseEntered (let)
REM -----------------------------------------------------------------------------
Property Get OnMouseExited() As Variant
''' Get the script associated with the OnMouseExited event
OnMouseExited = _PropertyGet("OnMouseExited")
End Property ' SFDialogs.SF_Dialog.OnMouseExited (get)
REM -----------------------------------------------------------------------------
Property Let OnMouseExited(Optional ByVal pvOnMouseExited As Variant)
''' Set the updatable property OnMouseExited
_PropertySet("OnMouseExited", pvOnMouseExited)
End Property ' SFDialogs.SF_Dialog.OnMouseExited (let)
REM -----------------------------------------------------------------------------
Property Get OnMouseMoved() As Variant
''' Get the script associated with the OnMouseMoved event
OnMouseMoved = _PropertyGet("OnMouseMoved")
End Property ' SFDialogs.SF_Dialog.OnMouseMoved (get)
REM -----------------------------------------------------------------------------
Property Let OnMouseMoved(Optional ByVal pvOnMouseMoved As Variant)
''' Set the updatable property OnMouseMoved
_PropertySet("OnMouseMoved", pvOnMouseMoved)
End Property ' SFDialogs.SF_Dialog.OnMouseMoved (let)
REM -----------------------------------------------------------------------------
Property Get OnMousePressed() As Variant
''' Get the script associated with the OnMousePressed event
OnMousePressed = _PropertyGet("OnMousePressed")
End Property ' SFDialogs.SF_Dialog.OnMousePressed (get)
REM -----------------------------------------------------------------------------
Property Let OnMousePressed(Optional ByVal pvOnMousePressed As Variant)
''' Set the updatable property OnMousePressed
_PropertySet("OnMousePressed", pvOnMousePressed)
End Property ' SFDialogs.SF_Dialog.OnMousePressed (let)
REM -----------------------------------------------------------------------------
Property Get OnMouseReleased() As Variant
''' Get the script associated with the OnMouseReleased event
OnMouseReleased = _PropertyGet("OnMouseReleased")
End Property ' SFDialogs.SF_Dialog.OnMouseReleased (get)
REM -----------------------------------------------------------------------------
Property Let OnMouseReleased(Optional ByVal pvOnMouseReleased As Variant)
''' Set the updatable property OnMouseReleased
_PropertySet("OnMouseReleased", pvOnMouseReleased)
End Property ' SFDialogs.SF_Dialog.OnMouseReleased (let)
REM -----------------------------------------------------------------------------
Property Get Page() As Variant
''' A dialog may have several pages that can be traversed by the user step by step.
''' The Page property of the Dialog object defines which page of the dialog is active.
@@ -831,7 +933,7 @@ Try:
iFlags = 0
With com.sun.star.awt.PosSize
If Left >= 0 Then iFlags = iFlags + .X Else Left = oPosSize.X
If Top >= 0 Then iFlags = iFlags + .Y Else Top = oPosSize.Y
If Top >= 0 Then iFlags = iFlags + .Y Else Top = oPosSize.Y
If Width > 0 Then iFlags = iFlags + .WIDTH Else Width = oPosSize.Width
If Height > 0 Then iFlags = iFlags + .HEIGHT Else Height = oPosSize.Height
End With
@@ -1021,7 +1123,7 @@ Check:
End If
Try:
_RemovePageListeners()
_RemoveAllListeners()
_DialogControl.dispose()
Set _DialogControl = Nothing
SF_Register._CleanCacheEntry(_CacheIndex)
@@ -1292,12 +1394,26 @@ Const cstSubArgs = ""
Case UCase("OnFocusGained"), UCase("OnFocusLost"), UCase("OnKeyPressed"), UCase("OnKeyReleased") _
, UCase("OnMouseDragged"), UCase("OnMouseEntered"), UCase("OnMouseExited"), UCase("OnMouseMoved") _
, UCase("OnMousePressed"), UCase("OnMouseReleased")
' Check OnEvents set statically in Basic IDE
Set oDialogEvents = _DialogModel.getEvents()
sEventName = "com.sun.star.awt." & _GetListener(psProperty) & "::" & _GetEventName(psProperty)
If oDialogEvents.hasByName(sEventName) Then
_PropertyGet = oDialogEvents.getByName(sEventName).ScriptCode
Else
_PropertyGet = ""
' Check OnEvents set dynamically by code
Select Case UCase(psProperty)
Case UCase("OnFocusGained") : _PropertyGet = _OnFocusGained
Case UCase("OnFocusLost") : _PropertyGet = _OnFocusLost
Case UCase("OnKeyPressed") : _PropertyGet = _OnKeyPressed
Case UCase("OnKeyReleased") : _PropertyGet = _OnKeyReleased
Case UCase("OnMouseDragged") : _PropertyGet = _OnMouseDragged
Case UCase("OnMouseEntered") : _PropertyGet = _OnMouseEntered
Case UCase("OnMouseExited") : _PropertyGet = _OnMouseExited
Case UCase("OnMouseMoved") : _PropertyGet = _OnMouseMoved
Case UCase("OnMousePressed") : _PropertyGet = _OnMousePressed
Case UCase("OnMouseReleased") : _PropertyGet = _OnMouseReleased
Case Else : _PropertyGet = ""
End Select
End If
Case UCase("Page")
If oSession.HasUNOProperty(_DialogModel, "Step") Then _PropertyGet = _DialogModel.Step
@@ -1347,23 +1463,28 @@ Const cstSubArgs = "Value"
bSet = True
Select Case UCase(psProperty)
Case UCase("Caption")
If Not ScriptForge.SF_Utils._Validate(pvValue, "Caption", V_STRING) Then GoTo Finally
If Not ScriptForge.SF_Utils._Validate(pvValue, "Caption", V_STRING) Then GoTo Catch
If oSession.HasUNOProperty(_DialogModel, "Title") Then _DialogModel.Title = pvValue
Case UCase("Height")
If Not ScriptForge.SF_Utils._Validate(pvValue, "Height", ScriptForge.V_NUMERIC) Then GoTo Finally
If Not ScriptForge.SF_Utils._Validate(pvValue, "Height", ScriptForge.V_NUMERIC) Then GoTo Catch
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 Catch
bSet = SF_DialogListener._SetOnProperty([Me], psProperty, pvValue)
Case UCase("Page")
If Not ScriptForge.SF_Utils._Validate(pvValue, "Page", ScriptForge.V_NUMERIC) Then GoTo Finally
If Not ScriptForge.SF_Utils._Validate(pvValue, "Page", ScriptForge.V_NUMERIC) Then GoTo Catch
If oSession.HasUNOProperty(_DialogModel, "Step") Then
_DialogModel.Step = CLng(pvValue)
' Execute the page manager instructions
_JumpToPage(pvValue)
End If
Case UCase("Visible")
If Not ScriptForge.SF_Utils._Validate(pvValue, "Visible", ScriptForge.V_BOOLEAN) Then GoTo Finally
If Not ScriptForge.SF_Utils._Validate(pvValue, "Visible", ScriptForge.V_BOOLEAN) Then GoTo Catch
If oSession.HasUnoMethod(_DialogControl, "setVisible") Then _DialogControl.setVisible(pvValue)
Case UCase("Width")
If Not ScriptForge.SF_Utils._Validate(pvValue, "Width", ScriptForge.V_NUMERIC) Then GoTo Finally
If Not ScriptForge.SF_Utils._Validate(pvValue, "Width", ScriptForge.V_NUMERIC) Then GoTo Catch
If oSession.HasUNOProperty(_DialogModel, "Width") Then _DialogModel.Width = pvValue
Case Else
bSet = False
@@ -1374,6 +1495,7 @@ Finally:
ScriptForge.SF_Utils._ExitFunction(cstThisSub)
Exit Function
Catch:
bSet = False
GoTo Finally
End Function ' SFDialogs.SF_Dialog._PropertySet
@@ -1449,8 +1571,9 @@ Catch:
End Function ' SFDialogs.SF_Dialog._RegisterPageListener
REM -----------------------------------------------------------------------------
Private Sub _RemovePageListeners()
''' Executed at dialog termination to drop at once all listeners set by the page manager
Private Sub _RemoveAllListeners()
''' Executed at dialog termination to drop at once all listeners set
''' either by the page manager or by an On-property setting
Dim oPageManager As Object ' Item of _PageManagement array of _PageManager type
Dim oControl As Object ' DialogControl instance
@@ -1467,7 +1590,7 @@ Try:
If .ListenerType = ACTIONPERFORMED Then
oControl._ControlView.removeActionListener(_ActionListener)
ElseIf .ListenerType = ITEMSTATECHANGED Then
oControl._ControlView.addItemListener(_ItemListener)
oControl._ControlView.removeItemListener(_ItemListener)
End If
End If
End With
@@ -1476,9 +1599,22 @@ Try:
Set _ActionListener = Nothing
Set _ItemListener = Nothing
' Clean listeners linked to On properties
With _DialogControl
If Not IsNull(_FocusListener) Then .removeFocusListener(_FocusListener)
If Not IsNull(_KeyListener) Then .removeKeyListener(_KeyListener)
If Not IsNull(_MouseListener) Then .removeMouseListener(_MouseListener)
If Not IsNull(_MouseMotionListener) Then .removeMouseMotionListener(_MouseMotionListener)
End With
Set _FocusListener = Nothing
Set _KeyListener = Nothing
Set _MouseListener = Nothing
Set _MouseMotionListener = Nothing
Finally:
Exit Sub
End Sub ' SFDialogs.SF_Dialog._RemovePageListeners
End Sub ' SFDialogs.SF_Dialog._RemoveAllListeners
REM -----------------------------------------------------------------------------
Private Function _Repr() As String
''' Convert the Model instance to a readable string, typically for debugging purposes (DebugPrint ...)
diff --git a/wizards/source/sfdialogs/SF_DialogControl.xba b/wizards/source/sfdialogs/SF_DialogControl.xba
index f4a0891..0818853 100644
--- a/wizards/source/sfdialogs/SF_DialogControl.xba
+++ b/wizards/source/sfdialogs/SF_DialogControl.xba
@@ -82,6 +82,45 @@ Private _OnNodeExpanded As String ' Script to invoke when a node is expan
Private _SelectListener As Object ' com.sun.star.view.XSelectionChangeListener
Private _ExpandListener As Object ' com.sun.star.awt.tree.XTreeExpansionListener
' Updatable events
Private _ActionListener As Object ' com.sun.star.awt.XActionListener
Private _OnActionPerformed As String ' Script to invoke when action triggered
Private _ActionCounter As Integer ' Counts the number of events set on the listener
' ---
Private _AdjustmentListener As Strung ' com.sun.star.awt.XAdjustmentListener
Private _OnAdjustmentValueChanged As String ' Script to invoke when scrollbar value has changed
Private _AdjustmentCounter As Integer ' Counts the number of events set on the listener
' ---
Private _FocusListener As Object ' com.sun.star.awt.XFocusListener
Private _OnFocusGained As String ' Script to invoke when control gets focus
Private _OnFocusLost As String ' Script to invoke when control loses focus
Private _FocusCounter As Integer ' Counts the number of events set on the listener
' ---
Private _ItemListener As Object ' com.sun.star.awt.XItemListener
Private _OnItemStateChanged As String ' Script to invoke when status of item changes
Private _ItemCounter As Integer ' Counts the number of events set on the listener
' ---
Private _KeyListener As Object ' com.sun.star.awt.XKeyListener
Private _OnKeyPressed As String ' Script to invoke when Key clicked in control
Private _OnKeyReleased As String ' Script to invoke when Key released in control
Private _KeyCounter As Integer ' Counts the number of events set on the listener
' ---
Private _MouseListener As Object ' com.sun.star.awt.XMouseListener
Private _OnMouseEntered As String ' Script to invoke when mouse enters control
Private _OnMouseExited As String ' Script to invoke when mouse leaves control
Private _OnMousePressed As String ' Script to invoke when mouse clicked in control
Private _OnMouseReleased As String ' Script to invoke when mouse released in control
Private _MouseCounter As Integer ' Counts the number of events set on the listener
' ---
Private _MouseMotionListener As Object ' com.sun.star.awt.XMouseMotionListener
Private _OnMouseDragged As String ' Script to invoke when mouse is dragged from the control
Private _OnMouseMoved As String ' Script to invoke when mouse is moved across the control
Private _MouseMotionCounter As Integer ' Counts the number of events set on the listener
' ---
Private _TextListener As Object ' com.sun.star.awt.XTextListener
Private _OnTextChanged As String ' Script to invoke when textual content has changed
Private _TextCounter As Integer ' Counts the number of events set on the listener
' Table control attributes
Private _ColumnWidths As Variant ' Array of column widths
@@ -127,10 +166,43 @@ Private Sub Class_Initialize()
Set _GridDataModel = Nothing
_ImplementationName = ""
_ControlType = ""
_OnNodeSelected = ""
_OnNodeExpanded = ""
Set _SelectListener = Nothing
Set _ExpandListener = Nothing
Set _ActionListener = Nothing
_OnActionPerformed = ""
_ActionCounter = 0
Set _AdjustmentListener = Nothing
_OnAdjustmentValueChanged = ""
_AdjustmentCounter = 0
Set _FocusListener = Nothing
_OnFocusGained = ""
_OnFocusLost = ""
_FocusCounter = 0
Set _KeyListener = Nothing
_OnKeyPressed = ""
_OnKeyReleased = ""
_KeyCounter = 0
Set _MouseListener = Nothing
_OnMouseEntered = ""
_OnMouseExited = ""
_OnMousePressed = ""
_OnMouseReleased = ""
_MouseCounter = 0
Set _MouseMotionListener = Nothing
_OnMouseDragged = ""
_OnMouseMoved = ""
_MouseMotionCounter = 0
Set _ItemListener = Nothing
_OnItemStateChanged = ""
_ItemCounter = 0
Set _TextListener = Nothing
_OnTextChanged = ""
_TextCounter = 0
_ColumnWidths = Array()
End Sub ' SFDialogs.SF_DialogControl Constructor
@@ -284,78 +356,156 @@ Property Get OnActionPerformed() As Variant
End Property ' SFDialogs.SF_DialogControl.OnActionPerformed (get)
REM -----------------------------------------------------------------------------
Property Let OnActionPerformed(Optional ByVal pvActionPerformed As Variant)
''' Set the updatable property OnActionPerformed
_PropertySet("OnActionPerformed", pvActionPerformed)
End Property ' SFDialogs.SF_DialogControl.OnActionPerformed (let)
REM -----------------------------------------------------------------------------
Property Get OnAdjustmentValueChanged() As Variant
''' Get the script associated with the OnAdjustmentValueChanged event
OnAdjustmentValueChanged = _PropertyGet("OnAdjustmentValueChanged")
End Property ' SFDialogs.SF_DialogControl.OnAdjustmentValueChanged (get)
REM -----------------------------------------------------------------------------
Property Let OnAdjustmentValueChanged(Optional ByVal pvAdjustmentValueChanged As Variant)
''' Set the updatable property OnAdjustmentValueChanged
_PropertySet("OnAdjustmentValueChanged", pvAdjustmentValueChanged)
End Property ' SFDialogs.SF_DialogControl.OnAdjustmentValueChanged (let)
REM -----------------------------------------------------------------------------
Property Get OnFocusGained() As Variant
''' Get the script associated with the OnFocusGained event
OnFocusGained = _PropertyGet("OnFocusGained")
End Property ' SFDialogs.SF_DialogControl.OnFocusGained (get)
REM -----------------------------------------------------------------------------
Property Let OnFocusGained(Optional ByVal pvOnFocusGained As Variant)
''' Set the updatable property OnFocusGained
_PropertySet("OnFocusGained", pvOnFocusGained)
End Property ' SFDialogs.SF_DialogControl.OnFocusGained (let)
REM -----------------------------------------------------------------------------
Property Get OnFocusLost() As Variant
''' Get the script associated with the OnFocusLost event
OnFocusLost = _PropertyGet("OnFocusLost")
End Property ' SFDialogs.SF_DialogControl.OnFocusLost (get)
REM -----------------------------------------------------------------------------
Property Let OnFocusLost(Optional ByVal pvOnFocusLost As Variant)
''' Set the updatable property OnFocusLost
_PropertySet("OnFocusLost", pvOnFocusLost)
End Property ' SFDialogs.SF_DialogControl.OnFocusLost (let)
REM -----------------------------------------------------------------------------
Property Get OnItemStateChanged() As Variant
''' Get the script associated with the OnItemStateChanged event
OnItemStateChanged = _PropertyGet("OnItemStateChanged")
End Property ' SFDialogs.SF_DialogControl.OnItemStateChanged (get)
REM -----------------------------------------------------------------------------
Property Let OnItemStateChanged(Optional ByVal pvItemStateChanged As Variant)
''' Set the updatable property OnItemStateChanged
_PropertySet("OnItemStateChanged", pvItemStateChanged)
End Property ' SFDialogs.SF_DialogControl.OnItemStateChanged (let)
REM -----------------------------------------------------------------------------
Property Get OnKeyPressed() As Variant
''' Get the script associated with the OnKeyPressed event
OnKeyPressed = _PropertyGet("OnKeyPressed")
End Property ' SFDialogs.SF_DialogControl.OnKeyPressed (get)
REM -----------------------------------------------------------------------------
Property Let OnKeyPressed(Optional ByVal pvOnKeyPressed As Variant)
''' Set the updatable property OnKeyPressed
_PropertySet("OnKeyPressed", pvOnKeyPressed)
End Property ' SFDialogs.SF_DialogControl.OnKeyPressed (let)
REM -----------------------------------------------------------------------------
Property Get OnKeyReleased() As Variant
''' Get the script associated with the OnKeyReleased event
OnKeyReleased = _PropertyGet("OnKeyReleased")
End Property ' SFDialogs.SF_DialogControl.OnKeyReleased (get)
REM -----------------------------------------------------------------------------
Property Let OnKeyReleased(Optional ByVal pvOnKeyReleased As Variant)
''' Set the updatable property OnKeyReleased
_PropertySet("OnKeyReleased", pvOnKeyReleased)
End Property ' SFDialogs.SF_DialogControl.OnKeyReleased (let)
REM -----------------------------------------------------------------------------
Property Get OnMouseDragged() As Variant
''' Get the script associated with the OnMouseDragged event
OnMouseDragged = _PropertyGet("OnMouseDragged")
End Property ' SFDialogs.SF_DialogControl.OnMouseDragged (get)
REM -----------------------------------------------------------------------------
Property Let OnMouseDragged(Optional ByVal pvOnMouseDragged As Variant)
''' Set the updatable property OnMouseDragged
_PropertySet("OnMouseDragged", pvOnMouseDragged)
End Property ' SFDialogs.SF_DialogControl.OnMouseDragged (let)
REM -----------------------------------------------------------------------------
Property Get OnMouseEntered() As Variant
''' Get the script associated with the OnMouseEntered event
OnMouseEntered = _PropertyGet("OnMouseEntered")
End Property ' SFDialogs.SF_DialogControl.OnMouseEntered (get)
REM -----------------------------------------------------------------------------
Property Let OnMouseEntered(Optional ByVal pvOnMouseEntered As Variant)
''' Set the updatable property OnMouseEntered
_PropertySet("OnMouseEntered", pvOnMouseEntered)
End Property ' SFDialogs.SF_DialogControl.OnMouseEntered (let)
REM -----------------------------------------------------------------------------
Property Get OnMouseExited() As Variant
''' Get the script associated with the OnMouseExited event
OnMouseExited = _PropertyGet("OnMouseExited")
End Property ' SFDialogs.SF_DialogControl.OnMouseExited (get)
REM -----------------------------------------------------------------------------
Property Let OnMouseExited(Optional ByVal pvOnMouseExited As Variant)
''' Set the updatable property OnMouseExited
_PropertySet("OnMouseExited", pvOnMouseExited)
End Property ' SFDialogs.SF_DialogControl.OnMouseExited (let)
REM -----------------------------------------------------------------------------
Property Get OnMouseMoved() As Variant
''' Get the script associated with the OnMouseMoved event
OnMouseMoved = _PropertyGet("OnMouseMoved")
End Property ' SFDialogs.SF_DialogControl.OnMouseMoved (get)
REM -----------------------------------------------------------------------------
Property Let OnMouseMoved(Optional ByVal pvOnMouseMoved As Variant)
''' Set the updatable property OnMouseMoved
_PropertySet("OnMouseMoved", pvOnMouseMoved)
End Property ' SFDialogs.SF_DialogControl.OnMouseMoved (let)
REM -----------------------------------------------------------------------------
Property Get OnMousePressed() As Variant
''' Get the script associated with the OnMousePressed event
OnMousePressed = _PropertyGet("OnMousePressed")
End Property ' SFDialogs.SF_DialogControl.OnMousePressed (get)
REM -----------------------------------------------------------------------------
Property Let OnMousePressed(Optional ByVal pvOnMousePressed As Variant)
''' Set the updatable property OnMousePressed
_PropertySet("OnMousePressed", pvOnMousePressed)
End Property ' SFDialogs.SF_DialogControl.OnMousePressed (let)
REM -----------------------------------------------------------------------------
Property Get OnMouseReleased() As Variant
''' Get the script associated with the OnMouseReleased event
OnMouseReleased = _PropertyGet("OnMouseReleased")
End Property ' SFDialogs.SF_DialogControl.OnMouseReleased (get)
REM -----------------------------------------------------------------------------
Property Let OnMouseReleased(Optional ByVal pvOnMouseReleased As Variant)
''' Set the updatable property OnMouseReleased
_PropertySet("OnMouseReleased", pvOnMouseReleased)
End Property ' SFDialogs.SF_DialogControl.OnMouseReleased (let)
REM -----------------------------------------------------------------------------
Property Get OnNodeExpanded() As Variant
''' Get the script associated with the OnNodeExpanded event
OnNodeExpanded = _PropertyGet("OnNodeExpanded")
@@ -386,6 +536,12 @@ Property Get OnTextChanged() As Variant
End Property ' SFDialogs.SF_DialogControl.OnTextChanged (get)
REM -----------------------------------------------------------------------------
Property Let OnTextChanged(Optional ByVal pvTextChanged As Variant)
''' Set the updatable property OnTextChanged
_PropertySet("OnTextChanged", pvTextChanged)
End Property ' SFDialogs.SF_DialogControl.OnTextChanged (let)
REM -----------------------------------------------------------------------------
Property Get Page() As Variant
''' A dialog may have several pages that can be traversed by the user step by step. The Page property of the Dialog object defines which page of the dialog is active.
''' The Page property of a control defines the page of the dialog on which the control is visible.
@@ -1606,7 +1762,24 @@ Const cstSubArgs = ""
If oControlEvents.hasByName(sEventName) Then
_PropertyGet = oControlEvents.getByName(sEventName).ScriptCode
Else
_PropertyGet = ""
' Check OnEvents set dynamically by code
Select Case UCase(psProperty)
Case UCase("OnActionPerformed") : _PropertyGet = _OnActionPerformed
Case UCase("OnAdjustmentValueChanged") : _PropertyGet = _OnAdjustmentValueChanged
Case UCase("OnFocusGained") : _PropertyGet = _OnFocusGained
Case UCase("OnFocusLost") : _PropertyGet = _OnFocusLost
Case UCase("OnItemStateChanged") : _PropertyGet = _OnItemStateChanged
Case UCase("OnKeyPressed") : _PropertyGet = _OnKeyPressed
Case UCase("OnKeyReleased") : _PropertyGet = _OnKeyReleased
Case UCase("OnMouseDragged") : _PropertyGet = _OnMouseDragged
Case UCase("OnMouseEntered") : _PropertyGet = _OnMouseEntered
Case UCase("OnMouseExited") : _PropertyGet = _OnMouseExited
Case UCase("OnMouseMoved") : _PropertyGet = _OnMouseMoved
Case UCase("OnMousePressed") : _PropertyGet = _OnMousePressed
Case UCase("OnMouseReleased") : _PropertyGet = _OnMouseReleased
Case UCase("OnTextChanged") : _PropertyGet = _OnTextChanged
Case Else : _PropertyGet = ""
End Select
End If
Case UCase("OnNodeExpanded")
Select Case _ControlType
@@ -1893,6 +2066,29 @@ Const cstSubArgs = "Value"
End If
Case Else : GoTo CatchType
End Select
Case UCase("OnActionPerformed"), UCase("OnAdjustmentValueChanged"), UCase("OnFocusGained"), UCase("OnFocusLost") _
, UCase("OnItemStateChanged"), UCase("OnKeyPressed"), UCase("OnKeyReleased") _
, UCase("OnMouseDragged"), UCase("OnMouseEntered"), UCase("OnMouseExited"), UCase("OnMouseMoved") _
, UCase("OnMousePressed"), UCase("OnMouseReleased"), UCase("OnTextChanged")
If Not ScriptForge.SF_Utils._Validate(pvValue, psProperty, V_STRING) Then GoTo Catch
' Check control type for not universal event types
Select Case UCase(psProperty)
Case UCase("OnActionPerformed"), UCase("OnItemStateChanged")
Select Case _ControlType
Case CTLBUTTON, CTLCHECKBOX, CTLCOMBOBOX, CTLLISTBOX, CTLRADIOBUTTON
Case Else : GoTo CatchType
End Select
Case UCase("OnAdjustmentValueChanged")
If _ControlType <> CTLSCROLLBAR Then GoTo CatchType
Case UCase("OnTextChanged")
Select Case _ControlType
Case CTLCOMBOBOX, CTLCURRENCYFIELD, CTLDATEFIELD, CTLFILECONTROL, CTLFORMATTEDFIELD _
, CTLNUMERICFIELD, CTLPATTERNFIELD, CTLTEXTFIELD, CTLTIMEFIELD, CTLTREECONTROL
Case Else : GoTo CatchType
End Select
Case Else
End Select
bSet = SF_DialogListener._SetOnProperty([Me], psProperty, pvValue)
Case UCase("OnNodeExpanded")
Select Case _ControlType
Case CTLTREECONTROL
diff --git a/wizards/source/sfdialogs/SF_DialogListener.xba b/wizards/source/sfdialogs/SF_DialogListener.xba
index 25634b3d..805a43d 100644
--- a/wizards/source/sfdialogs/SF_DialogListener.xba
+++ b/wizards/source/sfdialogs/SF_DialogListener.xba
@@ -13,7 +13,7 @@ Option Explicit
''' SF_Listener
''' ===========
''' The current module is dedicated to the management of dialog control events, triggered by user actions,
''' which cannot be defined with the Basic IDE
''' which are not defined with the Basic IDE
'''
''' Concerned events:
''' TreeControl control type, prefix = _SFEXP_
@@ -31,6 +31,11 @@ Option Explicit
'''
''' The described events are processed thru UNO listeners
'''
''' "On" events defined by code, prefix = _SFFOCUS_, _SFKEY_, _SFMOUSE_, _SFMOVE_, _SFITEM_, _SFADJUST_, _SFTEXT_
''' -----------
''' All event types applicable on dialogs and control types <> TreeControl
''' The events MUST NOT be preset in the Basic IDE
'''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
REM ================================================================= DEFINITIONS
@@ -63,7 +68,7 @@ Finally:
Exit Sub
Catch:
GoTo Finally
End Sub
End Sub ' SFDialogs.SF_Dialoglistener._SFEXP_requestChildNodes
Sub _SFEXP_disposing(ByRef poEvent As Object)
End Sub
@@ -84,7 +89,7 @@ REM ----------------------------------------------------------------------------
Public Sub _SFSEL_selectionChanged(Optional ByRef poEvent As Object)
''' Triggered by the OnNodeSelected event of a tree control
''' The event is triggered thru a com.sun.star.view.XSelectionChangeListener
''' The argument is passed to a user routine sstored in the SF_DialogControl instance
''' The argument is passed to a user routine stored in the SF_DialogControl instance
''' as a scripting framework URI
'''
''' Nothing happens if there are several selected nodes or none
@@ -108,7 +113,7 @@ Finally:
Exit Sub
Catch:
GoTo Finally
End Sub
End Sub ' SFDialogs.SF_Dialoglistener._SFSEL_selectionChanged
Sub _SFSEL_disposing(ByRef poEvent As Object)
End Sub
@@ -153,7 +158,7 @@ Try:
Finally:
Exit Sub
End Sub
End Sub ' SFDialogs.SF_Dialoglistener._SFTAB_actionPerformed
REM -----------------------------------------------------------------------------
Public Sub _SFTAB_itemStateChanged(Optional ByRef poEvent As Object)
@@ -187,13 +192,442 @@ Try:
Finally:
Exit Sub
End Sub
End Sub ' SFDialogs.SF_Dialoglistener._SFTAB_itemStateChanged
REM -----------------------------------------------------------------------------
Public Sub _SFTAB_disposing(Optional ByRef poEvent As Object)
End Sub
REM ========================== PUBLIC METHODS (GENERIC DIALOG AND CONTROL EVENTS)
''' Next methods SIMULATE the behaviour of events set on dialogs and dialog controls
''' in the Events tab of a dialog editing page in the Basic IDE.
''' They are not triggered by events preset in the Basic IDE.
''' They are triggered ONLY when the event has been set by code with one of the OnXxxYyyy properties,
''' like in:
''' dialog.OnActionPerformed = "vnd...." ' URI notation
REM -----------------------------------------------------------------------------
Public Sub _SFACTION_actionPerformed(Optional ByRef poEvent As Object)
''' Triggered by the OnActionPerformed event in a dialog control
''' The event is triggered thru a com.sun.star.awt.XActionListener
''' The argument is passed to a user routine stored in the SF_DialogControl instance
''' as a scripting framework URI
_TriggerEvent("actionPerformed", poEvent)
End Sub ' SFDialogs.SF_Dialoglistener. _SFACTION_actionPerformed
REM -----------------------------------------------------------------------------
Public Sub _SFACTION_disposing()
End Sub
REM -----------------------------------------------------------------------------
Public Sub _SFADJUST_adjustmentValueChanged(Optional ByRef poEvent As Object)
''' Triggered by the OnAdjustmentValueChanged event in a scrollbar
''' The event is triggered thru a com.sun.star.awt.XAdjustmentListener
''' The argument is passed to a user routine stored in the SF_DialogControl instance
''' as a scripting framework URI
_TriggerEvent("adjustmentValueChanged", poEvent)
End Sub ' SFDialogs.SF_Dialoglistener. _SFADJUST_adjustmentValueChanged
REM -----------------------------------------------------------------------------
Public Sub _SFADJUST_disposing()
End Sub
REM -----------------------------------------------------------------------------
Public Sub _SFFOCUS_focusGained(Optional ByRef poEvent As Object)
''' Triggered by the OnFocusGained event in a dialog or dialog control
''' The event is triggered thru a com.sun.star.awt.XFocusListener
''' The argument is passed to a user routine stored in the SF_Dialog or SF_DialogControl instance
''' as a scripting framework URI
_TriggerEvent("focusGained", poEvent)
End Sub ' SFDialogs.SF_Dialoglistener._SFFOCUS_focusGained
REM -----------------------------------------------------------------------------
Public Sub _SFFOCUS_focusLost(Optional ByRef poEvent As Object)
''' Triggered by the OnFocusLost event in a dialog or dialog control
''' The event is triggered thru a com.sun.star.awt.XFocusListener
''' The argument is passed to a user routine stored in the SF_Dialog or SF_DialogControl instance
''' as a scripting framework URI
_TriggerEvent("focusLost", poEvent)
End Sub ' SFDialogs.SF_Dialoglistener._SFFOCUS_focusLost
REM -----------------------------------------------------------------------------
Public Sub _SFFOCUS_disposing()
End Sub
REM -----------------------------------------------------------------------------
Public Sub _SFITEM_itemStateChanged(Optional ByRef poEvent As Object)
''' Triggered by the OnItemStateChanged event in a dialog control
''' The event is triggered thru a com.sun.star.awt.XItemListener
''' The argument is passed to a user routine stored in the SF_DialogControl instance
''' as a scripting framework URI
_TriggerEvent("itemStateChanged", poEvent)
End Sub ' SFDialogs.SF_Dialoglistener. _SFACTION_actionPerformed
REM -----------------------------------------------------------------------------
Public Sub _SFITEM_disposing()
End Sub
REM -----------------------------------------------------------------------------
Public Sub _SFKEY_keyPressed(Optional ByRef poEvent As Object)
''' Triggered by the OnKeyPressed event in a dialog or dialog control
''' The event is triggered thru a com.sun.star.awt.XKeyListener
''' The argument is passed to a user routine stored in the SF_Dialog or SF_DialogControl instance
''' as a scripting framework URI
_TriggerEvent("keyPressed", poEvent)
End Sub ' SFDialogs.SF_Dialoglistener._SFKEY_keyPressed
REM -----------------------------------------------------------------------------
Public Sub _SFKEY_keyReleased(Optional ByRef poEvent As Object)
''' Triggered by the OnKeyReleased event in a dialog or dialog control
''' The event is triggered thru a com.sun.star.awt.XKeyListener
''' The argument is passed to a user routine stored in the SF_Dialog or SF_DialogControl instance
''' as a scripting framework URI
_TriggerEvent("keyReleased", poEvent)
End Sub ' SFDialogs.SF_Dialoglistener._SFKEY_keyReleased
REM -----------------------------------------------------------------------------
Public Sub _SFKEY_disposing()
End Sub
REM -----------------------------------------------------------------------------
Public Sub _SFMOUSE_mouseEntered(Optional ByRef poEvent As Object)
''' Triggered by the OnMouseEntered event in a dialog or dialog control
''' The event is triggered thru a com.sun.star.awt.XMouseListener
''' The argument is passed to a user routine stored in the SF_Dialog or SF_DialogControl instance
''' as a scripting framework URI
_TriggerEvent("mouseEntered", poEvent)
End Sub ' SFDialogs.SF_Dialoglistener._SFMOUSE_mouseEntered
REM -----------------------------------------------------------------------------
Public Sub _SFMOUSE_mouseExited(Optional ByRef poEvent As Object)
''' Triggered by the OnMouseExited event in a dialog or dialog control
''' The event is triggered thru a com.sun.star.awt.XMouseListener
''' The argument is passed to a user routine stored in the SF_Dialog or SF_DialogControl instance
''' as a scripting framework URI
_TriggerEvent("mouseExited", poEvent)
End Sub ' SFDialogs.SF_Dialoglistener._SFMOUSE_mouseExited
REM -----------------------------------------------------------------------------
Public Sub _SFMOUSE_mousePressed(Optional ByRef poEvent As Object)
''' Triggered by the OnMousePressed event in a dialog or dialog control
''' The event is triggered thru a com.sun.star.awt.XMouseListener
''' The argument is passed to a user routine stored in the SF_Dialog or SF_DialogControl instance
''' as a scripting framework URI
_TriggerEvent("mousePressed", poEvent)
End Sub ' SFDialogs.SF_Dialoglistener._SFMOUSE_mousePressed
REM -----------------------------------------------------------------------------
Public Sub _SFMOUSE_mouseReleased(Optional ByRef poEvent As Object)
''' Triggered by the OnMouseReleased event in a dialog or dialog control
''' The event is triggered thru a com.sun.star.awt.XMouseListener
''' The argument is passed to a user routine stored in the SF_Dialog or SF_DialogControl instance
''' as a scripting framework URI
_TriggerEvent("mouseReleased", poEvent)
End Sub ' SFDialogs.SF_Dialoglistener._SFMOUSE_mouseReleased
REM -----------------------------------------------------------------------------
Public Sub _SFMOUSE_disposing()
End Sub
REM -----------------------------------------------------------------------------
Public Sub _SFMOVE_mouseDragged(Optional ByRef poEvent As Object)
''' Triggered by the OnMouseDragged event in a dialog or dialog control
''' The event is triggered thru a com.sun.star.awt.XMouseMotionListener
''' The argument is passed to a user routine stored in the SF_Dialog or SF_DialogControl instance
''' as a scripting framework URI
_TriggerEvent("mouseDragged", poEvent)
End Sub ' SFDialogs.SF_Dialoglistener._SFMOUSE_mouseDragged
REM -----------------------------------------------------------------------------
Public Sub _SFMOVE_mouseMoved(Optional ByRef poEvent As Object)
''' Triggered by the OnMouseMoved event in a dialog or dialog control
''' The event is triggered thru a com.sun.star.awt.XMouseMotionListener
''' The argument is passed to a user routine stored in the SF_Dialog or SF_DialogControl instance
''' as a scripting framework URI
_TriggerEvent("mouseMoved", poEvent)
End Sub ' SFDialogs.SF_Dialoglistener._SFMOUSE_mouseMoved
REM -----------------------------------------------------------------------------
Public Sub _SFMOVE_disposing()
End Sub
REM -----------------------------------------------------------------------------
Public Sub _SFTEXT_textChanged(Optional ByRef poEvent As Object)
''' Triggered by the OnTextChanged event in a dialog control
''' The event is triggered thru a com.sun.star.awt.XTextListener
''' The argument is passed to a user routine stored in the SF_DialogControl instance
''' as a scripting framework URI
_TriggerEvent("textChanged", poEvent)
End Sub ' SFDialogs.SF_Dialoglistener. _SFTEXT_textChanged
REM -----------------------------------------------------------------------------
Public Sub _SFTEXT_disposing()
End Sub
REM ============================================================= PRIVATE METHODS
REM -----------------------------------------------------------------------------
Public Function _SetOnProperty(ByRef poInstance As Object _
, ByVal psProperty As String _
, ByVal psScript As String _
) As Boolean
''' Set one of the On properties related to either a SF_Dialog or SF_DialogControl instance
''' Such a property is typically set by next pseudo-code:
''' poInstance.psProperty = psScript
''' It requires a strictly identical nomenclature of internal variables in both classes.
''' Args:
''' poInstance: a SF_Dialog or a SF_DialogControl instance
''' psProperty: one of the applicable On properties ("OnFocusGained", "OnMouseMoved", ...)
''' psScript: the script to run when the event is triggered
''' When the zero-length strng, the trigger is deactivated
Dim bSet As Boolean ' Return value
Dim oModel As Object ' com.sun.star.awt.XControlModel
Dim oView As Object ' com.sun.star.awt.XControl
Dim oDialogEvents As Object ' com.sun.star.container.XNameContainer
Dim sListener As String ' Applicable listener, depending on property, f.i. "XMouseListener"
Dim sEventName As String ' Internal event name
Dim iCounterIncrement As Integer ' Increment to be applied on listener counter
Dim sPrevious As String ' Actual value of script before the change
Const cstPrefix = "com.sun.star.awt."
bSet = True
Check:
If IsNull(poInstance) Or Len(psProperty) = 0 Then GoTo Catch
With poInstance
' Initialize local variables depending on instance type
If .ObjectType = "DIALOG" Then
Set oModel = ._DialogModel
Set oView = ._DialogControl
Else ' DIALOGCONTROL
Set oModel = ._ControlModel
Set oView = ._ControlView
End If
If IsNull(oModel) Or IsNull(oView) Then GoTo Catch
' Ignore request if an event has been statically preset (in the Basic IDE) with the same name
Set oDialogEvents = oModel.getEvents()
sListener = ._GetListener(psProperty)
sEventName = cstPrefix & sListener & "::" & ._GetEventName(psProperty)
If oDialogEvents.hasByName(sEventName) Then GoTo Catch
Try:
' Note the target scripts. Compare previous and new values. Fix the increment to be applied on counter
Select Case UCase(psProperty)
Case UCase("OnActionPerformed")
sPrevious = ._OnActionPerformed
._OnActionPerformed = psScript
Case UCase("OnAdjustmentValueChanged")
sPrevious = ._OnAdjustmentValueChanged
._OnAdjustmentValueChanged = psScript
Case UCase("OnFocusGained")
sPrevious = ._OnfocusGained
._OnFocusGained = psScript
Case UCase("OnFocusLost")
sPrevious = ._OnFocusLost
._OnFocusLost = psScript
Case UCase("OnItemStateChanged")
sPrevious = ._OnItemStateChanged
._OnItemStateChanged = psScript
Case UCase("OnKeyPressed")
sPrevious = ._OnKeyPressed
._OnKeyPressed = psScript
Case UCase("OnKeyReleased")
sPrevious = ._OnKeyReleased
._OnKeyReleased = psScript
Case UCase("OnMouseDragged")
sPrevious = ._OnMouseDragged
._OnMouseDragged = psScript
Case UCase("OnMouseEntered")
sPrevious = ._OnMouseEntered
._OnMouseEntered = psScript
Case UCase("OnMouseExited")
sPrevious = ._OnMouseExited
._OnMouseExited = psScript
Case UCase("OnMouseMoved")
sPrevious = ._OnMouseMoved
._OnMouseMoved = psScript
Case UCase("OnMousePressed")
sPrevious = ._OnMousePressed
._OnMousePressed = psScript
Case UCase("OnMouseReleased")
sPrevious = ._OnMouseReleased
._OnMouseReleased = psScript
Case UCase("OnTextChanged")
sPrevious = ._OnTextChanged
._OnTextChanged = psScript
End Select
' Compare previous and new event to know what to do next with the listener
If sPrevious = psScript Then GoTo Finally ' No change
If Len(sPrevious) = 0 Then ' New event
iCounterIncrement = +1
ElseIf Len(psScript) = 0 Then ' Cancel event
iCounterIncrement = -1
Else ' Event replacement
iCounterIncrement = 0
End If
' Setup a new fresh listener, only once by listener during dialog or control life time,
' (re)add it to the instance view or remove the existing one if not needed anymore
Select Case sListener
Case "XActionListener"
._ActionCounter = ._ActionCounter + iCounterIncrement
If ._ActionCounter = 1 Then
If IsNull(._ActionListener) Then Set ._ActionListener = CreateUnoListener("_SFACTION_", cstPrefix & sListener)
If iCounterIncrement = 1 Then oView.addActionListener(._ActionListener)
ElseIf ._ActionCounter <= 0 Then
If Not IsNull(._ActionListener) Then oView.removeActionListener(._ActionListener)
._ActionCounter = 0 ' Prevent negative values
End If
Case "XAdjustmentListener"
._AdjustmentCounter = ._AdjustmentCounter + iCounterIncrement
If ._AdjustmentCounter = 1 Then
If IsNull(._AdjustmentListener) Then Set ._AdjustmentListener = CreateUnoListener("_SFADJUST_", cstPrefix & sListener)
If iCounterIncrement = 1 Then oView.addAdjustmentListener(._AdjustmentListener)
ElseIf ._AdjustmentCounter <= 0 Then
If Not IsNull(._AdjustmentListener) Then oView.removeAdjustmentListener(._AdjustmentListener)
._AdjustmentCounter = 0 ' Prevent negative values
End If
Case "XFocusListener"
._FocusCounter = ._FocusCounter + iCounterIncrement
If ._FocusCounter = 1 Then
If IsNull(._FocusListener) Then Set ._FocusListener = CreateUnoListener("_SFFOCUS_", cstPrefix & sListener)
If iCounterIncrement = 1 Then oView.addFocusListener(._FocusListener)
ElseIf ._FocusCounter <= 0 Then
If Not IsNull(._FocusListener) Then oView.removeFocusListener(._FocusListener)
._FocusCounter = 0 ' Prevent negative values
End If
Case "XItemListener"
._ItemCounter = ._ItemCounter + iCounterIncrement
If ._ItemCounter = 1 Then
If IsNull(._ItemListener) Then Set ._ItemListener = CreateUnoListener("_SFITEM_", cstPrefix & sListener)
If iCounterIncrement = 1 Then oView.addItemListener(._ItemListener)
ElseIf ._ItemCounter <= 0 Then
If Not IsNull(._ItemListener) Then oView.removeItemListener(._ItemListener)
._ItemCounter = 0 ' Prevent negative values
End If
Case "XKeyListener"
._KeyCounter = ._KeyCounter + iCounterIncrement
If ._KeyCounter= 1 Then
If IsNull(._KeyListener) Then Set ._KeyListener = CreateUnoListener("_SFKEY_", cstPrefix & sListener)
If iCounterIncrement = 1 Then oView.addKeyListener(._KeyListener)
ElseIf ._KeyCounter <= 0 Then
If Not IsNull(._KeyListener) Then oView.removeKeyListener(._KeyListener)
._KeyCounter = 0 ' Prevent negative values
End If
Case "XMouseListener"
._MouseCounter = ._MouseCounter + iCounterIncrement
If ._MouseCounter= 1 Then
If IsNull(._MouseListener) Then Set ._MouseListener = CreateUnoListener("_SFMOUSE_", cstPrefix & sListener)
If iCounterIncrement = 1 Then oView.addMouseListener(._MouseListener)
ElseIf ._MouseCounter <= 0 Then
If Not IsNull(._MouseListener) Then oView.removeMouseListener(._MouseListener)
._MouseCounter = 0 ' Prevent negative values
End If
Case "XMouseMotionListener"
._MouseMotionCounter = ._MouseMotionCounter + iCounterIncrement
If ._MouseMotionCounter = 1 Then
If IsNull(._MouseMotionListener) Then Set ._MouseMotionListener = CreateUnoListener("_SFMOVE_", cstPrefix & sListener)
If iCounterIncrement = 1 Then oView.addMouseMotionListener(._MouseMotionListener)
ElseIf ._MouseMotionCounter <= 0 Then
If Not IsNull(._MouseMotionListener) Then oView.removeMouseMotionListener(._MouseMotionListener)
._MouseMotionCounter = 0 ' Prevent negative values
End If
Case "XTextListener"
._TextCounter = ._TextCounter + iCounterIncrement
If ._TextCounter = 1 Then
If IsNull(._TextListener) Then Set ._TextListener = CreateUnoListener("_SFTEXT_", cstPrefix & sListener)
If iCounterIncrement = 1 Then oView.addTextListener(._TextListener)
ElseIf ._TextCounter <= 0 Then
If Not IsNull(._TextListener) Then oView.removeTextListener(._TextListener)
._TextCounter = 0 ' Prevent negative values
End If
End Select
End With
Finally:
_SetOnProperty = bSet
Exit Function
Catch:
bSet = False
GoTo Finally
End Function ' SFDialogs.SF_Dialoglistener._SetOnProperty
REM -----------------------------------------------------------------------------
Public Sub _TriggerEvent(ByVal EventType, Optional ByRef poEvent As Object)
''' Triggered by the EventType event in a dialog or dialog control
''' The argument is passed to a user routine stored in the SF_Dialog or SF_DialogControl instance
''' as a scripting framework URI
Dim oDialog As Object ' The SF_Dialog or SF_DialogControl object having triggered the event
Dim sScript As String ' Script to be invoked
On Local Error GoTo Catch ' Avoid stopping event scripts
Check:
If IsNull(poEvent) Or IsMissing(poEvent) Then Exit Sub
Try:
Set oDialog = ScriptForge.SF_Services.CreateScriptService("SFDialogs.DialogEvent", poEvent)
If IsNull(oDialog) Then Exit Sub
With oDialog
Select Case EventType
Case "actionPerformed" : sScript = .OnActionPerformed
Case "adjustmentValueChanged" : sScript = .OnAdjustmentValueChanged
Case "focusGained" : sScript = .OnFocusGained
Case "focusLost" : sScript = .OnFocusLost
Case "itemStateChanged" : sScript = .OnItemStateChanged
Case "mouseDragged" : sScript = .OnMouseDragged
Case "mouseEntered" : sScript = .OnMouseEntered
Case "mouseExited" : sScript = .OnMouseExited
Case "mouseMoved" : sScript = .OnMouseMoved
Case "mousePressed" : sScript = .OnMousePressed
Case "mouseReleased" : sScript = .OnMouseReleased
Case "textChanged" : sScript = .OnTextChanged
Case Else : sScript = "" ' Should not happen
End Select
If Len(sScript) = 0 Then Exit Sub
ScriptForge.SF_Session._ExecuteScript(sScript, poEvent)
End With
Finally:
Exit Sub
Catch:
GoTo Finally
End Sub ' SFDialogs.SF_Dialoglistener._TriggerEvent
REM ============================================ END OF SFDIALOGS.SF_DIALOGLISTENER
</script:module>
\ No newline at end of file
\ No newline at end of file
diff --git a/wizards/source/sfwidgets/SF_Toolbar.xba b/wizards/source/sfwidgets/SF_Toolbar.xba
index d65e7c6..c457a62 100644
--- a/wizards/source/sfwidgets/SF_Toolbar.xba
+++ b/wizards/source/sfwidgets/SF_Toolbar.xba
@@ -154,7 +154,7 @@ End Property ' SFWidgets.SF_Toolbar.Name (get)
REM -----------------------------------------------------------------------------
Property Get ResourceURL() As String
''' Returns True when the toolbar is available in all documents of the same type
''' Returns URL of the toolbar, in the form private:toolbar/xxx
''' Example:
''' MsgBox myToolbar.ResourceURL
@@ -538,4 +538,4 @@ Private Function _Repr() As String
End Function ' SFWidgets.SF_Toolbar._Repr
REM ============================================ END OF SFWIDGETS.SF_TOOLBAR
</script:module>
</script:module>
\ No newline at end of file