summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Pierre Ledure <jp@ledure.be>2021-06-18 12:48:17 +0200
committerJean-Pierre Ledure <jp@ledure.be>2021-06-19 10:02:19 +0200
commit6de7707236ea918d94f321587cb1a728a42e0892 (patch)
treec6fffb5cff2b7f753d17baa3db28c12954be699c
parentd32a9f90e85a5cfa9ffd629494de3c291282454e (diff)
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@ledure.be> Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
-rw-r--r--wizards/source/scriptforge/SF_UI.xba9
1 files changed, 7 insertions, 2 deletions
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
&apos;&apos;&apos; Returns a SFDocuments.Document object referring to the active window or the given window
&apos;&apos;&apos; Args:
-&apos;&apos;&apos; WindowName: see definitions. If absent the active window is considered
+&apos;&apos;&apos; WindowName: when a string, see definitions. If absent the active window is considered.
+&apos;&apos;&apos; when an object, must be a UNO object of types
+&apos;&apos;&apos; com.sun.star.lang.XComponent or com.sun.star.comp.dba.ODatabaseDocument
&apos;&apos;&apos; Exceptions:
&apos;&apos;&apos; DOCUMENTERROR The targeted window could not be found
&apos;&apos;&apos; Examples:
&apos;&apos;&apos; Dim oDoc As Object
-&apos;&apos;&apos; Set oDoc = ui.GetDocument
+&apos;&apos;&apos; Set oDoc = ui.GetDocument &apos; or Set oDoc = ui.GetDcument(ThisComponent)
&apos;&apos;&apos; oDoc.Save()
Dim oDocument As Object &apos; Return value
@@ -420,7 +422,10 @@ Const cstSubArgs = &quot;[WindowName]&quot;
Check:
If IsMissing(WindowName) Or IsEmpty(WindowName) Then WindowName = &quot;&quot;
If SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
+ If Not SF_Utils._Validate(WindowName, &quot;WindowName&quot;, Array(V_STRING, V_OBJECT)) Then GoTo Finally
+ If VarType(WindowName) = V_STRING Then
If Not SF_Utils._ValidateFile(WindowName, &quot;WindowName&quot;, , True) Then GoTo Finally
+ End If
End If
Try: