wizards/source/sfdialogs/SF_Dialog.xba             |    6 ++-
 wizards/source/sfdialogs/SF_DialogControl.xba      |    6 ++-
 wizards/source/sfdialogs/SF_DialogListener.xba     |   32 +++++++++++++++------
 wizards/source/sfdialogs/script.xlb                |   10 +++---
 wizards/source/sfdocuments/SF_DocumentListener.xba |    3 +
 wizards/source/sfwidgets/SF_MenuListener.xba       |    2 -
 wizards/source/sfwidgets/script.xlb                |   14 ++++-----
 7 files changed, 47 insertions(+), 26 deletions(-)

New commits:
commit dec9f7d5b2d72e83f4feb81bc8845bca506bbe20
Author:     Jean-Pierre Ledure <j...@ledure.be>
AuthorDate: Sat Mar 1 12:45:29 2025 +0100
Commit:     Jean-Pierre Ledure <j...@ledure.be>
CommitDate: Sat Mar 1 14:38:42 2025 +0100

    ScriptForge (dialogs, documents, widgets) Secure listeners
    
    Listeners programmed in Basic are created with
      CreateUnoListener(prefix, listener)
    
    The prefix argument determines the series of
    routines run when an event is triggered.
    
    So far, for SF internal listeners, the prefix
    was chosen to minimize the risk of naming
    collisions with routines present in user scripts.
    
    In fact the prefix argument may be provided as
      Library.Module.Prefix
    which eliminates the risk of ambiguity or
    homonymy.
    
    With the actual change forcing the full
    qualification of prefixes, the risk is reduced
    from epsilon to zero.
    
    No impact on the user documentation.
    
    Change-Id: I95ef4beec80c89a074c8bec809f416479e64d8cf
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182384
    Reviewed-by: Jean-Pierre Ledure <j...@ledure.be>
    Tested-by: Jenkins

diff --git a/wizards/source/sfdialogs/SF_Dialog.xba 
b/wizards/source/sfdialogs/SF_Dialog.xba
index c204d44e1114..96035e277009 100644
--- a/wizards/source/sfdialogs/SF_Dialog.xba
+++ b/wizards/source/sfdialogs/SF_Dialog.xba
@@ -1989,7 +1989,8 @@ Try:
                _DialogModel.DesktopAsParent = Not ( _BuiltFromScratch And 
_BuiltInPython )
                _DialogControl.setVisible(True)
                &apos;  Watch the window Close button
-               Set oListener = CreateUnoListener(&quot;_SFNONMODAL_&quot;, 
&quot;com.sun.star.awt.XTopWindowListener&quot;)
+               Set oListener = 
CreateUnoListener(&quot;SFDialogs.SF_DialogListener._SFNONMODAL_&quot; _
+                                                                               
        , &quot;com.sun.star.awt.XTopWindowListener&quot;)
                _DialogControl.addTopWindowListener(oListener)
                lExecute = 0
        End If
@@ -2359,7 +2360,8 @@ Dim bManager As Boolean                           &apos;  
Return value
 Dim vControls As Variant                       &apos;  Array of involved 
controls
 Dim oControl As Object                         &apos;  A DialogControl object
 Dim i As Long
-Const cstPrefix = &quot;_SFTAB_&quot;          &apos;  Prefix of Subs to 
trigger when involved controls are clicked
+Const cstPrefix = &quot;SFDialogs.SF_DialogListener._SFTAB_&quot;
+                                                       &apos;  Prefix of Subs 
to trigger when involved controls are clicked
 Const cstComma = &quot;,&quot;
 
 Const cstThisSub = &quot;SFDialogs.Dialog.SetPageManager&quot;
diff --git a/wizards/source/sfdialogs/SF_DialogControl.xba 
b/wizards/source/sfdialogs/SF_DialogControl.xba
index a82a18e2e124..4ddc9e0e0608 100644
--- a/wizards/source/sfdialogs/SF_DialogControl.xba
+++ b/wizards/source/sfdialogs/SF_DialogControl.xba
@@ -2308,7 +2308,8 @@ Const cstSubArgs = &quot;Value&quot;
                                        End If
                                        &apos;  Setup a new fresh listener
                                        If Len(pvValue) &gt; 0 Then
-                                               Set _ExpandListener = 
CreateUnoListener(&quot;_SFEXP_&quot;, 
&quot;com.sun.star.awt.tree.XTreeExpansionListener&quot;)
+                                               Set _ExpandListener = 
CreateUnoListener(&quot;SFDialogs.SF_DialogListener._SFEXP_&quot; _
+                                                                               
                        , 
&quot;com.sun.star.awt.tree.XTreeExpansionListener&quot;)
                                                
