Kaydet (Commit) 76d5b9d0 authored tarafından Michael Stahl's avatar Michael Stahl

sw: convert DELETEZ to unique_ptr in SwTextNode

Change-Id: I0df469be660c20513f82b465412ffcf31b0a0f63
Reviewed-on: https://gerrit.libreoffice.org/49990Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarMichael Stahl <mstahl@redhat.com>
üst 665e646c
......@@ -82,7 +82,7 @@ class SW_DLLPUBLIC SwTextNode: public SwContentNode, public ::sfx2::Metadatable
/** May be 0. It is only then not 0 if it contains hard attributes.
Therefore: never access directly! */
SwpHints *m_pSwpHints;
std::unique_ptr<SwpHints> m_pSwpHints;
mutable SwNodeNum* mpNodeNum; ///< Numbering for this paragraph.
......@@ -213,8 +213,8 @@ public:
/// getters for SwpHints
inline SwpHints &GetSwpHints();
inline const SwpHints &GetSwpHints() const;
SwpHints *GetpSwpHints() { return m_pSwpHints; }
const SwpHints *GetpSwpHints() const { return m_pSwpHints; }
SwpHints *GetpSwpHints() { return m_pSwpHints.get(); }
const SwpHints *GetpSwpHints() const { return m_pSwpHints.get(); }
bool HasHints() const { return m_pSwpHints != nullptr; }
inline SwpHints &GetOrCreateSwpHints();
......@@ -810,7 +810,7 @@ inline SwpHints& SwTextNode::GetOrCreateSwpHints()
{
if ( !m_pSwpHints )
{
m_pSwpHints = new SwpHints;
m_pSwpHints.reset(new SwpHints);
}
return *m_pSwpHints;
}
......@@ -819,7 +819,7 @@ inline void SwTextNode::TryDeleteSwpHints()
{
if ( m_pSwpHints && m_pSwpHints->CanBeDeleted() )
{
DELETEZ( m_pSwpHints );
m_pSwpHints.reset();
}
}
......
......@@ -198,7 +198,6 @@ SwTextNode *SwNodes::MakeTextNode( const SwNodeIndex & rWhere,
SwTextNode::SwTextNode( const SwNodeIndex &rWhere, SwTextFormatColl *pTextColl, const SfxItemSet* pAutoAttr )
: SwContentNode( rWhere, SwNodeType::Text, pTextColl ),
m_pSwpHints( nullptr ),
mpNodeNum( nullptr ),
m_Text(),
m_pParaIdleData_Impl(nullptr),
......@@ -244,8 +243,7 @@ SwTextNode::~SwTextNode()
if ( m_pSwpHints )
{
// do not delete attributes twice when those delete their content
SwpHints* pTmpHints = m_pSwpHints;
m_pSwpHints = nullptr;
std::unique_ptr<SwpHints> pTmpHints(std::move(m_pSwpHints));
for( size_t j = pTmpHints->Count(); j; )
{
......@@ -253,8 +251,6 @@ SwTextNode::~SwTextNode()
// if would delete itself
DestroyAttr( pTmpHints->Get( --j ) );
}
delete pTmpHints;
}
// must be removed from outline nodes by now
......@@ -445,8 +441,7 @@ SwContentNode *SwTextNode::SplitContentNode( const SwPosition &rPos )
{
if ( pNode->m_pSwpHints->CanBeDeleted() )
{
delete pNode->m_pSwpHints;
pNode->m_pSwpHints = nullptr;
pNode->m_pSwpHints.reset();
}
else
{
......@@ -1398,7 +1393,7 @@ SwTextNode::GetTextAttrsAt(sal_Int32 const nIndex, sal_uInt16 const nWhich) cons
{
assert(nWhich >= RES_TXTATR_BEGIN && nWhich < RES_TXTATR_END);
std::vector<SwTextAttr *> ret;
lcl_GetTextAttrs(& ret, nullptr, m_pSwpHints, nIndex, nWhich, DEFAULT);
lcl_GetTextAttrs(&ret, nullptr, m_pSwpHints.get(), nIndex, nWhich, DEFAULT);
return ret;
}
......@@ -1416,7 +1411,7 @@ SwTextNode::GetTextAttrAt(sal_Int32 const nIndex, sal_uInt16 const nWhich,
// "GetTextAttrAt() will give wrong result for this hint!")
SwTextAttr * pRet(nullptr);
lcl_GetTextAttrs(nullptr, & pRet, m_pSwpHints, nIndex, nWhich, eMode);
lcl_GetTextAttrs(nullptr, & pRet, m_pSwpHints.get(), nIndex, nWhich, eMode);
return pRet;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment