wizards/source/scriptforge/python/scriptforge.py  |   17 ++++++++---------
 wizards/source/scriptforge/python/scriptforge.pyi |    6 ++++++
 wizards/source/sfdatabases/SF_Datasheet.xba       |   12 +++++++++++-
 wizards/source/sfdialogs/SF_Dialog.xba            |   13 ++++++++++++-
 wizards/source/sfdocuments/SF_Base.xba            |    6 ++++++
 wizards/source/sfdocuments/SF_Calc.xba            |    6 ++++++
 wizards/source/sfdocuments/SF_Document.xba        |   15 +++++++++++++--
 wizards/source/sfdocuments/SF_FormDocument.xba    |    6 ++++++
 wizards/source/sfdocuments/SF_Writer.xba          |    6 ++++++
 9 files changed, 74 insertions(+), 13 deletions(-)

New commits:
commit 609a6dc2df2492d75bad2a77b24c588a977d408d
Author:     Jean-Pierre Ledure <j...@ledure.be>
AuthorDate: Fri Sep 6 15:26:17 2024 +0200
Commit:     Jean-Pierre Ledure <j...@ledure.be>
CommitDate: Sun Sep 8 14:25:35 2024 +0200

    ScriptForge New IsAlive property
    
    When a document is closed inadvertently
    by the user during a macro run, or between
    two macros triggered by events, the actual
    behaviour is an error message and a stop
    of the execution of the macro.
    
    As this can be counter-productive, the macro
    may test at any moment if everything is ok
    with the
       IsAlive As Boolean (True = OK)
    property applied on next service instances:
       Document
       Base
       Calc
       FormDocument
       Writer
       Datasheet
       Dialog
    
    The functionality is available both for
    Basic and Python user scripts.
    
    The user documentation should be completed
    accordingly.
    
    Change-Id: I0b055dacc06c9da70c611dbb4e7bf841160168fd
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172970
    Reviewed-by: Jean-Pierre Ledure <j...@ledure.be>
    Tested-by: Jean-Pierre Ledure <j...@ledure.be>

diff --git a/wizards/source/scriptforge/python/scriptforge.py 
b/wizards/source/scriptforge/python/scriptforge.py
index e30c36bbb7ae..7c42964a1f0e 100644
--- a/wizards/source/scriptforge/python/scriptforge.py
+++ b/wizards/source/scriptforge/python/scriptforge.py
@@ -1933,7 +1933,7 @@ class SFDatabases:
         servicename = 'SFDatabases.Datasheet'
         servicesynonyms = ('datasheet', 'sfdatabases.datasheet')
         serviceproperties = dict(ColumnHeaders = 0, CurrentColumn = 1, 
CurrentRow = 1,
-                                 DatabaseFileName = 0, Filter = 2, LastRow = 
0, OrderBy = 2,
+                                 DatabaseFileName = 0, Filter = 2, IsAlive = 
1, LastRow = 0, OrderBy = 2,
                                  ParentDatabase = 0, Source = 0, SourceType = 
0, XComponent = 0,
                                  XControlModel = 0, XTabControllerModel = 0)
 
@@ -1991,11 +1991,10 @@ class SFDialogs:
         serviceimplementation = 'basic'
         servicename = 'SFDialogs.Dialog'
         servicesynonyms = ('dialog', 'sfdialogs.dialog')
