diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-07-15 17:26:34 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-07-21 10:42:40 +0200 |
commit | 37e215f708a872b9a232247217648c2c4872d550 (patch) | |
tree | 1e1aacb7f68026cceab53d5bd24ca89652c3fd17 /sw | |
parent | 3d32a7536fad8e50e6f5210688b8af1a2e6338f2 (diff) |
lok::Document::destroyView: clean up view cursors/selections
(cherry picked from commit bc9b4fd4c83af3532204237157821d4884c42d8e)
Conflicts:
sd/source/ui/view/ViewShellBase.cxx
sw/source/uibase/uiview/view.cxx
Change-Id: Icd3f96a922e7d1aec0d52e90df87ec45790c9807
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/tiledrendering/tiledrendering.cxx | 51 | ||||
-rw-r--r-- | sw/source/uibase/uiview/view.cxx | 7 |
2 files changed, 57 insertions, 1 deletions
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx index 6ab106ddfb72..ad1c36c418d2 100644 --- a/sw/qa/extras/tiledrendering/tiledrendering.cxx +++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx @@ -55,6 +55,7 @@ public: void testViewCursors(); void testMissingInvalidation(); void testViewCursorVisibility(); + void testViewCursorCleanup(); CPPUNIT_TEST_SUITE(SwTiledRenderingTest); CPPUNIT_TEST(testRegisterCallback); @@ -76,6 +77,7 @@ public: CPPUNIT_TEST(testViewCursors); CPPUNIT_TEST(testMissingInvalidation); CPPUNIT_TEST(testViewCursorVisibility); + CPPUNIT_TEST(testViewCursorCleanup); CPPUNIT_TEST_SUITE_END(); private: @@ -557,6 +559,7 @@ public: bool m_bViewSelectionSet; bool m_bTilesInvalidated; bool m_bViewCursorVisible; + bool m_bGraphicViewSelection; ViewCallback() : m_bOwnCursorInvalidated(false), @@ -564,7 +567,8 @@ public: m_bOwnSelectionSet(false), m_bViewSelectionSet(false), m_bTilesInvalidated(false), - m_bViewCursorVisible(false) + m_bViewCursorVisible(false), + m_bGraphicViewSelection(false) { } @@ -607,6 +611,14 @@ public: m_bViewCursorVisible = OString("true") == pPayload; } break; + case LOK_CALLBACK_GRAPHIC_VIEW_SELECTION: + { + std::stringstream aStream(pPayload); + boost::property_tree::ptree aTree; + boost::property_tree::read_json(aStream, aTree); + m_bGraphicViewSelection = aTree.get_child("selection").get_value<std::string>() != "EMPTY"; + } + break; } } }; @@ -720,6 +732,43 @@ void SwTiledRenderingTest::testViewCursorVisibility() comphelper::LibreOfficeKit::setActive(false); } +void SwTiledRenderingTest::testViewCursorCleanup() +{ + 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); + int nView2 = SfxLokHelper::createView(); + pXTextDocument->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>()); + ViewCallback aView2; + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView2); + + // Click on the shape in the second view. + SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell(); + SdrPage* pPage = pWrtShell->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0); + SdrObject* pObject = pPage->GetObj(0); + Point aCenter = pObject->GetSnapRect().Center(); + aView1.m_bGraphicViewSelection = false; + pXTextDocument->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONDOWN, aCenter.getX(), aCenter.getY(), 1); + pXTextDocument->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONUP, aCenter.getX(), aCenter.getY(), 1); + Scheduler::ProcessEventsToIdle(); + // Make sure there is a graphic view selection on the first view. + CPPUNIT_ASSERT(aView1.m_bGraphicViewSelection); + + // Now destroy the second view. + SfxLokHelper::destroyView(nView2); + Scheduler::ProcessEventsToIdle(); + CPPUNIT_ASSERT_EQUAL(static_cast<std::size_t>(1), SfxLokHelper::getViews()); + // Make sure that the graphic view selection on the first view is cleaned up. + CPPUNIT_ASSERT(!aView1.m_bGraphicViewSelection); + mxComponent->dispose(); + mxComponent.clear(); + + comphelper::LibreOfficeKit::setActive(false); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SwTiledRenderingTest); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/uibase/uiview/view.cxx b/sw/source/uibase/uiview/view.cxx index 0f3ff772cbb4..e95ac2e38415 100644 --- a/sw/source/uibase/uiview/view.cxx +++ b/sw/source/uibase/uiview/view.cxx @@ -112,6 +112,8 @@ #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> #include <svl/cjkoptions.hxx> +#include <sfx2/lokhelper.hxx> +#include <LibreOfficeKit/LibreOfficeKitEnums.h> using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -1016,6 +1018,11 @@ SwView::SwView( SfxViewFrame *_pFrame, SfxViewShell* pOldSh ) SwView::~SwView() { + // Notify other LOK views that we are going away. + SfxLokHelper::notifyOtherViews(this, LOK_CALLBACK_VIEW_CURSOR_VISIBLE, "visible", "false"); + SfxLokHelper::notifyOtherViews(this, LOK_CALLBACK_TEXT_VIEW_SELECTION, "selection", ""); + SfxLokHelper::notifyOtherViews(this, LOK_CALLBACK_GRAPHIC_VIEW_SELECTION, "selection", "EMPTY"); + GetViewFrame()->GetWindow().RemoveChildEventListener( LINK( this, SwView, WindowChildEventListener ) ); delete m_pPostItMgr; m_pPostItMgr = nullptr; |