Commit Graph
126 Commits
Author SHA1 Message Date
Andrea Gelmini 0fafd7ff65 Fix typos
Change-Id: Idcb10d0cc0759473e95e47afec7ed69853628612
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132587
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Tested-by: Jenkins
2022-04-05 23:44:14 +02:00
Jean-Pierre Ledure 2e3c34521d ScriptForge - (SF_Utils) new _VarTypeObj() method
The method is for internal use by the ScriptForge core only.

The only argument is an object with VarType() = V_OBJECT.

The purpose is to inspect thoroughly the argument
and to return a
   Type _ObjectDescriptor
      iVarType As Integer
      sObjectType As String
   End Type
The iVarType indicates if the object is either
 - a UNO object => sObjectType contains the UNO type ("com.sun.star. ...")
 - a ScriptForge class instance => sObjectType contains the class
 - another Basic object
 - Nothing (different from Null)

Several existing methods benefit from the new method and are part
of the commit.

No effect on help pages.
No effect on Python code.

Change-Id: I69565d335b3aeb7c08c48cbccfc13d3d82f11ae1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132525
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2022-04-05 18:52:05 +02:00
Jean-Pierre Ledure 7c8e9db0e4 ScriptForge - (SF_Dialog) new Resize() and Center() methods
The "dialog" service receives 2 new methods for easy
move/resize of the concerned dialog.

Resize(left, top, widt, height)
  Move the topleft corner of a dialog to new coordinates and/or modify its dimensions
  All distances are expressed in 1/100th mm
  Without arguments, the method resets the initial width and height

Center(window)
  Center the actual dialog instance in the middle of a parent window
  Without arguments, the method centers the dialog
    in the middle of the active window
  The Parent argument can be either
    - a ScriptForge dialog object
    - a ScriptForge document (Calc, Base, ...) object

Both methods are available from Basic and Python user scripts

Change-Id: Ic3680739c9d518da3d76d3588943ae5ce6bad8ce
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132418
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2022-04-01 14:09:40 +02:00
Andrea Gelmini c8e5c2e65a Fix typos
Change-Id: Iccb89d32b83b7f7035557ad7c0634f66f4c947d3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132082
Tested-by: Jenkins
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
2022-03-24 19:18:50 +01:00
Jean-Pierre Ledure 272a90c45a ScriptForge - (SF_Region) new service in the core library
Singleton class implementing the "ScriptForge.Region" service
Implemented as a usual Basic module

A collection of functions about languages, countries and timezones
- Locales
- Currencies
- Numbers and dates formatting
- Calendars
- Timezones conversions
- Numbers transformed to text in local language

Definitions:
  Locale or Region
    A combination of a language (2 or 3 lower case characters)
    and a country (2 upper case characters)
    Most properties and methods require a locale as argument.
    Some of them accept either the complete locale or only
    the language or country parts.
  Timezone
    Specified as "Region/City" name like "Europe/Berlin",
    or a custom time zone ID such as "UTC" or "GMT-8:00".
    The time offset between the timezone and the
    Greenwich Meridian Time (GMT) is expressed in minutes.
    The Daylight Saving Time (DST) is an additional offset.
    Both offsets can be positive or negative.

Properties:
  Currency
  Language
  Country
  DatePatterns
  DateSeparator
  ThousandSeparator
  DecimalPoint
  TimeSeparator
  ListSeparator
  DayNames
  DayAbbrevNames
  DayNarrowNames
  MonthNames
  MonthAbbrevNames
  MonthNarrowNames

Methods
  UTCDateTime
  UTCNow
  LocalDateTime
  TimeZoneOffset
  DSTOffset
  Number2Text

Change-Id: Iabf31ea0e6c235e960fcca5b1e7a9d928cf8cd0f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132068
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2022-03-24 16:20:30 +01:00
Jean-Pierre Ledure ae24ce8c63 ScriptForge - (UI) size and position of the active window
The UI service receives next 4 new properties:
  Height
  Width
  X
  Y

