diff --git a/source/text/sbasic/shared/03/sf_services.xhp b/source/text/sbasic/shared/03/sf_services.xhp new file mode 100644 index 0000000000..3dc040187c --- /dev/null +++ b/source/text/sbasic/shared/03/sf_services.xhp @@ -0,0 +1,264 @@ + + + + + + + ScriptForge.Services service + /text/sbasic/shared/03/sf_services.xhp + + + +
+ + Services service + + +

ScriptForge.Services service

+ + + The ScriptForge library is built upon an extensible collection of so-called "Services". +
This collection is implemented as categories of Basic libraries or Python modules: +
+ + + the standard ScriptForge library shipped with %PRODUCTNAME + + + a number of "associated" libraries shipped with %PRODUCTNAME as well + + + any user/contributor LibreOffice extension wanting to fit into the same framework + + +
+ +A service is a collection of properties or methods which implement the service. +For the author of a user script, a service may be either a module within a library, or an instance of a class module. +An event manager is a script contained in a library which binds an event triggering a macro - usually defined by the Tools - Customize menu - to the concerned service instance. +As an example, if several documents trigger the same macro when they are loaded, it might be useful to know which document triggered the macro this time. That's where an event manager plays its role. + +The following methods make up the kernel of the ScriptForge framework: + + + RegisterScriptServices + Called internally by ScriptForge to register for a library the list of services it implements. +
Each library associated to Scriptforge or extending it must implement its own RegisterScriptServices method.
+
+ + RegisterService + Called - as many times as there are services to register in the library - by RegisterScriptServices. + + + RegisterEventManager + Called to register a library event manager by RegisterScriptServices. + + + CreateScriptService + Called by user scripts to get an object giving access to the service given as argument. +
All services should be invoked thru the CreateScriptService method.
+
+
+Conventionally, the String, Array and Exception services may be invoked directly respectively as SF_String, SF_Array and SF_Exception. + + + + List of Methods in the Services Service + + + + + CreateScriptService + + + + + RegisterScriptServices
+ RegisterService +
+
+ + + RegisterEventManager + + +
+
+ +
+ CreateScriptService -------------------------------------------------------------------------------------------------------------------------- + + Services service;CreateScriptService + +

CreateScriptService

+ + Gain access to one of the services of a library for the benefit of a user script. +
The returned value is a Basic object or Nothing if an error occurred. +
+ + A service can be understood as either: + + + + as a set of methods gathered in a Basic standard module + + + or a set of methods and properties gathered in a Basic class module. + + +

+ + CreateScriptService(Service As String, [arg0, ...] As Variant) As Variant + +

+ Service: The name of the service identified as "library.service". +
The library is a Basic library that must exist in the GlobalScope. The default value is "ScriptForge". +
The service is one of the services registered by the library via the RegisterScriptServices() method.
+ arg0, ...: A list of arguments required by the invoked service. +
If the first argument refers to an event manager, then arg0 is mandatory and must be the UNO object representing the event provided as argument to the user macro.
+

+ + GlobalScope.BasicLibraries.loadLibrary("ScriptForge") + ' To be done once + Dim svc As Object + Set svc = CreateScriptService("Array") + ' Refers to the "ScriptForge.Array" service or SF_Array + Set svc = CreateScriptService("ScriptForge.Dictionary") + ' Returns a new empty dictionary class instance; "ScriptForge." is optional + Set svc = CreateScriptService("SFDocuments.Calc") + ' Refers to the Calc service, implemented in the associated SFDocuments library + Set svc = CreateScriptService("Timer", True) + ' Returns a Timer class instance starting immediately + Set svc = CreateScriptService("SFDocuments.DocumentEvent", oEvent) + ' Refers to the DocumentEvent service implemented in the associated SFDocuments library + ' Returns the instance of the Document class that fired the event + +
+ +
+ RegisterScriptServices ------------------------------------------------------------------------------------------------------------------------ + + Services service;RegisterScriptServices + +

RegisterScriptServices

+ + By executing a series of invocations of RegisterService() and RegisterEventManager(), the RegisterScriptServices() method incorporates a library into the ScriptForge framework. +
Each library pertaining to the framework must implement its own version of this method. +
+ The method has to be stored in a standard Basic module as opposed to a class module. + A service is either: +
+ + + a Basic standard module passed as a Basic object. + + + or a string designating the function to execute to get an instance of the service. It is in fact the function containing the New keyword of a Set statement creating the instance. + + + + GlobalScope.LibraryName.ModuleName ' Object + "LibraryName.ModuleName.FunctionName" ' String + +
+

