summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorHenry Castro <hcastro@collabora.com>2017-06-28 10:26:21 -0400
committerJan Holesovsky <kendy@collabora.com>2017-07-26 18:30:56 +0200
commit61396c713fcce8b4c6d6fd159753c58b53a55449 (patch)
tree25ada288cf9419987cae6355428279e0840c004b /sc
parent0892238c635009a7b078a0778dbd6138e06e0ac0 (diff)
sc lok: disable Undo/Redo state if conflict with other views
Change-Id: I5bc5be2b17925ec3a203f9704f62a8c80ac5fc9d Reviewed-on: https://gerrit.libreoffice.org/39363 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Henry Castro <hcastro@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/39402 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.cxx66
-rw-r--r--sc/source/ui/view/tabvwshb.cxx3
2 files changed, 69 insertions, 0 deletions
diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index fd318fe37a1e..8eaf06f7483d 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -76,6 +76,7 @@ public:
void testUndoRepairDispatch();
void testInsertGraphicInvalidations();
void testDocumentSizeWithTwoViews();
+ void testDisableUndoRepair();
CPPUNIT_TEST_SUITE(ScTiledRenderingTest);
CPPUNIT_TEST(testRowColumnSelections);
@@ -102,6 +103,7 @@ public:
CPPUNIT_TEST(testUndoRepairDispatch);
CPPUNIT_TEST(testInsertGraphicInvalidations);
CPPUNIT_TEST(testDocumentSizeWithTwoViews);
+ CPPUNIT_TEST(testDisableUndoRepair);
CPPUNIT_TEST_SUITE_END();
private:
@@ -1350,6 +1352,70 @@ void ScTiledRenderingTest::testDocumentSizeWithTwoViews()
comphelper::LibreOfficeKit::setActive(false);
}
+void ScTiledRenderingTest::testDisableUndoRepair()
+{
+ comphelper::LibreOfficeKit::setActive();
+ ScModelObj* pModelObj = createDoc("cursor-away.ods");
+ CPPUNIT_ASSERT(pModelObj);
+
+ // view #1
+ int nView1 = SfxLokHelper::getView();
+ SfxViewShell* pView1 = SfxViewShell::Current();
+
+ // view #2
+ SfxLokHelper::createView();
+ int nView2 = SfxLokHelper::getView();
+ SfxViewShell* pView2 = SfxViewShell::Current();
+ CPPUNIT_ASSERT(pView1 != pView2);
+ {
+ SfxItemSet aSet1(pView1->GetPool(), SID_UNDO, SID_UNDO);
+ SfxItemSet aSet2(pView2->GetPool(), SID_UNDO, SID_UNDO);
+ pView1->GetSlotState(SID_UNDO, nullptr, &aSet1);
+ pView2->GetSlotState(SID_UNDO, nullptr, &aSet2);
+ CPPUNIT_ASSERT(SfxItemState::DISABLED == aSet1.GetItemState(SID_UNDO));
+ CPPUNIT_ASSERT(SfxItemState::DISABLED == aSet2.GetItemState(SID_UNDO));
+ }
+
+ // text edit a cell in view #1
+ SfxLokHelper::setView(nView1);
+ pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'h', 0);
+ pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 'h', 0);
+ pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::RETURN);
+ pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::RETURN);
+ Scheduler::ProcessEventsToIdle();
+ {
+ SfxItemSet aSet1(pView1->GetPool(), SID_UNDO, SID_UNDO);
+ SfxItemSet aSet2(pView2->GetPool(), SID_UNDO, SID_UNDO);
+ pView1->GetSlotState(SID_UNDO, nullptr, &aSet1);
+ pView2->GetSlotState(SID_UNDO, nullptr, &aSet2);
+ CPPUNIT_ASSERT(SfxItemState::SET == aSet1.GetItemState(SID_UNDO));
+ CPPUNIT_ASSERT(dynamic_cast< const SfxStringItem* >(aSet1.GetItem(SID_UNDO)));
+ CPPUNIT_ASSERT(SfxItemState::SET == aSet2.GetItemState(SID_UNDO));
+ CPPUNIT_ASSERT(dynamic_cast< const SfxUInt32Item* >(aSet2.GetItem(SID_UNDO)));
+ CPPUNIT_ASSERT_EQUAL(static_cast< sal_uInt32 >(SID_REPAIRPACKAGE), dynamic_cast< const SfxUInt32Item* >(aSet2.GetItem(SID_UNDO))->GetValue());
+ }
+
+ // text edit a cell in view #2
+ 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();
+ {
+ SfxItemSet aSet1(pView1->GetPool(), SID_UNDO, SID_UNDO);
+ SfxItemSet aSet2(pView2->GetPool(), SID_UNDO, SID_UNDO);
+ pView1->GetSlotState(SID_UNDO, nullptr, &aSet1);
+ pView2->GetSlotState(SID_UNDO, nullptr, &aSet2);
+ CPPUNIT_ASSERT(SfxItemState::SET == aSet1.GetItemState(SID_UNDO));
+ CPPUNIT_ASSERT(dynamic_cast< const SfxUInt32Item* >(aSet1.GetItem(SID_UNDO)));
+ CPPUNIT_ASSERT_EQUAL(static_cast< sal_uInt32 >(SID_REPAIRPACKAGE), dynamic_cast< const SfxUInt32Item* >(aSet1.GetItem(SID_UNDO))->GetValue());
+ CPPUNIT_ASSERT(SfxItemState::SET == aSet2.GetItemState(SID_UNDO));
+ CPPUNIT_ASSERT(dynamic_cast< const SfxStringItem* >(aSet2.GetItem(SID_UNDO)));
+ }
+}
+
}
CPPUNIT_TEST_SUITE_REGISTRATION(ScTiledRenderingTest);
diff --git a/sc/source/ui/view/tabvwshb.cxx b/sc/source/ui/view/tabvwshb.cxx
index bfe407aca2e1..74f76894e2ea 100644
--- a/sc/source/ui/view/tabvwshb.cxx
+++ b/sc/source/ui/view/tabvwshb.cxx
@@ -520,7 +520,10 @@ void ScTabViewShell::ExecuteUndo(SfxRequest& rReq)
{
sal_Int32 nViewShellId = GetViewShellId();
if (pAction->GetViewShellId() != nViewShellId)
+ {
+ rReq.SetReturnValue(SfxUInt32Item(SID_UNDO, static_cast<sal_uInt32>(SID_REPAIRPACKAGE)));
return;
+ }
}
}