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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Thu Jan 17 14:41:11 UTC 2019


 sw/source/core/doc/DocumentLinksAdministrationManager.cxx |   14 +++++++-------
 sw/source/core/docnode/section.cxx                        |   11 +++++------
 sw/source/core/inc/DocumentLinksAdministrationManager.hxx |    2 +-
 sw/source/core/layout/paintfrm.cxx                        |    6 +++---
 4 files changed, 16 insertions(+), 17 deletions(-)

New commits:
commit 0f73327c2fa96c2b2f0469c8fac0cc1130a9130f
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Thu Jan 17 12:32:18 2019 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Thu Jan 17 15:40:41 2019 +0100

    use unique_ptr in sw
    
    Change-Id: I899d050e76f705002e943ae5384cc8c928789df9
    Reviewed-on: https://gerrit.libreoffice.org/66512
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sw/source/core/doc/DocumentLinksAdministrationManager.cxx b/sw/source/core/doc/DocumentLinksAdministrationManager.cxx
index 659acaf4e97a..018ca3e0e6a6 100644
--- a/sw/source/core/doc/DocumentLinksAdministrationManager.cxx
+++ b/sw/source/core/doc/DocumentLinksAdministrationManager.cxx
@@ -440,7 +440,7 @@ DocumentLinksAdministrationManager::~DocumentLinksAdministrationManager()
 {
 }
 
-bool DocumentLinksAdministrationManager::SelectServerObj( const OUString& rStr, SwPaM*& rpPam, SwNodeRange*& rpRange ) const
+bool DocumentLinksAdministrationManager::SelectServerObj( const OUString& rStr, SwPaM*& rpPam, std::unique_ptr<SwNodeRange>& rpRange ) const
 {
     // Do we actually have the Item?
     rpPam = nullptr;
@@ -474,8 +474,8 @@ bool DocumentLinksAdministrationManager::SelectServerObj( const OUString& rStr,
             }
             if( aPara.pTableNd )
             {
-                rpRange = new SwNodeRange( *aPara.pTableNd, 0,
-                                *aPara.pTableNd->EndOfSectionNode(), 1 );
+                rpRange.reset(new SwNodeRange( *aPara.pTableNd, 0,
+                                *aPara.pTableNd->EndOfSectionNode(), 1 ));
                 return true;
             }
         }
@@ -488,7 +488,7 @@ bool DocumentLinksAdministrationManager::SelectServerObj( const OUString& rStr,
                 nullptr != ( pIdx = const_cast<SwNodeIndex*>(pFlyFormat->GetContent().GetContentIdx()) ) &&
                 !( pNd = &pIdx->GetNode())->IsNoTextNode() )
             {
-                rpRange = new SwNodeRange( *pNd, 1, *pNd->EndOfSectionNode() );
+                rpRange.reset(new SwNodeRange( *pNd, 1, *pNd->EndOfSectionNode() ));
                 return true;
             }
         }
