LibreOffice Module wizards (master) 1
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
scriptforge.ScriptForge Class Reference
Inheritance diagram for scriptforge.ScriptForge:
[legend]
Collaboration diagram for scriptforge.ScriptForge:
[legend]

Public Member Functions

def __init__ (self, hostname='', port=0)
 
def ConnectToLOProcess (cls, hostname='', port=0)
 
def ScriptProvider (cls, context=None)
 
def InvokeSimpleScript (cls, script, *args)
 
def InvokeBasicService (cls, basicobject, flags, method, *args)
 
- Public Member Functions inherited from scriptforge._Singleton
def __call__ (cls, *args, **kwargs)
 

Static Public Member Functions

def SetAttributeSynonyms ()
 
def unpack_args (kwargs)
 

Public Attributes

 servicesdispatcher
 

Static Public Attributes

string hostname = ''
 
int port = 0
 
 componentcontext = None
 
 scriptprovider = None
 
bool SCRIPTFORGEINITDONE = False
 
string library = 'ScriptForge'
 
string Version = '7.6'
 
string basicdispatcher = '@application#ScriptForge.SF_PythonHelper._PythonDispatcher'
 
string pythonhelpermodule = 'ScriptForgeHelper.py'
 
 V_EMPTY
 
 V_NULL
 
 V_INTEGER
 
 V_LONG
 
 V_SINGLE
 
 V_DOUBLE
 
 V_CURRENCY
 
 V_DATE
 
 V_STRING
 
 V_OBJECT
 
 V_BOOLEAN
 
 V_VARIANT
 
 V_ARRAY
 
 V_ERROR
 
 V_UNO
 
 objMODULE
 
 objCLASS
 
 objUNO
 
 cstSymEmpty
 
 cstSymNull
 
 cstSymMissing
 
 servicesmodules
 
- Static Public Attributes inherited from scriptforge._Singleton
dictionary instances = {}
 

Detailed Description

    The ScriptForge (singleton) class encapsulates the core of the ScriptForge run-time
        - Bridge with the LibreOffice process
        - Implementation of the inter-language protocol with the Basic libraries
        - Identification of the available services interfaces
        - Dispatching of services
        - Coexistence with UNO

    It embeds the Service class that manages the protocol with Basic

Definition at line 81 of file scriptforge.py.

Constructor & Destructor Documentation

◆ __init__()

def scriptforge.ScriptForge.__init__ (   self,
  hostname = '',
  port = 0 
)
    Because singleton, constructor is executed only once while Python active
    Arguments are mandatory when Python and LibreOffice run in separate processes
    :param hostname: probably 'localhost'
    :param port: port number

Definition at line 132 of file scriptforge.py.

References scriptforge.ScriptForge.componentcontext, scriptforge.ScriptForge.ConnectToLOProcess(), scriptforge.ScriptForge.ScriptProvider(), scriptforge.SFScriptForge.SF_Array.servicename, scriptforge.SFScriptForge.SF_Basic.servicename, scriptforge.SFScriptForge.SF_Dictionary.servicename, scriptforge.SFScriptForge.SF_Exception.servicename, scriptforge.SFScriptForge.SF_FileSystem.servicename, scriptforge.SFScriptForge.SF_L10N.servicename, scriptforge.SFScriptForge.SF_Platform.servicename, scriptforge.SFScriptForge.SF_Region.servicename, scriptforge.SFScriptForge.SF_Session.servicename, scriptforge.SFScriptForge.SF_String.servicename, scriptforge.SFScriptForge.SF_TextStream.servicename, scriptforge.SFScriptForge.SF_Timer.servicename, scriptforge.SFScriptForge.SF_UI.servicename, scriptforge.SFDatabases.SF_Database.servicename, scriptforge.SFDatabases.SF_Datasheet.servicename, scriptforge.SFDialogs.SF_Dialog.servicename, scriptforge.SFDialogs.SF_NewDialog.servicename, scriptforge.SFDialogs.SF_DialogControl.servicename, scriptforge.SFDocuments.SF_Document.servicename, scriptforge.SFDocuments.SF_Base.servicename, scriptforge.SFDocuments.SF_Calc.servicename, scriptforge.SFDocuments.SF_CalcReference.servicename, scriptforge.SFDocuments.SF_Chart.servicename, scriptforge.SFDocuments.SF_Form.servicename, scriptforge.SFDocuments.SF_FormControl.servicename, scriptforge.SFDocuments.SF_FormDocument.servicename, scriptforge.SFDocuments.SF_Writer.servicename, scriptforge.SFWidgets.SF_Menu.servicename, scriptforge.SFWidgets.SF_PopupMenu.servicename, scriptforge.SFWidgets.SF_Toolbar.servicename, and scriptforge.SFWidgets.SF_ToolbarButton.servicename.

