summaryrefslogtreecommitdiff
path: root/svl
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2021-11-10 08:50:08 +0100
committerMike Kaganski <mike.kaganski@collabora.com>2021-11-11 09:11:10 +0100
commitc72e500ccaf0ce2261c5233b80fba9342778f810 (patch)
treed4b7875fc6fecaaf5bc2b774dfde513addd488ee /svl
parent6cc10c4492f59c6ab56c31a80712f604608d7f0d (diff)
sw: allow undo of typing in 2 views independent from each other
Undoing out of order is dangerous by default, so limit this to a very specific case as a start, that allows growing in follow-up commits. For now, allow out of order undo if: 1) redo stack is empty 2) we're in LOK mode (different views represent different users) 3) we undo a single action (count is 1) 4) the top undo action doesn't belong to the current view 5) the top and the previous undo actions are independent Which only requires that SwUndoInsert::UndoImpl() is independent for two different paragraphs, which seems to be the case. Independent undo actions opt in for this, currently the only such allowed undo action is SwUndoInsert ("typing"), which adds characters to a single text node. Even those are only considered independent if they operate on different text nodes. On the positive side, this allows out of order undo in the frequent case where two users collaborate on a long document and they just type some new content into the document at different paragraphs. (cherry picked from commit 8e8e72f08b01a284cf1a90b888d48acfb6a33d2e) Conflicts: sw/source/core/inc/UndoManager.hxx sw/source/uibase/shells/basesh.cxx Change-Id: Ibb4551e8f7046b4947491b8bf751eaa0cbb2d060 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124955 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'svl')
-rw-r--r--svl/source/undo/undo.cxx10
1 files changed, 10 insertions, 0 deletions
diff --git a/svl/source/undo/undo.cxx b/svl/source/undo/undo.cxx
index 2ce8fa84bf17..5889d59a064b 100644
--- a/svl/source/undo/undo.cxx
+++ b/svl/source/undo/undo.cxx
@@ -688,6 +688,16 @@ bool SfxUndoManager::ImplUndo( SfxUndoContext* i_contextOrNull )
return false;
}
+ if (i_contextOrNull && i_contextOrNull->GetUndoOffset() == 1)
+ {
+ if (m_xData->pActUndoArray->nCurUndoAction >= 2)
+ {
+ std::swap(
+ m_xData->pActUndoArray->maUndoActions[m_xData->pActUndoArray->nCurUndoAction - 1],
+ m_xData->pActUndoArray->maUndoActions[m_xData->pActUndoArray->nCurUndoAction - 2]);
+ }
+ }
+
SfxUndoAction* pAction = m_xData->pActUndoArray->maUndoActions[ --m_xData->pActUndoArray->nCurUndoAction ].pAction.get();
const OUString sActionComment = pAction->GetComment();
try