summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-10-03 12:25:45 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-10-04 12:51:42 +0200
commit55f78bcb63e552559ec6a18e39ae982dd925974a (patch)
treecc0b509a5257959fbfd45febb943eb3f315a42b4
parent04c5f27e8f904f01b1dbfba2b95ed57a9e439f91 (diff)
loplugin:useuniqueptr in SwWriteTableCols
Change-Id: Ib4c95401c3e9e60c1c909080b3381d652c862e62 Reviewed-on: https://gerrit.libreoffice.org/61342 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--sw/source/filter/html/htmltabw.cxx6
-rw-r--r--sw/source/filter/inc/wrtswtbl.hxx6
-rw-r--r--sw/source/filter/writer/wrtswtbl.cxx27
3 files changed, 18 insertions, 21 deletions
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; nCol<m_aCols.size(); ++nCol )
{
- SwWriteTableCol *pNextCol = m_aCols[nCol];
+ SwWriteTableCol *pNextCol = m_aCols[nCol].get();
bool bBorder = ( pCol->bRightBorder || pNextCol->bLeftBorder );
bColsHaveBorder |= bBorder;
bColsHaveBorderOnly &= bBorder;
@@ -736,7 +736,7 @@ void SwHTMLWrtTable::Write( SwHTMLWriter& rWrt, sal_Int16 eAlign,
{
rWrt.OutNewLine(); // </COL> 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<SwWriteTableCol> const & lhs, std::unique_ptr<SwWriteTableCol> const & rhs) {
return lhs->GetPos() < rhs->GetPos();
}
};
-class SwWriteTableCols : public o3tl::sorted_vector<SwWriteTableCol*, SwWriteTableColLess> {
-public:
- ~SwWriteTableCols() { DeleteAndDestroyAll(); }
+class SwWriteTableCols : public o3tl::sorted_vector<std::unique_ptr<SwWriteTableCol>, 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<SwWriteTableCol> 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<SwWriteTableCol> 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<nCols; ++nCol )
{
- SwWriteTableCol *pCol =
- new SwWriteTableCol( (nCol+1)*COL_DFLT_WIDTH );
+ std::unique_ptr<SwWriteTableCol> 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; nRow<nRows; ++nRow )
@@ -851,11 +850,11 @@ SwWriteTable::SwWriteTable(const SwTable* pTable, const SwHTMLTableLayout *pLayo
MergeBoxBorders( pBox, nRow, nCol, nRowSpan, nColSpan,
nTopBorder, nBottomBorder );
- SwWriteTableCol *pCol = m_aCols[nCol];
+ SwWriteTableCol *pCol = m_aCols[nCol].get();
if( !(nBorderMask & 4) )
pCol->bLeftBorder = false;
- pCol = m_aCols[nCol+nColSpan-1];
+ pCol = m_aCols[nCol+nColSpan-1].get();
if( !(nBorderMask & 8) )
pCol->bRightBorder = false;