diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-08-10 17:42:54 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-08-15 09:54:56 +0200 |
commit | d7ceb72ff0b1ce94118d3c85cdc7641e461e44a6 (patch) | |
tree | b50fc74a170eef943cfdcce2db4f0793f8d927ea /sw/qa | |
parent | 01e160686140299002df52e76dc8e3411c6e01c2 (diff) |
sw undo: add a Repair argument to the .uno:Undo/Redo commands
Undo/redo is limited to undo actions created by the same view in the LOK
case, this argument removes this limit. This can be used by a client for
"document repair" purposes, where undo/redo of others' changes is
intentional.
The sfx command dispatch has support for FASTCALL slots (a state
function is not called, the command is always enabled) and also has
support for state functions, but those functions only get the ID of the
slots, not its parameters. What is needed here is a command that's
disabled by default, but in case a Repair argument is used, then it's
unconditionally enabled. So handle that case in the sfx dispatcher
directly for now.
Change-Id: I96c1130bf51abcdd722684b1fa4a8277f92fd555
(cherry picked from commit e9bcd3475131b24b0b8818cfdfa256854ca5a59d)
Diffstat (limited to 'sw/qa')
-rw-r--r-- | sw/qa/extras/tiledrendering/tiledrendering.cxx | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx index 1447248bcc5a..a51d0c8919f2 100644 --- a/sw/qa/extras/tiledrendering/tiledrendering.cxx +++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx @@ -63,6 +63,7 @@ public: void testUndoInvalidations(); void testUndoLimiting(); void testUndoDispatch(); + void testUndoRepairDispatch(); void testShapeTextUndoShells(); void testShapeTextUndoGroupShells(); @@ -92,6 +93,7 @@ public: CPPUNIT_TEST(testUndoInvalidations); CPPUNIT_TEST(testUndoLimiting); CPPUNIT_TEST(testUndoDispatch); + CPPUNIT_TEST(testUndoRepairDispatch); CPPUNIT_TEST(testShapeTextUndoShells); CPPUNIT_TEST(testShapeTextUndoGroupShells); CPPUNIT_TEST_SUITE_END(); @@ -961,6 +963,45 @@ void SwTiledRenderingTest::testUndoDispatch() comphelper::LibreOfficeKit::setActive(false); } +void SwTiledRenderingTest::testUndoRepairDispatch() +{ + // 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); + + // Assert that by default the second view can't undo the action. + SfxLokHelper::setView(nView2); + SwDoc* pDoc = pXTextDocument->GetDocShell()->GetDoc(); + sw::UndoManager& rUndoManager = pDoc->GetUndoManager(); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), rUndoManager.GetUndoActionCount()); + comphelper::dispatchCommand(".uno:Undo", {}); + Scheduler::ProcessEventsToIdle(); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), rUndoManager.GetUndoActionCount()); + + // But the same is allowed in repair mode. + SfxLokHelper::setView(nView2); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), rUndoManager.GetUndoActionCount()); + uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence( + { + {"Repair", uno::makeAny(true)} + })); + comphelper::dispatchCommand(".uno:Undo", aPropertyValues); + Scheduler::ProcessEventsToIdle(); + // This was 1: repair mode couldn't undo the action, either. + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), rUndoManager.GetUndoActionCount()); + + comphelper::LibreOfficeKit::setActive(false); +} + void SwTiledRenderingTest::testShapeTextUndoShells() { // Load a document and create a view. |