summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorHenry Castro <hcastro@collabora.com>2017-06-17 13:52:15 -0400
committerJan Holesovsky <kendy@collabora.com>2018-01-18 13:34:53 +0100
commite3c1713807499fdbe63fad0944d0ce3b91b28637 (patch)
tree011c8706d89611714b8583c8acc7221cc26f17a1 /sd
parentba5556e62ed3fda9f02aaf7d3ba23c19af7dbdfc (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 'sd')
-rw-r--r--sd/qa/unit/tiledrendering/tiledrendering.cxx51
-rw-r--r--sd/source/ui/docshell/docshell.cxx6
2 files changed, 56 insertions, 1 deletions
diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx
index 03d756e5a260..8d624dc70c48 100644
--- a/sd/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx
@@ -98,6 +98,7 @@ public:
void testCommentCallbacks();
void testMultiViewInsertDeletePage();
void testDisableUndoRepair();
+ void testDocumentRepair();
void testLanguageStatus();
void testDefaultView();
@@ -137,6 +138,7 @@ public:
CPPUNIT_TEST(testCommentCallbacks);
CPPUNIT_TEST(testMultiViewInsertDeletePage);
CPPUNIT_TEST(testDisableUndoRepair);
+ CPPUNIT_TEST(testDocumentRepair);
CPPUNIT_TEST(testLanguageStatus);
CPPUNIT_TEST(testDefaultView);
@@ -1825,6 +1827,55 @@ void SdTiledRenderingTest::testDisableUndoRepair()
comphelper::LibreOfficeKit::setActive(false);
}
+void SdTiledRenderingTest::testDocumentRepair()
+{
+ comphelper::LibreOfficeKit::setActive();
+
+ // Create two views.
+ SdXImpressDocument* pXImpressDocument = createDoc("dummy.odp");
+ CPPUNIT_ASSERT(pXImpressDocument);
+
+ // 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);
+ pXImpressDocument->setPart(1);
+ pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::TAB);
+ pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::TAB);
+ pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'c', 0);
+ pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'c', 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);
+}
+
void SdTiledRenderingTest::testLanguageStatus()
{
// Load the document.
diff --git a/sd/source/ui/docshell/docshell.cxx b/sd/source/ui/docshell/docshell.cxx
index 0ec666309be0..eebff1427171 100644
--- a/sd/source/ui/docshell/docshell.cxx
+++ b/sd/source/ui/docshell/docshell.cxx
@@ -113,7 +113,11 @@ void DrawDocShell::Construct( bool bClipboard )
SetBaseModel( new SdXImpressDocument( this, bClipboard ) );
SetPool( &mpDoc->GetItemPool() );
- mpUndoManager = new sd::UndoManager;
+
+ sd::UndoManager* pUndoManager = new sd::UndoManager;
+ pUndoManager->SetDocShell(this);
+ mpUndoManager = pUndoManager;
+
mpDoc->SetSdrUndoManager( mpUndoManager );
mpDoc->SetSdrUndoFactory( new sd::UndoFactory );
UpdateTablePointers();