summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2021-11-26 17:05:41 +0100
committerMiklos Vajna <vmiklos@collabora.com>2021-12-17 16:23:20 +0100
commit8bd8fa55b2fd04006aa43a9e638c8801d24b06ca (patch)
tree5795e2e27e5b760354555e07890608b2199e2919 /vcl
parentf21f0f0ff656880149cfdfd34b8984c9541bca24 (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>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/components/dtranscomp.cxx11
-rw-r--r--vcl/source/treelist/transfer2.cxx14
2 files changed, 19 insertions, 6 deletions
diff --git a/vcl/source/components/dtranscomp.cxx b/vcl/source/components/dtranscomp.cxx
index 3819253e58dc..ee3e0d027105 100644
--- a/vcl/source/components/dtranscomp.cxx
+++ b/vcl/source/components/dtranscomp.cxx
@@ -20,6 +20,7 @@
#include <sal/config.h>
#include <comphelper/lok.hxx>
+#include <comphelper/processfactory.hxx>
#include <osl/mutex.hxx>
#include <tools/debug.hxx>
#include <vcl/svapp.hxx>
@@ -34,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>
@@ -422,13 +424,14 @@ Reference< XInterface > SalInstance::CreateClipboard( const Sequence< Any >& arg
"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 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;
}
DBG_TESTSOLARMUTEX();
if (!m_clipboard.is()) {
diff --git a/vcl/source/treelist/transfer2.cxx b/vcl/source/treelist/transfer2.cxx
index 0d43db107d9a..c06abcde72c3 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>
@@ -484,8 +486,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;