Commit Graph
100 Commits
Author SHA1 Message Date
Neil Roberts aed5ae5d21 tdf#173114 pyuno: Add unit test for objects with XInvocation
Adds a service to embindtest that implements XInvocation to handle all
possible method names and returns the name as a string. A Python unit
test then uses this. Without the fix pyuno would throw an exception when
it tries to use the XInvocation object that doesn’t also implement
XInvocation2 and return a valid reference for getIntrospection.

Change-Id: Icb3359c788acd5eda37980252e5fc5c956b38100
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/209087
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
2026-08-13 12:43:09 +02:00
Neil Roberts 97302647ba tdf#173114 pyuno: Don’t require XInvocation2
If an object implements XInvocation then the Invocation service will
directly return the object instead of creating its own invocation
wrapper. In that case the object isn’t guaranteed to also implement
XInvocation2. Previously, this was making pyuno just throw an exception
whenever it encounters one of these objects.

The only case where XInvocation2 is actually used is the implementation
of the __dir__ method. I don’t think this method is used very often so
it’s probably OK to just make it return an empty list if XInvocation2
isn’t supported. That way we can just store a reference to XInvocation
instead of XInvocation2.

This change makes it possible to use objects that implement XInvocation
from Python, for example ooo.vba.excel.Application.

Change-Id: I822c4ffa760f52d6488b9c1009435d059fc19fdd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/209086
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
2026-08-13 12:43:01 +02:00
Neil Roberts dcc46669fa tdf#173114 pyuno: Handle XInvocation::getIntrospection returning null
Many implementations of XInvocation for internal objects return null for
the getIntrospection method. In pyuno this method is only used in one
place to try and catch the case where the wrapped object is already a
PyUNO adapter. Let’s check for null in that case and assume the object
isn’t an adapter so that it won’t crash when handling objects that
implement XInvocation.

Change-Id: I26576a1a9fec92c679373d9ab47824d992065041
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/209085
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
Tested-by: Jenkins
2026-08-13 12:42:53 +02:00
Neil Roberts 935803f2f1 pyuno: Combine two implementations of PyUNO_dir into one
PyUNOStruct_dir is an almost exact copy of PyUNO_dir. This deletes the
first one and makes the struct code instead directly use PyUNO_dir. The
object version has the small advantage that it pre-allocates the Python
list to the right size so the struct code can now take advantage of that
too.

This will make it easier to modify the dir implementation for both use
cases in a later patch.

Change-Id: I7ebe2e6d547fd27c228842effd534e8d71d634ea
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/209084
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
2026-08-13 12:42:45 +02:00
Neil Roberts 7d2d7e7738 tdf#173116 Translator comments for Calc print preview notebook strings
These strings are kind of hard for translators to find so let’s give a
hint in the description.

Change-Id: I8387b54226c757d6af664c09573cc3387b69cc09
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/209089
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
2026-08-12 17:46:57 +02:00
Neil Roberts 2756d38adf [API CHANGE] tdf#172967 SwXTextView: Allow selecting multiple ranges
The select method of XSelectionSupplier can now accept a Sequence of
Anys containing XTextRanges to select at the same time. If any of the
ranges overlap then the whole sequence is rejected.

Change-Id: Ib4930b3144e92285cb504d1ae2ac27263d30d440
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/208898
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
2026-08-12 11:05:36 +02:00
Neil Roberts a3c8270e51 tdf#173043 Fix translator comments in xcu files
The commit below tried to add translator comments to a bunch of strings
containing “outline”. This wasn’t done correctly for xcu files because
in that case XML comments are ignored and instead the comment can be
added with a pseudo-language tag called “x-comment”.

commit 9dd7345159
Author: Neil Roberts <nroberts@libreoffice.org>
Date:   Fri Aug 7 17:35:49 2026 +0200

    tdf#173043 Add translator comments to strings containing “outline”

Change-Id: I1a4e21b98ebbaba5072a8064b67d0ab8fe583e1a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/209076
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
2026-08-11 16:29:37 +02:00
Neil Roberts 9dd7345159 tdf#173043 Add translator comments to strings containing “outline”
The word “outline” in LibreOffice can refer to either the lines of the
shape of something or an overview of something. When the string is quite
short it’s difficult for translators to know which meaning is intended.
There seems to be quite a lot of cases where the translators have got
this wrong. In order to help them this patch adds translator comments to
a bunch of the strings to explain which meaning should be used.

Change-Id: I4b75cc829128633bc9382817fc574d55a09af8a4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/209037
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
2026-08-09 12:12:44 +02:00
Neil Roberts 0066e963bc cui: Add a translator comment for the “No Bold/Italic” strings
The string in Weblate is presented just as “No %1”. The %1 is replaced
with the name of a font style. Without the context it’s easy to
misunderstand this as being an abbreviation for “number”. At least the
Dutch and Esperanto translations seem to have done this.

Change-Id: I220db88346a84e67b0e34affb1b8e7023cfbb90d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/209053
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
Tested-by: Jenkins
2026-08-09 11:28:20 +02:00
Neil Roberts 6685fe38e0 Use “allows X-ing” instead of “allows to X” in UI
“Allows to X” sounds wrong if it doesn’t also have the person it is
allowing as the object of the sentence. See this:

https://english.stackexchange.com/questions/60271/grammatical-complements-for-allow

For the text in the tooltip it is describing what the widget does rather
than giving a command so it should have an “s”, like “[this widget]
allows selecting…”.

Change-Id: I39883bfcd7b8f8e3392b3bf564130720fa6daaf2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/208986
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
Tested-by: Jenkins
2026-08-06 16:24:00 +02:00
Neil Roberts dbbac9fbfe provider_expandall: Don’t skip test if QuickJS provider isn’t built
The commit below changed the unit test so that if the QuickJS provider
isn’t available then the entire test is skipped. Even if the provider is
available, it also changed the check condition so that the test is
skipped if the dummy JavaScript macro was not found. This makes creating
the dummy macro a bit pointless.

The idea of the test is to make sure that all of the script providers
return nodes that can be handled from Python. If the QuickJS provider
isn’t available then it’s still interesting to test the other providers.
If it is available then we want to make sure the dummy script is found
otherwise the test won’t be checking that the nodes returned by the
singleprov code can be handled by Python.

This patch changes the logic so that it will continue the test even if
the QuickJS provider isn’t built but in that case it will skip the
assert that the dummy macro is found.

commit feddb7e827
Author: Christopher Sherlock <chris.sherlock79@gmail.com>
Date:   Sat Jul 25 17:17:33 2026 +1000

    tdf#172532 scripting: fix --without-java builds in provider_expandall.py

Change-Id: I81b83e6b5504d452c7ab05754c1296ff90d364e9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/208991
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
Tested-by: Jenkins
2026-08-06 15:49:05 +02:00
Neil Roberts 95959da85b tdf#172199: Don’t skip disabling read-only when already in read-only mode
When a read-only document is saved to a new file using the SaveAs
command it is supposed to become editable. The commit below added a
check whether the document is currently read-only before proceeding to
remove the read-only status. The patch also makes the read-only method
true if the document has restricted fonts, so presumably the intention
was to avoid removing the read-only status in that case. However it
ended up making the condition so that read-only status is only removed
if the document isn’t read-only, which of course doesn’t make sense.

This patch instead extracts the part from IsReadOnly that checks whether
the document has restricted fonts and only checks for that instead.

commit fdd24dabb6
Author: Mike Kaganski <mike.kaganski@collabora.com>
Date:   Mon Aug 11 17:55:27 2025 +0500

    tdf#145967: Initial support for docs with restricted embedded fonts

Change-Id: I7e59bf53e759110a636c398dc8f5af56b1e2da8c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/208746
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
2026-08-01 13:22:58 +02:00
Neil Roberts dce6dcd302 tdf#172952 uitabpage: Use separate strings for the Apply to X button
The dialog for choosing a UI has a button at the bottom to apply the
setting only to the current module and it has the text “Apply to
%MODULE” where %MODULE gets replaced with a non-translatable name for
the module.

For better or worse, some translations (such as Esperanto) have
different names for the modules. For example Writer is Verkilo. For the
sake of consistency, it would be nice to be able to translate these
strings.

It is also difficult translate this string in languages that have a lot
of grammatical cases. For example, in Slovakian the translator might
ideally want to translate the string as “Použiť vo Writeri” and “Použiť
v Calcu” etc, but they currently can’t do this because they would need
to be able to add a different suffix depending on which module is being
used.

In order to fix both problems there is now a specific string with the
whole text for each module.

Change-Id: I7c478790d89bf33f26b53642a076f9e308d1e64a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/208800
Tested-by: Jenkins
Reviewed-by: Heiko Tietze <heiko.tietze@documentfoundation.org>
2026-07-31 12:39:05 +02:00
Neil Roberts 33cdc558f9 uitabpage: Split part of GetCurrentApp into version to get the enum
The part of GetCurrentApp that gets the enum of the current app is now
split out into a separate function so that it can be used in a later
patch.

Change-Id: Iee2d00cc8384c6c05cd36c5ebcfe5df3174dfd21
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/208859
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
2026-07-31 12:38:33 +02:00
Neil Roberts fcf0f1e680 tdf#167864 tdf#167927 Don’t toggle resize/rotate handles if mouse moved
When clicking on a draw object, instead of storing the position of the
object to detect whether it has moved on mouse up, the position of the
mouse is stored instead. That way it will skip toggling the
resize/rotate handles if the mouse moves outside of a threshold for any
reason not just if the object is dragged to a new position. This fixes
the problem that dragging to resize the shape or moving an edit handle
without changing the shape’s position was causing the handles to be
toggled. This is similar to check used in
sd::FuSelection::MouseButtonUp.

This partially replaces the fix in the commit below:

commit 677e40c8b8
Author: Oliver Specht <oliver.specht@cib.de>
Date:   Mon Apr 14 11:59:22 2025 +0200

    tdf#166177 Fixes unintended switch to rotate mode

Change-Id: Id97266fd89f40fc2e9351771fd555c620d66ba84
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/208498
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
2026-07-24 09:13:57 +02:00
Neil Roberts 6a4bf34e5a singleprov/ScriptFile: Implement XCopyableBrowseNode
Implements XCopyableBrowseNode on the ScriptFile class so that all
script providers based on the single-file provider can support copying.

Change-Id: I14aa057ac432ff80e4a4841fbe5c19be082aa099
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/208161
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
2026-07-23 15:18:33 +02:00
Neil Roberts 54ba86b578 scripting: Replace XAggregation of XBrowseNode with helper function
The browse node factory had a wrapper using XAggregation that wraps
every XBrowseNode. As far as I can tell this was used to replace the
implementation of getChildNodes with one that checks for exceptions from
the underlying provider and then sorts all of the resulting nodes by
name. The trouble with this is that it prevents the script providers
from detecting when a node is one from the same script provider and thus
makes it difficult to implement the XCopyableBrowseNode interface. The
documentation for XAggregation mentions this problem and also states
that the interface is deprecated.

To avoid this overhead, this patch replaces the aggregation with a
helper function in comphelper that should be used to retrieve children
from a browse node. That takes care of catching exceptions and sorting
the results.

Change-Id: I319888fee1b84ddcef397317d2cf7e72bd2867cd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/208160
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
2026-07-23 15:18:22 +02:00
Neil Roberts f213860e49 basic/sbxmod: Combine two impls of CutLines into helper method
Previously there were two copies of a function called CutLines which
were used to remove a method from a string containing BASIC source code.
These have both been replaced with a helper method on SbModule that
returns the source without the given method.

Change-Id: I70c4a4ffe40085bd090ee6823c46154c057468e4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/207062
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
2026-07-22 15:59:07 +02:00
Neil Roberts 0b7d925276 sbutil/searchEOL: Fix mixed endings with first one \r
Fixes the case when the string to be searched contains mixed ending
types and the first one is “\r”. Previously it would have searched for
the “\n” first and skipped over the “\r”.

Change-Id: I945087f2b93d92e73781c07b9b3cdaf9064d1122
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/207061
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
2026-07-22 15:59:00 +02:00
Neil Roberts af830cc577 Move searchEOL from basicide to a general basic utility
Moves the searchEOL function from basicide to a general purpose utility
function in the basic module. This also adds some unit tests for it.

Change-Id: I8f446990654415a994b7964dd62706f3204d817a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/207060
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
2026-07-22 15:58:49 +02:00
Neil Roberts 9b60447481 Make SbMethod::GetLineRange const
This method doesn’t modify any state so I don’t think there’s any reason
not to make it const.

Change-Id: I51748ce2d95b2967ae76b9c5015a49df99d7fa07
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/207059
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
Tested-by: Jenkins
2026-07-22 15:58:39 +02:00
Neil Roberts 8d77a6a77d officecfg: Add a unit test to execute macro in AcceleratorKeyChecker.fodt
Adds a unit test which executes the macro in the utility document
AcceleratorKeyChecker.fodt. This should help make sure it doesn’t bit
rot if there are API changes in the core source code.

Change-Id: Id972dda31d0c8a09904e76dd6fd9760c9f2ad739
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/208220
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
2026-07-20 10:01:40 +02:00
Neil Roberts b42b3d5c64 AcceleratorKeyChecker: Fix retrieving the accessibility context
The macro in the document was relying on the document window directly
implementing the XAcessible interface. This is no longer the case so the
macro was hitting an error. This fix is based on the changes in the
commit below:

commit d1a25112bb
Author: Michael Weghorn <m.weghorn@posteo.de>
Date:   Wed Jun 18 17:49:48 2025 +0200

    java a11y tests: Don't rely on XWindow being XAccessible

