summaryrefslogtreecommitdiff
path: root/wizards
diff options
context:
space:
mode:
authorJean-Pierre Ledure <jp@ledure.be>2022-02-15 15:30:38 +0100
committerJean-Pierre Ledure <jp@ledure.be>2022-02-15 17:50:45 +0100
commit74a638011da4c2e8475d6f9d4d3a0ffbc4e10807 (patch)
tree2a645e304c8e3cb2fd2b29207922fa5ca9e70ced /wizards
parentb8337fdcc374864047b8fa5cdd213dde7387bc19 (diff)
ScriptForge - (scriptforge.py) get lists of properties and methods
To allow object introspection and some help files automatic generation (see Telegram discussions), the possibility to make the list of properties and methods used in Basic available in Python has been requested. These changes are for internal use only. Main changes: - the SFServices parent class receives new basicproperties() and basicmethods() methods - Basic PythonDispatcher() is adapted to provide the lists to the Python caller - Methods lists are reviewed in SFDocuments to NOT include the methods implemented in the parent SF_Document class, to avoid redundant entries in the list Change-Id: I80758e225b039426b46f52dd67efe54c50f9f31e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129969 Tested-by: Jean-Pierre Ledure <jp@ledure.be> Tested-by: Jenkins Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Diffstat (limited to 'wizards')
-rw-r--r--wizards/source/scriptforge/SF_FileSystem.xba4
-rw-r--r--wizards/source/scriptforge/SF_PythonHelper.xba86
-rw-r--r--wizards/source/scriptforge/python/scriptforge.py14
-rw-r--r--wizards/source/sfdocuments/SF_Base.xba10
-rw-r--r--wizards/source/sfdocuments/SF_Calc.xba10
-rw-r--r--wizards/source/sfdocuments/SF_Writer.xba12
6 files changed, 67 insertions, 69 deletions
diff --git a/wizards/source/scriptforge/SF_FileSystem.xba b/wizards/source/scriptforge/SF_FileSystem.xba
index c0b7e8316fe8..39ea4888e3d1 100644
--- a/wizards/source/scriptforge/SF_FileSystem.xba
+++ b/wizards/source/scriptforge/SF_FileSystem.xba
@@ -2121,8 +2121,8 @@ Dim sFolder As String &apos; Folder
End If
_SFInstallFolder = _ConvertFromUrl(sFolder)
-
+
End Function &apos; ScriptForge.SF_FileSystem._SFInstallFolder
REM ============================================ END OF SCRIPTFORGE.SF_FileSystem
-</script:module>
+</script:module> \ No newline at end of file
diff --git a/wizards/source/scriptforge/SF_PythonHelper.xba b/wizards/source/scriptforge/SF_PythonHelper.xba
index 442a4bd1b856..d2b8f3276f43 100644
--- a/wizards/source/scriptforge/SF_PythonHelper.xba
+++ b/wizards/source/scriptforge/SF_PythonHelper.xba
@@ -712,6 +712,7 @@ Try:
vBasicObject = _SF_.PythonStorage(BasicObject)
sObjectType = vBasicObject.ObjectType
sServiceName = vBasicObject.ServiceName
+
&apos; Basic modules have type = &quot;SF_*&quot;
bBasicClass = ( Left(sObjectType, 3) &lt;&gt; &quot;SF_&quot; )
sLibrary = Split(sServiceName, &quot;.&quot;)(0)
@@ -727,10 +728,17 @@ Try:
ElseIf Not bBasicClass And _
(((CallType And vbMethod) + (CallType And cstArgArray)) = vbMethod + cstArgArray Or _
((CallType And vbMethod) + (CallType And cstRetArray)) = vbMethod + cstRetArray) Then
- Select Case sServiceName
- Case &quot;ScriptForge.Array&quot;
- If Script = &quot;ImportFromCSVFile&quot; Then vReturn = SF_Array.ImportFromCSVFile(vArgs(0), vArgs(1), vArgs(2), True)
- End Select
+ &apos; Not service related
+ If Script = &quot;Methods&quot; Then
+ vReturn = vBasicObject.Methods()
+ ElseIf Script = &quot;Properties&quot; Then
+ vReturn = vBasicObject.Properties()
+ Else
+ Select Case sServiceName
+ Case &quot;ScriptForge.Array&quot;
+ If Script = &quot;ImportFromCSVFile&quot; Then vReturn = SF_Array.ImportFromCSVFile(vArgs(0), vArgs(1), vArgs(2), True)
+ End Select
+ End If
&apos; Methods in usual modules are called by ExecuteBasicScript() except if they use a ParamArray
ElseIf Not bBasicClass And (CallType And vbMethod) = vbMethod Then
@@ -759,38 +767,44 @@ Try:
&apos; Methods in class modules using a 2D array or returning arrays are hardcoded as exceptions. Bug #138155
ElseIf ((CallType And vbMethod) + (CallType And cstArgArray)) = vbMethod + cstArgArray Or _
((CallType And vbMethod) + (CallType And cstRetArray)) = vbMethod + cstRetArray Then
- Select Case sServiceName
- Case &quot;SFDatabases.Database&quot;
- If Script = &quot;GetRows&quot; Then vReturn = vBasicObject.GetRows(vArgs(0), vArgs(1), vArgs(2), vArgs(3))
- Case &quot;SFDialogs.Dialog&quot;
- If Script = &quot;Controls&quot; Then vReturn = vBasicObject.Controls(vArgs(0))
- Case &quot;SFDialogs.DialogControl&quot;
- If Script = &quot;SetTableData&quot; Then vReturn = vBasicObject.SetTableData(vArgs(0), vArgs(1), vArgs(2))
- Case &quot;SFDocuments.Document&quot;
- If Script = &quot;Forms&quot; Then vReturn = vBasicObject.Forms(vArgs(0))
- Case &quot;SFDocuments.Base&quot;
- Select Case Script
- Case &quot;FormDocuments&quot; : vReturn = vBasicObject.FormDocuments()
- Case &quot;Forms&quot; : vReturn = vBasicObject.Forms(vArgs(0), vArgs(1))
- End Select
- Case &quot;SFDocuments.Calc&quot;
- Select Case Script
- Case &quot;Charts&quot; : vReturn = vBasicObject.Charts(vArgs(0), vArgs(1))
- Case &quot;Forms&quot; : vReturn = vBasicObject.Forms(vArgs(0), vArgs(1))
- Case &quot;GetFormula&quot; : vReturn = vBasicObject.GetFormula(vArgs(0))
- Case &quot;GetValue&quot; : vReturn = vBasicObject.GetValue(vArgs(0))
- Case &quot;SetArray&quot; : vReturn = vBasicObject.SetArray(vArgs(0), vArgs(1))
- Case &quot;SetFormula&quot; : vReturn = vBasicObject.SetFormula(vArgs(0), vArgs(1))
- Case &quot;SetValue&quot; : vReturn = vBasicObject.SetValue(vArgs(0), vArgs(1))
- End Select
- Case &quot;SFDocuments.Form&quot;
- Select Case Script
- Case &quot;Controls&quot; : vReturn = vBasicObject.Controls(vArgs(0))
- Case &quot;Subforms&quot; : vReturn = vBasicObject.Subforms(vArgs(0))
- End Select
- Case &quot;SFDocuments.FormControl&quot;
- If Script = &quot;Controls&quot; Then vReturn = vBasicObject.Controls(vArgs(0))
- End Select
+ If Script = &quot;Methods&quot; Then
+ vReturn = vBasicObject.Methods()
+ ElseIf Script = &quot;Properties&quot; Then
+ vReturn = vBasicObject.Properties()
+ Else
+ Select Case sServiceName
+ Case &quot;SFDatabases.Database&quot;
+ If Script = &quot;GetRows&quot; Then vReturn = vBasicObject.GetRows(vArgs(0), vArgs(1), vArgs(2), vArgs(3))
+ Case &quot;SFDialogs.Dialog&quot;
+ If Script = &quot;Controls&quot; Then vReturn = vBasicObject.Controls(vArgs(0))
+ Case &quot;SFDialogs.DialogControl&quot;
+ If Script = &quot;SetTableData&quot; Then vReturn = vBasicObject.SetTableData(vArgs(0), vArgs(1), vArgs(2))
+ Case &quot;SFDocuments.Document&quot;
+ If Script = &quot;Forms&quot; Then vReturn = vBasicObject.Forms(vArgs(0))
+ Case &quot;SFDocuments.Base&quot;
+ Select Case Script
+ Case &quot;FormDocuments&quot; : vReturn = vBasicObject.FormDocuments()
+ Case &quot;Forms&quot; : vReturn = vBasicObject.Forms(vArgs(0), vArgs(1))
+ End Select
+ Case &quot;SFDocuments.Calc&quot;
+ Select Case Script
+ Case &quot;Charts&quot; : vReturn = vBasicObject.Charts(vArgs(0), vArgs(1))
+ Case &quot;Forms&quot; : vReturn = vBasicObject.Forms(vArgs(0), vArgs(1))
+ Case &quot;GetFormula&quot; : vReturn = vBasicObject.GetFormula(vArgs(0))
+ Case &quot;GetValue&quot; : vReturn = vBasicObject.GetValue(vArgs(0))
+ Case &quot;SetArray&quot; : vReturn = vBasicObject.SetArray(vArgs(0), vArgs(1))
+ Case &quot;SetFormula&quot; : vReturn = vBasicObject.SetFormula(vArgs(0), vArgs(1))
+ Case &quot;SetValue&quot; : vReturn = vBasicObject.SetValue(vArgs(0), vArgs(1))
+ End Select
+ Case &quot;SFDocuments.Form&quot;
+ Select Case Script
+ Case &quot;Controls&quot; : vReturn = vBasicObject.Controls(vArgs(0))
+ Case &quot;Subforms&quot; : vReturn = vBasicObject.Subforms(vArgs(0))
+ End Select
+ Case &quot;SFDocuments.FormControl&quot;
+ If Script = &quot;Controls&quot; Then vReturn = vBasicObject.Controls(vArgs(0))
+ End Select
+ End If
&apos; Methods in class modules are invoked with CallByName
ElseIf bBasicClass And ((CallType And vbMethod) = vbMethod) Then
diff --git a/wizards/source/scriptforge/python/scriptforge.py b/wizards/source/scriptforge/python/scriptforge.py
index 5eb0b08a5863..53a724d9b8f4 100644
--- a/wizards/source/scriptforge/python/scriptforge.py
+++ b/wizards/source/scriptforge/python/scriptforge.py
@@ -267,7 +267,7 @@ class ScriptForge(object, metaclass = _Singleton):
Execute a given Basic script and interpret its result
This method has as counterpart the ScriptForge.SF_PythonHelper._PythonDispatcher() Basic method
:param basicobject: a Service subclass
- :param flags: see the vb* and flg* constants below
+ :param flags: see the vb* and flg* constants in the SFServices class
:param method: the name of the method or property to invoke, as a string
:param args: the arguments of the method. Symbolic cst* constants may be necessary
:return: The invoked Basic counterpart script (with InvokeSimpleScript()) will return a tuple
@@ -569,6 +569,18 @@ class SFServices(object):
def Properties(self):
return list(self.serviceproperties)
+ def basicmethods(self):
+ if self.serviceimplementation == 'basic':
+ return self.ExecMethod(self.vbMethod + self.flgArrayRet, 'Methods')
+ else:
+ return []
+
+ def basicproperties(self):
+ if self.serviceimplementation == 'basic':
+ return self.ExecMethod(self.vbMethod + self.flgArrayRet, 'Properties')
+ else:
+ return []
+
def SetProperty(self, propertyname, value):
"""
Set the given property to a new value in the Basic world
diff --git a/wizards/source/sfdocuments/SF_Base.xba b/wizards/source/sfdocuments/SF_Base.xba
index 8e8dbfb4e27e..1e6395dbfa2c 100644
--- a/wizards/source/sfdocuments/SF_Base.xba
+++ b/wizards/source/sfdocuments/SF_Base.xba
@@ -440,21 +440,13 @@ Public Function Methods() As Variant
&apos;&apos;&apos; Return the list of public methods of the Base class as an array
Methods = Array( _
- &quot;Activate&quot; _
- , &quot;CloseDocument&quot; _
- , &quot;CloseFormDocument&quot; _
- , &quot;CreateMenu&quot; _
+ &quot;CloseFormDocument&quot; _
, &quot;FormDocuments&quot; _
, &quot;Forms&quot; _
, &quot;GetDatabase&quot; _
, &quot;IsLoaded&quot; _
, &quot;OpenFormDocument&quot; _
, &quot;PrintOut&quot; _
- , &quot;RemoveMenu&quot; _
- , &quot;RunCommand&quot; _
- , &quot;Save&quot; _
- , &quot;SaveAs&quot; _
- , &quot;SaveCopyAs&quot; _
, &quot;SetPrinter&quot; _
)
diff --git a/wizards/source/sfdocuments/SF_Calc.xba b/wizards/source/sfdocuments/SF_Calc.xba
index 8c9ab301370f..f7cd2005d1b5 100644
--- a/wizards/source/sfdocuments/SF_Calc.xba
+++ b/wizards/source/sfdocuments/SF_Calc.xba
@@ -1636,24 +1636,20 @@ Public Function Methods() As Variant
Methods = Array( _
&quot;A1Style&quot; _
- , &quot;Activate&quot; _
, &quot;Charts&quot; _
, &quot;ClearAll&quot; _
, &quot;ClearFormats&quot; _
, &quot;ClearValues&quot; _
- , &quot;CloseDocument&quot; _
, &quot;CopySheet&quot; _
, &quot;CopySheetFromFile&quot; _
, &quot;CopyToCell&quot; _
, &quot;CopyToRange&quot; _
, &quot;CreateChart&quot; _
- , &quot;CreateMenu&quot; _
, &quot;DAvg&quot; _
, &quot;DCount&quot; _
, &quot;DMax&quot; _
, &quot;DMin&quot; _
, &quot;DSum&quot; _
- , &quot;ExportAsPDF&quot; _
, &quot;GetColumnName&quot; _
, &quot;GetFormula&quot; _
, &quot;GetValue&quot; _
@@ -1666,17 +1662,11 @@ Public Function Methods() As Variant
, &quot;OpenRangeSelector&quot; _
, &quot;Printf&quot; _
, &quot;PrintOut&quot; _
- , &quot;RemoveMenu&quot; _
, &quot;RemoveSheet&quot; _
, &quot;RenameSheet&quot; _
- , &quot;RunCommand&quot; _
- , &quot;Save&quot; _
- , &quot;SaveAs&quot; _
- , &quot;SaveCopyAs&quot; _
, &quot;SetArray&quot; _
, &quot;SetCellStyle&quot; _
, &quot;SetFormula&quot; _
- , &quot;SetPrinter&quot; _
, &quot;SetValue&quot; _
, &quot;ShiftDown&quot; _
, &quot;ShiftLeft&quot; _
diff --git a/wizards/source/sfdocuments/SF_Writer.xba b/wizards/source/sfdocuments/SF_Writer.xba
index 9d2234637dd4..12d3136df65f 100644
--- a/wizards/source/sfdocuments/SF_Writer.xba
+++ b/wizards/source/sfdocuments/SF_Writer.xba
@@ -217,18 +217,8 @@ Public Function Methods() As Variant
&apos;&apos;&apos; Return the list of public methods of the Writer service as an array
Methods = Array( _
- &quot;Activate&quot; _
- , &quot;CloseDocument&quot; _
- , &quot;CreateMenu&quot; _
- , &quot;ExportAsPDF&quot; _
- , &quot;Forms&quot; _
+ &quot;Forms&quot; _
, &quot;PrintOut&quot; _
- , &quot;RemoveMenu&quot; _
- , &quot;RunCommand&quot; _
- , &quot;Save&quot; _
- , &quot;SaveAs&quot; _
- , &quot;SaveCopyAs&quot; _
- , &quot;SetPrinter&quot; _
)
End Function &apos; SFDocuments.SF_Writer.Methods