summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorVasily Melenchuk <vasily.melenchuk@cib.de>2021-07-23 14:28:04 +0300
committerThorsten Behrens <thorsten.behrens@allotropia.de>2021-08-05 18:33:54 +0200
commit4edf3a964e764dcc40be729b8305476c5b968f1c (patch)
tree31377a91331f124d550eb6c7e8820c8f6fd1aa46 /sw
parent3487d85ea384f74c096499cfea8e565e778f8408 (diff)
sw: undo/redo for outline modification
Outline changes done via "Tools"->"Chapter Numbering" were not tracked by undo/redo before. Change-Id: I764dda526d2b17ecbb62eca0d6a9fb0b368c4a69 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119405 Tested-by: Jenkins Reviewed-by: Thorsten Behrens <thorsten.behrens@allotropia.de>
Diffstat (limited to 'sw')
-rw-r--r--sw/inc/strings.hrc1
-rw-r--r--sw/inc/swundo.hxx3
-rw-r--r--sw/source/core/doc/docnum.cxx15
-rw-r--r--sw/source/core/inc/UndoCore.hxx14
-rw-r--r--sw/source/core/undo/undobj.cxx3
-rw-r--r--sw/source/core/undo/unoutl.cxx24
6 files changed, 59 insertions, 1 deletions
diff --git a/sw/inc/strings.hrc b/sw/inc/strings.hrc
index 4d374a5591f5..a6b502742989 100644
--- a/sw/inc/strings.hrc
+++ b/sw/inc/strings.hrc
@@ -453,6 +453,7 @@
#define STR_TEXT_CORRECTION NC_("STR_TEXT_CORRECTION", "Text Correction")
#define STR_OUTLINE_LR NC_("STR_OUTLINE_LR", "Promote/demote outline")
#define STR_OUTLINE_UD NC_("STR_OUTLINE_UD", "Move outline")
+#define STR_OUTLINE_EDIT NC_("STR_OUTLINE_EDIT", "Modify outline")
#define STR_INSNUM NC_("STR_INSNUM", "Insert numbering")
#define STR_NUMUP NC_("STR_NUMUP", "Promote level")
#define STR_NUMDOWN NC_("STR_NUMDOWN", "Demote level")
diff --git a/sw/inc/swundo.hxx b/sw/inc/swundo.hxx
index 90fa6c51d055..cda4ec02c49f 100644
--- a/sw/inc/swundo.hxx
+++ b/sw/inc/swundo.hxx
@@ -164,7 +164,8 @@ enum class SwUndoId
UI_TABLE_DELETE, // 133
CONFLICT, // 134
- INSERT_FORM_FIELD // 135
+ INSERT_FORM_FIELD, // 135
+ OUTLINE_EDIT, // 136
};
OUString GetUndoComment(SwUndoId eId);
diff --git a/sw/source/core/doc/docnum.cxx b/sw/source/core/doc/docnum.cxx
index fad2322f07d9..430d19220329 100644
--- a/sw/source/core/doc/docnum.cxx
+++ b/sw/source/core/doc/docnum.cxx
@@ -114,6 +114,16 @@ static sal_uInt8 GetUpperLvlChg( sal_uInt8 nCurLvl, sal_uInt8 nLevel, sal_uInt16
void SwDoc::SetOutlineNumRule( const SwNumRule& rRule )
{
+ if (GetIDocumentUndoRedo().DoesUndo())
+ {
+ GetIDocumentUndoRedo().StartUndo(SwUndoId::OUTLINE_EDIT, nullptr);
+ if (mpOutlineRule)
+ {
+ GetIDocumentUndoRedo().AppendUndo(
+ std::make_unique<SwUndoOutlineEdit>(*mpOutlineRule, rRule, *this));
+ }
+ }
+
if( mpOutlineRule )
(*mpOutlineRule) = rRule;
else
@@ -158,6 +168,11 @@ void SwDoc::SetOutlineNumRule( const SwNumRule& rRule )
getIDocumentFieldsAccess().UpdateExpFields(nullptr, true);
+ if (GetIDocumentUndoRedo().DoesUndo())
+ {
+ GetIDocumentUndoRedo().EndUndo(SwUndoId::OUTLINE_EDIT, nullptr);
+ }
+
getIDocumentState().SetModified();
}
diff --git a/sw/source/core/inc/UndoCore.hxx b/sw/source/core/inc/UndoCore.hxx
index 1fcfae22f6e2..62fcccd0231c 100644
--- a/sw/source/core/inc/UndoCore.hxx
+++ b/sw/source/core/inc/UndoCore.hxx
@@ -25,6 +25,7 @@
#include <o3tl/deleter.hxx>
#include <rtl/ustring.hxx>
#include <redline.hxx>
+#include <numrule.hxx>
#include <memory>
#include <vector>
@@ -221,6 +222,19 @@ public:
virtual void RepeatImpl( ::sw::RepeatContext & ) override;
};
+class SwUndoOutlineEdit final : public SwUndo, private SwUndRng
+{
+ SwNumRule m_aNewNumRule;
+ SwNumRule m_aOldNumRule;
+
+public:
+ SwUndoOutlineEdit(const SwNumRule& rOldRule, const SwNumRule& rNewRule, const SwDoc& rDoc);
+
+ virtual void UndoImpl(::sw::UndoRedoContext&) override;
+ virtual void RedoImpl(::sw::UndoRedoContext&) override;
+ virtual void RepeatImpl(::sw::RepeatContext&) override;
+};
+
const int nUndoStringLength = 20;
/**
diff --git a/sw/source/core/undo/undobj.cxx b/sw/source/core/undo/undobj.cxx
index a9566b770ae8..ba32c509b019 100644
--- a/sw/source/core/undo/undobj.cxx
+++ b/sw/source/core/undo/undobj.cxx
@@ -337,6 +337,9 @@ OUString GetUndoComment(SwUndoId eId)
case SwUndoId::OUTLINE_UD:
pId = STR_OUTLINE_UD;
break;
+ case SwUndoId::OUTLINE_EDIT:
+ pId = STR_OUTLINE_EDIT;
+ break;
case SwUndoId::INSNUM:
pId = STR_INSNUM;
break;
diff --git a/sw/source/core/undo/unoutl.cxx b/sw/source/core/undo/unoutl.cxx
index fc2e437a7459..2144c7dd78cf 100644
--- a/sw/source/core/undo/unoutl.cxx
+++ b/sw/source/core/undo/unoutl.cxx
@@ -46,4 +46,28 @@ void SwUndoOutlineLeftRight::RepeatImpl(::sw::RepeatContext & rContext)
rContext.GetDoc().OutlineUpDown(rContext.GetRepeatPaM(), m_nOffset);
}
+
+SwUndoOutlineEdit::SwUndoOutlineEdit(const SwNumRule& rOldRule, const SwNumRule& rNewRule,
+ const SwDoc& rDoc)
+ : SwUndo(SwUndoId::OUTLINE_EDIT, &rDoc)
+ , m_aNewNumRule(rNewRule)
+ , m_aOldNumRule(rOldRule)
+{
+}
+
+void SwUndoOutlineEdit::UndoImpl(::sw::UndoRedoContext& rContext)
+{
+ rContext.GetDoc().SetOutlineNumRule(m_aOldNumRule);
+}
+
+void SwUndoOutlineEdit::RedoImpl(::sw::UndoRedoContext& rContext)
+{
+ rContext.GetDoc().SetOutlineNumRule(m_aNewNumRule);
+}
+
+void SwUndoOutlineEdit::RepeatImpl(::sw::RepeatContext& rContext)
+{
+ rContext.GetDoc().SetOutlineNumRule(m_aNewNumRule);
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */