svl/source/fsstor/fsstorage.cxx   |   20 +++-----------------
 sw/inc/htmltbl.hxx                |   20 ++++++++++----------
 sw/source/core/doc/htmltbl.cxx    |   14 ++------------
 sw/source/filter/html/htmltab.cxx |   22 ++++++++++------------
 4 files changed, 25 insertions(+), 51 deletions(-)

New commits:
commit d21d14c112312c639383ba9d9091380327dc0717
Author: Noel Grandin <noel.gran...@collabora.co.uk>
Date:   Wed Apr 19 11:17:52 2017 +0200

    loplugin:inlinefields in SwHTMLTableLayout
    
    and make the memory management a little more obvious with
    std::unique_ptr.
    
    Change-Id: Ie0dad6a52f70896e144cc396d39c10e9cbff4316
    Reviewed-on: https://gerrit.libreoffice.org/36667
    Tested-by: Jenkins <c...@libreoffice.org>
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sw/inc/htmltbl.hxx b/sw/inc/htmltbl.hxx
index 5dfb2eb56b57..4aec0834be6e 100644
--- a/sw/inc/htmltbl.hxx
+++ b/sw/inc/htmltbl.hxx
@@ -173,8 +173,8 @@ class SwHTMLTableLayout
 {
     Timer m_aResizeTimer;             ///< Timer for DelayedResize.
 
-    SwHTMLTableLayoutColumn **m_aColumns;
-    SwHTMLTableLayoutCell **m_aCells;
+    std::vector<std::unique_ptr<SwHTMLTableLayoutColumn>> m_aColumns;
+    std::vector<std::unique_ptr<SwHTMLTableLayoutCell>>   m_aCells;
 
     const SwTable *m_pSwTable;            ///< SwTable (Top-Table only).
     SwTableBox *m_pLeftFillerBox;         ///< Left filler-box (table in table 
only).
@@ -278,10 +278,10 @@ public:
                     sal_uInt16 nParentInhSpace=0 );
 
     inline SwHTMLTableLayoutColumn *GetColumn( sal_uInt16 nCol ) const;
-    inline void SetColumn( SwHTMLTableLayoutColumn *pCol, sal_uInt16 nCol );
+    inline void SetColumn( std::unique_ptr<SwHTMLTableLayoutColumn> pCol, 
sal_uInt16 nCol );
 
     inline SwHTMLTableLayoutCell *GetCell( sal_uInt16 nRow, sal_uInt16 nCol ) 
const;
-    inline void SetCell( SwHTMLTableLayoutCell *pCell, sal_uInt16 nRow, 
sal_uInt16 nCol );
+    inline void SetCell( std::unique_ptr<SwHTMLTableLayoutCell> pCell, 
sal_uInt16 nRow, sal_uInt16 nCol );
 
     void SetLeftFillerBox( SwTableBox *pBox ) { m_pLeftFillerBox = pBox; }
     void SetRightFillerBox( SwTableBox *pBox ) { m_pRightFillerBox = pBox; }
@@ -410,7 +410,7 @@ inline sal_uInt16 SwHTMLTableLayout::GetInhCellSpace( 
sal_uInt16 nCol,
 
 inline SwHTMLTableLayoutColumn *SwHTMLTableLayout::GetColumn( sal_uInt16 nCol 
) const
 {
-    return m_aColumns[nCol];
+    return m_aColumns[nCol].get();
 }
 
 inline void SwHTMLTableLayoutColumn::SetWidthOption( sal_uInt16 nWidth )
@@ -419,20 +419,20 @@ inline void SwHTMLTableLayoutColumn::SetWidthOption( 
sal_uInt16 nWidth )
     bRelWidthOption = true;
 }
 
-inline void SwHTMLTableLayout::SetColumn( SwHTMLTableLayoutColumn *pCol, 
sal_uInt16 nCol )
+inline void SwHTMLTableLayout::SetColumn( 
std::unique_ptr<SwHTMLTableLayoutColumn> pCol, sal_uInt16 nCol )
 {
-    m_aColumns[nCol] = pCol;
+    m_aColumns[nCol] = std::move(pCol);
 }
 
 inline SwHTMLTableLayoutCell *SwHTMLTableLayout::GetCell( sal_uInt16 nRow, 
sal_uInt16 nCol ) const
 {
-    return m_aCells[nRow*m_nCols+nCol];
+    return m_aCells[nRow*m_nCols+nCol].get();
 }
 
