[Libreoffice-commits] core.git: wizards/source

Jean-Pierre Ledure (via logerrit) logerrit at kemper.freedesktop.org
Sat Jun 19 08:02:57 UTC 2021


 wizards/source/scriptforge/SF_UI.xba |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

New commits:
commit 6de7707236ea918d94f321587cb1a728a42e0892
Author:     Jean-Pierre Ledure <jp at ledure.be>
AuthorDate: Fri Jun 18 12:48:17 2021 +0200
Commit:     Jean-Pierre Ledure <jp at ledure.be>
CommitDate: Sat Jun 19 10:02:19 2021 +0200

    ScriptForge - (SF_UI) GetDocument() accepts component object
    
    SF_UI.GetDocument() has 1 argument.
    Before, must be a string designating an open window
    Now, also a UNO object of types
       com.sun.star.lang.XComponent or
       com.sun.star.comp.dba.ODatabaseDocument
    
    Typical usage: pass ThisComponent or ThisDatabaseDocument
    as argument to create a new SFDocuments.Document/Base/Calc service.
    
    Change-Id: Id9e0a40425dc3ce5e83953af5da4fb7ef8dd6f63
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117442
    Tested-by: Jean-Pierre Ledure <jp at ledure.be>
    Reviewed-by: Jean-Pierre Ledure <jp at ledure.be>

diff --git a/wizards/source/scriptforge/SF_UI.xba b/wizards/source/scriptforge/SF_UI.xba
index 9b98053a85c9..122dd218da93 100644
--- a/wizards/source/scriptforge/SF_UI.xba
+++ b/wizards/source/scriptforge/SF_UI.xba
@@ -402,12 +402,14 @@ REM ----------------------------------------------------------------------------
 Public Function GetDocument(Optional ByVal WindowName As Variant) As Variant
 ''' Returns a SFDocuments.Document object referring to the active window or the given window
 '''	Args:
-'''		WindowName: see definitions. If absent the active window is considered
+'''		WindowName:	when a string, see definitions. If absent the active window is considered.
+'''					when an object, must be a UNO object of types
+'''					   com.sun.star.lang.XComponent or com.sun.star.comp.dba.ODatabaseDocument
 '''	Exceptions:
 '''		DOCUMENTERROR		The targeted window could not be found
 '''	Examples:
 '''		Dim oDoc As Object
-'''			Set oDoc = ui.GetDocument
+'''			Set oDoc = ui.GetDocument	'	or Set oDoc = ui.GetDcument(ThisComponent)
 '''			oDoc.Save()
 
 Dim oDocument As Object			'	Return value
@@ -420,7 +422,10 @@ Const cstSubArgs = "[WindowName]"
 Check:
 	If IsMissing(WindowName) Or IsEmpty(WindowName) Then WindowName = ""
 	If SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
+		If Not SF_Utils._Validate(WindowName, "WindowName", Array(V_STRING, V_OBJECT)) Then GoTo Finally
+		If VarType(WindowName) = V_STRING Then
 			If Not SF_Utils._ValidateFile(WindowName, "WindowName", , True) Then GoTo Finally
+		End If
 	End If
 
 Try:


More information about the Libreoffice-commits mailing list