[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.3' - sfx2/source sw/qa
Henry Castro
hcastro at collabora.com
Mon May 29 15:41:58 UTC 2017
sfx2/source/control/unoctitm.cxx | 21 +++++-
sw/qa/extras/tiledrendering/tiledrendering.cxx | 78 +++++++++++++++++++++++++
2 files changed, 94 insertions(+), 5 deletions(-)
New commits:
commit 3ad60c39a266b54a0dd94ac8bd15a88d64c9dd5f
Author: Henry Castro <hcastro at collabora.com>
Date: Thu May 25 21:07:25 2017 -0400
sw lok: disable undo state if conflict with other views
Change-Id: I5497c9b1f236bc803529825ba8b423d55fffa93e
Reviewed-on: https://gerrit.libreoffice.org/38049
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Henry Castro <hcastro at collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/38108
Reviewed-by: Jan Holesovsky <kendy at collabora.com>
Tested-by: Jan Holesovsky <kendy at collabora.com>
diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx
index af13d3d33698..68a1cff0dd83 100644
--- a/sfx2/source/control/unoctitm.cxx
+++ b/sfx2/source/control/unoctitm.cxx
@@ -111,7 +111,7 @@ const char* URLTypeNames[URLType_COUNT] =
"double"
};
-static void InterceptLOKStateChangeEvent(const SfxViewFrame* pViewFrame, const css::frame::FeatureStateEvent& aEvent);
+static void InterceptLOKStateChangeEvent( const SfxViewFrame* pViewFrame, const css::frame::FeatureStateEvent& aEvent, const SfxPoolItem* pState );
void SfxStatusDispatcher::ReleaseAll()
{
@@ -954,7 +954,7 @@ void SfxDispatchController_Impl::StateChanged( sal_uInt16 nSID, SfxItemState eSt
if (pDispatcher && pDispatcher->GetFrame())
{
- InterceptLOKStateChangeEvent(pDispatcher->GetFrame(), aEvent);
+ InterceptLOKStateChangeEvent(pDispatcher->GetFrame(), aEvent, pState);
}
Sequence< OUString > seqNames = pDispatch->GetListeners().getContainedTypes();
@@ -972,7 +972,7 @@ void SfxDispatchController_Impl::StateChanged( sal_uInt16 nSID, SfxItemState eSt
StateChanged( nSID, eState, pState, nullptr );
}
-static void InterceptLOKStateChangeEvent(const SfxViewFrame* pViewFrame, const css::frame::FeatureStateEvent& aEvent)
+static void InterceptLOKStateChangeEvent(const SfxViewFrame* pViewFrame, const css::frame::FeatureStateEvent& aEvent, const SfxPoolItem* pState)
{
if (!comphelper::LibreOfficeKit::isActive())
return;
@@ -1039,8 +1039,19 @@ static void InterceptLOKStateChangeEvent(const SfxViewFrame* pViewFrame, const c
aBuffer.append(nColor);
}
else if (aEvent.FeatureURL.Path == "Undo" ||
- aEvent.FeatureURL.Path == "Redo" ||
- aEvent.FeatureURL.Path == "Cut" ||
+ aEvent.FeatureURL.Path == "Redo")
+ {
+ const SfxUInt32Item* pUndoConflict = dynamic_cast< const SfxUInt32Item * >( pState );
+ if ( pUndoConflict && pUndoConflict->GetValue() > 0 )
+ {
+ aBuffer.append(OUString("disabled"));
+ }
+ else
+ {
+ aBuffer.append(aEvent.IsEnabled ? OUString("enabled") : OUString("disabled"));
+ }
+ }
+ else if (aEvent.FeatureURL.Path == "Cut" ||
aEvent.FeatureURL.Path == "Copy" ||
aEvent.FeatureURL.Path == "Paste" ||
aEvent.FeatureURL.Path == "SelectAll" ||
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index f12d53f26fee..f915955df2b8 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -83,6 +83,7 @@ public:
void testPaintCallbacks();
void testUndoRepairResult();
void testRedoRepairResult();
+ void testDisableUndoRepair();
CPPUNIT_TEST_SUITE(SwTiledRenderingTest);
@@ -128,6 +129,7 @@ public:
CPPUNIT_TEST(testPaintCallbacks);
CPPUNIT_TEST(testUndoRepairResult);
CPPUNIT_TEST(testRedoRepairResult);
+ CPPUNIT_TEST(testDisableUndoRepair);
CPPUNIT_TEST_SUITE_END();
@@ -1720,6 +1722,82 @@ void SwTiledRenderingTest::testRedoRepairResult()
comphelper::LibreOfficeKit::setActive(false);
}
+void SwTiledRenderingTest::testDisableUndoRepair()
+{
+ comphelper::LibreOfficeKit::setActive();
+
+ // Create two views.
+ SwXTextDocument* pXTextDocument = createDoc("dummy.fodt");
+ ViewCallback aView1;
+ SwView* pView1 = dynamic_cast<SwView*>(SfxViewShell::Current());
+ int nView1 = SfxLokHelper::getView();
+ SfxLokHelper::createView();
+ ViewCallback aView2;
+ SwView* pView2 = dynamic_cast<SwView*>(SfxViewShell::Current());
+ int nView2 = SfxLokHelper::getView();
+
+ {
+ SfxItemSet aItemSet1(pXTextDocument->GetDocShell()->GetDoc()->GetAttrPool(), SID_UNDO, SID_UNDO);
+ SfxItemSet aItemSet2(pXTextDocument->GetDocShell()->GetDoc()->GetAttrPool(), SID_UNDO, SID_UNDO);
+ pView1->GetState(aItemSet1);
+ CPPUNIT_ASSERT(SfxItemState::DISABLED == aItemSet1.GetItemState(SID_UNDO));
+ pView2->GetState(aItemSet2);
+ CPPUNIT_ASSERT(SfxItemState::DISABLED == aItemSet2.GetItemState(SID_UNDO));
+ }
+
+ auto fnCheckStates = [pXTextDocument, pView1, pView2]()
+ {
+ SfxItemSet aItemSet1(pXTextDocument->GetDocShell()->GetDoc()->GetAttrPool(), SID_UNDO, SID_UNDO);
+ SfxItemSet aItemSet2(pXTextDocument->GetDocShell()->GetDoc()->GetAttrPool(), SID_UNDO, SID_UNDO);
+ // first view, undo enabled
+ pView1->GetState(aItemSet1);
+ CPPUNIT_ASSERT(SfxItemState::SET == aItemSet1.GetItemState(SID_UNDO));
+ CPPUNIT_ASSERT(!dynamic_cast< const SfxUInt32Item * >(aItemSet1.GetItem(SID_UNDO)));
+ // second view, undo conflict
+ pView2->GetState(aItemSet2);
+ CPPUNIT_ASSERT(SfxItemState::SET == aItemSet2.GetItemState(SID_UNDO));
+ CPPUNIT_ASSERT(dynamic_cast< const SfxUInt32Item * >(aItemSet2.GetItem(SID_UNDO)));
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt32>(UNDO_CONFLICT), dynamic_cast< const SfxUInt32Item * >(aItemSet2.GetItem(SID_UNDO))->GetValue());
+ };
+
+ // Insert a character in the first view.
+ SfxLokHelper::setView(nView1);
+ pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'k', 0);
+ pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'k', 0);
+ Scheduler::ProcessEventsToIdle();
+ fnCheckStates();
+
+ // 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();
+ {
+ SfxItemSet aItemSet1(pXTextDocument->GetDocShell()->GetDoc()->GetAttrPool(), SID_UNDO, SID_UNDO);
+ SfxItemSet aItemSet2(pXTextDocument->GetDocShell()->GetDoc()->GetAttrPool(), SID_UNDO, SID_UNDO);
+ // second view, undo enabled
+ pView2->GetState(aItemSet2);
+ CPPUNIT_ASSERT(SfxItemState::SET == aItemSet2.GetItemState(SID_UNDO));
+ CPPUNIT_ASSERT(!dynamic_cast< const SfxUInt32Item * >(aItemSet2.GetItem(SID_UNDO)));
+ // first view, undo conflict
+ pView1->GetState(aItemSet1);
+ CPPUNIT_ASSERT(SfxItemState::SET == aItemSet1.GetItemState(SID_UNDO));
+ CPPUNIT_ASSERT(dynamic_cast< const SfxUInt32Item * >(aItemSet1.GetItem(SID_UNDO)));
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt32>(UNDO_CONFLICT), dynamic_cast< const SfxUInt32Item * >(aItemSet1.GetItem(SID_UNDO))->GetValue());
+ }
+
+ // Insert a character in the first view.
+ SfxLokHelper::setView(nView1);
+ pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'l', 0);
+ pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'l', 0);
+ Scheduler::ProcessEventsToIdle();
+ fnCheckStates();
+
+ mxComponent->dispose();
+ mxComponent.clear();
+ comphelper::LibreOfficeKit::setActive(false);
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SwTiledRenderingTest);
CPPUNIT_PLUGIN_IMPLEMENT();
More information about the Libreoffice-commits
mailing list