Change-Id: Ie8cede2108f26e9d36cf1cf16e47f7ec5feab722
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/208207
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
2026-07-20 10:01:10 +02:00
Neil Roberts c8dc49153b scripting/qa/provider_expandall: Disable the Java-based JavaScript provider
The build configuration on the build bots enables both script providers
for JavaScript. One of them will end up being chosen for the
provider_expandall test and that probably depends on non-deterministic
factors such as the order of files on the disk. If the Java-based one is
chosen then the test will fail because it will ignore the temporary
JavaScript macro file created for the test. We do specifically want to
test the QuickJS-based provider in this test case because we want to
make sure the singleprov code is compatible with Python. The Java-based
script provider code will already be tested because of the Beanshell
provider. This patch therefore uses the remove method of the service
manager to just disable the Java-based JavaScript provider.

Change-Id: I265f4cf2191c0c5d08894c700be346ed93d12898
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/208226
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
Tested-by: Jenkins
2026-07-19 09:52:31 +02:00
Neil Roberts cff7386f71 testofficehelper: Don’t assert the context is true after terminating
Once XDesktop.terminate is called, there is a race condition where if
the termination completes before the truthiness of the context is
checked then it will end up checking on a disposed object and the test
will fail. The check for truthiness ends up calling __len__ on the UNO
wrapper which tries to query some interfaces on the object. This might
be the cause of some failures on Jenkins. I can replicate it if I put a
short sleep after calling terminate. This patch just makes it check the
truthiness immediately instead of waiting until after terminate is
called.

Change-Id: I41f93ca15a52dd45fc304dfd7d4c6d954ca26e42
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/208225
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
Tested-by: Jenkins
2026-07-18 12:14:32 +02:00
Neil Roberts becb1c338e tdf#165689 MacroManagerDialog: Add copy/paste buttons
Adds copy and paste buttons to the Macro Manager dialog so that script
files can be copied with script providers that support the
XCopyableBrowseNode interface. The “copy” button selects the file to be
copied and then the “paste” button works when a destination is selected.

Change-Id: I058b7ed53c837d17723b5f1b4e69f0bc7ae2594f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/207738
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
2026-07-15 12:28:50 +02:00
Neil Roberts 25458311e0 pythonscript: Implement the XCopyableBrowseNode interface
Implements the XCopyableBrowseNode interface on the Python script
provider.

Change-Id: I17c6916567518fd9f28d11724def4a0d98f53ed9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/207737
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
2026-07-15 09:09:36 +02:00
Neil Roberts d2429a3c46 pyuno: Reuse wrapped object when converting Python obj through UNO and back
When any2PyObject is given an interface which is actually an adapter for
a Python object, it now returns the original Python object instead of a
new wrapper for the object. This means that calling methods on the
returned object will be faster because they won’t involve UNO bridging.
It also means that Python implementations of UNO interfaces can detect
when they are given Python objects as a parameter and take advantage of
any internal private data attached to the object.

Change-Id: Ie13d0612f48e70973bd523e68710ec33a7875a16
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/207507
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
2026-07-15 09:09:22 +02:00
Neil Roberts 63e28543e7 [API CHANGE] Add an interface to make a browse node copyable
Adds an optional interface to BrowseNode that can be used to query
whether a node can be copied and also invoke the actual copy. The goal
is to use this from the macro dialogs in later patches to support drag
and drop of script files.

Change-Id: I396a493d704d481b8f0d52c16a77f6452159d76e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/207736
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
2026-07-15 09:09:03 +02:00
Neil Roberts dfb49f33f6 tdf#172532 scripting: Add Python unit test accessing all provider nodes
Adds a Python unit test that just tries to retrieve all child nodes from
the master script provider in order to check that they are all
accessible from Python.

Change-Id: I97185b7f21f38a79fdda4078a69d8e88b10cbaed
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/207349
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
2026-07-15 09:08:38 +02:00
Neil Roberts be27055b34 tdf#172532 basprov: Use new concrete interfaces for optional methods
Instead of using XInvocation and XPropertySet to expose the optional
edit method, the BASIC script provider now uses the new concrete
interface XEditableBrowseNode.

Change-Id: I7a99a1c335f408da9b0ac26c741577eb449e63c4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/207348
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
Tested-by: Jenkins
2026-07-15 09:08:17 +02:00
Neil Roberts b447e5d7b2 tdf#172532 singleprov: Use new concrete interfaces for optional methods
Instead of using XInvocation and XPropertySet to expose the optional
create and edit methods, the script providers based on singleprov now
use the new concrete interfaces XCreatableBrowseNode and
XEditableBrowseNode.

Change-Id: Iae966e554f436b8708699c7d86311f165db2d19f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/207347
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
2026-07-15 09:07:55 +02:00
Neil Roberts f67727b46c tdf#172532 Java provider: Use new concrete interfaces for optional methods
Instead of using XInvocation and XPropertySet to expose the optional
create and edit methods, the script providers based on Java now use the
new concrete interfaces XCreatableBrowseNode and XEditableBrowseNode.

Change-Id: Ibc72c434544eb129e30b406d527bef4bb6eea264
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/207346
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
Tested-by: Jenkins
2026-07-15 09:07:21 +02:00
Neil Roberts e0fb7f2466 tdf#172532 pythonscript: Use new concrete interfaces for optional methods
Instead of using XInvocation and XPropertySet to expose the optional
create and edit methods, the script provider for Python now uses the new
concrete interfaces XCreatableBrowseNode and XEditableBrowseNode.

Change-Id: Ic5944f2ade291598bac6f39411e86b351ffb0082
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/207345
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
Tested-by: Jenkins
2026-07-15 09:06:29 +02:00
Neil Roberts ca34fab9cc [API CHANGE] tdf#172532 Add concrete interfaces for manipulating scripts
Adds optional concrete interfaces that can be added to implementations
of XBrowseNode to create, delete, edit or rename nodes. The comphelper
abstraction now uses these if the interface is implemented otherwise it
will fall back to the old method using XPropertySet and XInvocation so
that existing script providers will continue to work.

The goal is to avoid using XInvocation for duck-typed methods because
that breaks pyuno. It is also easier to implement the optional
interfaces than to use the previous approach.

Change-Id: Id59136152941fd232673ec4b9082a0be0cb6ca8d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/207344
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
Tested-by: Jenkins
2026-07-15 09:05:46 +02:00
Neil Roberts 2365c64aa3 comphelper: Add helpers for accessing duck-typed methods of XBrowseNode
Implementations of XBrowseNode have a bunch of extra methods which are
accessed by using XPropertySet::getPropertyValue to determine if the
action is possible and then XInvocation::invoke to invoke it. This patch
adds wrappers around checking and invoking these methods. The idea is to
abstract away the actual implementation so that the approach can be
changed in a later patch.

Change-Id: I117ab848391dbb1277f9331d6a93f71c2cb556ea
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/207343
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
Tested-by: Jenkins
2026-07-15 09:05:13 +02:00
Neil Roberts 785bff8f88 objectbrowser: Use locale-dependant decimal separator
It now uses LocaleDataWrapper::getNum to format the number of seconds so
that the right decimal separator can be used.

Change-Id: Ic433e6b9f91619bf32526befce00006a6021f79e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/206349
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
Tested-by: Jenkins
2026-07-12 10:38:34 +02:00
Neil Roberts 7f8a06f4d2 objectbrowser: Add a translator comment to “Returns”
I noticed that the French translation misunderstood it so maybe it needs
a comment.

Change-Id: I84e41252a7cf6607d29faadf2a498fe4cc1fb6e5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/206348
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
2026-07-12 10:38:11 +02:00
Neil Roberts e0620bd443 objectbrowser: Use pluralisable strings in the description pane
This avoids having ungrammatical text like “1 items”.

Change-Id: I292f398bcfd2375f7b838e99230f6493840ccedb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/206347
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
2026-07-12 10:38:02 +02:00
Neil Roberts 715da59c42 testofficehelper: Retry connecting indefinitely
This test is sporadically failing on Jenkins. The test_default_config
test effectively only waits a total of 16 seconds for LibreOffice to
start up before giving up. The assumption is that this isn’t long enough
when the build bots are under heavy load from parallel testing.

This patch removes test_default_config and replaces the delays in the
other two tests with an infinite iterator so that it will keep trying to
connect every second forever. If there is a real problem launching
LibreOffice on Jenkins then eventually the kill-wrapper will kick in to
make the test fail.

Change-Id: I31c223892b7c5329c253c90703ec587874029d56
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/207771
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
2026-07-09 10:46:55 +02:00
Neil Roberts 64df8d7617 tdf#172670 TreeView: Make iter_n_children return 0 with children on demand
On at least the GTK and gen plugins, iter_n_children was returning 1
when the node has children on demand but then iter_children will return
false in order to ignore the dummy node. This was causing an infinite
recursion when iter_previous is called and the previous node has
on-demand children because that uses the result of iter_n_children to
determine if the node has children and then uses iter_children to move
to a child node without checking the return value. That meant the
iterator wouldn’t move and it would keep searching from the same place
forever.

This patch fixes it by making iter_n_children non-virtual and making it
bail out early with 0 if the node has children on demand. Otherwise it
will ask the backend via a virtual function which has been renamed to
do_iter_n_children so that it is similar to how do_iter_children works.

Change-Id: Ie9a3d5d51c9eae0789048fa5240441663642595d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/207589
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Tested-by: Jenkins
2026-07-08 09:48:49 +02:00
Neil Roberts 8b44be318a singleprov: Fix testing properties on directories in unit test
The test that checks the editable and creatable properties in nested
directories was always checking them on the provider node instead of the
nested directory node. This was probably due to a cut-and-paste
kerfuffle.

Change-Id: I083c84fff1229553ddaedd99b4f6c11f5127ed70
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/207342
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
2026-06-27 21:17:16 +02:00
Neil Roberts 775587d503 Related tdf#171924 Make macro manager dialog track document like run dialog
The Macro Manager dialog now keeps track of which XModel every node in
the tree is coming from just like the Run Macro and Organize Macros
dialogs. That way it can determine whether a macro should be runnable
based on whether it’s in a document rather than whether the user happens
to be looking at a document that has macros. This also fixes a problem
where the run button would not work from the start center.

The UI test is heavily copied from the UI test for the run macro dialog.

Change-Id: I8a47234511fa78ba7d2f97f78f42df8f58416cbc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/207244
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
Tested-by: Jenkins
2026-06-25 10:55:05 +02:00
Neil Roberts 55937ed56e Related tdf#168623 MacroManager: Implement Delete for BASIC macros
The delete button is now enabled when a BASIC macro is selected and it
causes the macro to be deleted using the new shared helper function.

Change-Id: I22ce8787eb753254a94e385d11684e0f0de8a677
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/207058
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
Tested-by: Jenkins
2026-06-24 14:37:01 +02:00
Neil Roberts c9ef750019 MacroManager: Add methods to get selected BASIC module and method
Adds GetSelectedBasicModule and GetSelectedBasicMethod to get the
selected SbModule or SbMethod when a node in the BASIC branch of the
tree is selected.

Change-Id: Id97634698b1c838a20026b249720901490de9f52
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/207057
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
Tested-by: Jenkins
2026-06-24 14:36:49 +02:00
Neil Roberts 00bd4b4aef basctl: Make QueryDelMacro a DLL public function
That way in can be used by the Macro Manager in a future patch.

Change-Id: Ifafcc360fa5ad8319b25593ca3b170e96d4ac8e8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/207056
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
2026-06-24 14:36:41 +02:00
Neil Roberts bc67811c52 basctl: Move DeleteMacro to a common helper function
Moves the DeleteMacro method from MacroChooser to a common helper
function so that it can later be used in other dialogs too.

Change-Id: Ibc909f0411de9db54f4aed5e1c71659c017287aa
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/207055
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
2026-06-24 14:36:33 +02:00
Neil Roberts 14aadcd280 tdf#172556 Show dialog from Macro Organizer when script can’t run
When the run button in the Macro Organizer is pressed for an embedded
script with macros disabled in the security settings it now displays a
dialog box instead of silently doing nothing.

Change-Id: I5bae91570a19e444881d56efc29f3dd735a22a78
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/207231
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
Tested-by: Jenkins
2026-06-24 14:28:41 +02:00
Neil Roberts 8d31bbc003 tdf#172556 Show a dialog box when macro can’t be run for security
The code to invoke a macro selected from the Run Macro and Macro Manager
dialogs has now been moved to a shared helper function. The function
additionally checks the return value and shows an error dialog if the
macro can’t be run because of the security settings.

Change-Id: Ie46ae295269e63dfec0236030ee9d2e12e04329e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/207214
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
2026-06-24 14:28:33 +02:00
Neil Roberts ff9899db6e Move string for macro security denied from basctl to sfx2
That way it can be used by other modules in later patches.

Change-Id: I5ea8ab0d835276e68de761d7e9b8924753388e6d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/207213
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
2026-06-24 14:28:25 +02:00
Neil Roberts 43bae78c12 DocumentRedlineManager: Search for types using ContainsType
The methods GetRedlinePos, GetRedlineEndPos and HasRedline try to find
redlines that match a specific type. However, they weren’t considering
stacked entries in an SwRedlineRange so they would only find the entries
if it’s the top one.

This fixes the “weird thing” in tdf#172185. Marking the entire text as
bold ends up putting the delete redline as the second entry in the stack
so it wasn’t being found.

Change-Id: I719dc67f98094390152b8492cb2daf10428d6c3c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/205478
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
Tested-by: Jenkins
2026-06-24 09:24:09 +02:00
Neil Roberts 6d0b80fdf2 SwRedlineRange: Add a method to check if the stack contains type
A few places in the code try to find redlines of a particular type by
iterating over the SwRedlineRanges and comparing the type with
GetType(). However, SwRedlineRange can actually have a stack of
redlines, so comparing this way only checks whether the topmost stack
entry has the type. This patch adds a method to search the whole stack
for the given type. This will be used a later patch.

