Adds a global variable to the QuickJS context called XSCRIPTCONTEXT
which holds an instance of ScriptContext. This makes the scripts more
compatible with scripts written for the Rhino JS implementation and also
more like Python scripts.
Change-Id: I95fd86229786a37c6fff282f45f65555cbde21cf
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/205122
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
Adds a generic helper class that implements the XScriptContext
interface. This interface is used in the providers to provide the
XSCRIPTCONTEXT builtin variable. For example for the Python provider it
is implemented in Python code. This C++ implementation can be reused by
any script providers.
Change-Id: I56f23138179555dee84ebf368e8a10cfb2fb4066
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/205121
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
Tested-by: Jenkins
Adds an XBrowseNode implementation for JavaScript scripts using the
QuickJS bindings so that JS files can be found and executed from the
macro organizer. Unlike in Python macros, the entire source file becomes
a single macro instead of trying to find function definitions in the
source.
Change-Id: I73d0c6e6fc6bb7ffd4f6164d1f1887d03bfdfe62
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/203219
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
This makes the create button enabled for script providers based on
SingleScriptProvider. When the button is pressed the SingleScriptFactory
is queried to get an example script to fill the new macro with and then
the file is created.
This is based on the code for the Python script provider in tdf#56289.
Change-Id: I11a6782e55ba775afed6b62f24ae0d11c347e529
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/203283
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
Tested-by: Jenkins
The Editable property is now advertised on script providers based on
SingleScriptProvider. Once invoked, the system default application for
the script will be opened using SystemShellExecute.
On Windows, the default app is queried via AssocQueryStringW and then
passed to the SingleScriptFactory to check if it looks like an
interpreter for the given language. If so, the script is opened in
Notepad instead to avoid just executing the script.
This is based on the code for the Python script provider in tdf#56289.
Change-Id: Ia89ddbdd92b4d76c3a4ce133ffcf9b6d7a9f1e27
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/203282
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
Adds a set of helpers to implement a script provider where the script
files are the entire macro. The provider only needs to make a subclass
of the abstract SingleScriptFactory class to provide the filename
extension, language name and a method to convert the contents of a file
to an XScript. The parts about handling file browsing and reading the
file contents are in the shared helper code.
This is based on the script provider from Luno.
Change-Id: Id39f3a07e887898650b0d77ec493011fb5acc858
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/203216
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
There seems to be an idiom used throughout the LibreOffice code where
lastIndexOf is called and then the returned index is checked to see if
it covers the entire end of the string. This should be equivalent to
just calling endsWith but it’s slightly less efficient because
lastIndexOf will pointlessly continue searching other places in the
string if the end doesn’t match.
Change-Id: I4c2c6dd750d41ffabf5d27011c22a4bbb5e32777
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/204300
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
Tested-by: Jenkins
Otherwise for example if the filename has spaces in it then these will
appear as “%20” in the macro organiser.
Change-Id: I2da91d5aeb08962c9175219ab75ee7cb9d7277f1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/203304
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
If a DirBrowseNode points to a file:/// URI then the Creatable property
will now be True. When the Creatable action is invoked it will create a
file with the chosen name and insert an example macro into it.
Change-Id: Ib63da6a2a075ea7c2cf7dcda464b5f61aee53041
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/202853
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
This implements the Editable invoke action on ScriptBrowseNode and
FileBrowseNode using a shared mixin class so that when the user selects
a file or a macro in the dialog for organising macros the edit button
will be clickable. When clicked the default app for .py files will be
opened.
On Windows it seems that installing a Python interpreter makes that the
default application for Python files. In order to avoid just running the
script instead of editing it, the code tries to determine what program
is the default by calling AssocQueryString via ctypes. If it looks like
a Python interpreter the python file will be opened with notepad
instead. Otherwise the document is opened with the “open” verb via
os.startfile.
On all other platforms the file is opened with SystemShellExecute. On my
Mac this ends up opening it in XCode. On my default Fedora install this
ends up opening the script in gedit which is probably quite a good
default. Hopefully there are no distros that default to executing Python
scripts when passed to xdg-open.
For some reason SystemShellExecute doesn’t seem to do anything on
Windows which is why os.startfile is used instead.
Change-Id: If37ee13aea0200cd6b20230bd92a77aa6a0d3273
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/202852
Tested-by: Jenkins
Reviewed-by: Heiko Tietze <heiko.tietze@documentfoundation.org>
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
Adds an implementation of XInvocation and XPropertySet to
PythonScriptProvider that just passes on all the methods to the wrapped
dirBrowseNode. If we don’t do this then the root browser nodes can’t
report that they are Editable or Creatable.
Change-Id: I2ddab92910ab0cb34866246844669c63b2f66671
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/202851
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
The ensureSourceState function assumes the source code is a bytes object
but the editor was passing it the result of calling getText on the
editor control directly, which is a str object. This was making it throw
an exception.
Change-Id: Id96b22c2b43667cd4b4b245cfeff5a6d2cca6fc5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/202744
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
Tested-by: Jenkins
SystemEnvData holds data specific to a single
frame/object, but the toolkit used is specific
to the SalInstance/vcl plugin.
Instead of having a SystemEnvData::toolkit member
that needs to be set for each object, introduce
a SalInstance::GetToolkit getter and a corresponding
Application::GetToolkit that calls it.
Change-Id: I052f122e991bec745af88d3f43847e4d77fb4ba4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/201536
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Tested-by: Jenkins
Since some code needs flexibility in error handling, where hardcoded
error value of -1 wasn't handy, o3tl::convertToHex was changed to
accept the error value as its template parameter.
Change-Id: Ifc771cc8fa29a801d4556dea969fc3ea7e620df5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/199367
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Tested-by: Jenkins
Move the class out of weld.hxx into its own header, in
order to make it easier to keep an overview and to avoid
having to recompile ~all UI code when the class is
modified.
Change-Id: I5b23b02151c75bb49831a2bbf8d515eb0b54415e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/199068
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Tested-by: Jenkins
This is in preparation of moving code out of weld.hxx
to separate headers/source files, in order to make it
easier to keep an overview and to avoid having to
recompile ~all UI code when anything changes.
Also move weldutils.cxx to a new vcl/source/weld
directory.
Change-Id: Ia75b42f21e560dd248307282a522f186a64cd742
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195777
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
utl::MediaDescriptor was just a SequenceAsHashMap with a few added
methods. It made it more difficult to assign a SequenceAsHashMap to
MediaDescriptor, without real upsides. In many places, the class was
used not as media descriptor, but just as helper to create sequences.
This change puts the string constants and the former methods into a
namespace utl::MediaDescriptor.
It would be also good to drop comphelper::NamedValueCollection, which
is basically a twin of comphelper::SequenceAsHashMap (TODO).
Change-Id: Ia9b69c5a2ad153ecc654944c419c1880252ed86e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195163
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
The goal is to make the script more readable. The format is done with
command:
black --line-length 120 <filename>
No manual modification to these files.
Change-Id: I8ebbac936924277308fc011b20cba60849fa9c45
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/179438
Reviewed-by: Ilmari Lauhakangas <ilmari.lauhakangas@libreoffice.org>
Tested-by: Jenkins
Also did some extensive reformat in this one as trailing whitespaces
and bad formatting prevented commiting because it gave the following
error:
*
* You have some suspicious patch lines:
*
* In scripting/source/pyprov/mailmerge.py
* indent with Tab (line 446)
scripting/source/pyprov/mailmerge.py:446: return PyMailSMTPService(self.ctx)
* indent with Tab (line 448)
scripting/source/pyprov/mailmerge.py:448: return PyMailPOP3Service(self.ctx)
* indent with Tab (line 450)
scripting/source/pyprov/mailmerge.py:450: return PyMailIMAPService(self.ctx)
Change-Id: Ie6a7a81dda851548a06057fb712cd3e094c9b97d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165498
Tested-by: Jenkins
Reviewed-by: Ilmari Lauhakangas <ilmari.lauhakangas@libreoffice.org>
Tested-by: Ilmari Lauhakangas <ilmari.lauhakangas@libreoffice.org>