[Libreoffice-commits] core.git: wizards/source
Jean-Pierre Ledure (via logerrit)
logerrit at kemper.freedesktop.org
Sun Dec 20 09:43:02 UTC 2020
wizards/source/sfdocuments/SF_Base.xba | 68 ++++++++++++++++++++++++++---
wizards/source/sfdocuments/SF_Calc.xba | 4 -
wizards/source/sfdocuments/SF_Document.xba | 6 +-
wizards/source/sfdocuments/SF_Form.xba | 2
4 files changed, 69 insertions(+), 11 deletions(-)
New commits:
commit 3bec3349e9898ee69645a88bbd0b722222a8dfa8
Author: Jean-Pierre Ledure <jp at ledure.be>
AuthorDate: Sat Dec 19 15:12:10 2020 +0100
Commit: Jean-Pierre Ledure <jp at ledure.be>
CommitDate: Sun Dec 20 10:42:17 2020 +0100
ScriptForge - (SF_Base) new OpenFormDocument() method
OpenFormDocument has 2 arguments
- the form document hierarchical name
- the mode: normal or design
If the form document is already open, the focus is set on it
Change-Id: I6fb055cde2e856d7dad17af99b11bc2fd15060c2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108023
Tested-by: Jean-Pierre Ledure <jp at ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp at ledure.be>
diff --git a/wizards/source/sfdocuments/SF_Base.xba b/wizards/source/sfdocuments/SF_Base.xba
index d0900849255f..92101c6f41d8 100644
--- a/wizards/source/sfdocuments/SF_Base.xba
+++ b/wizards/source/sfdocuments/SF_Base.xba
@@ -349,9 +349,9 @@ Public Function IsLoaded(Optional ByVal FormDocument As Variant) As Boolean
''' Args:
''' FormDocument: a valid document form name as a case-sensitive string
''' Returns:
-''' True if the form document is currently open, otherise False
+''' True if the form document is currently open, otherwise False
''' Exceptions:
-''' Form is invalid
+''' Form name is invalid
''' Example:
''' MsgBox oDoc.IsLoaded("Folder1/myFormDocument")
@@ -374,7 +374,6 @@ Check:
End If
Try:
-
Set oMainForm = _FormDocuments.getByHierarchicalName(FormDocument)
' A document form that has never been opened has no component
' If ever opened and closed afterwards, it keeps the Component but loses its Controller
@@ -391,7 +390,7 @@ End Function ' SFDocuments.SF_Base.IsLoaded
REM -----------------------------------------------------------------------------
Public Function Methods() As Variant
-''' Return the list of public methods of the Model service as an array
+''' Return the list of public methods of the Base class as an array
Methods = Array( _
"Activate" _
@@ -407,9 +406,68 @@ Public Function Methods() As Variant
End Function ' SFDocuments.SF_Base.Methods
+REM -----------------------------------------------------------------------------
+Public Function OpenFormDocument(Optional ByVal FormDocument As Variant _
+ , Optional ByVal DesignMode As Variant _
+ ) As Boolean
+''' Open the FormDocument given by its hierarchical name either in normal or in design mode
+''' If the form document is already open, the form document is made active without changing its mode
+''' Args:
+''' FormDocument: a valid document form name as a case-sensitive string
+''' DesignMode: when True the form document is opened in design mode (Default = False)
+''' Returns:
+''' True if the form document could be opened, otherwise False
+''' Exceptions:
+''' Form name is invalid
+''' Example:
+''' oDoc.OpenFormDocument("Folder1/myFormDocument")
+
+Dim bOpen As Boolean ' Return value
+Dim vFormNames As Variant ' Array of all document form names present in the document
+Dim oContainer As Object ' com.sun.star.awt.XWindow
+Const cstThisSub = "SFDocuments.Base.OpenFormDocument"
+Const cstSubArgs = "FormDocument, [DesignMode=False]"
+
+ If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
+ bOpen = False
+
+Check:
+ If IsMissing(DesignMode) Or IsEmpty(DesignMode) Then DesignMode = False
+ If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
+ If Not _IsStillAlive() Then GoTo Finally
+ ' Build list of available FormDocuments recursively with _CollectFormDocuments
+ If IsNull(_FormDocuments) Then Set _FormDocuments = _Component.getFormDocuments()
+ vFormNames = Split(_CollectFormDocuments(_FormDocuments), cstToken)
+ If Not ScriptForge.SF_Utils._Validate(FormDocument, "FormDocument", V_STRING, vFormNames) Then GoTo Finally
+ If Not ScriptForge.SF_Utils._Validate(DesignMode, "DesignMode", ScriptForge.V_BOOLEAN) Then GoTo Finally
+ End If
+
+Try:
+ If IsLoaded(FormDocument) Then ' Activate
+ Set oContainer = _FormDocuments.getByHierarchicalName(FormDocument).Component.CurrentController.Frame.ContainerWindow
+ With oContainer
+ If .isVisible() = False Then .setVisible(True)
+ .IsMinimized = False
+ .setFocus()
+ .toFront() ' Force window change in Linux
+ Wait 1 ' Bypass desynchro issue in Linux
+ End With
+ Else ' Open
+ _Component.CurrentController.loadComponent(com.sun.star.sdb.application.DatabaseObject.FORM, FormDocument, DesignMode)
+ bOpen = True
+ End If
+
+Finally:
+ OpenFormDocument = bOpen
+ ScriptForge.SF_Utils._ExitFunction(cstThisSub)
+ Exit Function
+Catch:
+ GoTo Finally
+End Function ' SFDocuments.SF_Base.OpenFormDocument
+
REM -----------------------------------------------------------------------------
Public Function Properties() As Variant
-''' Return the list or properties of the Timer class as an array
+''' Return the list or properties of the Base class as an array
Properties = Array( _
"DocumentType" _
diff --git a/wizards/source/sfdocuments/SF_Calc.xba b/wizards/source/sfdocuments/SF_Calc.xba
index aeb19ffed9c7..48f35fed98f0 100644
--- a/wizards/source/sfdocuments/SF_Calc.xba
+++ b/wizards/source/sfdocuments/SF_Calc.xba
@@ -1329,7 +1329,7 @@ End Function ' SFDocuments.SF_Calc.InsertSheet
REM -----------------------------------------------------------------------------
Public Function Methods() As Variant
-''' Return the list of public methods of the Model service as an array
+''' Return the list of public methods of the Calc service as an array
Methods = Array( _
"Activate" _
@@ -1548,7 +1548,7 @@ End Function ' SF_Documents.SF_Calc.Offset
REM -----------------------------------------------------------------------------
Public Function Properties() As Variant
-''' Return the list or properties of the Timer class as an array
+''' Return the list or properties of the Calc class as an array
Properties = Array( _
"CurrentSelection" _
diff --git a/wizards/source/sfdocuments/SF_Document.xba b/wizards/source/sfdocuments/SF_Document.xba
index 227638e99efa..d7dc14e5e9ed 100644
--- a/wizards/source/sfdocuments/SF_Document.xba
+++ b/wizards/source/sfdocuments/SF_Document.xba
@@ -570,7 +570,7 @@ End Function ' SFDocuments.SF_Document.GetProperty
REM -----------------------------------------------------------------------------
Public Function Methods() As Variant
-''' Return the list of public methods of the Model service as an array
+''' Return the list of public methods of the Document service as an array
Methods = Array( _
"Activate" _
@@ -585,7 +585,7 @@ End Function ' SFDocuments.SF_Document.Methods
REM -----------------------------------------------------------------------------
Public Function Properties() As Variant
-''' Return the list or properties of the Timer class as an array
+''' Return the list or properties of the Document class as an array
Properties = Array( _
"CustomProperties" _
@@ -594,7 +594,7 @@ Public Function Properties() As Variant
, "DocumentType" _
, "IsBase" _
, "IsCalc" _
- , "IsDraw " _
+ , "IsDraw" _
, "IsImpress" _
, "IsMath" _
, "IsWriter" _
diff --git a/wizards/source/sfdocuments/SF_Form.xba b/wizards/source/sfdocuments/SF_Form.xba
index 0b9303fae9b6..ee905e729581 100644
--- a/wizards/source/sfdocuments/SF_Form.xba
+++ b/wizards/source/sfdocuments/SF_Form.xba
@@ -416,7 +416,7 @@ End Function ' SFDocuments.SF_Form.GetProperty
REM -----------------------------------------------------------------------------
Public Function Methods() As Variant
-''' Return the list of public methods of the Model service as an array
+''' Return the list of public methods of the Form service as an array
Methods = Array( _
"Activate" _
More information about the Libreoffice-commits
mailing list