Commit Graph
42 Commits
Author SHA1 Message Date
Neil Roberts 26e03a6571 Add a unit test that constructs every service-based singleton via class name
The idea is to check that all of the class names match a singleton
declared in a component somewhere and that they return an object that
implements the advertised interface. Otherwise the generated getter for
the singleton will fail with a runtime exception.

Change-Id: I1352e7392e33e9182962e6279fcb62cf3b58352a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200056
Reviewed-by: Neil Roberts <bpeeluk@yahoo.co.uk>
Tested-by: Jenkins
2026-02-23 16:39:43 +01:00
Michael Weghorn a4954e5575 vcl: Drop logic to create drag source by service name
This is basically the drag source equivalent of previous
commit

    Change-Id: I93c099b82e209efe11f30bbc4f5fa0a6e1fff992
    Author: Michael Weghorn <m.weghorn@posteo.de>
    Date:   Fri Jul 11 13:47:54 2025 +0200

        vcl: Drop logic to create drop target by service name

, see the commit message of that one for more details/background.

Change-Id: If870b340f39bd7fcf6674af3184e2a4c3017310d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187727
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2025-07-14 09:48:41 +02:00
Michael Weghorn 44da22e03b vcl: Drop logic to create drop target by service name
DropTarget_createInstance, which would have been called
when trying to create a drop target via service name,
calls SalInstance::CreateDropTarget with the default
null `pSysEnv` param.

For all cases except headless mode or when running unit tests,
that calls the platform/VCL-specific SalInstance::ImplCreateDropTarget
overrides, which would unconditionally dereference the
null `pSysEnv`.

Since this logic to create a drop target by service
name is unused, presumably since

    commit 031576105c
    Author: Jan-Marek Glogowski <glogow@fbihome.de>
    Date:   Thu Jan 6 14:16:53 2022 +0100

        VCL move platform code from mouse.cxx into plugins

        ... by moving it into ImplCreate(DragSource|DropTarget).

        The existing Create* variant now checks for headless mode and the
        IsRunningUnitTest flag, before creating the platform variants.
        There are two small helpers to initialize either X11 or Ole based
        UNO DnD interace implementations.

        Unfortunatly Windows requires to move two dtrans header files, but
        at least any other changes are minimal.

, drop it altogether.

com::sun::star::datatransfer::dnd.X11DropTarget is a published
UNO service (see offapi/com/sun/star/datatransfer/dnd/X11DropTarget.idl),
so leave the specification in the IDL file around, even if there
is no way to create an instance via external code (macros, extensions).
That's not new with this commit, since the service was
only meant to be supported by the gen VCL plugin on Linux
previously, but then, trying to create an instance would
crash in X11SalInstance::ImplCreateDropTarget due to
dereferencing the null `pSysEnv`.

The XInitialization interface as mentioned in the IDL file:

    /** The service expects an instance of
        com::sun::star::awt::XDisplayConnection
         as the first parameter. The second parameter must be a long
        that contains an XWindow window which shall be registered
        as drop target.
    */
    interface com::sun::star::lang::XInitialization;

hasn't been implemented any more since

    commit 30b4c1d787
    Author: Michael Weghorn <m.weghorn@posteo.de>
    Date:   Fri Jul 4 10:01:23 2025 +0200

        gen: Simplify DropTarget init, don't use XInitialization

, but also before then, an XDisplayConnection to pass
as a param to the XInitilization::initialize implementation
couldn't be retrieved via external code, see the
commit message of

    commit 7a9108a48e
    Author: Michael Weghorn <m.weghorn@posteo.de>
    Date:   Fri Jul 4 11:16:24 2025 +0200

        vcl: Stop implementing XDisplayConnection

for more details.

The published service com::sun::star::datatransfer::dnd::OleDropTarget
is Windows-specific in its description. Quoting from
offapi/com/sun/star/datatransfer/dnd/OleDropTarget.idl:

    /** The service expects a windows window handle. It is passed as unsigned long.
    */
    interface com::sun::star::lang::XInitialization;

, while it was also used on macOS internally
before the above-mentioned
031576105c.

The actual Windows implementation has a separate
UNO constructor (see vcl/vclplug_win.component)
and should therefore be unaffected by this change.

If the X11-specific X11DropTarget service were actually
relevant, it should probably be implemented similarly
(specifically for the gen VCL plugin only, without
reintroducing the rest of the logic dropped in this
commit.)

Searches for "com.sun.star.datatransfer.dnd.X11DropTarget"
and "com.sun.star.datatransfer.dnd.OleDropTarget"
in Google and on Ask [1] didn't give any results that would
suggest that these services would actually be used by
existing third party code.

