diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-07-08 15:13:13 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-07-08 13:46:10 +0000 |
commit | af8419fa1d3cea57481e0e53518237eea2d9cdad (patch) | |
tree | 42458217ef0137430b058950d5f99e80d0b4ba21 /sw | |
parent | 5d1865293a66eb902237e70877226b7cec31105c (diff) |
sw lok: add LOK_CALLBACK_VIEW_CURSOR_VISIBLE
With this, in case a text cursor is turned into a graphic selection in
view#0, then view#1 can also hide the text cursor of view#0.
Change-Id: I7de89b8537ef8b0985336793b719d93733604bff
Reviewed-on: https://gerrit.libreoffice.org/27044
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/tiledrendering/tiledrendering.cxx | 43 | ||||
-rw-r--r-- | sw/source/core/crsr/crsrsh.cxx | 9 |
2 files changed, 48 insertions, 4 deletions
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx index 7709df87b1f4..476b6d618066 100644 --- a/sw/qa/extras/tiledrendering/tiledrendering.cxx +++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx @@ -53,6 +53,7 @@ public: void testPartHash(); void testViewCursors(); void testMissingInvalidation(); + void testViewCursorVisibility(); CPPUNIT_TEST_SUITE(SwTiledRenderingTest); CPPUNIT_TEST(testRegisterCallback); @@ -73,6 +74,7 @@ public: CPPUNIT_TEST(testPartHash); CPPUNIT_TEST(testViewCursors); CPPUNIT_TEST(testMissingInvalidation); + CPPUNIT_TEST(testViewCursorVisibility); CPPUNIT_TEST_SUITE_END(); private: @@ -553,13 +555,15 @@ public: bool m_bOwnSelectionSet; bool m_bViewSelectionSet; bool m_bTilesInvalidated; + bool m_bViewCursorVisible; ViewCallback() : m_bOwnCursorInvalidated(false), m_bViewCursorInvalidated(false), m_bOwnSelectionSet(false), m_bViewSelectionSet(false), - m_bTilesInvalidated(false) + m_bTilesInvalidated(false), + m_bViewCursorVisible(false) { } @@ -568,7 +572,7 @@ public: static_cast<ViewCallback*>(pData)->callbackImpl(nType, pPayload); } - void callbackImpl(int nType, const char* /*pPayload*/) + void callbackImpl(int nType, const char* pPayload) { switch (nType) { @@ -597,6 +601,11 @@ public: m_bViewSelectionSet = true; } break; + case LOK_CALLBACK_VIEW_CURSOR_VISIBLE: + { + m_bViewCursorVisible = OString("true") == pPayload; + } + break; } } }; @@ -680,6 +689,36 @@ void SwTiledRenderingTest::testViewCursors() comphelper::LibreOfficeKit::setActive(false); } +void SwTiledRenderingTest::testViewCursorVisibility() +{ + comphelper::LibreOfficeKit::setActive(); + + // Load a document that has a shape and create two views. + SwXTextDocument* pXTextDocument = createDoc("shape.fodt"); + ViewCallback aView1; + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView1); + SfxLokHelper::createView(); + pXTextDocument->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>()); + ViewCallback aView2; + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView2); + + // Click on the shape in the second view. + aView1.m_bViewCursorVisible = true; + SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell(); + SdrPage* pPage = pWrtShell->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0); + SdrObject* pObject = pPage->GetObj(0); + Point aCenter = pObject->GetSnapRect().Center(); + pXTextDocument->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONDOWN, aCenter.getX(), aCenter.getY(), 1); + pXTextDocument->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONUP, aCenter.getX(), aCenter.getY(), 1); + Scheduler::ProcessEventsToIdle(); + // Make sure the "view/text" cursor of the first view gets a notification. + CPPUNIT_ASSERT(!aView1.m_bViewCursorVisible); + mxComponent->dispose(); + mxComponent.clear(); + + comphelper::LibreOfficeKit::setActive(false); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SwTiledRenderingTest); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx index bd7670136ac2..62f751d1d125 100644 --- a/sw/source/core/crsr/crsrsh.cxx +++ b/sw/source/core/crsr/crsrsh.cxx @@ -64,6 +64,7 @@ #include <IDocumentLayoutAccess.hxx> #include <LibreOfficeKit/LibreOfficeKitEnums.h> #include <comphelper/lok.hxx> +#include <sfx2/lokhelper.hxx> #include <comphelper/string.hxx> #include <PostItMgr.hxx> @@ -2138,7 +2139,9 @@ void SwCursorShell::ShowCursor() if (comphelper::LibreOfficeKit::isActive()) { - GetSfxViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_CURSOR_VISIBLE, OString::boolean(true).getStr()); + OString aPayload = OString::boolean(m_bSVCursorVis); + GetSfxViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_CURSOR_VISIBLE, aPayload.getStr()); + SfxLokHelper::notifyOtherViews(GetSfxViewShell(), LOK_CALLBACK_VIEW_CURSOR_VISIBLE, "visible", aPayload); } UpdateCursor(); @@ -2157,7 +2160,9 @@ void SwCursorShell::HideCursor() if (comphelper::LibreOfficeKit::isActive()) { - GetSfxViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_CURSOR_VISIBLE, OString::boolean(false).getStr()); + OString aPayload = OString::boolean(m_bSVCursorVis); + GetSfxViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_CURSOR_VISIBLE, aPayload.getStr()); + SfxLokHelper::notifyOtherViews(GetSfxViewShell(), LOK_CALLBACK_VIEW_CURSOR_VISIBLE, "visible", aPayload); } } } |