diff options
author | Henry Castro <hcastro@collabora.com> | 2017-06-27 14:35:58 -0400 |
---|---|---|
committer | Henry Castro <hcastro@collabora.com> | 2017-06-28 02:50:00 +0200 |
commit | 9f3814af7264ce90685a82cbf4eb015a38f22bf7 (patch) | |
tree | 9aeba4af7e08129fd69ab73b8e71d7069c7bec25 /sd/source/ui/view/viewshel.cxx | |
parent | e0f67add2ec56706ce06a03572535266f21c0303 (diff) |
sd lok: fix Undo/Redo Document Repair
REPAIRPACKAGE is sent to enable Undo/Redo actions when two views
have conflicts.
Change-Id: I58133f5b9006c41a297711c52ed0acfce3c19f92
Reviewed-on: https://gerrit.libreoffice.org/39325
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Henry Castro <hcastro@collabora.com>
Diffstat (limited to 'sd/source/ui/view/viewshel.cxx')
-rw-r--r-- | sd/source/ui/view/viewshel.cxx | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/sd/source/ui/view/viewshel.cxx b/sd/source/ui/view/viewshel.cxx index c72d90886dc6..a0e86368021f 100644 --- a/sd/source/ui/view/viewshel.cxx +++ b/sd/source/ui/view/viewshel.cxx @@ -1258,11 +1258,18 @@ void ViewShell::ImpSidUndo(SfxRequest& rReq) ::svl::IUndoManager* pUndoManager = ImpGetUndoManager(); sal_uInt16 nNumber(1); const SfxItemSet* pReqArgs = rReq.GetArgs(); + bool bRepair = false; if(pReqArgs) { const SfxUInt16Item* pUIntItem = static_cast<const SfxUInt16Item*>(&pReqArgs->Get(SID_UNDO)); nNumber = pUIntItem->GetValue(); + + // Repair mode: allow undo/redo of all undo actions, even if access would + // be limited based on the view shell ID. + const SfxPoolItem* pRepairItem; + if (pReqArgs->GetItemState(SID_REPAIRPACKAGE, false, &pRepairItem) == SfxItemState::SET) + bRepair = static_cast<const SfxBoolItem*>(pRepairItem)->GetValue(); } if(nNumber && pUndoManager) @@ -1270,6 +1277,17 @@ void ViewShell::ImpSidUndo(SfxRequest& rReq) sal_uInt16 nCount(pUndoManager->GetUndoActionCount()); if(nCount >= nNumber) { + if (comphelper::LibreOfficeKit::isActive() && !bRepair) + { + // If an other view created the first undo action, prevent redoing it from this view. + const SfxUndoAction* pAction = pUndoManager->GetUndoAction(); + if (pAction->GetViewShellId() != GetViewShellBase().GetViewShellId()) + { + rReq.SetReturnValue(SfxUInt32Item(SID_UNDO, static_cast<sal_uInt32>(SID_REPAIRPACKAGE))); + return; + } + } + try { // when UndoStack is cleared by ModifyPageUndoAction @@ -1309,11 +1327,17 @@ void ViewShell::ImpSidRedo(SfxRequest& rReq) ::svl::IUndoManager* pUndoManager = ImpGetUndoManager(); sal_uInt16 nNumber(1); const SfxItemSet* pReqArgs = rReq.GetArgs(); + bool bRepair = false; if(pReqArgs) { const SfxUInt16Item* pUIntItem = static_cast<const SfxUInt16Item*>(&pReqArgs->Get(SID_REDO)); nNumber = pUIntItem->GetValue(); + // Repair mode: allow undo/redo of all undo actions, even if access would + // be limited based on the view shell ID. + const SfxPoolItem* pRepairItem; + if (pReqArgs->GetItemState(SID_REPAIRPACKAGE, false, &pRepairItem) == SfxItemState::SET) + bRepair = static_cast<const SfxBoolItem*>(pRepairItem)->GetValue(); } if(nNumber && pUndoManager) @@ -1321,6 +1345,17 @@ void ViewShell::ImpSidRedo(SfxRequest& rReq) sal_uInt16 nCount(pUndoManager->GetRedoActionCount()); if(nCount >= nNumber) { + if (comphelper::LibreOfficeKit::isActive() && !bRepair) + { + // If an other view created the first undo action, prevent redoing it from this view. + const SfxUndoAction* pAction = pUndoManager->GetRedoAction(); + if (pAction->GetViewShellId() != GetViewShellBase().GetViewShellId()) + { + rReq.SetReturnValue(SfxUInt32Item(SID_REDO, static_cast<sal_uInt32>(SID_REPAIRPACKAGE))); + return; + } + } + try { // when UndoStack is cleared by ModifyPageRedoAction |