They all return a Long value representing the size or position
of the active window. The active window does not need to be a
document, it may f.i. be the Basic IDE.

Those properties are read-only.
To modify the size or the position of the window,
use the the Resize() method.

They are implemented for use from Basic and Python scripts.

Change-Id: I0021663e39612f411cefa5c7ec9ec594a4cb6f39
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131444
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2022-03-13 16:11:07 +01:00
Jean-Pierre Ledure 511cc0cd62 ScriptForge - (SF_Root) differ loading of the localized interface
So far, the loading of the user interface in the user's
own language was done at the first invocation of
ScriptForge, usually via
- a CreateScriptService() method
- a direct call to any method, f.i. SF_Array.Append()

Now the same loading of the user interface in memory
is done at the first request of a localized text or message.

Due to the fact that since last commit
   https://gerrit.libreoffice.org/c/core/+/131255
only error messages contain localized texts,
the benefit is that correct scripts will not load any
unnecessary texts anymore.

The "Interface" variable has be renamed "LocalizedInterface"
for clarity in the SF_Root class module

No impact on documentation or Python scripts.

Change-Id: Ie654625540c0c8f8442e9ba36d38ecaab00c0eb1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131313
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2022-03-10 16:26:11 +01:00
Jean-Pierre Ledure 14e550c596 ScriptForge - Console + progress bar receive a Close icon
Next dialogs:
- dlgConsole (modal or non-modal)
- dlgProgress (non-modal)
had a Close button with label "Close" or a translation.

The "Close" text is replaced with a "Cancel" icon.

Objective: make console and progress bar user-language independent.

No impact either on user documentation or on Python part.

Change-Id: Ib1c2370986d47ccab49c6d42500231fd73b9ff3f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131255
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2022-03-10 10:56:10 +01:00
Jean-Pierre Ledure 7e834362a8 ScriptForge - 'SF_Root) load user interface from code when locale=en
The user interface is loaded in the user's language
at the first use of Scriptforge during the LO session.

So far the labels were always loaded from the relevant
.po file.
Now they are loaded in memory by code when the user's
language = "en".

Objective = gain in performance.

Additionally the default language is set to
   SF_Platform.OfficeLocale
i.o.
   SF_Platform.SystemLocale

Internal change, no impact on documentation

Change-Id: Ia0d1235f8ca6a42141a5481fe80b5bec1d53a7e3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131214
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2022-03-08 19:53:14 +01:00
Jean-Pierre Ledure 2598c35dba ScriptForge - (SF_Document) new Import/ExportFilters properties
The ImportFilters and ExportFilters properties
of the Document, Calc and Writer services
return a zero-based array (Basic) or a list (Python)
of all filters available for the current document
instance.

These properties are NOT applicable to Base documents.

ImportFilter contains the filters flagged for import
or for Import/Export. Idem for ExportFilters.
Both lists overlap each other partially.

The filter selection is done thanks to the
- filter type, to be compared with the Identifier of
  the document's component
- filter flags, last 2 bits determine the import or export
  orientation

The filter names are potential arguments of the OpenDocument()
and SaveAs() methods (and alike).

Both properties are callable from Basic and Python user scripts.

Change-Id: I8ce5312a58a013bc7e1e68101ff9f50f3233155d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131106
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2022-03-07 16:13:46 +01:00
Jean-Pierre Ledure 363dd5850f ScriptForge - (SF_Calc) new ExportRangeToFile() method
The Calc service offers the possibility to export
a range, given as a string, to a file in several
different image formats.

Supported formats: pdf, jpeg, png.

Arguments:
- Range: a sheet name or a range of cells
- Filename: the file to export to in FileSystem notation
- ImageType: the expected output format
- Overwrite: True when the output file may be overwritten

New error message: RANGEEXPORTERROR
Error is introduced in po files.

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

Change-Id: Ibd297ec2da1b48fca3dee7d8e03bd2ee4815957a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130835
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2022-03-02 14:13:39 +01:00
Jean-Pierre Ledure 740329373b ScriptForge - (SF_Platform) add the FilterNames property
The FilterNames property returns, as an unsorted zero-based
array of strings, the list of available/installed import
and export filters for components.