-inline void SwHTMLTableLayout::SetCell( SwHTMLTableLayoutCell *pCell,
+inline void SwHTMLTableLayout::SetCell( std::unique_ptr<SwHTMLTableLayoutCell> 
pCell,
                                sal_uInt16 nRow, sal_uInt16 nCol )
 {
-    m_aCells[nRow*m_nCols+nCol] = pCell;
+    m_aCells[nRow*m_nCols+nCol] = std::move(pCell);
 }
 
 inline long SwHTMLTableLayout::GetBrowseWidthMin() const
diff --git a/sw/source/core/doc/htmltbl.cxx b/sw/source/core/doc/htmltbl.cxx
index b29806314fa9..e15f70aae6e3 100644
--- a/sw/source/core/doc/htmltbl.cxx
+++ b/sw/source/core/doc/htmltbl.cxx
@@ -168,8 +168,8 @@ SwHTMLTableLayout::SwHTMLTableLayout( const SwTable * 
pTable,
                                       sal_uInt16 nRightBWidth,
                                       sal_uInt16 nInhLeftBWidth,
                                       sal_uInt16 nInhRightBWidth )
-    : m_aColumns( new SwHTMLTableLayoutColumn*[nCls] )
-    , m_aCells( new SwHTMLTableLayoutCell*[static_cast<size_t>(nRws)*nCls] )
+    : m_aColumns( nCls )
+    , m_aCells( static_cast<size_t>(nRws)*nCls )
     , m_pSwTable( pTable )
     , m_pLeftFillerBox( nullptr )
     , m_pRightFillerBox( nullptr )
@@ -216,16 +216,6 @@ SwHTMLTableLayout::SwHTMLTableLayout( const SwTable * 
pTable,
 
 SwHTMLTableLayout::~SwHTMLTableLayout()
 {
-    sal_uInt16 i;
-
-    for( i = 0; i < m_nCols; i++ )
-        delete m_aColumns[i];
-    delete[] m_aColumns;
-
-    sal_uInt16 nCount = m_nRows*m_nCols;
-    for( i=0; i<nCount; i++ )
-        delete m_aCells[i];
-    delete[] m_aCells;
 }
 
 /// The border widths are calculated like in Netscape:
diff --git a/sw/source/filter/html/htmltab.cxx 
b/sw/source/filter/html/htmltab.cxx
index 131b6b282a60..3aee21ce5391 100644
--- a/sw/source/filter/html/htmltab.cxx
+++ b/sw/source/filter/html/htmltab.cxx
@@ -261,7 +261,7 @@ public:
     // Is the cell filled or protected ?
     bool IsUsed() const { return pContents!=nullptr || bProtected; }
 
-    SwHTMLTableLayoutCell *CreateLayoutInfo();
+    std::unique_ptr<SwHTMLTableLayoutCell> CreateLayoutInfo();
 
     bool IsCovered() const { return mbCovered; }
 };
@@ -355,7 +355,7 @@ public:
     inline SwFrameFormat *GetFrameFormat( bool bBorderLine,
                                 sal_Int16 eVertOri ) const;
 
-    SwHTMLTableLayoutColumn *CreateLayoutInfo();
+    std::unique_ptr<SwHTMLTableLayoutColumn> CreateLayoutInfo();
 };
 
 // HTML table
@@ -758,12 +758,12 @@ inline bool HTMLTableCell::GetValue( double& rValue ) 
const
     return bHasValue;
 }
 
-SwHTMLTableLayoutCell *HTMLTableCell::CreateLayoutInfo()
+std::unique_ptr<SwHTMLTableLayoutCell> HTMLTableCell::CreateLayoutInfo()
 {
     SwHTMLTableLayoutCnts *pCntInfo = pContents ? 
pContents->CreateLayoutInfo() : nullptr;
 
-    return new SwHTMLTableLayoutCell( pCntInfo, nRowSpan, nColSpan, nWidth,
-                                      bRelWidth, bNoWrap );
+    return std::unique_ptr<SwHTMLTableLayoutCell>(new SwHTMLTableLayoutCell( 
pCntInfo, nRowSpan, nColSpan, nWidth,
+                                      bRelWidth, bNoWrap ));
 }
 
 HTMLTableRow::HTMLTableRow(sal_uInt16 const nCells)
@@ -885,9 +885,9 @@ inline void HTMLTableColumn::SetWidth( sal_uInt16 nWdth, 
bool bRelWdth )
     bRelWidth = bRelWdth;
 }
 
