Kaydet (Commit) ba2a084d authored tarafından Noel Grandin's avatar Noel Grandin

loplugin:useuniqueptr in SwAttrIter

Change-Id: I204250a02ac88cc36267b79ef1d70cd361230752
Reviewed-on: https://gerrit.libreoffice.org/57245
Tested-by: Jenkins
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 7c6ca00e
......@@ -69,6 +69,35 @@ using namespace ::com::sun::star;
static sal_Int32 GetNextAttrImpl(SwTextNode const* pTextNode,
size_t nStartIndex, size_t nEndIndex, sal_Int32 nPosition);
SwAttrIter::SwAttrIter(SwTextNode const * pTextNode)
: m_pViewShell(nullptr)
, m_pFont(nullptr)
, m_pScriptInfo(nullptr)
, m_pLastOut(nullptr)
, m_nChgCnt(0)
, m_nStartIndex(0)
, m_nEndIndex(0)
, m_nPosition(0)
, m_nPropFont(0)
, m_pTextNode(pTextNode)
, m_pMergedPara(nullptr)
{
m_aMagicNo[SwFontScript::Latin] = m_aMagicNo[SwFontScript::CJK] = m_aMagicNo[SwFontScript::CTL] = nullptr;
}
SwAttrIter::SwAttrIter(SwTextNode& rTextNode, SwScriptInfo& rScrInf, SwTextFrame const*const pFrame)
: m_pViewShell(nullptr)
, m_pFont(nullptr)
, m_pScriptInfo(nullptr)
, m_pLastOut(nullptr)
, m_nChgCnt(0)
, m_nPropFont(0)
, m_pTextNode(&rTextNode)
, m_pMergedPara(nullptr)
{
CtorInitAttrIter(rTextNode, rScrInf, pFrame);
}
void SwAttrIter::Chg( SwTextAttr const *pHt )
{
assert(pHt && m_pFont && "No attribute of font available for change");
......@@ -92,7 +121,7 @@ void SwAttrIter::Rst( SwTextAttr const *pHt )
SwAttrIter::~SwAttrIter()
{
delete m_pRedline;
m_pRedline.reset();
delete m_pFont;
}
......
......@@ -42,14 +42,14 @@ protected:
SwAttrHandler m_aAttrHandler;
SwViewShell *m_pViewShell;
SwFont *m_pFont;
SwFont* m_pFont;
SwScriptInfo* m_pScriptInfo;
private:
VclPtr<OutputDevice> m_pLastOut;
/// count currently open hints, redlines, ext-input
short m_nChgCnt;
SwRedlineItr *m_pRedline;
std::unique_ptr<SwRedlineItr> m_pRedline;
/// current iteration index in HintStarts
size_t m_nStartIndex;
/// current iteration index in HintEnds
......@@ -72,44 +72,17 @@ protected:
void Chg( SwTextAttr const *pHt );
void Rst( SwTextAttr const *pHt );
void CtorInitAttrIter(SwTextNode& rTextNode, SwScriptInfo& rScrInf, SwTextFrame const* pFrame = nullptr);
explicit SwAttrIter(SwTextNode const * pTextNode)
: m_pViewShell(nullptr)
, m_pFont(nullptr)
, m_pScriptInfo(nullptr)
, m_pLastOut(nullptr)
, m_nChgCnt(0)
, m_pRedline(nullptr)
, m_nStartIndex(0)
, m_nEndIndex(0)
, m_nPosition(0)
, m_nPropFont(0)
, m_pTextNode(pTextNode)
, m_pMergedPara(nullptr)
{
m_aMagicNo[SwFontScript::Latin] = m_aMagicNo[SwFontScript::CJK] = m_aMagicNo[SwFontScript::CTL] = nullptr;
}
explicit SwAttrIter(SwTextNode const * pTextNode);
public:
/// All subclasses of this always have a SwTextFrame passed to the
/// constructor, but SwAttrIter itself may be created without a
/// SwTextFrame in certain special cases via this ctor here
SwAttrIter(SwTextNode& rTextNode, SwScriptInfo& rScrInf, SwTextFrame const*const pFrame = nullptr)
: m_pViewShell(nullptr)
, m_pFont(nullptr)
, m_pScriptInfo(nullptr)
, m_pLastOut(nullptr)
, m_nChgCnt(0)
, m_pRedline(nullptr)
, m_nPropFont(0)
, m_pTextNode(&rTextNode)
, m_pMergedPara(nullptr)
{
CtorInitAttrIter(rTextNode, rScrInf, pFrame);
}
SwAttrIter(SwTextNode& rTextNode, SwScriptInfo& rScrInf, SwTextFrame const*const pFrame = nullptr);
virtual ~SwAttrIter();
SwRedlineItr *GetRedln() { return m_pRedline; }
SwRedlineItr *GetRedln() { return m_pRedline.get(); }
// The parameter returns the position of the next change before or at the
// char position.
TextFrameIndex GetNextAttr() const;
......
......@@ -272,13 +272,13 @@ void SwAttrIter::CtorInitAttrIter(SwTextNode & rTextNode,
Seek( TextFrameIndex(0) );
}
m_pRedline = new SwRedlineItr( rTextNode, *m_pFont, m_aAttrHandler, nRedlPos,
m_pRedline.reset(new SwRedlineItr( rTextNode, *m_pFont, m_aAttrHandler, nRedlPos,
m_pMergedPara
? SwRedlineItr::Mode::Hide
: bShow
? SwRedlineItr::Mode::Show
: SwRedlineItr::Mode::Ignore,
pArr, pExtInp ? pExtInp->Start() : nullptr);
pArr, pExtInp ? pExtInp->Start() : nullptr));
if( m_pRedline->IsOn() )
++m_nChgCnt;
......
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