Commit Graph
163 Commits
Author SHA1 Message Date
Jean-Pierre Ledure e0935e73bb ScriptForge - Upgrade to version 25.8
Hard-coded version numbers are modified
from 25.2 to 25.8.

Many changes in po files due to the alphabetical
sequence of keys after the introduction of the
new "case-sensitive" keys feature.
Before this the dict.Keys() method delivered
the keys as an array in the order of creation.

No effect on actual user scripts.

Change-Id: Iee0c48eca22d17ad892278398c9125912b8b2b3c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180120
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
2025-01-11 16:00:11 +01:00
Andrea Gelmini bce744550d Fix typo
Change-Id: I0b9be4ea10c3837007158771fde46ad70e5c52a8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177785
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
2024-12-05 16:11:06 +01:00
Jean-Pierre Ledure d28fcb3e26 ScriptForge (SF_Session) enhance ExecuteCalcFunction
The ExecuteCalcFunction() method is a wrapper
of the
   com.sun.star.sheet.FunctionAccess::callFunction()
method.

This method accepts a broad variety of arguments
- scalars: numeric and strings only
- data arrays (= arrays os arrays)
- 2D arrays (1D arrays give errors)
- com.sun.star.table.XCellRange objects
depending on the called function and its
execution or not as an "array function".

The actual commit makes that the arguments passed to
   session.ExecuteCalcFunction()
are checked as formally correct: scalars are filtered
as numeric or strings, dates and booleans are converted,
arrays are reshaped to 2D where necessary.

The actual change facilitates, as an example,
the use of complex array functions like XLOOKUP,
a powerful search engine on large data sets.

The implemented functionalities are valid in Basic
and Python.

The help documentation might be completed with
additional examples.

Change-Id: I6bba1e21828ef09c5c6f0463cbcfa1f5df695073
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177744
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2024-12-04 10:21:45 +01:00
Jean-Pierre Ledure e74b731c80 scriptforge.pyi - Fix typo
Change-Id: I993e30d3d228c639a69007a846b46f420f9297b3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175097
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2024-10-18 13:38:18 +02:00
Andrea Gelmini 85e4167c64 Fix typo
Change-Id: I2d58d52d5f331ae9b3f3c4d3dc91d86c075c2a39
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174968
Tested-by: Jenkins
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
2024-10-15 19:29:14 +02:00
Jean-Pierre Ledure 0f74a4c2bf scriptforge.py Color args in exception.PythonShell()
The
   exception.PythonShell()
method opens the APSO console.

It receives 2 additional arguments
   background
   foreground
which specify the back- and foreground colors
of the window to open as a Python console.

Typical use of the method:
   exc.PythonShell({**globals(), **locals()}, \
       background = 0x0, foregound = 0xFFFFFF)
opens the shell with all existing variables
loaded and with white characters on a black
background.

The default values are those set in APSO:
   background = 0xFDF6E3
   foreground = 0x657B83
No impact on existing scripts.

The current change requires to be completed with
the addition of the 2 arguments in the
adequate help page.

Additonal minor changes
- typo in scriptforge.pyi
- 'outsideprocess' replaced by 'remoteprocess'

Change-Id: I9b1be123f049aa39bd0d814b6dd63fcc4f4ea310
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174897
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2024-10-15 11:00:38 +02:00
Jean-Pierre Ledure af67aa7cc9 scriptforge.py - clarify pipe mode
Introduction of a
  ScriptForge.outsideprocess
property: when True the actual mode
is via socket or via pipe.

The property is for internal use only.
Once set it cannot be changed anymore.

Previous statements similar to
   if ScriptForge.port > 0:
which returned True when socket mode
are replaced by a broader
   if ScriptForge.outsideprocess:

No effect on user scripts.