Change-Id: I93c099b82e209efe11f30bbc4f5fa0a6e1fff992
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187726
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Tested-by: Jenkins
2025-07-14 09:48:35 +02:00
Noel Grandin d573e2ae17 loplugin:ostr in various
Change-Id: I9f399b3752da9df930e0647536ffcd4e82beb1ac
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167856
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2024-05-20 22:09:56 +02:00
Caolán McNamara 9e786320a7 move using the vcl file dialog in headless mode to the point of creation
instead of setting and unsetting the config option at start and exit
because a document that crashes in headless mode leaves my config
in an unwanted built-in file dialog state.

Change-Id: Ib5fcc5994a08c78bffdf57cb5b252dc469167ba2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150126
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
2023-04-07 16:54:45 +02:00
Andrea Gelmini f1134ca310 Fix typo
Change-Id: Iebbecfbd395aa001d82dc00c7ef9b9587b4755fc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134048
Tested-by: Jenkins
Reviewed-by: Adolfo Jayme Barrientos <fitojb@ubuntu.com>
2022-05-14 14:08:53 +02:00
Noel Grandin e25ba7dc57 use a dummy clipboard when running unit tests
so the multiple unit tests don't stomp on each other.

This fixes a couple of things in my earlier attempt
(*) actually set the env variable on Windows
(*) don't use a global variable to test the env var, because that
variable might be initialised BEFORE the env var is actually set

Change-Id: Id43a1dd2fbd324691e0b6578c9026b8a523012e8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121436
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2021-09-01 20:42:40 +02:00
Stephan Bergmann 35e471bb4d Adapt the remaining OUString functions to std string_view
...for LIBO_INTERNAL_ONLY.  These had been missed by
1b43cceaea "Make many OUString functions take
std::u16string_view parameters" because they did not match the multi-overload
pattern that was addressed there, but they nevertheless benefit from being
changed just as well (witness e.g. the various resulting changes from copy() to
subView()).

This showed a conversion from OStringChar to std::string_view to be missing
(while the corresponding conversion form OUStringChar to std::u16string_view was
already present).

The improvement to loplugin:stringadd became necessary to fix

> [CPT] compilerplugins/clang/test/stringadd.cxx
> error: 'error' diagnostics expected but not seen:
>   File ~/lo/core/compilerplugins/clang/test/stringadd.cxx Line 43 (directive at ~/lo/core/compilerplugins/clang/test/stringadd.cxx:42): simplify by merging with the preceding assignment [loplugin:stringadd]
>   File ~/lo/core/compilerplugins/clang/test/stringadd.cxx Line 61 (directive at ~/lo/core/compilerplugins/clang/test/stringadd.cxx:60): simplify by merging with the preceding assignment [loplugin:stringadd]
> 2 errors generated.

Change-Id: Ie40de0616a66e60e289c1af0ca60aed6f9ecc279
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107602
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2020-12-11 21:25:10 +01:00
Noel Grandin 6e35794cad terminate XDesktop properly in unit tests
So that the UNO constructor work can continue - where we need the
desktop to be disposed properly so that all UNO constructors objects
have their dispose() called, and they can clean up their global state.

We detect this case by changing a SAL_WARN to an assert in
Desktop::disposing()

(*) in ~ScTabViewShell, don't call EnterHandler, because that tries to
create EditEngine's and other stuff, which crashes
(*) Need a fake singleton so that the servicemanager calls dispose()
 on the AnalysAddIn and we can clear the global variable there.

Change-Id: Id13b51e17afc16fcbbc65d64281cdf847e4a58cf
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99640
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2020-07-30 10:49:27 +02:00
Thorsten Behrens 493ae7a6bb replace usage of blacklist with denylist
.. and a few cases of instead doing blacklist->excludelist where that
made more sense.

Background and motivation:
  https://tools.ietf.org/html/draft-knodel-terminology-02

[API CHANGE] officecfg::Office::Canvas::DeviceBlacklist -> DeviceDenylist
[API CHANGE] officecfg::Office::Canvas::BlacklistCurrentDevice -> DenylistCurrentDevice
[API CHANGE] officecfg::Office::Common::Misc::OpenCLBlackList -> OpenCLDenyList

Change-Id: Ia35e25496bf0cc0692d5de4cb66bfc232d3a869e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98180
Tested-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
2020-07-10 01:34:54 +02:00
Noel Grandin b5da97197b Revert "loplugin:constfields in package..registry"
This reverts commit 31138ff772.

Now that we know that making fields has negative side effects
like disabling assignment operator generation.

Change-Id: I3f1ae65532f441c8be5ebca5866b8a1e1c69318c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90363
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2020-03-12 08:17:11 +01:00
Arkadiy Illarionov edcdfe5477 Simplify Sequence iterations in postprocess..sax
Use range-based loops, STL and comphelper functions

