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

Noel Grandin noel.grandin at collabora.co.uk
Fri Mar 16 07:26:53 UTC 2018


 sw/source/core/access/acctable.cxx |   27 ++++++++++-----------------
 sw/source/core/access/acctable.hxx |    6 +++---
 2 files changed, 13 insertions(+), 20 deletions(-)

New commits:
commit 2a74684aab0def63cfd1afff6d2e8882e27b22df
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Thu Mar 15 15:40:26 2018 +0200

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

diff --git a/sw/source/core/access/acctable.cxx b/sw/source/core/access/acctable.cxx
index ba7f407f5721..4b363ce9bc77 100644
--- a/sw/source/core/access/acctable.cxx
+++ b/sw/source/core/access/acctable.cxx
@@ -691,7 +691,7 @@ SwAccessibleTable::~SwAccessibleTable()
 {
     SolarMutexGuard aGuard;
 
-    delete mpTableData;
+    mpTableData.reset();
 }
 
 void SwAccessibleTable::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew)
@@ -794,23 +794,21 @@ uno::Sequence< sal_Int8 > SAL_CALL SwAccessibleTable::getImplementationId()
 }
 
 // #i77106#
-SwAccessibleTableData_Impl* SwAccessibleTable::CreateNewTableData()
+std::unique_ptr<SwAccessibleTableData_Impl> SwAccessibleTable::CreateNewTableData()
 {
     const SwTabFrame* pTabFrame = static_cast<const SwTabFrame*>( GetFrame() );
-    return new SwAccessibleTableData_Impl( *GetMap(), pTabFrame, IsInPagePreview() );
+    return std::unique_ptr<SwAccessibleTableData_Impl>(new SwAccessibleTableData_Impl( *GetMap(), pTabFrame, IsInPagePreview() ));
 }
 
 void SwAccessibleTable::UpdateTableData()
 {
     // #i77106# - usage of new method <CreateNewTableData()>
-    delete mpTableData;
     mpTableData = CreateNewTableData();
 }
 
 void SwAccessibleTable::ClearTableData()
 {
-    delete mpTableData;
-    mpTableData = nullptr;
+    mpTableData.reset();
 }
 
 OUString SAL_CALL SwAccessibleTable::getAccessibleDescription()
@@ -1260,11 +1258,10 @@ void SwAccessibleTable::InvalidatePosOrSize( const SwRect& rOldBox )
     SolarMutexGuard aGuard;
 
     //need to update children
-    SwAccessibleTableData_Impl *pNewTableData = CreateNewTableData();
+    std::unique_ptr<SwAccessibleTableData_Impl> pNewTableData = CreateNewTableData();
     if( !pNewTableData->CompareExtents( GetTableData() ) )
     {
-        delete mpTableData;
-        mpTableData = pNewTableData;
+        mpTableData = std::move(pNewTableData);
         FireTableChangeEvent(*mpTableData);
     }
     if( HasTableData() )
@@ -1315,7 +1312,7 @@ void SwAccessibleTable::InvalidateChildPosOrSize( const SwAccessibleChild& rChil
                 "sw.a11y", "table has invalid position" );
         if( HasTableData() )
         {
-            SwAccessibleTableData_Impl *pNewTableData = CreateNewTableData(); // #i77106#
+            std::unique_ptr<SwAccessibleTableData_Impl> pNewTableData = CreateNewTableData(); // #i77106#
             if( !pNewTableData->CompareExtents( GetTableData() ) )
             {
                 if (pNewTableData->GetRowCount() != mpTableData->GetRowCount()
@@ -1347,11 +1344,7 @@ void SwAccessibleTable::InvalidateChildPosOrSize( const SwAccessibleChild& rChil
                 else
                     FireTableChangeEvent( GetTableData() );
                 ClearTableData();
-                mpTableData = pNewTableData;
-            }
-            else
-            {
-                delete pNewTableData;
+                mpTableData = std::move(pNewTableData);
             }
         }
     }
@@ -1739,10 +1732,10 @@ SwAccessibleTableColHeaders::SwAccessibleTableColHeaders(
     NotRegisteredAtAccessibleMap(); // #i85634#
 }
 
-SwAccessibleTableData_Impl* SwAccessibleTableColHeaders::CreateNewTableData()
+std::unique_ptr<SwAccessibleTableData_Impl> SwAccessibleTableColHeaders::CreateNewTableData()
 {
     const SwTabFrame* pTabFrame = static_cast<const SwTabFrame*>( GetFrame() );
-    return new SwAccessibleTableData_Impl( *(GetMap()), pTabFrame, IsInPagePreview(), true );
+    return std::unique_ptr<SwAccessibleTableData_Impl>(new SwAccessibleTableData_Impl( *(GetMap()), pTabFrame, IsInPagePreview(), true ));
 }
 
 void SwAccessibleTableColHeaders::Modify( const SfxPoolItem * /*pOld*/, const SfxPoolItem * /*pNew*/ )
diff --git a/sw/source/core/access/acctable.hxx b/sw/source/core/access/acctable.hxx
index 96b653c1b834..d9d6424ee7a8 100644
--- a/sw/source/core/access/acctable.hxx
+++ b/sw/source/core/access/acctable.hxx
@@ -43,7 +43,7 @@ class SwAccessibleTable :
         public css::accessibility::XAccessibleTableSelection,
         public SwClient
 {
-    SwAccessibleTableData_Impl *mpTableData;    // the table's data, prot by Sol-Mutex
+    std::unique_ptr<SwAccessibleTableData_Impl> mpTableData;    // the table's data, protected by SolarMutex
     OUString m_sDesc;
     const SwSelBoxes *GetSelBoxes() const;
 
@@ -69,7 +69,7 @@ protected:
         m_sDesc = sNewDesc;
     }
 
-    virtual SwAccessibleTableData_Impl* CreateNewTableData(); // #i77106#
+    virtual std::unique_ptr<SwAccessibleTableData_Impl> CreateNewTableData(); // #i77106#
 
     // force update of table data
     void UpdateTableData();
@@ -234,7 +234,7 @@ protected:
     virtual ~SwAccessibleTableColHeaders() override
     {}
 
-    virtual SwAccessibleTableData_Impl* CreateNewTableData() override;
+    virtual std::unique_ptr<SwAccessibleTableData_Impl> CreateNewTableData() override;
     virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) override;
 
 public:


More information about the Libreoffice-commits mailing list