From c6813f12e709e0ad6ad727ab0c9205d262fa89fb Mon Sep 17 00:00:00 2001 From: Alain Romedenne Date: Fri, 29 Apr 2022 10:29:33 +0100 Subject: Document SF_Dialog new Resize() and Center() methods Change-Id: I7867cde08f179f6100560f37b6e481238f9fc047 Reviewed-on: https://gerrit.libreoffice.org/c/help/+/133595 Tested-by: Jenkins Reviewed-by: Rafael Lima --- source/text/sbasic/shared/03/lib_ScriptForge.xhp | 3 +- source/text/sbasic/shared/03/sf_dialog.xhp | 84 ++++++++++++++++++++++-- 2 files changed, 81 insertions(+), 6 deletions(-) diff --git a/source/text/sbasic/shared/03/lib_ScriptForge.xhp b/source/text/sbasic/shared/03/lib_ScriptForge.xhp index 8c1dee32a1..4a257e4b1d 100644 --- a/source/text/sbasic/shared/03/lib_ScriptForge.xhp +++ b/source/text/sbasic/shared/03/lib_ScriptForge.xhp @@ -26,8 +26,7 @@ ScriptForge libraries build up an extensible collection of macro scripting resources for %PRODUCTNAME to be invoked from Basic macros or Python scripts.
- • Basic macros require to load ScriptForge library using the following statement:
GlobalScope.BasicLibraries.loadLibrary("ScriptForge")

• Python scripts require an import from scriptforge module:
- from scriptforge import CreateScriptService + • Basic macros require to load ScriptForge library using the following statement:
GlobalScope.BasicLibraries.loadLibrary("ScriptForge")

• Python scripts require an import from scriptforge module:
from scriptforge import CreateScriptService
To learn more about how to create and execute Python scripts using the ScriptForge library, read the help page Creating Python Scripts with ScriptForge. diff --git a/source/text/sbasic/shared/03/sf_dialog.xhp b/source/text/sbasic/shared/03/sf_dialog.xhp index 8499434e77..4d2108b0fd 100644 --- a/source/text/sbasic/shared/03/sf_dialog.xhp +++ b/source/text/sbasic/shared/03/sf_dialog.xhp @@ -382,20 +382,22 @@ Methods - + Activate
+ Center
Controls
EndExecute
Execute
+ GetTextsFromL10N
- GetTextsFromL10N
- Terminate
+ Resize
+ Terminate

@@ -427,6 +429,51 @@ +
+ Center -------------------------------------------------------------------------------------------------------------------------- + + Dialog service;Center + +

Center

+ Centers the current dialog instance in the middle of a parent window. Without arguments, the method centers the dialog in the middle of the current window. + Returns True when successful. + + svc.Center(opt Parent: obj): bool + + Parent: An optional object that can be either … + + + a ScriptForge dialog object + + + a ScriptForge document (Calc, Base, ...) object + + + + + + Sub TriggerEvent(oEvent As Object) + Dim oDialog1 As Object, oDialog2 As Object, lExec As Long + Set oDialog1 = CreateScriptService("DialogEvent", oEvent) ' The dialog that caused the event + Set oDialog2 = CreateScriptService("Dialog", ...) ' Open a second dialog + oDialog2.Center(oDialog1) + lExec = oDialog2.Execute() + Select Case lExec + ... + End Sub + + + + def triggerEvent(event: uno): + dlg1 = CreateScriptService('DialogEvent.Dialog', event) # The dialog having caused the event + dlg2 = CreateScriptService('Dialog', ...) # Open a second dialog + dlg2.Center(dlg1) + rc = dlg2.Execute() + if rc is False: + # ... + +
+
Controls -------------------------------------------------------------------------------------------------------------------------- @@ -568,6 +615,33 @@ Read the L10N service help page to learn more about how PO and POT files are handled.
+
+ Resize -------------------------------------------------------------------------------------------------------------------------- + + Dialog service;Resize + +

Resize

+ Moves the topleft corner of a dialog to new coordinates and/or modify its dimensions. All distances are expressed in 1/100 mm. Without arguments, the method resets the initial dimensions. Return True if the resize was successful. + + svc.Resize(opt Left: num, opt Top: num, opt Width: num, opt Height: num): bool + + Left: the horizontal distance from the top-left corner + Top: the vertical distance from the top-left corner + Width: the width of the rectangle containing the dialog + Height: the height of the rectangle containing the dialog + Negative or missing arguments are left unchanged + + + + oDialog.Resize(1000, 2000, Height := 6000) ' Width is not changed + + + With Python: + + oDialog.Resize(1000, 2000, Height = 6000) # Width is not changed + +
+
Terminate -------------------------------------------------------------------------------------------------------------------------- @@ -580,6 +654,7 @@ Below Basic and Python examples open DlgConsole and dlgTrace non-modal dialogs. They are respectively stored in ScriptForge and Access2Base shared libraries. Dialog close buttons are disabled and explicit termination is performed at the end of a running process. In this example a button in DlgConsole is substituting inhibited window closing: + oDlg = CreateScriptService("SFDialogs.Dialog","GlobalScope","ScriptForge","DlgConsole") oDlg.Execute(modal:=False) @@ -587,7 +662,8 @@ oDlg.Terminate() With Python: - + + from time import sleep dlg = CreateScriptService('SFDialogs.Dialog',"GlobalScope",'Access2Base',"dlgTrace") dlg.Execute(modal=False) -- cgit