The property can serve as support for the FilterName
argument used for opening and saving documents.

The FilterNames property is available both from Basic
and Python user scripts.

Change-Id: I607500b56836ceeb6716b10d39d22638b0741f3c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130624
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2022-02-27 15:27:15 +01:00
Jean-Pierre Ledure 60f786bde4 ScriptForge - (L10N): add new arguments to the service creation
Actual arguments:
  - FolderName: the folder containing the PO-files
  - Locale: in the form la-CO (language-COUNTRY)
  - Encoding: The character set that should be used

New arguments introduced by this commit:
  - Locale2: fallback Locale to select if Locale po file does not exist
  - Encoding2: Encoding of the 2nd Locale file

Both new arguments are optional => no regression on existing scripts

The arguments are available in Basic and Python equally.
They may be passed as keyworg arguments in Python only.

The default locale is now set to the "OfficeLocale",
which is the locale in the user interface.
NB: the distinction between SystemLocale and OfficeLocale
is new in version 7.4.

Change-Id: Ie3bc5d30193df35a8c6c1ec706e13eaea0050981
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130074
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2022-02-17 16:18:49 +01:00
Jean-Pierre Ledure d94a476743 ScriptForge - (SF_UI) Fix omission of ServiceName
The ServiceName property is part of the standard
norm for ScriptForge services.

It is used only internally.

Its omission in SF_UI caused the tree in construction
for help files to contain wrong redirections.

Change-Id: I51f1966ef463fffe62c9495dbc2ea0c152fa9667
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130004
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2022-02-17 10:54:09 +01:00
Jean-Pierre Ledure 74a638011d ScriptForge - (scriptforge.py) get lists of properties and methods
To allow object introspection and some help
files automatic generation (see Telegram discussions),
the possibility to make the list of properties
and methods used in Basic  available in Python
has been requested.

These changes are for internal use only.

Main changes:
- the SFServices parent class receives new basicproperties()
  and basicmethods() methods
- Basic PythonDispatcher() is adapted to provide the lists to
  the Python caller
- Methods lists are reviewed in SFDocuments to NOT include
  the methods implemented in the parent SF_Document class, to
  avoid redundant entries in the list

Change-Id: I80758e225b039426b46f52dd67efe54c50f9f31e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129969
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2022-02-15 17:50:45 +01:00
Jean-Pierre Ledure 3e340d3f7b ScriptForge - (SF_Utils) review optional argument of _Repr()
As from LO 7.3, optional missing arguments must not be used
in assignments and comparisons.
The Basic interpreter tolerated it before 7.3.

Probable commit having changed Basic behaviour:
    https://gerrit.libreoffice.org/c/core/+/121794

A unique case of this singularity was found in the
    SF_Utils._Repr()
method.

The bad consequence was that the commonly used
    SF_Exception.DebugPrint()
method calls above method. This broke in fact
the whole ScriptForge library.

Change-Id: Iba8792b92c73c992429de4382bd8a3dc4b58a94f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129728
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2022-02-10 09:43:10 +01:00
Andrea Gelmini 571be264d9 Fix typos
Change-Id: I50e8988c320c0068f7adf4a3429d7639df0cbcd1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129596
Tested-by: Jenkins
Reviewed-by: Andrea Gelmini <andrea.gelmini@gelma.net>
2022-02-09 12:55:48 +01:00
Jean-Pierre Ledure b52016e5d0 ScriptForge - (SF_Platform,SF_FileSystem) Manage extensions
New properties and methods
--------------------------

SF_Platform.Extensions : (property)
   provide a list of the installed extensions
   as an array of strings

SF_FileSystem.ExtensionFolder(Extension as string) : (method)
   provides the location in FileNaming notation of the
   folder where the given extension is installed

The SF_FileSystem.ExtensionsFolder (notice the additional "s")
is kept as a property providing the folder containing the
extensions installed by the user.

All methods and properties are available with an identical
syntax and semantics both from Basic and Python scripts.

