ScriptForge Session.GetUnoProperty/GetPropertyByName()

Several changes:

- 2 new methods in the Session service:
    session.GetPropertyByName(basicobject,
        propertyname, [arg])
      for read access to properties of ScriptForge
      object instances.
      Argument is required for some Calc properties.
    session.GetUnoProperty(unoobject,
        propertyname)
      for read access to properties of UNO
      object instances.
  Those methods complement nicely the
  array.Map(), Filter() and Reduce() methods.

- The wording of trapped errors when
    session.ExecutePythonScript()
  fails has been reviewed to be distinct
  to that of
    session.ExecuteBasicScript()

- The source code of
    session.GetPDFExportOptions() was missplaced.

- A more accurate identification of ScriptForge
  object instances has been implemented in
    SF_Utils._VarTypeObj()
  (internal use only).

- Some fixed typos

The changes are applicable to Basic and Python
user scripts.

The new methods require an update of the user
documentation.

Change-Id: Ibbc0eecfe52a190eece66edadc14710a7fd6a106
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/205033
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
This commit is contained in:
Jean-Pierre Ledure
2026-05-11 10:12:10 +02:00
parent 47b9582999
commit d6b4eb14c3
7 changed files with 287 additions and 140 deletions
+2 -3
View File
@@ -2254,8 +2254,7 @@ Public Function Reduce(Optional ByVal Module As Variant _
&apos;&apos;&apos; The script must be written in Basic.
&apos;&apos;&apos; Reduce() returns the value returned by the last iteration.
&apos;&apos;&apos; Module: a Basic object referring either to a module, or to an instance of a Basic class.
&apos;&apos;&apos; Method: the method to execute, as a string
&apos;&apos;&apos; When Module is a ScriptForge object, Method may also be a property (get).
&apos;&apos;&apos; Method: the method to execute, as a string. The method must have two arguments.
&apos;&apos;&apos; Params: a 1D array where each item represents the argument to pass for a given iteration.
&apos;&apos;&apos; InitialValue: when present, the first argument of the first iteration.
&apos;&apos;&apos; Return:
@@ -3334,4 +3333,4 @@ Dim iCompare As Integer, iVarType1 As Integer, iVarType2 As Integer
End Function &apos; ScriptForge.SF_Array._ValCompare
REM ================================================= END OF SCRIPTFORGE.SF_ARRAY
</script:module>
</script:module>
+5 -3
View File
@@ -71,6 +71,7 @@ Private CharacterClass As Object &apos; com.sun.star.i18n.CharacterClassificati
Private FileAccess As Object &apos; com.sun.star.ucb.SimpleFileAccess
Private FilterFactory As Object &apos; com.sun.star.document.FilterFactory
Private URLTransformer As Object &apos; com.sun.star.util.URLTransformer
Private Invocation As Object &apos; com.sun.star.script.Invocation
Private Introspection As Object &apos; com.sun.star.beans.Introspection
Private BrowseNodeFactory As Object &apos; com.sun.star.script.browse.BrowseNodeFactory
Private DatabaseContext As Object &apos; com.sun.star.sdb.DatabaseContext
@@ -142,6 +143,7 @@ Private Sub Class_Initialize()
Set FileAccess = Nothing
Set FilterFactory = Nothing
Set URLTransformer = Nothing
Set Invocation = Nothing
Set Introspection = Nothing
FileSystemNaming = &quot;ANY&quot;
PythonHelper = &quot;ScriptForgeHelper.py&quot;
@@ -659,12 +661,12 @@ Try:
&amp; &quot;%4: An identifier\n&quot; _
&amp; &quot;%5: A string&quot; _
)
&apos; SF_Session.ExecuteBasicScript
&apos; SF_Session.ExecuteBasicScript/ExecutePythonScript
.AddText( Context := &quot;SCRIPTEXEC&quot; _
, MsgId := &quot;An exception occurred during the execution of the Basic script.\n&quot; _
, MsgId := &quot;An exception occurred during the execution of the script.\n&quot; _
&amp; &quot;Cause: %3\n&quot; _
&amp; &quot;« %1 » = %2&quot; _
, Comment := &quot;SF_Session.ExecuteBasicScript error message\n&quot; _
, Comment := &quot;SF_Session.ExecuteBasicScript/ExecutePythonScript error message\n&quot; _
&amp; &quot;%1: An identifier\n&quot; _
&amp; &quot;%2: A string\n&quot; _
&amp; &quot;%3: A (long) string&quot; _
+171 -82
View File
@@ -314,6 +314,7 @@ Try:
&apos; Execute script
If Not IsNull(oScript) Then
On Local Error GoTo CatchExec
vReturn = oScript.Invoke(pvArgs(), Array(), Array())
&apos; Remove surrounding array when single returned value
If IsArray(vReturn) Then
@@ -327,90 +328,11 @@ Finally:
Exit Function
Catch:
GoTo Finally
CatchExec:
SF_Exception.RaiseFatal(SCRIPTEXECERROR, &quot;Script&quot;, Script, Error$)
GoTo Finally
End Function &apos; ScriptForge.SF_Session.ExecutePythonScript
REM -----------------------------------------------------------------------------
Public Function GetRangeFromCalc(Optional ByVal FileName As Variant _
, Optional ByVal Range As Variant _
) As Variant
&apos;&apos;&apos; Extract the content of a range of adjacent cells stored in a Calc file.
&apos;&apos;&apos; The file may be open or closed. If the file is open in the actual LibreOffice
&apos;&apos;&apos; session, its actual content will be read. Otherwise the content will be
&apos;&apos;&apos; read from the file on disk.
&apos;&apos;&apos; Inspired by https://bugs.documentfoundation.org/show_bug.cgi?id=148040
&apos;&apos;&apos; Args:
&apos;&apos;&apos; FileName: the full file name, given in FileSystem.FileNaming notation.
&apos;&apos;&apos; The file must exist.
&apos;&apos;&apos; Range: either
&apos;&apos;&apos; &quot;sheet.cells&quot;, where &quot;sheet&quot; is the mandatory sheet name, eventually
&apos;&apos;&apos; surrounded with single quotes when it contains special characters,
&apos;&apos;&apos; and &quot;cells&quot; is the single cell or the range of cells
&apos;&apos;&apos; to be considered, in A1 notation with or without dollar signs
&apos;&apos;&apos; a defined name at document-global level.
&apos;&apos;&apos; Current selection shortcuts (&quot;~&quot;) are forbidden in this context.
&apos;&apos;&apos; Returns:
&apos;&apos;&apos; Either a scalar, or a 1D array when the range is located in a single row or column,
&apos;&apos;&apos; or a 2D array.
&apos;&apos;&apos; The returned values are either strings or numbers. No dates, booleans, ...
&apos;&apos;&apos; To convert doubles to dates, use the CDate builtin function.
&apos;&apos;&apos; Empty cells are returned as empty strings.
&apos;&apos;&apos; Exceptions:
&apos;&apos;&apos; UNKNOWNFILEERROR The Calc file does not exist
&apos;&apos;&apos; CALCADDRESSERROR Invalid Calc range
&apos;&apos;&apos; Example:
&apos;&apos;&apos; value = session.GetFromFileName(&quot;C:\myFile.ods&quot;, &quot;Sheet1.A1:J10&quot;)
Dim vReturn As Variant &apos; Returned value
Dim oCalc As Object &apos; Give access to the com.sun.star.sheet.FunctionAccess service
Dim sArgument As String &apos; The argument given to the &quot;Indirect&quot; Calc function
Const cstThisSub = &quot;Session.GetRangeFromCalc&quot;
Const cstSubArgs = &quot;FileName, Range&quot;
If SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
vReturn = Empty
Check:
If SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
If Not SF_Utils._ValidateFile(FileName, &quot;FileName&quot;) Then GoTo Finally
If Not SF_Utils._Validate(Range, &quot;Range&quot;, V_STRING) Then GoTo Finally
End If
If Not SF_FileSystem.FileExists(FileName) Then GoTo CatchNotExists
Try:
&apos; The execution results from the com.sun.star.sheet.FunctionAccess service
Set oCalc = SF_Utils._GetUNOService(&quot;FunctionAccess&quot;)
&apos; Error trapping, execution, error reset
If SF_Utils._ErrorHandling() Then On Local Error GoTo CatchCall
sArgument = &quot;&apos;&quot; &amp; SF_FileSystem._ConvertToUrl(FileName) &amp; &quot;&apos;#&quot; &amp; Range
vReturn = oCalc.callFunction(&quot;INDIRECT&quot;, Array(sArgument))
If SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
&apos; Transform the arrays of subarrays =&gt; 2D arrays, only in Basic
Select Case SF_Array.CountDims(vReturn)
Case -1, 0, 2
&apos; Do nothing: scalar or empty array or 2D array (should not happen)
Case 1
If IsArray(vReturn(0)) And Not _SF_.TriggeredByPython Then vReturn = SF_Array.ConvertFromDataArray(vReturn, IsRange := True)
Case Else
End Select
Finally:
GetRangeFromCalc = vReturn
SF_Utils._ExitFunction(cstThisSub)
Exit Function
Catch:
GoTo Finally
CatchNotExists:
SF_Exception.RaiseFatal(UNKNOWNFILEERROR, &quot;FileName&quot;, FileName)
GoTo Finally
CatchCall:
ScriptForge.SF_Exception.RaiseFatal(CALCADDRESSERROR, &quot;Range&quot;, Range, &quot;FileName&quot;, FileName)
GoTo Finally
End Function &apos; ScriptForge.SF_Session.GetRangeFromCalc
REM -----------------------------------------------------------------------------
Public Function GetPDFExportOptions() As Variant
&apos;&apos;&apos; Return the actual values of the PDF export options
@@ -499,6 +421,173 @@ Catch:
GoTo Finally
End Function &apos; ScriptForge.SF_Session.GetProperty
REM -----------------------------------------------------------------------------
Public Function GetPropertyByName(Optional ByRef BasicObject As Variant _
, Optional ByVal PropertyName As Variant _
, Optional ByVal Arg As Variant _
) As Variant
&apos;&apos;&apos; Return the actual value of the given property related to the given ScriptForge/Basic object
&apos;&apos;&apos; Args:
&apos;&apos;&apos; BasicObject: a ScriptForge Basic module or a ScriptForge Basic class instance
&apos;&apos;&apos; PropertyName: the name of the property as a string
&apos;&apos;&apos; Arg: some properties have 1 argument
&apos;&apos;&apos; Returns:
&apos;&apos;&apos; The actual value of the property or Null/None if the method failed.
&apos;&apos;&apos; Exceptions
&apos;&apos;&apos; ARGUMENTERROR The argument does not pass the validation rules
Dim vProperty As Variant &apos; Return value
Const cstThisSub = &quot;Session.GetPropertyByName&quot;
Const cstSubArgs = &quot;BasicObject, PropertyName, [Arg]&quot;
If SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
vProperty = Null
Check:
If IsMissing(Arg) Then Arg = Empty
SF_Utils._EnterFunction(cstThisSub, cstSubArgs)
If Not SF_Utils._Validate(BasicObject, &quot;BasicObject&quot;, V_OBJECT, , , &quot;ANY&quot;) Then GoTo Catch
If Not SF_Utils._Validate(PropertyName, &quot;PropertyName&quot;, V_STRING, BasicObject.Properties()) Then GoTo Catch
Try:
With BasicObject
If IsEmpty(Arg) Then
vProperty = .GetProperty(PropertyName)
Else
vProperty = .GetProperty(PropertyName, Arg)
End If
End With
Finally:
GetPropertyByName = vProperty
SF_Utils._ExitFunction(cstThisSub)
Exit Function
Catch:
GoTo Finally
End Function &apos; ScriptForge.SF_Session.GetPropertyByName
REM -----------------------------------------------------------------------------
Public Function GetRangeFromCalc(Optional ByVal FileName As Variant _
, Optional ByVal Range As Variant _
) As Variant
&apos;&apos;&apos; Extract the content of a range of adjacent cells stored in a Calc file.
&apos;&apos;&apos; The file may be open or closed. If the file is open in the actual LibreOffice
&apos;&apos;&apos; session, its actual content will be read. Otherwise the content will be
&apos;&apos;&apos; read from the file on disk.
&apos;&apos;&apos; Inspired by https://bugs.documentfoundation.org/show_bug.cgi?id=148040
&apos;&apos;&apos; Args:
&apos;&apos;&apos; FileName: the full file name, given in FileSystem.FileNaming notation.
&apos;&apos;&apos; The file must exist.
&apos;&apos;&apos; Range: either
&apos;&apos;&apos; &quot;sheet.cells&quot;, where &quot;sheet&quot; is the mandatory sheet name, eventually
&apos;&apos;&apos; surrounded with single quotes when it contains special characters,
&apos;&apos;&apos; and &quot;cells&quot; is the single cell or the range of cells
&apos;&apos;&apos; to be considered, in A1 notation with or without dollar signs
&apos;&apos;&apos; a defined name at document-global level.
&apos;&apos;&apos; Current selection shortcuts (&quot;~&quot;) are forbidden in this context.
&apos;&apos;&apos; Returns:
&apos;&apos;&apos; Either a scalar, or a 1D array when the range is located in a single row or column,
&apos;&apos;&apos; or a 2D array.
&apos;&apos;&apos; The returned values are either strings or numbers. No dates, booleans, ...
&apos;&apos;&apos; To convert doubles to dates, use the CDate builtin function.
&apos;&apos;&apos; Empty cells are returned as empty strings.
&apos;&apos;&apos; Exceptions:
&apos;&apos;&apos; UNKNOWNFILEERROR The Calc file does not exist
&apos;&apos;&apos; CALCADDRESSERROR Invalid Calc range
&apos;&apos;&apos; Example:
&apos;&apos;&apos; value = session.GetFromFileName(&quot;C:\myFile.ods&quot;, &quot;Sheet1.A1:J10&quot;)
Dim vReturn As Variant &apos; Returned value
Dim oCalc As Object &apos; Give access to the com.sun.star.sheet.FunctionAccess service
Dim sArgument As String &apos; The argument given to the &quot;Indirect&quot; Calc function
Const cstThisSub = &quot;Session.GetRangeFromCalc&quot;
Const cstSubArgs = &quot;FileName, Range&quot;
If SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
vReturn = Empty
Check:
If SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
If Not SF_Utils._ValidateFile(FileName, &quot;FileName&quot;) Then GoTo Finally
If Not SF_Utils._Validate(Range, &quot;Range&quot;, V_STRING) Then GoTo Finally
End If
If Not SF_FileSystem.FileExists(FileName) Then GoTo CatchNotExists
Try:
&apos; The execution results from the com.sun.star.sheet.FunctionAccess service
Set oCalc = SF_Utils._GetUNOService(&quot;FunctionAccess&quot;)
&apos; Error trapping, execution, error reset
If SF_Utils._ErrorHandling() Then On Local Error GoTo CatchCall
sArgument = &quot;&apos;&quot; &amp; SF_FileSystem._ConvertToUrl(FileName) &amp; &quot;&apos;#&quot; &amp; Range
vReturn = oCalc.callFunction(&quot;INDIRECT&quot;, Array(sArgument))
If SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
&apos; Transform the arrays of subarrays =&gt; 2D arrays, only in Basic
Select Case SF_Array.CountDims(vReturn)
Case -1, 0, 2
&apos; Do nothing: scalar or empty array or 2D array (should not happen)
Case 1
If IsArray(vReturn(0)) And Not _SF_.TriggeredByPython Then vReturn = SF_Array.ConvertFromDataArray(vReturn, IsRange := True)
Case Else
End Select
Finally:
GetRangeFromCalc = vReturn
SF_Utils._ExitFunction(cstThisSub)
Exit Function
Catch:
GoTo Finally
CatchNotExists:
SF_Exception.RaiseFatal(UNKNOWNFILEERROR, &quot;FileName&quot;, FileName)
GoTo Finally
CatchCall:
ScriptForge.SF_Exception.RaiseFatal(CALCADDRESSERROR, &quot;Range&quot;, Range, &quot;FileName&quot;, FileName)
GoTo Finally
End Function &apos; ScriptForge.SF_Session.GetRangeFromCalc
REM -----------------------------------------------------------------------------
Public Function GetUnoProperty(Optional ByRef UnoObject As Variant _
, Optional ByVal PropertyName As Variant _
) As Variant
&apos;&apos;&apos; Return the actual value of the given property related to the given UNO object
&apos;&apos;&apos; Args:
&apos;&apos;&apos; UnoObject: the UNO object to consider
&apos;&apos;&apos; PropertyName: the exact name of the property as a string
&apos;&apos;&apos; Returns:
&apos;&apos;&apos; The actual value of the property or Null/None if the method failed to find the property or to catch its value.
Dim vProperty As Variant &apos; Return value
Dim oInvocation As Object &apos; com.sun.star.script.Invocation
Dim oIntroObject As Object &apos; Alias of UNO object for introspection
Const cstThisSub = &quot;Session.GetUnoProperty&quot;
Const cstSubArgs = &quot;UnoObject, PropertyName&quot;
vProperty = Null
If SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
Check:
SF_Utils._EnterFunction(cstThisSub, cstSubArgs)
If Not SF_Utils._Validate(UnoObject, &quot;UnoObject&quot;, V_OBJECT) Then GoTo Catch
If Not SF_Utils._Validate(PropertyName, &quot;PropertyName&quot;, V_STRING, SF_Session.UnoProperties(UnoObject)) Then GoTo Catch
Try:
Set oInvocation = SF_Utils._GetUNOService(&quot;Invocation&quot;)
Set oIntroObject = oInvocation.createInstanceWithArguments(Array(UnoObject))
vProperty = oIntroObject.getValue(PropertyName)
Finally:
GetUnoProperty = vProperty
SF_Utils._ExitFunction(cstThisSub)
Exit Function
Catch:
GoTo Finally
End Function &apos; ScriptForge.SF_Session.GetUnoProperty
REM -----------------------------------------------------------------------------
Public Function HasUnoMethod(Optional ByRef UnoObject As Variant _
, Optional ByVal MethodName As Variant _
+12 -6
View File
@@ -18,7 +18,7 @@ Option Private Module
REM ===================================================================== GLOBALS
Global _SF_ As Variant &apos; SF_Root (Basic) object)
Global _SF_ As Variant &apos; SF_Root (Basic) class singleton
&apos;&apos;&apos; ScriptForge version
Const SF_Version = &quot;26.8&quot;
@@ -413,6 +413,11 @@ Dim oDefaultContext As Object
Set .Introspection = CreateUnoService(&quot;com.sun.star.beans.Introspection&quot;)
End If
Set _GetUNOService = .Introspection
Case &quot;Invocation&quot;
If IsEmpty(.Invocation) Or IsNull(.Invocation) Then
Set .Invocation = CreateUnoService(&quot;com.sun.star.script.Invocation&quot;)
End If
Set _GetUNOService = .Invocation
Case &quot;LocaleData&quot;
If IsEmpty(.LocaleData) Or IsNull(.LocaleData) Then
Set .LocaleData = CreateUnoService(&quot;com.sun.star.i18n.LocaleData&quot;)
@@ -746,7 +751,7 @@ Public Function _Validate(Optional ByRef pvArgument As Variant _
&apos;&apos;&apos; pvTypes: array of allowed VarTypes
&apos;&apos;&apos; pvValues: array of allowed values
&apos;&apos;&apos; pvCaseSensitive: when True the comparison between strings is done case-sensitively
&apos;&apos;&apos; pvObjectType: mandatory Basic class
&apos;&apos;&apos; pvObjectType: ScriptForge class, may be &quot;ANY&quot;
&apos;&apos;&apos; Return: True if validation OK
&apos;&apos;&apos; Otherwise an error is raised
&apos;&apos;&apos; Exceptions:
@@ -786,10 +791,9 @@ Try:
End If
&apos; Check instance types
If bValid And Len(pvObjectType) &gt; 0 And iVarType = V_OBJECT Then
&apos;Set oArgument = pvArgument
Set oObjectDescriptor = SF_Utils._VarTypeObj(pvArgument)
bValid = ( oObjectDescriptor.iVarType = V_SFOBJECT )
If bValid Then bValid = ( oObjectDescriptor.sObjectType = pvObjectType )
If bValid And pvObjectType &lt;&gt; &quot;ANY&quot; Then bValid = ( oObjectDescriptor.sObjectType = pvObjectType )
End If
End If
@@ -1102,10 +1106,12 @@ Try:
If .sObjectType = cstBasicClass Then
bUno = False
&apos; Try if the Basic object has an ObjectType property
If Left(oValue.Name, 3) = &quot;SF_&quot; Then
On Local Error GoTo NotSF &apos;If Left(oValue.Name, 3) = &quot;SF_&quot; Then
.sObjectType = oValue.ObjectType
.sServiceName = oValue.ServiceName
End If
&apos;End If
NotSF:
On Local Error GoTo 0
End If
&apos; Derive the return value from the object type
Select Case True
@@ -380,7 +380,7 @@ class ScriptForge(object, metaclass = _Singleton):
pass
elif returntuple[cstClass] == cls.objDICT:
dico = CreateScriptService('ScriptForge.Dictionary')
if not isinstance(returnvalue, uno.ByteSequence): # if array not empty
if len(returnvalue) > 0: # if array not empty
dico.ImportFromPropertyValues(returnvalue, overwrite = True)
return dico
else:
@@ -393,10 +393,10 @@ class ScriptForge(object, metaclass = _Singleton):
if subcls is not None:
return subcls(returnvalue, returntuple[cstType], returntuple[cstClass], returntuple[cstName])
elif returntuple[cstVarType] >= cls.V_ARRAY:
# Intercept empty array
if isinstance(returnvalue, uno.ByteSequence):
return ()
if flag & SFServices.flgDateRet == SFServices.flgDateRet: # Bits comparison
# Ignore empty array
if len(returnvalue) == 0:
pass
elif flag & SFServices.flgDateRet == SFServices.flgDateRet: # Bits comparison
# Intercept all UNO dates in the 1D or 2D array
if isinstance(returnvalue[0], tuple): # tuple of tuples
arr = []
@@ -647,7 +647,7 @@ class SFServices(object):
"""
if self.serviceimplementation == 'basic':
# Conventionally properties starting with X (and only them) may return a UNO object
calltype = self.vbGet + (self.flgUno if propertyname[0] == 'X' else 0)
calltype = self.vbGet + self.flgDateRet + (self.flgUno if propertyname[0] == 'X' else 0)
if arg is None:
return self.EXEC(self.objectreference, calltype, propertyname)
else: # There are a few cases (Calc ...) where GetProperty accepts an argument
@@ -1575,11 +1575,28 @@ class SFScriptForge:
def ExecutePythonScript(cls, scope = '', script = '', *args):
return cls.SIMPLEEXEC(scope + '#' + script, *args)
def GetPDFExportOptions(self):
return self.ExecMethod(self.vbMethod, 'GetPDFExportOptions')
def GetPropertyByName(self, basicobject, propertyname, arg = None):
if isinstance(basicobject, SFServices) is False:
return None
if basicobject.serviceimplementation == 'basic':
# Conventionally properties starting with X (and only them) may return a UNO object
calltype = (self.vbMethod + self.flgObject + self.flgDateRet +
(self.flgUno if propertyname[0] == 'X' else 0))
if arg is None:
return self.ExecMethod(calltype, 'GetPropertyByName', basicobject.objectreference, propertyname)
else: # There are a few cases (Calc ...) where GetProperty accepts an argument
return self.ExecMethod(calltype, 'GetPropertyByName',
basicobject.objectreference, propertyname, arg)
return None
def GetRangeFromCalc(self, filename, range):
return self.ExecMethod(self.vbMethod, 'GetRangeFromCalc', filename, range)
def GetPDFExportOptions(self):
return self.ExecMethod(self.vbMethod, 'GetPDFExportOptions')
def GetUnoProperty(self, unoobject, propertyname):
return self.ExecMethod(self.vbMethod, 'GetUnoProperty', unoobject, propertyname)
def HasUnoMethod(self, unoobject, methodname):
return self.ExecMethod(self.vbMethod, 'HasUnoMethod', unoobject, methodname)
@@ -1869,30 +1869,6 @@ class SFScriptForge:
"""
...
def GetRangeFromCalc(self, filename: FILE, range: RANGE):
"""
Extract the content of a range of adjacent cells stored in a Calc file. The file may be open
or closed. If the file is open in the actual LibreOffice session, its actual content will be read.
Otherwise, the content will be read from the file on disk.
Args
``filename``: the full file name, given in ``FileSystem.FileNaming`` notation.
``range``: either
- "sheet.cells", where "sheet" is the mandatory sheet name, eventually surrounded with
single quotes when it contains special characters, and "cells" is the single cell
or the range of cells to be considered, in A1 notation with or without dollar signs
- a defined name at document-global level.
Note
Current selection shortcuts ("~") are forbidden in this context.
Returns
Either a scalar, or a tuple when the range is located in a single row or column,
or a tuple of tuples. The returned values are either strings or numbers. No dates, booleans, ...
To convert doubles to dates, use the ``basic.CDate()`` method.
Empty cells are returned as empty strings.
"""
...
def GetPDFExportOptions(self) -> DICTIONARY:
"""
Returns the current PDF export settings defined in the ``PDF Options`` dialog, which can be accessed
@@ -1903,6 +1879,64 @@ class SFScriptForge:
"""
...
def GetPropertyByName(self,
basicobject: SERVICE,
propertyname: str,
arg: Any = ...,
) -> Any:
"""
Return the actual value of the given property related to the given ``ScriptForge`` service instance.
Args
``basicobject``: an instance of a class implemented in the Basic world.
``propertyname``: the name of the property, as a ProperCased string.
``arg``: some properties require an argument.
Returns
The actual value of the property.
"""
...
def GetRangeFromCalc(self, filename: FILE, range: RANGE):
"""
Extract the content of a range of adjacent cells stored in a Calc file. The file may be open
or closed. If the file is open in the actual LibreOffice session, its actual content will be read.
Otherwise, the content will be read from the file on disk.
Args
``filename``: the full file name, given in ``FileSystem.FileNaming`` notation.
``range``: either
- "sheet.cells", where "sheet" is the mandatory sheet name, eventually surrounded with
single quotes when it contains special characters, and "cells" is the single cell
or the range of cells to be considered, in A1 notation with or without dollar signs
- a defined name at document-global level.
Note
Current selection shortcuts ("~") are forbidden in this context.
Returns
Either a scalar, or a tuple when the range is located in a single row or column,
or a tuple of tuples. The returned values are either strings or numbers. No dates, booleans, ...
To convert doubles to dates, use the ``basic.CDate()`` method.
Empty cells are returned as empty strings.
"""
...
def GetUnoProperty(self,
unoobject: UNO,
propertyname: str,
) -> Any:
"""
Return the actual value of the given property related to the given ``UNO`` object.
Args
``unoobject``: the.considered ``UNO`` object.
``propertyname``: the name of the property, as a string.
Returns
The actual value of the property or None if the method failed to find the property
or to catch its value.
"""
...
def HasUnoMethod(self, unoobject: UNO, methodname: str) -> bool:
"""
Returns ``True`` if a UNO object contains the given method.
+14 -14
View File
@@ -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="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:element library:name="SF_SharedMemory"/>
<library:element library:name="SF_L10N"/>
<library:element library:name="SF_Region"/>
<library:element library:name="__License"/>
<library:element library:name="SF_Root"/>
<library:element library:name="SF_Timer"/>
<library:element library:name="SF_FileSystem"/>
<library:element library:name="SF_Services"/>
<library:element library:name="SF_UI"/>
<library:element library:name="SF_Exception"/>
<library:element library:name="SF_Dictionary"/>
<library:element library:name="SF_Session"/>
<library:element library:name="_CodingConventions"/>
<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_FileSystem"/>
<library:element library:name="SF_Timer"/>
<library:element library:name="SF_Region"/>
<library:element library:name="SF_L10N"/>
<library:element library:name="SF_SharedMemory"/>
<library:element library:name="SF_Root"/>
<library:element library:name="__License"/>
</library:library>