summaryrefslogtreecommitdiff
path: root/sw/source
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-08-09 18:13:37 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-08-09 16:44:27 +0000
commit5d8639aaf2f60157c99c3ee3a8bfa78e4efd010a (patch)
treefc3e431ce0398bff382ff792a97e0588a8ca31b0 /sw/source
parente328cab3c987a057411264209d1393440504a2cd (diff)
sw lok: limit undo/redo access to undo actions created by the same view
So one view can't undo the changes of an other view by accident. If this is found to be useful in the desktop case, perhaps a dedicated config option can be added for it; for now the behavior is LOK-only. Change-Id: I7ff505d021bd6f6be36953ecc8f8bb971ce8927e Reviewed-on: https://gerrit.libreoffice.org/28007 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'sw/source')
-rw-r--r--sw/source/core/edit/edws.cxx14
-rw-r--r--sw/source/core/inc/UndoManager.hxx6
-rw-r--r--sw/source/core/undo/docundo.cxx22
-rw-r--r--sw/source/uibase/shells/basesh.cxx4
-rw-r--r--sw/source/uibase/wrtsh/wrtundo.cxx4
5 files changed, 38 insertions, 12 deletions
diff --git a/sw/source/core/edit/edws.cxx b/sw/source/core/edit/edws.cxx
index ae5c6815bdf1..6c9ac8689a8a 100644
--- a/sw/source/core/edit/edws.cxx
+++ b/sw/source/core/edit/edws.cxx
@@ -224,11 +224,17 @@ SwUndoId SwEditShell::EndUndo(SwUndoId eUndoId, const SwRewriter *pRewriter)
{ return GetDoc()->GetIDocumentUndoRedo().EndUndo(eUndoId, pRewriter); }
bool SwEditShell::GetLastUndoInfo(OUString *const o_pStr,
- SwUndoId *const o_pId) const
-{ return GetDoc()->GetIDocumentUndoRedo().GetLastUndoInfo(o_pStr, o_pId); }
+ SwUndoId *const o_pId,
+ const SwView* pView) const
+{
+ return GetDoc()->GetIDocumentUndoRedo().GetLastUndoInfo(o_pStr, o_pId, pView);
+}
-bool SwEditShell::GetFirstRedoInfo(OUString *const o_pStr) const
-{ return GetDoc()->GetIDocumentUndoRedo().GetFirstRedoInfo(o_pStr); }
+bool SwEditShell::GetFirstRedoInfo(OUString *const o_pStr,
+ const SwView* pView) const
+{
+ return GetDoc()->GetIDocumentUndoRedo().GetFirstRedoInfo(o_pStr, nullptr, pView);
+}
SwUndoId SwEditShell::GetRepeatInfo(OUString *const o_pStr) const
{ return GetDoc()->GetIDocumentUndoRedo().GetRepeatInfo(o_pStr); }
diff --git a/sw/source/core/inc/UndoManager.hxx b/sw/source/core/inc/UndoManager.hxx
index 68774c47d003..5092e95a34ab 100644
--- a/sw/source/core/inc/UndoManager.hxx
+++ b/sw/source/core/inc/UndoManager.hxx
@@ -61,10 +61,12 @@ public:
SwRewriter const*const pRewriter) override;
virtual void DelAllUndoObj() override;
virtual bool GetLastUndoInfo(OUString *const o_pStr,
- SwUndoId *const o_pId) const override;
+ SwUndoId *const o_pId,
+ const SwView* pView = nullptr) const override;
virtual SwUndoComments_t GetUndoComments() const override;
virtual bool GetFirstRedoInfo(OUString *const o_pStr,
- SwUndoId *const o_pId = nullptr) const override;
+ SwUndoId *const o_pId = nullptr,
+ const SwView* pView = nullptr) const override;
virtual SwUndoComments_t GetRedoComments() const override;
virtual bool Repeat(::sw::RepeatContext & rContext,
sal_uInt16 const nRepeatCnt) override;
diff --git a/sw/source/core/undo/docundo.cxx b/sw/source/core/undo/docundo.cxx
index 9f70fa0d1768..ba4aeff8d575 100644
--- a/sw/source/core/undo/docundo.cxx
+++ b/sw/source/core/undo/docundo.cxx
@@ -39,6 +39,7 @@
#include <IDocumentDrawModelAccess.hxx>
#include <IDocumentRedlineAccess.hxx>
#include <IDocumentState.hxx>
+#include <comphelper/lok.hxx>
using namespace ::com::sun::star;
@@ -296,7 +297,7 @@ UndoManager::EndUndo(SwUndoId const i_eUndoId, SwRewriter const*const pRewriter)
bool
UndoManager::GetLastUndoInfo(
- OUString *const o_pStr, SwUndoId *const o_pId) const
+ OUString *const o_pStr, SwUndoId *const o_pId, const SwView* pView) const
{
// this is actually expected to work on the current level,
// but that was really not obvious from the previous implementation...
@@ -307,6 +308,14 @@ UndoManager::GetLastUndoInfo(
SfxUndoAction *const pAction( SdrUndoManager::GetUndoAction() );
+ if (comphelper::LibreOfficeKit::isActive())
+ {
+ // If an other view created the undo action, prevent undoing it from this view.
+ sal_Int32 nViewShellId = pView ? pView->GetViewShellId() : m_pDocShell->GetView()->GetViewShellId();
+ if (pAction->GetViewShellId() != nViewShellId)
+ return false;
+ }
+
if (o_pStr)
{
*o_pStr = pAction->GetComment();
@@ -338,7 +347,8 @@ SwUndoComments_t UndoManager::GetUndoComments() const
}
bool UndoManager::GetFirstRedoInfo(OUString *const o_pStr,
- SwUndoId *const o_pId) const
+ SwUndoId *const o_pId,
+ const SwView* pView) const
{
if (!SdrUndoManager::GetRedoActionCount())
{
@@ -351,6 +361,14 @@ bool UndoManager::GetFirstRedoInfo(OUString *const o_pStr,
return false;
}
+ if (comphelper::LibreOfficeKit::isActive())
+ {
+ // If an other view created the undo action, prevent redoing it from this view.
+ sal_Int32 nViewShellId = pView ? pView->GetViewShellId() : m_pDocShell->GetView()->GetViewShellId();
+ if (pAction->GetViewShellId() != nViewShellId)
+ return false;
+ }
+
if (o_pStr)
{
*o_pStr = pAction->GetComment();
diff --git a/sw/source/uibase/shells/basesh.cxx b/sw/source/uibase/shells/basesh.cxx
index fc2bfb1d963b..6f802bed355f 100644
--- a/sw/source/uibase/shells/basesh.cxx
+++ b/sw/source/uibase/shells/basesh.cxx
@@ -527,7 +527,7 @@ void SwBaseShell::StateUndo(SfxItemSet &rSet)
{
case SID_UNDO:
{
- if (rSh.GetLastUndoInfo(nullptr, nullptr))
+ if (rSh.GetLastUndoInfo(nullptr, nullptr, &rSh.GetView()))
{
rSet.Put( SfxStringItem(nWhich,
rSh.GetDoString(SwWrtShell::UNDO)));
@@ -538,7 +538,7 @@ void SwBaseShell::StateUndo(SfxItemSet &rSet)
}
case SID_REDO:
{
- if (rSh.GetFirstRedoInfo(nullptr))
+ if (rSh.GetFirstRedoInfo(nullptr, &rSh.GetView()))
{
rSet.Put(SfxStringItem(nWhich,
rSh.GetDoString(SwWrtShell::REDO)));
diff --git a/sw/source/uibase/wrtsh/wrtundo.cxx b/sw/source/uibase/wrtsh/wrtundo.cxx
index ea1c37e32783..1260d8902b15 100644
--- a/sw/source/uibase/wrtsh/wrtundo.cxx
+++ b/sw/source/uibase/wrtsh/wrtundo.cxx
@@ -102,11 +102,11 @@ OUString SwWrtShell::GetDoString( DoType eDoType ) const
{
case UNDO:
nResStr = STR_UNDO;
- (void)GetLastUndoInfo(&aUndoStr, nullptr);
+ (void)GetLastUndoInfo(&aUndoStr, nullptr, &m_rView);
break;
case REDO:
nResStr = STR_REDO;
- (void)GetFirstRedoInfo(&aUndoStr);
+ (void)GetFirstRedoInfo(&aUndoStr, &m_rView);
break;
default:;//prevent warning
}