From ee821f3cc68838910e1a06b6141c2580152640d3 Mon Sep 17 00:00:00 2001 From: Marco Cecchetti Date: Fri, 6 Jan 2017 18:35:08 +0100 Subject: LOK: Calc: limiting undo and add support for repair mode During collaborative editing changes can be undone regardless of who made them. This patch avoids this possibility and introduce support for repair mode, for cases where undo/redo of others' changes is intentional. Change-Id: I69fd435e96c4c675ffd1df81e936b5eae109daa0 --- sc/source/ui/view/tabvwshb.cxx | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'sc/source/ui') diff --git a/sc/source/ui/view/tabvwshb.cxx b/sc/source/ui/view/tabvwshb.cxx index 2864c7bf921d..5ad79bfcfd82 100644 --- a/sc/source/ui/view/tabvwshb.cxx +++ b/sc/source/ui/view/tabvwshb.cxx @@ -62,6 +62,7 @@ #include #include +#include using namespace com::sun::star; @@ -511,6 +512,33 @@ void ScTabViewShell::ExecuteUndo(SfxRequest& rReq) if ( pReqArgs && pReqArgs->GetItemState( nSlot, true, &pItem ) == SfxItemState::SET ) nCount = static_cast(pItem)->GetValue(); + // Repair mode: allow undo/redo of all undo actions, even if access would + // be limited based on the view shell ID. + bool bRepair = false; + if (pReqArgs && pReqArgs->GetItemState(SID_REPAIRPACKAGE, false, &pItem) == SfxItemState::SET) + bRepair = static_cast(pItem)->GetValue(); + + if (comphelper::LibreOfficeKit::isActive() && !bRepair) + { + SfxUndoAction* pAction = nullptr; + if (bIsUndo) + { + if (pUndoManager->GetUndoActionCount() != 0) + pAction = pUndoManager->GetUndoAction(); + } + else + { + if (pUndoManager->GetRedoActionCount() != 0) + pAction = pUndoManager->GetRedoAction(); + } + if (pAction) + { + sal_Int32 nViewShellId = GetViewShellId(); + if (pAction->GetViewShellId() != nViewShellId) + return; + } + } + // lock paint for more than one cell undo action (not for editing within a cell) bool bLockPaint = ( nCount > 1 && pUndoManager == GetUndoManager() ); if ( bLockPaint ) -- cgit v1.2.3