Change-Id: If738d8f4e792c4686870183b0c0fdfbb61fd3351
Reviewed-on: https://gerrit.libreoffice.org/77245
Tested-by: Jenkins
Reviewed-by: Arkadiy Illarionov <qarkai@gmail.com>
2019-08-17 14:08:33 +02:00
Noel Grandin aea932b58b loplugin:sequenceloop in postprocess..reportdesign
Change-Id: I86b9174c37e4a347a3a8ac6c2707052167e6fdc0
Reviewed-on: https://gerrit.libreoffice.org/77522
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2019-08-15 20:21:55 +02:00
Noel Grandin 31138ff772 loplugin:constfields in package..registry
Change-Id: Ie139490f2b008bf294910d002af711f8f41fe76d
Reviewed-on: https://gerrit.libreoffice.org/61727
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-10-13 07:43:45 +02:00
Stephan Bergmann 604df2f608 [API CHANGE] Fix typo in prop implemented by stardiv.UnoControls.FrameControl
There is exactly one implementation of css.frame.FrameControl (which demands a
property named "ComponentUrl" not "ComponentURL"), and exactly one place where
that property is used.  So switch those two places to use the spelling of the
property name as documented in the UNOIDL service.  (Even though that can be
considered an incompatible change, in the unlikely case that 3rd party code
expects to be able to access the given implementation's property with the mis-
spelled name.)

Change-Id: I4fa3f21851b61079c09deea1a24aac22bc96f36f
Reviewed-on: https://gerrit.libreoffice.org/51766
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2018-03-23 13:02:45 +01:00
Stephan Bergmann 198b1ed586 blacklist should have been static
Change-Id: I2f9172ba9d9724b39ce00f0e5a24a5d4032789a9
Reviewed-on: https://gerrit.libreoffice.org/51765
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2018-03-23 10:56:44 +01:00
Stephan Bergmann ffc525e348 CppunitTest_services: check service impls support properties as advertised
...blacklisting existing violations for now (to be cleaned up)

Change-Id: Ie94de44d44e04ed45c0ae10d518157da76332bda
Reviewed-on: https://gerrit.libreoffice.org/51654
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2018-03-21 10:26:22 +01:00
Andrea Gelmini c101df2171 Fix typos
Change-Id: Iedd82d035454c940d76a94c7e910c81827c1389c
Reviewed-on: https://gerrit.libreoffice.org/48828
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Tested-by: Julien Nabet <serval2412@yahoo.fr>
2018-01-29 13:26:15 +01:00
Stephan Bergmann 11cf64b730 Better fix for CppunitTest_services
...than 25313923b0 "Fix CppunitTest_services for
constructor-based implementations..." (which this commit reverts again).  My
claim that "the 'factory' would be the object itself" is nonsense, it would
rather be an ImplementationWrapper (but one that was freshly created for each
ServiceManager::createContentEnumeration).

Change-Id: I85c683cff6f9ba78d0f8567a53f8fcbc56fe55cf
2017-10-27 10:37:26 +02:00
Stephan Bergmann 25313923b0 Fix CppunitTest_services for constructor-based implementations...
(i.e., using constructor="..." in the .component file) that implement multiple
services, but are not implemented as single-instance objects (i.e., always
return different objects from that constructor function).  In that case, the
"factory" would be the object itself, and would thus be different for different
instantiations of that implementation.  erAck ran into such a case with new code
he's writing.

Change-Id: Ib134a4c6d1400b43a7df3cf6a115f8206fb80c93
2017-10-26 18:26:02 +02:00
Noel Grandin 65e293f524 clang-tidy modernize-use-emplace in package..sax
Change-Id: Ibc0258fd79df987a0e295552bcc5bf89ee12007a
Reviewed-on: https://gerrit.libreoffice.org/42173
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-09-12 08:03:09 +02:00
Miklos Vajna e71ed748ac sw: fix remaining loplugin:cppunitassertequals warnings
Now only subsequentchecks are remaining, as far as I see.

Change-Id: Id5e5a874f8de08c0fd3722aecdc02967ae5d421f
Reviewed-on: https://gerrit.libreoffice.org/33346
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
2017-01-20 14:07:27 +00:00
Noel Grandin 2087484c65 use consistent #define checks for the Windows platform
stage 2 of replacing usage of various checks for the windows platform
with the compiler-defined '_WIN32' macro

In this stage we focus on replacing usage of the WIN macro

Change-Id: Ie8a4a63198a6de96bd158ecd707dadafb9c8ea84
Reviewed-on: https://gerrit.libreoffice.org/22393
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
2016-02-17 11:33:57 +00:00
Stephan Bergmann 61a3be76c2 tdf#92668: Revert some implementation names, for backwards compatibility
These implementation names of Calc, Draw, Impress, and Writer documents are the
most likely to be checked by existing third-party code, so revert the
corresponding parts of 3099c70b11 "Fix various
XServiceInfo implementations" (and instead add fixups in CppunitTest_serives).

Change-Id: I1a760adbf4c89a1b4477d6e628abba8d2028ccfe
2015-07-13 13:47:50 +02:00
Stephan Bergmann 0620451818 Revert "give this a copy ctor"
This reverts commit da42d11008, problem is fixed
now with fc56579e9d "Keep GCC 4.6 happy"

Conflicts:
	postprocess/qa/services.cxx

Change-Id: If819749d322a0887c1668fbbe563d14e0402ac78
2015-03-25 11:59:57 +01:00
Stephan Bergmann fc56579e9d Keep GCC 4.6 happy
Change-Id: Iaaab55a9ac1ba8e0550f9cb35ed13489e4e4d851
2015-03-25 09:29:00 +01:00
Caolán McNamara da42d11008 give this a copy ctor
Change-Id: I144679e93e61f1bc19319ebf8893529c164ae0ee
2015-03-24 21:04:31 +00:00
Stephan Bergmann 131c9beffe CppunitTest_services: Check that XServiceInfo and .component data matches
Change-Id: I660c261a90d0ce7ace045f97e28808bc924fefd9
2015-03-24 18:08:40 +01:00
Stephan Bergmann 5e5a2e3e4d Fill in bug ID
Change-Id: I9aef1c4e74f296fa06bee98781462dd8138eebe4
2015-02-12 16:52:04 +01:00
Stephan Bergmann f7cd7b2ce4 Make CppunitTest_services instantiate even more services
Change-Id: Id9bfb3886e4a9cbc15a7bf7ef3aefa73bd160e3b
2015-02-12 16:01:55 +01:00
Markus Mohrhard 22fe5da542 add log message about untested services
Change-Id: I3e8da0ae510ce40421767de2bd106d39ec254a17
2015-02-11 23:20:59 +01:00
Caolán McNamara b1964a24a6 ReportDefinition is the one that is failing for me under Linux too
Change-Id: I00480813d8c3703039a55a7a706937d33e8e8463
2014-06-24 16:05:50 +01:00
Stephan Bergmann 0b5568b9dd Fix CppunitTest_services on Windows
...by blacklisting the problematic service

Change-Id: I524a7c7af2cb374911db7b204021c3d2bcd1fdd6
2014-06-12 12:29:24 +02:00
Stephan Bergmann c4444ea0c4 Avoid Solar Mutex deadlocks when disposing services
...as test code using gb_CppunitTest_use_vcl is implicitly run with Solar Mutex locked

Change-Id: I480b4bcce7c6a94922019679099b0883b3ee1030
2014-06-12 12:29:23 +02:00
Markus Mohrhard 336364b46d Revert "Revert "Make sure to dispose services supporting the XComponent protocol""
This reverts commit 044be7107a.

It only works sometimes. Still a deadlock based on a race condition.
2014-06-09 04:55:22 +02:00
Markus Mohrhard 044be7107a Revert "Make sure to dispose services supporting the XComponent protocol"
This reverts commit 4cacc6080e.
2014-06-07 04:34:10 +02:00
Stephan Bergmann 4cacc6080e Make sure to dispose services supporting the XComponent protocol
...to e.g. avoid leftover temp files from instantiating
com.sun.star.comp.report.OReportDefinition.  But dispose all instances only at
the very end, to avoid disposing some single-instance services too early.

Change-Id: I71fc50e80f4b5d1a1ca16e392725903b079ce2d1
2014-05-15 12:23:39 +02:00
Noel Grandin 78b9537b6a various: sal_Bool->bool
Change-Id: I30fa5227f30373f95060148f269450d2945c1bb9
2014-05-08 11:48:14 +02:00
Chris Sherlock c05ef7eeb1 Make service unit test easier to debug
It's sort of hard to break into this function with gdb. Seperating it out
makes it a lot easier to work out where things are breaking.

Change-Id: If99effd44fe677452ac3c1012b99da7da80c720e
Reviewed-on: https://gerrit.libreoffice.org/8844
Reviewed-by: Chris Sherlock <chris.sherlock79@gmail.com>
Tested-by: Chris Sherlock <chris.sherlock79@gmail.com>
2014-04-04 08:53:05 -05:00
Jan Holesovsky d8db8edded Add more logging so that we have the info even in case of weird crashes.
Change-Id: I5888fb3e1ffa1bfdf9b91c06087ef5b7ccbb82ec
2014-01-14 09:58:16 +01:00
Stephan Bergmann 014fbd610e Improve CppunitTest_services
Change-Id: I4b22ce7e5fa91d5008f72e1f351d25063065ba43
2013-12-19 22:46:34 +01:00
Matúš Kukan ff9614a744 Add a unit test trying to create every available service with default ctor.
Change-Id: I79e70aeabdb816eaf7a719d2094034d78d11c90b
2013-12-18 07:15:50 +01:00