Commit Graph
58 Commits
Author SHA1 Message Date
Jean-Pierre Ledure a97227aeb4 ScriptForge - (SF_Calc) new XSheetCellCursor property
The XSheetCellCursor property requires one mandatory argument,
a range as a string.

It returns a UNO object of type com.sun.star.sheet.XSheetCellCursor.
Such an object is designed to navigate thru the spreadsheet.

After the user script has used one or more navigation verbs
(gotoNext(), ...) the resulting range can be got back in the
script by using the cursor.AbsoluteName UNO property.
The new range can be given as input to further ScriptForge
methods.

XSheetCellCursor is available both from Basic and Python user scripts.

Change-Id: I62fb18a6f496d81b01036aef2ca6733f07632d9d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124280
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2021-10-28 10:47:52 +02:00
Jean-Pierre Ledure f73196867b ScriptForge - (SF_Calc) new Region() property
The Region() property expects one mandatory argument,
a range given as a string.

It returns a new range as a string, including the sheet name,
corresponding with the smallest area
- containing the input range
- completely surrounded with empty cells

It is complementary to Offset() and A1Style() to make easy the
definition of new ranges relative to known ranges

The property is available both in Basic and Python user scripts.

Change-Id: Ifc9ce07b76e72fe580baf2c8103387cab56a6ef0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124230
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2021-10-27 12:49:44 +02:00
Jean-Pierre Ledure 6a1feb2644 ScriptForge - (SF_Calc) new A1Style() method
Returns a range expressed in A1-style as defined by its coordinates
If only one pair of coordinates is given, the range will embrace only a single cell

Arguments:
   Row1 : the row number of the first coordinate
   Column1 : the column number of the first coordinates
   Row2 : optional, the row number of the second coordinate
   Column2 : optional, the column number of the second coordinates
   SheetName: Default = the current sheet. If present, the sheet must exist

Is complementary to the Offset() method to compute ranges easily

Available both from Basic and Python user scripts

Change-Id: Ib9323441bbd579beb867329c8b0930653462d00e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124093
Tested-by: Jenkins
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2021-10-25 11:06:54 +02:00
Jean-Pierre Ledure 78db0dcfb6 ScriptForge - new SFWidgets library, new PopupMenu service
The SFWidgets library is intended to host the Toolbar,
ToolbarControl (both future) and PopupMenu services.

A popup menu is usually triggered by a mouse action
(typically a right-click) on a dialog, a form, or one of their controls.
In these cases the menu will be displayed below the clicked area.

When triggered by other events, including in the normal flow
of a user script, the script should provide the coordinates
of the topleft edge of the menu versus the actual component.

The menu is described from top to bottom with next methods:
   AddItem()
   AddCheckBox()
   AddRadioButton()
Example:
   .AddCheckBox("View>Toolbars>Dialog")
   .AddCheckBox("View>Toolbars>Find", Status := True)
   .AddCheckBox("View>Status Bar", Status := True)
   .AddItem("View>Full Screen", Name := "FULLSCREEN")
The SubmenuCharacter (Default = ">") is modifiable.

Each menu item receives a numeric and a string identifier.
The execute() method returns the item selected by the user.

The service is available both from Basic and Python user scripts.

The commit includes the review of build files to include
the new library and the new modules.

Change-Id: I2940be25313cc8fff7b337766edd348b04a20584
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123654
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2021-10-15 16:39:48 +02:00
Jean-Pierre Ledure 0bcc4b55d7 ScriptForge - (SF_Platform) new Fonts property
The Fonts property returns the list of available fonts
as an unsorted array of unique font names

The size of the array being potentially huge, the choice
has been made to not sort the list at each invocation
of the property.
To get it sorted, use the SF_Array.Sort() method.

The property is available both from Basic and Python scripts.
It is read-only.

Change-Id: I49233d279dc7257d3b97e5a17be0bc8807f18d67
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122780
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2021-09-28 19:11:00 +02:00
Jean-Pierre Ledure 552a1f30ec ScriptForge - add AddTextsFromDialog and GetTextsFromL10N methods
The objective is to facilitate the automatic translation of
all fixed texts in dialogs and dialog controls.

Concerned items are:
- the title of the dialog
- the caption associated with next control types:
  Button, CheckBox, FixedLine, FixedText, GroupBox and RadioButton
- the content of list- and comboboxes
- the tip- or helptext displayed when the mouse is hovering the
  control

ScriptForge.SF_L10N.AddTextsFromDialog(dialog)
  store all fixed texts of the dialog in the list of translatable
  strings of a L10N object to prepare a POT file

SFDialogs.Dialog.GetTextsFromL10N(l10n)
  get the translated versions of all fixed texts in the dialog from
  a L10N object and apply them on the dialog before display

Both methods are executable from Basic and Python user scripts

Change-Id: I3dc9fbbce287d7af4040df713f9d11e0ff928b1c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121514
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2021-09-03 14:53:27 +02:00
Jean-Pierre Ledure e4a3c4ba51 ScriptForge - (SF_DialogControl) add management of table controls in dialogs
With the method SetTableData(), feed a tablecontrol
with a sortable and selectable array of data.
Columns and rows may receive a header.
Column widths are adjusted manually by the user or
with the same method.
Alignments can be set as well by script.

  oControl.SetTableData(DataArray, Widths, Alignments)
    DataArray: the set of data to display in the table control,
      including optional column/row headers
      Is a 2D array in Basic, is a tuple of tuples inPython
    Widths: the column's relative widths as a 1D array,
      each element corresponding with a column.
      If the array is shorter than the number of columns,
      the last value is kept for the next columns.
      Example:
        Widths := Array(1, 2)
      means that the first column is half as wide as all
      the other columns.
      When the argument is absent, the columns are evenly
      spreaded over the control.
    Alignments: the column's horizontal alignment as a string
      with length = number of columns.
      Possible characters are:
        L(EFT), C(ENTER), R(IGHT) or space (default behaviour)
      Default: LEFT for strings, RIGHT for numbers

Impact on existing properties: ListIndex, Value
New properties: XGridColumnModel, XGridDataModel

All properties and methods are available from user
scripts written either in Basic or in Python.

Change-Id: I70582cd0ba48ee3b9b9a292d8a47dbc1229b1fe6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121148
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2021-08-27 17:01:26 +02:00
Jean-Pierre Ledure 407b53dd22 ScriptForge - (PDF Export) get/set options, export as PDF file
Next methods are introduced in SF_Session:
  - GetPDFExportOptions to extract a dictionary of the
    40+ existing options for PDF export
  - SetPDFExportOptions to update the existing options
    When applied the options are permanent also for user manual exports
Those methods are not available in Python.

Next method to export a document to PDF:
  - ExportAsPDF: it uses the options set above and/or takes
    next specific and transitional options:
      pages, password, watermark
This method is implemented for use from Basic and Python

Change-Id: Ic5c4190cff579e62137930f422638aad98e61a16
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120740
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2021-08-19 17:16:59 +02:00
Jean-Pierre Ledure ef08207a29 ScriptForge - (SF_Chart) new service to manage Calc charts
New methods in the SF_Calc service:
  Charts(), to list charts or to instantiate a chart service
  CreateChart, to create a new chart in a given Calc sheet

The SF_Chart service has next properties to parameter the type
and the characteristics of the (new or pre-existing) chart
  ChartType, Deep, Dim3d, Exploded, Filled, Legend, Percent, Stacked,
  Title, XTitle, YTitle
Next methods are available:
  Resize, to move and resize the chart shape
  ExportToFile, to export the chart as a graphical object
    Supported: gif, jpeg, png, svg and tiff

New error messages in SF_Root and SF_Exception.
Corresponding labels are integrated in the POT file

Full support under Basic and Python

Review of make file of the SFDocuments library

Change-Id: Id8db3098ff24fbf2efcbdd9c6dcd4f02ff5972af
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119824
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2021-08-02 10:45:37 +02:00
Jean-Pierre Ledure 1908717ff7 ScriptForge - Change copyright dates and names
Change-Id: Iac45dca972c294ed3772bcdcd0b3f05484ce912a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119418
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2021-07-23 18:36:58 +02:00
Jean-Pierre Ledure 2d7c0af3c3 ScriptForge - (scriptforge.py/CreateScriptService) allow keyword arguments
For Python scripts only:

the CreateScriptService() method accepts now both positional
(as before) and keyword arguments.

The impacted services are:
- l10n
- timer

Done with the ReviewServiceArgs() class method that returns the
input arguments as a tuple in the correct sequence. This method
is inserted in each of the impacted service definitions.

Implied a review of the creation of the L10N service to
replace absent arguments by zero-length default arguments

Change-Id: I3cc3b98847a395a2fd9f5e5bb15f45b398858b12
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119359
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2021-07-22 12:03:20 +02:00
Jean-Pierre Ledure 2366c24ffe ScriptForge - (SF_Base) new CloseFormDocument() method
The closure of a form document is available from
the SF_Form service.

A form document is since recent commits associated with
actions like PrintOut() that do not require to access
its internal forms.

As a consequence, the closure of a form document from
the SF_Base service gains in relevance.

Hence the actual commit.

Change-Id: I9d4af078e6631d18c2d92c17249be6025ac9dfdd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118857
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2021-07-14 10:45:15 +02:00
Jean-Pierre Ledure a35b49c585 ScriptForge - (SFDocuments) new PrintOut() method
The PrintOut() method launches the printing of a
LO document to a printer previously defined by default,
by the user or by the SetPrinter() method.

It is applicable on any document, on a Calc sheet, a Base form
document. For a Writer document specific arguments may
be provided.

Implemented both for Basic and Python user scripts.

Change-Id: I51ce897b66d3e5624cec97a46e5eb28d9132357a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118786
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2021-07-13 08:59:19 +02:00
Jean-Pierre Ledure 90d33528ce ScriptForge - (SF_Document) new SetPrinter() method
The SetPrinter() method is applicable to any document type,
except Base documents.
It is also applicable to Base form documents with an
additional "FormDocument" argument.

Implemented in Basic and in Python.

The method defines next printer settings:
- the printer name
- the orientation
- the paper format

The settings are kept per document or form document

To bypass array management troubles in Basic,
the SF_Utils._SetPropertyValue() Sub is converted to a Function.
(no user scripts impact, only internal use).

Change-Id: I39290d924646ff3b2a65a6d9282f1265ca7543b7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118685
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2021-07-09 17:46:07 +02:00
Jean-Pierre Ledure f3657a886d ScriptForge - (SF_Writer) move Forms() method from SF_Document
The Forms() method was placed in the SF_Document service
but was applicable only on Writer documents

Now it is placed correctly in the recently created Writer service.
Effective in Basic and Python.

Additionally redundant parentheses have been removed in scriptforge.py

Change-Id: I0d328b40577ddf81a188fdf72611f84751bcb506
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118559
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2021-07-07 14:31:04 +02:00
Jean-Pierre Ledure c2d69eae17 ScriptForge - (SFDocuments) New SF_Writer service
Addition of the skeleton of the new SF_Writer service
as a subclass of SF_Document.

Entry points in CreateScriptService are provided
both for Basic and Python user scripts.

Full compatibility with existing user scripts.

Specific properties and methods will be provided in later
commits.

Change-Id: Ib00a9ea52023707d1429e8ad9dcb4dca2ca63174
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118515
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2021-07-07 09:55:20 +02:00
Jean-Pierre Ledure adc0c34bcf ScriptForge - (SF_Exception) new PythonPrint() method
Send from BASIC the arguments of the method to the
Python shell (APSO) console.
The same string is added to the ScriptForge debug console.

From PYTHON use simply the builtin print() statement instead.

Change-Id: Iac175b2f7c5773e0369361c3f26bbc33485848db
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118225
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2021-07-02 10:50:09 +02:00
Jean-Pierre Ledure 28ee6bc8cf ScriptForge - Backdoor to alternate Python helper script
While developing a new version of
    ScriptForgeHelper.py
the dev should be sure to invoke the new version
instead of the standard version shipped with its
LO release.

This can be done now by setting
- in Python a specific ScriptForge class property
    ScriptForge.pythonhelpermodule2 = 'user#QA/ScriptForgeHelper.py'
- in Basic a specific property of the root class
    _SF_.PythonHelper2 = "QA/ScriptForgeHelper.py"
both in the test script

Testing a new version of scriptforge.py can be configured
entirely from the test script by inserting next statements
    import sys
    sys.path.reverse()
    sys.path.append('/home/jean-pierre/.config/libreoffice/4/user/Scripts/python/QA')
    sys.path.reverse()

Change-Id: Iab6db518932e9dde9030b7e5bbe00a50dee31840
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118171
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2021-07-01 11:05:09 +02:00
Jean-Pierre Ledure 28c3228cf8 ScriptForge - (SF_Platform) new Printers property
The SF_Platform.Printers property returns the list of
available printers as a zero-based array.
The default printer is put in the 1st position of the
list (index = [0]).

The property is available in Basic and Python.