Member Function Documentation

◆ ConnectToLOProcess()

def scriptforge.ScriptForge.ConnectToLOProcess (   cls,
  hostname = '',
  port = 0 
)
    Called by the ScriptForge class constructor to establish the connection with
    the requested LibreOffice instance
    The default arguments are for the usual interactive mode

    :param hostname: probably 'localhost' or ''
    :param port: port number or 0
    :return: the derived component context

Definition at line 156 of file scriptforge.py.

References uno.getComponentContext().

Referenced by scriptforge.ScriptForge.__init__().

◆ InvokeBasicService()

def scriptforge.ScriptForge.InvokeBasicService (   cls,
  basicobject,
  flags,
  method,
args 
)
    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 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
        [0]     The returned value - scalar, object reference or a tuple
        [1]     The Basic VarType() of the returned value
                Null, Empty and Nothing have different vartypes but return all None to Python
        Additionally, when [0] is a tuple:
        [2]     Number of dimensions in Basic
        Additionally, when [0] is a UNO or Basic object:
        [2]     Module (1), Class instance (2) or UNO (3)
        [3]     The object's ObjectType
        [4]     The object's ServiceName
        [5]     The object's name
        When an error occurs Python receives None as a scalar. This determines the occurrence of a failure
        The method returns either
            - the 0th element of the tuple when scalar, tuple or UNO object
            - a new Service() object or one of its subclasses otherwise

Definition at line 266 of file scriptforge.py.

References scriptforge.ScriptForge.InvokeSimpleScript().

◆ InvokeSimpleScript()

def scriptforge.ScriptForge.InvokeSimpleScript (   cls,
  script,
args 
)
    Create a UNO object corresponding with the given Python or Basic script
    The execution is done with the invoke() method applied on the created object
    Implicit scope: Either
        "application"            a shared library                               (BASIC)
        "share"                  a library of LibreOffice Macros                (PYTHON)
    :param script: Either
            [@][scope#][library.]module.method - Must not be a class module or method
                [@] means that the targeted method accepts ParamArray arguments (Basic only)
            [scope#][directory/]module.py$method - Must be a method defined at module level
    :return: the value returned by the invoked script, or an error if the script was not found

Definition at line 195 of file scriptforge.py.

References scriptforge.ScriptForge.library, scriptforge.ScriptForge.pythonhelpermodule, scriptforge.ScriptForge.scriptprovider, and scriptforge.ScriptForge.servicesdispatcher.

Referenced by scriptforge.ScriptForge.InvokeBasicService().

◆ ScriptProvider()

def scriptforge.ScriptForge.ScriptProvider (   cls,
  context = None 
)
    Returns the general script provider

Definition at line 185 of file scriptforge.py.

Referenced by scriptforge.ScriptForge.__init__().

◆ SetAttributeSynonyms()

def scriptforge.ScriptForge.SetAttributeSynonyms ( )
static
    A synonym of an attribute is either the lowercase or the camelCase form of its original ProperCase name.
    In every subclass of SFServices:
    1) Fill the propertysynonyms dictionary with the synonyms of the properties listed in serviceproperties
        Example:
             serviceproperties = dict(ConfigFolder = False, InstallFolder = False)
             propertysynonyms = dict(configfolder = 'ConfigFolder', installfolder = 'InstallFolder',
                                     configFolder = 'ConfigFolder', installFolder = 'InstallFolder')
    2) Define new method attributes synonyms of the original methods
        Example:
            def CopyFile(...):
                # etc ...
            copyFile, copyfile = CopyFile, CopyFile

Definition at line 335 of file scriptforge.py.

◆ unpack_args()

def scriptforge.ScriptForge.unpack_args (   kwargs)
static
    Convert a dictionary passed as argument to a list alternating keys and values
    Example:
        dict(A = 'a', B = 2) => 'A', 'a', 'B', 2

Definition at line 376 of file scriptforge.py.

Member Data Documentation

◆ basicdispatcher

string scriptforge.ScriptForge.basicdispatcher = '@application#ScriptForge.SF_PythonHelper._PythonDispatcher'
static

Definition at line 109 of file scriptforge.py.

◆ componentcontext

scriptforge.ScriptForge.componentcontext = None
static

Definition at line 98 of file scriptforge.py.

Referenced by scriptforge.ScriptForge.__init__().

◆ cstSymEmpty

scriptforge.ScriptForge.cstSymEmpty
static

