From d5eb6397f3b58d19d442c85aa4243ace4914bb59 Mon Sep 17 00:00:00 2001 From: Alain Romedenne Date: Wed, 10 Feb 2021 15:01:28 +0100 Subject: sf_session new help page - extra bookmark & link in sf_array - typo in py2bas - typo in sf-string Change-Id: I508722de9b4cb1e55e203ba97b470b28f1ba03ae Reviewed-on: https://gerrit.libreoffice.org/c/help/+/110678 Tested-by: Jenkins Reviewed-by: Alain Romedenne --- AllLangHelp_sbasic.mk | 1 + source/text/sbasic/python/python_2_basic.xhp | 2 +- source/text/sbasic/shared/03/lib_ScriptForge.xhp | 2 +- source/text/sbasic/shared/03/sf_array.xhp | 8 +- source/text/sbasic/shared/03/sf_session.xhp | 490 +++++++++++++++++++++++ source/text/sbasic/shared/03/sf_string.xhp | 2 +- 6 files changed, 500 insertions(+), 5 deletions(-) create mode 100644 source/text/sbasic/shared/03/sf_session.xhp diff --git a/AllLangHelp_sbasic.mk b/AllLangHelp_sbasic.mk index 3db5bbb4da..d87b5eb2b2 100644 --- a/AllLangHelp_sbasic.mk +++ b/AllLangHelp_sbasic.mk @@ -85,6 +85,7 @@ $(eval $(call gb_AllLangHelp_add_helpfiles,sbasic,\ helpcontent2/source/text/sbasic/shared/03/sf_exception \ helpcontent2/source/text/sbasic/shared/03/sf_ui \ helpcontent2/source/text/sbasic/shared/03/sf_document \ + helpcontent2/source/text/sbasic/shared/03/sf_session \ helpcontent2/source/text/sbasic/shared/03/sf_string \ helpcontent2/source/text/sbasic/shared/03/sf_timer \ helpcontent2/source/text/sbasic/shared/03/lib_schedule \ diff --git a/source/text/sbasic/python/python_2_basic.xhp b/source/text/sbasic/python/python_2_basic.xhp index b9978122cc..5cd5308c02 100644 --- a/source/text/sbasic/python/python_2_basic.xhp +++ b/source/text/sbasic/python/python_2_basic.xhp @@ -27,7 +27,7 @@ Xray calls interrupting Python script execution to help inspect variables.
- The %PRODUCTNAME Application Programming Interface (API) Scripting Framework supports inter-language script execution between Python and Basic, or other supported programming languages for that matter. Arguments can be passed back and fourth across calls, providing they represent primitives data types that both languages recognize, and assuming that the Scripting Framework converts them appropriately. + The %PRODUCTNAME Application Programming Interface (API) Scripting Framework supports inter-language script execution between Python and Basic, or other supported programming languages for that matter. Arguments can be passed back and fourth across calls, provided that they represent primitive data types that both languages recognize, and assuming that the Scripting Framework converts them appropriately.
It is recommended to have knowledge of Python standard modules and %PRODUCTNAME API features prior to perform inter-language calls from Python to Basic, JavaScript or any other script engine. diff --git a/source/text/sbasic/shared/03/lib_ScriptForge.xhp b/source/text/sbasic/shared/03/lib_ScriptForge.xhp index 21fefe9fdf..c8f1912659 100644 --- a/source/text/sbasic/shared/03/lib_ScriptForge.xhp +++ b/source/text/sbasic/shared/03/lib_ScriptForge.xhp @@ -85,7 +85,7 @@ L10n class Service Platform Service Services class Service - Session Service + TextStream class Service diff --git a/source/text/sbasic/shared/03/sf_array.xhp b/source/text/sbasic/shared/03/sf_array.xhp index c4df6ba66c..d4b65fb016 100644 --- a/source/text/sbasic/shared/03/sf_array.xhp +++ b/source/text/sbasic/shared/03/sf_array.xhp @@ -17,6 +17,10 @@
+ + Array service + +

ScriptForge.Array service

