Commit Graph
16 Commits
Author SHA1 Message Date
Jean-Pierre Ledure c1f5d07f35 ScriptForge - (scriptforge.py) Session class
Full support of the session class methods from Python

The InvokeSimpleScript() python method has been
extended to support broader scopes (extensions and user documents)
and ParamArray arguments in Basic.

Indeed the SF_Session.ExecuteBasicScript() and
SF_Session.ExecuteCalcFunction() require a varying number
of arguments.

No regression found in unit tests

Change-Id: I0899bc6535b00340ed82b46336d60a7bb23b2098
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113154
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2021-03-26 17:31:39 +01:00
Jean-Pierre Ledure 137b087998 ScriptForge - (scriptforge.py) String class
Only a subset of the available methods is implemented:
  HashStr, IsADate, IsEmail, IsFileName, IsIBAN,
  IsIPv4, IsLike, IsSheetName, IsUrl,
  SplitNotQuoted, Wrap

The other methods are better replaced by Python builtin
functions.

The flgDateArg flag has been introduced to distinguish
a date argument passed as a string that does not require
conversion from a date  passed in iso-format that
requires a conversion to a Basic variable of type Date

Change-Id: I80f7e816dfeaee793862f3c3d35488da7c573c8f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113002
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2021-03-24 18:38:42 +01:00
Jean-Pierre Ledure 83bee81c52 ScriptForge - (scritforge.py) SF_Basic: review of function signatures
The signatures of standard Basic built-in functions were
derived from the Help documentation.

They appeared to be inexact.

They now comply with
    core/basic/source/runtime/stdobj.cxx

Change-Id: I343fb553f5fad5236d75f6b72910714d47b6a289
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112669
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2021-03-18 15:39:01 +01:00
Jean-Pierre Ledure 8c04c9b3c7 ScriptForge - (scriptforge.py) Array class
The SF_Array (Basic) class is highly redundant with the
Python tuple/list classes.

Hence only 1 method is implemented in Python:
    ImportFromCSVFile()
to have the same csv files imported identically
in both environments.
The returned value is a tuple of tuples.

Restriction: dates are recognized but converted to their ISO format.
Up to the user to interpret them correctly.

Change-Id: I6611964a8083a9d7c6f9622b2aef64fe8b1491ea
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112585
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2021-03-17 18:11:23 +01:00
Jean-Pierre Ledure 8570a945f2 ScriptForge - (scriptforge.py) Exception class
The SF_Exception class is not intended to replace or complement
the builtin Python exception handling.
Hence it implements only a subset of the corresponding
Basic service.

- no properties: they are fully related to Basic error trapping
- next methods are available: Console, ConsoleClear, ConsoleToFile,
  DebugPrint and RaiseFatal (reserved for internal use)
Restriction: Console() does not work in non-modal mode.

DebugPrint formats its messages by using the repr() builtin method.
DebugPrint outputs from Basic or from Python are mixed within
the same console.
The other methods call their Basic counterpart.

A new method has been added both in Python and Basic: DebugDisplay
It combines DebugPrint with a display in a message box of the
arguments.

Change-Id: Iba94ab951b95b409c881ac17560476d6e9bc2fc2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112570
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2021-03-16 13:08:05 +01:00
Jean-Pierre Ledure 2e5055ed46 ScriptForge - (scriptforge.py) Dictionary class
The new SF_Dictionary class subclasses the dict native Python class
and implements 2 methods:
- ConvertToPropertyValues()
- ImportFromPropertyValues()

Usage:
 dico = dict(A = 1, B = 2, C = 3)
 myDict = CreateScriptService('Dictionary', dico)  # Initialize myDict with the content of dico
 myDict['D'] = 4
 print(myDict)   # {'A': 1, 'B': 2, 'C': 3, 'D': 4}
 propval = myDict.ConvertToPropertyValues()
or, alternatively:
 dico = dict(A = 1, B = 2, C = 3)
 myDict = CreateScriptService('Dictionary')  # Initialize myDict as an empty dict object
 myDict.update(dico) # Load the values of dico into myDict
 myDict['D'] = 4
 print(myDict)   # {'A': 1, 'B': 2, 'C': 3, 'D': 4}
 propval = myDict.ConvertToPropertyValues()

Change-Id: I932e899062c39f3fe8ab05dcf3cd02acf2f060a8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112488
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2021-03-15 15:51:09 +01:00
Andrea Gelmini 24b1067502 Fix typos
Change-Id: Ied3445430ffefbf27674f103c879a606909c9b3f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112478
Tested-by: Jenkins
Reviewed-by: Andrea Gelmini <andrea.gelmini@gelma.net>
2021-03-14 22:44:16 +01:00
Jean-Pierre Ledure 082d4741fe ScriptForge - (scriptforge.py) enhance property and method naming
To make the access to services more close to Python habits
and to better attract Basic users to Python, the convention
for attributes naming has been enhanced:

