[Libreoffice-commits] core.git: sw/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Fri Sep 14 07:25:05 UTC 2018


 sw/source/core/text/frmcrsr.cxx |   13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

New commits:
commit 2327d5cfc1cb938b5b7e1c6388d460a1236f4665
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Thu Sep 13 11:03:56 2018 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri Sep 14 09:24:40 2018 +0200

    loplugin:useuniqueptr in SwTextFrame
    
    Change-Id: I34fac0560a1a408df421365379b15e64c96c9a15
    Reviewed-on: https://gerrit.libreoffice.org/60450
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sw/source/core/text/frmcrsr.cxx b/sw/source/core/text/frmcrsr.cxx
index 8cb7a18aedcf..a017ce95bc1e 100644
--- a/sw/source/core/text/frmcrsr.cxx
+++ b/sw/source/core/text/frmcrsr.cxx
@@ -567,8 +567,9 @@ bool SwTextFrame::GetCursorOfst_(SwPosition* pPos, const Point& rPoint,
     if ( IsRightToLeft() )
         SwitchRTLtoLTR( const_cast<Point&>(rPoint) );
 
-    SwFillData *pFillData = ( pCMS && pCMS->m_pFill ) ?
-                        new SwFillData( pCMS, pPos, getFrameArea(), rPoint ) : nullptr;
+    std::unique_ptr<SwFillData> pFillData;
+    if ( pCMS && pCMS->m_pFill )
+        pFillData.reset(new SwFillData( pCMS, pPos, getFrameArea(), rPoint ));
 
     if ( IsEmpty() )
     {
@@ -652,7 +653,6 @@ bool SwTextFrame::GetCursorOfst_(SwPosition* pPos, const Point& rPoint,
     }
 
     const_cast<Point&>(rPoint) = aOldPoint;
-    delete pFillData;
 
     return true;
 }
@@ -1349,7 +1349,7 @@ void SwTextFrame::FillCursorPos( SwFillData& rFill ) const
             return;
         }
     }
-    SwFont *pFnt;
+    std::unique_ptr<SwFont> pFnt;
     SwTextFormatColl* pColl = GetTextNodeForParaProps()->GetTextColl();
     SwTwips nFirst = GetTextNodeForParaProps()->GetSwAttrSet().GetULSpace().GetLower();
     SwTwips nDiff = rFill.Y() - getFrameArea().Bottom();
@@ -1368,12 +1368,12 @@ void SwTextFrame::FillCursorPos( SwFillData& rFill ) const
         aSet.Put( *GetTextNodeForParaProps()->GetpSwAttrSet() );
         aSet.SetParent( pSet );
         pSet = &aSet;
-        pFnt = new SwFont( pSet, &GetDoc().getIDocumentSettingAccess() );
+        pFnt.reset(new SwFont( pSet, &GetDoc().getIDocumentSettingAccess() ));
     }
     else
     {
         SwFontAccess aFontAccess( pColl, pSh );
-        pFnt = new SwFont( aFontAccess.Get()->GetFont() );
+        pFnt.reset(new SwFont( aFontAccess.Get()->GetFont() ));
         pFnt->CheckFontCacheId( pSh, pFnt->GetActual() );
     }
     OutputDevice* pOut = pSh->GetOut();
@@ -1675,7 +1675,6 @@ void SwTextFrame::FillCursorPos( SwFillData& rFill ) const
         }
     }
     const_cast<SwCursorMoveState*>(rFill.pCMS)->m_bFillRet = bFill;
-    delete pFnt;
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list