diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-08-15 17:27:45 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-08-16 11:49:20 +0200 |
commit | 7b8c4aa152e89e00f706906cbd5c40099749554b (patch) | |
tree | 317f123de08c3d3102ca848262b99ef1ce00148e /sw/qa | |
parent | 89206e27368249985f05957e833a20f03a945221 (diff) |
sw lok: limit undo/redo in SwDrawTextShell
So that one view can only undo/redo its own changes. This is used when
editing shape text, as that doesn't use
sw::UndoManager::GetLastUndoInfo().
Change-Id: Ibc3d6fcbd18398569190f06ed9b7399c54bb7d41
(cherry picked from commit 40231526b6a0d6d8713932b3ae60d665f615833c)
Diffstat (limited to 'sw/qa')
-rw-r--r-- | sw/qa/extras/tiledrendering/tiledrendering.cxx | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx index a51d0c8919f2..72f6f1c3bcef 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 testUndoShapeLimiting(); void testUndoDispatch(); void testUndoRepairDispatch(); void testShapeTextUndoShells(); @@ -92,6 +93,7 @@ public: CPPUNIT_TEST(testTextEditViewInvalidations); CPPUNIT_TEST(testUndoInvalidations); CPPUNIT_TEST(testUndoLimiting); + CPPUNIT_TEST(testUndoShapeLimiting); CPPUNIT_TEST(testUndoDispatch); CPPUNIT_TEST(testUndoRepairDispatch); CPPUNIT_TEST(testShapeTextUndoShells); @@ -928,6 +930,38 @@ void SwTiledRenderingTest::testUndoLimiting() comphelper::LibreOfficeKit::setActive(false); } +void SwTiledRenderingTest::testUndoShapeLimiting() +{ + // Load a document and create a view. + comphelper::LibreOfficeKit::setActive(); + SwXTextDocument* pXTextDocument = createDoc("shape.fodt"); + SwWrtShell* pWrtShell1 = pXTextDocument->GetDocShell()->GetWrtShell(); + SfxLokHelper::createView(); + pXTextDocument->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>()); + SwWrtShell* pWrtShell2 = pXTextDocument->GetDocShell()->GetWrtShell(); + + // Start shape text in the second view. + SdrPage* pPage = pWrtShell2->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0); + SdrObject* pObject = pPage->GetObj(0); + SdrView* pView = pWrtShell2->GetDrawView(); + pWrtShell2->GetView().BeginTextEdit(pObject, pView->GetSdrPageView(), pWrtShell2->GetWin()); + pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'x', 0); + pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'x', 0); + + // Assert that the first view can't and the second view can undo the insertion. + SwDoc* pDoc = pXTextDocument->GetDocShell()->GetDoc(); + sw::UndoManager& rUndoManager = pDoc->GetUndoManager(); + rUndoManager.SetView(&pWrtShell1->GetView()); + // This was 1: first view could undo the change of the second view. + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), rUndoManager.GetUndoActionCount()); + rUndoManager.SetView(&pWrtShell2->GetView()); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), rUndoManager.GetUndoActionCount()); + + pWrtShell2->EndTextEdit(); + rUndoManager.SetView(nullptr); + comphelper::LibreOfficeKit::setActive(false); +} + void SwTiledRenderingTest::testUndoDispatch() { // Load a document and create two views. |