wizards/source/scriptforge/python/scriptforge.py |    3 
 wizards/source/sfdocuments/SF_Calc.xba           |    7 ++
 wizards/source/sfdocuments/SF_Document.xba       |   73 +++++++++++++++++++++++
 wizards/source/sfdocuments/SF_FormDocument.xba   |    7 ++
 wizards/source/sfdocuments/SF_Writer.xba         |    7 ++
 5 files changed, 97 insertions(+)

New commits:
commit 96302e0bbadfe3ed33af4a14a33a44bab3f5f0d4
Author:     Jean-Pierre Ledure <j...@ledure.be>
AuthorDate: Fri Jan 27 16:39:42 2023 +0100
Commit:     Jean-Pierre Ledure <j...@ledure.be>
CommitDate: Fri Jan 27 16:54:19 2023 +0000

    ScriptForge (SF_Document) Echo() method freezes screen updates
    
    While a script is executed any display update
    resulting from that execution is done immediately.
    
    For performance reasons it might be an advantage
    to differ the display updates up to the end of the script.
    This is where pairs of Echo() methods to set
    and reset the removal of the immediate updates
    may be beneficial.
    
    Optionally the actual mouse pointer can be
    modified to the image of an hourglass.
    
    Arguments:
      EchoOn: when False, the display updates are suspended.
              Default = True.
              Multiple calls with EchoOn = False are harmless.
      Hourglass: when True, the mouse pointer is changed
              to an hourglass. Default = False.
              The mouse pointer needs to be inside the actual
              document's window.
              Note that it is very likely that at the least
              manual movement of the mouse, the operating system
              or the LibreOffice process will take back
              the control of the mouse icon and its usual behaviour.
    
    The method may be called from any document, including Calc and
    Writer, or form document.
    
    It may be invoked from Basic and Python user scripts.
    
    Echo() should be documented in the sfdocument.xhp help page.
    
    Change-Id: I4d669f5e332131bd1b2efcd33b7a98b304796ad1
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146258
    Tested-by: Jean-Pierre Ledure <j...@ledure.be>
    Reviewed-by: Jean-Pierre Ledure <j...@ledure.be>
    Tested-by: Jenkins

diff --git a/wizards/source/scriptforge/python/scriptforge.py 
b/wizards/source/scriptforge/python/scriptforge.py
index 7abd8ff67716..a67dca437fd1 100644
--- a/wizards/source/scriptforge/python/scriptforge.py
+++ b/wizards/source/scriptforge/python/scriptforge.py
@@ -1993,6 +1993,9 @@ class SFDocuments:
         def CreateMenu(self, menuheader, before = '', submenuchar = '>'):
             return self.ExecMethod(self.vbMethod, 'CreateMenu', menuheader, 
before, submenuchar)
 
+        def Echo(self, echoon = True, hourglass = False):
+            return self.ExecMethod(self.vbMethod, 'Echo', echoon, hourglass)
+
         def ExportAsPDF(self, filename, overwrite = False, pages = '', 
password = '', watermark = ''):
             return self.ExecMethod(self.vbMethod, 'ExportAsPDF', filename, 
overwrite, pages, password, watermark)
 
