[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.1' - desktop/source sw/inc sw/qa sw/source
Henry Castro
hcastro at collabora.com
Mon Nov 28 03:42:32 UTC 2016
desktop/source/lib/init.cxx | 8 +-
sw/inc/editsh.hxx | 1
sw/inc/swundo.hxx | 3
sw/qa/extras/tiledrendering/tiledrendering.cxx | 99 +++++++++++++++++++++++++
sw/source/core/edit/edws.cxx | 3
sw/source/core/undo/docundo.cxx | 12 +++
sw/source/uibase/shells/annotsh.cxx | 30 ++++++-
sw/source/uibase/shells/basesh.cxx | 50 +++++++++---
sw/source/uibase/wrtsh/wrtundo.cxx | 2
9 files changed, 186 insertions(+), 22 deletions(-)
New commits:
commit 6161b19ac5e521668e698bc22e34fce169f98d2b
Author: Henry Castro <hcastro at collabora.com>
Date: Thu Nov 24 07:09:38 2016 -0400
sw lok: notify repair when exist a conflict of multiple users undo/redo
Change-Id: I026f4df6239fa87ee191f92127f9fa98ac2993eb
Reviewed-on: https://gerrit.libreoffice.org/31161
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Henry Castro <hcastro at collabora.com>
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 3e91af8..ea266b1 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -323,6 +323,11 @@ static boost::property_tree::ptree unoAnyToPropertyTree(const uno::Any& anyItem)
if (aType == "string")
aTree.put("value", anyItem.get<OUString>().toUtf8().getStr());
+ else if (aType == "unsigned long")
+ aTree.put("value", OString::number(anyItem.get<sal_uInt32>()).getStr());
+ else if (aType == "long")
+ aTree.put("value", OString::number(anyItem.get<sal_Int32>()).getStr());
+
// TODO: Add more as required
return aTree;
@@ -1812,8 +1817,7 @@ public:
aTree.put("success", bSuccess);
}
- // TODO UNO Any rEvent.Result -> JSON
- // aTree.put("result": "...");
+ aTree.add_child("result", unoAnyToPropertyTree(rEvent.Result));
std::stringstream aStream;
boost::property_tree::write_json(aStream, aTree);
diff --git a/sw/inc/editsh.hxx b/sw/inc/editsh.hxx
index e0ab5c7..987c5c0 100644
--- a/sw/inc/editsh.hxx
+++ b/sw/inc/editsh.hxx
@@ -565,6 +565,7 @@ public:
SwUndoId *const o_pId,
const SwView* pView = nullptr) const;
bool GetFirstRedoInfo(OUString *const o_pStr,
+ SwUndoId *const o_pId,
const SwView* pView = nullptr) const;
SwUndoId GetRepeatInfo(OUString *const o_pStr) const;
diff --git a/sw/inc/swundo.hxx b/sw/inc/swundo.hxx
index 5c5f197..ef5e15f 100644
--- a/sw/inc/swundo.hxx
+++ b/sw/inc/swundo.hxx
@@ -168,7 +168,8 @@ enum SwUndoId
UNDO_UI_REPLACE_STYLE,
UNDO_UI_DELETE_PAGE_BREAK,
UNDO_UI_TEXT_CORRECTION,
- UNDO_UI_TABLE_DELETE
+ UNDO_UI_TABLE_DELETE,
+ UNDO_CONFLICT
};
#endif
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index b787352..ecd32c3 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -10,6 +10,7 @@
#include <string>
#include <boost/property_tree/json_parser.hpp>
+#include <com/sun/star/frame/DispatchResultState.hpp>
#include <swmodeltestbase.hxx>
#include <LibreOfficeKit/LibreOfficeKitEnums.h>
#include <comphelper/dispatchcommand.hxx>
@@ -79,6 +80,9 @@ public:
void testCommentEndTextEdit();
void testCursorPosition();
void testPaintCallbacks();
+ void testUndoRepairResult();
+ void testRedoRepairResult();
+
CPPUNIT_TEST_SUITE(SwTiledRenderingTest);
CPPUNIT_TEST(testRegisterCallback);
@@ -121,6 +125,9 @@ public:
CPPUNIT_TEST(testCommentEndTextEdit);
CPPUNIT_TEST(testCursorPosition);
CPPUNIT_TEST(testPaintCallbacks);
+ CPPUNIT_TEST(testUndoRepairResult);
+ CPPUNIT_TEST(testRedoRepairResult);
+
CPPUNIT_TEST_SUITE_END();
private:
@@ -755,6 +762,30 @@ public:
}
};
+class TestResultListener : public cppu::WeakImplHelper<css::frame::XDispatchResultListener>
+{
+public:
+ sal_uInt32 m_nDocRepair;
+
+ TestResultListener() : m_nDocRepair(0)
+ {
+ }
+
+ virtual void SAL_CALL dispatchFinished(const css::frame::DispatchResultEvent& rEvent)
+ throw(css::uno::RuntimeException, std::exception) override
+ {
+ if (rEvent.State == frame::DispatchResultState::SUCCESS)
+ {
+ rEvent.Result >>= m_nDocRepair;
+ }
+ }
+
+ virtual void SAL_CALL disposing(const css::lang::EventObject&)
+ throw (css::uno::RuntimeException, std::exception) override
+ {
+ }
+};
+
void SwTiledRenderingTest::testMissingInvalidation()
{
comphelper::LibreOfficeKit::setActive();
@@ -1580,6 +1611,74 @@ void SwTiledRenderingTest::testPaintCallbacks()
comphelper::LibreOfficeKit::setActive(false);
}
+void SwTiledRenderingTest::testUndoRepairResult()
+{
+ // Load a document and create two views.
+ comphelper::LibreOfficeKit::setActive();
+ SwXTextDocument* pXTextDocument = createDoc("dummy.fodt");
+ int nView1 = SfxLokHelper::getView();
+ SfxLokHelper::createView();
+ TestResultListener* pResult2 = new TestResultListener();
+ css::uno::Reference< css::frame::XDispatchResultListener > xListener(static_cast< css::frame::XDispatchResultListener* >(pResult2), css::uno::UNO_QUERY);
+ pXTextDocument->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>());
+ int nView2 = SfxLokHelper::getView();
+
+ // Insert a character in the second view.
+ SfxLokHelper::setView(nView2);
+ pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'b', 0);
+ pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'b', 0);
+
+ // Insert a character in the first view.
+ SfxLokHelper::setView(nView1);
+ pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'a', 0);
+ pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'a', 0);
+
+ // Assert that by default the second view can't undo the action.
+ SfxLokHelper::setView(nView2);
+ comphelper::dispatchCommand(".uno:Undo", {}, xListener);
+ Scheduler::ProcessEventsToIdle();
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt32>(UNDO_CONFLICT), pResult2->m_nDocRepair);
+
+ mxComponent->dispose();
+ mxComponent.clear();
+ comphelper::LibreOfficeKit::setActive(false);
+}
+
+void SwTiledRenderingTest::testRedoRepairResult()
+{
+ // Load a document and create two views.
+ comphelper::LibreOfficeKit::setActive();
+ SwXTextDocument* pXTextDocument = createDoc("dummy.fodt");
+ int nView1 = SfxLokHelper::getView();
+ SfxLokHelper::createView();
+ TestResultListener* pResult2 = new TestResultListener();
+ css::uno::Reference< css::frame::XDispatchResultListener > xListener(static_cast< css::frame::XDispatchResultListener* >(pResult2), css::uno::UNO_QUERY);
+ pXTextDocument->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>());
+ int nView2 = SfxLokHelper::getView();
+
+ // Insert a character in the second view.
+ SfxLokHelper::setView(nView2);
+ pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'b', 0);
+ pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'b', 0);
+
+ // Insert a character in the first view.
+ SfxLokHelper::setView(nView1);
+ pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'a', 0);
+ pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'a', 0);
+ comphelper::dispatchCommand(".uno:Undo", {}, xListener);
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt32>(0), pResult2->m_nDocRepair);
+
+ // Assert that by default the second view can't redo the action.
+ SfxLokHelper::setView(nView2);
+ comphelper::dispatchCommand(".uno:Redo", {}, xListener);
+ Scheduler::ProcessEventsToIdle();
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt32>(UNDO_CONFLICT), pResult2->m_nDocRepair);
+
+ mxComponent->dispose();
+ mxComponent.clear();
+ comphelper::LibreOfficeKit::setActive(false);
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SwTiledRenderingTest);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/core/edit/edws.cxx b/sw/source/core/edit/edws.cxx
index 6ef43e1..dc3af50 100644
--- a/sw/source/core/edit/edws.cxx
+++ b/sw/source/core/edit/edws.cxx
@@ -231,9 +231,10 @@ bool SwEditShell::GetLastUndoInfo(OUString *const o_pStr,
}
bool SwEditShell::GetFirstRedoInfo(OUString *const o_pStr,
+ SwUndoId *const o_pId,
const SwView* pView) const
{
- return GetDoc()->GetIDocumentUndoRedo().GetFirstRedoInfo(o_pStr, nullptr, pView);
+ return GetDoc()->GetIDocumentUndoRedo().GetFirstRedoInfo(o_pStr, o_pId, pView);
}
SwUndoId SwEditShell::GetRepeatInfo(OUString *const o_pStr) const
diff --git a/sw/source/core/undo/docundo.cxx b/sw/source/core/undo/docundo.cxx
index 18669a5..dcae067 100644
--- a/sw/source/core/undo/docundo.cxx
+++ b/sw/source/core/undo/docundo.cxx
@@ -374,7 +374,13 @@ UndoManager::GetLastUndoInfo(
// If an other view created the undo action, prevent undoing it from this view.
sal_Int32 nViewShellId = pView ? pView->GetViewShellId() : m_pDocShell->GetView()->GetViewShellId();
if (pAction->GetViewShellId() != nViewShellId)
+ {
+ if (o_pId)
+ {
+ *o_pId = UNDO_CONFLICT;
+ }
return false;
+ }
}
if (o_pStr)
@@ -427,7 +433,13 @@ bool UndoManager::GetFirstRedoInfo(OUString *const o_pStr,
// If an other view created the undo action, prevent redoing it from this view.
sal_Int32 nViewShellId = pView ? pView->GetViewShellId() : m_pDocShell->GetView()->GetViewShellId();
if (pAction->GetViewShellId() != nViewShellId)
+ {
+ if (o_pId)
+ {
+ *o_pId = UNDO_CONFLICT;
+ }
return false;
+ }
}
if (o_pStr)
diff --git a/sw/source/uibase/shells/annotsh.cxx b/sw/source/uibase/shells/annotsh.cxx
index 7dbfa4db..c7b80e6 100644
--- a/sw/source/uibase/shells/annotsh.cxx
+++ b/sw/source/uibase/shells/annotsh.cxx
@@ -1472,6 +1472,7 @@ void SwAnnotationShell::ExecUndo(SfxRequest &rReq)
const SfxItemSet* pArgs = rReq.GetArgs();
::svl::IUndoManager* pUndoManager = GetUndoManager();
SwWrtShell &rSh = rView.GetWrtShell();
+ SwUndoId nUndoId(UNDO_EMPTY);
long aOldHeight = rView.GetPostItMgr()->HasActiveSidebarWin()
? rView.GetPostItMgr()->GetActiveSidebarWin()->GetPostItTextHeight()
@@ -1486,6 +1487,13 @@ void SwAnnotationShell::ExecUndo(SfxRequest &rReq)
{
case SID_UNDO:
{
+ rSh.GetLastUndoInfo(nullptr, &nUndoId);
+ if (nUndoId == UNDO_CONFLICT)
+ {
+ rReq.SetReturnValue( SfxUInt32Item(nId, static_cast<sal_uInt32>(nUndoId)) );
+ break;
+ }
+
if ( pUndoManager )
{
sal_uInt16 nCount = pUndoManager->GetUndoActionCount();
@@ -1510,6 +1518,13 @@ void SwAnnotationShell::ExecUndo(SfxRequest &rReq)
case SID_REDO:
{
+ rSh.GetFirstRedoInfo(nullptr, &nUndoId);
+ if (nUndoId == UNDO_CONFLICT)
+ {
+ rReq.SetReturnValue( SfxUInt32Item(nId, static_cast<sal_uInt32>(nUndoId)) );
+ break;
+ }
+
if ( pUndoManager )
{
sal_uInt16 nCount = pUndoManager->GetRedoActionCount();
@@ -1546,6 +1561,7 @@ void SwAnnotationShell::StateUndo(SfxItemSet &rSet)
return;
SfxWhichIter aIter(rSet);
+ SwUndoId nUndoId(UNDO_EMPTY);
sal_uInt16 nWhich = aIter.FirstWhich();
::svl::IUndoManager* pUndoManager = GetUndoManager();
SfxViewFrame *pSfxViewFrame = rView.GetViewFrame();
@@ -1560,10 +1576,14 @@ void SwAnnotationShell::StateUndo(SfxItemSet &rSet)
sal_uInt16 nCount = pUndoManager ? pUndoManager->GetUndoActionCount() : 0;
if ( nCount )
pSfxViewFrame->GetSlotState( nWhich, pSfxViewFrame->GetInterface(), &rSet );
- else if (rSh.GetLastUndoInfo(nullptr, nullptr))
+ else if (rSh.GetLastUndoInfo(nullptr, &nUndoId))
{
rSet.Put( SfxStringItem( nWhich, rSh.GetDoString(SwWrtShell::UNDO)) );
}
+ else if (nUndoId == UNDO_CONFLICT)
+ {
+ rSet.Put( SfxUInt32Item(nWhich, static_cast<sal_uInt32>(nUndoId)) );
+ }
else
rSet.DisableItem(nWhich);
break;
@@ -1573,10 +1593,14 @@ void SwAnnotationShell::StateUndo(SfxItemSet &rSet)
sal_uInt16 nCount = pUndoManager ? pUndoManager->GetRedoActionCount() : 0;
if ( nCount )
pSfxViewFrame->GetSlotState( nWhich, pSfxViewFrame->GetInterface(), &rSet );
- else if (rSh.GetFirstRedoInfo(nullptr))
+ else if (rSh.GetFirstRedoInfo(nullptr, &nUndoId))
{
rSet.Put(SfxStringItem( nWhich, rSh.GetDoString(SwWrtShell::REDO)) );
}
+ else if (nUndoId == UNDO_CONFLICT)
+ {
+ rSet.Put( SfxUInt32Item(nWhich, static_cast<sal_uInt32>(nUndoId)) );
+ }
else
rSet.DisableItem(nWhich);
break;
@@ -1614,7 +1638,7 @@ void SwAnnotationShell::StateUndo(SfxItemSet &rSet)
rSh.GetDoStrings( SwWrtShell::UNDO, aItem );
}
else if ((nWhich == SID_GETREDOSTRINGS) &&
- (rSh.GetFirstRedoInfo(nullptr)))
+ (rSh.GetFirstRedoInfo(nullptr, nullptr)))
{
rSh.GetDoStrings( SwWrtShell::UNDO, aItem );
}
diff --git a/sw/source/uibase/shells/basesh.cxx b/sw/source/uibase/shells/basesh.cxx
index 8400b0b..254ed38 100644
--- a/sw/source/uibase/shells/basesh.cxx
+++ b/sw/source/uibase/shells/basesh.cxx
@@ -477,6 +477,7 @@ void SwBaseShell::ExecUndo(SfxRequest &rReq)
{
SwWrtShell &rWrtShell = GetShell();
+ SwUndoId nUndoId(UNDO_EMPTY);
sal_uInt16 nId = rReq.GetSlot(), nCnt = 1;
const SfxItemSet* pArgs = rReq.GetArgs();
const SfxPoolItem* pItem;
@@ -503,19 +504,25 @@ void SwBaseShell::ExecUndo(SfxRequest &rReq)
switch( nId )
{
case SID_UNDO:
- for (SwViewShell& rShell : rWrtShell.GetRingContainer())
- rShell.LockPaint();
- rWrtShell.Do( SwWrtShell::UNDO, nCnt );
- for (SwViewShell& rShell : rWrtShell.GetRingContainer())
- rShell.UnlockPaint();
+ if (rUndoRedo.GetLastUndoInfo(nullptr, &nUndoId, &rWrtShell.GetView()))
+ {
+ for (SwViewShell& rShell : rWrtShell.GetRingContainer())
+ rShell.LockPaint();
+ rWrtShell.Do( SwWrtShell::UNDO, nCnt );
+ for (SwViewShell& rShell : rWrtShell.GetRingContainer())
+ rShell.UnlockPaint();
+ }
break;
case SID_REDO:
- for (SwViewShell& rShell : rWrtShell.GetRingContainer())
- rShell.LockPaint();
- rWrtShell.Do( SwWrtShell::REDO, nCnt );
- for (SwViewShell& rShell : rWrtShell.GetRingContainer())
- rShell.UnlockPaint();
+ if (rUndoRedo.GetFirstRedoInfo(nullptr, &nUndoId, &rWrtShell.GetView()))
+ {
+ for (SwViewShell& rShell : rWrtShell.GetRingContainer())
+ rShell.LockPaint();
+ rWrtShell.Do( SwWrtShell::REDO, nCnt );
+ for (SwViewShell& rShell : rWrtShell.GetRingContainer())
+ rShell.UnlockPaint();
+ }
break;
case SID_REPEAT:
@@ -525,6 +532,11 @@ void SwBaseShell::ExecUndo(SfxRequest &rReq)
OSL_FAIL("wrong Dispatcher");
}
+ if (nUndoId == UNDO_CONFLICT)
+ {
+ rReq.SetReturnValue( SfxUInt32Item(nId, static_cast<sal_uInt32>(nUndoId)) );
+ }
+
if (pViewFrame) { pViewFrame->GetBindings().InvalidateAll(false); }
}
@@ -532,6 +544,7 @@ void SwBaseShell::ExecUndo(SfxRequest &rReq)
void SwBaseShell::StateUndo(SfxItemSet &rSet)
{
+ SwUndoId nUndoId(UNDO_EMPTY);
SwWrtShell &rSh = GetShell();
SfxWhichIter aIter(rSet);
sal_uInt16 nWhich = aIter.FirstWhich();
@@ -541,29 +554,38 @@ void SwBaseShell::StateUndo(SfxItemSet &rSet)
{
case SID_UNDO:
{
- if (rSh.GetLastUndoInfo(nullptr, nullptr, &rSh.GetView()))
+ if (rSh.GetLastUndoInfo(nullptr, &nUndoId, &rSh.GetView()))
{
rSet.Put( SfxStringItem(nWhich,
rSh.GetDoString(SwWrtShell::UNDO)));
}
+ else if (nUndoId == UNDO_CONFLICT)
+ {
+ rSet.Put( SfxUInt32Item(nWhich, static_cast<sal_uInt32>(nUndoId)) );
+ }
else
rSet.DisableItem(nWhich);
+
break;
}
case SID_REDO:
{
- if (rSh.GetFirstRedoInfo(nullptr, &rSh.GetView()))
+ if (rSh.GetFirstRedoInfo(nullptr, &nUndoId, &rSh.GetView()))
{
rSet.Put(SfxStringItem(nWhich,
rSh.GetDoString(SwWrtShell::REDO)));
}
+ else if (nUndoId == UNDO_CONFLICT)
+ {
+ rSet.Put( SfxInt32Item(nWhich, static_cast<sal_uInt32>(nUndoId)) );
+ }
else
rSet.DisableItem(nWhich);
break;
}
case SID_REPEAT:
{ // Repeat is only possible if no REDO is possible - UI-Restriction
- if ((!rSh.GetFirstRedoInfo(nullptr)) &&
+ if ((!rSh.GetFirstRedoInfo(nullptr, nullptr)) &&
!rSh.IsSelFrameMode() &&
(UNDO_EMPTY != rSh.GetRepeatInfo(nullptr)))
{
@@ -586,7 +608,7 @@ void SwBaseShell::StateUndo(SfxItemSet &rSet)
break;
case SID_GETREDOSTRINGS:
- if (rSh.GetFirstRedoInfo(nullptr))
+ if (rSh.GetFirstRedoInfo(nullptr, nullptr))
{
SfxStringListItem aStrLst( nWhich );
rSh.GetDoStrings( SwWrtShell::REDO, aStrLst );
diff --git a/sw/source/uibase/wrtsh/wrtundo.cxx b/sw/source/uibase/wrtsh/wrtundo.cxx
index d7da499..e0eba76 100644
--- a/sw/source/uibase/wrtsh/wrtundo.cxx
+++ b/sw/source/uibase/wrtsh/wrtundo.cxx
@@ -106,7 +106,7 @@ OUString SwWrtShell::GetDoString( DoType eDoType ) const
break;
case REDO:
nResStr = STR_REDO;
- (void)GetFirstRedoInfo(&aUndoStr, &m_rView);
+ (void)GetFirstRedoInfo(&aUndoStr, nullptr, &m_rView);
break;
default:;//prevent warning
}
More information about the Libreoffice-commits
mailing list