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

Noel Grandin noel.grandin at collabora.co.uk
Tue Jul 10 06:31:18 UTC 2018


 sw/source/core/inc/txmsrt.hxx   |    4 ++--
 sw/source/core/text/pordrop.hxx |    6 +++---
 sw/source/core/text/txtdrop.cxx |   18 +++++++++---------
 sw/source/core/tox/txmsrt.cxx   |    8 ++++----
 4 files changed, 18 insertions(+), 18 deletions(-)

New commits:
commit 6b8a1a6fa77f910a2537958799bbdbac96e0bb57
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Wed Jul 4 10:51:01 2018 +0200

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

diff --git a/sw/source/core/text/pordrop.hxx b/sw/source/core/text/pordrop.hxx
index 7d2293d17648..648ed03f4c38 100644
--- a/sw/source/core/text/pordrop.hxx
+++ b/sw/source/core/text/pordrop.hxx
@@ -61,7 +61,7 @@ public:
 class SwDropPortion : public SwTextPortion
 {
     friend class SwDropCapCache;
-    SwDropPortionPart* pPart; // due to script/attribute changes
+    std::unique_ptr<SwDropPortionPart> pPart; // due to script/attribute changes
     sal_uInt16 nLines;          // Line count
     sal_uInt16 nDropHeight;     // Height
     sal_uInt16 nDropDescent;    // Distance to the next line
@@ -91,8 +91,8 @@ public:
     sal_uInt16 GetDropDescent() const { return nDropDescent; }
     sal_uInt16 GetDropLeft() const { return Width() + nFix; }
 
-    SwDropPortionPart* GetPart() const { return pPart; }
-    void SetPart( SwDropPortionPart* pNew ) { pPart = pNew; }
+    SwDropPortionPart* GetPart() const { return pPart.get(); }
+    void SetPart( std::unique_ptr<SwDropPortionPart> pNew ) { pPart = std::move(pNew); }
 
     void SetY( short nNew )  { nY = nNew; }
 
diff --git a/sw/source/core/text/txtdrop.cxx b/sw/source/core/text/txtdrop.cxx
index 6ced927d91cb..53558c50b230 100644
--- a/sw/source/core/text/txtdrop.cxx
+++ b/sw/source/core/text/txtdrop.cxx
@@ -117,7 +117,7 @@ SwDropPortion::SwDropPortion( const sal_uInt16 nLineCnt,
 
 SwDropPortion::~SwDropPortion()
 {
-    delete pPart;
+    pPart.reset();
     if( pBlink )
         pBlink->Delete( this );
 }
@@ -635,15 +635,16 @@ SwDropPortion *SwTextFormatter::NewDropPortion( SwTextFormatInfo &rInf )
         if ( nNextChg > nPorLen )
             nNextChg = nPorLen;
 
-        SwDropPortionPart* pPart =
-                new SwDropPortionPart( *pTmpFnt, nNextChg - nTmpIdx );
+        std::unique_ptr<SwDropPortionPart> pPart(
+                new SwDropPortionPart( *pTmpFnt, nNextChg - nTmpIdx ) );
+        auto pPartTemp = pPart.get();
 
         if ( ! pCurrPart )
-            pDropPor->SetPart( pPart );
+            pDropPor->SetPart( std::move(pPart) );
         else
-            pCurrPart->SetFollow( std::unique_ptr<SwDropPortionPart>(pPart) );
+            pCurrPart->SetFollow( std::move(pPart) );
 
-        pCurrPart = pPart;
+        pCurrPart = pPartTemp;
     }
 
     SetPaintDrop( true );
@@ -1008,7 +1009,7 @@ bool SwDropPortion::Format( SwTextFormatInfo &rInf )
         const long nOldX = rInf.X();
         {
             SwDropSave aSave( rInf );
-            SwDropPortionPart* pCurrPart = pPart;
+            SwDropPortionPart* pCurrPart = pPart.get();
 
             while ( pCurrPart )
             {
@@ -1057,8 +1058,7 @@ bool SwDropPortion::Format( SwTextFormatInfo &rInf )
 
             // And now for another round
             nDropHeight = nLines = 0;
-            delete pPart;
-            pPart = nullptr;
+            pPart.reset();
 
             // Meanwhile use normal formatting
             bFull = SwTextPortion::Format( rInf );
commit 208f91edea145fd76ffd67f238079f11c4142082
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Wed Jul 4 10:47:56 2018 +0200

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

diff --git a/sw/source/core/inc/txmsrt.hxx b/sw/source/core/inc/txmsrt.hxx
index 2bb74d78d725..61091af43b8a 100644
--- a/sw/source/core/inc/txmsrt.hxx
+++ b/sw/source/core/inc/txmsrt.hxx
@@ -69,8 +69,8 @@ struct TextAndReading
 
 class SwTOXInternational
 {
-    IndexEntrySupplierWrapper* m_pIndexWrapper;
-    CharClass*                 m_pCharClass;
+    std::unique_ptr<IndexEntrySupplierWrapper> m_pIndexWrapper;
+    std::unique_ptr<CharClass>                 m_pCharClass;
     LanguageType               m_eLang;
     OUString                   m_sSortAlgorithm;
     SwTOIOptions               m_nOptions;
diff --git a/sw/source/core/tox/txmsrt.cxx b/sw/source/core/tox/txmsrt.cxx
index ffc6e222081c..41b66760ec20 100644
--- a/sw/source/core/tox/txmsrt.cxx
+++ b/sw/source/core/tox/txmsrt.cxx
@@ -69,7 +69,7 @@ SwTOXInternational::SwTOXInternational( const SwTOXInternational& rIntl ) :
 
 void SwTOXInternational::Init()
 {
-    m_pIndexWrapper = new IndexEntrySupplierWrapper();
+    m_pIndexWrapper.reset( new IndexEntrySupplierWrapper() );
 
     const lang::Locale aLcl( LanguageTag::convertToLocale( m_eLang ) );
     m_pIndexWrapper->SetLocale( aLcl );
@@ -86,14 +86,14 @@ void SwTOXInternational::Init()
     else
         m_pIndexWrapper->LoadAlgorithm( aLcl, m_sSortAlgorithm, SW_COLLATOR_IGNORES );
 
-    m_pCharClass = new CharClass( LanguageTag( aLcl ));
+    m_pCharClass.reset( new CharClass( LanguageTag( aLcl )) );
 
 }
 
 SwTOXInternational::~SwTOXInternational()
 {
-    delete m_pCharClass;
-    delete m_pIndexWrapper;
+    m_pCharClass.reset();
+    m_pIndexWrapper.reset();
 }
 
 OUString SwTOXInternational::ToUpper( const OUString& rStr, sal_Int32 nPos ) const


More information about the Libreoffice-commits mailing list