include/sfx2/lokhelper.hxx | 2 sfx2/source/view/lokhelper.cxx | 2 sfx2/source/view/viewsh.cxx | 9 +++ sw/qa/extras/tiledrendering/tiledrendering.cxx | 60 +++++++++++++++++++++++++ 4 files changed, 71 insertions(+), 2 deletions(-)
New commits: commit 4d211384f048b689f20e46d4d586f342b110cb5c Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Mon Jun 20 20:33:50 2016 +0200 sfx2 lok: fix missing view cursors in a new view When a new view was created, the old views got the position of the new view, but not the other way around. Make sure that the old views notify the new one right after registering the callback. Change-Id: If26edbd57aa939e453d95f4907a0e5722329dd65 Reviewed-on: https://gerrit.libreoffice.org/26523 Reviewed-by: Miklos Vajna <vmik...@collabora.co.uk> Tested-by: Jenkins <c...@libreoffice.org> diff --git a/include/sfx2/lokhelper.hxx b/include/sfx2/lokhelper.hxx index 43c0189..ec68ed6 100644 --- a/include/sfx2/lokhelper.hxx +++ b/include/sfx2/lokhelper.hxx @@ -26,7 +26,7 @@ public: /// Set a view shell as current one. static void setView(std::uintptr_t nId); /// Get the currently active view. - static std::uintptr_t getView(SfxViewShell *pViewShell = nullptr); + static std::uintptr_t getView(SfxViewShell* pViewShell = nullptr); /// Get the number of views of the current object shell. static std::size_t getViews(); }; diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx index ba42188..c994877 100644 --- a/sfx2/source/view/lokhelper.cxx +++ b/sfx2/source/view/lokhelper.cxx @@ -60,7 +60,7 @@ void SfxLokHelper::setView(std::uintptr_t nId) } -std::uintptr_t SfxLokHelper::getView(SfxViewShell *pViewShell) +std::uintptr_t SfxLokHelper::getView(SfxViewShell* pViewShell) { if (!pViewShell) pViewShell = SfxViewShell::Current(); diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx index 635ba12..f787d00 100644 --- a/sfx2/source/view/viewsh.cxx +++ b/sfx2/source/view/viewsh.cxx @@ -1456,6 +1456,15 @@ void SfxViewShell::registerLibreOfficeKitViewCallback(LibreOfficeKitCallback pCa { pImpl->m_pLibreOfficeKitViewCallback = pCallback; pImpl->m_pLibreOfficeKitViewData = pData; + + // Ask other views to send their cursor position to the new view. + SfxViewShell* pViewShell = SfxViewShell::GetFirst(); + while (pViewShell) + { + pViewShell->ShowCursor(false); + pViewShell->ShowCursor(); + pViewShell = SfxViewShell::GetNext(*pViewShell); + } } void SfxViewShell::libreOfficeKitViewCallback(int nType, const char* pPayload) const diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx index 5eed6d1..b244635 100644 --- a/sw/qa/extras/tiledrendering/tiledrendering.cxx +++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx @@ -26,6 +26,7 @@ #include <ndtxt.hxx> #include <wrtsh.hxx> #include <sfx2/viewsh.hxx> +#include <sfx2/lokhelper.hxx> static const char* DATA_DIRECTORY = "/sw/qa/extras/tiledrendering/data/"; @@ -50,6 +51,7 @@ public: void testSearchAllNotifications(); void testPageDownInvalidation(); void testPartHash(); + void testViewCursors(); CPPUNIT_TEST_SUITE(SwTiledRenderingTest); CPPUNIT_TEST(testRegisterCallback); @@ -68,6 +70,7 @@ public: CPPUNIT_TEST(testSearchAllNotifications); CPPUNIT_TEST(testPageDownInvalidation); CPPUNIT_TEST(testPartHash); + CPPUNIT_TEST(testViewCursors); CPPUNIT_TEST_SUITE_END(); private: @@ -487,6 +490,8 @@ void SwTiledRenderingTest::testSearchAllNotifications() SwXTextDocument* pXTextDocument = createDoc("search.odt"); SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell(); pWrtShell->GetSfxViewShell()->registerLibreOfficeKitViewCallback(&SwTiledRenderingTest::callback, this); + // Reset notification counter before search. + m_nSelectionBeforeSearchResult = 0; uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence( { {"SearchItem.SearchString", uno::makeAny(OUString("shape"))}, @@ -538,6 +543,61 @@ void SwTiledRenderingTest::testPartHash() comphelper::LibreOfficeKit::setActive(false); } +class ViewCallback +{ +public: + bool m_bOwnCursorInvalidated; + bool m_bViewCursorInvalidated; + + ViewCallback() + : m_bOwnCursorInvalidated(false), + m_bViewCursorInvalidated(false) + { + } + + static void callback(int nType, const char* pPayload, void* pData) + { + static_cast<ViewCallback*>(pData)->callbackImpl(nType, pPayload); + } + + void callbackImpl(int nType, const char* /*pPayload*/) + { + switch (nType) + { + case LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR: + { + m_bOwnCursorInvalidated = true; + } + break; + case LOK_CALLBACK_INVALIDATE_VIEW_CURSOR: + { + m_bViewCursorInvalidated = true; + } + break; + } + } +}; + +void SwTiledRenderingTest::testViewCursors() +{ + comphelper::LibreOfficeKit::setActive(); + + createDoc("dummy.fodt"); + ViewCallback aView1; + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView1); + SfxLokHelper::createView(); + ViewCallback aView2; + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView2); + CPPUNIT_ASSERT(aView1.m_bOwnCursorInvalidated); + CPPUNIT_ASSERT(aView1.m_bViewCursorInvalidated); + CPPUNIT_ASSERT(aView2.m_bOwnCursorInvalidated); + // This failed: the cursor position of view1 was only known to view2 once + // it changed. + CPPUNIT_ASSERT(aView2.m_bViewCursorInvalidated); + + comphelper::LibreOfficeKit::setActive(false); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SwTiledRenderingTest); CPPUNIT_PLUGIN_IMPLEMENT(); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits