diff options
author | Henry Castro <hcastro@collabora.com> | 2017-06-17 13:52:15 -0400 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2018-01-18 13:34:53 +0100 |
commit | e3c1713807499fdbe63fad0944d0ce3b91b28637 (patch) | |
tree | 011c8706d89611714b8583c8acc7221cc26f17a1 /sw | |
parent | ba5556e62ed3fda9f02aaf7d3ba23c19af7dbdfc (diff) |
lokit: add .uno:DocumentRepair command
Change-Id: I5b13ea6f4785bc91c29111fa63c4a1b0ea9b2660
Reviewed-on: https://gerrit.libreoffice.org/38908
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Henry Castro <hcastro@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/47915
Reviewed-by: Jan Holesovsky <kendy@collabora.com>
Tested-by: Jan Holesovsky <kendy@collabora.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/tiledrendering/tiledrendering.cxx | 48 | ||||
-rw-r--r-- | sw/source/core/inc/UndoManager.hxx | 3 | ||||
-rw-r--r-- | sw/source/core/undo/docundo.cxx | 8 |
3 files changed, 58 insertions, 1 deletions
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx index 0365ec10cc75..91cc2140716b 100644 --- a/sw/qa/extras/tiledrendering/tiledrendering.cxx +++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx @@ -32,6 +32,7 @@ #include <sfx2/viewsh.hxx> #include <sfx2/bindings.hxx> #include <sfx2/dispatch.hxx> +#include <sfx2/viewfrm.hxx> #include <sfx2/lokhelper.hxx> #include <redline.hxx> #include <IDocumentRedlineAccess.hxx> @@ -87,7 +88,7 @@ public: void testRedoRepairResult(); void testDisableUndoRepair(); void testAllTrackedChanges(); - + void testDocumentRepair(); CPPUNIT_TEST_SUITE(SwTiledRenderingTest); CPPUNIT_TEST(testRegisterCallback); @@ -134,6 +135,7 @@ public: CPPUNIT_TEST(testRedoRepairResult); CPPUNIT_TEST(testDisableUndoRepair); CPPUNIT_TEST(testAllTrackedChanges); + CPPUNIT_TEST(testDocumentRepair); CPPUNIT_TEST_SUITE_END(); @@ -1875,6 +1877,50 @@ void SwTiledRenderingTest::testAllTrackedChanges() comphelper::LibreOfficeKit::setActive(false); } +void SwTiledRenderingTest::testDocumentRepair() +{ + comphelper::LibreOfficeKit::setActive(); + + // Create two views. + SwXTextDocument* pXTextDocument = createDoc("dummy.fodt"); + // view #1 + SfxViewShell* pView1 = SfxViewShell::Current(); + + // view #2 + SfxLokHelper::createView(); + SfxViewShell* pView2 = SfxViewShell::Current(); + int nView2 = SfxLokHelper::getView(); + CPPUNIT_ASSERT(pView1 != pView2); + { + std::unique_ptr<SfxPoolItem> pItem1; + std::unique_ptr<SfxPoolItem> pItem2; + pView1->GetViewFrame()->GetBindings().QueryState(SID_DOC_REPAIR, pItem1); + pView2->GetViewFrame()->GetBindings().QueryState(SID_DOC_REPAIR, pItem2); + CPPUNIT_ASSERT(dynamic_cast< const SfxBoolItem* >(pItem1.get())); + CPPUNIT_ASSERT(dynamic_cast< const SfxBoolItem* >(pItem2.get())); + CPPUNIT_ASSERT_EQUAL(false, dynamic_cast< const SfxBoolItem* >(pItem1.get())->GetValue()); + CPPUNIT_ASSERT_EQUAL(false, dynamic_cast< const SfxBoolItem* >(pItem2.get())->GetValue()); + } + + // Insert a character in the second view. + SfxLokHelper::setView(nView2); + pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'u', 0); + pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'u', 0); + Scheduler::ProcessEventsToIdle(); + { + std::unique_ptr<SfxPoolItem> pItem1; + std::unique_ptr<SfxPoolItem> pItem2; + pView1->GetViewFrame()->GetBindings().QueryState(SID_DOC_REPAIR, pItem1); + pView2->GetViewFrame()->GetBindings().QueryState(SID_DOC_REPAIR, pItem2); + CPPUNIT_ASSERT(dynamic_cast< const SfxBoolItem* >(pItem1.get())); + CPPUNIT_ASSERT(dynamic_cast< const SfxBoolItem* >(pItem2.get())); + CPPUNIT_ASSERT_EQUAL(true, dynamic_cast< const SfxBoolItem* >(pItem1.get())->GetValue()); + CPPUNIT_ASSERT_EQUAL(true, dynamic_cast< const SfxBoolItem* >(pItem2.get())->GetValue()); + } + + comphelper::LibreOfficeKit::setActive(false); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SwTiledRenderingTest); diff --git a/sw/source/core/inc/UndoManager.hxx b/sw/source/core/inc/UndoManager.hxx index ede9604059ad..d5db9f69bc5e 100644 --- a/sw/source/core/inc/UndoManager.hxx +++ b/sw/source/core/inc/UndoManager.hxx @@ -94,6 +94,9 @@ public: SwNodes & GetUndoNodes(); void SetDocShell(SwDocShell* pDocShell); +protected: + virtual void EmptyActionsChanged() override; + private: IDocumentDrawModelAccess & m_rDrawModelAccess; IDocumentRedlineAccess & m_rRedlineAccess; diff --git a/sw/source/core/undo/docundo.cxx b/sw/source/core/undo/docundo.cxx index 4d117dac50ae..cecf40c180ee 100644 --- a/sw/source/core/undo/docundo.cxx +++ b/sw/source/core/undo/docundo.cxx @@ -629,6 +629,14 @@ bool UndoManager::Redo() } } +void UndoManager::EmptyActionsChanged() +{ + if (m_pDocShell) + { + m_pDocShell->Broadcast(SfxHint(SFX_HINT_DOCREPAIR)); + } +} + /** N.B.: this does _not_ call SdrUndoManager::Repeat because it is not possible to wrap a list action around it: calling EnterListAction here will cause SdrUndoManager::Repeat |