Provides a collection of methods for manipulating and transforming arrays of one dimension (vectors) and arrays of two dimensions (matrices). This includes set operations, sorting, importing to and exporting from text files. Arrays with more than two dimensions cannot be used with the methods in this service, the only exception being the CountDims method that accepts Arrays with any number of dimensions. @@ -197,7 +201,7 @@ Array service;ConvertToDictionary

ConvertToDictionary

- Store the content of a 2-columns array into a ScriptForge Dictionary object. + Store the content of a 2-columns array into a ScriptForge.Dictionary object.
The key will be extracted from the first column, the item from the second.

@@ -904,7 +908,7 @@
- +
diff --git a/source/text/sbasic/shared/03/sf_session.xhp b/source/text/sbasic/shared/03/sf_session.xhp new file mode 100644 index 0000000000..8c9aae2f03 --- /dev/null +++ b/source/text/sbasic/shared/03/sf_session.xhp @@ -0,0 +1,490 @@ + + + + + + + ScriptForge.Session service + /text/sbasic/shared/03/sf_session.xhp + + + + +
+ + Session service + + +

ScriptForge.Session service

+ + The Session service gathers various general purpose methods about: + + + the installation or execution environment + + + UNO introspection + + ** for 7.x ** clipboard management + + the invocation of external scripts or programs + + +
+ +

Service invocation

+ + + GlobalScope.BasicLibraries.loadLibrary("ScriptForge") + Dim session As Variant + session = CreateScriptService("Session") + + +

Constants

+ Below is a list of constants available to ease the designation of the library containing a Basic or Python script to invoke. +
Use them as session.CONSTANT.
+ + + + CONSTANT + + + Value + + + Where to find the library ? + + + Applicable + + + + + SCRIPTISEMBEDDED + + + "document" + + + in the document + + + Basic + Python + + + + + SCRIPTISAPPLICATION + + + "application" + + + in any shared library + + + Basic + + + + + SCRIPTISPERSONAL + + + "user" + + + in My Macros + + + Python + + + + + SCRIPTISPERSOXT + + + "user:uno_packages" + + + in an extension installed for the current user + + + Python + + + + + SCRIPTISSHARED + + + "share" + + + in %PRODUCTNAME macros + + + Python + + + + + SCRIPTISSHAROXT + + + "share:uno_packages" + + + in an extension installed for all users + + + Python + + + + + SCRIPTISOXT + + + "uno_packages" + + + in an extension but the installation parameters are unknown + + + Python + + +
+ + + + List of Methods in the Session Service + + + + + ExecuteBasicScript
+ ExecuteCalcFunction
+ ExecutePythonScript
+ HasUnoMethod +
+
+ + + HasUnoProperty
+ OpenURLInBrowser
+ RunApplication
+ SendMail +
+
+ + + UnoMethods
+ UnoProperties
+ UnoObjectType
+ WebService +
+
+
+
+ + Session service methods behave as follows: +
Arguments are passed by value. Updates performed by the called function are not sent back to the calling script. +
A single value or an array of values is returned to the calling script. +
+ +
+ ExecuteBasicScript -------------------------------------------------------------------------------------------------------------------------- + + Session service;ExecuteBasicScript + +

ExecuteBasicScript

+ Execute the Basic script given its name and location and fetch its result if any. + If the script is not found, or if it returns nothing, the returned value is Empty. +

+ + session.ExecuteBasicScript([Scope As String], Script As String[, arg0 As Variant, ...]) As Variant + +

+ Scope: "document" or "application" or one of the applicable session.CONSTANTS. + Script: "library.module.method" as a case-sensitive string. +
The library is loaded in memory if necessary. +
The module must not be a class module. +
The method may be a Sub or a Function.
+ arg0, ...: The arguments to provide to the called script. +

+ + session.ExecuteBasicScript(, "XrayTool._Main.Xray", CreateUnoService("com.sun.star.util.TextSearch")) + ' Xray returns no value + +
+ +
+ ExecuteCalcFunction -------------------------------------------------------------------------------------------------------------------------- + + Session service;ExecuteCalcFunction + +

