New methods in the 'array' service:
- Map(module, method, array, Args) -> outarray
Executes the method for each item
in array and accumulates the results
in outarray.
- Filter(module, method, array, Args) -> outarray
outarray contains all the items of
the input array for which the method
has returned True
- Reduce(module, method, array, initialvalue) -> scalar
At each iteration, the partial result
is passed as 1st argument of the next
iteration.
Module = any Basic module, any Basic class instance,
any ScriptForge service instance
Method = given as a string
may be a method or a property
when module is a SF object
Above mzthods allow the programmer to write
simpler, shorter code, without neccessarily
needing to bother about intricacies
like loops, branching and error handling.
Examples:
Let's assume:
ar = CreateScriptService("array")
fs = CreateScriptService("filesystem")
st = CreateScriptService("string")
ui = CreateScriptService("UI")
Open read-only all Calc docs stored in a folder
folder = "C:\MyFolder"
ar.Map(ui, "OpenDocument", fs.Files(folder, filter := "*.ods"), "", True)
Minimize all active Writer docs
ar.Map(ui, "Minimize", ar.Filter(st, "EndsWith", _
ui.Documents(), ".odt"))
Designed for Basic user scripts only.
The user documentation should include those
new functions.
In addition:
- some changes done in Session for more
flexibility in script provider handling
- identification of SF objects modified
in SF_Utils
Change-Id: I16f5fe03d31613c9c777905edd5190f56e460df3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/202037
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
ui.Activate(...)
sets the focus on the window in argument.
Before the actual patch, when the window
in background was maximized, it appeared
in foreground simply "restored".
Now "restored" or "maximized" depends on
the previous status.
Limited impact on existing scripts.
Improvement valid for Python and Basic
user scripts.
No impact on help documentation.
Change-Id: Ie3d30967948d114a422345afa9d13d54e587b79e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/201175
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
The bug "CallByName() does not work when the returned value
is an array"
https://bugs.documentfoundation.org/show_bug.cgi?id=138155
is now fixed thanks to tdf#187145
This is a major improvement for the protocol
designed to make ScriptForge run smoothly
in Python as well as in Basic.
Indeed, CallByName() is a cornerstone of that protocol.
The implementation of this protocol is now
greatly simplified: the previous use of
hardcoded calls to workaround the limitation
to scalars of CallByName() has been suppressed.
The actual commit has no effect on existing scripts.
The documentation is not impacted.
Change-Id: Id01bb2d2d8be587d9c6aed227d172d10ddd85d4e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/199740
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Sometimes,
- headless mode
- client/server mode from python scripts
via pipe or socket
- ...
the StarDesktop object has punctually
no active frame set.
This caused inopportune aborts in the
ScriptForge code: "Object variable not set",
when maximizing/minimizing the frame.
The request should simply be ignored.
Change-Id: Ifd38207cdeb4c5c4f40c58cca561f8131e8aed51
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/199466
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
The
ui.EnterValue(...)
method displays a typed input box to the user
and returns the entered value as a scalar
of the requested type, or Empty/None
when the user cancels the box.
=> A single statement to interact with
the user through a complex dialog box
e.g. a listbox field of allowed values.
The box is centered on the active window.
The arguments (all are optional) :
prompt: the message appearing above the input field
Escape chars (\n \t) are interpreted correctly
valuetype: determines the type of the input field
and of the returned value, either
STRING, PASSWORD -> str
BOOL, INTEGER, FLOAT -> bool, int, float
DATE, TIME, DATETIME -> datetime
COMBO, LIST, RADIO -> str
default: the initial value
title: the header of the dialog
choices: the list of valid values
(COMBO, LIST and RADIO only)
format: the format of numeric and date values
Example (Python):
destination = ui.EnterValue(("What is your next destination ?", "LIST",
choices = ("Belgium", "Brazil", "France", "Mexico"),
default = "France",
title = "This text is in the titlebar")
The box is sized based on the arguments.
The function is available both in Basic
and Python user scripts.
The user documentation should be adapted accordingly.
Change-Id: I7c3f02f597ba5990c5f5a8548fb4f07699cda358
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/199194
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Per
https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file#file-and-directory-names
the comma and the semicolon are not
reserved characters in folder or file
names.
Not in Windows, and also not in Linux.
The regular expressions used to filter
valid file names have been reviewed
accordingly in the
ScriptForge.SF_String
module.
No impact on user scripts, except a better
tolerance.
No impact on user documentation.
Change-Id: I4970c6d8334d717e5642782d3b5385731aa98717
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/198545
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Version number is modified from 26.2 to 26.8.
No effect on actual user scripts.
Change-Id: I3010985552fc90b5374ca7fa571dfacfbdc8af37
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/196202
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
In the scenario where
- the console is opened in modal mode,
- the console is closed immediately,
- the exception.ConsoleClear() is run,
an abort occurs:
Object variable not set
Fixed now.
Change-Id: Ib7de836457e77786b0e29a68eaf64e8bd6aa8a0e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/194846
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
The durations in the Timer service
are measured with a precision of
the millisecond.
Thanks to tdf#161469 the Basic Now()
function provides sub-seconds precision
since LO 25.2.
Hence the use of the Calc NOW() function
is replaced in the Basic code by the
more immediately available Basic Now()
equivalent.
No impact on existing user scripts.
Documentation is unchanged.
Change-Id: Ia3b0f07918d9b9a9e96f62aaa5ce3862a2b48579
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/194070
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
The new "Shape" service is focused on
the description of shapes/images/drawing
objects stored in documents.
In the actual release only shapes
in Calc sheets are considered.
A Shape instance is created from either:
- calc.CreateShapeFromFile(shapename, imagefile,
range, aslink)
=> the shape is loaded in the sheet and
anchored to the given range.
The shape may or not be embedded in the
document.
- calc.Shapes(sheetname, shapename)
Next methods are available:
- shape.Anchor(anchortype, cell)
=> define the anchor type and the cell
to which the shape has to be anchored.
- shape.ExportToFile(filename, imagetype, overwrite)
=> save the shape as an image file
to a specified location.
- shape.Pick()
=> select the shape (NB "Select" is a reserved
word in Basic, hence "Pick")
- shape.Resize(xpos, ypos, width, height)
=> change position and/or size.
- shape.Rotate(angle, pivot)
=> rotate the shape using a given
pivot point (x, y) with a given angle.
The shape.XShape property gives a direct
access to its com.sun.star.drawing.XShape
UNO representation.
The pre-existing SF_Chart service is
functionally unchanged. However it is
now implemented as a subclass of the
new SF_Shape service.
Compatibility with previous releases
is preserved.
The implementation required a few changes
in the error messages. Hence also in
their translations.
All the functions are available for both
Basic and Python user scripts.
The documentation should include:
- a revision of the Calc and Chart help pages
- the creation of an additional Shape page
Change-Id: Ib67f5e755e3112961aadeffc3188b2cdf9aca613
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/193906
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
The ColorizeRange() method accepts next
arguments:
- TargetRange : the cell or the range as a string
in which cells should be re-colorizeed
- Foreground: the foreground color as the output
of the RGB() function
- Background: the background color as the output
of the RGB() function
- FilterFormula: a Calc formula to select
among the given TargetRange which cells,
rows or columns should affected
- FilterScope: "CELL", "ROW" or "COLUMN"
So far, negative values for Foreground and
Background were ignored.
Now, they reset the colors to their default
values.
This is valid for Basic and Python user scripts.
The documentation should be updated
accordingly.
Change-Id: Ie7722365bcacb1ebe82dc1fc226ed047483143dd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/191969
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Extract from above bug report:
The accessibility UNO API is unpublished and
for LibreOffice-internal use only and
subject to change by design.
The com.sub.star.accessibility.AccessibleContext
service is used in ScriptForge to determine
the location on the screen, in pixels, of
next window subsets:
(1) a Calc cell or cellrange
=> calc.XRectangle(range) property
(2) a toolbarbutton in a docked toolbar
=> toolbar.ToolbarButtons(buttonname) method
In both situations, SF offers a facility
to display a well-positioned popup menu
triggered by a mouse left- or right-click.
The situation of the API is as follows:
- fully available in 25.2
- partially available in 25.8
(1) is not broken
(2) is broken
- fully vanished in 26.2
The gradual phase-out of the API requires,
to fix the bug, a tiered adaptation of
the code.
The choice is made to incorporate, where
appropriate, a switch to the right code
snippet based on the run LibreOffice version:
25.2, 25.8 or 26.2.
Now the behaviours in 25.2 and 25.8 are
identical. In 26.2, a different location
is returned for undocked toolbars.
The solution used for 26.2 must be considered
as still subject to change.
The emergency is to fix the issue in 25.8,
which is currently broken.
With the actual patch, the compatibility
between releases is restored, both in
Basic and Pythonuser scripts, and does
not need any documentation revision.
Change-Id: I29b4ccca3f11eca39e5a1841d3cfd744d5eb1fe3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/191670
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
The import of a CSV-formatted file
into an array fails when specific
combinations of double quotes and
commas (= delimiter) are present.
The
array.ImportFromCSVFile()
method uses internally the
string.SplitNotQuoted()
method for parsing the input
records.
The latter method skips the delimiters
located inside quoted strings.
It was buggy and needed a revision.
Documentation unchanged.
Change-Id: Ie156455b99749c6a8e4f43f4d3c258772904848f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/191227
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Thanks to commit
https://gerrit.libreoffice.org/c/core/+/190931
(Extend Python-Basic gateway for objects)
a signature with an object instance as argument
is allowed in any position, i.o. the 1st only.
This is applicable to
sharedmemory.StoreValue(value, variablename)
Indeed, 'value' may be such an object instance.
The signature becomes now
sharedmemory.StoreValue(variablename, value)
which is more intuitive.
No impact on user scripts <= 25.8
Documentation should take both commits
into account.
Change-Id: I1a07cd740fc9dcba1077932bba0f69735a7bc647
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190979
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
A Python ScriptForge object may be passed to
Basic functions, so far only when it is
positioned as the first argument in the
method signature.
Like in:
dialogB.Center(dialogA)
The actual commit extends the protocol
between Python and Basic to allow passing
Python objects from another position
in the method signature.
However this possibility is limited to
maximum 1 such argument.
(Note that removing this limitation,
if ever needed, would not require
a big change.)
No impact on user existing scripts.
No documentation update.
Change-Id: I191b7bb7c32b158b7274815577349ddfa1406b93
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190931
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Concerned file:
scriptforge.pyi
(python stub having no impact on script
execution, only on script edition with
advanced IDE's like PyCharm and VSCode).
Guided by
https://typing.python.org/en/latest/guides/modernizing.html#generics-in-the-typing-module
Older typing features are superseded
by more modern alternatives,
which are recommended to use.
Applicable changes:
>= Python 3.9
typing.Dict => dict
typing.List => list - replaced by tuple
typing.Tuple => tuple
typing.Sequence => collections.abc.Sequence
replaced by tuple
>= Python 3.10
typing.Optional => | None
typing.Union => | (pipe operator)
This makes the source more readable
and, also, a bit shorter.
No impact on user scripts.
Documentation unchanged.
Change-Id: I856d01660c5c3e1c3f0a0c2cca756fa0cbfd9a4a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190362
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Singleton class implementing the
"ScriptForge.SharedMemory"
service. Implemented as a usual Basic module.
Contains the mechanisms to manage persistent memory storage
across Basic and/or Python scripts.
When a script stops running, all the variables it uses vanish,
except Basic Global variables, which stay in memory until
the end of the LibreOffice session.
However event-driven scripting can often benefit from having
variables still being available when the next script is
triggered, probably due to a user action.
The SharedMemory service implements interfaces allowing
to store both BASIC and PYTHON variables in persistent storage,
and to retrieve them later from either BASIC or PYTHON scripts
interchangeably.
The use of the Basic Global statement is more efficient
than the actual service and should be preferred when the variables
are created and retrieved in basic scripts only.
The supported variable types are:
* Scalar or tuple combining:
- int, within the bounds of the Basic Long type
- float, within the bounds of the Basic Double type
- str
- bool
- None
* datetime.datetime
* UNO object
* ScriptForge class instance
Example:
Sub CreateDoc()
ui = CreateScriptService("UI")
doc = ui.CreateDocument("Calc")
store = CreateScriptService("SharedMemory")
store.StoreValue(doc, "actualdocument")
...
def UpdateDoc():
store = CreateScriptService("SharedMemory")
doc = store.ReadValue("actualdocument")
...
The service is available both for Basic and Python scripts.
The actual commit requires the creation of an additional
Help page.
Change-Id: Id53994be5105206c16659f769338261b3dde2d3a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190174
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Incomplete implementation of the
case-sensitivity of Basic dictionaries
in
CreateScriptService()
Change-Id: Id12b50fb7b62322909622a19fa191d3110447dae
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/189792
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
The
GetRangeFromCalc(filename: str, range: str)
method (stored in the Session service)
reads the values contained in the given
range located in the given Calc file.
The file does not need to be open. This
makes this shortcut particularly useful.
The content of the range is returned either
- as a scalar for a single cell
- as a 1D-array or a tuple when the range
is contained in a single row or column
- as a 2D-array or a tuple of tuples for
a rectangular range of adjacent cells.
Clean error management is included in the code.
The method is available for Basic and Python
user scripts.
The user documentation needs to be updated.
Change-Id: I39cd218f0bf3a6a21e3ada42826069eeee451c6e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/189000
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Version numbers are modified from 25.8 to 26.2.
No effect on actual user scripts,
no documentation update.
Change-Id: I19a6711d43a5641cdb8e00ba59fff8285a9e9120
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/188912
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Constructions (Python) like
import time
while some_event is False:
time.sleep(1)
watching for some_event becoming True
have the drawback to freeze the LibreOffice
user interface.
While next (Basic) snippet
Do While Not some_event
Wait(1000)
does not.
The Python example prevents for waiting for events
that require user input,f.i. entering a value
in a cell.
The here proposed alternative is (Python):
basic = CreateScriptService('Basic')
while some_event is False:
basic.Wait(1000)
This works smoothly.
The Wait() method executes in the background
a Basic Wait statement.
This impacts only Python user scripts.
The change requires an update of the user
documentation.
Change-Id: Idb73907a5e27cf288310e306fb41c0aba9c8a388
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185137
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Introduction of
1. the DefinedNames property
Returns the full sorted list of all
named ranges in the document.
The names defined in a single sheet
are qualified with the sheet name.
2. the DefineName() method
calc.DefineName(definedname, value [,sheetname])
Define a new name in the worksheet, at global
or sheet level. If the name existed already,
it is overwritten without warning.
The Value of the new name may be a range,
a scalar value or a formula.
When a range, the top-left cell is set
as reference cell.
After creation, the new name can be used
in formulaes.
The functions are available both for Basic
and Python user scripts.
The documentation will need an update.
Change-Id: I184e97b734a57ecba2e8a8eae583050116f40296
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184963
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
The
ui.CreateBaseDocument()
method accepted so far to create Base documents
either embedding HSQLDB or FIREBIRD databases
or linked to a Cals spreadsheet.
It is now extended to make the new Base document
finding its datasource in an external Firebird
database file.
The previous signature
ui.CreateBaseDocument(FileName, EmbeddedDatabase,
CalcFileName)
is replaced by
ui.CreateBaseDocument(FileName, EmbeddedDatabase,
DataFileName, CalcFileName)
=> The CalcFileName argument is deprecated. When present,
it is copied to DataFileName.
The EmbeddedDatabase argument may take next values:
HSQLDB (default), FIREBIRD, FIREBIRD_EXTERNAL or CALC.
The change is valid for both Basic and Python scripts.
The documentation should be upgraded.
Change-Id: I5daf418f50739baca6be899eb1444d1b99cf89aa
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184935
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Only Windows implements the Description
property of the FolderPicker by displaying
it in the dialog's header. Otherwise it
is ignored.
This commit harmonizes the behaviour
among all environments, including Linux.
The previous signature:
fs.PickFolder(defaultdirectory, freetext)
is replaced by:
fs.PickFolder(defaultdirectory, title, freetext)
The 'freetext' parameter is kept for backward
compatibility. It becomes obsolete. When present,
and 'title' is absent, its content is pushed
to the dialog's title.
The change is valid both for Basic and Python scripts.
The documentation should be updated accordingly.
Change-Id: I888ee4afa5046212081bbdedc849147ebda1a3bf
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184719
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Dialogs can either be stored in a library
or created from scratch.
When run in non-modal mode, the closing of
a stored dialog with the Close top-right cross
is done by LO correctly.
When the dialog is created from scratch,
a coded XTopWindowListener should do the job.
So far, the listener was activated for all dialogs.
Additionally the Console is a stored dialog.
When closed and relaunched, the processing
will now handle the window Close and
the built-in Close buttons identically, at
least apparently.
Change-Id: I29e0881989816fbf7e3e8bd12f59517bde4b3047
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184662
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
So far, an exception raised in a user script
and detected by ScriptForge gave next behaviour:
- an error message was displayed to the user (1)
- the same error message was recorded in the
console (2)
- the execution of the script was stopped (3)
The actual commit introduces 4 new properties
in the SF_Exception service.
Next two boolean properties may optionally
change above behaviour:
exception.ReportScriptErrors (default = True)
exception.StopWhenError (default = True)
They may change resp. behaviours (1) and (3).
Note that behaviour (2) is preserved anyway.
Their values are set until they are set
again or until the LO session expires.
When StopWhenError is set to False, next two
properties allow to test the success of the
last call to the ScriptForge API and to
define an appropriate action, including the
continuation of the process:
exception.ReturnCode
exception.ReturnCodeDescription
Example:
exc = CreateScriptService("Exception")
fs = CreateScriptService("FileSystem")
exc.ReportScriptErrors = False
exc.StopWhenError = False
fs.OpenTextFile("/aaa/bbb")
if exc.ReturnCode = "UNKNOWNFILEERROR":
...
The test on the return code must precede any
next call to any ScriptForge API entry.
The list of the available return codes is
listed in the SF_Exception.xba source code.
These changes are applicable both for Basic
and Python user scripts.
The user documentation should be reviewed.
Change-Id: I6d274e54ee37702f244e729ea5c9d1751b69abec
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183486
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
The latest version of APSO (1.4.4) introduces
a new positional argument in the
def console():
in apso_utile.py, named 'prettyprint'.
The def is used in
SF_Exception.PythonShell()
The absence of the argument caused
an exception/regression.
The actual patch makes above method compatible
with latest and previous versions of APSO.
No impact on user scripts.
No impact on user documentation.
Change-Id: I0a90112d441bba550b330925742e5021665ecee6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183265
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Returns the prefix used to name new documents
(in English = "Untitled ").
Improves the portability of scripts by making
them more language-agnostic.
Available for Basic and Python scripts.
The user documentation should be updated.
Change-Id: Ie3c06e25fdc30fc1c3c775ef6ebbcee1d9cd77cd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183134
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
The
ImportControl()
method copies a control stored in a dialog
to the actual dialog.
Like in:
dlg1 = CreateScriptService("Dialog", ...)
dlg2 = CreateScriptService("NewDialog", ...)
dlg2.ImportControl(dlg1, "thiscontrol", ...)
The additional arguments contribute to optionally:
- renaming the new control
- storing the new control in a specific page
- repositioning the control (offsetx and offsety args)
- including the OnEventxxx properties
One goal is to help defining individual smaller
dialogs in the IDE and inserting them in a larger
one, keeping them in separate pages.
The function works for Basic and Python user scripts.
The user documentation will have to be updated.
Change-Id: I6155f58d2e8706b73fc5f72c070bb8230cdd17ee
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182865
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
TabPageContainer-type controls are not supported
by the Basic IDE, while they are visually
attractive.
The current commit proposes the insertion
of such a control by code
dialog.CreateTabPageContainer(..., tabheaders, ...)
where tabheaders is simply an array of strings.
The originality of the approach is here to make
the link with dialog pages very easy:
OnTabSelected: define the script to trigger
when a tab is selected
Value: get or set the actual tab
Additionally, the TabPageContainer control is
associated with the SetPageManager() method.
Example on
https://gitlab.com/LibreOfficiant/scriptforge/-/snippets/4823173
The function is available for Basic and Python user scripts.
The documentation will need to be updated accordingly.
Change-Id: I7a1644344cad5f3739055f7e1eec69310ffa019c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182697
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
So far only the SetCellStyle() method
provided means to modify cell formats.
The actual patch introduces next methods
to apply simple and common formats. For
other options use the XCellRange
UNO interface.
- calc.AlignRange(targetrange,alignment,...)
- calc.BorderRange(targetrange,borders,...)
- calc.ColorizeRange(targetrange,foreground,background,...)
- calc.DecorateFont(targetrange,fontname,fontsize,
decoration,...)
- calc.FormatRange(targetrange,numberformat,locale,...)
Extra arguments ("...") are:
FilterFormula: a Calc formula to select cells
FilterScope; CELL, ROW or COLUMN
to allow a kind of static conditional formats.
All methods are applicable to Basic and Python
user scripts.
This change will require an update of the
user documentation.
Change-Id: Ic824aebd763f2b55364c2c0bea17430f32512742
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181854
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
When a user script invokes CreateScriptService()
for a not yet used library, ScriptForge loads
the library and searches for the list of
services provided by that library.
The list can be found in a specific method
that the library must contain,
RegisterScriptServices()
in whatever module.
The exploration was done so far through a
ScriptProvider UNO service. This service includes
all programming languages, including Java,
even without Java being used. This caused
an inconvenient error message when Java
is disabled in the advanced options.
This service is now replaced by a
com.sun.star.comp.scripting.ScriptProviderForBasic
service. This gives a direct access to a lower
branch of the scripts tree and skips the Java issue.
All the changes are done in the
ScriptForge.SF_Services._FindModuleFrom Method()
function.
No change required in the user documentation.
Change-Id: I4a6820e5d1a379bf5b61c6077db8a9a382c1757d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181445
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
The %enuHeaders property returns,
as an array/tuple of strings the list
of the menus present in the menubar.
This is a helper for the CreateMenu()
method:
- check if the menu exists already to
avoid duplicates
- ease the choice of the Before argument
The property is applicable to next classes:
- Document, and its subclasses
Base, Calc, Writer, FormDocument
- Datasheet
The property is made available to Basic
and Python user scripts.
This new property will require an update
of the user documentation/help
Change-Id: Ia14daf6c58973e06d576b350e416eb178f70feb3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181065
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
The contextmenu service handles the context
menus stored in a document. So far, it
provided only the AddItem() method to add
new items at the bottom of the menu.
The new method allows to forget the preconfigured
menu and to replace it completely.
Example: associate next Sub with the
on-right-click event of sheet 'Sheet1'
=> The custom menu appears when
right-clicking in column C, otherwise
normal behaviour
Sub OnRightClick1(Optional XRange)
' Xrange is a com.sun.star.table.XCellRange
Dim calc, menu, bColumn
Set calc = CreateScriptService("Calc", ThisComponent)
Set menu = calc.ContextMenus("cell")
menu.RemoveAllItems()
bColumn = ( Len(calc.Intersect("Sheet1.$C:$C", _
XRange.AbsoluteName)) > 0 )
If bColumn Then
menu.AddItem("A", Script := "vnd.sun.star.script:...&location=document")
...
End If
menu.Activate(bColumn)
End Sub
The function is available both for Basic and Python user scripts.
The user documentation will have to be reviewed.
Change-Id: I84ee8724bf99c37397a19d729133cc4686a63980
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180520
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
The
calc.Intersect(range1, range2) method
computes the common area as a string
which is a sub-range of both input ranges.
It returns an empty string when the
sub-range is empty.
Potential use case: customizing a popup
or context menu depending on the presence
of the selected cell in a given area.
In addition, the A1Style() method returns
the sheetname in the output string only
when it is an explicit argument.
Changes are applicable both for Basic and
Python scripts.
They require an update of the user documentation.
Change-Id: I920fc8bee6dace9ceed263a0570b4c0197bc8cb8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180479
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
In addition the VALIDATEREGEX message
is obsolete and removed from next
language files
modified: wizards/source/scriptforge/po/es.po
modified: wizards/source/scriptforge/po/fr.po
modified: wizards/source/scriptforge/po/pt.po
Change-Id: I67c2e5604e548870bf1bdceb9641d4802530e437
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180413
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Replace:
-"supporté" with "pris en charge"
-"tableau" with "matrice" when it's about an array
Change-Id: I7c91bece58da90beb8c9787c1310fcd235698402
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180306
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins