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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Fri Jul 20 11:16:42 UTC 2018


 sw/source/filter/html/svxcss1.cxx |   35 +++++++++++------------------------
 sw/source/filter/html/svxcss1.hxx |    5 +++--
 2 files changed, 14 insertions(+), 26 deletions(-)

New commits:
commit f3c4af6383340886b94bdbc429b95916c104e09e
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Thu Jul 19 13:19:23 2018 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri Jul 20 13:16:17 2018 +0200

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

diff --git a/sw/source/filter/html/svxcss1.cxx b/sw/source/filter/html/svxcss1.cxx
index c7b832b540e1..aa6298da1a55 100644
--- a/sw/source/filter/html/svxcss1.cxx
+++ b/sw/source/filter/html/svxcss1.cxx
@@ -362,9 +362,6 @@ constexpr sal_uInt16 SvxCSS1PropertyInfo::UNSET_BORDER_DISTANCE;
 
 SvxCSS1PropertyInfo::SvxCSS1PropertyInfo()
 {
-    for(SvxCSS1BorderInfo* & rp : m_aBorderInfos)
-        rp = nullptr;
-
     Clear();
 }
 
@@ -400,24 +397,19 @@ SvxCSS1PropertyInfo::SvxCSS1PropertyInfo( const SvxCSS1PropertyInfo& rProp ) :
     m_ePageBreakBefore( rProp.m_ePageBreakBefore ),
     m_ePageBreakAfter( rProp.m_ePageBreakAfter )
 {
-    for( size_t i=0; i<SAL_N_ELEMENTS(m_aBorderInfos); ++i )
-        m_aBorderInfos[i] = rProp.m_aBorderInfos[i]
-                            ? new SvxCSS1BorderInfo( *rProp.m_aBorderInfos[i] )
-                            : nullptr;
+    for( size_t i=0; i<m_aBorderInfos.size(); ++i )
+        if (rProp.m_aBorderInfos[i])
+            m_aBorderInfos[i].reset( new SvxCSS1BorderInfo( *rProp.m_aBorderInfos[i] ) );
 }
 
 SvxCSS1PropertyInfo::~SvxCSS1PropertyInfo()
 {
-    DestroyBorderInfos();
 }
 
 void SvxCSS1PropertyInfo::DestroyBorderInfos()
 {
-    for(SvxCSS1BorderInfo* & rp : m_aBorderInfos)
-    {
-        delete rp;
-        rp = nullptr;
-    }
+    for(auto & rp : m_aBorderInfos)
+        rp.reset();
 }
 
 void SvxCSS1PropertyInfo::Clear()
@@ -469,15 +461,10 @@ void SvxCSS1PropertyInfo::Merge( const SvxCSS1PropertyInfo& rProp )
     if( rProp.m_bTextIndent )
         m_bTextIndent = true;
 
-    for( size_t i=0; i<SAL_N_ELEMENTS(m_aBorderInfos); ++i )
+    for( size_t i=0; i<m_aBorderInfos.size(); ++i )
     {
         if( rProp.m_aBorderInfos[i] )
-        {
-            if( m_aBorderInfos[i] )
-                delete m_aBorderInfos[i];
-
-            m_aBorderInfos[i] = new SvxCSS1BorderInfo( *rProp.m_aBorderInfos[i] );
-        }
+            m_aBorderInfos[i].reset( new SvxCSS1BorderInfo( *rProp.m_aBorderInfos[i] ) );
     }
 
     if( UNSET_BORDER_DISTANCE != rProp.m_nTopBorderDistance )
@@ -548,9 +535,9 @@ SvxCSS1BorderInfo *SvxCSS1PropertyInfo::GetBorderInfo( SvxBoxItemLine nLine, boo
     }
 
     if( !m_aBorderInfos[nPos] && bCreate )
-        m_aBorderInfos[nPos] = new SvxCSS1BorderInfo;
+        m_aBorderInfos[nPos].reset( new SvxCSS1BorderInfo );
 
-    return m_aBorderInfos[nPos];
+    return m_aBorderInfos[nPos].get();
 }
 
 void SvxCSS1PropertyInfo::CopyBorderInfo( SvxBoxItemLine nSrcLine, SvxBoxItemLine nDstLine,
@@ -596,7 +583,7 @@ void SvxCSS1PropertyInfo::SetBoxItem( SfxItemSet& rItemSet,
                 m_nLeftBorderDistance != UNSET_BORDER_DISTANCE ||
                 m_nRightBorderDistance != UNSET_BORDER_DISTANCE;
 
-    for( size_t i=0; !bChg && i<SAL_N_ELEMENTS(m_aBorderInfos); ++i )
+    for( size_t i=0; !bChg && i<m_aBorderInfos.size(); ++i )
         bChg = m_aBorderInfos[i]!=nullptr;
 
     if( !bChg )
@@ -622,7 +609,7 @@ void SvxCSS1PropertyInfo::SetBoxItem( SfxItemSet& rItemSet,
     if( pInfo )
         pInfo->SetBorderLine( SvxBoxItemLine::RIGHT, aBoxItem );
 
-    for( size_t i=0; i<SAL_N_ELEMENTS(m_aBorderInfos); ++i )
+    for( size_t i=0; i<m_aBorderInfos.size(); ++i )
     {
         SvxBoxItemLine nLine = SvxBoxItemLine::TOP;
         sal_uInt16 nDist = 0;
diff --git a/sw/source/filter/html/svxcss1.hxx b/sw/source/filter/html/svxcss1.hxx
index c5b6b68af433..aa0e9ec5e1ba 100644
--- a/sw/source/filter/html/svxcss1.hxx
+++ b/sw/source/filter/html/svxcss1.hxx
@@ -25,9 +25,10 @@
 #include "parcss1.hxx"
 #include <o3tl/typed_flags_set.hxx>
 
+#include <array>
+#include <map>
 #include <memory>
 #include <vector>
-#include <map>
 
 class SfxItemPool;
 class SvxBoxItem;
@@ -96,7 +97,7 @@ namespace editeng { class SvxBorderLine; }
 struct SvxCSS1BorderInfo;
 class SvxCSS1PropertyInfo
 {
-    SvxCSS1BorderInfo *m_aBorderInfos[4];
+    std::array<std::unique_ptr<SvxCSS1BorderInfo>,4> m_aBorderInfos;
 
     void DestroyBorderInfos();
 


More information about the Libreoffice-commits mailing list