Class MacroScript
- class ooodev.macro.script.MacroScript[source]
Class for call macro
See also
New in version 0.40.0.
- __init__()
- classmethod call(*, name: str)[source]
- classmethod call(**kwargs)
- classmethod call(**kwargs)
Call any macro
- Parameters:
name (str) – Macro Name.
library (str, optional) – Macro Library. Defaults to
Standard
.language (str, optional) – Language
Basic
orPython
. Defaults toBasic
.location (str, optional) – Location
user
,application
ordocument
. Defaults to “user”.module (str, optional) – Module portion. Only Applies if
language` is not ``Basic
orPython
. Defaults to “.”.in_thread (bool, optional) – If execute in thread. Defaults to
False
.args (tuple, optional) – Arguments passed to script when invoking. Defaults to ().
kwargs (Any) –
- Returns:
The return value of the script.
- Return type:
Any
Example
The
MacroScript.call()
method:>>> def r_trim(input: str, remove: str = " ") -> str: ... res = MacroScript.call( ... name="RTrimStr", ... library="Tools", ... language="Basic", ... module="Strings", ... args=(input, remove), ... ) ... return res >>> result = r_trim("hello ") >>> assert result == "hello"
- classmethod call_url(url, *args, in_thread=False)[source]
Call macro by url
- Parameters:
args (tuple) – Arguments passed to script when invoking.
url (str) – The URL of the script to be invoked.
in_thread (bool, optional) – If execute in thread. Defaults to
False
.
- Returns:
The return value of the script.
- Return type:
Any
- static get_script(script_url)[source]
Grab Basic script object before invocation.
- Parameters:
script_url (str) – The URL of the script to be invoked.
- Returns:
Basic script object.
- Return type:
XScript
- classmethod get_url_script(*, name: str)[source]
- classmethod get_url_script(**kwargs)
- classmethod get_url_script(**kwargs)
Get uno command or url for macro
- Parameters:
name (str) – Macro Name.
library (str, optional) – Macro Library. Defaults to
Standard
.language (str, optional) – Language
Basic
orPython
. Defaults toBasic
.location (str, optional) – Location
user
,application
ordocument
. Defaults to “user”.module (str, optional) – Module portion. Only Applies if
language` is not ``Basic
orPython
. Defaults to “.”.kwargs (Any) –
- Returns:
Macro Url such as
vnd.sun.star.script:myLibrary.myModule.myMacro?language=Basic&location=application
.- Return type:
str