diff options
author | Jean-Pierre Ledure <jp@ledure.be> | 2024-09-06 15:26:17 +0200 |
---|---|---|
committer | Jean-Pierre Ledure <jp@ledure.be> | 2024-09-08 14:25:35 +0200 |
commit | 609a6dc2df2492d75bad2a77b24c588a977d408d (patch) | |
tree | 29298a9fda6b651504184fefb60a7eff2b5945e5 /wizards/source | |
parent | a6a957405e5c9d8639e709916fe7b5bbd472676b (diff) |
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 <jp@ledure.be>
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Diffstat (limited to 'wizards/source')
-rw-r--r-- | wizards/source/scriptforge/python/scriptforge.py | 17 | ||||
-rw-r--r-- | wizards/source/scriptforge/python/scriptforge.pyi | 6 | ||||
-rw-r--r-- | wizards/source/sfdatabases/SF_Datasheet.xba | 12 | ||||
-rw-r--r-- | wizards/source/sfdialogs/SF_Dialog.xba | 13 | ||||
-rw-r--r-- | wizards/source/sfdocuments/SF_Base.xba | 6 | ||||
-rw-r--r-- | wizards/source/sfdocuments/SF_Calc.xba | 6 | ||||
-rw-r--r-- | wizards/source/sfdocuments/SF_Document.xba | 15 | ||||
-rw-r--r-- | wizards/source/sfdocuments/SF_FormDocument.xba | 6 | ||||
-rw-r--r-- | wizards/source/sfdocuments/SF_Writer.xba | 6 |
9 files changed, 74 insertions, 13 deletions
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 @@ -147,6 +147,11 @@ Property Let Filter(Optional ByVal pvFilter As Variant) End Property ' SFDatabases.SF_Datasheet.Filter (let) REM ----------------------------------------------------------------------------- +Property Get IsAlive() As Boolean + IsAlive = _PropertyGet("IsAlive") +End Property ' SFDatabases.SF_Datasheet.IsAlive + +REM ----------------------------------------------------------------------------- Property Get LastRow() As Long ''' Returns the total number of rows ''' The process may imply to move the cursor to the last available row. @@ -579,6 +584,7 @@ Public Function Properties() As Variant , "CurrentRow" _ , "DatabaseFileName" _ , "Filter" _ + , "IsAlive" _ , "LastRow" _ , "OrderBy" _ , "ParentDatabase" _ @@ -835,7 +841,9 @@ Const cstSubArgs = "" 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 <> "IsAlive" Then + If Not _IsStillAlive() Then GoTo Finally + End If Select Case psProperty Case "ColumnHeaders" @@ -848,6 +856,8 @@ Const cstSubArgs = "" _PropertyGet = ScriptForge.SF_FileSystem._ConvertFromUrl(_BaseFileName) Case "Filter" _PropertyGet = _TabControllerModel.Filter + Case "IsAlive" + _PropertyGet = _IsStillAlive(False) Case "LastRow" 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 @@ -254,6 +254,12 @@ Property Let Height(Optional ByVal pvHeight As Variant) End Property ' SFDialogs.SF_Dialog.Height (let) REM ----------------------------------------------------------------------------- +Property Get IsAlive() As Boolean +''' Returns True when the dialog has not been closed by the user + IsAlive = _PropertyGet("IsAlive") +End Property ' SFDocuments.SF_Dialog.IsAlive + +REM ----------------------------------------------------------------------------- Property Get Modal() As Boolean ''' The Modal property specifies if the dialog box has been executed in modal mode Modal = _PropertyGet("Modal") @@ -2256,6 +2262,7 @@ Public Function Properties() As Variant Properties = Array( _ "Caption" _ , "Height" _ + , "IsAlive" _ , "Modal" _ , "Name" _ , "OnFocusGained" _ @@ -2872,7 +2879,9 @@ Const cstSubArgs = "" 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) <> UCase("IsAlive") Then + If Not _IsStillAlive() Then GoTo Finally + End If If IsNull(oSession) Then Set oSession = ScriptForge.SF_Services.CreateScriptService("Session") Select Case UCase(psProperty) @@ -2884,6 +2893,8 @@ Const cstSubArgs = "" Else If oSession.HasUNOProperty(_DialogModel, "Height") Then _PropertyGet = _DialogModel.Height End If + Case UCase("IsAlive") + _PropertyGet = _IsStillAlive(False) Case UCase("Modal") _PropertyGet = _Modal Case UCase("Name") 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( _ "DocumentType" _ , "FileSystem" _ + , "IsAlive" _ , "IsBase" _ , "IsCalc" _ , "IsDraw " _ @@ -831,6 +832,11 @@ Property Get FileSystem() As String End Property ' SFDocuments.SF_Base.FileSystem REM ----------------------------------------------------------------------------- +Property Get IsAlive() As Boolean + IsAlive = [_Super].GetProperty("IsAlive") +End Property ' SFDocuments.SF_Base.IsAlive + +REM ----------------------------------------------------------------------------- Property Get IsBase() As Boolean IsBase = [_Super].GetProperty("IsBase") End Property ' SFDocuments.SF_Base.IsBase 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 , "FirstRow" _ , "Height" _ , "ImportFilters" _ + , "IsAlive" _ , "IsBase" _ , "IsCalc" _ , "IsDraw" _ @@ -3632,6 +3633,11 @@ Property Get ImportFilters() As Variant End Property ' SFDocuments.SF_Calc.ImportFilters REM ----------------------------------------------------------------------------- +Property Get IsAlive() As Boolean + IsAlive = [_Super].GetProperty("IsAlive") +End Property ' SFDocuments.SF_Calc.IsAlive + +REM ----------------------------------------------------------------------------- Property Get IsBase() As Boolean IsBase = [_Super].GetProperty("IsBase") End Property ' SFDocuments.SF_Calc.IsBase 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 @@ -294,6 +294,11 @@ Property Get ImportFilters() As Variant End Property ' SFDocuments.SF_Document.ImportFilters REM ----------------------------------------------------------------------------- +Property Get IsAlive() As Boolean + IsAlive = _PropertyGet("IsAlive") +End Property ' SFDocuments.SF_Document.IsAlive + +REM ----------------------------------------------------------------------------- Property Get IsBase() As Boolean IsBase = _PropertyGet("IsBase") End Property ' SFDocuments.SF_Document.IsBase @@ -997,6 +1002,7 @@ Public Function Properties() As Variant , "ExportFilters" _ , "FileSystem" _ , "ImportFilters" _ + , "IsAlive" _ , "IsBase" _ , "IsCalc" _ , "IsDraw" _ @@ -2152,11 +2158,14 @@ Const cstSubArgs = "" _PropertyGet = False Select Case _DocumentType - Case "Calc" : cstThisSub = "SFDocuments.SF_" & _DocumentType & ".get" & psProperty + Case "Base", "Calc", "FormDocument", "Writer" + cstThisSub = "SFDocuments.SF_" & _DocumentType & ".get" & psProperty Case Else : cstThisSub = "SFDocuments.SF_Document.get" & psProperty End Select ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) - If Not _IsStillAlive() Then GoTo Finally + If psProperty <> "IsAlive" Then + If Not _IsStillAlive() Then GoTo Finally + End If Select Case psProperty Case "CustomProperties" @@ -2181,6 +2190,8 @@ Const cstSubArgs = "" _PropertyGet = oContent.getIdentifier().ContentIdentifier & "/" Case "ImportFilters" _PropertyGet = _GetFilterNames(False) + Case "IsAlive" + _PropertyGet = _IsStillAlive(False, False) Case "IsBase", "IsCalc", "IsDraw", "IsFormDocument", "IsImpress", "IsMath", "IsWriter" _PropertyGet = ( Mid(psProperty, 3) = _DocumentType ) Case "Keywords" 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( _ "DocumentType" _ , "FileSystem" _ + , "IsAlive" _ , "IsBase" _ , "IsCalc" _ , "IsDraw" _ @@ -445,6 +446,11 @@ Property Get FileSystem() As String End Property ' SFDocuments.SF_FormDocument.FileSystem REM ----------------------------------------------------------------------------- +Property Get IsAlive() As Boolean + IsAlive = [_Super].GetProperty("IsAlive") +End Property ' SFDocuments.SF_FormDocument.IsAlive + +REM ----------------------------------------------------------------------------- Property Get IsBase() As Boolean IsBase = [_Super].GetProperty("IsBase") End Property ' SFDocuments.SF_FormDocument.IsBase 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 , "FileSystem" _ , "Frames" _ , "ImportFilters" _ + , "IsAlive" _ , "IsBase" _ , "IsCalc" _ , "IsDraw" _ @@ -558,6 +559,11 @@ Property Get ImportFilters() As Variant End Property ' SFDocuments.SF_Writer.ImportFilters REM ----------------------------------------------------------------------------- +Property Get IsAlive() As Boolean + IsAlive = [_Super].GetProperty("IsAlive") +End Property ' SFDocuments.SF_Writer.IsAlive + +REM ----------------------------------------------------------------------------- Property Get IsBase() As Boolean IsBase = [_Super].GetProperty("IsBase") End Property ' SFDocuments.SF_Writer.IsBase |