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 @@ + + + + + + + + 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 #include +#include #include #include #include +#include using namespace css; using namespace css::uno; @@ -75,7 +77,7 @@ LOKClipboard::LOKClipboard() Sequence LOKClipboard::getSupportedServiceNames_static() { - Sequence aRet{ "com.sun.star.datatransfer.clipboard.SystemClipboard" }; + Sequence 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 const& /*args*/) +{ + SolarMutexGuard aGuard; + + cppu::OWeakObject* pClipboard = LOKClipboardFactory::getClipboardForCurView().get(); + + pClipboard->acquire(); + return pClipboard; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk index 0f8c58db702d..e56e1dcf7754 100644 --- a/offapi/UnoApi_offapi.mk +++ b/offapi/UnoApi_offapi.mk @@ -107,6 +107,7 @@ $(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,com/sun/star/datatransfer,\ MimeContentTypeFactory \ )) $(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,com/sun/star/datatransfer/clipboard,\ + LokClipboard \ SystemClipboard \ )) $(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,com/sun/star/deployment,\ diff --git a/offapi/com/sun/star/datatransfer/clipboard/LokClipboard.idl b/offapi/com/sun/star/datatransfer/clipboard/LokClipboard.idl new file mode 100644 index 000000000000..4d9d3dea0646 --- /dev/null +++ b/offapi/com/sun/star/datatransfer/clipboard/LokClipboard.idl @@ -0,0 +1,35 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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 . + */ + +#ifndef __com_sun_star_datatransfer_clipboard_LokClipboard_idl__ +#define __com_sun_star_datatransfer_clipboard_LokClipboard_idl__ + +#include + +module com { module sun { module star { module datatransfer { module clipboard { + +/** This service provides access to the clipboard dedicated for current view +*/ +service LokClipboard : XSystemClipboard; + +}; }; }; }; }; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/CppunitTest_sc_tiledrendering.mk b/sc/CppunitTest_sc_tiledrendering.mk index 723cefb73dca..960e5fa67205 100644 --- a/sc/CppunitTest_sc_tiledrendering.mk +++ b/sc/CppunitTest_sc_tiledrendering.mk @@ -24,6 +24,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sc_tiledrendering, \ editeng \ sal \ sfx \ + sot \ svl \ svt \ svxcore \ diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx index 65e1f894c834..47ed1530c075 100644 --- a/sc/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx @@ -13,7 +13,9 @@ #include #include -#include +#include +#include +#include #include #include #include @@ -1686,14 +1688,14 @@ void ScTiledRenderingTest::testMultiViewCopyPaste() ScTabViewShell* pView1 = dynamic_cast(SfxViewShell::Current()); CPPUNIT_ASSERT(pView1); // emulate clipboard - pView1->GetViewData().GetActiveWin()->SetClipboard(css::datatransfer::clipboard::SystemClipboard::create(comphelper::getProcessComponentContext())); + pView1->GetViewData().GetActiveWin()->SetClipboard(css::datatransfer::clipboard::LokClipboard::create(comphelper::getProcessComponentContext())); // view #2 int nView1 = SfxLokHelper::getView(); SfxLokHelper::createView(); ScTabViewShell* pView2 = dynamic_cast(SfxViewShell::Current()); // emulate clipboard - pView2->GetViewData().GetActiveWin()->SetClipboard(css::datatransfer::clipboard::SystemClipboard::create(comphelper::getProcessComponentContext())); + pView2->GetViewData().GetActiveWin()->SetClipboard(css::datatransfer::clipboard::LokClipboard::create(comphelper::getProcessComponentContext())); CPPUNIT_ASSERT(pView2); CPPUNIT_ASSERT(pView1 != pView2); CPPUNIT_ASSERT(pView1->GetViewData().GetActiveWin()->GetClipboard() != pView2->GetViewData().GetActiveWin()->GetClipboard()); @@ -2503,6 +2505,27 @@ void ScTiledRenderingTest::testPasteIntoWrapTextCell() ScTabViewShell* pView = dynamic_cast(SfxViewShell::Current()); CPPUNIT_ASSERT(pView); + // create source text in A1 + OUString sCopyContent("Very long text to copy"); + pDoc->SetString(0, 0, 0, sCopyContent); + + // copy A1 + pView->SetCursor(0, 0); + Scheduler::ProcessEventsToIdle(); + pView->GetViewFrame()->GetBindings().Execute(SID_COPY); + Scheduler::ProcessEventsToIdle(); + + // verify clipboard + uno::Reference xClipboard1 = pView->GetViewData().GetActiveWin()->GetClipboard(); + uno::Reference< datatransfer::XTransferable > xDataObj = + xClipboard1->getContents(); + datatransfer::DataFlavor aFlavor; + SotExchange::GetFormatDataFlavor(SotClipboardFormatId::STRING, aFlavor); + uno::Any aData = xDataObj->getTransferData(aFlavor); + OUString aTmpText; + aData >>= aTmpText; + CPPUNIT_ASSERT_EQUAL(sCopyContent, aTmpText.trim()); + // Go to A2 and paste. pView->SetCursor(0, 1); Scheduler::ProcessEventsToIdle(); @@ -2510,8 +2533,27 @@ void ScTiledRenderingTest::testPasteIntoWrapTextCell() pView->GetViewFrame()->GetBindings().Execute(SID_PASTE); Scheduler::ProcessEventsToIdle(); - // No SG invalidations - CPPUNIT_ASSERT_EQUAL(OString(""), aView.m_sInvalidateSheetGeometry); + CPPUNIT_ASSERT_EQUAL(sCopyContent, pDoc->GetString(0, 1, 0)); + CPPUNIT_ASSERT_EQUAL(OString("rows sizes"), aView.m_sInvalidateSheetGeometry); + + // create new source text in A2 + OUString sCopyContent2("Very long text to copy 2"); + pDoc->SetString(0, 1, 0, sCopyContent2); + Scheduler::ProcessEventsToIdle(); + + // cut from A2 + pView->GetViewFrame()->GetBindings().Execute(SID_CUT); + Scheduler::ProcessEventsToIdle(); + + // verify clipboard + uno::Reference xClipboard2 + = pView->GetViewData().GetActiveWin()->GetClipboard(); + xDataObj = xClipboard2->getContents(); + SotExchange::GetFormatDataFlavor(SotClipboardFormatId::STRING, aFlavor); + aData = xDataObj->getTransferData(aFlavor); + aData >>= aTmpText; + CPPUNIT_ASSERT_EQUAL(xClipboard1, xClipboard2); + CPPUNIT_ASSERT_EQUAL(sCopyContent2, aTmpText.trim()); // Go to A3 and paste. pView->SetCursor(0, 2); @@ -2521,6 +2563,7 @@ void ScTiledRenderingTest::testPasteIntoWrapTextCell() Scheduler::ProcessEventsToIdle(); // SG invalidations for all + CPPUNIT_ASSERT_EQUAL(sCopyContent2, pDoc->GetString(0, 1, 0)); CPPUNIT_ASSERT_EQUAL(OString("all"), aView.m_sInvalidateSheetGeometry); SfxViewShell::Current()->setLibreOfficeKitViewCallback(nullptr); diff --git a/solenv/bin/native-code.py b/solenv/bin/native-code.py index 6869bdbf805e..660c5d65fd57 100755 --- a/solenv/bin/native-code.py +++ b/solenv/bin/native-code.py @@ -127,6 +127,8 @@ core_constructor_list = [ "com_sun_star_comp_dba_ODatabaseDocument", "com_sun_star_comp_dba_ODatabaseSource", "com_sun_star_comp_dba_ORowSet_get_implementation", +# desktop/lokclipboard.component + "desktop_LOKClipboard_get_implementation", # drawinglayer/drawinglayer.component "drawinglayer_XPrimitive2DRenderer", # embeddedobj/util/embobj.component 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 #include +#include +#include #include #include @@ -33,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -417,13 +420,14 @@ Reference< XInterface > SalInstance::CreateClipboard( const Sequence< Any >& arg return Reference< XInterface >( static_cast(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 // "Re: Linux // SAL_USE_VCLPLUGIN=svp and the clipboard"): - return Reference< XInterface >( static_cast(new vcl::GenericClipboard()) ); + css::uno::Reference 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 #include #include +#include #include +#include #include #include #include @@ -482,8 +484,16 @@ Reference GetSystemClipboard() Reference 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;