Change-Id: Ice0efd8c2ab9925511fc8c6889cab714fd208ba1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174874
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2024-10-14 10:25:03 +02:00
Jean-Pierre Ledure 74b79b7ac1 scriptforge.pyi - Typo
Change-Id: Ieff7ec790c457b1f4f67544d3f300fc68723d5aa
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174393
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
2024-10-02 17:53:55 +02:00
Jean-Pierre Ledure acbbf33d67 scriptforge.py - improve debugging mode
To facilitate the debugging of the
ScriptForge Basic code called by the
python scripts, 2 methods have been
added to the ScriptForge() class:

- initializeRoot(force = False)
  Initialize the global scriptforge
  data structure.
  - When force = False, only when
    not yet done.
  - When force = True, reinitialize it
    whatever its status.

- errorHandling(standard = True)
  Determine how errors in the ScriptForge
  Basic code are handled. Either
  - the standard mode, i.e. display a "crash" message
    to the user
  - the debugging mode, i.e. the execution stops
    on the line causing the error

Example (cfr. tdf#162962)

from scriptforge import CreateScriptService, ScriptForge
sf = ScriptForge()
sf.errorHandling(False)

def testSF():
    srv = CreateScriptService("Calc")

g_exportedScripts = (testSF,)

Change-Id: I25d7d8e36e71d95ff8a04191bb8344794886d69e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173458
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
2024-09-17 12:58:10 +02:00
Jean-Pierre Ledure 0419b8c8f9 scriptforge.py Connect via pipe
Python scripts using ScriptForge start like:
   from scriptforge import CreateScriptService, \
           ScriptForge
   ScriptForge(...)		(*)
   sv = CreateScriptService(...)

The (*) statement has next syntaxes: either
   (1)   ScriptForge()
   (2)   ScriptForge(host: str = ..., port: int = ...)
   (3)   ScriptForge(pipe: str = ...)

Syntax (1) is implicit at the first invocation of
CreateScriptService() without a former call to
ScriptForge()

Syntax (2) exists in previous versions.

This commit implements syntax (3) to connect a Python
process to a LO process on the same system via a pipe
mechanism.

The change impacts only Python scripts.

The documentation should be upgraded to include
the new functionality.

Change-Id: I50457b6fffc8c9d6a9ad5c5289de1c363c6680e3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173252
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2024-09-13 15:04:17 +02:00
Jean-Pierre Ledure 609a6dc2df ScriptForge New IsAlive property
When a document is closed inadvertently
by the user during a macro run, or between
two macros triggered by events, the actual
behaviour is an error message and a stop
of the execution of the macro.

As this can be counter-productive, the macro
may test at any moment if everything is ok
with the
   IsAlive As Boolean (True = OK)
property applied on next service instances:
   Document
   Base
   Calc
   FormDocument
   Writer
   Datasheet
   Dialog

The functionality is available both for
Basic and Python user scripts.

The user documentation should be completed
accordingly.

Change-Id: I0b055dacc06c9da70c611dbb4e7bf841160168fd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172970
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
2024-09-08 14:25:35 +02:00
Jean-Pierre Ledure d2d14c36d1 ScriptForge (Database) DMin, DMax return strings or dates
Python only:

Reset a flag in SF_Database.DMin and DMax methods
to allow dates to be returned.

Review typing hints to accept strings and dates

Integration of remarks from Microsoft/VSCode
about minor syntax issues in scriptforge.pyi
(syntax was accepted by PyCharm).
Now, syntax commonly accepted by both IDE's.

Change-Id: I752d9f1d7a5293222d81748f8fb2e8f46f4317de
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172912
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
2024-09-05 15:21:53 +02:00
Jean-Pierre Ledure 3f3ea3351c scriptforge.py - Platform & TextStream
Since
  https://gerrit.libreoffice.org/c/core/+/172600
a better categorization of properties
has been done between 4 distinct levels.

The SF_Platform and SF_TextStream services
still needed an update to avoid
redundancy on some of their properties.

A choice had to be made, either:
- put them in the serviceproperties dict
- or define them explicitly with @Property
Not both, for clarity.

Change-Id: I787c7e57235622abf5deb5c7fd42c4c28aa82ec8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172863
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
2024-09-04 17:22:09 +02:00
Jean-Pierre Ledure 87bfd87ecf ScriptForge (scriptforge.py) fine tune getattr/setattr()
Several minor changes
- comments
- 'cls' used where relevant i.o. class name
- dynamic getting/setting properties reviewed
- SF_Platform properties:
  set level = 1 i.o. 0 when returned
  by PythonHelper module

Change-Id: I4e9877bc16efd340dc14693833c032c998329b6e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172836
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
2024-09-04 10:14:42 +02:00
Jean-Pierre Ledure f2f7dbb78c scriptforge.py Improve properties performance
When considering next python user script:
   a = CreateScriptService(...)
   a.prop = ...
   print(a.prop)
   print(a.prop)
so far, the evaluation of a.prop was done
either once or twice depending on
- a parameter of the class a is an instance of
- the read-only status of prop (True/False)

Now the recomputation of the expression
depends on a parameter of prop which can take
one of next values:
  0: prop is read-only and not re-evaluated
  1: prop is read-only but re-evaluated
     f.i. because a user action can change its value
  2: prop is editable and not re-evaluated
     f.i. because it can be changed only by code
  3: prop is editable and always re-evaluated

The change will decrease the number of useless
and more costly recomputations of properties.

Change-Id: I11412a58772147dab2e6b9b06c31477135932603
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172600
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2024-08-30 10:21:31 +02:00
Jean-Pierre Ledure 8a4ee0fb39 ScriptForge (SFWidgets) new ContextMenu service
Complete a predefined context menu with new items
placed at its bottom.

A context menu is obtained by a right-click
on several areas of a document. Each area has
its own context menu.
Each component model has its own set of context menus.

A context menu is usually predefined at
LibreOffice installation. Customization is done
statically with the Tools + Customize dialog.
The actual new service provides a mean
to make temporary additions at the bottom of a
context menu. Those changes are lost when
the document is closed.

The name of a context menu is the last component
of the resource URL:
   "private:resource/popupmenu/the-name-here"

Context menu items are either usual items or
line separators. Checkboxes or radio buttons
are not supported.
Items run a command or a script when clicked.

The service implements 2 methods:
   AddItem() adds an entry in the menu hierarchy
   Activate() shows or hides the added entries

A context menu can be defined from both Basic
and Python user scripts.

An update of the documentation is required.

Change-Id: Id77f1f2565d75e36c09b13972330d0f83b3f1db4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172355
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
2024-08-24 18:29:12 +02:00
Jean-Pierre Ledure e7aa613e75 ScriptForge - Upgrade to version 25.2
Change-Id: Icc7cbdeed7685118408896c52b0415310d7b20fd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171590
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
2024-08-07 16:14:59 +02:00
Ilmari Lauhakangas 129e69f005 testtools, wizards, xmlsecurity: fix issues found by Ruff linter
Change-Id: I03edbaa7c9a643ca7503fa0e93c2bf0de3ac4e51
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171211
Tested-by: Ilmari Lauhakangas <ilmari.lauhakangas@libreoffice.org>
Tested-by: Jenkins
Reviewed-by: Ilmari Lauhakangas <ilmari.lauhakangas@libreoffice.org>
2024-07-29 16:56:57 +02:00
Andrea Gelmini 55bf8a21d0 Fix typo
Change-Id: I67c1591af46b530c3cbf46b0871d863a5c0aec24
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164907
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
2024-03-16 19:51:03 +01:00
Andrea Gelmini 08750535c5 Fix typo
Change-Id: Ie04b3b3a96b2d4651b6dc477215f29a48c1be4c5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164901
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
2024-03-16 19:50:47 +01:00
Andrea Gelmini a0d5d8d165 Fix typo
Change-Id: I1264c4594bbedf7398816552795e33c489ef2863
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164902
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
2024-03-16 19:50:27 +01:00
Andrea Gelmini 3764ae10f8 Fix typo
Change-Id: I8c5c281897c53afb456b63c5f3838059bd1887d3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164912
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
2024-03-16 19:49:54 +01:00
Andrea Gelmini 42a01a525b Fix typo
Change-Id: Iac27e35e92ec8f481d0d6ba71c87f72e10a99ffb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164910
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
2024-03-16 19:49:23 +01:00
Andrea Gelmini 5569de72d7 Fix typo
Change-Id: I07c180c9b659950fa0ecc4bf8ca26f2d133a393c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164913
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
2024-03-16 19:48:44 +01:00
Andrea Gelmini d845d151fd Fix typo
Change-Id: I5bece7e286f8ebced0f5f45fff7377037b546a37
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164918
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
2024-03-16 19:47:47 +01:00
Andrea Gelmini da7c50f6f7 Fix typo
Change-Id: I0db6ac0b9edfd6953d668dd0949c692630665a2f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164915
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
2024-03-16 19:47:34 +01:00
Andrea Gelmini 66567a0bcd Fix typo
Change-Id: I3620d218898a91293d57611d4dcf062f75045892
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164897
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Julien Nabet <serval2412@yahoo.fr>
2024-03-16 19:47:17 +01:00
Andrea Gelmini c1215a2e08 Fix typo
Change-Id: I0a68811af1f5b9d32f453592ec357fa694747d35
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164909
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Julien Nabet <serval2412@yahoo.fr>
2024-03-16 19:46:56 +01:00
Andrea Gelmini b360a2b64f Fix typo
Change-Id: Ibb07cca05ef733932326ceb29aa3fd1cd1e969d4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164896
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Julien Nabet <serval2412@yahoo.fr>
2024-03-16 19:46:34 +01:00
Andrea Gelmini 3f9a557813 Fix typo
Change-Id: Id099d4e9471415d572f7eac56e70d20cbae8e577
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164906
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Julien Nabet <serval2412@yahoo.fr>
2024-03-16 19:46:08 +01:00
Andrea Gelmini 7abfe574e2 Fix typo
Change-Id: I42521b965da582e00e4fa9186bb5de3ea3defd4f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164905
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Julien Nabet <serval2412@yahoo.fr>
2024-03-16 19:45:46 +01:00
Andrea Gelmini d7d37ac32c Fix typo
Change-Id: I2e38b46435d927fe4fe8d656c92e7a75a5771ba1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164911
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Julien Nabet <serval2412@yahoo.fr>
2024-03-16 19:45:20 +01:00
Andrea Gelmini 7e0a186d18 Fix typo
Change-Id: I3f6f98e2781dd6ca37483ca4224b76f7b474a909
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164908
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Julien Nabet <serval2412@yahoo.fr>
2024-03-16 19:44:56 +01:00
Andrea Gelmini 36f6aea73f Fix typo
Change-Id: I5b5182b56259808e7c4c351f24510806bf79c9fa
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164916
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Julien Nabet <serval2412@yahoo.fr>
2024-03-16 19:44:32 +01:00
Andrea Gelmini 5640b1b0d3 Fix typo
Change-Id: I58ae1ae35bef53a79dfb60ac17b485e7e22a8d87
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164900
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Julien Nabet <serval2412@yahoo.fr>
2024-03-16 19:44:11 +01:00
Andrea Gelmini c68303fb07 Fix typo
Change-Id: I6e332fc1366cf6cc20f7d4bbb546996bcfcfc6f6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164919
Tested-by: Julien Nabet <serval2412@yahoo.fr>
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
2024-03-16 19:43:42 +01:00
Andrea Gelmini 7c42fca202 Fix typo
Change-Id: I5c2075d5c3e87fe5e4f56d884bf7bcfb7371498b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164917
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Julien Nabet <serval2412@yahoo.fr>
2024-03-16 19:42:52 +01:00
Andrea Gelmini 26785eed76 Fix typo
Change-Id: Ib1f5fdc8c44c62619325f6d21d834459905fab44
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164921
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
2024-03-16 19:42:08 +01:00
Andrea Gelmini 5b7e83ddb0 Fix typo
Change-Id: I54dff81d7dffda684f3e39a5ebf1dda06959b9dd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164920
Tested-by: Julien Nabet <serval2412@yahoo.fr>
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
2024-03-16 19:41:44 +01:00
Andrea Gelmini 85eb0d1394 Fix typo
Change-Id: I965793a29a92eedb5555b541a22b5be0350c6b98
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164923
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Tested-by: Julien Nabet <serval2412@yahoo.fr>
2024-03-16 19:38:12 +01:00
Andrea Gelmini da56c68f5a Fix typo
Change-Id: I493fece1547f15d1e428146928e34807a96636a5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164914
Tested-by: Julien Nabet <serval2412@yahoo.fr>
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
2024-03-16 19:37:42 +01:00
Andrea Gelmini 5208cc2995 Fix typo
Change-Id: Ic25c4b9fe4fe898de328f1ea98ef69983c66a7c0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164904
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
2024-03-16 13:00:38 +01:00
Andrea Gelmini 4640cec920 Fix typo
Change-Id: I794f03ec9fe6cc7f1adfe790432a3e252da54b70
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164903
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
2024-03-16 13:00:24 +01:00
Andrea Gelmini ff7ed8ccca Fix typo
Change-Id: I8c2e3dcfddd27aa7d32feb7a3c7923b411cdafa6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164899
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
2024-03-16 13:00:11 +01:00
Andrea Gelmini effb43e5ac Fix typo
Change-Id: I26ad4b2cc6738087bb9cbae6eb5e852d7d520c05
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164898
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
2024-03-16 12:59:58 +01:00
Jean-Pierre Ledure c5e0c65bd2 ScriptForge - Python typing hints
Python typing hints may be stored either
- inside the original .py source file
- in a separate .pyi source file (aka. STUB).
Choice is made to create a new scriptforge.pyi file
- to allow hiding the private functions
- to specialize each module: technical doc
  vs. user doc
- to allow potential later translation
- to minimize the impact at run-time:
  stubs are active only during code edition.

The new scriptforge.pyi module
- provides the static type checking of all the public
  interfaces (methods/properties) of the ScriptForge API.
- when the user uses an IDE like PyCharm or VSCode,
  (s)he might benefit from the typing hints provided
  by the signatures and docstrings stored
  in the module.

Visually, while editing a user script:
- hovering an object instance, a method or a property
  displays its detailed description
- a "." after an object instance displays a drop-down
  box listing all available interfaces
- brackets after a method-name start code-completion
  by displaying its arguments.

Limitations: SF supports ProperCase, lowercase and
camelCase naming for methods and properties.
Only ProperCase is described in scriptforge.pyi.
Extending to the other 2 notations would be easy
but would also overload needlessly the drop-down lists.

The effective code (scriptforge.py) is completed
with a series of importable variable types,
corresponding roughly with the available service
instance names in uppercase. Example
       from scriptforge import CALC, RANGE
       def userfct(c: CALC, r: RANGE) -> RANGE:
           r1: RANGE = "A1:K10"
Objective: enrich the signatures in user scripts
and benefit from the same hints when the variable
types cannot be derived from the context.

The help documentation should be complemented
with the actual additional feature.

Change-Id: I6c39939a3cdbed94828e9449cd691fe15c24c923
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164867
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
2024-03-15 17:27:00 +01:00
Jean-Pierre Ledure 5fc9908b95 ScriptForge - Upgrade to version 24.8
Copyright years are also reviewed to include 2024.

Change-Id: I1f30443922a6dc3b35c6f05616a5c4e56de1e396
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161277
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
2023-12-25 14:10:36 +01:00
Jean-Pierre Ledure 9b5b313a2f ScriptForge (SF_Database) manage transactions
Transactions are managed by next UNO properties:
   XConnection.AutoCommit
   XConnection.TransactionIsolation
(They seem very easy to use but, in practice,
are not easy at all)

Usually all transactions are in auto-commit mode,
that means, a commit takes place after each
single SQL command.

Switching auto-commit off  means however that
the connection needs to be of type "ISOLATED"
and not of the default type "SHARED".

=> The usual shared connection must be closed.
   As a consequence, all rowsets/resultsets linked
   to the shared connection need to be closed as well.
=> Additionally the buffers must be emptied (flushed)
   to make committed data visible in the Base user
   interface.

All above aspects and constraints are managed in the
   database.SetTransactionMode(transactionmode)
   database.Commit()
   database.Rollback()
methods transparently for the user scripts.

The [transactionmode] argument has as value one of
the TransactionIsolation constants.
Without argument, database.SetTransactionMode()
restores the automatic mode.

The manual transaction mode is available for both
Basic and Python scripts.
Its implementation will require an update of the
documentation about the Database service.

Change-Id: I214bd91a1744d6d24609bc5efc987152c6e946c9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159867
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
2023-11-24 09:54:59 +01:00
Jean-Pierre Ledure 5dac0fe157 ScriptForge (SFDatabases) fix dates processing in GetRows
The
   database.GetRows()
   dataset.GetRows()
methods return an array of data collected
in a database table or query.

When a column has the type DATE, the transmission
of their values through the Basic-Python bridge
require them to be converted upfront to UNO
DateTime structures.

The later conversion from UNO DateTime to the python
datetime.datetime structure has been added with
this patch.

No impact on Basic scripts.

The documentation does not need to be changed.

Change-Id: I7a6533aff70d2d1402bfc3f057b65a4940148cc4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159348
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
2023-11-12 17:44:55 +01:00
Jean-Pierre Ledure 7b2a6f0444 ScriptForge (SFDatabases) new Dataset service
A dataset represents a set of tabular data
stored/produced by a database.
To use datasets, the database instance must exist
but the Base document may not be open.

A Dataset instance is create either with
- the (new) database.CreateDataset() method
- from an existing dataset with the (new)
  dataset.CreateDataset() method.

The proposed API supports next main purposes:
- browse for- and backward thru the dataset to get its content
- update any record with new values
- create new records or delete some.
In summary, the AKA "CRUD" operations
(create, read, update, delete).

The originality of the proposed API is the use
of a dense syntax to make insertions and updates
easy and readable:
Example:
(BASIC)
  Dim newID As Long
  newID = dataset.Insert("LastName", "Doe", "FirstName", "John")
  '     ... is equivalent to:
  Dim dict As Object, newID As Long
  Set dict = CreateScriptService("ScriptForge.Dictionary")
  dict.Add("LastName", "Doe")
  dict.Add("FirstName", "John")
  newID = dataset.Insert(dict)
(PYTHON) - next statements are equivalent
  newid = dataset.Insert('LastName', 'Doe', 'FirstName', 'John')
  newid = dataset.Insert({'LastName': 'Doe', 'FirstName': 'John'})
  newid = dataset.Insert(dict(LastName = 'Doe', FirstName = 'John'))
  newid = dataset.Insert(LastName = 'Doe', FirstName = 'John')

You will notice that the returned value is the AutoValue primery
key (when it exists) which makes it reuse as a foreign key
immediate.

The API is fully available both in Basic and Python user scripts.

The new service will require its inclusion in the user documentation.

Change-Id: I4f834c4234e5b96ec8fddfffbad791ecf31899df
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159325
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
2023-11-11 18:20:15 +01:00