[Libreoffice-commits] core.git: editeng/source include/editeng

Noel Grandin noel.grandin at collabora.co.uk
Mon Feb 5 06:52:32 UTC 2018


 editeng/source/rtf/svxrtf.cxx |   15 ++++-----------
 include/editeng/svxrtf.hxx    |   10 +++++-----
 2 files changed, 9 insertions(+), 16 deletions(-)

New commits:
commit cf4ee7b872a67fa91bbbaa18a8effde71d6523c9
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Mon Jan 29 11:00:54 2018 +0200

    loplugin:useuniqueptr in SvxRTFParser
    
    Change-Id: I0d01e8612ff4e8eb1eb53a817c8fb586b61aa5bb
    Reviewed-on: https://gerrit.libreoffice.org/49150
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
    Tested-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/editeng/source/rtf/svxrtf.cxx b/editeng/source/rtf/svxrtf.cxx
index b9d6dd33a887..297320a5658e 100644
--- a/editeng/source/rtf/svxrtf.cxx
+++ b/editeng/source/rtf/svxrtf.cxx
@@ -73,8 +73,8 @@ SvxRTFParser::SvxRTFParser( SfxItemPool& rPool, SvStream& rIn )
     , bIsLeftToRightDef( true)
     , bIsInReadStyleTab( false)
 {
-    pDfltFont = new vcl::Font;
-    pDfltColor = new Color;
+    pDfltFont.reset( new vcl::Font );
+    pDfltColor.reset( new Color );
 }
 
 SvxRTFParser::~SvxRTFParser()
@@ -83,18 +83,11 @@ SvxRTFParser::~SvxRTFParser()
         ClearColorTbl();
     if( !aAttrStack.empty() )
         ClearAttrStack();
-
-    delete pRTFDefaults;
-
-    delete pInsPos;
-    delete pDfltFont;
-    delete pDfltColor;
 }
 
 void SvxRTFParser::SetInsPos( const EditPosition& rNew )
 {
-    delete pInsPos;
-    pInsPos = rNew.Clone();
+    pInsPos.reset( rNew.Clone() );
 }
 
 SvParserState SvxRTFParser::CallParser()
@@ -914,7 +907,7 @@ const SfxItemSet& SvxRTFParser::GetRTFDefaults()
 {
     if( !pRTFDefaults )
     {
-        pRTFDefaults = new SfxItemSet( *pAttrPool, &aWhichMap[0] );
+        pRTFDefaults.reset( new SfxItemSet( *pAttrPool, &aWhichMap[0] ) );
         sal_uInt16 nId;
         if( 0 != ( nId = aPardMap.nScriptSpace ))
         {
diff --git a/include/editeng/svxrtf.hxx b/include/editeng/svxrtf.hxx
index 73e885553a43..8273e64b6f12 100644
--- a/include/editeng/svxrtf.hxx
+++ b/include/editeng/svxrtf.hxx
@@ -187,11 +187,11 @@ class EDITENG_DLLPUBLIC SvxRTFParser : public SvRTFParser
     RTFPardAttrMapIds aPardMap;
     std::vector<sal_uInt16> aWhichMap;
 
-    EditPosition* pInsPos;
+    std::unique_ptr<EditPosition> pInsPos;
     SfxItemPool* pAttrPool;
-    Color*  pDfltColor;
-    vcl::Font*   pDfltFont;
-    SfxItemSet *pRTFDefaults;
+    std::unique_ptr<Color>  pDfltColor;
+    std::unique_ptr<vcl::Font>   pDfltFont;
+    std::unique_ptr<SfxItemSet> pRTFDefaults;
 
     int     nDfltFont;
 
@@ -355,7 +355,7 @@ public:
 
 inline const Color& SvxRTFParser::GetColor( size_t nId ) const
 {
-    Color* pColor = pDfltColor;
+    Color* pColor = pDfltColor.get();
     if( nId < aColorTbl.size() )
         pColor = aColorTbl[ nId ];
     return *pColor;


More information about the Libreoffice-commits mailing list