diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2022-08-07 21:02:33 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-08-09 08:40:13 +0200 |
commit | c7e9a787a289c20e330df83e780da051f8646146 (patch) | |
tree | c5a069b32958e25a3fe982b63db84515b31b1d37 | |
parent | 029e607ef095be49d0d2e843cc183a99c587deab (diff) |
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.grandin@collabora.co.uk>
-rw-r--r-- | sw/source/core/doc/docedt.cxx | 12 | ||||
-rw-r--r-- | sw/source/core/inc/mvsave.hxx | 7 |
2 files changed, 10 insertions, 9 deletions
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: |