diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-08-02 19:35:05 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-08-03 11:42:29 +0200 |
commit | 9ab633b5ea1266e354a3d0f122dff9c10c4e7120 (patch) | |
tree | 89d83992331dc5485cc620933af4b927fa35d16b /sw | |
parent | 7e89f1ec496c51bf183437ad097c6ed33365b8d3 (diff) |
editeng: track view shells in SfxListUndoActions
This is needed for e.g. tracking deletions by backspace in Writer shape
text.
Reviewed-on: https://gerrit.libreoffice.org/27807
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
(cherry picked from commit c86e89c5bb040786193f7b8bba8516ffa706a14a)
Change-Id: I6f873872566313096c2c57f4a13ac2f1db67e77d
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/tiledrendering/tiledrendering.cxx | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx index e4f95d8106be..340473d7d835 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 testShapeTextUndoShells(); + void testShapeTextUndoGroupShells(); CPPUNIT_TEST_SUITE(SwTiledRenderingTest); CPPUNIT_TEST(testRegisterCallback); @@ -88,6 +89,7 @@ public: CPPUNIT_TEST(testTextEditViewInvalidations); CPPUNIT_TEST(testUndoInvalidations); CPPUNIT_TEST(testShapeTextUndoShells); + CPPUNIT_TEST(testShapeTextUndoGroupShells); CPPUNIT_TEST_SUITE_END(); private: @@ -922,6 +924,36 @@ void SwTiledRenderingTest::testShapeTextUndoShells() comphelper::LibreOfficeKit::setActive(false); } +void SwTiledRenderingTest::testShapeTextUndoGroupShells() +{ + // Load a document and create a view. + comphelper::LibreOfficeKit::setActive(); + SwXTextDocument* pXTextDocument = createDoc("shape.fodt"); + sal_Int32 nView1 = SfxLokHelper::getView(); + + // Begin text edit. + SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell(); + SdrPage* pPage = pWrtShell->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0); + SdrObject* pObject = pPage->GetObj(0); + SdrView* pView = pWrtShell->GetDrawView(); + pWrtShell->GetView().BeginTextEdit(pObject, pView->GetSdrPageView(), pWrtShell->GetWin()); + pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'x', 0); + pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'x', 0); + pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::BACKSPACE); + pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::BACKSPACE); + + // Make sure that the undo item remembers who created it. + SwDoc* pDoc = pXTextDocument->GetDocShell()->GetDoc(); + sw::UndoManager& rUndoManager = pDoc->GetUndoManager(); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), rUndoManager.GetUndoActionCount()); + // This was -1: the view shell id for the (top) undo list action wasn't known. + CPPUNIT_ASSERT_EQUAL(nView1, rUndoManager.GetUndoAction()->GetViewShellId()); + + mxComponent->dispose(); + mxComponent.clear(); + comphelper::LibreOfficeKit::setActive(false); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SwTiledRenderingTest); CPPUNIT_PLUGIN_IMPLEMENT(); |