summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-07-15 17:26:34 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-07-21 10:42:40 +0200
commit37e215f708a872b9a232247217648c2c4872d550 (patch)
tree1e1aacb7f68026cceab53d5bd24ca89652c3fd17
parent3d32a7536fad8e50e6f5210688b8af1a2e6338f2 (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
-rw-r--r--sc/source/ui/view/tabvwsh4.cxx8
-rw-r--r--sd/source/ui/view/ViewShellBase.cxx7
-rw-r--r--sw/qa/extras/tiledrendering/tiledrendering.cxx51
-rw-r--r--sw/source/uibase/uiview/view.cxx7
4 files changed, 72 insertions, 1 deletions
diff --git a/sc/source/ui/view/tabvwsh4.cxx b/sc/source/ui/view/tabvwsh4.cxx
index 5a6413e90313..9d91dec43bd7 100644
--- a/sc/source/ui/view/tabvwsh4.cxx
+++ b/sc/source/ui/view/tabvwsh4.cxx
@@ -97,6 +97,8 @@
#include <com/sun/star/chart2/XCoordinateSystem.hpp>
#include <com/sun/star/chart2/XChartTypeContainer.hpp>
#include <com/sun/star/chart2/XChartType.hpp>
+#include <sfx2/lokhelper.hxx>
+#include <LibreOfficeKit/LibreOfficeKitEnums.h>
extern SfxViewShell* pScActiveViewShell; // global.cxx
@@ -1717,6 +1719,12 @@ ScTabViewShell::ScTabViewShell( SfxViewFrame* pViewFrame,
ScTabViewShell::~ScTabViewShell()
{
+ // 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");
+ SfxLokHelper::notifyOtherViews(this, LOK_CALLBACK_CELL_VIEW_CURSOR, "rectangle", "EMPTY");
+
ScDocShell* pDocSh = GetViewData().GetDocShell();
EndListening(*pDocSh);
EndListening(*GetViewFrame());
diff --git a/sd/source/ui/view/ViewShellBase.cxx b/sd/source/ui/view/ViewShellBase.cxx
index 7b57e9ec3358..b90fa2af0665 100644
--- a/sd/source/ui/view/ViewShellBase.cxx
+++ b/sd/source/ui/view/ViewShellBase.cxx
@@ -84,6 +84,8 @@
#include <vcl/settings.hxx>
#include <tools/diagnose_ex.h>
+#include <sfx2/lokhelper.hxx>
+#include <LibreOfficeKit/LibreOfficeKitEnums.h>
#include "fubullet.hxx"
@@ -268,6 +270,11 @@ ViewShellBase::ViewShellBase (
*/
ViewShellBase::~ViewShellBase()
{
+ // 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");
+
rtl::Reference<SlideShow> xSlideShow(SlideShow::GetSlideShow(*this));
if (xSlideShow.is() && xSlideShow->dependsOn(this))
SlideShow::Stop(*this);
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;