[Libreoffice-commits] core.git: 2 commits - sw/inc sw/source
Vasily Melenchuk (via logerrit)
logerrit at kemper.freedesktop.org
Thu Aug 5 16:34:39 UTC 2021
sw/inc/strings.hrc | 1 +
sw/inc/swundo.hxx | 3 ++-
sw/source/core/doc/docnum.cxx | 15 +++++++++++++++
sw/source/core/draw/dview.cxx | 5 +++++
sw/source/core/inc/UndoCore.hxx | 14 ++++++++++++++
sw/source/core/undo/undobj.cxx | 3 +++
sw/source/core/undo/unoutl.cxx | 24 ++++++++++++++++++++++++
7 files changed, 64 insertions(+), 1 deletion(-)
New commits:
commit 6e879d5f142766c941d1c3bafd17f67b78c1c9f4
Author: Vasily Melenchuk <vasily.melenchuk at cib.de>
AuthorDate: Thu Aug 5 11:16:58 2021 +0300
Commit: Thorsten Behrens <thorsten.behrens at allotropia.de>
CommitDate: Thu Aug 5 18:34:09 2021 +0200
tdf#99932: sw: fix for invalid anchor location for FLY_AT_CHAR mode
In such case anchor position depends on LastCharRect which can be
invalid because of happened frame movement, resize, etc.
Change-Id: I3d3c6318ee1ce5f4043e21ab091417d283c4260c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120059
Tested-by: Jenkins
Reviewed-by: Thorsten Behrens <thorsten.behrens at allotropia.de>
diff --git a/sw/source/core/draw/dview.cxx b/sw/source/core/draw/dview.cxx
index 276fbf922c9a..aa116d3d7bb7 100644
--- a/sw/source/core/draw/dview.cxx
+++ b/sw/source/core/draw/dview.cxx
@@ -236,6 +236,11 @@ void SwDrawView::AddCustomHdl()
// #i28701# - use last character rectangle saved at object
// in order to avoid a format of the anchor frame
SwAnchoredObject* pAnchoredObj = ::GetUserCall( pObj )->GetAnchoredObj( pObj );
+
+ // Invalidate/recalc LastCharRect which can contain invalid frame offset because
+ // of later frame changes
+ pAnchoredObj->CheckCharRectAndTopOfLine(false);
+
SwRect aAutoPos = pAnchoredObj->GetLastCharRect();
if ( aAutoPos.Height() )
{
commit 4edf3a964e764dcc40be729b8305476c5b968f1c
Author: Vasily Melenchuk <vasily.melenchuk at cib.de>
AuthorDate: Fri Jul 23 14:28:04 2021 +0300
Commit: Thorsten Behrens <thorsten.behrens at allotropia.de>
CommitDate: Thu Aug 5 18:33:54 2021 +0200
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 at allotropia.de>
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: */
More information about the Libreoffice-commits
mailing list