@@ -508,7 +508,7 @@ bool DocumentLinksAdministrationManager::SelectServerObj( const OUString& rStr,
                 const SwOutlineNodes& rOutlNds = m_rDoc.GetNodes().GetOutLineNds();
                 SwOutlineNodes::size_type nTmpPos;
                 (void)rOutlNds.Seek_Entry( pNd, &nTmpPos );
-                rpRange = new SwNodeRange( aPos.nNode, 0, aPos.nNode );
+                rpRange.reset(new SwNodeRange( aPos.nNode, 0, aPos.nNode ));
 
                 // look for the section's end, now
                 for( ++nTmpPos;
@@ -555,8 +555,8 @@ bool DocumentLinksAdministrationManager::SelectServerObj( const OUString& rStr,
             }
             if( aPara.pSectNd )
             {
-                rpRange = new SwNodeRange( *aPara.pSectNd, 1,
-                                        *aPara.pSectNd->EndOfSectionNode() );
+                rpRange.reset(new SwNodeRange( *aPara.pSectNd, 1,
+                                        *aPara.pSectNd->EndOfSectionNode() ));
                 return true;
 
             }
diff --git a/sw/source/core/docnode/section.cxx b/sw/source/core/docnode/section.cxx
index 06424ac8aecf..92cc3839dd87 100644
--- a/sw/source/core/docnode/section.cxx
+++ b/sw/source/core/docnode/section.cxx
@@ -1274,7 +1274,7 @@ static void lcl_UpdateLinksInSect( SwBaseLink& rUpdLnk, SwSectionNode& rSectNd )
                 rSection.SetConnectFlag();
 
                 SwNodeIndex aSave( pPam->GetPoint()->nNode, -1 );
-                SwNodeRange* pCpyRg = nullptr;
+                std::unique_ptr<SwNodeRange> pCpyRg;
 
                 if( xDocSh->GetMedium() &&
                     rSection.GetLinkFilePassword().isEmpty() )
@@ -1321,13 +1321,12 @@ static void lcl_UpdateLinksInSect( SwBaseLink& rUpdLnk, SwSectionNode& rSectNd )
                     if( pCpyRg && pSrcDoc == pDoc &&
                         pCpyRg->aStart < rInsPos && rInsPos < pCpyRg->aEnd )
                     {
-                        delete pCpyRg;
-                        pCpyRg = nullptr;
+                        pCpyRg.reset();
                     }
                 }
                 else if( pSrcDoc != pDoc )
-                    pCpyRg = new SwNodeRange( pSrcDoc->GetNodes().GetEndOfExtras(), 2,
-                                          pSrcDoc->GetNodes().GetEndOfContent() );
+                    pCpyRg.reset(new SwNodeRange( pSrcDoc->GetNodes().GetEndOfExtras(), 2,
+                                          pSrcDoc->GetNodes().GetEndOfContent() ));
 
                 // #i81653#
                 // Update links of extern linked document or extern linked
@@ -1364,7 +1363,7 @@ static void lcl_UpdateLinksInSect( SwBaseLink& rUpdLnk, SwSectionNode& rSectNd )
                         pDoc->CorrAbs( aSave, *pPam->GetPoint(), 0, true );
                         pDoc->GetNodes().Delete( aSave );
                     }
-                    delete pCpyRg;
+                    pCpyRg.reset();
                 }
 
                 lcl_BreakSectionLinksInSect( *pSectNd );
diff --git a/sw/source/core/inc/DocumentLinksAdministrationManager.hxx b/sw/source/core/inc/DocumentLinksAdministrationManager.hxx
index 8294eaf86f4d..23bb91778f1a 100644
--- a/sw/source/core/inc/DocumentLinksAdministrationManager.hxx
+++ b/sw/source/core/inc/DocumentLinksAdministrationManager.hxx
@@ -61,7 +61,7 @@ public:
     bool LinksUpdated() const override;
 
     //Non-Interface method
-    bool SelectServerObj( const OUString& rStr, SwPaM*& rpPam, SwNodeRange*& rpRange ) const;
+    bool SelectServerObj( const OUString& rStr, SwPaM*& rpPam, std::unique_ptr<SwNodeRange>& rpRange ) const;
 
     virtual ~DocumentLinksAdministrationManager() override;
 
diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx
index 671916cf4194..dafc00ec4d34 100644
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -2910,9 +2910,9 @@ void SwRootFrame::PaintSwFrame(vcl::RenderContext& rRenderContext, SwRect const&
     else
         SwRootFrame::s_isInPaint = bResetRootPaint = true;
 
-    SwSavePaintStatics *pStatics = nullptr;
+    std::unique_ptr<SwSavePaintStatics> pStatics;
     if ( gProp.pSGlobalShell )
-        pStatics = new SwSavePaintStatics();
+        pStatics.reset(new SwSavePaintStatics());
     gProp.pSGlobalShell = pSh;
 
     if( !pSh->GetWin() )
@@ -3230,7 +3230,7 @@ void SwRootFrame::PaintSwFrame(vcl::RenderContext& rRenderContext, SwRect const&
     if ( bResetRootPaint )
         SwRootFrame::s_isInPaint = false;
     if ( pStatics )
-        delete pStatics;
+        pStatics.reset();
     else
     {
         gProp.pSProgress = nullptr;


More information about the Libreoffice-commits mailing list