ExecuteCalcFunction

+ Execute a Calc function using its English name and based on the given arguments. +
If the arguments are arrays, the function is executed as an array function.
+

+ + session.ExecuteCalcFunction(CalcFunction As String, arg0, ...) As Variant + +

+ CalcFunction: The english name of the function to execute. + arg0, ...: The arguments to provide to the called Calc function. Each argument must be either a string, a numeric value or an array of arrays combining those types. +

+ + session.ExecuteCalcFunction("AVERAGE", 1, 5, 3, 7) ' 4 + session.ExecuteCalcFunction("ABS", Array(Array(-1,2,3),Array(4,-5,6),Array(7,8,-9)))(2)(2) ' 9 + session.ExecuteCalcFunction("LN", -3) + ' Generates an error. + +
+ +
+ ExecutePythonScript -------------------------------------------------------------------------------------------------------------------------- + + Session service;ExecutePythonScript + +

ExecutePythonScript

+ Execute the Python script given its location and name, fetch its result if any. Result can be a single value or an array of values. + If the script is not found, or if it returns nothing, the returned value is Empty. + +

+ + session.ExecutePythonScript([Scope] As String, Script As String[, arg0 As Variant, ...]) As Variant + +

+ Scope: One of the applicable session.CONSTANTS. Default = session.SCRIPTISSHARED. + Script: Either "library/module.py$method" or "module.py$method" or "myExtension.oxt|myScript|module.py$method" as a case-sensitive string. + + library: The folder path to the Python module. + myScript: The folder containing the Python module. + module.py: The Python module. + method: The Python function. + + arg0, ...: The arguments to provide to the called script. +

+ + session.ExecutePythonScript(session.SCRIPTISSHARED, "Capitalise.py$getNewString", "Abc") ' "abc" + +
+ +
+ HasUnoMethod -------------------------------------------------------------------------------------------------------------------------- + + Session service;HasUnoMethod + +

HasUnoMethod

+ Returns True if an UNO object contains the given method. Returns False when the method is not found or when an argument is invalid. +

+ + session.HasUnoMethod(UnoObject As Object, MethodName As String) As Boolean + +

+ UnoObject: The object to inspect. + MethodName: the method as a case-sensitive string +

+ + Dim a As Variant + a = CreateUnoService("com.sun.star.sheet.FunctionAccess") + MsgBox session.HasUnoMethod(a, "callFunction") + +
+ +
+ HasUnoProperty -------------------------------------------------------------------------------------------------------------------------- + + Session service;HasUnoProperty + +

HasUnoProperty

+ Returns True if a UNO object has the given property. Returns False when the property is not found or when an argument is invalid. +

+ + session.HasUnoProperty(UnoObject As Object, PropertyName As String) As Boolean + +

+ UnoObject: The object to inspect. + PropertyName: the property as a case-sensitive string +

+ + Dim a As Variant + a = CreateUnoService("com.sun.star.sheet.FunctionAccess") + MsgBox session.HasUnoProperty(a, "Wildcards") + +
+ +
+ OpenURLInBrowser -------------------------------------------------------------------------------------------------------------------------- + + Session service;OpenURLInBrowser + +

OpenURLInBrowser

+ Open a Uniform Resource Locator (URL) in the default browser. +

+ + session.OpenURLInBrowser(URL As String) + +

+ URL: The URL to open. +

+ + session.OpenURLInBrowser("https://docs.python.org/3/library/webbrowser.html") + +
+ +
+ RunApplication -------------------------------------------------------------------------------------------------------------------------- + + Session service;RunApplication + +

RunApplication

+ Executes an arbitrary system command and returns True if it was launched successfully. +

+ + session.RunApplication(Command As String, Parameters As String) As Boolean + +

+ Command: The command to execute. This may be an executable file or a document which is registered with an application so that the system knows what application to launch for that document. The command must be expressed in the current SF_FileSystem.FileNaming notation. + Parameters: A list of space separated parameters as a single string. The method does not validate the given parameters, but only passes them to the specified command. +