Change-Id: Ic1852c67428b62e12df59ddade0c3fb58d9aa0cd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/205477
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
2026-06-24 09:24:00 +02:00
Neil Roberts 9bda674e65 tmpdlg: Don’t try to remove dialog tabs that were never added
If you open the Format->Page style dialog when looking at an HTML
document the code tries to remove a bunch of tabs that were never added.
The code that would add them is already gated on !html_mode. On a debug
build with the gtk backed this causes an assert failure. It looks like
it has always been like this since the code was added in the patch
below:

commit a2304f62e9
Author: Caolán McNamara <caolanm@redhat.com>
Date:   Thu Aug 30 09:43:59 2018 +0100

    weld writer page style dialog and SvxBorderBackgroundDlg

Change-Id: Ib650b2d5a4d8788f1159a5058a1651a7eb5c8303
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/207173
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
2026-06-23 22:40:30 +02:00
Neil Roberts 049f332965 tmpdlg: Don’t try to remove non-existant background tab
When Styles->Edit Style is clicked for an HTML document the code was
trying to remove a tab called “background” but this is never added
anywhere. This was causing an assert failure when using a debug build
with the GTK plugin. It looks like this has always been there since the
code was added in the patch below:

commit b78edeca86
Author: Caolán McNamara <caolanm@redhat.com>
Date:   Mon Oct 1 20:20:51 2018 +0100

    weld writer parastyle dialog

Change-Id: I9d02d99d596ab301e6c4e8ebd32f78b443649502
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/207196
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
2026-06-23 17:12:25 +02:00
Neil Roberts 58efdfd898 Related tdf#168623 Fix renaming empty Java/BeanShell libraries
The base script provider in Java for several languages was throwing an
exception when trying to rename an empty library. The browsenodes member
variable was being lazily created when getChildNodes was called but in
the case where there were no children it was being left as null which
was causing a Java runtime exception.

Change-Id: I0d9eac2006bc26d47c22f2e1a7a4424fd67a512f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/207152
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
2026-06-23 08:16:16 +02:00
Neil Roberts 5e3784870e pyuno/officehelper: Use f-strings instead of ''.join
This is probably slightly easier to understand.

Change-Id: If41ee1b3fd21d246447638056657d2ee56274ad8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/206261
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
Tested-by: Jenkins
2026-06-22 12:21:28 +02:00
Neil Roberts 8fa45b9f69 Related tdf#171441 idedataprovider: Lazily load libraries on demand
Instead of loading all of the scripting libraries when IdeDataProvider
is initialised, it now only loads them when the children are requested.
This is probably a good idea for efficiency anyway, but it also
partially fixes the problem described in tdf#171441. Loading a library
ends up making the members of the library accessible in the global
namespace of a running script. That meant that just openining the macro
editor would cause the IdeDataProvider to make all members of all
libraries available to the current script. If we lazily load them then
they are instead only available if the object browser is manipulated.
This is still a problem, but it’s no worse than the existing object
catalog and macro dialogs which also have the same problem (see comments
4&5 of the bug).

Change-Id: I43ccd06cee45e53e6575f768fa24fe4befeefc20
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/206473
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
2026-06-22 10:24:38 +02:00
Neil Roberts 39cb96f0b6 configure: Update the required Python version to 3.11
Updates the configure script to explicitly require the same version of
Python as mentioned as the baseline in the README. This is for both the
version required for building and the version for pyuno.

All versions less than 3.9 are already end-of-life and version 3.11 is
currently in security-fix-only mode so it is probably quite reasonable
to require that.

Previously the configure script only checked for version 3.3, or 3.7 if
internal Harfbuzz is being used. In practice it probably hasn’t worked
to build with anything less than 3.6 since desktop-translate.py started
using f-strings in 2022.

Change-Id: Ice26324f4e7805bc37a0dd07d984451460529249
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/206368
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
2026-06-19 15:58:00 +02:00
Neil Roberts ef2cee37c5 pyuno: Set UNO_PATH when running testofficehelper
Otherwise the bootstrap function will just run whatever soffice
executable it finds in the PATH instead of the one built in the build
directory.

Change-Id: I122ca8efc80a7f134f7d06fb248ca1bc1108b0b3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/206949
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
2026-06-18 13:16:23 +02:00
Neil Roberts c1f4dc187b pyuno/officehelper: Let UNO_PATH work on macOS
On macOS a hard-coded path is used for the soffice binary. It probably
makes sense to avoid doing this if the UNO_PATH environment variable is
set.

Change-Id: I160bbec8a7ddffbb7032b55a61a3004e9d42bf18
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/206263
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
2026-06-12 09:30:42 +02:00
Neil Roberts 40034e4b49 pyuno/officehelper: Simplify handling of UNO_PATH a little bit
Instead of calling os.path.join with an empty string when UNO_PATH is
not set, it is now only called when UNO_PATH is set.

Change-Id: I8ebf99d1849e62634860686c0bb4c9d0c2a9c0d6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/206262
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
2026-06-12 09:30:16 +02:00
Neil Roberts b7224c8628 pyuno/officehelper: Let python quote process args instead of shell
subprocess.Popen can take an array argument with the arguments. If we do
this instead of trying to build up a single argument to pass to the
shell then we can let Python handle quoting the arguments on Windows.
This also means the executable path could contain spaces on platforms
other than Windows too.

Change-Id: I7779c5bab431b65cf4a602047c184fe78d802d77
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/206260
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
2026-06-12 09:29:33 +02:00
Neil Roberts 3cddd0bb95 sdext: Use Translate::nget for two strings with numbers
Two strings used in the Presentation Optimizer were using a count
without using pluralisable strings. They are only used with counts > 1
so maybe the assumption was that there is only one possible plural form,
but of course some languages have several plural forms that need
differing strings even for larger numbers.

I noticed this because the French translation was incorrect for
STR_DELETE_SLIDES as if %SLIDES was going to be replaced by a type of
slide rather than a number. Maybe if the string had plural forms that
would have been more obvious.

Change-Id: Icf2df1bfed3907226e45e819ad0c14c4a33e8bfe
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/206314
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
2026-06-11 13:36:08 +02:00
Neil Roberts 14c0e370dc objectbrowser: Don’t mark Basic and IDL keywords as translatable
These strings are being used to build up a declaration for either a
Basic subroutine or a method from an IDL file. In the English original
they are the actual keywords used by the code. If they get translated it
is confusing because it looks like a new programming language. For
example in French the acess2base.Module.ProcOfLine function looks like
this in the description pane:

ProcOfLine(Facultatif pvLine Comme Variant,
           Facultatif pvProcType Comme Variant) Comme String

The “Facultatif” and “Comme” are translations of the “Optional” and “As”
keywords.

This patch just replaces them with string literals.

Change-Id: Icb427ebaa587f99ee2ce81a2e6997787a535001e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/206335
Tested-by: Jenkins
Reviewed-by: Jonathan Clark <jonathan@libreoffice.org>
2026-06-11 10:26:46 +02:00
Neil Roberts 3223245186 pyuno: Don’t use PyObject_CallOneArg
That function was added in Python 3.9. Even though the LibreOffice
README says the baseline is 3.11, the configure script actually lets you
build with 3.3. I tested with Python 3.5 and it does work apart from
that function call and the fact that desktop-translate.py is using
f-strings. The call to PyObject_CallOneArg was added in the patch below
after the 26.2 branch point so it hasn’t been battle-tested in a release
version yet. Seeing as it’s easy to use an alternative let’s do that in
case someone is using a really old version of Python with pyuno for some
reason.

commit 45d2412c78
Author: Neil Roberts <bpeeluk@yahoo.co.uk>
Date:   Wed Feb 11 16:40:48 2026 +0100

    tdf#171122 pyuno: Add class getter methods for singletons

Change-Id: Ic6f7cf8d0005f59e8cbfd1f9703d393b7e30dabe
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/206333
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
2026-06-11 08:23:25 +02:00
Neil Roberts 5e3838839d pyuno: Add testofficehelper to the pyuno module
Otherwise the tests aren’t actually run.

Change-Id: I781bcfe42726a7109e0494e02124690d34395232
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/206259
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
2026-06-10 10:22:59 +02:00
Neil Roberts fa05a80aae [API CHANGE] tdf#171950 Add API to create 2- and 3- color scales
The existing API allows creating a color scale conditional format but it
has no entries and there is no API to create an instance of
XColorScaleEntry in order to add one. For data bars the existing API
instead creates a conditional format with two existing entries and then
you can use the XDataBarEntry interface to modify them. This patch makes
the color scale API work like the databar one. It adds constants to
ConditionEntryType to create a 2-color or 3-color scale which have the
entries pre-created.

This is an API change because it adds constants to an unpublished
constant group. It also makes it so that the getType method on the
conditional format will now return either COLORSCALE2 or COLORSCALE3
depending on the number of entries. In practice I think this is very
unlikely to break any existing code.

Change-Id: I28faa6c66ac3963220786e8da45a2d550058f095
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/205944
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
2026-06-09 13:11:16 +02:00
Neil Roberts 599d616d3e tdf#172333 Call AddCondFormatData after creating condformat with API
Without this the conditional formatting isn’t immediately visible in the
document after creating it with the API until the document is saved and
reloaded. This call seems to be the missing piece that sets the
ATTR_CONDITIONAL attribute on the cells. It is also called from
ScDocFunc::ReplaceConditionalFormat when creating a conditional format
with the UI.

Change-Id: I4a4e48a9ada62c8635e13ac47f94f7d7dc76b4b6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/206224
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
2026-06-09 13:11:08 +02:00
Neil Roberts 745a783a7e customisation: Don’t try to remove non-existant notebookbar tab
Since the commit below the notebookbar tab no longer exists on the
customisation dialog. If you open the dialog from the start center the
code tries to remove this tab by name. At least on the GTK backend, this
ends up hitting an assert failure. This patch just removes that code.

commit 7312d7d3c9
Author: Heiko Tietze <tietze.heiko@gmail.com>
Date:   Wed May 20 15:28:42 2026 +0200

    Relates tdf#166641 - Add category labels to Writer's Tabbed Notebookbar

Change-Id: Id430ef85bba5fb748108b89987bf73ee2acc4257
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/206003
Reviewed-by: Dan Williams <dcbw@libreoffice.org>
Tested-by: Jenkins
2026-06-09 12:01:13 +02:00
Neil Roberts 45caec45f6 tdf#171924 Make the run macro dialog check security like organizer
When a macro is chosen from the Run Macro dialog, the script context is
now taken from the model that the script is contained in instead of the
current frame. If the script isn’t embedded in a document then it won’t
have a model so the security check will pass. This makes the Run Macro
dialog work like the run button in the Organize Macros dialog. It also
means the dialog can be used from the start center.

Change-Id: Ibe4a1632ca8d26307296f30a8041b90aff86bc30
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/206153
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
2026-06-09 11:46:46 +02:00
Neil Roberts e34d43d53c Allow script if script context is null in SfxObjectShell::CallXScript
That way we have a way to run a script without checking the security
policy if we know that it doesn’t come from a document.

Change-Id: I7274e255ba8fe708843971069c8f87f5e4848e10
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/206152
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
2026-06-09 11:46:35 +02:00
Neil Roberts c4c4127727 SvxScriptSelectorDialog: Add method to get XModel containing script
Now that SfxGroupInfo_Impl stores the model where each script came from
we can expose that information for the selected script in the script
selector dialog via a new method called GetScriptModel.

Change-Id: I7d9baaa99c276842e3b7e6bcacf89a915bcdca33
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/206151
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
Tested-by: Jenkins
2026-06-09 11:46:19 +02:00
Neil Roberts 3b5e9ee988 CuiGroupListBox: Keep track of the XModel for each script
When expanding the root browse node, the FillScriptList function now
finds the XModel for script groups that come from a document. This model
is then stored in the SfxGroupInfo_Impl data for the group. Every time a
group is expanded the model is propagated to the children and finally on
to the FUNCTION_SCRIPT nodes. That way it is possible to determine which
XModel every script comes from, if any.

Change-Id: Ieea6c31b2164a42c07195abf04bd242b28fe1922
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/206150
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
Tested-by: Jenkins
2026-06-09 11:45:56 +02:00
Neil Roberts ab62d5b78c cui: Combine the two copies of getDocumentModel into one util
Both SvxScriptOrgDialog and CuiConfigGroupListBox had a copy of a
function called getDocumentModel which looks up an XModel given the name
of a document. This patch combines them into one shared utility
function.

Change-Id: I25cafd7658760a1cf02a7bcef9a38e63b02979ad
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/206149
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
Tested-by: Jenkins
2026-06-09 11:45:05 +02:00
Neil Roberts 87c2583f9c cfgutil: Use std::variant to store data for SfxGroupInfo
Previously SfxGroupInfo contained a void* pointer that worked like a
tagged union to store data depending on the type of the group. The
pointer was cast to the right type depending on the value of the nKind
member. Surprisingly, the SfxGroupInfo has no explicit destructor and
instead the data was destructed in several implementations of ClearAll
to clear the list box. Some of the implementations didn’t handle every
type of group.

This patch makes it store the data in a std::variant instead so that the
default destructor can take care of cleaning up the data properly. nKind
is now moved directly into the index of the variant so that it’s not
stored in two places.

This should make it easier to modify the struct without having to worry
about updating all of the places where the data was destructed.

Change-Id: I3393bb6ab8ea4cfc82c1fd03f345b2f6782785ab
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/206148
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
2026-06-09 11:43:58 +02:00
Neil Roberts 2c591fcbc3 CommandCategoryListBox: Move ref acquire to right place
When building up a tree list from the children of an XBrowseNode the
code was unconditionally taking a reference on each child. I think this
reference is needed in the case when the node has its own children
because it ends up getting stored in an SfxGroupInfo_Impl struct which
has an explicit call to release() when the tree list is cleared. However
if the node doesn’t have children then the reference was apparently
being leaked. If I add some tracing to BrowseNodeAggregator then I can
see that without this patch a bunch of nodes are leaked when the process
closes.