-        serviceproperties = dict(Caption = 2, Height = 2, Modal = 0, Name = 0,
+        serviceproperties = dict(Caption = 2, Height = 2, IsAlive = 1, Modal = 
0, Name = 0,
                                  OnFocusGained = 2, OnFocusLost = 2, 
OnKeyPressed = 2,
                                  OnKeyReleased = 2, OnMouseDragged = 2, 
OnMouseEntered = 2,
-                                 OnMouseExited = 2, OnMouseMoved = 2, 
OnMousePressed = 2,
-                                 OnMouseReleased = 2,
+                                 OnMouseExited = 2, OnMouseMoved = 2, 
OnMousePressed = 2, OnMouseReleased = 2,
                                  Page = 2, Visible = 2, Width = 2, 
XDialogModel = 0, XDialogView = 0)
         # Class constants used together with the Execute() method
         OKBUTTON, CANCELBUTTON = 1, 0
@@ -2261,7 +2260,7 @@ class SFDocuments:
         servicesynonyms = ('document', 'sfdocuments.document')
         serviceproperties = dict(CustomProperties = 3, Description = 3, 
DocumentProperties = 1,
                                  DocumentType = 0, ExportFilters = 0, 
FileSystem = 0, ImportFilters = 0,
-                                 IsBase = 0, IsCalc = 0, IsDraw = 0, 
IsFormDocument = 0,
+                                 IsAlive = 1, IsBase = 0, IsCalc = 0, IsDraw = 
0, IsFormDocument = 0,
                                  IsImpress = 0, IsMath = 0, IsWriter = 0, 
Keywords = 3, Readonly = 1,
                                  StyleFamilies = 1, Subject = 3, Title = 3, 
XComponent = 0,
                                  XDocumentSettings = 0)
@@ -2356,7 +2355,7 @@ class SFDocuments:
         serviceimplementation = 'basic'
         servicename = 'SFDocuments.Base'
         servicesynonyms = ('base', 'scriptforge.base')
-        serviceproperties = dict(DocumentType = 0, FileSystem = 0, IsBase = 0, 
IsCalc = 0,
+        serviceproperties = dict(DocumentType = 0, FileSystem = 0, IsAlive = 
1, IsBase = 0, IsCalc = 0,
                                  IsDraw = 0, IsFormDocument = 0, IsImpress = 
0, IsMath = 0,
                                  IsWriter = 0, XComponent = 0)
 
@@ -2415,7 +2414,7 @@ class SFDocuments:
         servicesynonyms = ('calc', 'sfdocuments.calc')
         serviceproperties = dict(CurrentSelection = 3, CustomProperties = 3, 
Description = 3,
                                  DocumentProperties = 1, DocumentType = 0, 
ExportFilters = 0,
-                                 FileSystem = 0, ImportFilters = 0, IsBase = 
0, IsCalc = 0,
+                                 FileSystem = 0, ImportFilters = 0, IsAlive = 
1, IsBase = 0, IsCalc = 0,
                                  IsDraw = 0, IsFormDocument = 0, IsImpress = 
0, IsMath = 0,
                                  IsWriter = 0, Keywords = 3, Readonly = 1, 
Sheets = 1,
                                  StyleFamilies = 0, Subject = 3, Title = 3, 
XComponent = 0,
@@ -2773,7 +2772,7 @@ class SFDocuments:
         serviceimplementation = 'basic'
         servicename = 'SFDocuments.FormDocument'
         servicesynonyms = ('formdocument', 'sfdocuments.formdocument')
-        serviceproperties = dict(DocumentType = 0, FileSystem = 0, IsBase = 0, 
IsCalc = 0,
+        serviceproperties = dict(DocumentType = 0, FileSystem = 0, IsAlive = 
1, IsBase = 0, IsCalc = 0,
                                  IsDraw = 0, IsFormDocument = 0, IsImpress = 
0, IsMath = 0,
                                  IsWriter = 0, Readonly = 0, StyleFamilies = 
0, XComponent = 0,
                                  XDocumentSettings = 0)
@@ -2813,7 +2812,7 @@ class SFDocuments:
         servicesynonyms = ('writer', 'sfdocuments.writer')
         serviceproperties = dict(CustomProperties = 3, Description = 3, 
DocumentProperties = 1,
                                  DocumentType = 0, ExportFilters = 0, 
FileSystem = 0, ImportFilters = 0,
-                                 IsBase = 0, IsCalc = 0, IsDraw = 0, 
IsFormDocument = 0,
+                                 IsAlive = 1, IsBase = 0, IsCalc = 0, IsDraw = 
0, IsFormDocument = 0,
                                  IsImpress = 0, IsMath = 0, IsWriter = 0, 
Keywords = 3, Readonly = 1,
                                  StyleFamilies = 1, Subject = 3, Title = 3, 
XComponent = 0,
                                  XDocumentSettings = 0)
diff --git a/wizards/source/scriptforge/python/scriptforge.pyi 
b/wizards/source/scriptforge/python/scriptforge.pyi
index 98ca1e3d78be..0269744e47c2 100644
--- a/wizards/source/scriptforge/python/scriptforge.pyi
+++ b/wizards/source/scriptforge/python/scriptforge.pyi
@@ -3111,6 +3111,8 @@ class SFDatabases:
         Filter: str
         """ Specifies a filter to be applied to the datasheet expressed as the 
``WHERE`` clause of a ``SQL`` query
         without the ``WHERE`` keyword. If an empty string is specified then 
the active Filter is removed. """
+        IsAlive: bool
+        """ Returns True when the datasheet component has not been closed by 
the user.  """
         LastRow: int
         """ Returns the number of rows in the datasheet.    """
         OrderBy: str
@@ -3273,6 +3275,8 @@ class SFDialogs:
         """ Specify the title of the dialog.        """
         Height: int
         """ Specify the height of the dialog.       """
+        IsAlive: bool
+        """ Returns True when the dialog is not terminated due to a user 
intervention.  """
         Modal: bool
         """ Specifies if the dialog box is currently in execution in modal 
mode.    """
         Name: str
@@ -4429,6 +4433,8 @@ class SFDocuments:
         """ Returns a tuple of strings with the import filter names applicable 
to the current document.
         Filters used for both import/export are also returned.
         This property is not applicable to ``Base`` documents. """
+        IsAlive: bool
+        """ Returns True when the document component has not been closed by 
the user.  """
         IsBase: bool
         """ ``True`` when type of document = ``Base``.          """
         IsCalc: bool
diff --git a/wizards/source/sfdatabases/SF_Datasheet.xba 
b/wizards/source/sfdatabases/SF_Datasheet.xba
index 89e66aefd6c6..c505dd45f104 100644
--- a/wizards/source/sfdatabases/SF_Datasheet.xba
+++ b/wizards/source/sfdatabases/SF_Datasheet.xba
@@ -146,6 +146,11 @@ Property Let Filter(Optional ByVal pvFilter As Variant)
        _PropertySet(&quot;Filter&quot;, pvFilter)
 End Property   &apos;  SFDatabases.SF_Datasheet.Filter (let)
 
+REM 
-----------------------------------------------------------------------------
+Property Get IsAlive() As Boolean
+       IsAlive = _PropertyGet(&quot;IsAlive&quot;)
+End Property   &apos;  SFDatabases.SF_Datasheet.IsAlive
+
 REM 
-----------------------------------------------------------------------------
 Property Get LastRow() As Long
 &apos;&apos;&apos;     Returns the total number of rows
@@ -579,6 +584,7 @@ Public Function Properties() As Variant
                                        , &quot;CurrentRow&quot; _
                                        , &quot;DatabaseFileName&quot; _
                                        , &quot;Filter&quot; _
+                                       , &quot;IsAlive&quot; _
                                        , &quot;LastRow&quot; _
                                        , &quot;OrderBy&quot; _
                                        , &quot;ParentDatabase&quot; _
@@ -835,7 +841,9 @@ Const cstSubArgs = &quot;&quot;
        If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
 
        ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs)
-       If Not _IsStillAlive(False) Then GoTo Finally
+       If psProperty &lt;&gt; &quot;IsAlive&quot; Then
+               If Not _IsStillAlive() Then GoTo Finally
+       End If
 
        Select Case psProperty
                Case &quot;ColumnHeaders&quot;
@@ -848,6 +856,8 @@ Const cstSubArgs = &quot;&quot;
                        _PropertyGet = 
ScriptForge.SF_FileSystem._ConvertFromUrl(_BaseFileName)
                Case &quot;Filter&quot;
                        _PropertyGet = _TabControllerModel.Filter
+               Case &quot;IsAlive&quot;
+                       _PropertyGet = _IsStillAlive(False)
                Case &quot;LastRow&quot;
                        With _TabControllerModel
                                If .IsRowCountFinal Then
diff --git a/wizards/source/sfdialogs/SF_Dialog.xba 
b/wizards/source/sfdialogs/SF_Dialog.xba
index f044a86db05b..c204d44e1114 100644
--- a/wizards/source/sfdialogs/SF_Dialog.xba
+++ b/wizards/source/sfdialogs/SF_Dialog.xba
@@ -253,6 +253,12 @@ Property Let Height(Optional ByVal pvHeight As Variant)
        _PropertySet(&quot;Height&quot;, pvHeight)
 End Property   &apos;  SFDialogs.SF_Dialog.Height (let)
 
+REM 
-----------------------------------------------------------------------------
+Property Get IsAlive() As Boolean
+&apos;&apos;&apos;     Returns True when the dialog has not been closed by the 
user
+       IsAlive = _PropertyGet(&quot;IsAlive&quot;)
+End Property   &apos;  SFDocuments.SF_Dialog.IsAlive
+
 REM 
-----------------------------------------------------------------------------
 Property Get Modal() As Boolean
 &apos;&apos;&apos;     The Modal property specifies if the dialog box has been 
executed in modal mode
@@ -2256,6 +2262,7 @@ Public Function Properties() As Variant
        Properties = Array( _
                                        &quot;Caption&quot; _
                                        , &quot;Height&quot; _
+                                       , &quot;IsAlive&quot; _
                                        , &quot;Modal&quot; _
                                        , &quot;Name&quot; _
                                        , &quot;OnFocusGained&quot; _
@@ -2872,7 +2879,9 @@ Const cstSubArgs = &quot;&quot;
        If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
 
        ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs)
-       If Not _IsStillAlive() Then GoTo Finally
+       If UCase(psProperty) &lt;&gt; UCase(&quot;IsAlive&quot;) Then
+               If Not _IsStillAlive() Then GoTo Finally
+       End If
 
        If IsNull(oSession) Then Set oSession = 
ScriptForge.SF_Services.CreateScriptService(&quot;Session&quot;)
        Select Case UCase(psProperty)
@@ -2884,6 +2893,8 @@ Const cstSubArgs = &quot;&quot;
                        Else
                                If oSession.HasUNOProperty(_DialogModel, 
&quot;Height&quot;) Then _PropertyGet = _DialogModel.Height
                        End If                  
+               Case UCase(&quot;IsAlive&quot;)
+                       _PropertyGet = _IsStillAlive(False)
                Case UCase(&quot;Modal&quot;)
                        _PropertyGet = _Modal
                Case UCase(&quot;Name&quot;)
diff --git a/wizards/source/sfdocuments/SF_Base.xba 
b/wizards/source/sfdocuments/SF_Base.xba
index 30713e88b587..5c0feaec5c63 100644
--- a/wizards/source/sfdocuments/SF_Base.xba
+++ b/wizards/source/sfdocuments/SF_Base.xba
@@ -687,6 +687,7 @@ Public Function Properties() As Variant
        Properties = Array( _
                                        &quot;DocumentType&quot; _
                                        , &quot;FileSystem&quot; _
+                                       , &quot;IsAlive&quot; _
                                        , &quot;IsBase&quot; _
                                        , &quot;IsCalc&quot; _
                                        , &quot;IsDraw &quot; _
@@ -830,6 +831,11 @@ Property Get FileSystem() As String
        FileSystem = [_Super].GetProperty(&quot;FileSystem&quot;)
 End Property   &apos;  SFDocuments.SF_Base.FileSystem
 
+REM 
-----------------------------------------------------------------------------
+Property Get IsAlive() As Boolean
+       IsAlive = [_Super].GetProperty(&quot;IsAlive&quot;)
+End Property   &apos;  SFDocuments.SF_Base.IsAlive
+
 REM 
-----------------------------------------------------------------------------
 Property Get IsBase() As Boolean
        IsBase = [_Super].GetProperty(&quot;IsBase&quot;)
diff --git a/wizards/source/sfdocuments/SF_Calc.xba 
b/wizards/source/sfdocuments/SF_Calc.xba
index b917b36a85fa..f7d1eebae18c 100644
--- a/wizards/source/sfdocuments/SF_Calc.xba
+++ b/wizards/source/sfdocuments/SF_Calc.xba
@@ -2557,6 +2557,7 @@ Public Function Properties() As Variant
                                        , &quot;FirstRow&quot; _
                                        , &quot;Height&quot; _
                                        , &quot;ImportFilters&quot; _
+                                       , &quot;IsAlive&quot; _
                                        , &quot;IsBase&quot; _
                                        , &quot;IsCalc&quot; _
                                        , &quot;IsDraw&quot; _
@@ -3631,6 +3632,11 @@ Property Get ImportFilters() As Variant
        ImportFilters = [_Super].GetProperty(&quot;ImportFilters&quot;)
 End Property   &apos;  SFDocuments.SF_Calc.ImportFilters
 
+REM 
-----------------------------------------------------------------------------
+Property Get IsAlive() As Boolean
+       IsAlive = [_Super].GetProperty(&quot;IsAlive&quot;)
+End Property   &apos;  SFDocuments.SF_Calc.IsAlive
+
 REM 
-----------------------------------------------------------------------------
 Property Get IsBase() As Boolean
        IsBase = [_Super].GetProperty(&quot;IsBase&quot;)
diff --git a/wizards/source/sfdocuments/SF_Document.xba 
b/wizards/source/sfdocuments/SF_Document.xba
index 2b80dd4cb5d6..d839538879d6 100644
--- a/wizards/source/sfdocuments/SF_Document.xba
+++ b/wizards/source/sfdocuments/SF_Document.xba
@@ -293,6 +293,11 @@ Property Get ImportFilters() As Variant
        ImportFilters = _PropertyGet(&quot;ImportFilters&quot;)
 End Property   &apos;  SFDocuments.SF_Document.ImportFilters
 
+REM 
-----------------------------------------------------------------------------
+Property Get IsAlive() As Boolean
+       IsAlive = _PropertyGet(&quot;IsAlive&quot;)
+End Property   &apos;  SFDocuments.SF_Document.IsAlive
+
 REM 
-----------------------------------------------------------------------------
 Property Get IsBase() As Boolean
        IsBase = _PropertyGet(&quot;IsBase&quot;)
@@ -997,6 +1002,7 @@ Public Function Properties() As Variant
                                        , &quot;ExportFilters&quot; _
                                        , &quot;FileSystem&quot; _
                                        , &quot;ImportFilters&quot; _
+                                       , &quot;IsAlive&quot; _
                                        , &quot;IsBase&quot; _
                                        , &quot;IsCalc&quot; _
                                        , &quot;IsDraw&quot; _
@@ -2152,11 +2158,14 @@ Const cstSubArgs = &quot;&quot;
        _PropertyGet = False
 
        Select Case _DocumentType
-               Case &quot;Calc&quot;           :       cstThisSub = 
&quot;SFDocuments.SF_&quot; &amp; _DocumentType &amp; &quot;.get&quot; &amp; 
psProperty
+               Case &quot;Base&quot;, &quot;Calc&quot;, 
&quot;FormDocument&quot;, &quot;Writer&quot;
+                       cstThisSub = &quot;SFDocuments.SF_&quot; &amp; 
_DocumentType &amp; &quot;.get&quot; &amp; psProperty
                Case Else               :       cstThisSub = 
&quot;SFDocuments.SF_Document.get&quot; &amp; psProperty
        End Select
        ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs)
-       If Not _IsStillAlive() Then GoTo Finally
+       If psProperty &lt;&gt; &quot;IsAlive&quot; Then
+               If Not _IsStillAlive() Then GoTo Finally
+       End If
 
        Select Case psProperty
                Case &quot;CustomProperties&quot;
@@ -2181,6 +2190,8 @@ Const cstSubArgs = &quot;&quot;
                        _PropertyGet = 
oContent.getIdentifier().ContentIdentifier &amp; &quot;/&quot;
                Case &quot;ImportFilters&quot;
                        _PropertyGet = _GetFilterNames(False)
+               Case &quot;IsAlive&quot;
+                       _PropertyGet = _IsStillAlive(False, False)
                Case &quot;IsBase&quot;, &quot;IsCalc&quot;, 
&quot;IsDraw&quot;, &quot;IsFormDocument&quot;, &quot;IsImpress&quot;, 
&quot;IsMath&quot;, &quot;IsWriter&quot;
                        _PropertyGet = ( Mid(psProperty, 3) = _DocumentType )
                Case &quot;Keywords&quot;
diff --git a/wizards/source/sfdocuments/SF_FormDocument.xba 
b/wizards/source/sfdocuments/SF_FormDocument.xba
index f187bb85441b..6f055ff359ef 100644
--- a/wizards/source/sfdocuments/SF_FormDocument.xba
+++ b/wizards/source/sfdocuments/SF_FormDocument.xba
@@ -423,6 +423,7 @@ Public Function Properties() As Variant
        Properties = Array( _
                                        &quot;DocumentType&quot; _
                                        , &quot;FileSystem&quot; _
+                                       , &quot;IsAlive&quot; _
                                        , &quot;IsBase&quot; _
                                        , &quot;IsCalc&quot; _
                                        , &quot;IsDraw&quot; _
@@ -444,6 +445,11 @@ Property Get FileSystem() As String
        FileSystem = [_Super].GetProperty(&quot;FileSystem&quot;)
 End Property   &apos;  SFDocuments.SF_FormDocument.FileSystem
 
+REM 
-----------------------------------------------------------------------------
+Property Get IsAlive() As Boolean
+       IsAlive = [_Super].GetProperty(&quot;IsAlive&quot;)
+End Property   &apos;  SFDocuments.SF_FormDocument.IsAlive
+
 REM 
-----------------------------------------------------------------------------
 Property Get IsBase() As Boolean
        IsBase = [_Super].GetProperty(&quot;IsBase&quot;)
diff --git a/wizards/source/sfdocuments/SF_Writer.xba 
b/wizards/source/sfdocuments/SF_Writer.xba
index 5be6e37cf06a..38767666300e 100644
--- a/wizards/source/sfdocuments/SF_Writer.xba
+++ b/wizards/source/sfdocuments/SF_Writer.xba
@@ -444,6 +444,7 @@ Public Function Properties() As Variant
                                        , &quot;FileSystem&quot; _
                                        , &quot;Frames&quot; _
                                        , &quot;ImportFilters&quot; _
+                                       , &quot;IsAlive&quot; _
                                        , &quot;IsBase&quot; _
                                        , &quot;IsCalc&quot; _
                                        , &quot;IsDraw&quot; _
@@ -557,6 +558,11 @@ Property Get ImportFilters() As Variant
        ImportFilters = [_Super].GetProperty(&quot;ImportFilters&quot;)
 End Property   &apos;  SFDocuments.SF_Writer.ImportFilters
 
+REM 
-----------------------------------------------------------------------------
+Property Get IsAlive() As Boolean
+       IsAlive = [_Super].GetProperty(&quot;IsAlive&quot;)
+End Property   &apos;  SFDocuments.SF_Writer.IsAlive
+
 REM 
-----------------------------------------------------------------------------
 Property Get IsBase() As Boolean
        IsBase = [_Super].GetProperty(&quot;IsBase&quot;)

Reply via email to