diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2020-04-08 09:26:38 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2020-04-08 11:33:46 +0200 |
commit | 68c3d3e46bf731c93fe5eca2e35042484f77d650 (patch) | |
tree | 8f91e931df4e6024e5df45e99bea170798395b5f /vcl | |
parent | 92f1626160b823f8136c03ab067136f866279da9 (diff) |
Make SalInstance::CreateClipboard return a single instance in the non-LOK case
I came across this when seeing UITest_calc_tests2's
tdf118189.tdf118189.test_tdf118189 fail on Linux with SAL_USE_VCLPLUGIN=gen and
also on Windows, see the mailing list thread starting at
<https://lists.freedesktop.org/archives/libreoffice/2020-April/084822.html>
"Linux SAL_USE_VCLPLUGIN=svp and the clipboard". That email thread clarified
that the codified behavior of that non-LOK test was wrong. (While the LOK test
ScTiledRenderingTest::testMultiViewCopyPaste in
sc/qa/unit/tiledrendering/tiledrendering.cxx keeps working as intended.)
I did not find documentation for what arguments CreateClipboard shall support,
but things seem to work if anything but empty arguments is rejected with an
IllegalArgumentException.
Change-Id: I1918254cc15878ad43b8aa22aff7eb1c4bea73fe
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91869
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/inc/salinst.hxx | 1 | ||||
-rw-r--r-- | vcl/source/components/dtranscomp.cxx | 27 |
2 files changed, 25 insertions, 3 deletions
diff --git a/vcl/inc/salinst.hxx b/vcl/inc/salinst.hxx index 621343677078..36c51d990d5c 100644 --- a/vcl/inc/salinst.hxx +++ b/vcl/inc/salinst.hxx @@ -82,6 +82,7 @@ class VCL_DLLPUBLIC SalInstance private: rtl::Reference< vcl::DisplayConnectionDispatch > m_pEventInst; const std::unique_ptr<comphelper::SolarMutex> m_pYieldMutex; + css::uno::Reference<css::uno::XInterface> m_clipboard; public: SalInstance(std::unique_ptr<comphelper::SolarMutex> pMutex); diff --git a/vcl/source/components/dtranscomp.cxx b/vcl/source/components/dtranscomp.cxx index e76e7691ded8..c7bda5361fdb 100644 --- a/vcl/source/components/dtranscomp.cxx +++ b/vcl/source/components/dtranscomp.cxx @@ -17,14 +17,18 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include <osl/mutex.hxx> +#include <sal/config.h> +#include <comphelper/lok.hxx> +#include <osl/mutex.hxx> +#include <tools/debug.hxx> #include <vcl/svapp.hxx> #include <factory.hxx> #include <svdata.hxx> #include <salinst.hxx> +#include <com/sun/star/lang/IllegalArgumentException.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/lang/XSingleServiceFactory.hpp> @@ -452,9 +456,26 @@ Reference< XInterface > DropTarget_createInstance( const Reference< XMultiServic /* * SalInstance generic */ -Reference< XInterface > SalInstance::CreateClipboard( const Sequence< Any >& ) +Reference< XInterface > SalInstance::CreateClipboard( const Sequence< Any >& arguments ) { - return Reference< XInterface >( static_cast<cppu::OWeakObject *>(new vcl::GenericClipboard()) ); + if (arguments.hasElements()) { + throw css::lang::IllegalArgumentException( + "non-empty SalInstance::CreateClipboard arguments", {}, -1); + } + if (comphelper::LibreOfficeKit::isActive()) { + // In LOK, each document view shall have its own clipboard instance, and the way that + // (happens to?) work is that apparently this function is called at most once for each such + // document view, so it is OK if we hand out a fresh instance on each call in LOK (whereas + // in non-LOK below we keep handing out one single instance; see also + // <https://lists.freedesktop.org/archives/libreoffice/2020-April/084824.html> "Re: Linux + // SAL_USE_VCLPLUGIN=svp and the clipboard"): + return Reference< XInterface >( static_cast<cppu::OWeakObject *>(new vcl::GenericClipboard()) ); + } + DBG_TESTSOLARMUTEX(); + if (!m_clipboard.is()) { + m_clipboard = static_cast<cppu::OWeakObject *>(new vcl::GenericClipboard()); + } + return m_clipboard; } Reference< XInterface > SalInstance::CreateDragSource() |