Change-Id: Ie6d2f69101f6eaf2f3a364bc65c286e891615e4f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/206147
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
Tested-by: Jenkins
2026-06-05 22:45:53 +02:00
Neil Roberts 0fa2bcc293 CommandCategoryListBox: Remove spurious ref acquire
When iterating over the child nodes of a category of macros the code
that builds up the tree list was taking a reference on every node.
Seeing as there is no comment explaining this and there doesn’t seem to
be any use for the reference I think it may have been a copy and paste
mistake from CommandCategoryListBox::addChildren. If I add some tracing
to BrowseNodeAggregator then I can see that a bunch of nodes are leaked
when the process closes and this patch reduces the count.

Change-Id: I2a94b716e798b15f9b90f1779109dbddbf605dda
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/206146
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
2026-06-05 22:45:41 +02:00
Neil Roberts 156176bef8 Related tdf#171950 Add a unit test for cond format API with threads
Tests creating some conditional formats simultaneously in a bunch of
threads. This is a unit test for the commit below which fixed a problem
where the destructor for the XConditionalFormats implementation would
trigger an assert when the solar mutex isn’t held.

commit 11ca379481
Author: Neil Roberts <nroberts@libreoffice.org>
Date:   Wed Jun 3 15:04:19 2026 +0200

    Grab the solar mutex when deconstructing ScCondFormatsObj

Change-Id: I51ad068f4fa7fb2b8ae2e986eae2f2c8608379e9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/206175
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
2026-06-05 22:42:21 +02:00
Neil Roberts 11ca379481 Grab the solar mutex when deconstructing ScCondFormatsObj
SfxBroadcaster::RemoveListener asserts that the solar mutex is held so
without this LibreOffice will crash in a debug build if the object is
deconstructed in another thread such as when the last reference to it
was from an external process. The same thing is done in the other
constructors for uno objects in the same directory.

This fixes the crash mentioned at the bottom of comment #3 of
tdf#171950.

Change-Id: I881a86018a7ee88bf36d600b7f3119dd869af0d0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/205947
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
Tested-by: Jenkins
2026-06-03 21:02:33 +02:00
Neil Roberts 745c5a1fa4 string: Fix documentation for char versions of endsWith/startsWith
Some of the methods added in the commit below had the wrong name for the
character parameter in the documention.

commit ab871d3af9
Author: Neil Roberts <nroberts@libreoffice.org>
Date:   Sun Apr 26 12:00:28 2026 +0200

    [API CHANGE] rtl/string: Add startsWith/endsWith for a single character

Change-Id: I47eec8a7a6aca75f5735e3158125efc4cb44c734
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/205716
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
2026-05-26 17:40:25 +02:00
Neil Roberts b1e6f3cc25 svxacorr: Use lcl_IsInArr instead of chain of ch=='a'||ch=='b'...
This makes the code a little bit easier to read.

Change-Id: I679d5bb05fa9c7f87828ccd756132098f2403cfb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/205449
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
2026-05-20 20:58:51 +02:00
Neil Roberts e2af4c9f81 basic: Add unit test asserting that array arguments can’t have size
Adds a short unit test to assert that if you try to put a size inside
the brackets for the declaration of an array argument to a subroutine
then the compiler will report an error.

See this comment for an example of how it would be easy to break this
behaviour:

https://gerrit.libreoffice.org/c/core/+/203437/comment/749269bd_f55ea943/

Change-Id: I048234c7cf5a13e2ab2b71885ea1c0455566decf
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/205369
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
2026-05-19 20:23:21 +02:00
Neil Roberts 023b634d62 jsuno: Free JSValues with JS_FreeValueRT
The ValueRef helper class now keeps a pointer to the JS_Runtime instead
of the JS_Context and uses that to free the JSValue instead. This is
needed if the ValueRef is kept alive until the end of the execution of
the script because in that case the JS_Context will be destroyed before
the final garbage collection is run. This can happen if the ValueRef is
being stored in the opaque data for an object such as is the case for
the WrapperData struct.

This was picked up in the following ubsan build:

https://ci.libreoffice.org/job/lo_ubsan/3913/consoleFull#-1184025599d893063f-7f3d-4b7e-b56f-4e0f225817cd

It is also picked up by running CppunitTest_jsuno_testuno under
valgrind.

Change-Id: Ic929fb8ab9015ddcbb9fd69a4a7985e9d2b18b0a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/205353
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
Tested-by: Jenkins
2026-05-19 14:02:13 +02:00
Neil Roberts b16d490e5a tdf#171135 Disable unrelated auto-format options when making bullets
If bSetNumRule and bSetNumRuleAfterSpace are set then auto formatting is
applied whenever space is pressed on a line with only two characters in
order to convert the two characters to a bullet point if applicable.
However this would also end up running all of the other auto-format
options such as removing trailing spaces. These aren’t designed to be
executed in the middle of editing a paragraph so it would end up
removing the space that the user just tried to type. This patch fixes
that by disabling any unrelated flags in SvxSwAutoFormatFlags before
executing the auto formatting so that only the bullet point formatting
will be applied.

A new method is added to SvxSwAutoFormatFlags to reset all of the flags
to false so that the bullet code can re-enable the relevant ones. In
order to avoid having a long list of assignments that is likely to get
out of sync as new options are added, the flag members of
SvxSwAutoFormatFlags are now declared using a macro that can be reused
to define the assignments.

Change-Id: I33155f45ba6cfd316222ad4d552beeb7979f8f4a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/205225
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
Tested-by: Jenkins
2026-05-19 08:37:23 +02:00
Neil Roberts b28b4c8c3d autofmt: Don’t correct for redlines if they’re not displayed
The Esperanto hat auto formatter tries to adjust for the length of the
word growing when redlines are enabled because both the original and the
old version end up in the text. However, this doesn’t happen if tracked
changes are hidden (ie, via Edit->Track Changes->Show) so the adjustment
shouldn’t happen in that case. Instead of trying to work out the
conditions for whether the redlines are shown or not, the code now just
detects if the string has grown in order to decide whether to adjust the
word end.

Change-Id: I5a019640f1357d29ba40e91f6132171d1102b70b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/205320
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
2026-05-19 08:35:06 +02:00
Neil Roberts 1b2ce1d030 autocorrect/qa: Add a test combining Esperanto hats with initial capital
Adds a test that executes the esperanto hat converter and the sentence
initial capitaliser on the same character. For this to work the results
of one auto correct feature need to be visible by the other one. See the
comment below for a case where we accidentally broke this:

https://gerrit.libreoffice.org/c/core/+/205196/comments/f69d4c85_472c06fb

