From 55f78bcb63e552559ec6a18e39ae982dd925974a Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Wed, 3 Oct 2018 12:25:45 +0200 Subject: loplugin:useuniqueptr in SwWriteTableCols Change-Id: Ib4c95401c3e9e60c1c909080b3381d652c862e62 Reviewed-on: https://gerrit.libreoffice.org/61342 Tested-by: Jenkins Reviewed-by: Noel Grandin --- sw/source/filter/html/htmltabw.cxx | 6 +++--- sw/source/filter/inc/wrtswtbl.hxx | 6 ++---- sw/source/filter/writer/wrtswtbl.cxx | 27 +++++++++++++-------------- 3 files changed, 18 insertions(+), 21 deletions(-) (limited to 'sw') diff --git a/sw/source/filter/html/htmltabw.cxx b/sw/source/filter/html/htmltabw.cxx index d3f76c41adb1..a2e93d6bd9f8 100644 --- a/sw/source/filter/html/htmltabw.cxx +++ b/sw/source/filter/html/htmltabw.cxx @@ -587,10 +587,10 @@ void SwHTMLWrtTable::Write( SwHTMLWriter& rWrt, sal_Int16 eAlign, bool bColsHaveBorder = false; bool bColsHaveBorderOnly = true; - SwWriteTableCol *pCol = m_aCols[0]; + SwWriteTableCol *pCol = m_aCols[0].get(); for( SwWriteTableCols::size_type nCol=1; nColbRightBorder || pNextCol->bLeftBorder ); bColsHaveBorder |= bBorder; bColsHaveBorderOnly &= bBorder; @@ -736,7 +736,7 @@ void SwHTMLWrtTable::Write( SwHTMLWriter& rWrt, sal_Int16 eAlign, { rWrt.OutNewLine(); // in new line - const SwWriteTableCol *pColumn = m_aCols[nCol]; + const SwWriteTableCol *pColumn = m_aCols[nCol].get(); HtmlWriter html(rWrt.Strm(), rWrt.maNamespace); html.start(OOO_STRING_SVTOOLS_HTML_col); diff --git a/sw/source/filter/inc/wrtswtbl.hxx b/sw/source/filter/inc/wrtswtbl.hxx index c19b6b929e90..915ad04dbe9a 100644 --- a/sw/source/filter/inc/wrtswtbl.hxx +++ b/sw/source/filter/inc/wrtswtbl.hxx @@ -200,14 +200,12 @@ inline bool SwWriteTableCol::operator<( const SwWriteTableCol& rCol ) const } struct SwWriteTableColLess { - bool operator()(SwWriteTableCol const * lhs, SwWriteTableCol const * rhs) { + bool operator()(std::unique_ptr const & lhs, std::unique_ptr const & rhs) { return lhs->GetPos() < rhs->GetPos(); } }; -class SwWriteTableCols : public o3tl::sorted_vector { -public: - ~SwWriteTableCols() { DeleteAndDestroyAll(); } +class SwWriteTableCols : public o3tl::sorted_vector, SwWriteTableColLess> { }; class SwTable; diff --git a/sw/source/filter/writer/wrtswtbl.cxx b/sw/source/filter/writer/wrtswtbl.cxx index 0fc83c31b38a..251d871acebf 100644 --- a/sw/source/filter/writer/wrtswtbl.cxx +++ b/sw/source/filter/writer/wrtswtbl.cxx @@ -296,7 +296,7 @@ sal_uInt16 SwWriteTable::GetLeftSpace( sal_uInt16 nCol ) const { nSpace = nSpace + m_nLeftSub; - const SwWriteTableCol *pCol = m_aCols[nCol]; + const SwWriteTableCol *pCol = m_aCols[nCol].get(); if( pCol->HasLeftBorder() ) nSpace = nSpace + m_nBorder; } @@ -315,7 +315,7 @@ SwWriteTable::GetRightSpace(size_t const nCol, sal_uInt16 nColSpan) const { nSpace += (m_nCellSpacing + m_nRightSub); - const SwWriteTableCol *pCol = m_aCols[nCol+nColSpan-1]; + const SwWriteTableCol *pCol = m_aCols[nCol+nColSpan-1].get(); if( pCol->HasRightBorder() ) nSpace = nSpace + m_nBorder; } @@ -468,10 +468,9 @@ void SwWriteTable::CollectTableRowsCols( long nStartRPos, if( nBox < nBoxes-1 || (nParentLineWidth==0 && nLine==0) ) { nCPos = nCPos + GetBoxWidth( pBox ); - SwWriteTableCol *pCol = new SwWriteTableCol( nCPos ); + std::unique_ptr pCol(new SwWriteTableCol( nCPos )); - if( !m_aCols.insert( pCol ).second ) - delete pCol; + m_aCols.insert( std::move(pCol) ); if( nBox==nBoxes-1 ) { @@ -680,7 +679,7 @@ void SwWriteTable::FillTableRowsCols( long nStartRPos, sal_uInt16 nStartRow, // above can be changed. if (!(nBorderMask & 4) && nOldCol < m_aCols.size()) { - SwWriteTableCol *pCol = m_aCols[nOldCol]; + SwWriteTableCol *pCol = m_aCols[nOldCol].get(); OSL_ENSURE(pCol, "No TableCol found, panic!"); if (pCol) pCol->bLeftBorder = false; @@ -688,7 +687,7 @@ void SwWriteTable::FillTableRowsCols( long nStartRPos, sal_uInt16 nStartRow, if (!(nBorderMask & 8)) { - SwWriteTableCol *pCol = m_aCols[nCol]; + SwWriteTableCol *pCol = m_aCols[nCol].get(); OSL_ENSURE(pCol, "No TableCol found, panic!"); if (pCol) pCol->bRightBorder = false; @@ -743,8 +742,8 @@ SwWriteTable::SwWriteTable(const SwTable* pTable, const SwTableLines& rLines, lo // First the table structure set. Behind the table is in each // case the end of a column - SwWriteTableCol *pCol = new SwWriteTableCol( nParentWidth ); - m_aCols.insert( pCol ); + std::unique_ptr pCol(new SwWriteTableCol( nParentWidth )); + m_aCols.insert( std::move(pCol) ); m_bUseLayoutHeights = true; CollectTableRowsCols( 0, 0, 0, nParentWidth, rLines, nMaxDepth - 1 ); @@ -785,8 +784,8 @@ SwWriteTable::SwWriteTable(const SwTable* pTable, const SwHTMLTableLayout *pLayo // First set the table structure. for( sal_uInt16 nCol=0; nCol pCol( + new SwWriteTableCol( (nCol+1)*COL_DFLT_WIDTH )); if( m_bColTags ) { @@ -796,7 +795,7 @@ SwWriteTable::SwWriteTable(const SwTable* pTable, const SwHTMLTableLayout *pLayo pLayoutCol->IsRelWidthOption() ); } - m_aCols.insert( pCol ); + m_aCols.insert( std::move(pCol) ); } for( sal_uInt16 nRow=0; nRowbLeftBorder = false; - pCol = m_aCols[nCol+nColSpan-1]; + pCol = m_aCols[nCol+nColSpan-1].get(); if( !(nBorderMask & 8) ) pCol->bRightBorder = false; -- cgit