Definition at line 120 of file scriptforge.py.

◆ cstSymMissing

scriptforge.ScriptForge.cstSymMissing
static

Definition at line 120 of file scriptforge.py.

◆ cstSymNull

scriptforge.ScriptForge.cstSymNull
static

Definition at line 120 of file scriptforge.py.

◆ hostname

string scriptforge.ScriptForge.hostname = ''
static

Definition at line 96 of file scriptforge.py.

◆ library

string scriptforge.ScriptForge.library = 'ScriptForge'
static

Definition at line 105 of file scriptforge.py.

Referenced by scriptforge.ScriptForge.InvokeSimpleScript().

◆ objCLASS

scriptforge.ScriptForge.objCLASS
static

Definition at line 118 of file scriptforge.py.

◆ objMODULE

scriptforge.ScriptForge.objMODULE
static

Definition at line 118 of file scriptforge.py.

◆ objUNO

scriptforge.ScriptForge.objUNO
static

Definition at line 118 of file scriptforge.py.

◆ port

int scriptforge.ScriptForge.port = 0
static

Definition at line 97 of file scriptforge.py.

◆ pythonhelpermodule

string scriptforge.ScriptForge.pythonhelpermodule = 'ScriptForgeHelper.py'
static

Definition at line 111 of file scriptforge.py.

Referenced by scriptforge.ScriptForge.InvokeSimpleScript().

◆ SCRIPTFORGEINITDONE

bool scriptforge.ScriptForge.SCRIPTFORGEINITDONE = False
static

Definition at line 100 of file scriptforge.py.

◆ scriptprovider

scriptforge.ScriptForge.scriptprovider = None
static

Definition at line 99 of file scriptforge.py.

Referenced by scriptforge.ScriptForge.InvokeSimpleScript().

◆ servicesdispatcher

scriptforge.ScriptForge.servicesdispatcher

Definition at line 253 of file scriptforge.py.

Referenced by scriptforge.ScriptForge.InvokeSimpleScript().

◆ servicesmodules

scriptforge.ScriptForge.servicesmodules
static
Initial value:
= dict([('ScriptForge.Array', 0),
('ScriptForge.Exception', 1),
('ScriptForge.FileSystem', 2),
('ScriptForge.Platform', 3),
('ScriptForge.Region', 4),
('ScriptForge.Services', 5),
('ScriptForge.Session', 6),
('ScriptForge.String', 7),
('ScriptForge.UI', 8)])

Definition at line 122 of file scriptforge.py.

◆ V_ARRAY

scriptforge.ScriptForge.V_ARRAY
static

Definition at line 116 of file scriptforge.py.

◆ V_BOOLEAN

scriptforge.ScriptForge.V_BOOLEAN
static

Definition at line 115 of file scriptforge.py.

◆ V_CURRENCY

scriptforge.ScriptForge.V_CURRENCY
static

Definition at line 115 of file scriptforge.py.

◆ V_DATE

scriptforge.ScriptForge.V_DATE
static

Definition at line 115 of file scriptforge.py.

◆ V_DOUBLE

scriptforge.ScriptForge.V_DOUBLE
static

Definition at line 114 of file scriptforge.py.

◆ V_EMPTY

scriptforge.ScriptForge.V_EMPTY
static

Definition at line 114 of file scriptforge.py.

◆ V_ERROR

scriptforge.ScriptForge.V_ERROR
static

Definition at line 116 of file scriptforge.py.

◆ V_INTEGER

scriptforge.ScriptForge.V_INTEGER
static

Definition at line 114 of file scriptforge.py.

◆ V_LONG

scriptforge.ScriptForge.V_LONG
static

Definition at line 114 of file scriptforge.py.

◆ V_NULL

scriptforge.ScriptForge.V_NULL
static

Definition at line 114 of file scriptforge.py.

◆ V_OBJECT

scriptforge.ScriptForge.V_OBJECT
static

Definition at line 115 of file scriptforge.py.

◆ V_SINGLE

scriptforge.ScriptForge.V_SINGLE
static

Definition at line 114 of file scriptforge.py.

◆ V_STRING

scriptforge.ScriptForge.V_STRING
static

Definition at line 115 of file scriptforge.py.

◆ V_UNO

scriptforge.ScriptForge.V_UNO
static

Definition at line 116 of file scriptforge.py.

◆ V_VARIANT

scriptforge.ScriptForge.V_VARIANT
static

Definition at line 116 of file scriptforge.py.

◆ Version

string scriptforge.ScriptForge.Version = '7.6'
static

Definition at line 106 of file scriptforge.py.


The documentation for this class was generated from the following file: