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 /sc | |
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 'sc')
-rw-r--r-- | sc/qa/unit/tiledrendering/tiledrendering.cxx | 51 | ||||
-rw-r--r-- | sc/source/core/data/document.cxx | 5 |
2 files changed, 54 insertions, 2 deletions
diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx index 53d96494ad75..f8357435f0e3 100644 --- a/sc/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx @@ -78,6 +78,7 @@ public: void testInsertGraphicInvalidations(); void testDocumentSizeWithTwoViews(); void testDisableUndoRepair(); + void testDocumentRepair(); void testLanguageStatus(); void testMultiViewCopyPaste(); @@ -107,6 +108,7 @@ public: CPPUNIT_TEST(testInsertGraphicInvalidations); CPPUNIT_TEST(testDocumentSizeWithTwoViews); CPPUNIT_TEST(testDisableUndoRepair); + CPPUNIT_TEST(testDocumentRepair); CPPUNIT_TEST(testLanguageStatus); CPPUNIT_TEST(testMultiViewCopyPaste); CPPUNIT_TEST_SUITE_END(); @@ -1420,6 +1422,55 @@ void ScTiledRenderingTest::testDisableUndoRepair() comphelper::LibreOfficeKit::setActive(false); } +void ScTiledRenderingTest::testDocumentRepair() +{ + comphelper::LibreOfficeKit::setActive(); + + // Create two views. + ScModelObj* pModelObj = createDoc("cursor-away.ods"); + CPPUNIT_ASSERT(pModelObj); + + // 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); + pModelObj->setPart(1); + pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'c', 0); + pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 'c', 0); + pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::RETURN); + pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::RETURN); + 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); +} + void ScTiledRenderingTest::testLanguageStatus() { comphelper::LibreOfficeKit::setActive(); diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx index 4c5084f8d752..2b4bf337f40b 100644 --- a/sc/source/core/data/document.cxx +++ b/sc/source/core/data/document.cxx @@ -6256,8 +6256,9 @@ SfxUndoManager* ScDocument::GetUndoManager() { if (!mpUndoManager) { - // to support enhanced text edit for draw objects, use an SdrUndoManager - mpUndoManager = new SdrUndoManager; + SdrUndoManager* pUndoManager = new SdrUndoManager; + pUndoManager->SetDocShell(GetDocumentShell()); + mpUndoManager = pUndoManager; } return mpUndoManager; |