wizards/source/scriptforge/SF_SharedMemory.xba | 18 +++++++++--------- wizards/source/scriptforge/python/scriptforge.py | 10 +++++----- wizards/source/scriptforge/python/scriptforge.pyi | 6 +++--- wizards/source/scriptforge/script.xlb | 18 +++++++++--------- 4 files changed, 26 insertions(+), 26 deletions(-)
New commits: commit d8c75e9bda28bdba67148931a0d4c102446d89ce Author: Jean-Pierre Ledure <j...@ledure.be> AuthorDate: Mon Sep 15 17:27:33 2025 +0200 Commit: Jean-Pierre Ledure <j...@ledure.be> CommitDate: Wed Sep 17 16:44:26 2025 +0200 ScriptForge (Sharedmemory) review StoreValue() signature Thanks to commit https://gerrit.libreoffice.org/c/core/+/190931 (Extend Python-Basic gateway for objects) a signature with an object instance as argument is allowed in any position, i.o. the 1st only. This is applicable to sharedmemory.StoreValue(value, variablename) Indeed, 'value' may be such an object instance. The signature becomes now sharedmemory.StoreValue(variablename, value) which is more intuitive. No impact on user scripts <= 25.8 Documentation should take both commits into account. Change-Id: I1a07cd740fc9dcba1077932bba0f69735a7bc647 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190979 Tested-by: Jenkins Reviewed-by: Jean-Pierre Ledure <j...@ledure.be> diff --git a/wizards/source/scriptforge/SF_SharedMemory.xba b/wizards/source/scriptforge/SF_SharedMemory.xba index f16a323f0d60..3c079aeebea8 100644 --- a/wizards/source/scriptforge/SF_SharedMemory.xba +++ b/wizards/source/scriptforge/SF_SharedMemory.xba @@ -188,10 +188,10 @@ Public Function ReadValue(Optional ByVal VariableName As Variant) As Variant ''' Example: ''' memory = CreateScriptService("SharedMemory") ''' doc = CreateScriptService("Document", ThisComponent) -''' memory.StoreValue(doc, "ActualDoc") +''' memory.StoreValue("ActualDoc", doc) ''' ... ' The script might be stopped ''' doc2 = memory.ReadValue("ActualDoc") -''' If doc2.IsAlive Then ' Check that the document has not be closed by the user +''' If doc2.IsAlive Then ' Check that the document has not been closed by the user ''' ... Dim vRead As Variant ' Return value @@ -229,7 +229,7 @@ Public Function Remove(Optional ByVal VariableName As Variant) As Boolean ''' Args: ''' VariableName: the case-sensitive name to remove. ''' Returns: -''' A scalar or an array of scalars. +''' True when successful. ''' If VariableName does not exist, an error is generated. ''' Example: ''' memory = CreateScriptService("SharedMemory") @@ -334,13 +334,14 @@ Catch: End Function ' ScriptForge.SF_SharedMemory.SetProperty REM ----------------------------------------------------------------------------- -Public Function StoreValue(Optional ByVal Value As Variant _ - , Optional ByVal VariableName As Variant _ +Public Function StoreValue(Optional ByVal VariableName As Variant _ + , Optional ByVal Value As Variant _ ) As Boolean ''' Store in the shared and persistent storage area the given value. ''' Later retrieval will be done thanks to the given variable name. ''' If the given name already exists, its value is replaced without warning. ''' Args: +''' VariableName: the case-sensitive name to retrieve the Value when needed. ''' Value: the value to be stored. ''' The supported variable types are: ''' * Scalar or 1D-array/tuple combining : @@ -353,30 +354,29 @@ Public Function StoreValue(Optional ByVal Value As Variant _ ''' * Date or datetime.datetime ''' * UNO object ''' * ScriptForge class instance -''' VariableName: the case-sensitive name to retrieve the Value when needed. ''' Returns: ''' True when successful ''' Example: ''' memory = CreateScriptService("SharedMemory") ''' doc = CreateScriptService("Document", ThisComponent) -''' memory.StoreValue(doc, "ActualDoc") +''' memory.StoreValue("ActualDoc", doc) Dim bStore As Boolean ' Return value Dim vGlobal As Variant ' A stored value Dim i As Long Const cstThisSub = "SharedMemory.StoreValue" -Const cstSubArgs = "Value, VariableName" +Const cstSubArgs = "VariableName, Value" If SF_Utils._ErrorHandling() Then On Local Error GoTo Catch bStore = False Check: If SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then + If Not SF_Utils._Validate(VariableName, "VariableName", V_STRING) Then GoTo Catch If IsArray(Value) Then If Not SF_Utils._ValidateArray(Value, "Value", 1) Then GoTo Catch End If - If Not SF_Utils._Validate(VariableName, "VariableName", V_STRING) Then GoTo Catch End If Try: diff --git a/wizards/source/scriptforge/python/scriptforge.py b/wizards/source/scriptforge/python/scriptforge.py index 2ba18e377a60..36199dbdd0f8 100644 --- a/wizards/source/scriptforge/python/scriptforge.py +++ b/wizards/source/scriptforge/python/scriptforge.py @@ -1640,14 +1640,14 @@ class SFScriptForge: def RemoveAll(self): return self.ExecMethod(self.vbMethod, 'RemoveAll') - def StoreValue(self, value, variablename): + def StoreValue(self, variablename, value): if isinstance(value, SFServices): - return self.ExecMethod(self.vbMethod + self.flgObject, 'StoreValue', - value.objectreference, variablename) + return self.ExecMethod((self.vbMethod + self.flgObject, 1), 'StoreValue', + variablename, value.objectreference) if isinstance(value, datetime.datetime): value = SFScriptForge.SF_Basic.CDateToUnoDateTime(value) - return self.ExecMethod(self.vbMethod + self.flgDateArg, 'StoreValue', value, variablename) - return self.ExecMethod(self.vbMethod, 'StoreValue', value, variablename) + return self.ExecMethod(self.vbMethod + self.flgDateArg, 'StoreValue', variablename, value) + return self.ExecMethod(self.vbMethod, 'StoreValue', variablename, value) # ######################################################################### # SF_String CLASS diff --git a/wizards/source/scriptforge/python/scriptforge.pyi b/wizards/source/scriptforge/python/scriptforge.pyi index b2b497a2bb7c..41bdf771cc33 100644 --- a/wizards/source/scriptforge/python/scriptforge.pyi +++ b/wizards/source/scriptforge/python/scriptforge.pyi @@ -2085,13 +2085,15 @@ class SFScriptForge: ... def StoreValue(self, + variablename: str, value: Any | datetime.datetime | UNO | tuple[int | float | str | bool, ...], - variablename: str ) -> bool: """ Store in the shared and persistent storage area the given value. Later retrieval will be done thanks to the given variable name. If the given name already exists, its value is replaced without warning. Args + ``variablename``: the case-sensitive name to retrieve ``value`` when needed. + ``value``: the value to be stored. The supported variable types are: * Scalar or tuple combining: @@ -2103,8 +2105,6 @@ class SFScriptForge: * datetime.datetime * UNO object * ScriptForge class instance - - ``variablename``: the case-sensitive name to retrieve ``value`` when needed. Returns ``True`` when successful """ diff --git a/wizards/source/scriptforge/script.xlb b/wizards/source/scriptforge/script.xlb index bead89b8a66e..0c1ae2408640 100644 --- a/wizards/source/scriptforge/script.xlb +++ b/wizards/source/scriptforge/script.xlb @@ -1,24 +1,24 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE library:library PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "library.dtd"> <library:library xmlns:library="http://openoffice.org/2000/library" library:name="ScriptForge" library:readonly="false" library:passwordprotected="false"> + <library:element library:name="_ModuleModel"/> + <library:element library:name="SF_String"/> + <library:element library:name="SF_Utils"/> + <library:element library:name="SF_TextStream"/> + <library:element library:name="SF_Array"/> + <library:element library:name="SF_Platform"/> + <library:element library:name="SF_PythonHelper"/> <library:element library:name="SF_Timer"/> <library:element library:name="SF_FileSystem"/> - <library:element library:name="__License"/> - <library:element library:name="SF_Root"/> <library:element library:name="SF_Region"/> <library:element library:name="SF_L10N"/> <library:element library:name="SF_SharedMemory"/> + <library:element library:name="__License"/> + <library:element library:name="SF_Root"/> <library:element library:name="_CodingConventions"/> <library:element library:name="SF_Session"/> <library:element library:name="SF_Dictionary"/> <library:element library:name="SF_Exception"/> <library:element library:name="SF_UI"/> <library:element library:name="SF_Services"/> - <library:element library:name="SF_PythonHelper"/> - <library:element library:name="SF_Platform"/> - <library:element library:name="SF_Array"/> - <library:element library:name="SF_TextStream"/> - <library:element library:name="SF_Utils"/> - <library:element library:name="SF_String"/> - <library:element library:name="_ModuleModel"/> </library:library> \ No newline at end of file