Change-Id: I3f02b1b5e37aa9866491d9285683fc45d17fb664
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117776
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2021-06-25 12:00:57 +02:00
Jean-Pierre Ledure 8467a8e058 ScriptForge - (SF_UI) CreateBaseDocument() new CalcFileName argument
Syntax of CreateBaseDocument() becomes
   FileName, [EmbeddedDatabase=HSQLDB|FIREBIRD|CALC],
   [RegistrationName=""], [CalcFileName]

Only when EmbedddedDatabase = "CALC", the new argument CalcFileName
represents the file containing the tables as Calc sheets.
The file must exist or an error is raised.

Example:
    Dim myBase As Object, myCalcBase As Object
    Set myBase = ui.CreateBaseDocument("C:\Databases\MyBaseFile.odb", "FIREBIRD")
    Set myCalcBase = ui.CreateBaseDocument("C:\Databases\MyCalcBaseFile.odb", _
        "CALC", , "C:\Databases\MyCalcFile.ods")

Both Basic and Python are supported.

Change-Id: I9912b110dcec12fe451a47abb61ab143fb543b94
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117665
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2021-06-22 18:10:01 +02:00
Jean-Pierre Ledure 7c0d8c646b ScriptForge - (scriptforge.py/CreateScriptService) allow keyword args
For Python scripts only:

the CreateScriptService() method accepts now both positional
(as before) and keyword arguments.

The impacted services are:
- database
- dialog
- document
- base
- calc

Done with the ReviewServiceArgs() class method that returns the
input arguments as a tuple in the correct sequence. This method
is inserted in each of the impacted service definitions.

Change-Id: I545ca5ef0a4e7946d598eed07a2122885e4f864a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117387
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2021-06-18 12:20:42 +02:00
Jean-Pierre Ledure 2a38a064df ScriptForge - Comments in code: pointers to help pages
Insert in each service module a pointer to the
help page on https://help.libreoffice.org
containing the user documentation of the given
service.

Example:
SF_Array.xba contains a pointer to next help page
https://help.libreoffice.org/latest/en-US/text/sbasic/shared/03/sf_array.html?DbPAR=BASIC

Only addition of comments lines.
No code change.

Change-Id: I83899d9fab247d23e2d5123378e2fb3fd0ade60e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117370
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2021-06-17 14:40:49 +02:00
Jean-Pierre Ledure ed7f1a6fb4 ScriptForge - Increment version number
Increment the versioning constants from 7.2 to 7.3 in next files
	modified:   wizards/source/scriptforge/SF_Utils.xba
	modified:   wizards/source/scriptforge/po/ScriptForge.pot
	modified:   wizards/source/scriptforge/po/en.po
	modified:   wizards/source/scriptforge/python/scriptforge.py

Change-Id: Iba78215cea9c16f3e7dd9302b84c90815c7a9e68
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117258
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2021-06-17 09:40:03 +02:00
Jean-Pierre Ledure af3f99dd1f ScriptForge - (scriptforge.py) add reference to SF/Python help page
Change-Id: I68ec6c53bbf9f6631f33192776b154936c1b721e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117065
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2021-06-11 18:30:09 +02:00
Jean-Pierre Ledure 0dd002a5f1 ScriptForge - (scriptforge.py) ThisComponent, ThisDatabaseDocument
Addition to the Basic service for Python scripts
of 2 Basic builtin objects:
- ThisComponent
returning the current component
- ThisDatabaseDocument
returning the main Base component when a subcomponent is active

Both are implemented as properties of SF_Basic.

The behaviour can be slightly different versus native Basic when
the Basic IDE is involved. Read comments in code.

Change-Id: I5d59b0ae0bae026f9b7e4c1d7068e84958aab56d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116674
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2021-06-04 10:21:54 +02:00
Jean-Pierre Ledure 024a11fee3 ScriptForge - (scriptforge.py.SF_Basic): methods in alphabatical order
GetSystemTicks() and GetPathSeparator() are inverted

Change-Id: I7e5c14041d6c70fe0a47519c93a24360ccc2d162
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116048
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2021-05-24 15:53:25 +02:00
Jean-Pierre Ledure 14d62503e9 ScriptForge - (SF_Basic) Add new CDate() method
The CDate() method replicates in Python the behavior of the Basic
builtin function with the same name, except that it returns
its unique input argument when it could not be recognized as
a valid date, while Basic raises an DataType error.

The method is introduced to make it easy to Python devs to
convert numbers stored in Calc cells and representing dates
to their corresponding datetime.datetime instance.

