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>
This commit is contained in:
parent
029e607ef0
commit
c7e9a787a2
2 changed files with 10 additions and 9 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue