summaryrefslogtreecommitdiff
path: root/sd/source
diff options
context:
space:
mode:
authorHenry Castro <hcastro@collabora.com>2017-06-27 14:35:58 -0400
committerHenry Castro <hcastro@collabora.com>2017-06-28 02:50:00 +0200
commit9f3814af7264ce90685a82cbf4eb015a38f22bf7 (patch)
tree9aeba4af7e08129fd69ab73b8e71d7069c7bec25 /sd/source
parente0f67add2ec56706ce06a03572535266f21c0303 (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')
-rw-r--r--sd/source/core/undo/undomanager.cxx49
-rw-r--r--sd/source/ui/view/viewshe3.cxx10
-rw-r--r--sd/source/ui/view/viewshel.cxx35
3 files changed, 35 insertions, 59 deletions
diff --git a/sd/source/core/undo/undomanager.cxx b/sd/source/core/undo/undomanager.cxx
index e4caf4df4cb7..57bc43880e63 100644
--- a/sd/source/core/undo/undomanager.cxx
+++ b/sd/source/core/undo/undomanager.cxx
@@ -17,7 +17,6 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#include <comphelper/lok.hxx>
#include <sfx2/viewsh.hxx>
#include <undo/undomanager.hxx>
@@ -25,7 +24,6 @@ using namespace sd;
UndoManager::UndoManager()
: mpLinkedUndoManager(nullptr)
- , mpViewShell(nullptr)
{
}
@@ -51,53 +49,6 @@ void UndoManager::AddUndoAction( SfxUndoAction *pAction, bool bTryMerg /* = sal_
}
}
-size_t UndoManager::GetUndoActionCount(const bool bCurrentLevel) const
-{
- size_t nRet = SdrUndoManager::GetUndoActionCount(bCurrentLevel);
- if (!comphelper::LibreOfficeKit::isActive() || !mpViewShell)
- return nRet;
-
- if (!nRet || !SdrUndoManager::GetUndoActionCount())
- return nRet;
-
- const SfxUndoAction* pAction = SdrUndoManager::GetUndoAction();
- if (!pAction)
- return nRet;
-
- // If an other view created the last undo action, prevent undoing it from this view.
- ViewShellId nViewShellId = mpViewShell->GetViewShellId();
- if (pAction->GetViewShellId() != nViewShellId)
- nRet = 0;
-
- return nRet;
-}
-
-size_t UndoManager::GetRedoActionCount(const bool bCurrentLevel) const
-{
- size_t nRet = SdrUndoManager::GetRedoActionCount(bCurrentLevel);
- if (!comphelper::LibreOfficeKit::isActive() || !mpViewShell)
- return nRet;
-
- if (!nRet || !SdrUndoManager::GetRedoActionCount())
- return nRet;
-
- const SfxUndoAction* pAction = SdrUndoManager::GetRedoAction();
- if (!pAction)
- return nRet;
-
- // If an other view created the first redo action, prevent redoing it from this view.
- ViewShellId nViewShellId = mpViewShell->GetViewShellId();
- if (pAction->GetViewShellId() != nViewShellId)
- nRet = 0;
-
- return nRet;
-}
-
-void UndoManager::SetViewShell(SfxViewShell* pViewShell)
-{
- mpViewShell = pViewShell;
-}
-
void UndoManager::SetLinkedUndoManager (::svl::IUndoManager* pLinkedUndoManager)
{
mpLinkedUndoManager = pLinkedUndoManager;
diff --git a/sd/source/ui/view/viewshe3.cxx b/sd/source/ui/view/viewshe3.cxx
index 2a59f0ecdfab..7e744d07f598 100644
--- a/sd/source/ui/view/viewshe3.cxx
+++ b/sd/source/ui/view/viewshe3.cxx
@@ -130,15 +130,10 @@ void ViewShell::GetMenuState( SfxItemSet &rSet )
if(pUndoManager)
{
- auto pSdUndoManager = dynamic_cast<sd::UndoManager*>(pUndoManager);
- if (pSdUndoManager)
- pSdUndoManager->SetViewShell(&GetViewShellBase());
if(pUndoManager->GetUndoActionCount() != 0)
{
bActivate = true;
}
- if (pSdUndoManager)
- pSdUndoManager->SetViewShell(nullptr);
}
if(bActivate)
@@ -162,15 +157,10 @@ void ViewShell::GetMenuState( SfxItemSet &rSet )
if(pUndoManager)
{
- auto pSdUndoManager = dynamic_cast<sd::UndoManager*>(pUndoManager);
- if (pSdUndoManager)
- pSdUndoManager->SetViewShell(&GetViewShellBase());
if(pUndoManager->GetRedoActionCount() != 0)
{
bActivate = true;
}
- if (pSdUndoManager)
- pSdUndoManager->SetViewShell(nullptr);
}
if(bActivate)
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