-inline SwHTMLTableLayoutColumn *HTMLTableColumn::CreateLayoutInfo()
+inline std::unique_ptr<SwHTMLTableLayoutColumn> 
HTMLTableColumn::CreateLayoutInfo()
 {
-    return new SwHTMLTableLayoutColumn( nWidth, bRelWidth, bLeftBorder );
+    return std::unique_ptr<SwHTMLTableLayoutColumn>(new 
SwHTMLTableLayoutColumn( nWidth, bRelWidth, bLeftBorder ));
 }
 
 inline sal_uInt16 HTMLTableColumn::GetFrameFormatIdx( bool bBorderLine,
@@ -1118,10 +1118,8 @@ SwHTMLTableLayout *HTMLTable::CreateLayoutInfo()
         HTMLTableRow *const pRow = (*m_pRows)[i].get();
         for( sal_uInt16 j=0; j<m_nCols; j++ )
         {
-            SwHTMLTableLayoutCell *pLayoutCell =
-                pRow->GetCell(j)->CreateLayoutInfo();
-
-            m_pLayoutInfo->SetCell( pLayoutCell, i, j );
+            m_pLayoutInfo->SetCell( pRow->GetCell(j)->CreateLayoutInfo(), i, j 
);
+            SwHTMLTableLayoutCell* pLayoutCell = m_pLayoutInfo->GetCell(i, j );
 
             if( bExportable )
             {
@@ -1137,7 +1135,7 @@ SwHTMLTableLayout *HTMLTable::CreateLayoutInfo()
     m_pLayoutInfo->SetExportable( bExportable );
 
     for( i=0; i<m_nCols; i++ )
-        m_pLayoutInfo->SetColumn( ((*m_pColumns)[i])->CreateLayoutInfo(), i );
+        m_pLayoutInfo->SetColumn( (*m_pColumns)[i]->CreateLayoutInfo(), i );
 
     return m_pLayoutInfo;
 }
commit 4a553b9a5830ecc752efe0b0f2692bac0f0f3f8c
Author: Noel Grandin <noel.gran...@collabora.co.uk>
Date:   Wed Apr 19 10:49:07 2017 +0200

    loplugin:inlinefields in FSStorage_Impl
    
    Change-Id: I6650d39f8f4c2f271e3936d590fe7eb500e674fe
    Reviewed-on: https://gerrit.libreoffice.org/36665
    Tested-by: Jenkins <c...@libreoffice.org>
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/svl/source/fsstor/fsstorage.cxx b/svl/source/fsstor/fsstorage.cxx
index 999a5a52e121..b79b626a94f4 100644
--- a/svl/source/fsstor/fsstorage.cxx
+++ b/svl/source/fsstor/fsstorage.cxx
@@ -69,7 +69,7 @@ struct FSStorage_Impl
 {
     OUString m_aURL;
 
-    ::ucbhelper::Content* m_pContent;
+    ::ucbhelper::Content m_aContent;
     sal_Int32 m_nMode;
 
     ::comphelper::OInterfaceContainerHelper2* m_pListenersContainer; // list 
of listeners
@@ -80,7 +80,7 @@ struct FSStorage_Impl
 
     FSStorage_Impl( const ::ucbhelper::Content& aContent, sal_Int32 nMode, 
uno::Reference< uno::XComponentContext > const & xContext )
     : m_aURL( aContent.getURL() )
-    , m_pContent( new ::ucbhelper::Content( aContent ) )
+    , m_aContent( aContent )
     , m_nMode( nMode )
     , m_pListenersContainer( nullptr )
     , m_pTypeCollection( nullptr )
@@ -100,7 +100,6 @@ FSStorage_Impl::~FSStorage_Impl()
 {
     delete m_pListenersContainer;
     delete m_pTypeCollection;
-    delete m_pContent;
 }
 
 FSStorage::FSStorage( const ::ucbhelper::Content& aContent,
@@ -148,20 +147,7 @@ bool FSStorage::MakeFolderNoUI( const OUString& rFolder )
 ::ucbhelper::Content* FSStorage::GetContent()
 {
     ::osl::MutexGuard aGuard( m_aMutex );
-    if ( !m_pImpl->m_pContent )
-    {
-        uno::Reference< ucb::XCommandEnvironment > xDummyEnv;
-
-        try
-        {
-            m_pImpl->m_pContent = new ::ucbhelper::Content( m_pImpl->m_aURL, 
xDummyEnv, comphelper::getProcessComponentContext() );
-        }
-        catch( uno::Exception& )
-        {
-        }
-    }
-
-    return m_pImpl->m_pContent;
+    return &m_pImpl->m_aContent;
 }
 
 void FSStorage::CopyStreamToSubStream( const OUString& aSourceURL,
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to