+ + Public Sub RegisterScriptServices() + ' To be stored in library = myLibrary + With GlobalScope.ScriptForge.SF_Services + .RegisterService("myService1", GlobalScope.myLibrary.myModule) + ' Refer to a Basic standard module implementing the service as a set of methods + .RegisterService("myService2", "myLibrary.someModule.someFunction") + ' The function should return an instance of a Basic object class implementing the service + ' ... + End With + End Sub + + When a user script contains a statement such as: + Set myServ = CreateScriptService("myLibrary.myService1") +
ScriptForge performs these tasks:
+ + + load the library myLibrary when necessary + + + invoke the RegisterScriptServices method to load the list of services of myLibrary in memory + + + initialize the variable myServ with the given service + + +
+ +
+ RegisterService ------------------------------------------------------------------------------------------------------------------------ + + Services service;RegisterService + +

RegisterService

+ + The method returns True if the name-value pair given as argument could be registered successfully. + +

+ + GlobalScope.ScriptForge.SF_Services.RegisterService(ServiceName As String, ServiceReference As Variant) As Boolean + +

+ ServiceName: The name of the service as a case-insensitive string. The name must be unique. + ServiceReference: A service reference is either: + +

+ + With GlobalScope.ScriptForge.SF_Services + .RegisterService("myService1", GlobalScope.myLibrary.myModule) + ' Refer to a Basic standard module implementing the service as a set of methods + .RegisterService("myService2", "myLibrary.someModule.someFunction") + ' The function should return an instance of a Basic object class implementing the service + ' ... + End With + +
+ +
+ RegisterEventManager ------------------------------------------------------------------------------------------------------------------------ + + Services service;RegisterEventManager + +

RegisterEventManager

+ + The method returns True if the name-value pair given as argument could be registered successfully. + +

+ + GlobalScope.ScriptForge.SF_Services.RegisterEventManager(ServiceName As String, ServiceReference As String) As Boolean + +

+ ServiceName: The name of the service as a case-insensitive string. The name must be unique. + ServiceReference: A string designating the function to execute to get an instance of the service. It is in fact the function containing the New keyword of a Set statement creating the instance.: + "LibraryName.ModuleName.FunctionName" ' String +

+ + With GlobalScope.ScriptForge.SF_Services + .RegisterEventManager("myEventMgr", "myLibrary.someModule.someFunction") + ' The function should return an instance of a Basic object class implementing the service + ' ... + End With + +
+ + + +
+ + +
+ + +
\ No newline at end of file diff --git a/source/text/sbasic/shared/03/sf_session.xhp b/source/text/sbasic/shared/03/sf_session.xhp index 8c9aae2f03..e9a32de584 100644 --- a/source/text/sbasic/shared/03/sf_session.xhp +++ b/source/text/sbasic/shared/03/sf_session.xhp @@ -227,7 +227,7 @@ ' Xray returns no value - +
ExecuteCalcFunction -------------------------------------------------------------------------------------------------------------------------- @@ -235,13 +235,13 @@

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.
+
If the arguments are arrays, the function is executed as an array formula.

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

- CalcFunction: The english name of the function to execute. + 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.

@@ -251,7 +251,7 @@ ' Generates an error.
- +
ExecutePythonScript -------------------------------------------------------------------------------------------------------------------------- @@ -280,7 +280,7 @@ session.ExecutePythonScript(session.SCRIPTISSHARED, "Capitalise.py$getNewString", "Abc") ' "abc"
- +
HasUnoMethod -------------------------------------------------------------------------------------------------------------------------- @@ -302,7 +302,7 @@ MsgBox session.HasUnoMethod(a, "callFunction")
- +
HasUnoProperty -------------------------------------------------------------------------------------------------------------------------- @@ -319,12 +319,12 @@ PropertyName: the property as a case-sensitive string

