diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-04-19 11:17:52 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-04-20 08:24:35 +0200 |
commit | d21d14c112312c639383ba9d9091380327dc0717 (patch) | |
tree | 6a145331fd999463c5aa63440cd34fd8930477e4 /sw | |
parent | 4a553b9a5830ecc752efe0b0f2692bac0f0f3f8c (diff) |
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 <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/htmltbl.hxx | 20 | ||||
-rw-r--r-- | sw/source/core/doc/htmltbl.cxx | 14 | ||||
-rw-r--r-- | sw/source/filter/html/htmltab.cxx | 22 |
3 files changed, 22 insertions, 34 deletions
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; } |