Singleton class implementing the
"ScriptForge.SharedMemory"
service. Implemented as a usual Basic module.
Contains the mechanisms to manage persistent memory storage
across Basic and/or Python scripts.
When a script stops running, all the variables it uses vanish,
except Basic Global variables, which stay in memory until
the end of the LibreOffice session.
However event-driven scripting can often benefit from having
variables still being available when the next script is
triggered, probably due to a user action.
The SharedMemory service implements interfaces allowing
to store both BASIC and PYTHON variables in persistent storage,
and to retrieve them later from either BASIC or PYTHON scripts
interchangeably.
The use of the Basic Global statement is more efficient
than the actual service and should be preferred when the variables
are created and retrieved in basic scripts only.
The supported variable types are:
* Scalar or tuple combining:
- int, within the bounds of the Basic Long type
- float, within the bounds of the Basic Double type
- str
- bool
- None
* datetime.datetime
* UNO object
* ScriptForge class instance
Example:
Sub CreateDoc()
ui = CreateScriptService("UI")
doc = ui.CreateDocument("Calc")
store = CreateScriptService("SharedMemory")
store.StoreValue(doc, "actualdocument")
...
def UpdateDoc():
store = CreateScriptService("SharedMemory")
doc = store.ReadValue("actualdocument")
...
The service is available both for Basic and Python scripts.
The actual commit requires the creation of an additional
Help page.
Change-Id: Id53994be5105206c16659f769338261b3dde2d3a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190174
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins