diff options
author | Szymon Kłos <szymon.klos@collabora.com> | 2021-11-26 17:05:41 +0100 |
---|---|---|
committer | Szymon Kłos <szymon.klos@collabora.com> | 2023-02-06 17:02:54 +0000 |
commit | 52eba7937154a49e07360b297d5d7c396ca91903 (patch) | |
tree | 3e5f8afc29458f720cb6d7cd46e84d3ffeae6a3e /sc | |
parent | f16f69f719b7efa99a2b3a4d73dffc2777d5d425 (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 'sc')
-rw-r--r-- | sc/CppunitTest_sc_tiledrendering.mk | 1 | ||||
-rw-r--r-- | sc/qa/unit/tiledrendering/tiledrendering.cxx | 53 |
2 files changed, 49 insertions, 5 deletions
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 <LibreOfficeKit/LibreOfficeKitEnums.h> #include <com/sun/star/frame/Desktop.hpp> -#include <com/sun/star/datatransfer/clipboard/SystemClipboard.hpp> +#include <com/sun/star/frame/DispatchHelper.hpp> +#include <com/sun/star/datatransfer/clipboard/LokClipboard.hpp> +#include <com/sun/star/datatransfer/UnsupportedFlavorException.hpp> #include <comphelper/dispatchcommand.hxx> #include <comphelper/processfactory.hxx> #include <comphelper/propertysequence.hxx> @@ -1686,14 +1688,14 @@ void ScTiledRenderingTest::testMultiViewCopyPaste() ScTabViewShell* pView1 = dynamic_cast<ScTabViewShell*>(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<ScTabViewShell*>(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<ScTabViewShell*>(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<datatransfer::clipboard::XClipboard> 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<datatransfer::clipboard::XClipboard> 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); |