+ + session.RunApplication("Notepad.exe") + session.RunApplication("C:\myFolder\myDocument.odt") + session.RunApplication("kate", "/home/me/install.txt") ' GNU/Linux + +
+ +
+ SendMail -------------------------------------------------------------------------------------------------------------------------- + + Session service;SendMail + +

SendMail

+ Send a message - with optional attachments - to recipients from the user's mail client. The message may be edited by the user before sending or, alternatively, be sent immediately. +

+ + session.SendMail(Recipient As String, [Cc As String], [Bcc As String], [Subject As String], [Body As String], [FileNames As String], [EditMessage As Boolean]) + +

+ Recipient: An email address (the "To" recipient). + Cc: A comma-separated list of email addresses (the "carbon copy" recipients). + Bcc: A comma-separated list of email addresses (the "blind carbon copy" recipients). + Subject: the header of the message. + Body: The content of the message as an unformatted text. + FileNames: a comma-separated list of file names. Each file name must respect the SF_FileSystem.FileNaming notation. + EditMessage: When True (default), the message is edited before being sent. +

+ + session.SendMail("a@example.com" _ + , Cc := "b@other.fr, c@other.be" _ + , FileNames := "C:\myFile1.txt, C:\myFile2.txt" _ + ) + +
+ +
+ UnoMethods -------------------------------------------------------------------------------------------------------------------------- + + Session service;UnoMethods + +

UnoMethods

+ Returns a list of the methods callable from an UNO object. The list is a zero-based array of strings and may be empty. +

+ + session.UnoMethods(UnoObject As Object) As Variant + +

+ UnoObject: The object to inspect. +

+ + Dim a As Variant + a = CreateUnoService("com.sun.star.sheet.FunctionAccess") + MsgBox SF_Array.Contains(session.UnoMethods(a), "callFunction") + +
+ +
+ UnoProperties -------------------------------------------------------------------------------------------------------------------------- + + Session service;UnoProperties + +

UnoProperties

+ Returns a list of the properties of an UNO object. The list is a zero-based array of strings and may be empty. +

+ + session.UnoProperties(UnoObject As Object) As Variant + +

+ UnoObject: The object to inspect. +

+ + Dim a As Variant + a = CreateUnoService("com.sun.star.sheet.FunctionAccess") + MsgBox SF_Array.Contains(session.UnoProperties(a), "Wildcards") + +
+ +
+ UnoObjectType -------------------------------------------------------------------------------------------------------------------------- + + Session service;UnoObjectType + +

UnoObjectType

+ Identify the type of a UNO object as a string. +

+ + session.UnoObjectType(UnoObject As Object) As String + +

+ UnoObject: The object to identify. +

+ + Dim a As Variant, s As String + a = CreateUnoService("com.sun.star.system.SystemShellExecute") + s = session.UnoObjectType(a) ' "com.sun.star.comp.system.SystemShellExecute" + a = CreateUnoStruct("com.sun.star.beans.Property") + s = session.UnoObjectType(a) ' "com.sun.star.beans.Property" + +
+ +
+ WebService -------------------------------------------------------------------------------------------------------------------------- + + Session service;WebService + +

WebService

+ Get some web content from a URI. +

+ + session.WebService(URI As String) As String + +

+ URI: URI text of the web service. +

+ + session.WebService("wiki.documentfoundation.org/api.php?" _ + & "hidebots=1&days=7&limit=50&action=feedrecentchanges&feedformat=rss") + +
+ + + +
+ + +
+ + +
diff --git a/source/text/sbasic/shared/03/sf_string.xhp b/source/text/sbasic/shared/03/sf_string.xhp index c48a3bdf90..7ed1dc643f 100644 --- a/source/text/sbasic/shared/03/sf_string.xhp +++ b/source/text/sbasic/shared/03/sf_string.xhp @@ -24,7 +24,7 @@
-

ScriptForge.String service

+

ScriptForge.String service

The String service provides a collection of methods for string processing. These methods can be used to: -- cgit