_ControlView.addTreeExpansionListener(_ExpandListener)
                                                _OnNodeExpanded = pvValue
                                        End If
@@ -2326,7 +2327,8 @@ Const cstSubArgs = &quot;Value&quot;
                                        End If
                                        &apos;  Setup a new fresh listener
                                        If Len(pvValue) &gt; 0 Then
-                                               Set _SelectListener = 
CreateUnoListener(&quot;_SFSEL_&quot;, 
&quot;com.sun.star.view.XSelectionChangeListener&quot;)
+                                               Set _SelectListener = 
CreateUnoListener(&quot;SFDialogs.SF_DialogListener._SFSEL_&quot; _
+                                                                               
                        , 
&quot;com.sun.star.view.XSelectionChangeListener&quot;)
                                                
_ControlView.addSelectionChangeListener(_SelectListener)
                                                _OnNodeSelected = pvValue
                                        End If
diff --git a/wizards/source/sfdialogs/SF_DialogListener.xba 
b/wizards/source/sfdialogs/SF_DialogListener.xba
index 60c5e9a34499..8975c2d8257a 100644
--- a/wizards/source/sfdialogs/SF_DialogListener.xba
+++ b/wizards/source/sfdialogs/SF_DialogListener.xba
@@ -564,7 +564,9 @@ Try:
                        Case &quot;XActionListener&quot;
                                ._ActionCounter = ._ActionCounter + 
iCounterIncrement
                                If ._ActionCounter = 1 Then
-                                       If IsNull(._ActionListener) Then Set 
._ActionListener = CreateUnoListener(&quot;_SFACTION_&quot;, cstPrefix &amp; 
sListener)
+                                       If IsNull(._ActionListener) Then
+                                               Set ._ActionListener = 
CreateUnoListener(&quot;SFDialogs.SF_DialogListener._SFACTION_&quot;, cstPrefix 
&amp; sListener)
+                                       End If
                                        If iCounterIncrement = 1 Then 
oView.addActionListener(._ActionListener)
                                ElseIf ._ActionCounter &lt;= 0 Then
                                        If Not IsNull(._ActionListener) Then 
oView.removeActionListener(._ActionListener)
@@ -573,7 +575,9 @@ Try:
                        Case &quot;XAdjustmentListener&quot;
                                ._AdjustmentCounter = ._AdjustmentCounter + 
iCounterIncrement
                                If ._AdjustmentCounter = 1 Then
-                                       If IsNull(._AdjustmentListener) Then 
Set ._AdjustmentListener = CreateUnoListener(&quot;_SFADJUST_&quot;, cstPrefix 
&amp; sListener)
+                                       If IsNull(._AdjustmentListener) Then
+                                               Set ._AdjustmentListener = 
CreateUnoListener(&quot;SFDialogs.SF_DialogListener._SFADJUST_&quot;, cstPrefix 
&amp; sListener)
+                                       End If
                                        If iCounterIncrement = 1 Then 
oView.addAdjustmentListener(._AdjustmentListener)
                                ElseIf ._AdjustmentCounter &lt;= 0 Then
                                        If Not IsNull(._AdjustmentListener) 
Then oView.removeAdjustmentListener(._AdjustmentListener)
@@ -582,7 +586,9 @@ Try:
                        Case &quot;XFocusListener&quot;
                                ._FocusCounter = ._FocusCounter + 
iCounterIncrement
                                If ._FocusCounter = 1 Then
-                                       If IsNull(._FocusListener) Then Set 
._FocusListener = CreateUnoListener(&quot;_SFFOCUS_&quot;, cstPrefix &amp; 
sListener)
+                                       If IsNull(._FocusListener) Then
+                                               Set ._FocusListener = 
CreateUnoListener(&quot;SFDialogs.SF_DialogListener._SFFOCUS_&quot;, cstPrefix 
&amp; sListener)
+                                       End If
                                        If iCounterIncrement = 1 Then 
oView.addFocusListener(._FocusListener)
                                ElseIf ._FocusCounter &lt;= 0 Then
                                        If Not IsNull(._FocusListener) Then 
oView.removeFocusListener(._FocusListener)
@@ -591,7 +597,9 @@ Try:
                        Case &quot;XItemListener&quot;
                                ._ItemCounter = ._ItemCounter + 
iCounterIncrement
                                If ._ItemCounter = 1 Then
