summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2019-01-09 16:13:21 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2019-01-10 08:28:49 +0100
commita3f409262db9a9939d40e8f009f3e2396c78c020 (patch)
treec1ff860e5fca905e86cc75201530b6d0b414f869 /sw
parent6cd5d350db92b78f1d4b8a552e0b8972d48c16a0 (diff)
use unique_ptr in SwTextNode
Change-Id: I3f263a617e0ca48cbbe894a061910f1af767bb11 Reviewed-on: https://gerrit.libreoffice.org/66037 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw')
-rw-r--r--sw/inc/ndtxt.hxx4
-rw-r--r--sw/source/core/txtnode/ndtxt.cxx19
2 files changed, 9 insertions, 14 deletions
diff --git a/sw/inc/ndtxt.hxx b/sw/inc/ndtxt.hxx
index 4c0e6468fb9b..e10fd669eddc 100644
--- a/sw/inc/ndtxt.hxx
+++ b/sw/inc/ndtxt.hxx
@@ -91,8 +91,8 @@ class SW_DLLPUBLIC SwTextNode
Therefore: never access directly! */
std::unique_ptr<SwpHints> m_pSwpHints;
- mutable SwNodeNum* mpNodeNum; ///< Numbering for this paragraph.
- mutable SwNodeNum* mpNodeNumRLHidden; ///< Numbering for this paragraph (hidden redlines)
+ mutable std::unique_ptr<SwNodeNum> mpNodeNum; ///< Numbering for this paragraph.
+ mutable std::unique_ptr<SwNodeNum> mpNodeNumRLHidden; ///< Numbering for this paragraph (hidden redlines)
OUString m_Text;
diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx
index 07a69d87b0e7..7a2a4cdf0ee1 100644
--- a/sw/source/core/txtnode/ndtxt.cxx
+++ b/sw/source/core/txtnode/ndtxt.cxx
@@ -200,8 +200,6 @@ SwTextNode *SwNodes::MakeTextNode( const SwNodeIndex & rWhere,
SwTextNode::SwTextNode( const SwNodeIndex &rWhere, SwTextFormatColl *pTextColl, const SfxItemSet* pAutoAttr )
: SwContentNode( rWhere, SwNodeType::Text, pTextColl ),
- mpNodeNum( nullptr ),
- mpNodeNumRLHidden(nullptr),
m_Text(),
m_pParaIdleData_Impl(nullptr),
m_bContainsHiddenChars(false),
@@ -3976,20 +3974,19 @@ const SwNodeNum* SwTextNode::GetNum(SwRootFrame const*const pLayout) const
{
// invariant: it's only in list in Hide mode if it's in list in normal mode
assert(mpNodeNum || !mpNodeNumRLHidden);
- return pLayout && pLayout->IsHideRedlines() ? mpNodeNumRLHidden : mpNodeNum;
+ return pLayout && pLayout->IsHideRedlines() ? mpNodeNumRLHidden.get() : mpNodeNum.get();
}
void SwTextNode::DoNum(std::function<void (SwNodeNum &)> const& rFunc)
{
// temp. clear because GetActualListLevel() may be called and the assert
// there triggered during update, which is unhelpful
- SwNodeNum * pBackup(mpNodeNumRLHidden);
- mpNodeNumRLHidden = nullptr;
+ std::unique_ptr<SwNodeNum> pBackup = std::move(mpNodeNumRLHidden);
assert(mpNodeNum);
rFunc(*mpNodeNum);
if (pBackup)
{
- mpNodeNumRLHidden = pBackup;
+ mpNodeNumRLHidden = std::move(pBackup);
rFunc(*mpNodeNumRLHidden);
}
}
@@ -4289,7 +4286,7 @@ void SwTextNode::AddToList()
if (pList && GetNodes().IsDocNodes()) // not for undo nodes
{
assert(!mpNodeNum);
- mpNodeNum = new SwNodeNum(this, false);
+ mpNodeNum.reset(new SwNodeNum(this, false));
pList->InsertListItem(*mpNodeNum, false, GetAttrListLevel());
// iterate all frames & if there's one with hidden layout...
SwIterator<SwTextFrame, SwTextNode, sw::IteratorMode::UnwrapMulti> iter(*this);
@@ -4320,7 +4317,7 @@ void SwTextNode::AddToListRLHidden()
if (pList)
{
assert(!mpNodeNumRLHidden);
- mpNodeNumRLHidden = new SwNodeNum(this, true);
+ mpNodeNumRLHidden.reset(new SwNodeNum(this, true));
pList->InsertListItem(*mpNodeNumRLHidden, true, GetAttrListLevel());
}
}
@@ -4332,8 +4329,7 @@ void SwTextNode::RemoveFromList()
if ( IsInList() )
{
SwList::RemoveListItem( *mpNodeNum );
- delete mpNodeNum;
- mpNodeNum = nullptr;
+ mpNodeNum.reset();
SetWordCountDirty( true );
}
@@ -4345,8 +4341,7 @@ void SwTextNode::RemoveFromListRLHidden()
{
assert(mpNodeNumRLHidden->GetParent() || !GetNodes().IsDocNodes());
SwList::RemoveListItem(*mpNodeNumRLHidden);
- delete mpNodeNumRLHidden;
- mpNodeNumRLHidden = nullptr;
+ mpNodeNumRLHidden.reset();
SetWordCountDirty( true );
}