summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2022-08-07 21:46:07 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-08-10 10:08:45 +0200
commit17073362f47425996575cefb682383f2710d3436 (patch)
tree5d20205e1b32ecedc312a3c9147f012ead430719
parentunique_ptr->optional in SwUndoDelete (diff)
downloadcore-17073362f47425996575cefb682383f2710d3436.tar.gz
core-17073362f47425996575cefb682383f2710d3436.zip
unique_ptr->optional in SwUndoInsert
Change-Id: Id351826427ef1ab6a292d7af96d3fa5bcf6ebb9b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137999 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--sw/source/core/inc/UndoInsert.hxx3
-rw-r--r--sw/source/core/undo/unins.cxx21
2 files changed, 12 insertions, 12 deletions
diff --git a/sw/source/core/inc/UndoInsert.hxx b/sw/source/core/inc/UndoInsert.hxx
index ae7b6c02dbd5..20bc4be7fdc5 100644
--- a/sw/source/core/inc/UndoInsert.hxx
+++ b/sw/source/core/inc/UndoInsert.hxx
@@ -26,6 +26,7 @@
#include <svx/svdtypes.hxx>
#include <rtl/ustring.hxx>
#include <swtypes.hxx>
+#include <ndindex.hxx>
#include <IDocumentContentOperations.hxx>
#include <optional>
@@ -41,7 +42,7 @@ enum class MirrorGraph;
class SwUndoInsert final : public SwUndo, private SwUndoSaveContent
{
/// start of Content in UndoNodes for Redo
- std::unique_ptr<SwNodeIndex> m_pUndoNodeIndex;
+ std::optional<SwNodeIndex> m_oUndoNodeIndex;
std::optional<OUString> maText;
std::optional<OUString> maUndoText;
std::unique_ptr<SwRedlineData> m_pRedlData;
diff --git a/sw/source/core/undo/unins.cxx b/sw/source/core/undo/unins.cxx
index 6ba42b5327cc..e923db1f2fe9 100644
--- a/sw/source/core/undo/unins.cxx
+++ b/sw/source/core/undo/unins.cxx
@@ -185,13 +185,13 @@ bool SwUndoInsert::CanGrouping( const SwPosition& rPos )
SwUndoInsert::~SwUndoInsert()
{
- if (m_pUndoNodeIndex) // delete the section from UndoNodes array
+ if (m_oUndoNodeIndex) // delete the section from UndoNodes array
{
// Insert saves the content in IconSection
- SwNodes& rUNds = m_pUndoNodeIndex->GetNodes();
- rUNds.Delete(*m_pUndoNodeIndex,
- rUNds.GetEndOfExtras().GetIndex() - m_pUndoNodeIndex->GetIndex());
- m_pUndoNodeIndex.reset();
+ SwNodes& rUNds = m_oUndoNodeIndex->GetNodes();
+ rUNds.Delete(*m_oUndoNodeIndex,
+ rUNds.GetEndOfExtras().GetIndex() - m_oUndoNodeIndex->GetIndex());
+ m_oUndoNodeIndex.reset();
}
else // the inserted text
{
@@ -268,9 +268,8 @@ void SwUndoInsert::UndoImpl(::sw::UndoRedoContext & rContext)
if (!maText)
{
- m_pUndoNodeIndex.reset(
- new SwNodeIndex(m_pDoc->GetNodes().GetEndOfContent()));
- MoveToUndoNds(aPaM, m_pUndoNodeIndex.get());
+ m_oUndoNodeIndex.emplace(m_pDoc->GetNodes().GetEndOfContent());
+ MoveToUndoNds(aPaM, &*m_oUndoNodeIndex);
}
m_nNode = aPaM.GetPoint()->GetNodeIndex();
m_nContent = aPaM.GetPoint()->GetContentIndex();
@@ -341,9 +340,9 @@ void SwUndoInsert::RedoImpl(::sw::UndoRedoContext & rContext)
}
else
{
- // re-insert content again (first detach m_pUndoNodeIndex!)
- SwNodeOffset const nMvNd = m_pUndoNodeIndex->GetIndex();
- m_pUndoNodeIndex.reset();
+ // re-insert content again (first detach m_oUndoNodeIndex!)
+ SwNodeOffset const nMvNd = m_oUndoNodeIndex->GetIndex();
+ m_oUndoNodeIndex.reset();
MoveFromUndoNds(*pTmpDoc, nMvNd, *pPam->GetMark());
}
m_nNode = pPam->GetMark()->GetNodeIndex();