summaryrefslogtreecommitdiff
path: root/desktop
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-07 12:14:10 +0000
commit644513afa28aa6eee7bee40a1182b4a114aac53a (patch)
tree123ad21f0605944ba25d5ae17eb144b98d0d3680 /desktop
parentf30a8f6cb9a755d3ac73c2aafc2f71a0bb0d0369 (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 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146577
Diffstat (limited to 'desktop')
-rw-r--r--desktop/Library_sofficeapp.mk3
-rw-r--r--desktop/lokclipboard.component26
-rw-r--r--desktop/source/lib/lokclipboard.cxx16
3 files changed, 44 insertions, 1 deletions
diff --git a/desktop/Library_sofficeapp.mk b/desktop/Library_sofficeapp.mk
index c315a113ca89..0ae136c70e50 100644
--- a/desktop/Library_sofficeapp.mk
+++ b/desktop/Library_sofficeapp.mk
@@ -136,6 +136,8 @@ $(eval $(call gb_Library_add_exception_objects,sofficeapp,\
$(if $(filter $(OS),ANDROID), \
desktop/source/lib/lokandroid) \
))
+$(if $(filter-out $(OS),IOS), \
+ $(eval $(call gb_Library_set_componentfile,sofficeapp,desktop/lokclipboard,services)))
else
ifneq ($(filter TRUE,$(USING_X11) $(DISABLE_GUI))($filter EMSCRIPTEN,$(OS)),)
$(eval $(call gb_Library_add_exception_objects,sofficeapp,\
@@ -143,6 +145,7 @@ $(eval $(call gb_Library_add_exception_objects,sofficeapp,\
desktop/source/lib/lokinteractionhandler \
desktop/source/lib/lokclipboard \
))
+$(eval $(call gb_Library_set_componentfile,sofficeapp,desktop/lokclipboard,services))
endif
endif
diff --git a/desktop/lokclipboard.component b/desktop/lokclipboard.component
new file mode 100644
index 000000000000..a2c7c63284aa
--- /dev/null
+++ b/desktop/lokclipboard.component
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+-->
+
+<component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@"
+ xmlns="http://openoffice.org/2010/uno-components">
+ <implementation name="com.sun.star.datatransfer.LOKClipboard"
+ constructor="desktop_LOKClipboard_get_implementation">
+ <service name="com.sun.star.datatransfer.clipboard.LokClipboard"/>
+ </implementation>
+</component>
diff --git a/desktop/source/lib/lokclipboard.cxx b/desktop/source/lib/lokclipboard.cxx
index b4de36c56578..6a04f386ce17 100644
--- a/desktop/source/lib/lokclipboard.cxx
+++ b/desktop/source/lib/lokclipboard.cxx
@@ -10,9 +10,11 @@
#include "lokclipboard.hxx"
#include <unordered_map>
#include <vcl/lazydelete.hxx>
+#include <vcl/svapp.hxx>
#include <sfx2/lokhelper.hxx>
#include <sal/log.hxx>
#include <cppuhelper/supportsservice.hxx>
+#include <com/sun/star/uno/XComponentContext.hpp>
using namespace css;
using namespace css::uno;
@@ -75,7 +77,7 @@ LOKClipboard::LOKClipboard()
Sequence<OUString> LOKClipboard::getSupportedServiceNames_static()
{
- Sequence<OUString> aRet{ "com.sun.star.datatransfer.clipboard.SystemClipboard" };
+ Sequence<OUString> aRet{ "com.sun.star.datatransfer.clipboard.LokClipboard" };
return aRet;
}
@@ -227,4 +229,16 @@ sal_Bool SAL_CALL LOKTransferable::isDataFlavorSupported(const datatransfer::Dat
!= std::cend(m_aFlavors);
}
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
+desktop_LOKClipboard_get_implementation(css::uno::XComponentContext*,
+ css::uno::Sequence<css::uno::Any> const& /*args*/)
+{
+ SolarMutexGuard aGuard;
+
+ cppu::OWeakObject* pClipboard = LOKClipboardFactory::getClipboardForCurView().get();
+
+ pClipboard->acquire();
+ return pClipboard;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */