When considering next python user script:
a = CreateScriptService(...)
a.prop = ...
print(a.prop)
print(a.prop)
so far, the evaluation of a.prop was done
either once or twice depending on
- a parameter of the class a is an instance of
- the read-only status of prop (True/False)
Now the recomputation of the expression
depends on a parameter of prop which can take
one of next values:
0: prop is read-only and not re-evaluated
1: prop is read-only but re-evaluated
f.i. because a user action can change its value
2: prop is editable and not re-evaluated
f.i. because it can be changed only by code
3: prop is editable and always re-evaluated
The change will decrease the number of useless
and more costly recomputations of properties.
Change-Id: I11412a58772147dab2e6b9b06c31477135932603
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172600
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Complete a predefined context menu with new items
placed at its bottom.
A context menu is obtained by a right-click
on several areas of a document. Each area has
its own context menu.
Each component model has its own set of context menus.
A context menu is usually predefined at
LibreOffice installation. Customization is done
statically with the Tools + Customize dialog.
The actual new service provides a mean
to make temporary additions at the bottom of a
context menu. Those changes are lost when
the document is closed.
The name of a context menu is the last component
of the resource URL:
"private:resource/popupmenu/the-name-here"
Context menu items are either usual items or
line separators. Checkboxes or radio buttons
are not supported.
Items run a command or a script when clicked.
The service implements 2 methods:
AddItem() adds an entry in the menu hierarchy
Activate() shows or hides the added entries
A context menu can be defined from both Basic
and Python user scripts.
An update of the documentation is required.
Change-Id: Id77f1f2565d75e36c09b13972330d0f83b3f1db4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172355
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Python typing hints may be stored either
- inside the original .py source file
- in a separate .pyi source file (aka. STUB).
Choice is made to create a new scriptforge.pyi file
- to allow hiding the private functions
- to specialize each module: technical doc
vs. user doc
- to allow potential later translation
- to minimize the impact at run-time:
stubs are active only during code edition.
The new scriptforge.pyi module
- provides the static type checking of all the public
interfaces (methods/properties) of the ScriptForge API.
- when the user uses an IDE like PyCharm or VSCode,
(s)he might benefit from the typing hints provided
by the signatures and docstrings stored
in the module.
Visually, while editing a user script:
- hovering an object instance, a method or a property
displays its detailed description
- a "." after an object instance displays a drop-down
box listing all available interfaces
- brackets after a method-name start code-completion
by displaying its arguments.
Limitations: SF supports ProperCase, lowercase and
camelCase naming for methods and properties.
Only ProperCase is described in scriptforge.pyi.
Extending to the other 2 notations would be easy
but would also overload needlessly the drop-down lists.
The effective code (scriptforge.py) is completed
with a series of importable variable types,
corresponding roughly with the available service
instance names in uppercase. Example
from scriptforge import CALC, RANGE
def userfct(c: CALC, r: RANGE) -> RANGE:
r1: RANGE = "A1:K10"
Objective: enrich the signatures in user scripts
and benefit from the same hints when the variable
types cannot be derived from the context.
The help documentation should be complemented
with the actual additional feature.
Change-Id: I6c39939a3cdbed94828e9449cd691fe15c24c923
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164867
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Transactions are managed by next UNO properties:
XConnection.AutoCommit
XConnection.TransactionIsolation
(They seem very easy to use but, in practice,
are not easy at all)
Usually all transactions are in auto-commit mode,
that means, a commit takes place after each
single SQL command.
Switching auto-commit off means however that
the connection needs to be of type "ISOLATED"
and not of the default type "SHARED".
=> The usual shared connection must be closed.
As a consequence, all rowsets/resultsets linked
to the shared connection need to be closed as well.
=> Additionally the buffers must be emptied (flushed)
to make committed data visible in the Base user
interface.
All above aspects and constraints are managed in the
database.SetTransactionMode(transactionmode)
database.Commit()
database.Rollback()
methods transparently for the user scripts.
The [transactionmode] argument has as value one of
the TransactionIsolation constants.
Without argument, database.SetTransactionMode()
restores the automatic mode.
The manual transaction mode is available for both
Basic and Python scripts.
Its implementation will require an update of the
documentation about the Database service.
Change-Id: I214bd91a1744d6d24609bc5efc987152c6e946c9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159867
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
The
database.GetRows()
dataset.GetRows()
methods return an array of data collected
in a database table or query.
When a column has the type DATE, the transmission
of their values through the Basic-Python bridge
require them to be converted upfront to UNO
DateTime structures.
The later conversion from UNO DateTime to the python
datetime.datetime structure has been added with
this patch.
No impact on Basic scripts.
The documentation does not need to be changed.
Change-Id: I7a6533aff70d2d1402bfc3f057b65a4940148cc4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159348
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
A dataset represents a set of tabular data
stored/produced by a database.
To use datasets, the database instance must exist
but the Base document may not be open.
A Dataset instance is create either with
- the (new) database.CreateDataset() method
- from an existing dataset with the (new)
dataset.CreateDataset() method.
The proposed API supports next main purposes:
- browse for- and backward thru the dataset to get its content
- update any record with new values
- create new records or delete some.
In summary, the AKA "CRUD" operations
(create, read, update, delete).
The originality of the proposed API is the use
of a dense syntax to make insertions and updates
easy and readable:
Example:
(BASIC)
Dim newID As Long
newID = dataset.Insert("LastName", "Doe", "FirstName", "John")
' ... is equivalent to:
Dim dict As Object, newID As Long
Set dict = CreateScriptService("ScriptForge.Dictionary")
dict.Add("LastName", "Doe")
dict.Add("FirstName", "John")
newID = dataset.Insert(dict)
(PYTHON) - next statements are equivalent
newid = dataset.Insert('LastName', 'Doe', 'FirstName', 'John')
newid = dataset.Insert({'LastName': 'Doe', 'FirstName': 'John'})
newid = dataset.Insert(dict(LastName = 'Doe', FirstName = 'John'))
newid = dataset.Insert(LastName = 'Doe', FirstName = 'John')
You will notice that the returned value is the AutoValue primery
key (when it exists) which makes it reuse as a foreign key
immediate.
The API is fully available both in Basic and Python user scripts.
The new service will require its inclusion in the user documentation.
Change-Id: I4f834c4234e5b96ec8fddfffbad791ecf31899df
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159325
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Introduction of new properties and methods:
- StyleFamilies
List of available style families
All document types except Base
- XStyle(family, stylename)
UNO representation of given style
All document types except Base
- Styles(family, [namepattern, used, userdefined,
parentstyle, category)
A list of styles matching the given criteria
All document types except Base
- DeleteStyles(family, styleslist)
Suppress the user-defined styles in the list
All document types except Base and FormDocument
- ImportStylesFromFile(filename, families, overwrite)
Load styles from a closed file
Calc and Writer only
Example: to delete unused styles:
a = doc.Styles("ParagraphStyles", used := False)
doc.DeleteStyles("ParagraphStyles", a)
All functionalities are available from Basic and
Python scripts.
Documentation has to be completed.
Change-Id: I2533c14912257b58feb42bb11ff9d151c7b9531a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157563
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
The XDocumentSettings property returns a
com.sun.star.XXX.DocumentSettings
UNO object.
XXX = sheet, text, drawing or presentation
It gives access to a bunch of UNO internal
properties, specific to the document(s type.
The property is available in Basic and Python
user scripts.
An update of the SF_Document service help
page is required.
Change-Id: I9d6db473c91ac5b1814def9cd100e874aa5490cd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156475
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Incremental changes had made the code in
SF_PythonHelper.xba
scriptforge.py
(which manage the protocol between the Python
user scripts and the ScriptForge services
implemented in Basic) less readable and efficient.
Next features have been reviewed:
- dict instances may be passed as arguments
and returned. Conversions are done on-th-fly.
- dates may be passed as arguments
and returned. Conversions are done on-th-fly.
The lists of hardcoded methods have been removed.
- 2D arrays in standard modules may be passed
as arguments and returned. Conversions are done
on-th-fly. The lists of hardcoded methods have
been removed.
- The hardcoded list of methods requiring a post-
processing has been reduced.
- Methods in standard modules, when not returning
an array, are also executed with CallByName().
- The unused 'localProperties' attribute in Python
services has been removed.
- Flags about arrays in standard modules have been
adapted in
filesystem.Files()
filesystem.SubFolders()
session.UnoMethods()
session.UnoProperties()
string.SplitNotQuoted()
string.Wrap()
ui.Documents()
- The platform.UserData property became a usual
property.
Dictionaries are admitted as arguments and return
values. As a consquence next functions are supported
in Python as well:
session.GetPDFExportOpetions()
session.SetPDFExportOptions()
document, calc, writer.CustomProperties
document, calc, writer.DocumentProperties
These changes require an update of the help pages.
Non-regression tests were run with success. All changes
are transparent for existing scripts.
Change-Id: Iae7a1f5090c590209cd3cb2314c919c44736eba9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155860
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
The UserData property lists the content of the
"User Data" oage of the Options dialog.
The content is returned:
- in Basic: in a SF_Dictionary instance
- in Python: in a dict[] instance.
The list of the available keys is:
city, company, country, email, encryptionkey,
encrypttoself, fax, firstname, homephone,
initials, lastname, officephone, position,
postalcode, signingkey, state, street, title
Many are different from the UNO/priginal values
to make them more user understandable.
This commit will require an update of the SF_Platform
help page.
Both Basic and Python user scripts are supported.
Change-Id: If645579ee9109a1b8180da5a5f3a71979bb5ca59
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155024
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
In the FileSystem service, the
- SubFolders()
- Files()
methods receive an optional argument
IncludeSubfolders (Boolean).
That argument determines whether or not only
the given FolderName is explored or also its subfolders
up to the bottom of the folders structure.
The argument must be used with caution as the number
of returned folders or files may increase rapidly.
anThis could consume excessive process time.
This patch will require an update of the
help page about the filesystem service.
The new argument is available both for Basic and Python
user scripts.
Change-Id: Id2a96cd63cb51f8681f20a203a711b47a636fc3a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154763
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
1. The SF_Document services (document, base, calc,
formdocument, writer) receive a new FileSystem
property that returns the "root" of the
component's file structure under the format:
"vnd.sun.star.tdoc:/XXX"
XXX being the document's identifier.
The implementation does not use the RuntimeUID
(UNO property of the OfficeDocument service) which
is optional and, f.i. not present for Base documents.
Instead the
css.frame.TransientDocumentsDocumentContentFactory
service is used.
2. The SF_FileSystem and SF_TextStream modules have been
reviewed to support the new context.
Next restrictions have been met:
- The FileNaming property is always cnsidered as 'URL'
- CompareFiles() is not applicable
- GetFileLen() always returns zero
- HashFile() is not applicable
- Normalize() always returns the input string unchanged
- PickFile() is not applicable
- PickFolder() is not applicable
Additionally,
- CreatetextFile()
- OpenTextFile() in write or append modes
copy or initialize the file in a temporary storage
and write it back in the document when it is being closed.
The process is transparent for the user.
3. The GetTempName() method accepts an option
Extension
argument, for better convenience.
The new functionalities are available in Basic and Python.
Changes require an update of the help documentation.
Change-Id: Ibf8dd9983656923cf6ab43d9f48398dc4d1e6307
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154443
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Duplicate an existing control of any type
in the actual dialog.
The duplicated control is left unchanged.
The new control can be relocated.
Args:
SourceName: the name of the control to duplicate
ControlName: the name of the new control.
It must not exist yet.
Left, Top: the coordinates of the new control
expressed in "Map AppFont" units.
Returns:
an instance of the SF_DialogControl class or Nothing
The method is available from Basic and Python user scripts
This change will require an update of the SF_Dialog help page.
Change-Id: I5c2a5404a14ad60b2d4df2ac7eabbf0ddd843170
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152333
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Set the tabulation index f a series of controls.
The sequence of controls are given as an array
of control names from the first to the last.
Next controls will not be accessible (anymore ?)
via the TAB key if >=1 of next conditions is met:
- if they are not in the given list
- if their type is FixedLine, GroupBox or ProgressBar
- if the control is disabled
Args:
TabsList: an array of valid control names in the order of tabulation.
Start: the tab index to be assigned to the 1st control in the list. Default = 1.
Increment: the difference between 2 successive tab indexes. Default = 1.
Returns:
True when successful.
The method is available from Basic and Python user scripts
This change will require an update of the SF_Dialog help page.
Change-Id: Ie854227691c4e182b49a521b1285deaa4de3d1ff
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152166
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
A dialog service is returned by next statement
dialog = CreateScriptService("newdialog", dialogname, place)
All properties and methods applicable to predefined
dialogs are available for such new dialogs.
In particular the series of CreateXXX() methods for the addition
of ne dialog controls.
The functionality is available from Basic and Python user
scripts.
An update of the SFDialogs.SF_Dialog help page is required.
A display rendering unstability (flickerings, delays, ..) has
been observed when (all conditions must be met)
- the user script is run from Python
- from inside the LibreOffice process
- the dialog is non-modal
Change-Id: Id3f311cd04497fd79712ce712bdb2724b5caa861
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152071
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
The dialog service hosts now a bunch of methods
to create new controls dynamically in an existing
dialog predefined in the Basic IDE.
In other words, a dialog is initialized with controls
in the Basic IDE. New controls can be added at run-time
before or after the Execute() statement.
All the new methods have in common their first 2 arguments:
ControlName
Place: an (X, Y, Width, Height) array
or a com.sun.star.awt.Rectangle
New methods:
CreateButton(..., toggle, push)
CreateCheckBox(..., multiline)
CreateComboBox(..., border, dropdown, linecount)
CreateCurrencyField(..., border, spinbutton, minvalue,
maxvalue, increment, accuracy)
CreateDateField(..., border, dropdown, mindate, maxdate)
CreateFileControl(..., border)
CreateFixedLine(..., orientation)
CreateFixedText(..., border, multiline, align, verticalalign)
CreateFormattedField(..., border, spinbutton, minvalue,
maxvalue)
CreateGroupBox(...)
CreateImageControl(..., border, scale)
CreateListBox(..., border, dropdown, linecount, multiselect)
CreateNumericField(..., border, spinbutton, minvalue,
maxvalue, increment, accuracy)
CreatePatternField(..., border, editmask, literalmask)
CreateProgressBar(..., border, minvalue, maxvalue)
CreateRadioButton(..., multiline)
CreateScrollBar(..., orientation, border, minvalue, maxvalue)
CreateTableControl(..., border, rowheaders, columnheaders,
scrollbars, gridlines)
CreateTextField(..., border, multiline, maximumlength,
passwordcharacter)
CreateTimeField(..., border, mintime, maxtime)
CreateTreeControl(..., border)
All the methods return a SF_DialogControl instance.
The arguments have bben chosen based on functionality
rather than on layout. After the creatio of the control,
most properties and methods relevant to SF_DialogControl
objects are applicable. Also the XControlModel property
might contribute to layout refinements.
Other changes:
- The SF_DialogControl class receives next updatable
properties: Border and TabIndex
- The dialogcontrol.SetTableData() receives an
additional argument: rowheaderwidth
- The dialogcontrol.Resize() method without arguments
resizes the control to its "preferred size", a size
adjusted depending on its actual content
All the new functionalities are callable from both
Basic and Python user scripts.
Described changes will require a serios review of the
Dialog and DialogControl help pages.
Change-Id: I654eeae5456527bf14b1f4b43f04d176bbd830b6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151896
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Controls designated in english as "Hyperlink controls"
in the Basic IDE are from now on accepted as instances
of the SF_DialogControl service.
All generic properties are accepted.
The supported specific properties are:
- Caption (the text that appears in the dialog box)
- URL (the URL to activate when clicked)
The new control type is supported in Basic and Python
user scripts.
The SFDialogs.DialogControl help page needs to be updated.
Change-Id: I4827834ad8ef336c084ee51b5285b85745ceb1b9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150824
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Dimensioning a dialog in the Basic IDE is done
by using "Map AppFont" units.
Map AppFont units are device and resolution independent.
One Map AppFont unit is equal to one eighth of the average
character (Systemfont) height and one quarter of the average
character width.
A dialog or control model also uses AppFont units.
While their views use pixels.
This is confusing. It also complicates size prototyping
with the Basic IDE.
In ScriptForge, sizing and positioning a dialog or a control
is done from now on in AppFont units as well.
Additionally, X and Y positions accept now negative values.
Compatibility with past is ensured: dynamic change or
position and size is a new feature in 7.6.
The change is valid both for Basic and Python user scripts.
It requires a small change in the actual documentation
(pixels => AppFontunits)
Change-Id: Id80b0ccf473eb012b0a8c85d66f5a8ada9b26be5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150704
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Addition of method
control.Resize(X, Y, Width, Height)
to selectively (arguments are applicable only when present)
update the position and/or the size of any
dialog control.
Addition of updatable properties:
Height
Width
X
Y
for the same purpose.
All measures are expressed in PIXELS.
The measures for dialogs are also as from now expressed
in pixels.
Changes are applicable to Basic and Python user scripts.
Documentation should be updated.
Change-Id: I03a6c819efa6a2a67c88403f1ae644d94eb7f2d7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149174
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
A dialog box and its controls may be associated
with scripts triggered by events (mouse moved,
key pressed, ...).
The link is usually preset in the Basic IDE when
the dialog is designed.
So far, ScriptForge did not offer the setting of
a link event-script by code.
The actual commit removes this limitation: every
On-property related to either a dialog or a dialog
control is now editbale.
With the important precision that such a property
may be updated ONLY IF it was NOT PRESET in the
Basic IDE.
Static (IDE) and dynamic (by code) definition of
a specific On property on a specific dialog or on
a specific dialog control are mutually exclusive.
The new capacity may be used both in Basic and Python scripts.
A short update of the help texts (dialog and dialogcontrol)
is needed with mention of above restriction.
Change-Id: Ia078aaab317ced7ade7ce69694504013f8e768a1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148800
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Each component has its own set of toolbars, depending
on the component type (Calc, Writer, Basic IDE, ...).
In the context of the actual class, a toolbar
is presumed defined statically:
- either by the application
- or by a customization done by the user.
The definition of a toolbar can be stored
in the application configuration files
or in the current document.
Changes made by scripts to toolbars stored
in the application are persistent. They are valid
for all documents of the same type.
Note that the menubar and the statusbar
are not considered toolbars in this context.
A toolbar consists in a series of graphical
controls to trigger actions.
The "Toolbar" service gives access to the "ToolbarButton" service to manage
the individual buttons belonging to the toolbar.
The "Toolbar" service is triggered from next
services: Document, Calc, Writer, Base, FormDocument
and Datasheet. All those components might host toolbars.
Proposed properties in the Toolbar service:
BuiltIn
Docked
HasGlobalScope
Name
ResourceURL
Visible (r/w)
XUIElement
Proposed method:
ToolbarButtons()
Proposed properties in the ToolbarButton service:
Caption
Height
Index
OnClick (r/w)
Parent
TipText (r/w)
Visible (r/w)
X
Y
(The Height, Width, X, Y properties allow for
easy hook of a popup menu to tye button)
Proposed method:
Execute()
Both services are available both from Basic and Python user scripts.
An update of the dcumentation help is required.
Change-Id: I43cb523b52e3d6362994557d74c4ef9faa220507
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147925
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
While a script is executed any display update
resulting from that execution is done immediately.
For performance reasons it might be an advantage
to differ the display updates up to the end of the script.
This is where pairs of Echo() methods to set
and reset the removal of the immediate updates
may be beneficial.
Optionally the actual mouse pointer can be
modified to the image of an hourglass.
Arguments:
EchoOn: when False, the display updates are suspended.
Default = True.
Multiple calls with EchoOn = False are harmless.
Hourglass: when True, the mouse pointer is changed
to an hourglass. Default = False.
The mouse pointer needs to be inside the actual
document's window.
Note that it is very likely that at the least
manual movement of the mouse, the operating system
or the LibreOffice process will take back
the control of the mouse icon and its usual behaviour.
The method may be called from any document, including Calc and
Writer, or form document.
It may be invoked from Basic and Python user scripts.
Echo() should be documented in the sfdocument.xhp help page.
Change-Id: I4d669f5e332131bd1b2efcd33b7a98b304796ad1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146258
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Remove duplicate values from a range of values.
The comparison between rows is done on a subset
of the columns in the range.
The resulting range replaces the input range,
in which, either:
all duplicate rows are cleared from their content
all duplicate rows are suppressed
and rows below are pushed upwards.
Anyway, the first copy of each set of duplicates
is kept and the initial sequence is preserved.
Arguments of the method:
Range: the range, as a string,
from which the duplicate rows should be removed
Columns: an array of column numbers to compare;
items are in the interval [1 .. range width]
Default = the first column in the range
Header: when True, the first row is a header row.
Default = False.
CaseSensitive: for string comparisons.
Default = False.
Mode: either "CLEAR" or "COMPACT" (Default)
For large ranges, the "COMPACT" mode
is probably significantly slower.
The method has been implemented for Basic
and Python user scripts.
The calc.xhp help page should be updated accordingly.
Change-Id: I352b2f3da98974d9482575850550cec4e27d2e01
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145954
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
The SF_FormDocument service is focused on :
- The orchestration of Base form documents
(aka Base Forms, but this is confusing)
and the identification of and the access to their controls.
- Form documents are always contained in a Base document.
A form document may be opened either:
- via code or user interface from the Base file welcome page
- via code only, without having its Base container opened first
In any mode, a form document can be opened only in 1 single copy.
The FormDocument service is triggered either by
base.OpenFormDocument(...)
database.OpenFormDocument(...)
' Base file may be closed
ui.GetDocument(...)
Specific methods:
CloseDocument()
Forms()
GetDatabase()
PrintOut()
Next methods are inherited from the Document superclass:
Activate()
CreateMenu(), RemoveMenu()
ExportAsPdf()
RunCommand()
SaveCopyAs()
SetPrinter()
As a consequence, next methods remain available
but should be declared as deprecated in the help:
base.CloseFormDocument()
base.Forms()
base.PrintOut()
base.SetPrinter()
Above changes have several more minor impacts :
- beside IsCalc, IsWriter, ... , a new IsFormDocument property
- the UI service identifies open form documents
- a new service means a new entry to register
in the Services catalog
- management of form events has been reviewed
- the connection between Base, FormDocument, Form
and Database services is reinforced
- menus were available on components, now also on sub-components
The new service is available for both Basic and Python user scripts.
It requires in the help
- a new sf_formdocument page
- a review of the sf_base, sf_database, sf_form, sf_ui pages
Change-Id: Ib06d1c4565ca093af2f068fa5b8082082641752e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145080
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
For homogeneity with the Form service,
the
ApplyFilter()
OrderBy()
methods are replaced by the
Filter
OrderBy
updatable properties respectively.
Functionally there is no change.
This substitution is valid both for Basic and
Python user scripts.
Change-Id: I63a1d5c4554437b6a2cd634677e6eee246cb59ab
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142355
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Next 2 methods are added:
CreateMenu()
RemoveMenu()
They allow the addition of a menu entry in the menubar
of datasheets in the same way as in documents.
The implementation required to make the
SFWidgets.SF_Menu
SFWidgets.SF_MenuListener
SFWidgets.SF_Register
classes and modules more generic to be applicable
in several contexts.
In addition, 2 properties are added:
DatabaseFileName
ParentDatabase
to better identify the database from which the datasheet
is derived.
New properties and methods are applicable both
for Basic and Python user scripts.
Change-Id: Iac6318287e89b18810a53ec5928a68e921ea96db
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142285
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
A datasheet is the visual representation
of tabular data produced by a database.
In the user interface of LibreOffice
it is the result of the opening of a table or a query.
In this case the concerned Base document must be open.
In the context of ScriptForge, a datasheet
may be opened automatically by script code :
- either by reproducing the behaviour of the user interface
- or at any moment.
In this case the Base document does not need to be open.
Additionally, any SELECT SQL statement
may define the datasheet display.
The proposed API allows for either datasheets
(opened manually of by code) in particular
to know which cell is selected and its content.
Properties:
ColumnHeaders
CurrentColumn
CurrentRow
LastRow
Source
SourceType
XComponent
XControlModel
XTabControllerModel
Methods
Activate
ApplyFilter
CloseDatasheet
GetValue
GetText
GoToCell
OrderBy
The Base and Database services are enriched with the
OpenTable
OpenQuery
methods. The Database service gets also a new
OpenSql
method.
The whole set of properties and methods is available
both for Basic and Python scripts.
This new service requires a new help page dedicated
to this service, as well as an update of the
pages about the Base and Database services.
Change-Id: Ib409ce74d95de78f2792ba53e7ae554eab0867ab
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142118
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
The method extends the set of functions compatible
with their corresponding Basic builtin functions.
BTW it might avoid the need for the user to
import uno
in his/her Python scripts.
Of course (s)he remains free to prefer the latter.
Impact only on Python scripts. Basic part is unchanged.
An update of the help page about the Basic service is reuired.
Change-Id: I3b01eb76aa52f62fa54bae49ddb45755126bc3fe
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141429
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
The SetPageManager() method
Define how the dialog displays pages.
The page manager is an alternative to the direct use
of the Page property of the dialog and dialogcontrol objects.
The arguments define which controls are involved
in the orchestration of the displayed pages.
Possible options:
- select a value in a list- or combobox
- select an item in a group of radio buttons
- select a button linked to a page
placed side-by-side the buttons can simulate a tabbed interface
- press a NEXT or BACK button like in many wizards
Those options may be combined.
The control updates will be synchronized.
The method will set the actual page number to 1.
Afterwards the Page property may be used to display any other page
The SetPageManager() method is to be run
only once and before the Execute() statement.
If invoked several times, subsequent calls will be ignored.
The method will define new listeners
on the concerned controls, addressing generic routines.
The corresponding events will be fired during the dialog execution.
Preset events (in the Basic IDE) will be preserved
and executed immediately AFTER the page change.
The listeners will be removed at dialog termination.
The implementation has next parts:
1. Store the arguments in the Dialog instance
2. Set appropriate listeners on involved controls
3. Page change synchronizes the values in the involved controls
(be it by user code or by page manager)
4. Events triggered by listeners change page number
The method is available both in Basic and Python contexts.
This commit require the Dialog help page to be updated.
Change-Id: I00a0212414f283102c73de4ceb488aa1aeddf746
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141257
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Bridge mode = python dialogs with LO process via socket.
Behaviour before actual patch:
the exception.PythonShell() method gives a Python error on the
from apso_utils import console
statement, because the APSO libraries are not in the
pythonpath.
(They are set in the path by the exension in macro mode)
New behaviour:
the exception.PythonShell() method does nothing,
the import statement is not executed, hence no error.
The rationale behind is:
- in bridge mode, the macro run is started in practice
from either a Python console or an IDE console
that receive evntual print() statements outputs
- there is no need for an APSO console that, anyway, should
not receive any output of print() statements, except
if redirection of the output towards the APSO console
(run in the [LO] process) was possible, quod non.
- the same script may be executed in both bridge and macro modes
without change
Change-Id: Id7c8eb19cd074bf39f470d84b5eb48880e908f39
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139772
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
A FilterFormula is a Calc formula that returns TRUE or FALSE
The formula is expressed in terms of
- the top-left cell of the range when FilterScope = "CELL"
- the topmost row of the range when FilterScope = "ROW"
- the leftmost column of the range when FilterScope = "COLUMN"
After pasting, the relative and absolute references
will be interpreted correctly.
The FilterScope indicates the way the formula is applied,
once by row, column or individual cell.
The requested action is done only on the rows/columns/cells
for which the FilterFormula returns True.
Next methods receive 2 new arguments:
=> FilterFormula and FilterScope:
ClearAll()
ClearFormats()
ClearValues()
SetCellStyle()
These changes are valid for Basic and Python user scripts.
Without these new arguments above methods behave as before.
The documentation needs to be adapted:
- inclusion of FilterFormula and FilterScope concepts in the
DEFINITIONS section of the SF_Calc help page
- new arguments to add in resp. methods
Change-Id: I657b231252106b91ed7e27a49ef3331c1fcee917
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138590
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
(patch https://gerrit.libreoffice.org/c/core/+/137084 cont'd)
In SF_PythonHelper._PythonDispatcher():
Force a hardcoded call of the methods in the Dialog
service which may potentially be invoked while the
dialog is displayed, bypassing the generic CallByName()
Basic builtin function:
Activate
Center
EndExecute
Resize
Execute => was missing in the list
Case when a parent dialog opens a child dialog
(Controls is already hardcoded because returning an array)
Change-Id: Ia12fccbb61362768301df6670161f258b32d3a78
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137289
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
In SF_PythonHelper._PythonDispatcher():
Force a hardcoded call of the methods in the Dialog
service which may potentially be invoked while the
dialog is displayed, bypassing the generic CallByName()
Basic builtin function:
Activate
Center
EndExecute
Resize
(Controls is already hardcoded because returning an array)
Change-Id: I4931f43b37ae5f7337740d1c65b255f4a14ca069
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137084
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Normalize a pathname by collapsing redundant
separators and up-level references
so that A//B, A/B/, A/./B and A/foo/../B
all become A/B.
On Windows, it converts forward slashes
to backward slashes.
The Basic Normalize() method invokes the
_SF_FileSystem__Normalize() function located in
the ScriptForgeHelper.py module for execution
with the os.path builtin library
The os.path.normpath() function can easily be
executed directly from python user scripts.
However the FileSystem.Normalize() method is
proposed as well for Python scripts
- for compatibility Basic/Python reasons
- to manage the FileNaming notation
Change-Id: I1e089612432bd2c75b2e76ffa984289ef7f9d75c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136835
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Create a new pivot table with the properties defined by the arguments.
If a pivot table with the same name exists already in the
targeted sheet, it will be erased without warning.
Parameters:
PivotTableName: The user-defined name of the new pivottable
SourceRange: The range as a string containing the raw data.
The first row of the range is presumed to contain
the field names of the new pivot table
TargetCell: the top left cell or the range as a string
where to locate the pivot table.
Only the top left cell of the range will be considered.
DataFields: A single string or an array of
field name + function to apply, formatted like:
Array("FieldName[;Function]", ...)
The allowed functions are: Sum, Count, Average, Max,
Min, Product, CountNums, StDev, StDevP, Var, VarP and Median.
The default function is:
When the values are all numerical, Sum is used, otherwise Count.
RowFields: A single string or an array of the field
names heading the pivot table rows
ColumnFields: A single string or an array of the field
names heading the pivot table columns
FilterButton: When True (default), display a "Filter"
button above the pivot table
RowTotals: When True (default), display a separate
column for row totals
ColumnTotals: When True (default), display a
separate row for column totals
Returns:
Return the range where the new pivot table is deployed.
The method may be used in Basic and Python user scripts.
Change-Id: I99df23e1b1b97b17a747ae15a079d7e2f5655b41
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133131
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
The CompactUp(CompactLeft) method:
Delete the rows(columns) of a specified range matching a filter
expressed as a formula applied on each row(column).
The deleted cells can span whole rows(columns)
or be limited to the width(height) of the range.
The execution of the method has no effect on the
current selection.
Args:
Range: the range in which cells have to be erased, as a string
WholeRow(WholeColumn): when True (default = False),
erase whole rows(columns)
FilterFormula: the formula to be applied on each row(column).
The row(column) is erased when the formula results in True.
The formula shall probably involve one or more cells of
the first row(column) of the range..
By default, a row is erased when all the cells
of the row(column) are empty,
i.e. suppose the range is "A1:J200" (width = 10),
the default value [for CompactUp] becomes "=(COUNTBLANK(A1:J1)=10)"
Returns:
A string representing the location of the initial range
after compaction, or the zero-length string if the whole range
has been deleted.
Examples for CompactUp():
newrange = oDoc.CompactUp("SheetX.G1:L10")
' All empty rows of the range are suppressed
newrange = oDoc.CompactUp("SheetX.G1:L10", WholeRow := True, _
FilterFormula := "=(G1=""X"")")
' The rows having a "X" in column G are completely suppressed
Both methods are available for use from Basic and Python scripts.
Change-Id: Ib1269b22bcd189ca86a1bd3bda2c67e895598cb0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132783
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
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>
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>
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>
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>