The difference between a propert or a method is
irrelevant for Basic but is essential in Python:
a property must not have brackets, a method must have them.
Hence the distinction between
   ExtensionFolder being a method requiring an argument
   ExtensionsFolder being a property without argument

Change-Id: Idd18a5624f4abd84095d146e467e8fdcf497bd0d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129572
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2022-02-07 09:16:03 +01:00
Jean-Pierre Ledure a151300354 ScriptForge - (SF_UI) Import RunCommand() from SF_Session
Functionally SF_UI groups methods impacting the
user interface, while the Session service groups general-purpose
actions.

The RunCommand() method (newly introduced in 7.4) simulates
menu commands applied on the active window.

RunCommand() fits better in the UI service.

It is removed from SF_Session.

Change-Id: Ia72150efea2f50de13d15a4c1f5fea79777d1760
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129453
Tested-by: Jenkins
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2022-02-04 14:20:10 +01:00
Jean-Pierre Ledure 5069692319 ScriptForge - (SF_Platform) refine locales
So far, only SF_Platform.Locale was supported, returning
the locale of the operating system.

Now, 3 different locales may be considered:

- SystemLocale: identical to Locale (still supported)
- OfficeLocale: the locale associated with the LibreOffice
  installation
- FormatLocale: the locale associated with how numbers and
  dates are formatted.

Of course, in many cases all locales are identical. Anyway
a distinction can be made.

All these properties are read-only.

Those properties are supported in Basic and Python evenly.

Change-Id: I0792d49a052b1441a30ac231d61eda997dc4216a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129297
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2022-02-01 19:26:49 +01:00
Jean-Pierre Ledure 57f6c7f4c9 ScriptForge - (SF_Exception) error messages give access to help page
When ScriptForge detects an error in a user script,
a message box is displayed with a summary of the
syntax and validation rules the invoked method
should respect, and/or any other reason the library
has identified.

Now the error message is completed with
- the sentence "Do you want to receive more information
  about the '%1' method ?"
- 2 buttons Yes/No (No being the default)

When the Yes button is pressed the local browser opens
the help page/anchor of the invoked service/method.

The pot template and the english po files are modified.

There is no difference between Basic and Python in this
matter.

Change-Id: Ie6210b9d108c9a1e98a46173504680e3985125b0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129232
Tested-by: Jenkins
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2022-02-01 12:17:03 +01:00
Andrea Gelmini cba7646dbc Fix typo
Change-Id: I472190c743dd26e88e3400f323ab52fa05c187d9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129215
Tested-by: Jenkins
Reviewed-by: Adolfo Jayme Barrientos <fitojb@ubuntu.com>
2022-01-31 14:24:31 +01:00
Jean-Pierre Ledure 9688e4970e ScriptForge - (SF_Session, SF_Document) add arguments to RunCommand()
Next wiki page
 https://wiki.documentfoundation.org/Development/DispatchCommands
facilitates the use of commands with the
DispatchHelper service, including with arguments

This commit
- adds the RunCommand() method in the Session service
- extends the scope of existing RunCommand() methods
  for the Document, Base, Calc and Writer services
  with the addition of command arguments
Syntax by examples:
 (Basic)
  session.RunCommand("BasicIDEAppear", _
    "Document", "LibreOffice Macros & Dialogs", _
    "LibName", "ScriptForge", _
    "Name", "SF_Session", _
    "Line", 100)
 (Python) (1)
  session.RunCommand("BasicIDEAppear",
    "Document", "LibreOffice Macros & Dialogs",
    "LibName", "ScriptForge",
    "Name", "SF_Session",
    "Line", 100)
 (Python) (2)
  session.RunCommand("BasicIDEAppear",
    Document = "LibreOffice Macros & Dialogs",
    LibName = "ScriptForge",
    Name = "SF_Session",
    Line = 100)

