summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2021-11-26 17:05:41 +0100
committerSzymon Kłos <szymon.klos@collabora.com>2023-02-06 17:02:54 +0000
commit52eba7937154a49e07360b297d5d7c396ca91903 (patch)
tree3e5f8afc29458f720cb6d7cd46e84d3ffeae6a3e /vcl
parentf16f69f719b7efa99a2b3a4d73dffc2777d5d425 (diff)
Make LOKClipboard available to other modules
LOKClipboard has higher level dependencies (sfx2) so it cannot be moved to the vcl where SystemClibpoard instance is created. - introduce new interface LokClipboard to differentiate from SystemClipboard so we can have vcl's and lok's implementations at the same time - publish LOKClipboard using new interface for other modules by adding component file in desktop module Thanks to that when code calls GetClipboard and we cannot get clipboard assigned to the vcl::Window* (for welded widgets) in GetSystemClipboard correct instance is returned (shared clipboard for current view) so we can access content which was copied before. Previously always a new instance was created (with empty content). test ScTiledRenderingTest::testPasteIntoWrapTextCell was broken add some content to clipboard to simulate more real case and test the content copied Change-Id: I23c0298960a710c498646493f33122b908864cba Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126310 Reviewed-by: Luboš Luňák <l.lunak@collabora.com> Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131644 Reviewed-by: Szymon Kłos <szymon.klos@collabora.com> Tested-by: Szymon Kłos <szymon.klos@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135198 Tested-by: Jenkins
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/components/dtranscomp.cxx12
-rw-r--r--vcl/source/treelist/transfer2.cxx14
2 files changed, 20 insertions, 6 deletions
diff --git a/vcl/source/components/dtranscomp.cxx b/vcl/source/components/dtranscomp.cxx
index 643d9cbc17be..b3acc0e6094d 100644
--- a/vcl/source/components/dtranscomp.cxx
+++ b/vcl/source/components/dtranscomp.cxx
@@ -20,6 +20,8 @@
#include <sal/config.h>
#include <comphelper/lok.hxx>
+#include <comphelper/processfactory.hxx>
+#include <osl/mutex.hxx>
#include <tools/debug.hxx>
#include <vcl/svapp.hxx>
@@ -33,6 +35,7 @@
#include <com/sun/star/lang/XSingleServiceFactory.hpp>
#include <com/sun/star/lang/XInitialization.hpp>
#include <com/sun/star/datatransfer/XTransferable.hpp>
+#include <com/sun/star/datatransfer/clipboard/LokClipboard.hpp>
#include <com/sun/star/datatransfer/clipboard/XClipboardListener.hpp>
#include <com/sun/star/datatransfer/clipboard/XSystemClipboard.hpp>
#include <com/sun/star/datatransfer/dnd/XDragSource.hpp>
@@ -417,13 +420,14 @@ Reference< XInterface > SalInstance::CreateClipboard( const Sequence< Any >& arg
return Reference< XInterface >( static_cast<cppu::OWeakObject *>(new vcl::GenericClipboard()) );
#else
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 LOK, each document view shall have its own clipboard instance (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()) );
+ css::uno::Reference<css::datatransfer::clipboard::XClipboard> xClipboard =
+ css::datatransfer::clipboard::LokClipboard::create(
+ comphelper::getProcessComponentContext());
+ return xClipboard;
}
#endif
DBG_TESTSOLARMUTEX();
diff --git a/vcl/source/treelist/transfer2.cxx b/vcl/source/treelist/transfer2.cxx
index c63770d8a4cc..d0a105554c0f 100644
--- a/vcl/source/treelist/transfer2.cxx
+++ b/vcl/source/treelist/transfer2.cxx
@@ -24,7 +24,9 @@
#include <tools/debug.hxx>
#include <vcl/svapp.hxx>
#include <vcl/window.hxx>
+#include <comphelper/lok.hxx>
#include <comphelper/processfactory.hxx>
+#include <com/sun/star/datatransfer/clipboard/LokClipboard.hpp>
#include <com/sun/star/datatransfer/clipboard/SystemClipboard.hpp>
#include <com/sun/star/datatransfer/dnd/XDropTargetDragContext.hpp>
#include <com/sun/star/datatransfer/dnd/XDragGestureRecognizer.hpp>
@@ -482,8 +484,16 @@ Reference<XClipboard> GetSystemClipboard()
Reference<XClipboard> xClipboard;
try
{
- xClipboard = css::datatransfer::clipboard::SystemClipboard::create(
- comphelper::getProcessComponentContext());
+ if (comphelper::LibreOfficeKit::isActive())
+ {
+ xClipboard = css::datatransfer::clipboard::LokClipboard::create(
+ comphelper::getProcessComponentContext());
+ }
+ else
+ {
+ xClipboard = css::datatransfer::clipboard::SystemClipboard::create(
+ comphelper::getProcessComponentContext());
+ }
}
catch (DeploymentException const &) {}
return xClipboard;