From 414be5f0b520740158392e93835ed910e09100b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?LibreO=EF=AC=83ciant?= Date: Wed, 12 Jun 2019 09:37:48 +0200 Subject: [PATCH] Some examples of Basic macros Change-Id: I20f0693dfb1e965f50be875565d505021bcb9d4a Reviewed-on: https://gerrit.libreoffice.org/73861 Tested-by: Jenkins Tested-by: Olivier Hallot Reviewed-by: Olivier Hallot --- source/text/sbasic/guide/basic_examples.xhp | 12 +++- source/text/sbasic/guide/sample_code.xhp | 65 ++++++++++++--------- source/text/sbasic/guide/show_dialog.xhp | 5 +- 3 files changed, 49 insertions(+), 33 deletions(-) diff --git a/source/text/sbasic/guide/basic_examples.xhp b/source/text/sbasic/guide/basic_examples.xhp index 7b398d1020..888903b39e 100644 --- a/source/text/sbasic/guide/basic_examples.xhp +++ b/source/text/sbasic/guide/basic_examples.xhp @@ -8,7 +8,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. * --> - Basic Programming Examples @@ -22,7 +21,16 @@

Basic Programming Examples

- + + + + + + +
diff --git a/source/text/sbasic/guide/sample_code.xhp b/source/text/sbasic/guide/sample_code.xhp index cc3ab51d84..7ef8b6a450 100644 --- a/source/text/sbasic/guide/sample_code.xhp +++ b/source/text/sbasic/guide/sample_code.xhp @@ -1,6 +1,4 @@ - - - - - -Programming Examples for Controls in the Dialog Editor -/text/sbasic/guide/sample_code.xhp - - -Sun Microsystems, Inc. - - + + + Programming Examples for Controls in the Dialog Editor + /text/sbasic/guide/sample_code.xhp + + + Sun Microsystems, Inc. + + -programming examples for controls -dialogs;loading (example) -dialogs;displaying (example) -controls;reading or editing properties (example) -list boxes;removing entries from (example) -list boxes;adding entries to (example) -examples; programming controls -dialog editor;programming examples for controls + programming examples for controls + dialogs;loading (example) + dialogs;displaying (example) + controls;reading or editing properties (example) + list boxes;removing entries from (example) + list boxes;adding entries to (example) + examples; programming controls + dialog editor;programming examples for controls + Tools;LoadDialog
Programming Examples for Controls in the Dialog Editor @@ -48,7 +46,7 @@ Global Function for Loading Dialogs Function LoadDialog(Libname as String, DialogName as String, Optional oLibContainer) -Dim oLib as Object +Dim oLib as Object ' com.sun.star.script.XLibraryContainer Dim oLibDialog as Object Dim oRuntimeDialog as Object If IsMissing(oLibContainer) Then @@ -61,21 +59,26 @@ LoadDialog() = oRuntimeDialog End Function +LoadDialog function is stored in Tools.ModuleControls available from %PRODUCTNAME Macros and Dialogs. Displaying a Dialog REM global definition of variables Dim oDialog1 AS Object Sub StartDialog1 - BasicLibraries.LoadLibrary("Tools") - oDialog1 = LoadDialog("Standard", "Dialog1") + With GlobalScope.BasicLibraries + If Not .IsLibraryLoaded("Tools") Then .LoadLibrary("Tools") + End With + oDialog1 = Tools.ModuleControls.LoadDialog("Standard", "Dialog1") oDialog1.Execute() End Sub Read or Edit Properties of Controls in the Program Sub Sample1 - BasicLibraries.LoadLibrary("Tools") - oDialog1 = LoadDialog("Standard", "Dialog1") + With GlobalScope.Basiclibraries + If Not .IsLibraryLoaded("Tools") Then .LoadLibrary("Tools") + End With + oDialog1 = Tools.LoadDialog("Standard", "Dialog1") REM get dialog model oDialog1Model = oDialog1.Model REM display text of Label1 @@ -101,8 +104,10 @@ Add an Entry to a ListBox Sub AddEntry - BasicLibraries.LoadLibrary("Tools") - oDialog1 = LoadDialog("Standard", "Dialog1") + With GlobalScope.Basiclibraries + If Not .IsLibraryLoaded("Tools") Then .LoadLibrary("Tools") + End With + oDialog1 = ModuleControls.LoadDialog("Standard", "Dialog1") REM adds a new entry to the ListBox oDialog1Model = oDialog1.Model oListBox = oDialog1.GetControl("ListBox1") @@ -114,8 +119,10 @@ Remove an Entry from a ListBox Sub RemoveEntry - BasicLibraries.LoadLibrary("Tools") - oDialog1 = LoadDialog("Standard", "Dialog1") + With GlobalScope.Basiclibraries + If Not .IsLibraryLoaded("Tools") Then .LoadLibrary("Tools") + End With + oDialog1 = Tools.ModuleControls.LoadDialogLoadDialog("Standard", "Dialog1") REM remove the first entry from the ListBox oDialog1Model = oDialog1.Model oListBox = oDialog1.GetControl("ListBox1") diff --git a/source/text/sbasic/guide/show_dialog.xhp b/source/text/sbasic/guide/show_dialog.xhp index f59a481b00..117ff796c2 100644 --- a/source/text/sbasic/guide/show_dialog.xhp +++ b/source/text/sbasic/guide/show_dialog.xhp @@ -29,13 +29,14 @@ dialogs;using Basic to show (example) examples; showing a dialog with Basic Tools;LoadDialog -Opening a Dialog With Program Code + +Opening a Dialog With Basic In the %PRODUCTNAME BASIC window for a dialog that you created, leave the dialog editor by clicking the name tab of the Module that the dialog is assigned to. The name tab is at the bottom of the window. Enter the following code for a subroutine called Dialog1Show. In this example, the name of the dialog that you created is "Dialog1": Sub Dialog1Show - With GlobalScope.Basiclibraries + With GlobalScope.BasicLibraries If Not .IsLibraryLoaded("Tools") Then .LoadLibrary("Tools") End With oDialog1 = Tools.ModuleControls.LoadDialog("Standard", "Dialog1")