Change-Id: I60cd5eb1ed0a057420215ce7aebe92b2aafabd53
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129175
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2022-01-30 18:26:36 +01:00
Julien Nabet 240b3ccaec Fix case for "ByVal", "Variant", "UCase"
Change-Id: I136d292cd535d4208457ef91a7773fc7ac00d5c8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127716
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Reviewed-by: Andreas Heinisch <andreas.heinisch@yahoo.de>
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Tested-by: Jenkins
2021-12-30 10:34:54 +01:00
Jean-Pierre Ledure 408838e529 ScriptForge - (SF_Utils) language may have a length > 2 in locales
The vaste majority of language codes are 2 characters long.
However it is not the norm.
A length of 3 is admitted for less spread languages

Change-Id: Iabdf6a6cf453169419d0a4a7a3ab6ea80ae4753e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126531
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2021-12-08 18:19:21 +01:00
Jean-Pierre Ledure 88c82f1028 ScriptForge - (SFWidgets) new SF_Menu service
Display a menu in the menubar of a document (form document to be done)
After use, the menu will not be saved neither in the application settings,
nor in the document. The menu setting does not affect the modified status of the
document.

The menu will be displayed, as usual, when its header in the menubar is clicked.
When one of its items is selected, there are 3 alternative options:
  - a UNO command (like ".uno:About") is triggered
  - a user script is run receiving a standard argument defined in this service
  - one of above combined with a toggle of the status of the item

The menu is described from top to bottom.
Each menu item receives a numeric and a string identifier.
Each menu item may be decorated with a tooltip and/or an icon.

The AddItem(), AddCheckBox() and AddRadioButton() methods, when
coompared with their equivalents in the SF_PopupMenu service,
receive 2 additional arguments: Command and Script.

The various document services receive 2 additional methods:
   CreateMenu(), returning a Menu service instance
   RemoveMenu()