- property names may be ProperCased, camelCased or lowercased
- method names may be ProperCased, camelCased or lowercased
  Their arguments are always lowercased
In documentation examples, the camelCased notation will be privileged

Synonyms for properties are managed with generic functions.
The generic getter and setter has been reviewed accordingly.

Method synonyms are hardcoded.

The management of synonyms for servicenames have also been
reviewed to be defined in each class i.o. centrally and hardcoded
in CreateScriptService()

Change-Id: Id8d3181118b1e61937e2412109bd0d1eedd6f5e6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112470
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2021-03-14 14:43:03 +01:00
Jean-Pierre Ledure 42f05d000a ScriptForge - (scriptforge.py) Platform class
Addition of SF_Platform class

Most properties are provided by a direct call to
ScriptForgeHelper.py

Others result from an interaction with the Basic-Python  machinery

Addition of STarDesktop() method in the SF_Basic class

Change-Id: If1c03fe8e0ad36b6a665c8c44b477eca7cbc24bc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112393
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2021-03-13 13:12:00 +01:00
Jean-Pierre Ledure 1f842e3aa0 ScriptForge - (scriptforge.py) L10N class
Addition of SF_L10N class

Correction in Languages() property:
selection of file based on *.po filter i.o. ??-??.po

Change-Id: I5c57d1973265f2aeb7a3cfb4f507ffd50a28785a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112211
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2021-03-10 16:28:15 +01:00
Jean-Pierre Ledure 055ba70145 ScriptForge - (scriptforge.py) FileSystem and TextStream classes
Addition of SF_FileSystem and SF_TextStream classes

Machinery tuning:
- freeze a predefined list of standard modules
in the python persistent storage
- error management reviewed to mimic Basic behaviour on wrong
arguments

Standard modules are predefined in scriptforge.py as well

Both lists must be synchronized on a hardcoded entry number

Basic has minor revisions:
- complex boolean expressions return -1 and 0 to Python
i.o. True and False => Add a CBool() function
- [User]TemplatesFolder properties of FileSystem omitted the final "/"

Change-Id: Ice138de956f5f87269557cdb3db023849081b99d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112199
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2021-03-09 15:36:32 +01:00
Andrea Gelmini 476a37f76c Fix typos
Change-Id: I0a6b74356bd689b54883efc4608a06fb9446e828
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112024
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
2021-03-07 12:26:46 +01:00
Jean-Pierre Ledure f66a479225 ScriptForge - (scriptforge.py) Python-Basic machinery
Python scripts can now invoke usual Basic builtin functions
Example:
    from ScriptForge import CreateScriptService
    bas = CreateScriptService('Basic')
    bas.MsgBox('This is the text to be displayed', bas.MB_ICONEXCLAMATION)

Python scripts can use most ScriptForge services written in Basic
Example:
    from scriptforge import CreateScriptService
    FSO = CreateScriptService('FileSystem')
    a = FSO.BuildPath('/tmp', 'xyz')
Syntax and semantic are as close as possible to the Basic syntax

Implemented are a SFServices class and its subclasses representing each
a ScriptForge service and where the interfaces are defined (properties,
methods and arguments)

Their execution goes through the "machinery", i.e. a set of python
and basic routines that manage the call from the python process to
the appropriate service in an as much agnostic and generic way

Only a limited set of services are implemented so far: SF_FileSystem
(partially) and SF_Timer: they served as prototypes and initial tests

Change-Id: I0b383b59359c12710e7165139e498cca5a7856bb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111971
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2021-03-05 10:26:51 +01:00
Jean-Pierre Ledure 4b448758a9 ScriptForge - (SF_Platform) new Locale and PythonVersion properties
- 'Locale' returns a la-CO (language-COUNTRY) string
   derived from com.sun.star.lang.Locale
- 'PythonVersion' returns Python major.minor.patchlevel
   supplied by ScriptForgeHelper.py platform class

Change-Id: I2b8495c03253b17c5e4ba14765b1f359eee67813
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111284
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2021-02-21 17:06:18 +01:00
Jean-Pierre Ledure 19e5606df7 ScriptForge - (ScriptForgeHelper.py) add empty list of visible routines
The g_exportedScripts  variable contains the list of the methods
in the script that may be made visible in LO IDE's
(APSO and alike)

Currently that list (in fact, a tuple) must be empty

Change-Id: I86abc0bb55be524a3f9d39da7c6bd248abec8668
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109435
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2021-01-16 14:35:47 +01:00
Jean-Pierre Ledure a0dedcb23c ScriptForge - python helper functions
Change-Id: Id12a40afcba8034ed85218d78cb832a87c0d6af7
2020-11-05 16:51:34 +01:00