- Dim a As Variant - a = CreateUnoService("com.sun.star.sheet.FunctionAccess") - MsgBox session.HasUnoProperty(a, "Wildcards") + Dim svc As Variant + svc = CreateUnoService("com.sun.star.sheet.FunctionAccess") + MsgBox session.HasUnoProperty(svc, "Wildcards")
- +
OpenURLInBrowser -------------------------------------------------------------------------------------------------------------------------- @@ -343,7 +343,7 @@ session.OpenURLInBrowser("https://docs.python.org/3/library/webbrowser.html")
- +
RunApplication -------------------------------------------------------------------------------------------------------------------------- @@ -365,7 +365,7 @@ session.RunApplication("kate", "/home/me/install.txt") ' GNU/Linux
- +
SendMail -------------------------------------------------------------------------------------------------------------------------- @@ -393,7 +393,7 @@ )
- +
UnoMethods -------------------------------------------------------------------------------------------------------------------------- @@ -414,7 +414,7 @@ MsgBox SF_Array.Contains(session.UnoMethods(a), "callFunction")
- +
UnoProperties -------------------------------------------------------------------------------------------------------------------------- @@ -430,12 +430,12 @@ UnoObject: The object to inspect.

- Dim a As Variant - a = CreateUnoService("com.sun.star.sheet.FunctionAccess") - MsgBox SF_Array.Contains(session.UnoProperties(a), "Wildcards") + Dim svc As Variant + svc = CreateUnoService("com.sun.star.sheet.FunctionAccess") + MsgBox SF_Array.Contains(session.UnoProperties(svc), "Wildcards")
- +
UnoObjectType -------------------------------------------------------------------------------------------------------------------------- @@ -451,11 +451,11 @@ 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" + Dim svc As Variant, txt As String + svc = CreateUnoService("com.sun.star.system.SystemShellExecute") + txt = session.UnoObjectType(svc) ' "com.sun.star.comp.system.SystemShellExecute" + svc = CreateUnoStruct("com.sun.star.beans.Property") + txt = session.UnoObjectType(svc) ' "com.sun.star.beans.Property"
@@ -482,8 +482,10 @@
- + + +
diff --git a/source/text/sbasic/shared/03103700.xhp b/source/text/sbasic/shared/03103700.xhp index dbbfa1cb3f..8203a58d51 100644 --- a/source/text/sbasic/shared/03103700.xhp +++ b/source/text/sbasic/shared/03103700.xhp @@ -35,39 +35,39 @@ -Set Statement +

Set Statement

Sets an object reference on a variable. -Syntax: + Set Statement diagram -[Set] variable = [New] object + [Set] variable = [New] object -Parameters: + variable: a variable or a property that requires an object reference. expression: A computable combination of terms such as a formula or an object property or method. object: Object that the variable refers to. Nothing - Assign Nothing to a variable to remove a previous assignment. Set keyword is optional. Nothing is the default value for objects. -Example: + -Sub ExampleSet - Dim obj As Object - Set obj = ThisComponent - Print obj.Title - - obj = New com.sun.star.beans.PropertyValue - With obj - .Name = "key" : .Value = 594.34 - Print .Name, .Value - End With -End Sub +Sub ExampleSet + Dim obj As Object + Set obj = ThisComponent + Print obj.Title + + obj = New com.sun.star.beans.PropertyValue + With obj + .Name = "key" : .Value = 594.34 + Print .Name, .Value + End With +End Sub New creates UNO objects or class module objects, before assigning it to a variable. - + \ No newline at end of file diff --git a/source/text/sbasic/shared/03104200.xhp b/source/text/sbasic/shared/03104200.xhp index 4657343f22..056478400a 100644 --- a/source/text/sbasic/shared/03104200.xhp +++ b/source/text/sbasic/shared/03104200.xhp @@ -32,18 +32,18 @@
Array function -Array Function +

Array Function

Returns the type Variant with a data field.
-Syntax: + Array ( Argument list) See also DimArray -Parameters: + Argument list: A list of any number of arguments that are separated by commas. -Example: + Dim A As Variant A = Array("Fred","Tom","Bill") diff --git a/source/text/sbasic/shared/03131900.xhp b/source/text/sbasic/shared/03131900.xhp index a91107a43d..faf6abd276 100644 --- a/source/text/sbasic/shared/03131900.xhp +++ b/source/text/sbasic/shared/03131900.xhp @@ -39,7 +39,7 @@ BasicLibraries; library container DialogLibraries; library container -

GlobalScope specifier

+

GlobalScope specifier

To manage personal or shared library containers (%PRODUCTNAME Macros or My Macros) from within a document, use the GlobalScope specifier.