[Libreoffice-commits] core.git: sfx2/source sw/qa
Henry Castro
hcastro at collabora.com
Sat May 27 04:21:15 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 0582bd49b385ebcebf93fe87d0161ed4846c8805
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>
diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx
index 30399c2c3cbe..3294bc0e9913 100644
--- a/sfx2/source/control/unoctitm.cxx
+++ b/sfx2/source/control/unoctitm.cxx
@@ -113,7 +113,7 @@ const char* const 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()
{
@@ -964,7 +964,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();
@@ -982,7 +982,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;
@@ -1048,8 +1048,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 cd67c8b28fcb..d876736f8076 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -89,6 +89,7 @@ public:
void testPaintCallbacks();
void testUndoRepairResult();
void testRedoRepairResult();
+ void testDisableUndoRepair();
CPPUNIT_TEST_SUITE(SwTiledRenderingTest);
@@ -134,6 +135,7 @@ public:
CPPUNIT_TEST(testPaintCallbacks);
CPPUNIT_TEST(testUndoRepairResult);
CPPUNIT_TEST(testRedoRepairResult);
+ CPPUNIT_TEST(testDisableUndoRepair);
CPPUNIT_TEST_SUITE_END();
@@ -1724,6 +1726,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_EQUAL(SfxItemState::DISABLED, aItemSet1.GetItemState(SID_UNDO));
+ pView2->GetState(aItemSet2);
+ CPPUNIT_ASSERT_EQUAL(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_EQUAL(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_EQUAL(SfxItemState::SET, aItemSet2.GetItemState(SID_UNDO));
+ CPPUNIT_ASSERT(dynamic_cast< const SfxUInt32Item * >(aItemSet2.GetItem(SID_UNDO)));
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt32>(SwUndoId::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_EQUAL(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_EQUAL(SfxItemState::SET, aItemSet1.GetItemState(SID_UNDO));
+ CPPUNIT_ASSERT(dynamic_cast< const SfxUInt32Item * >(aItemSet1.GetItem(SID_UNDO)));
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt32>(SwUndoId::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