sw/source/core/doc/docedt.cxx |   12 ++++++------
 sw/source/core/inc/mvsave.hxx |    7 ++++---
 2 files changed, 10 insertions(+), 9 deletions(-)

New commits:
commit c7e9a787a289c20e330df83e780da051f8646146
Author:     Noel Grandin <noelgran...@gmail.com>
AuthorDate: Sun Aug 7 21:02:33 2022 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Tue Aug 9 08:40:13 2022 +0200

    unique_ptr->optional in SaveRedlEndPosForRestore
    
    Change-Id: I355931b53457079c0bce3da26a99f250fdc11bac
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137997
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sw/source/core/doc/docedt.cxx b/sw/source/core/doc/docedt.cxx
index 63eb1f967690..122260ad1aab 100644
--- a/sw/source/core/doc/docedt.cxx
+++ b/sw/source/core/doc/docedt.cxx
@@ -281,9 +281,9 @@ SaveRedlEndPosForRestore::SaveRedlEndPosForRestore( const 
SwNodeIndex& rInsIdx,
           && *( pEnd = ( pRedl = 
rDest.getIDocumentRedlineAccess().GetRedlineTable()[ nFndPos ] )->End() ) == 
aSrcPos
           && *pRedl->Start() < aSrcPos )
     {
-        if( !mpSaveIndex )
+        if( !moSaveIndex )
         {
-            mpSaveIndex.reset(new SwNodeIndex( rInsIdx, -1 ));
+            moSaveIndex.emplace( rInsIdx, -1 );
         }
         mvSavArr.push_back( const_cast<SwPosition*>(pEnd) );
     }
@@ -291,20 +291,20 @@ SaveRedlEndPosForRestore::SaveRedlEndPosForRestore( const 
SwNodeIndex& rInsIdx,
 
 SaveRedlEndPosForRestore::~SaveRedlEndPosForRestore()
 {
-    mpSaveIndex.reset();
+    moSaveIndex.reset();
 }
 
 void SaveRedlEndPosForRestore::Restore()
 {
     if (mvSavArr.empty())
         return;
-    ++(*mpSaveIndex);
-    SwContentNode* pNode = mpSaveIndex->GetNode().GetContentNode();
+    ++(*moSaveIndex);
+    SwContentNode* pNode = moSaveIndex->GetNode().GetContentNode();
     // If there's no content node at the remembered position, we will not 
restore the old position
     // This may happen if a table (or section?) will be inserted.
     if( pNode )
     {
-        SwPosition aPos( *mpSaveIndex, pNode, mnSaveContent );
+        SwPosition aPos( *moSaveIndex, pNode, mnSaveContent );
         for( auto n = mvSavArr.size(); n; )
             *mvSavArr[ --n ] = aPos;
     }
diff --git a/sw/source/core/inc/mvsave.hxx b/sw/source/core/inc/mvsave.hxx
index 641e65342bef..ab0593db6173 100644
--- a/sw/source/core/inc/mvsave.hxx
+++ b/sw/source/core/inc/mvsave.hxx
@@ -21,8 +21,10 @@
 
 #include <vcl/keycod.hxx>
 #include <IDocumentMarkAccess.hxx>
-#include <vector>
+#include <ndindex.hxx>
 #include <deque>
+#include <optional>
+#include <vector>
 #include <o3tl/typed_flags_set.hxx>
 
 namespace sfx2 {
@@ -34,7 +36,6 @@ class SwDoc;
 class SwFormatAnchor;
 class SwFrameFormat;
 class SwContentIndex;
-class SwNodeIndex;
 class SwNodeRange;
 class SwPaM;
 class SwNode;
@@ -187,7 +188,7 @@ public:
 class SaveRedlEndPosForRestore
 {
     std::vector<SwPosition*> mvSavArr;
-    std::unique_ptr<SwNodeIndex> mpSaveIndex;
+    std::optional<SwNodeIndex> moSaveIndex;
     sal_Int32 mnSaveContent;
 
 public:

Reply via email to