summaryrefslogtreecommitdiff
path: root/svl
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2021-11-10 08:50:08 +0100
committerMiklos Vajna <vmiklos@collabora.com>2021-11-10 09:37:36 +0100
commit8e8e72f08b01a284cf1a90b888d48acfb6a33d2e (patch)
treee4e18c52d669f6233fdabdb0f4deed1a51cdd155 /svl
parentcf2d88b8a44ac9e8b37954fc2cc4b52d719cc035 (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. Change-Id: Ibb4551e8f7046b4947491b8bf751eaa0cbb2d060 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124949 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
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 630bb9deea5b..0c081b152c3a 100644
--- a/svl/source/undo/undo.cxx
+++ b/svl/source/undo/undo.cxx
@@ -683,6 +683,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