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>
where it was obsoleted by commits 2484de6728
(Remove non-const Sequence::begin()/end() in internal code, 2021-10-15) and
fb3c04bd19 (Drop non-const Sequence::operator[]
in internal code 2021-11-05).
Change-Id: I64683093afc48ddf2307dc1dee2302cf0b3cbecc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167110
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Tested-by: Jenkins
where it was obsoleted by commits 2484de6728
(Remove non-const Sequence::begin()/end() in internal code, 2021-10-15) and
fb3c04bd19 (Drop non-const Sequence::operator[]
in internal code 2021-11-05).
Change-Id: I4ccc647bb794515c8c11f8dfd9a26563f4aa094b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166819
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Tested-by: Jenkins