Very short example:
   menu = doc.CreateMenu("My menu", Before := "Help")
   menu.AddItem("First Item", Command := "About")
   menu.AddItem('2nd Item", Script := "... URI notation ...")
   menu.Dispose()   '   Once set the menu object may ve erased, listeners stay tuned
Later in the lifecycle of the document, one may run:
   doc.RemoveMenu("My menu")   '  doc.RemoveMenu("File") works as well !!!

All the functionalities are available both in Basic and Python user scripts.

Change-Id: Iabd157573693e9648fcb06d36c90af9a22b17a6c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126309
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2021-12-03 15:24:57 +01:00
Jean-Pierre Ledure 6983e9e0a2 ScriptForge - (SF_Platform) fix Locale should return the OS locale
So far it returned the LO locale.
Discussed on Telegram

Change-Id: I2cf66ca3acebe695354de9185e0698ffa4d8cf05
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125820
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2021-11-25 17:35:45 +01:00
Jean-Pierre Ledure 6b4f02396b ScriptForge - (SF_Calc) new OpenRangeSelector() method
The method activates the Calc document, opens a non-modal dialog
with a text box, let the user make a selection in the current
or another sheet and returns the selected area as a string.
This method does not change the current selection.

Arguments:
 Title: the title to display on the top of the dialog
 Selection: a default preselection as a String.
   When absent, the first element of the current selection is preselected.
 SingleCell: When True, only a single cell may be selected. Default = False
 CloseAfterSelect: When True (default-, the dialog is closed immediately
   after the selection. When False, the user may change his/her mind
   and must close the dialog manually.
Returns:
 The selected range as a string, or the empty string
 when the user cancelled the request (close window button)

Example:
 Dim sSelect As String, vValues As Variant
 sSelect = oDoc.OpenRangeSelector("Select a range ...")
 If sSelect = "" Then Exit Function
 vValues = oDoc.GetValue(sSelect)

The implementation requires a new module: SF_DocumentListener.xba

The method is available for Basic and Python user scripts.

Change-Id: I2d67a9c900ea8ac661cd6b6fb43bb4a34e6abd8e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125201
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2021-11-15 13:47:26 +01:00
Jean-Pierre Ledure bef0b6dfef ScriptForge - (SF_Calc) new Printf() method
Returns the input string after substitution of its tokens by
their values in the given range

This method is usually used in combination with SetFormula()

The accepted tokens are:
   - %S   The sheet name containing the range,
          including single quotes when necessary
   - %R1  The row number of the top-left part of the range
   - %C1  The column letter of the top-left part of the range
   - %R2  The row number of the bottom-right part of the range
   - %C2  The column letter of the bottom-right part of the range

The default token character (%) may be modified.

The method is available both for Basic and Python user scripts

Change-Id: If9c3a042abf22ba760d1410b105b04716d092418
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125044
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2021-11-11 14:53:40 +01:00
Jean-Pierre Ledure 754247fe3f ScriptForge - (SF_Calc) First/Last * Row/Column/Cell accept sheets and ranges
The methods
   FirstCell
   FirstColumn
   FirstRow
   LastCell
   LastColumn
   LastRow
   SheetName
accept uniformly either a sheet name or a range name.
They return a single cell as an absolute address (First/LastCell),
a String (SheetName) or a Long.

The range name is to be understood as the extended notation for ranges.

FirstCell/Column/Row accept sheet names. However they will then always return
either the "A1" cell or the value 1.

The LastCell/Column/Row return the real last xxx for ranges, and
the last USED xxx when the argument is a sheet.

The A1Style() method surrounds from now on sheet names
with single quotes only when necessary.

The GetRangeAddress() method has been dropped as redundant with the actual
methods. (Was new in 7.3 => no effect on upward compatibiity)

Change-Id: Iff1ce437ee27dfb8481361f648b3f7a33ae2c4b1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124904
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2021-11-09 13:09:24 +01:00
Jean-Pierre Ledure 59372ead7e ScriptForge - (SF_Calc) new GetRangeAddress() method
The GetRangeAddress() method accepts 2 arguments:
  GetRangeAddress(Range, AddressItem)

- a range as a string, to be understood as the extended definition
  described in the help pages

- the item to be extracted from the given range, either:
    firstrow
    firstcol
    lastrow
    lastcol
    sheet

The returned value is either:
- a Long
- a String when sheet is requested
- an array of all these values when no item is given

The method is available for both Basic and Python user scripts

Change-Id: I6156b176e29cf47207a079d10552443467dd2f6d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124551
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2021-11-01 16:39:23 +01:00
Jean-Pierre Ledure 020967fde8 ScriptForge - (SF_Calc) new ShiftDown, ShiftLeft, ShiftRight, ShiftUp methods
ShiftRight()/ShiftDown() insert empty cells at the left/on the top of
a given range and move all cells at the right/bottom of the range
accordingly.
They are similar to the Insert Cells ... menu commands

ShiftLeft()/ShiftUp() delete cells at the left/top of a given
range and move all cells at the right/below the range
accordingly.
They are similar to the Delete Cells ... menu commands

The insertion/deletion may be done for a whole column/row.

The number of columns/rows to insert/delete may be chosen.

All methods are available in Basic and Python user scripts.

Change-Id: I14555a3966c26054925dd71b0696f3dfc773fc21
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124530
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2021-10-31 18:16:42 +01:00
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 b42a94c6fd ScriptForge - (SF_Platform) increase speed of Fonts property
Tests have proven that the use of a case sensitive search
on long strings improves significantly the execution
performance.

The number of fonts being potentially huge (2-3K), the change
in the InStr() Basic function of the Compare argument
can divide the execution duration by factors in the range > 5.

Change-Id: I248ff88cd2cb5a2753e7749f8d512ad44b5fc8d5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122979
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2021-10-02 13:49:40 +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
Andrea Gelmini 51d4ba35dd Fix typos
Change-Id: Ic3793bd77a7db52e59797cc6b2153850b1cec42e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121737
Tested-by: Jenkins
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
2021-09-08 09:19:41 +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 0abc993f1b ScriptForge - (SF_L10N) FIX return value of AddText()
Return value should be True when successful.
Was erroneously False.

Minor bug. No correction in 7.1 and 7.2

Change-Id: I71040f2ba8fec80297428b0ca317e9d67c79a25e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118815
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2021-07-13 10:08:51 +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