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>
This commit is contained in:
Stephan Bergmann 2020-04-08 09:26:38 +02:00
parent 92f1626160
commit 68c3d3e46b
3 changed files with 26 additions and 4 deletions

View file

@ -46,7 +46,7 @@ class tdf118189(UITestCase):
self.xUITest.executeCommand(".uno:Undo") self.xUITest.executeCommand(".uno:Undo")
#-> CRASH #-> CRASH
self.assertEqual(get_cell_by_position(document2, 0, 0, 0).getString(), "") self.assertEqual(get_cell_by_position(document2, 0, 0, 0).getString(), "On Back Order")
self.ui_test.close_doc() self.ui_test.close_doc()

View file

@ -82,6 +82,7 @@ class VCL_DLLPUBLIC SalInstance
private: private:
rtl::Reference< vcl::DisplayConnectionDispatch > m_pEventInst; rtl::Reference< vcl::DisplayConnectionDispatch > m_pEventInst;
const std::unique_ptr<comphelper::SolarMutex> m_pYieldMutex; const std::unique_ptr<comphelper::SolarMutex> m_pYieldMutex;
css::uno::Reference<css::uno::XInterface> m_clipboard;
public: public:
SalInstance(std::unique_ptr<comphelper::SolarMutex> pMutex); SalInstance(std::unique_ptr<comphelper::SolarMutex> pMutex);

View file

@ -17,14 +17,18 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 . * 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 <vcl/svapp.hxx>
#include <factory.hxx> #include <factory.hxx>
#include <svdata.hxx> #include <svdata.hxx>
#include <salinst.hxx> #include <salinst.hxx>
#include <com/sun/star/lang/IllegalArgumentException.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/lang/XSingleServiceFactory.hpp> #include <com/sun/star/lang/XSingleServiceFactory.hpp>
@ -452,9 +456,26 @@ Reference< XInterface > DropTarget_createInstance( const Reference< XMultiServic
/* /*
* SalInstance generic * 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() Reference< XInterface > SalInstance::CreateDragSource()