From e3fe4a46104d9379bca3302fd9ed3883915f2d80 Mon Sep 17 00:00:00 2001 From: Jean-Pierre Ledure Date: Sun, 20 Dec 2020 14:23:34 +0100 Subject: ScriptForge - new CloseFormDocument() method Only when form instance is inside a Base form document Change-Id: I6fd0cf1d77588b9720efb2c45384371a122dbd4d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108048 Tested-by: Jean-Pierre Ledure Tested-by: Jenkins Reviewed-by: Jean-Pierre Ledure --- wizards/source/sfdocuments/SF_Form.xba | 40 ++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'wizards') diff --git a/wizards/source/sfdocuments/SF_Form.xba b/wizards/source/sfdocuments/SF_Form.xba index ca4be09e56df..a6c4a074d0b9 100644 --- a/wizards/source/sfdocuments/SF_Form.xba +++ b/wizards/source/sfdocuments/SF_Form.xba @@ -257,6 +257,46 @@ Catch: GoTo Finally End Function ' SFDocuments.SF_Form.Activate +REM ----------------------------------------------------------------------------- +Public Function CloseFormDocument() As Boolean +''' Close the form document containing the actual form instance +''' The form instance is disposed +''' The method does nothong if the actual form is not located in a Base form document +''' Args: +''' Returns: +''' True if closure is successful +''' Example: +''' myForm.CloseFormDocument() + +Dim bClose As Boolean ' Return value +Dim oContainer As Object ' com.sun.star.awt.XWindow +Const cstThisSub = "SFDocuments.Form.CloseFormDocument" +Const cstSubArgs = "" + + If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch + bClose = False + +Check: + If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then + If Not _IsStillAlive() Then GoTo Finally + End If +Try: + Select Case _FormType + Case ISDOCFORM, ISCALCFORM, ISSUBFORM + Case ISBASEFORM + _MainForm.close() + Dispose() + bClose = True + End Select + +Finally: + CloseFormDocument = bClose + ScriptForge.SF_Utils._ExitFunction(cstThisSub) + Exit Function +Catch: + GoTo Finally +End Function ' SFDocuments.SF_Form.CloseFormDocument + REM ----------------------------------------------------------------------------- Public Function Controls(Optional ByVal ControlName As Variant) As Variant ''' Return either -- cgit