summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-09-03 11:32:58 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-09-06 09:41:48 +0200
commitfad919eb0d30b2303193e1c00ba765514957652c (patch)
tree10c6d6a8a326d18369148be45a6c4fc66206797d /sw
parent62159ea8cc806df327461275563e95dfdff25667 (diff)
make SwWriteTableRows be a vector of std::unique_ptr
and update o3tl::sorted_vector to handle that Change-Id: I11a9ec3ec09f835cbd7e49ccda133b9f210d761e Reviewed-on: https://gerrit.libreoffice.org/59931 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw')
-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.cxx31
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.cxx4
-rw-r--r--sw/source/filter/ww8/rtfattributeoutput.cxx8
5 files changed, 28 insertions, 27 deletions
diff --git a/sw/source/filter/html/htmltabw.cxx b/sw/source/filter/html/htmltabw.cxx
index 0d400245efb9..d3f76c41adb1 100644
--- a/sw/source/filter/html/htmltabw.cxx
+++ b/sw/source/filter/html/htmltabw.cxx
@@ -564,10 +564,10 @@ void SwHTMLWrtTable::Write( SwHTMLWriter& rWrt, sal_Int16 eAlign,
// determine value of RULES
bool bRowsHaveBorder = false;
bool bRowsHaveBorderOnly = true;
- SwWriteTableRow *pRow = m_aRows[0];
+ SwWriteTableRow *pRow = m_aRows[0].get();
for( SwWriteTableRows::size_type nRow=1; nRow < m_aRows.size(); ++nRow )
{
- SwWriteTableRow *pNextRow = m_aRows[nRow];
+ SwWriteTableRow *pNextRow = m_aRows[nRow].get();
bool bBorder = ( pRow->bBottomBorder || pNextRow->bTopBorder );
bRowsHaveBorder |= bBorder;
bRowsHaveBorderOnly &= bBorder;
@@ -808,7 +808,7 @@ void SwHTMLWrtTable::Write( SwHTMLWriter& rWrt, sal_Int16 eAlign,
for( SwWriteTableRows::size_type nRow = 0; nRow < m_aRows.size(); ++nRow )
{
- const SwWriteTableRow *pRow2 = m_aRows[nRow];
+ const SwWriteTableRow *pRow2 = m_aRows[nRow].get();
OutTableCells( rWrt, pRow2->GetCells(), pRow2->GetBackground() );
if( !m_nCellSpacing && nRow < m_aRows.size()-1 && pRow2->bBottomBorder &&
diff --git a/sw/source/filter/inc/wrtswtbl.hxx b/sw/source/filter/inc/wrtswtbl.hxx
index 2537dbb5dd29..7c61ba07de8c 100644
--- a/sw/source/filter/inc/wrtswtbl.hxx
+++ b/sw/source/filter/inc/wrtswtbl.hxx
@@ -151,10 +151,8 @@ inline bool SwWriteTableRow::operator<( const SwWriteTableRow& rRow ) const
return nPos < rRow.nPos - (mbUseLayoutHeights ? 0 : ROWFUZZY);
}
-class SwWriteTableRows : public o3tl::sorted_vector<SwWriteTableRow*, o3tl::less_ptr_to<SwWriteTableRow> > {
-public:
- ~SwWriteTableRows() { DeleteAndDestroyAll(); }
-};
+using SwWriteTableRows
+ = o3tl::sorted_vector< std::unique_ptr<SwWriteTableRow>, o3tl::less_uniqueptr_to<SwWriteTableRow> >;
class SW_DLLPUBLIC SwWriteTableCol
{
diff --git a/sw/source/filter/writer/wrtswtbl.cxx b/sw/source/filter/writer/wrtswtbl.cxx
index e0a7273e8c76..0fc83c31b38a 100644
--- a/sw/source/filter/writer/wrtswtbl.cxx
+++ b/sw/source/filter/writer/wrtswtbl.cxx
@@ -367,7 +367,7 @@ long SwWriteTable::GetAbsHeight(long nRawHeight, size_t const nRow,
if( nRow==0 )
{
nRawHeight -= m_nCellSpacing;
- pRow = m_aRows[nRow];
+ pRow = m_aRows[nRow].get();
if( pRow->HasTopBorder() )
nRawHeight -= m_nBorder;
}
@@ -376,7 +376,7 @@ long SwWriteTable::GetAbsHeight(long nRawHeight, size_t const nRow,
if( nRow+nRowSpan==m_aRows.size() )
{
if( !pRow || nRowSpan > 1 )
- pRow = m_aRows[nRow+nRowSpan-1];
+ pRow = m_aRows[nRow+nRowSpan-1].get();
if( pRow->HasBottomBorder() )
nRawHeight -= m_nBorder;
}
@@ -432,9 +432,8 @@ void SwWriteTable::CollectTableRowsCols( long nStartRPos,
nLineHeight /= nLines - nLine; // divided through the number of remaining sub rows
nRPos += nLineHeight;
}
- SwWriteTableRow *pRow = new SwWriteTableRow( nRPos, m_bUseLayoutHeights);
- if( !m_aRows.insert( pRow ).second )
- delete pRow;
+ std::unique_ptr<SwWriteTableRow> pRow(new SwWriteTableRow( nRPos, m_bUseLayoutHeights));
+ m_aRows.insert( std::move(pRow) );
}
else
{
@@ -444,7 +443,9 @@ void SwWriteTable::CollectTableRowsCols( long nStartRPos,
nRPos = nStartRPos + nParentLineHeight;
#if OSL_DEBUG_LEVEL > 0
SwWriteTableRow aSrchRow( nRPos, m_bUseLayoutHeights );
- OSL_ENSURE( m_aRows.find( &aSrchRow ) != m_aRows.end(), "Parent-Row not found" );
+ OSL_ENSURE( std::find_if(m_aRows.begin(), m_aRows.end(),
+ [&](std::unique_ptr<SwWriteTableRow> const & p)
+ { return *p == aSrchRow; }) != m_aRows.end(), "Parent-Row not found" );
SwWriteTableRow aRowCheckPos(nCheckPos,m_bUseLayoutHeights);
SwWriteTableRow aRowRPos(nRPos,m_bUseLayoutHeights);
OSL_ENSURE( !m_bUseLayoutHeights ||
@@ -561,7 +562,9 @@ void SwWriteTable::FillTableRowsCols( long nStartRPos, sal_uInt16 nStartRow,
// And their index
sal_uInt16 nOldRow = nRow;
SwWriteTableRow aSrchRow( nRPos,m_bUseLayoutHeights );
- SwWriteTableRows::const_iterator it2 = m_aRows.find( &aSrchRow );
+ SwWriteTableRows::const_iterator it2 = std::find_if(m_aRows.begin(), m_aRows.end(),
+ [&](std::unique_ptr<SwWriteTableRow> const &p)
+ { return *p == aSrchRow; });
// coupled methods out of sync ...
assert( it2 != m_aRows.end() );
@@ -575,8 +578,8 @@ void SwWriteTable::FillTableRowsCols( long nStartRPos, sal_uInt16 nStartRow,
--nOldRow;
}
- SwWriteTableRow *pRow = m_aRows[nOldRow];
- SwWriteTableRow *pEndRow = m_aRows[nRow];
+ SwWriteTableRow *pRow = m_aRows[nOldRow].get();
+ SwWriteTableRow *pEndRow = m_aRows[nRow].get();
if( nLine+1==nNumOfHeaderRows && nParentLineHeight==0 )
m_nHeadEndRow = nRow;
@@ -798,17 +801,17 @@ SwWriteTable::SwWriteTable(const SwTable* pTable, const SwHTMLTableLayout *pLayo
for( sal_uInt16 nRow=0; nRow<nRows; ++nRow )
{
- SwWriteTableRow *pRow =
- new SwWriteTableRow( (nRow+1)*ROW_DFLT_HEIGHT, m_bUseLayoutHeights );
+ std::unique_ptr<SwWriteTableRow> pRow(
+ new SwWriteTableRow( (nRow+1)*ROW_DFLT_HEIGHT, m_bUseLayoutHeights ));
pRow->nTopBorder = 0;
pRow->nBottomBorder = 0;
- m_aRows.insert( pRow );
+ m_aRows.insert( std::move(pRow) );
}
// And now fill with life
for( sal_uInt16 nRow=0; nRow<nRows; ++nRow )
{
- SwWriteTableRow *pRow = m_aRows[nRow];
+ SwWriteTableRow *pRow = m_aRows[nRow].get();
bool bHeightExported = false;
for( sal_uInt16 nCol=0; nCol<nCols; nCol++ )
@@ -859,7 +862,7 @@ SwWriteTable::SwWriteTable(const SwTable* pTable, const SwHTMLTableLayout *pLayo
if( !(nBorderMask & 1) )
pRow->bTopBorder = false;
- SwWriteTableRow *pEndRow = m_aRows[nRow+nRowSpan-1];
+ SwWriteTableRow *pEndRow = m_aRows[nRow+nRowSpan-1].get();
if( !(nBorderMask & 2) )
pEndRow->bBottomBorder = false;
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index adb5e65d913b..af29b9fcd4e0 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -3254,7 +3254,7 @@ void DocxAttributeOutput::TableCellProperties( ww8::WW8TableNodeInfoInner::Point
// Horizontal spans
const SwWriteTableRows& rRows = m_xTableWrt->GetRows( );
- SwWriteTableRow *pRow = rRows[ nRow ];
+ SwWriteTableRow *pRow = rRows[ nRow ].get();
const SwWriteTableCells& rTableCells = pRow->GetCells();
if (nCell < rTableCells.size() )
{
@@ -4081,7 +4081,7 @@ void DocxAttributeOutput::TableVerticalCell( ww8::WW8TableNodeInfoInner::Pointer
}
const SwWriteTableRows& rRows = m_xTableWrt->GetRows( );
- SwWriteTableRow *pRow = rRows[ pTableTextNodeInfoInner->getRow( ) ];
+ SwWriteTableRow *pRow = rRows[ pTableTextNodeInfoInner->getRow( ) ].get();
sal_uInt32 nCell = pTableTextNodeInfoInner->getCell();
const SwWriteTableCells& rTableCells = pRow->GetCells();
if (nCell < rTableCells.size() )
diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx
index 86bbb4201a2d..8fba8b326d63 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.cxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.cxx
@@ -653,7 +653,7 @@ void RtfAttributeOutput::TableDefinition(
// The cell-dependent properties
const double fWidthRatio = m_pTableWrt->GetAbsWidthRatio();
const SwWriteTableRows& aRows = m_pTableWrt->GetRows();
- SwWriteTableRow* pRow = aRows[pTableTextNodeInfoInner->getRow()];
+ SwWriteTableRow* pRow = aRows[pTableTextNodeInfoInner->getRow()].get();
SwTwips nSz = 0;
// Not using m_nTableDepth, which is not yet incremented here.
@@ -687,7 +687,7 @@ void RtfAttributeOutput::TableDefaultBorders(
*/
const SwWriteTableRows& aRows = m_pTableWrt->GetRows();
- SwWriteTableRow* pRow = aRows[pTableTextNodeInfoInner->getRow()];
+ SwWriteTableRow* pRow = aRows[pTableTextNodeInfoInner->getRow()].get();
const SwWriteTableCell* const pCell
= pRow->GetCells()[pTableTextNodeInfoInner->getCell()].get();
const SwFrameFormat* pCellFormat = pCell->GetBox()->GetFrameFormat();
@@ -742,7 +742,7 @@ void RtfAttributeOutput::TableBackgrounds(
aColor = pRowColorProp->GetColor();
const SwWriteTableRows& aRows = m_pTableWrt->GetRows();
- SwWriteTableRow* pRow = aRows[pTableTextNodeInfoInner->getRow()];
+ SwWriteTableRow* pRow = aRows[pTableTextNodeInfoInner->getRow()].get();
const SwWriteTableCell* const pCell
= pRow->GetCells()[pTableTextNodeInfoInner->getCell()].get();
const SwFrameFormat* pCellFormat = pCell->GetBox()->GetFrameFormat();
@@ -830,7 +830,7 @@ void RtfAttributeOutput::TableVerticalCell(
ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner)
{
const SwWriteTableRows& aRows = m_pTableWrt->GetRows();
- SwWriteTableRow* pRow = aRows[pTableTextNodeInfoInner->getRow()];
+ SwWriteTableRow* pRow = aRows[pTableTextNodeInfoInner->getRow()].get();
const SwWriteTableCell* const pCell
= pRow->GetCells()[pTableTextNodeInfoInner->getCell()].get();
const SwFrameFormat* pCellFormat = pCell->GetBox()->GetFrameFormat();