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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Wed Sep 12 11:06:56 UTC 2018


 sw/source/core/access/accmap.cxx |   27 ++++++++++++---------------
 sw/source/core/crsr/findtxt.cxx  |    6 +++---
 2 files changed, 15 insertions(+), 18 deletions(-)

New commits:
commit c5a9da1e47dffcf7c15229612bcdd48d7491ce3d
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Tue Sep 11 15:59:50 2018 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Wed Sep 12 13:06:37 2018 +0200

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

diff --git a/sw/source/core/crsr/findtxt.cxx b/sw/source/core/crsr/findtxt.cxx
index 8d97635b4b93..243699f5de91 100644
--- a/sw/source/core/crsr/findtxt.cxx
+++ b/sw/source/core/crsr/findtxt.cxx
@@ -516,13 +516,13 @@ bool SwPaM::DoSearch( const i18nutil::SearchOptions2& rSearchOpt, utl::TextSearc
         sCleanStr = lcl_CleanStr(*pNode->GetTextNode(), nEnd, nStart,
                         aFltArr, bRemoveSoftHyphens, bRemoveCommentAnchors);
 
-    SwScriptIterator* pScriptIter = nullptr;
+    std::unique_ptr<SwScriptIterator> pScriptIter;
     sal_uInt16 nSearchScript = 0;
     sal_uInt16 nCurrScript = 0;
 
     if (SearchAlgorithms2::APPROXIMATE == rSearchOpt.AlgorithmType2)
     {
-        pScriptIter = new SwScriptIterator( sCleanStr, nStart, bSrchForward );
+        pScriptIter.reset(new SwScriptIterator( sCleanStr, nStart, bSrchForward ));
         nSearchScript = g_pBreakIt->GetRealScriptOfText( rSearchOpt.searchString, 0 );
     }
 
@@ -606,7 +606,7 @@ bool SwPaM::DoSearch( const i18nutil::SearchOptions2& rSearchOpt, utl::TextSearc
         nStart = nEnd;
     }
 
-    delete pScriptIter;
+    pScriptIter.reset();
 
     if ( bFound )
         return true;
commit 7ee808ba894db274a474febe39ace46deebf8896
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Mon Sep 10 14:40:04 2018 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Wed Sep 12 13:06:33 2018 +0200

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

diff --git a/sw/source/core/access/accmap.cxx b/sw/source/core/access/accmap.cxx
index 2fd055fc9dbf..0257733cfccd 100644
--- a/sw/source/core/access/accmap.cxx
+++ b/sw/source/core/access/accmap.cxx
@@ -250,7 +250,7 @@ public:
 
     const ::accessibility::AccessibleShapeTreeInfo& GetInfo() const { return maInfo; }
 
-    SwAccessibleObjShape_Impl *Copy( size_t& rSize,
+    std::unique_ptr<SwAccessibleObjShape_Impl[]> Copy( size_t& rSize,
         const SwFEShell *pFESh,
         SwAccessibleObjShape_Impl  **pSelShape ) const;
 
@@ -271,12 +271,12 @@ SwAccessibleShapeMap_Impl::~SwAccessibleShapeMap_Impl()
         static_cast < SwDrawModellListener_Impl * >( xBrd.get() )->Dispose();
 }
 
-SwAccessibleObjShape_Impl
-    *SwAccessibleShapeMap_Impl::Copy(
+std::unique_ptr<SwAccessibleObjShape_Impl[]>
+    SwAccessibleShapeMap_Impl::Copy(
             size_t& rSize, const SwFEShell *pFESh,
             SwAccessibleObjShape_Impl **pSelStart ) const
 {
-    SwAccessibleObjShape_Impl *pShapes = nullptr;
+    std::unique_ptr<SwAccessibleObjShape_Impl[]> pShapes;
     SwAccessibleObjShape_Impl *pSelShape = nullptr;
 
     size_t nSelShapes = pFESh ? pFESh->IsObjSelected() : 0;
@@ -284,12 +284,12 @@ SwAccessibleObjShape_Impl
 
     if( rSize > 0 )
     {
-        pShapes = new SwAccessibleObjShape_Impl[rSize];
+        pShapes.reset(new SwAccessibleObjShape_Impl[rSize]);
 
         const_iterator aIter = maMap.cbegin();
         const_iterator aEndIter = maMap.cend();
 
-        SwAccessibleObjShape_Impl *pShape = pShapes;
+        SwAccessibleObjShape_Impl *pShape = pShapes.get();
         pSelShape = &(pShapes[rSize]);
         while( aIter != aEndIter )
         {
@@ -1099,7 +1099,7 @@ void SwAccessibleMap::InvalidateShapeSelection()
 //3.find the paragraph objects and set the selected state.
 void SwAccessibleMap::InvalidateShapeInParaSelection()
 {
-    SwAccessibleObjShape_Impl *pShapes = nullptr;
+    std::unique_ptr<SwAccessibleObjShape_Impl[]> pShapes;
     SwAccessibleObjShape_Impl *pSelShape = nullptr;
     size_t nShapes = 0;
 
@@ -1226,7 +1226,7 @@ void SwAccessibleMap::InvalidateShapeInParaSelection()
                     }
                     if( !bMarked )
                     {
-                        SwAccessibleObjShape_Impl  *pShape = pShapes;
+                        SwAccessibleObjShape_Impl  *pShape = pShapes.get();
                         size_t nNumShapes = nShapes;
                         while( nNumShapes )
                         {
@@ -1247,7 +1247,7 @@ void SwAccessibleMap::InvalidateShapeInParaSelection()
         }//else
     }
 
-    delete[] pShapes;
+    pShapes.reset();
 
     //Checked for FlyFrame
     if (mpFrameMap)
@@ -1416,7 +1416,7 @@ void SwAccessibleMap::InvalidateShapeInParaSelection()
 //Marge with DoInvalidateShapeFocus
 void SwAccessibleMap::DoInvalidateShapeSelection(bool bInvalidateFocusMode /*=false*/)
 {
-    SwAccessibleObjShape_Impl *pShapes = nullptr;
+    std::unique_ptr<SwAccessibleObjShape_Impl[]> pShapes;
     SwAccessibleObjShape_Impl *pSelShape = nullptr;
     size_t nShapes = 0;
 
@@ -1447,7 +1447,7 @@ void SwAccessibleMap::DoInvalidateShapeSelection(bool bInvalidateFocusMode /*=fa
 
     vcl::Window *pWin = GetShell()->GetWin();
     bool bFocused = pWin && pWin->HasFocus();
-    SwAccessibleObjShape_Impl *pShape = pShapes;
+    SwAccessibleObjShape_Impl *pShape = pShapes.get();
     int nShapeCount = nShapes;
     while( nShapeCount )
     {
@@ -1476,7 +1476,7 @@ void SwAccessibleMap::DoInvalidateShapeSelection(bool bInvalidateFocusMode /*=fa
         }
     }
 
-    pShape = pShapes;
+    pShape = pShapes.get();
 
     while( nShapes )
     {
@@ -1580,9 +1580,6 @@ void SwAccessibleMap::DoInvalidateShapeSelection(bool bInvalidateFocusMode /*=fa
             }
         }
     }
-
-    delete[] pShapes;
-
 }
 
 //Marge with DoInvalidateShapeSelection


More information about the Libreoffice-commits mailing list