sw/source/core/inc/UndoDelete.hxx | 3 ++- sw/source/core/inc/UndoInsert.hxx | 3 ++- sw/source/core/undo/undel.cxx | 10 +++++----- sw/source/core/undo/unins.cxx | 21 ++++++++++----------- 4 files changed, 19 insertions(+), 18 deletions(-)
New commits: commit 17073362f47425996575cefb682383f2710d3436 Author: Noel Grandin <noelgran...@gmail.com> AuthorDate: Sun Aug 7 21:46:07 2022 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Wed Aug 10 10:08:45 2022 +0200 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.gran...@collabora.co.uk> 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(); commit 296110d547903ef67f6d1048c044378d30cb1406 Author: Noel Grandin <noelgran...@gmail.com> AuthorDate: Sun Aug 7 22:30:49 2022 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Wed Aug 10 10:08:33 2022 +0200 unique_ptr->optional in SwUndoDelete Change-Id: I29cc59bb7283e86d4045cd854d7e9a4f056c3361 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138000 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sw/source/core/inc/UndoDelete.hxx b/sw/source/core/inc/UndoDelete.hxx index 2491af658c61..70e91367cb6b 100644 --- a/sw/source/core/inc/UndoDelete.hxx +++ b/sw/source/core/inc/UndoDelete.hxx @@ -21,6 +21,7 @@ #define INCLUDED_SW_SOURCE_CORE_INC_UNDODELETE_HXX #include <undobj.hxx> +#include <ndindex.hxx> #include <rtl/ustring.hxx> #include <memory> #include <optional> @@ -39,7 +40,7 @@ class SwUndoDelete final , private SwUndRng , private SwUndoSaveContent { - std::unique_ptr<SwNodeIndex> m_pMvStt; // Position of Nodes in UndoNodes-Array + std::optional<SwNodeIndex> m_oMvStt; // Position of Nodes in UndoNodes-Array std::optional<OUString> m_aSttStr, m_aEndStr; std::unique_ptr<SwRedlineSaveDatas> m_pRedlSaveData; std::shared_ptr< ::sfx2::MetadatableUndo > m_pMetadataUndoStart; diff --git a/sw/source/core/undo/undel.cxx b/sw/source/core/undo/undel.cxx index 82d5e9635b89..f60f8911815e 100644 --- a/sw/source/core/undo/undel.cxx +++ b/sw/source/core/undo/undel.cxx @@ -385,7 +385,7 @@ SwUndoDelete::SwUndoDelete( // Step 3: Moving into UndoArray... m_nNode = rNds.GetEndOfContent().GetIndex(); rDocNds.MoveNodes( aRg, rNds, SwNodeIndex( rNds.GetEndOfContent() )); - m_pMvStt.reset( new SwNodeIndex( rNds, m_nNode ) ); + m_oMvStt.emplace( rNds, m_nNode ); // remember difference! m_nNode = rNds.GetEndOfContent().GetIndex() - m_nNode; @@ -602,11 +602,11 @@ bool SwUndoDelete::CanGrouping( SwDoc& rDoc, const SwPaM& rDelPam ) SwUndoDelete::~SwUndoDelete() { - if( m_pMvStt ) // Delete also the selection from UndoNodes array + if( m_oMvStt ) // Delete also the selection from UndoNodes array { // Insert saves content in IconSection - m_pMvStt->GetNode().GetNodes().Delete( *m_pMvStt, m_nNode ); - m_pMvStt.reset(); + m_oMvStt->GetNode().GetNodes().Delete( *m_oMvStt, m_nNode ); + m_oMvStt.reset(); } m_pRedlSaveData.reset(); } @@ -969,7 +969,7 @@ void SwUndoDelete::UndoImpl(::sw::UndoRedoContext & rContext) if( bNodeMove ) { - SwNodeRange aRange( *m_pMvStt, SwNodeOffset(0), *m_pMvStt, m_nNode ); + SwNodeRange aRange( *m_oMvStt, SwNodeOffset(0), *m_oMvStt, m_nNode ); SwNodeIndex aCopyIndex( aPos.nNode, -1 ); rDoc.GetUndoManager().GetUndoNodes().Copy_(aRange, aPos.nNode, // sw_redlinehide: delay creating frames: the flags on the