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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Tue Jul 17 06:39:52 UTC 2018


 sw/source/filter/basflt/fltini.cxx |    5 ---
 sw/source/filter/html/htmlctxt.cxx |   58 ++++++++++++++++++++++++++++++++++---
 sw/source/filter/html/swhtml.hxx   |   51 ++------------------------------
 sw/source/filter/inc/fltini.hxx    |    2 -
 4 files changed, 60 insertions(+), 56 deletions(-)

New commits:
commit 8f32dc03302e2435aab8e876fb874a1c4897d536
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Mon Jul 16 13:58:43 2018 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Tue Jul 17 08:39:42 2018 +0200

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

diff --git a/sw/source/filter/html/htmlctxt.cxx b/sw/source/filter/html/htmlctxt.cxx
index 0157ef999e66..074ca6e2ebd8 100644
--- a/sw/source/filter/html/htmlctxt.cxx
+++ b/sw/source/filter/html/htmlctxt.cxx
@@ -110,15 +110,65 @@ std::shared_ptr<HTMLAttrTable> const & HTMLAttrContext_SaveDoc::GetAttrTab( bool
 HTMLAttrContext_SaveDoc *HTMLAttrContext::GetSaveDocContext( bool bCreate )
 {
     if( !m_pSaveDocContext && bCreate )
-        m_pSaveDocContext = new HTMLAttrContext_SaveDoc;
+        m_pSaveDocContext.reset(new HTMLAttrContext_SaveDoc);
 
-    return m_pSaveDocContext;
+    return m_pSaveDocContext.get();
+}
+
+HTMLAttrContext::HTMLAttrContext( HtmlTokenId nTokn, sal_uInt16 nPoolId, const OUString& rClass,
+                  bool bDfltColl ) :
+    m_aClass( rClass ),
+    m_pSaveDocContext( nullptr ),
+    m_nToken( nTokn ),
+    m_nTextFormatColl( nPoolId ),
+    m_nLeftMargin( 0 ),
+    m_nRightMargin( 0 ),
+    m_nFirstLineIndent( 0 ),
+    m_nUpperSpace( 0 ),
+    m_nLowerSpace( 0 ),
+    m_eAppend( AM_NONE ),
+    m_bLRSpaceChanged( false ),
+    m_bULSpaceChanged( false ),
+    m_bDefaultTextFormatColl( bDfltColl ),
+    m_bSpansSection( false ),
+    m_bPopStack( false ),
+    m_bFinishPREListingXMP( false ),
+    m_bRestartPRE( false ),
+    m_bRestartXMP( false ),
+    m_bRestartListing( false ),
+    m_bHeaderOrFooter( false )
+{}
+
+HTMLAttrContext::HTMLAttrContext( HtmlTokenId nTokn ) :
+    m_pSaveDocContext( nullptr ),
+    m_nToken( nTokn ),
+    m_nTextFormatColl( 0 ),
+    m_nLeftMargin( 0 ),
+    m_nRightMargin( 0 ),
+    m_nFirstLineIndent( 0 ),
+    m_nUpperSpace( 0 ),
+    m_nLowerSpace( 0 ),
+    m_eAppend( AM_NONE ),
+    m_bLRSpaceChanged( false ),
+    m_bULSpaceChanged( false ),
+    m_bDefaultTextFormatColl( false ),
+    m_bSpansSection( false ),
+    m_bPopStack( false ),
+    m_bFinishPREListingXMP( false ),
+    m_bRestartPRE( false ),
+    m_bRestartXMP( false ),
+    m_bRestartListing( false ),
+    m_bHeaderOrFooter( false )
+{}
+
+HTMLAttrContext::~HTMLAttrContext()
+{
+    m_pSaveDocContext.reset();
 }
 
 void HTMLAttrContext::ClearSaveDocContext()
 {
-    delete m_pSaveDocContext;
-    m_pSaveDocContext = nullptr;
+    m_pSaveDocContext.reset();
 }
 
 void SwHTMLParser::SplitAttrTab( const SwPosition& rNewPos )
diff --git a/sw/source/filter/html/swhtml.hxx b/sw/source/filter/html/swhtml.hxx
index ae6a91ad3250..0867f3e4d0ed 100644
--- a/sw/source/filter/html/swhtml.hxx
+++ b/sw/source/filter/html/swhtml.hxx
@@ -207,7 +207,7 @@ class HTMLAttrContext
 
     OUString    m_aClass;          // context class
 
-    HTMLAttrContext_SaveDoc *m_pSaveDocContext;
+    std::unique_ptr<HTMLAttrContext_SaveDoc> m_pSaveDocContext;
     std::unique_ptr<SfxItemSet> m_pFrameItemSet;
 
     HtmlTokenId m_nToken;         // the token of the context
@@ -238,52 +238,9 @@ public:
     void ClearSaveDocContext();
 
     HTMLAttrContext( HtmlTokenId nTokn, sal_uInt16 nPoolId, const OUString& rClass,
-                      bool bDfltColl=false ) :
-        m_aClass( rClass ),
-        m_pSaveDocContext( nullptr ),
-        m_nToken( nTokn ),
-        m_nTextFormatColl( nPoolId ),
-        m_nLeftMargin( 0 ),
-        m_nRightMargin( 0 ),
-        m_nFirstLineIndent( 0 ),
-        m_nUpperSpace( 0 ),
-        m_nLowerSpace( 0 ),
-        m_eAppend( AM_NONE ),
-        m_bLRSpaceChanged( false ),
-        m_bULSpaceChanged( false ),
-        m_bDefaultTextFormatColl( bDfltColl ),
-        m_bSpansSection( false ),
-        m_bPopStack( false ),
-        m_bFinishPREListingXMP( false ),
-        m_bRestartPRE( false ),
-        m_bRestartXMP( false ),
-        m_bRestartListing( false ),
-        m_bHeaderOrFooter( false )
-    {}
-
-    explicit HTMLAttrContext( HtmlTokenId nTokn ) :
-        m_pSaveDocContext( nullptr ),
-        m_nToken( nTokn ),
-        m_nTextFormatColl( 0 ),
-        m_nLeftMargin( 0 ),
-        m_nRightMargin( 0 ),
-        m_nFirstLineIndent( 0 ),
-        m_nUpperSpace( 0 ),
-        m_nLowerSpace( 0 ),
-        m_eAppend( AM_NONE ),
-        m_bLRSpaceChanged( false ),
-        m_bULSpaceChanged( false ),
-        m_bDefaultTextFormatColl( false ),
-        m_bSpansSection( false ),
-        m_bPopStack( false ),
-        m_bFinishPREListingXMP( false ),
-        m_bRestartPRE( false ),
-        m_bRestartXMP( false ),
-        m_bRestartListing( false ),
-        m_bHeaderOrFooter( false )
-    {}
-
-    ~HTMLAttrContext() { ClearSaveDocContext(); }
+                      bool bDfltColl=false );
+    explicit HTMLAttrContext( HtmlTokenId nTokn );
+    ~HTMLAttrContext();
 
     HtmlTokenId GetToken() const { return m_nToken; }
 