Change-Id: Ifd8fbd4bf7a97bf6b91cf481c09d75ec14159916
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115989
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2021-05-22 17:45:47 +02:00
Jean-Pierre Ledure 4cb73b7a57 ScriptForge - (scriptforge.py) FIX stdout redirection in PythonShell()
Previous behavior:
  After a PythonShell() statement that opened the APSO shell console,
  subsequent print() statements executed in the same macro
  run were not displayed in the console.
  They were only from a next macro run.

Solution:
  Force a brief suspension of the Python process by inserting
  a call to a Basic routine (IPC) immediately after the launch
  of the shell console.

Result: The redirection of STDOUT and STDERR happens normally inside
  the APSO code, as expected.
Change-Id: Ifbf267a898d45a97c346f0f3ea824edd4e6045ff
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115930
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2021-05-21 18:13:32 +02:00
Jean-Pierre Ledure 1054cad056 ScriptForge - (scriptforge.py) None as default value
CreateScriptService() does not accept keyword arguments.

In Basic positional arguments may be skipped, not in Python.
This makes
    CreateScriptSevice('Dialog', '', '', 'myDialog')
rather inelegant.

Only for the Dialog service, None is accepted as default value
i.o. '' for the Container and Library arguments.

Change-Id: Ib96e23373140264c7100f174c7704ed32351f124
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115629
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2021-05-15 09:52:26 +02:00
Jean-Pierre Ledure 53230b4954 ScriptForge - (scriptforge.py)Non-modal dialogs and OK/Cancel buttons
In the SFDialogs.SF_Dialog class:
- Fix the comments describing the behaviour of non-modal dialogs
- Add the OKBUTTON and CANCELBUTTON definitions

Change-Id: I2d3abc1c610b0c60949987feb1a9d66e21abfdc1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115152
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2021-05-06 14:46:19 +02:00
Jean-Pierre Ledure cec00cd70a ScriptForge - (scriptforge.py) Fix dates transfer Basic <-> Python
Strings in CSV file recognized as dates are passed via
their ISO format, not in the default com.sun.star.util.DateTime
format. This required a fix in Basic ImportFromCSVFile().

Errors in user scripts can be announced to users from Python
with the same interface as from Basic: SF_Exception.RaiseFatal().
Error messages become translatable.

Used by SF_Exception.PythonShell(), display of APSO console,
when the APSO extension is not present.
Addition of the PYTHONSHELL error message in the po files.

Review of typos.

Change-Id: I52a19faa3773904bd37505fee780d517436485f2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115032
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2021-05-03 15:45:51 +02:00
Jean-Pierre Ledure 225ee78552 ScriptForge - (scriptforge.py) dates passed as UNO dates
In replacement of the ISO format, to avoid any
misinterpretation of strings containing accidentally
a date,
from now on, dates are exchanged between Basic and Python
as com.sun.star.util.DateTime structures.

The year boundaries are [1900 - 9999].

The code managing the Python-Basic protocol has been changed
on both sides.

The Basic service receives the
- CDateFromUnoDateTime()
- CDateToUnoDateTime()
methods, equivalent with their Basic homonyms.

Change-Id: Ib6ded20c24ff71d3349d242f72bd7b88f69a2661
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114815
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2021-04-29 11:02:47 +02:00
Jean-Pierre Ledure deb51a303d ScriptForge - (scriptforge.py) SF_Exception.PythonShell() method
The PythonShell() method invokes the console() method
of the APSO extension.
It accepts 1 argument, which is a dictionary of variables
that the user wants transferred to the console to become part
of the Python context there.

Typical usage:
    exc.PythonShell( {**globals(), **locals()} )

Subsequent print() statements executed in the user script
are displayed in the console.

An (untranslated - english) error message is raised when
the APSO extension is not installed.

Change-Id: I1b620bc041e1293234ddfd789e0ce8892dc87169
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114561
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2021-04-24 14:54:43 +02:00
Jean-Pierre Ledure 32dda25037 ScriptForge - (scriptforge.py) @classmethods
A number of methods were defined implicitly as
instance methods.

Where apropriate they are replaced by class methods:
- insertion of the @classmethod decorator
- self replaced with cls

1 line in SF_PythonHelper.xba uncommented:
it was so far commented in for debugging

Change-Id: Ie8c3dd740f0129511295877ef947b1db35475c48
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114440
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2021-04-22 10:48:35 +02:00
Jean-Pierre Ledure 49f6c9d8c1 ScriptForge - (scriptforge.py) Dialog and DialogControl classes
New classes to manage Basic dialogs and their controls from
Python.

The use of UNO interfaces has been reviewed in Basic:
 replacement of
  CreateUnoDialog()
by
  XDialogProvider.createDialog()
The latter allows to run dialogs in non-modal mode.

SF_UI.ShowProgressBar() and SF_Console() have been reviewed
to incorporate the XSCRIPTCONTEXT shipped with Python
Now the console and the progress bar are able to run
in non-modal mode.

Change-Id: I49b09aa41ee6f50e6d205f44fc329f91bce76beb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114296
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2021-04-20 10:20:59 +02:00
Jean-Pierre Ledure 77cb68db10 ScriptForge - (scriptforge.py) Database class
New class to run from Python DDL + DML SQL commands
on databases embedded in or connected to Base documents.

GetRows() is hardcoded as an exception (cfr. bug #138155) in
_PythonDispatcher() - SF_PythonHelper.xba
to be able to return 2D arrays to Python.

Fix returned empty arrays in the Basic-Python engine:
the standard bridge ignores them and returns a null byte
sequence instead of an empty tuple.

Change-Id: I336ea0b585b759b998af0871d25bfd384a2e66ae
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113953
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2021-04-11 18:33:59 +02:00
Jean-Pierre Ledure de3b720f40 ScriptForge - (scriptforge.py) FormControl class
New class to manage controls in forms and subforms
from Python, essentially thru the use of Properties

Required a review of SF_FormControl.Getproperty()
Indeed, the IDE debugger computes all the properties
of a Basic object when expanded in the watch window.
This can cause errors.
This class makes use of default values for properties
when irrelevant for the actual control type

Error were detected on date/time conversions of date/timefield
controls and corrected.

SF_String etc shortcuts have been removed (see previous commit)
because not applicable in every scenario.
The only entry point to the API from a user Python script
is via CreateScriptService().

Change-Id: Ia87c7281c3fcf39ab0c3528f00114c9b1e067bcf
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113920
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2021-04-10 16:44:27 +02:00
Jean-Pierre Ledure 33ec919b63 ScriptForge - (scriptforge.py) Base and Form classes
Completion of the SFDocuments.SF_Base
and addition of the SFDocuments.SF_Form classes

Config of properties and methods

Some methods require an hardcoded processing in
_PythonDispatcher() - SF_PythonHelper.xba
because they potentially may return arrays (cfr. bug #138155)

Addition of SF_String etc shortcuts in Python
for compatibility with Basic

Change-Id: Id9852c214618e863b2fdf60aa5f80e36b3547a36
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113739
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2021-04-08 15:12:35 +02:00
Andrea Gelmini 317af2e31b Fix typos
Change-Id: I64d32773984a3ab06e809fcaeff8f95b910e127b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113700
Tested-by: Jenkins
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
2021-04-06 23:01:31 +02:00
Jean-Pierre Ledure 69147d9306 ScriptForge - (scriptforge.py) Remove hardcoded method synonyms
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 defined as:

- 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 and methods are computed
with a generic function: SCriptForge.SetAttributeSynonyms()
The generic getter and setter have been reviewed accordingly.

Method synonyms are NOT HARDCODED anymore.

Change-Id: I528820fe195d6b67e02035e589deee2b61c056ba
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113666
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2021-04-06 16:26:41 +02:00
Andrea Gelmini d67829bdd3 Fix variable name
Change-Id: Ida5172f860303fa9493dd3477a970d29f87444de
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113596
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
2021-04-05 13:28:14 +02:00
Jean-Pierre Ledure 88d3172f17 ScriptForge (scriptforge.py) UI, Document & Calc classes
Changes in the Basic-Python engine:
- arguments of methods may be 2D arrays
- 1st argument of method may be a Basic object
- properties starting with 'X' may contain UNO objects
- GetProperty may contain 1 argument

Calc class is a subclass of the Document class in Python
(in Basic it is simulated)
A CalcReference class is also created to contain
Range and Sheet objects

Many comments have been reviewed for consistency in SF_Calc,
SF_Form and SF_FormControl.xba
Conversion to DataArrays is improved to process input
arrays of arrays. Date conversions are supported.

Change-Id: Id6254d668ec981b00555e7e277c4d31982c00092
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113568
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2021-04-04 17:04:15 +02:00
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