diff --git a/wizards/source/sfdocuments/SF_Calc.xba 
b/wizards/source/sfdocuments/SF_Calc.xba
index bba5ebdf5b2e..dfd66fb5a2bf 100644
--- a/wizards/source/sfdocuments/SF_Calc.xba
+++ b/wizards/source/sfdocuments/SF_Calc.xba
@@ -3718,6 +3718,13 @@ Public Function CreateMenu(Optional ByVal MenuHeader As 
Variant _
        Set CreateMenu = [_Super].CreateMenu(MenuHeader, Before, SubmenuChar)
 End Function   &apos;  SFDocuments.SF_Calc.CreateMenu
 
+REM 
-----------------------------------------------------------------------------
+Public Sub Echo(Optional ByVal EchoOn As Variant _
+                                               , Optional ByVal Hourglass As 
Variant _
+                                               )
+       [_Super].Echo(EchoOn, Hourglass)
+End Sub                   &apos;   SFDocuments.SF_Calc.Echo
+
 REM 
-----------------------------------------------------------------------------
 Public Function ExportAsPDF(Optional ByVal FileName As Variant _
                                                        , Optional ByVal 
Overwrite As Variant _
diff --git a/wizards/source/sfdocuments/SF_Document.xba 
b/wizards/source/sfdocuments/SF_Document.xba
index 03fb215369ea..879d90c0cfef 100644
--- a/wizards/source/sfdocuments/SF_Document.xba
+++ b/wizards/source/sfdocuments/SF_Document.xba
@@ -538,6 +538,78 @@ Catch:
        GoTo Finally
 End Function   &apos;   SFDocuments.SF_Document.CreateMenu
 
+REM 
-----------------------------------------------------------------------------
+Public Sub Echo(Optional ByVal EchoOn As Variant _
+                                               , Optional ByVal Hourglass As 
Variant _
+                                               )
+&apos;&apos;&apos;     While a script is executed any display update resulting 
from that execution
+&apos;&apos;&apos;     is done immediately.
+&apos;&apos;&apos;     For performance reasons it might be an advantage to 
differ the display updates
+&apos;&apos;&apos;     up to the end of the script.
+&apos;&apos;&apos;     This is where pairs of Echo() methods to set and reset 
the removal of the
+&apos;&apos;&apos;     immediate updates may be beneficial.
+&apos;&apos;&apos;     Optionally the actual mouse pointer can be modified to 
the image of an hourglass.
+&apos;&apos;&apos;     Args:
+&apos;&apos;&apos;             EchoOn: when False, the display updates are 
suspended. Default = True.
+&apos;&apos;&apos;                     Multiple calls with EchoOn = False are 
harmless.
+&apos;&apos;&apos;             Hourglass: when True, the mouse pointer is 
changed to an hourglass. Default = False.
+&apos;&apos;&apos;                     The mouse pointer needs to be inside 
the actual document&apos;s window.
+&apos;&apos;&apos;                     Note that it is very likely that at the 
least manual movement of the mouse,
+&apos;&apos;&apos;                     the operating system or the LibreOffice 
process will take back the control
+&apos;&apos;&apos;                     of the mouse icon and its usual 
behaviour.
+&apos;&apos;&apos;     Returns:
+&apos;&apos;&apos;     Examples:
+&apos;&apos;&apos;             oDoc.Echo(False, Hourglass := True)
+&apos;&apos;&apos;             &apos;  ... &quot;long-lasting&quot; script ...
+&apos;&apos;&apos;             oDoc.Echo()                     &apos;  Reset 
to normal
+
+Dim oContainer As Object               &apos;  com.sun.star.awt.XWindow
+Dim lPointer As Long                   &apos;  com.sun.star.awt.SystemPointer 
constant
+Dim oPointer As Object                 &apos;  com.sun.star.awt.Pointer
+Const cstThisSub = &quot;SFDocuments.Document.Echo&quot;
+Const cstSubArgs = &quot;[EchoOn=True], [Hourglass=False]&quot;
+
+       If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
+
+Check:
+       If IsMissing(EchoOn) Or IsEmpty(EchoOn) Then EchoOn = True
+       If IsMissing(Hourglass) Or IsEmpty(Hourglass) Then Hourglass = False
+       If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
+               If Not _IsStillAlive() Then GoTo Finally
+               If Not SF_Utils._Validate(EchoOn, &quot;EchoOn&quot;, 
ScriptForge.V_BOOLEAN) Then GoTo Finally
+               If Not SF_Utils._Validate(Hourglass, &quot;Hourglass&quot;, 
ScriptForge.V_BOOLEAN) Then GoTo Finally
+       End If
+
+Try:
+       With _Component
+
+               Set oContainer = .CurrentController.Frame.GetContainerWindow()
+               Set oPointer = 
CreateUnoService(&quot;com.sun.star.awt.Pointer&quot;)
+               With com.sun.star.awt.SystemPointer
+                       If Hourglass Then lPointer = .WAIT Else lPointer = 
.ARROW
+               End With
+               oPointer.setType(lPointer)
+
+               &apos;  Mouse icon is set when controller is unlocked
+               If Not EchoOn Then
+                       oContainer.setPointer(oPointer)
+                       .lockControllers()
+               Else                    &apos;  EchoOn = True
+                       Do While .hasControllersLocked()
+                               .unlockControllers()
+                       Loop
+                       oContainer.setPointer(oPointer)
+               End If
+
+       End With
+
+Finally:
+       ScriptForge.SF_Utils._ExitFunction(cstThisSub)
+       Exit Sub
+Catch:
+       GoTo Finally    
+End Sub                        &apos;  SFDocuments.SF_Document.Echo
+
 REM 
-----------------------------------------------------------------------------
 Public Function ExportAsPDF(Optional ByVal FileName As Variant _
                                                        , Optional ByVal 
Overwrite As Variant _
@@ -679,6 +751,7 @@ Public Function Methods() As Variant
                                        &quot;Activate&quot; _
                                        , &quot;CloseDocument&quot; _
                                        , &quot;CreateMenu&quot; _
+                                       , &quot;Echo&quot; _
                                        , &quot;ExportAsPDF&quot; _
                                        , &quot;PrintOut&quot; _
                                        , &quot;RemoveMenu&quot; _
diff --git a/wizards/source/sfdocuments/SF_FormDocument.xba 
b/wizards/source/sfdocuments/SF_FormDocument.xba
index 8d13d86e96e4..f0dfa51d6a97 100644
--- a/wizards/source/sfdocuments/SF_FormDocument.xba
+++ b/wizards/source/sfdocuments/SF_FormDocument.xba
@@ -488,6 +488,13 @@ Public Function CreateMenu(Optional ByVal MenuHeader As 
Variant _
        Set CreateMenu = [_Super].CreateMenu(MenuHeader, Before, SubmenuChar)
 End Function   &apos;  SFDocuments.SF_FormDocument.CreateMenu
 
+REM 
-----------------------------------------------------------------------------
+Public Sub Echo(Optional ByVal EchoOn As Variant _
+                                               , Optional ByVal Hourglass As 
Variant _
+                                               )
+       [_Super].Echo(EchoOn, Hourglass)
+End Sub                   &apos;   SFDocuments.SF_FormDocument.Echo
+
 REM 
-----------------------------------------------------------------------------
 Public Function ExportAsPDF(Optional ByVal FileName As Variant _
                                                        , Optional ByVal 
Overwrite As Variant _
diff --git a/wizards/source/sfdocuments/SF_Writer.xba 
b/wizards/source/sfdocuments/SF_Writer.xba
index 6f3f258dcb75..d19b18d5c98f 100644
--- a/wizards/source/sfdocuments/SF_Writer.xba
+++ b/wizards/source/sfdocuments/SF_Writer.xba
@@ -512,6 +512,13 @@ Public Function CreateMenu(Optional ByVal MenuHeader As 
Variant _
        Set CreateMenu = [_Super].CreateMenu(MenuHeader, Before, SubmenuChar)
 End Function   &apos;  SFDocuments.SF_Writer.CreateMenu
 
+REM 
-----------------------------------------------------------------------------
+Public Sub Echo(Optional ByVal EchoOn As Variant _
+                                               , Optional ByVal Hourglass As 
Variant _
+                                               )
+       [_Super].Echo(EchoOn, Hourglass)
+End Sub                   &apos;   SFDocuments.SF_Writer.Echo
+
 REM 
-----------------------------------------------------------------------------
 Public Function ExportAsPDF(Optional ByVal FileName As Variant _
                                                        , Optional ByVal 
Overwrite As Variant _

Reply via email to