commit 4c9423b3e033a4eabf76b3bffb344385e770a4b6
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Mon Jul 16 12:24:19 2018 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Tue Jul 17 08:39:28 2018 +0200

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

diff --git a/sw/source/filter/basflt/fltini.cxx b/sw/source/filter/basflt/fltini.cxx
index 64f607331d69..57427cde8e42 100644
--- a/sw/source/filter/basflt/fltini.cxx
+++ b/sw/source/filter/basflt/fltini.cxx
@@ -283,7 +283,7 @@ void StgReader::SetFltName( const OUString& rFltNm )
 
 SwRelNumRuleSpaces::SwRelNumRuleSpaces( SwDoc const & rDoc, bool bNDoc )
 {
-    pNumRuleTable = new SwNumRuleTable;
+    pNumRuleTable.reset(new SwNumRuleTable);
     pNumRuleTable->reserve(8);
     if( !bNDoc )
         pNumRuleTable->insert( pNumRuleTable->begin(),
@@ -293,10 +293,7 @@ SwRelNumRuleSpaces::SwRelNumRuleSpaces( SwDoc const & rDoc, bool bNDoc )
 SwRelNumRuleSpaces::~SwRelNumRuleSpaces()
 {
     if( pNumRuleTable )
-    {
         pNumRuleTable->clear();
-        delete pNumRuleTable;
-    }
 }
 
 void CalculateFlySize(SfxItemSet& rFlySet, const SwNodeIndex& rAnchor,
diff --git a/sw/source/filter/inc/fltini.hxx b/sw/source/filter/inc/fltini.hxx
index 70cafaa46e94..ca3f9e347e7f 100644
--- a/sw/source/filter/inc/fltini.hxx
+++ b/sw/source/filter/inc/fltini.hxx
@@ -64,7 +64,7 @@ void GetWW8Writer( const OUString&, const OUString&, WriterRef& );
 // of the NumRule must be subtracted from the paragraph indentation.
 class SW_DLLPUBLIC SwRelNumRuleSpaces
 {
-    SwNumRuleTable* pNumRuleTable;  // list of all named NumRules
+    std::unique_ptr<SwNumRuleTable> pNumRuleTable;  // list of all named NumRules
 
 public:
     SwRelNumRuleSpaces( SwDoc const & rDoc, bool bNewDoc );


More information about the Libreoffice-commits mailing list