summaryrefslogtreecommitdiff
path: root/sw/source/core
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-08-10 17:42:54 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-08-15 09:54:56 +0200
commitd7ceb72ff0b1ce94118d3c85cdc7641e461e44a6 (patch)
treeb50fc74a170eef943cfdcce2db4f0793f8d927ea /sw/source/core
parent01e160686140299002df52e76dc8e3411c6e01c2 (diff)
sw undo: add a Repair argument to the .uno:Undo/Redo commands
Undo/redo is limited to undo actions created by the same view in the LOK case, this argument removes this limit. This can be used by a client for "document repair" purposes, where undo/redo of others' changes is intentional. The sfx command dispatch has support for FASTCALL slots (a state function is not called, the command is always enabled) and also has support for state functions, but those functions only get the ID of the slots, not its parameters. What is needed here is a command that's disabled by default, but in case a Repair argument is used, then it's unconditionally enabled. So handle that case in the sfx dispatcher directly for now. Change-Id: I96c1130bf51abcdd722684b1fa4a8277f92fd555 (cherry picked from commit e9bcd3475131b24b0b8818cfdfa256854ca5a59d)
Diffstat (limited to 'sw/source/core')
-rw-r--r--sw/source/core/inc/UndoManager.hxx4
-rw-r--r--sw/source/core/undo/docundo.cxx15
2 files changed, 17 insertions, 2 deletions
diff --git a/sw/source/core/inc/UndoManager.hxx b/sw/source/core/inc/UndoManager.hxx
index 5092e95a34ab..00132625bdcd 100644
--- a/sw/source/core/inc/UndoManager.hxx
+++ b/sw/source/core/inc/UndoManager.hxx
@@ -49,6 +49,8 @@ public:
virtual bool DoesGroupUndo() const override;
virtual void DoDrawUndo(bool const bDoUndo) override;
virtual bool DoesDrawUndo() const override;
+ void DoRepair(bool bRepair) override;
+ bool DoesRepair() const override;
virtual void SetUndoNoModifiedPosition() override;
virtual void LockUndoNoModifiedPosition() override;
virtual void UnLockUndoNoModifiedPosition() override;
@@ -100,6 +102,8 @@ private:
bool m_bGroupUndo : 1; // TRUE: Undo grouping enabled
bool m_bDrawUndo : 1; // TRUE: Draw Undo enabled
+ /// If true, then repair mode is enabled.
+ bool m_bRepair;
bool m_bLockUndoNoModifiedPosition : 1;
/// position in Undo-Array at which Doc was saved (and is not modified)
UndoStackMark m_UndoSaveMark;
diff --git a/sw/source/core/undo/docundo.cxx b/sw/source/core/undo/docundo.cxx
index 46a66933e709..943de4b20219 100644
--- a/sw/source/core/undo/docundo.cxx
+++ b/sw/source/core/undo/docundo.cxx
@@ -58,6 +58,7 @@ UndoManager::UndoManager(std::shared_ptr<SwNodes> xUndoNodes,
, m_xUndoNodes(xUndoNodes)
, m_bGroupUndo(true)
, m_bDrawUndo(true)
+ , m_bRepair(false)
, m_bLockUndoNoModifiedPosition(false)
, m_UndoSaveMark(MARK_INVALID)
{
@@ -138,6 +139,16 @@ bool UndoManager::DoesDrawUndo() const
return m_bDrawUndo;
}
+void UndoManager::DoRepair(bool bRepair)
+{
+ m_bRepair = bRepair;
+}
+
+bool UndoManager::DoesRepair() const
+{
+ return m_bRepair;
+}
+
bool UndoManager::IsUndoNoResetModified() const
{
return MARK_INVALID == m_UndoSaveMark;
@@ -308,7 +319,7 @@ UndoManager::GetLastUndoInfo(
SfxUndoAction *const pAction( SdrUndoManager::GetUndoAction() );
- if (comphelper::LibreOfficeKit::isActive())
+ if (comphelper::LibreOfficeKit::isActive() && !m_bRepair)
{
// If an other view created the undo action, prevent undoing it from this view.
sal_Int32 nViewShellId = pView ? pView->GetViewShellId() : m_pDocShell->GetView()->GetViewShellId();
@@ -361,7 +372,7 @@ bool UndoManager::GetFirstRedoInfo(OUString *const o_pStr,
return false;
}
- if (comphelper::LibreOfficeKit::isActive())
+ if (comphelper::LibreOfficeKit::isActive() && !m_bRepair)
{
// If an other view created the undo action, prevent redoing it from this view.
sal_Int32 nViewShellId = pView ? pView->GetViewShellId() : m_pDocShell->GetView()->GetViewShellId();