diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-08-10 15:51:51 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-08-15 09:54:47 +0200 |
commit | 01e160686140299002df52e76dc8e3411c6e01c2 (patch) | |
tree | 907ae72ed50c45791328e5b31ef9b1a8b50925da /sw/qa/extras/tiledrendering/tiledrendering.cxx | |
parent | ea8ba40c06fe2d0702c6dba22d1d4bed4af306b5 (diff) |
sfx2: make SfxLokHelper::setView() set also the active frame
Without this, comphelper::dispatchCommand() doesn't work on the current
frame. This causes e.g. undo not working when only a given view is
allowed to do undo.
In the desktop case vcl::Window::ImplGrabFocus() calls both
SfxViewFrame::MakeActive_Impl() and
framework::Desktop::setActiveFrame(), but in the LOK case the first was
called directly, that's how the active frame was outdated.
Change-Id: If97a9de316b4c8dd49e55cd273bdb2dfe9866f38
Reviewed-on: https://gerrit.libreoffice.org/28032
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
(cherry picked from commit d6e8d4f773d970b69baedd8523a426f18a8d8eef)
Diffstat (limited to 'sw/qa/extras/tiledrendering/tiledrendering.cxx')
-rw-r--r-- | sw/qa/extras/tiledrendering/tiledrendering.cxx | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx index cba799752506..1447248bcc5a 100644 --- a/sw/qa/extras/tiledrendering/tiledrendering.cxx +++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx @@ -62,6 +62,7 @@ public: void testTextEditViewInvalidations(); void testUndoInvalidations(); void testUndoLimiting(); + void testUndoDispatch(); void testShapeTextUndoShells(); void testShapeTextUndoGroupShells(); @@ -90,6 +91,7 @@ public: CPPUNIT_TEST(testTextEditViewInvalidations); CPPUNIT_TEST(testUndoInvalidations); CPPUNIT_TEST(testUndoLimiting); + CPPUNIT_TEST(testUndoDispatch); CPPUNIT_TEST(testShapeTextUndoShells); CPPUNIT_TEST(testShapeTextUndoGroupShells); CPPUNIT_TEST_SUITE_END(); @@ -924,6 +926,41 @@ void SwTiledRenderingTest::testUndoLimiting() comphelper::LibreOfficeKit::setActive(false); } +void SwTiledRenderingTest::testUndoDispatch() +{ + // Load a document and create two views. + comphelper::LibreOfficeKit::setActive(); + SwXTextDocument* pXTextDocument = createDoc("dummy.fodt"); + int nView1 = SfxLokHelper::getView(); + SfxLokHelper::createView(); + pXTextDocument->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>()); + int nView2 = SfxLokHelper::getView(); + + // Insert a character in the first view. + SfxLokHelper::setView(nView1); + pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'c', 0); + pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'c', 0); + + // Click before the first word in the second view. + SfxLokHelper::setView(nView2); + SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell(); + SwShellCursor* pShellCursor = pWrtShell->getShellCursor(false); + Point aStart = pShellCursor->GetSttPos(); + aStart.setX(aStart.getX() - 1000); + pXTextDocument->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONDOWN, aStart.getX(), aStart.getY(), 1, MOUSE_LEFT, 0); + pXTextDocument->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONUP, aStart.getX(), aStart.getY(), 1, MOUSE_LEFT, 0); + uno::Reference<frame::XDesktop2> xDesktop = frame::Desktop::create(comphelper::getProcessComponentContext()); + uno::Reference<frame::XFrame> xFrame2 = xDesktop->getActiveFrame(); + + // Now switch back to the first view, and make sure that the active frame is updated. + SfxLokHelper::setView(nView1); + uno::Reference<frame::XFrame> xFrame1 = xDesktop->getActiveFrame(); + // This failed: setView() did not update the active frame. + CPPUNIT_ASSERT(xFrame1 != xFrame2); + + comphelper::LibreOfficeKit::setActive(false); +} + void SwTiledRenderingTest::testShapeTextUndoShells() { // Load a document and create a view. |