diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-08-02 17:52:44 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-08-02 17:33:17 +0000 |
commit | b567278c4aa6e3dee331b60c71eb996babcc9d08 (patch) | |
tree | c459be957e7e3146f1854e72e755bcdfdca06743 /sw | |
parent | db686815b41c52598f0952613ff8c6be34b2f0e0 (diff) |
editeng: implement SfxUndoAction::GetViewShellId() interface in EditUndo
With this, e.g. inserting a character in a Writer shape text remembers
its view shell.
Change-Id: Ic82a3f45a66cf622496e3131390d365440dffb3b
Reviewed-on: https://gerrit.libreoffice.org/27796
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/tiledrendering/tiledrendering.cxx | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx index 79d3e18050dc..cfb1cbed5d79 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 <view.hxx> +#include <UndoManager.hxx> #include <sfx2/viewsh.hxx> #include <sfx2/lokhelper.hxx> @@ -59,6 +60,7 @@ public: void testViewLock(); void testTextEditViewInvalidations(); void testUndoInvalidations(); + void testShapeTextUndoShells(); CPPUNIT_TEST_SUITE(SwTiledRenderingTest); CPPUNIT_TEST(testRegisterCallback); @@ -84,6 +86,7 @@ public: CPPUNIT_TEST(testViewLock); CPPUNIT_TEST(testTextEditViewInvalidations); CPPUNIT_TEST(testUndoInvalidations); + CPPUNIT_TEST(testShapeTextUndoShells); CPPUNIT_TEST_SUITE_END(); private: @@ -890,6 +893,34 @@ void SwTiledRenderingTest::testUndoInvalidations() comphelper::LibreOfficeKit::setActive(false); } +void SwTiledRenderingTest::testShapeTextUndoShells() +{ + // 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); + + // 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>(1), rUndoManager.GetUndoActionCount()); + // This was -1: the view shell id for the undo 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(); |