Change-Id: I854c9f8f42f8ea0f15146d1e9bed6461b65362f6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/205226
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
2026-05-18 12:37:26 +02:00
Neil Roberts b07500ec55 autocorrect: Add method to SvxAutoCorrDoc to retrieve paragraph text
The autocorrect functions take as arguments an abstract interface to a
document and a string reference containing the text for the paragraph
being updated. The string needs to be a reference to the actual text
used for the document because the functions rely on it being
automatically updated when modifications are made to the paragraph. This
causes problems when redlines are enabled and the text comes from a
MergedPara because some operations can cause the MergedPara to be
recreated. The SvxAutoCorrect::DoAutoCorrect function has many
workarounds to try and fix this problem. The one from the commit below
tries to fix it for the case where a small group of autocorrect
functions can all be run together by making a temporary copy of the
string. This isn’t ideal because the different functions can no longer
see the result of the other functions. This is particularly bad for the
Esperanto hat function that was added after the patch was created. For
example “cxu” at the start of a sentence will be corrected to “Cu”
instead of “Ĉu” beause the word capitaliser can’t see the result of the
esperanto hat function adding the hat so it only capitalises the letter
“c”.

To fix this this patch adds a method to SvxAutoCorrDoc to get the latest
version of the paragraph text. That way each function can query the
string at the start and it won’t matter if it comes from a recreated
MergedPara. Ideally I think we should eventually move all autocorrect
functions to use this method and then remove the rTxt parameter to make
the code a bit more robust.

commit 22baeb9f9e
Author: Andras Timar <andras.timar@collabora.com>
Date:   Thu Mar 19 10:19:21 2026 +0100

    sw autocorrect: fix use-after-free with track changes enabled

Change-Id: Id407be018bdfa31c6f4642a9503c65e4c9e736d4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/205235
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
Tested-by: Jenkins
2026-05-18 12:37:17 +02:00
Neil Roberts 3caaa859ca testAutocorrectRedline: Set redline settings via UNO dispatches
The unit test tries to trigger the shell into making a MergedPara by
disabling the visibility of tracked changes. However, it was doing this by
directly setting the red line flags on the shell and this doesn’t seem
to hit the code path that creates the MergedPara. This patch makes it
instead change the flags using an UNO dispatch as if the menu item had
been selected.

If I revert the fix and use this patch under Valgrind then it shows the
use-after-free errors.

Change-Id: I1d29f14ffd68c2f4dab4e8713b432624aba84aa4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/205230
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
Tested-by: Jenkins
2026-05-18 12:37:08 +02:00
Neil Roberts 825509b5da optlanguagespage: Remove whitespace in extended tooltip text
The spaces are conserved in the actual tooltip making it look broken. It
was also confusing for translators.

Change-Id: I76d08b2244369c1ec8102c6d0fc9ce1807802b28
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/205256
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
Tested-by: Jenkins
2026-05-17 21:45:49 +02:00
Neil Roberts 0016a7ccc4 jsuno: Implement a basic Rhino compatibility layer
Adds the following features in order to make the QuickJS engine slightly
more compatible with the Rhino engine:

Makes “Packages” be an alias for “uno.idl”

Adds an implementation of importClass. This tries to get the name of the
thing that is being imported and then sets a global variable with that
name to point to that thing. The name is retrieved by adding a
getImportClassName method to most of the objects returned by
moduleGetOwnProperty.

Inserts a com.sun.star.uno.UnoRuntime object with a hack on
moduleGetOwnProperty. This object has a method called “queryInterface”
to allow doing UnoRuntime.queryInterface(interface,obj). The
implementation just calls
obj.queryInterface(uno.type.interface(interface))

This is enough to run the HelloWorld example from the Rhino JavaScript
provider.

Change-Id: I569fe4dad4cd8cdc6029a60f8e5421a5de1588c2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/204912
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
2026-05-14 11:03:03 +02:00
Neil Roberts 6953efb07e jsuno: Split moduleGetOwnProperty out into uncached version
The main bulk of moduleGetOwnProperty is now split out into a helper
function that just directly returns the property value. The caller then
handles the caching. This makes it easier to add an early return with
different values in a later patch.

Change-Id: Ifaf346df7d1d576cc0a466eb3bd4a3dc2cfab732
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/204911
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
2026-05-14 11:02:54 +02:00
Neil Roberts 9069f5c462 jsuno: Use prototypes to implement toString methods
Instead of directly adding the toString method to an object every time
an instance of the appropriate class is created, the method is now added
to a prototype object and this is set on the class.

Change-Id: I7c69cb5294ba52a84a88aba354684263d4b3736c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/204910
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
2026-05-14 11:02:44 +02:00
Neil Roberts d08ca1f347 jsuno: Use get_own_property instead of get_property
get_property completely overrides the property resolution mechanism and
stops QuickJS from looking at the prototypes. If we replace it with
get_own_property, as well as fixing that it will make has_property work
correctly too. Sadly this also means we have to override the property
setter, which means we can’t just call JS_SetProperty on the object when
we want to cache the value. Instead, the wrapper and module classes now
have a struct as their opaque data and this contains an additional JS
Object to use as a hash table for the cache.

Change-Id: Ia1580ba2017d6376c6f8565ceff6bd46afa7ffc4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/204909
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
2026-05-14 11:02:35 +02:00
Neil Roberts ddd0b88a8f jsuno/testuno: Use the character version of endsWith
Now that endsWith has an overload that takes a single character, we
might as well use it here. This also uses the “rest” parameter to avoid
the if-statement.

Change-Id: I7b82e65a943715bb4a65574482944c846a696396
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/204908
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
2026-05-14 11:02:25 +02:00
Neil Roberts 0425d0c795 jsuno/testuno: Move the assertError function to a common utility file
More of the tests will later want to use the assertError function so
let’s move it to a shared helper file.

Change-Id: Ib19e51e659214f8d7f08cedd98bf54f4cf06d4ee
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/204907
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
2026-05-14 11:02:14 +02:00
Neil Roberts 443fe7e736 jsuno: Move JSValue out into a separate header file
This makes it easier to split the code into multiple files and share the
JSValue class.

Change-Id: I10149088a970392c0face4b8533aed9096f2e0b4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/204906
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
Tested-by: Jenkins
2026-05-14 11:01:48 +02:00
Neil Roberts 9f822cde2c tdf#172042 Make AutoCorrect replace X’s with circumflexes in Esperanto
Adds an AutoCorrect option that corrects text like “sxangxigxis” to
“ŝanĝiĝis”. The former is a common alternative way to type the special
Esperanto letters when the user doesn’t have the right software
installed to type them properly.

Change-Id: I822f4239667bf60dad77e60497488e04514d46a2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/205066
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
2026-05-14 10:51:43 +02:00
Neil Roberts 2c0bc4e33c scripting/jsprov: Define the XSCRIPTCONTEXT global variable
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>
2026-05-13 09:06:32 +02:00
Neil Roberts 1183f254fe scripting: Add a helper class to implement XScriptContext
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
2026-05-13 09:06:22 +02:00
Neil Roberts 0c207d3479 jsuno: Add a parameter to execute() to specify a list of global variables
Adds an optional parameter to jsuno::execute to specify a list of global
variables to define in the global scope of the running script. The
values are references to XInterfaces.

Change-Id: I03b7de9fb904f4a172324f0e54c11ff9b0d76134
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/205120
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
2026-05-13 09:06:12 +02:00