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

loplugin:useuniqueptr in SwGrammarContact

Change-Id: I13b346751a001871fe2db04c0b40a0201d55352b
Reviewed-on: https://gerrit.libreoffice.org/57304
Tested-by: Jenkins
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 816bfa20
......@@ -41,7 +41,7 @@ public:
SwGrammarMarkUp() : SwWrongList( WRONGLIST_GRAMMAR ) {}
virtual ~SwGrammarMarkUp() override;
virtual SwWrongList* Clone() override;
virtual std::unique_ptr<SwWrongList> Clone() override;
virtual void CopyFrom( const SwWrongList& rCopy ) override;
/* SwWrongList::Move() + handling of maSentence */
......
......@@ -259,7 +259,7 @@ public:
SwWrongList( WrongListType eType );
virtual ~SwWrongList();
virtual SwWrongList* Clone();
virtual std::unique_ptr<SwWrongList> Clone();
virtual void CopyFrom( const SwWrongList& rCopy );
WrongListType GetWrongListType() const { return meType; }
......
......@@ -23,9 +23,9 @@ SwGrammarMarkUp::~SwGrammarMarkUp()
{
}
SwWrongList* SwGrammarMarkUp::Clone()
std::unique_ptr<SwWrongList> SwGrammarMarkUp::Clone()
{
SwWrongList* pClone = new SwGrammarMarkUp();
std::unique_ptr<SwWrongList> pClone(new SwGrammarMarkUp());
pClone->CopyFrom( *this );
return pClone;
}
......
......@@ -62,9 +62,9 @@ SwWrongList::~SwWrongList()
ClearList();
}
SwWrongList* SwWrongList::Clone()
std::unique_ptr<SwWrongList> SwWrongList::Clone()
{
SwWrongList* pClone = new SwWrongList( meType );
std::unique_ptr<SwWrongList> pClone(new SwWrongList( meType ));
pClone->CopyFrom( *this );
return pClone;
}
......@@ -78,7 +78,7 @@ void SwWrongList::CopyFrom( const SwWrongList& rCopy )
for(SwWrongArea & i : maList)
{
if( i.mpSubList )
i.mpSubList = i.mpSubList->Clone();
i.mpSubList = i.mpSubList->Clone().release();
}
}
......
......@@ -41,14 +41,14 @@
class SwGrammarContact : public IGrammarContact, public SwClient
{
Timer aTimer;
SwGrammarMarkUp *mpProxyList;
std::unique_ptr<SwGrammarMarkUp> mpProxyList;
bool mbFinished;
SwTextNode* getMyTextNode() { return static_cast<SwTextNode*>(GetRegisteredIn()); }
DECL_LINK( TimerRepaint, Timer *, void );
public:
SwGrammarContact();
virtual ~SwGrammarContact() override { aTimer.Stop(); delete mpProxyList; }
virtual ~SwGrammarContact() override { aTimer.Stop(); }
// (pure) virtual functions of IGrammarContact
virtual void updateCursorPosition( const SwPosition& rNewPos ) override;
......@@ -73,7 +73,7 @@ IMPL_LINK( SwGrammarContact, TimerRepaint, Timer *, pTimer, void )
pTimer->Stop();
if( GetRegisteredIn() )
{ //Replace the old wrong list by the proxy list and repaint all frames
getMyTextNode()->SetGrammarCheck( mpProxyList );
getMyTextNode()->SetGrammarCheck( mpProxyList.get() );
mpProxyList = nullptr;
SwTextFrame::repaintTextFrames( *getMyTextNode() );
}
......@@ -91,7 +91,7 @@ void SwGrammarContact::updateCursorPosition( const SwPosition& rNewPos )
{
if( mpProxyList )
{ // replace old list by the proxy list and repaint
getMyTextNode()->SetGrammarCheck( mpProxyList );
getMyTextNode()->SetGrammarCheck( mpProxyList.get() );
SwTextFrame::repaintTextFrames( *getMyTextNode() );
}
EndListeningAll();
......@@ -112,22 +112,21 @@ SwGrammarMarkUp* SwGrammarContact::getGrammarCheck( SwTextNode& rTextNode, bool
{
if( mbFinished )
{
delete mpProxyList;
mpProxyList = nullptr;
mpProxyList.reset();
}
if( !mpProxyList )
{
if( rTextNode.GetGrammarCheck() )
mpProxyList = static_cast<SwGrammarMarkUp*>(rTextNode.GetGrammarCheck()->Clone());
mpProxyList.reset( static_cast<SwGrammarMarkUp*>(rTextNode.GetGrammarCheck()->Clone().release()) );
else
{
mpProxyList = new SwGrammarMarkUp();
mpProxyList.reset( new SwGrammarMarkUp() );
mpProxyList->SetInvalid( 0, COMPLETE_STRING );
}
}
mbFinished = false;
}
pRet = mpProxyList;
pRet = mpProxyList.get();
}
else
{
......@@ -153,8 +152,7 @@ void SwGrammarContact::Modify( const SfxPoolItem* pOld, const SfxPoolItem * )
{ // if my current paragraph dies, I throw the proxy list away
aTimer.Stop();
EndListeningAll();
delete mpProxyList;
mpProxyList = nullptr;
mpProxyList.reset();
}
}
......
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