-                                       If IsNull(._ItemListener) Then Set 
._ItemListener = CreateUnoListener(&quot;_SFITEM_&quot;, cstPrefix &amp; 
sListener)
+                                       If IsNull(._ItemListener) Then
+                                               Set ._ItemListener = 
CreateUnoListener(&quot;SFDialogs.SF_DialogListener._SFITEM_&quot;, cstPrefix 
&amp; sListener)
+                                       End If
                                        If iCounterIncrement = 1 Then 
oView.addItemListener(._ItemListener)
                                ElseIf ._ItemCounter &lt;= 0 Then
                                        If Not IsNull(._ItemListener) Then 
oView.removeItemListener(._ItemListener)
@@ -600,7 +608,9 @@ Try:
                        Case &quot;XKeyListener&quot;
                                ._KeyCounter = ._KeyCounter + iCounterIncrement
                                If ._KeyCounter= 1 Then
-                                       If IsNull(._KeyListener) Then Set 
._KeyListener = CreateUnoListener(&quot;_SFKEY_&quot;, cstPrefix &amp; 
sListener)
+                                       If IsNull(._KeyListener) Then
+                                               Set ._KeyListener = 
CreateUnoListener(&quot;SFDialogs.SF_DialogListener._SFKEY_&quot;, cstPrefix 
&amp; sListener)
+                                       End If
                                        If iCounterIncrement = 1 Then 
oView.addKeyListener(._KeyListener)
                                ElseIf ._KeyCounter &lt;= 0 Then
                                        If Not IsNull(._KeyListener) Then 
oView.removeKeyListener(._KeyListener)
@@ -609,7 +619,9 @@ Try:
                        Case &quot;XMouseListener&quot;
                                ._MouseCounter = ._MouseCounter + 
iCounterIncrement
                                If ._MouseCounter= 1 Then
-                                       If IsNull(._MouseListener) Then Set 
._MouseListener = CreateUnoListener(&quot;_SFMOUSE_&quot;, cstPrefix &amp; 
sListener)
+                                       If IsNull(._MouseListener) Then
+                                               Set ._MouseListener = 
CreateUnoListener(&quot;SFDialogs.SF_DialogListener._SFMOUSE_&quot;, cstPrefix 
&amp; sListener)
+                                       End If
                                        If iCounterIncrement = 1 Then 
oView.addMouseListener(._MouseListener)
                                ElseIf ._MouseCounter &lt;= 0 Then
                                        If Not IsNull(._MouseListener) Then 
oView.removeMouseListener(._MouseListener)
@@ -618,7 +630,9 @@ Try:
                        Case &quot;XMouseMotionListener&quot;
                                ._MouseMotionCounter = ._MouseMotionCounter + 
iCounterIncrement
                                If ._MouseMotionCounter = 1 Then
-                                       If IsNull(._MouseMotionListener) Then 
Set ._MouseMotionListener = CreateUnoListener(&quot;_SFMOVE_&quot;, cstPrefix 
&amp; sListener)
+                                       If IsNull(._MouseMotionListener) Then
+                                               Set ._MouseMotionListener = 
CreateUnoListener(&quot;SFDialogs.SF_DialogListener._SFMOVE_&quot;, cstPrefix 
&amp; sListener)
+                                       End If
                                        If iCounterIncrement = 1 Then 
oView.addMouseMotionListener(._MouseMotionListener)
                                ElseIf ._MouseMotionCounter &lt;= 0 Then
                                        If Not IsNull(._MouseMotionListener) 
Then oView.removeMouseMotionListener(._MouseMotionListener)
@@ -627,7 +641,9 @@ Try:
                        Case &quot;XTextListener&quot;
                                ._TextCounter = ._TextCounter + 
iCounterIncrement
                                If ._TextCounter = 1 Then
-                                       If IsNull(._TextListener) Then Set 
._TextListener = CreateUnoListener(&quot;_SFTEXT_&quot;, cstPrefix &amp; 
sListener)
+                                       If IsNull(._TextListener) Then
+                                               Set ._TextListener = 
CreateUnoListener(&quot;SFDialogs.SF_DialogListener._SFTEXT_&quot;, cstPrefix 
&amp; sListener)
+                                       End If
                                        If iCounterIncrement = 1 Then 
oView.addTextListener(._TextListener)
                                ElseIf ._TextCounter &lt;= 0 Then
                                        If Not IsNull(._TextListener) Then 
oView.removeTextListener(._TextListener)
diff --git a/wizards/source/sfdialogs/script.xlb 
b/wizards/source/sfdialogs/script.xlb
index 59263472b3a1..199ba3621c19 100644
--- a/wizards/source/sfdialogs/script.xlb
+++ b/wizards/source/sfdialogs/script.xlb
@@ -1,10 +1,10 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE library:library PUBLIC "-//OpenOffice.org//DTD OfficeDocument 
1.0//EN" "library.dtd">
 <library:library xmlns:library="http://openoffice.org/2000/library"; 
library:name="SFDialogs" library:readonly="false" 
library:passwordprotected="false">
- <library:element library:name="__License"/>
- <library:element library:name="SF_Register"/>
- <library:element library:name="SF_Dialog"/>
- <library:element library:name="SF_DialogControl"/>
- <library:element library:name="SF_DialogListener"/>
  <library:element library:name="SF_DialogUtils"/>
+ <library:element library:name="SF_DialogListener"/>
+ <library:element library:name="SF_DialogControl"/>
+ <library:element library:name="SF_Dialog"/>
+ <library:element library:name="SF_Register"/>
+ <library:element library:name="__License"/>
 </library:library>
\ No newline at end of file
diff --git a/wizards/source/sfdocuments/SF_DocumentListener.xba 
b/wizards/source/sfdocuments/SF_DocumentListener.xba
index fbb0271bbc38..96afe4560951 100644
--- a/wizards/source/sfdocuments/SF_DocumentListener.xba
+++ b/wizards/source/sfdocuments/SF_DocumentListener.xba
@@ -47,7 +47,8 @@ Dim oController As Object                                     
        &apos;  com.sun.star.frame.Controller
 Dim oListener As Object                                                        
&apos;  com.sun.star.sheet.XRangeSelectionListener
 Dim lCountLoops As Long                                                        
&apos;  Sleep cycles counter
 
-Const cstListenerPrefix = &quot;_SFRGSEL_&quot;                        &apos;  
Prefix used for naming events Subs
+Const cstListenerPrefix = &quot;SFDocuments.SF_DocumentListener._SFRGSEL_&quot;
+                                                                               
                &apos;  Prefix used for naming events Subs
 Const cstSleep = 50                                                            
&apos;  Sleep steps in ms while waiting for the end of the interaction
 Const cstMaxSleep = (60 * 5 * 1000) / cstSleep &apos;  Never sleep more than 5 
minutes. Afterwards, processing continues
 
diff --git a/wizards/source/sfwidgets/SF_MenuListener.xba 
b/wizards/source/sfwidgets/SF_MenuListener.xba
index cb7839de5804..18ce2b6a977e 100644
--- a/wizards/source/sfwidgets/SF_MenuListener.xba
+++ b/wizards/source/sfwidgets/SF_MenuListener.xba
@@ -29,7 +29,7 @@ Dim MenuListener                              As Object       
        &apos; com.sun.star.awt.XMenuListener
 
 REM =========================================================== PRIVATE 
CONSTANTS
 
-Private Const _MenuListenerPrefix              = &quot;_SFMENU_&quot;
+Private Const _MenuListenerPrefix              = 
&quot;SFWidgets.SF_MenuListener._SFMENU_&quot;
 Private Const _MenuListener                            = 
&quot;com.sun.star.awt.XMenuListener&quot;
 Private Const cstUnoPrefix                             = &quot;.uno:&quot;
 Private Const cstScriptArg                             = &quot;:::&quot;
diff --git a/wizards/source/sfwidgets/script.xlb 
b/wizards/source/sfwidgets/script.xlb
index e23174375536..cea251e83b61 100644
--- a/wizards/source/sfwidgets/script.xlb
+++ b/wizards/source/sfwidgets/script.xlb
@@ -1,12 +1,12 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE library:library PUBLIC "-//OpenOffice.org//DTD OfficeDocument 
1.0//EN" "library.dtd">
 <library:library xmlns:library="http://openoffice.org/2000/library"; 
library:name="SFWidgets" library:readonly="false" 
library:passwordprotected="false">
- <library:element library:name="SF_ToolbarButton"/>
- <library:element library:name="SF_Toolbar"/>
- <library:element library:name="SF_MenuListener"/>
- <library:element library:name="SF_Menu"/>
- <library:element library:name="SF_ContextMenu"/>
- <library:element library:name="SF_PopupMenu"/>
- <library:element library:name="SF_Register"/>
  <library:element library:name="__License"/>
+ <library:element library:name="SF_Register"/>
+ <library:element library:name="SF_PopupMenu"/>
+ <library:element library:name="SF_ContextMenu"/>
+ <library:element library:name="SF_Menu"/>
+ <library:element library:name="SF_MenuListener"/>
+ <library:element library:name="SF_Toolbar"/>
+ <library:element library:name="SF_ToolbarButton"/>
 </library:library>
\ No newline at end of file

Reply via email to