summaryrefslogtreecommitdiff
path: root/sw/source
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2021-11-11 08:41:50 +0100
committerMike Kaganski <mike.kaganski@collabora.com>2021-11-11 18:04:18 +0100
commit60665dc4a2af238939b1a5056ae4a4ce2c083159 (patch)
tree74e61cc046c24be356b8c79abbf5c834725a0cbb /sw/source
parent9e9681109f7a340c306342791015f12e6f21be4f (diff)
sw, out of order undo: allow a subset of a non-empty redo list
Specifically, we used to not allow out of order undo at all if the redo list was non-empty. This relaxes that condition a bit. Out of order undo is OK with a non-empty redo list, in case all undo actions in the redo list are either 1) owned by the current view or 2) independent from the undo action to be executed I.e. if view1 has lots of type undo actions and an view2 adds a single type undo action on top of it, then allow view 1 to execute multiple of its typing undo actions, not just a single one. (cherry picked from commit 2875c65946e59f5dd7968155463bf00bd71d440b) Conflicts: sw/source/core/undo/docundo.cxx Change-Id: I2f5d9404a9994ed74b65233d2a315976c27b28b2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125039 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sw/source')
-rw-r--r--sw/source/core/undo/docundo.cxx21
1 files changed, 18 insertions, 3 deletions
diff --git a/sw/source/core/undo/docundo.cxx b/sw/source/core/undo/docundo.cxx
index 8c46f659cf06..16266e6a4f85 100644
--- a/sw/source/core/undo/docundo.cxx
+++ b/sw/source/core/undo/docundo.cxx
@@ -359,10 +359,9 @@ UndoManager::EndUndo(SwUndoId eUndoId, SwRewriter const*const pRewriter)
*/
bool UndoManager::IsViewUndoActionIndependent(const SwView* pView) const
{
- if (GetUndoActionCount() <= 1 || SdrUndoManager::GetRedoActionCount() > 0)
+ if (GetUndoActionCount() <= 1)
{
- // Single or less undo, owned by an other view; or redo actions that might depend on the
- // current undo order.
+ // Single or less undo, owned by another view.
return false;
}
@@ -405,6 +404,22 @@ bool UndoManager::IsViewUndoActionIndependent(const SwView* pView) const
const auto& rTopInsert = *static_cast<const SwUndoInsert*>(pTopSwAction);
const auto& rViewInsert = *static_cast<const SwUndoInsert*>(pViewSwAction);
+ for (size_t i = 0; i < GetRedoActionCount(); ++i)
+ {
+ auto pRedoAction = dynamic_cast<const SwUndo*>(GetRedoAction(i));
+ if (!pRedoAction || pViewSwAction->GetId() != SwUndoId::TYPING)
+ {
+ return false;
+ }
+
+ const auto& rRedoInsert = *static_cast<const SwUndoInsert*>(pRedoAction);
+ if (!rViewInsert.IsIndependent(rRedoInsert) && rRedoInsert.GetViewShellId() != nViewId)
+ {
+ // Dependent redo action and owned by an other view.
+ return false;
+ }
+ }
+
return rViewInsert.IsIndependent(rTopInsert);
}