Kaydet (Commit) 9aa6cbab authored tarafından Caolán McNamara's avatar Caolán McNamara

just use a simpler vector

Change-Id: Id43776101d3466704ff62363e6a69b064ecc414c
Reviewed-on: https://gerrit.libreoffice.org/47645Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 76db5577
...@@ -266,7 +266,7 @@ public: ...@@ -266,7 +266,7 @@ public:
}; };
// Row of a HTML table // Row of a HTML table
typedef std::vector<std::unique_ptr<HTMLTableCell>> HTMLTableCells; typedef std::vector<HTMLTableCell> HTMLTableCells;
class HTMLTableRow class HTMLTableRow
{ {
...@@ -290,7 +290,11 @@ public: ...@@ -290,7 +290,11 @@ public:
inline void SetHeight( sal_uInt16 nHeight ); inline void SetHeight( sal_uInt16 nHeight );
sal_uInt16 GetHeight() const { return nHeight; } sal_uInt16 GetHeight() const { return nHeight; }
inline HTMLTableCell& GetCell(sal_uInt16 nCell) const; const HTMLTableCell& GetCell(sal_uInt16 nCell) const;
HTMLTableCell& GetCell(sal_uInt16 nCell)
{
return const_cast<HTMLTableCell&>(const_cast<const HTMLTableRow&>(*this).GetCell(nCell));
}
void SetAdjust( SvxAdjust eAdj ) { eAdjust = eAdj; } void SetAdjust( SvxAdjust eAdj ) { eAdjust = eAdj; }
SvxAdjust GetAdjust() const { return eAdjust; } SvxAdjust GetAdjust() const { return eAdjust; }
...@@ -522,7 +526,11 @@ public: ...@@ -522,7 +526,11 @@ public:
~HTMLTable(); ~HTMLTable();
// Identifying of a cell // Identifying of a cell
inline HTMLTableCell& GetCell(sal_uInt16 nRow, sal_uInt16 nCell) const; const HTMLTableCell& GetCell(sal_uInt16 nRow, sal_uInt16 nCell) const;
HTMLTableCell& GetCell(sal_uInt16 nRow, sal_uInt16 nCell)
{
return const_cast<HTMLTableCell&>(const_cast<const HTMLTable&>(*this).GetCell(nRow, nCell));
}
// set/determine caption // set/determine caption
inline void SetCaption( const SwStartNode *pStNd, bool bTop ); inline void SetCaption( const SwStartNode *pStNd, bool bTop );
...@@ -755,20 +763,16 @@ std::unique_ptr<SwHTMLTableLayoutCell> HTMLTableCell::CreateLayoutInfo() ...@@ -755,20 +763,16 @@ std::unique_ptr<SwHTMLTableLayoutCell> HTMLTableCell::CreateLayoutInfo()
bRelWidth, bNoWrap)); bRelWidth, bNoWrap));
} }
HTMLTableRow::HTMLTableRow(sal_uInt16 const nCells) HTMLTableRow::HTMLTableRow(sal_uInt16 const nCells) :
: bIsEndOfGroup(false), m_aCells(nCells),
bIsEndOfGroup(false),
nHeight(0), nHeight(0),
nEmptyRows(0), nEmptyRows(0),
eAdjust(SvxAdjust::End), eAdjust(SvxAdjust::End),
eVertOri(text::VertOrientation::TOP), eVertOri(text::VertOrientation::TOP),
bBottomBorder(false) bBottomBorder(false)
{ {
for( sal_uInt16 i=0; i<nCells; i++ ) assert(nCells == m_aCells.size() &&
{
m_aCells.push_back(o3tl::make_unique<HTMLTableCell>());
}
OSL_ENSURE(nCells == m_aCells.size(),
"wrong Cell count in new HTML table row"); "wrong Cell count in new HTML table row");
} }
...@@ -778,11 +782,11 @@ inline void HTMLTableRow::SetHeight( sal_uInt16 nHght ) ...@@ -778,11 +782,11 @@ inline void HTMLTableRow::SetHeight( sal_uInt16 nHght )
nHeight = nHght; nHeight = nHght;
} }
inline HTMLTableCell& HTMLTableRow::GetCell(sal_uInt16 nCell) const const HTMLTableCell& HTMLTableRow::GetCell(sal_uInt16 nCell) const
{ {
OSL_ENSURE( nCell < m_aCells.size(), OSL_ENSURE( nCell < m_aCells.size(),
"invalid cell index in HTML table row" ); "invalid cell index in HTML table row" );
return *m_aCells.at(nCell); return m_aCells.at(nCell);
} }
void HTMLTableRow::Expand( sal_uInt16 nCells, bool bOneCell ) void HTMLTableRow::Expand( sal_uInt16 nCells, bool bOneCell )
...@@ -793,12 +797,10 @@ void HTMLTableRow::Expand( sal_uInt16 nCells, bool bOneCell ) ...@@ -793,12 +797,10 @@ void HTMLTableRow::Expand( sal_uInt16 nCells, bool bOneCell )
sal_uInt16 nColSpan = nCells - m_aCells.size(); sal_uInt16 nColSpan = nCells - m_aCells.size();
for (sal_uInt16 i = m_aCells.size(); i < nCells; ++i) for (sal_uInt16 i = m_aCells.size(); i < nCells; ++i)
{ {
std::unique_ptr<HTMLTableCell> pCell(new HTMLTableCell); m_aCells.emplace_back();
if( bOneCell ) if (bOneCell)
pCell->SetColSpan( nColSpan ); m_aCells.back().SetColSpan(nColSpan);
--nColSpan;
m_aCells.push_back(std::move(pCell));
nColSpan--;
} }
OSL_ENSURE(nCells == m_aCells.size(), OSL_ENSURE(nCells == m_aCells.size(),
...@@ -817,14 +819,14 @@ void HTMLTableRow::Shrink( sal_uInt16 nCells ) ...@@ -817,14 +819,14 @@ void HTMLTableRow::Shrink( sal_uInt16 nCells )
sal_uInt16 i=nCells; sal_uInt16 i=nCells;
while( i ) while( i )
{ {
HTMLTableCell *pCell = m_aCells[--i].get(); HTMLTableCell& rCell = m_aCells[--i];
if( !pCell->GetContents() ) if (!rCell.GetContents())
{ {
#if OSL_DEBUG_LEVEL > 0 #if OSL_DEBUG_LEVEL > 0
OSL_ENSURE( pCell->GetColSpan() == nEnd - i, OSL_ENSURE( rCell.GetColSpan() == nEnd - i,
"invalid col span for empty cell at row end" ); "invalid col span for empty cell at row end" );
#endif #endif
pCell->SetColSpan( nCells-i); rCell.SetColSpan( nCells-i);
} }
else else
break; break;
...@@ -832,12 +834,12 @@ void HTMLTableRow::Shrink( sal_uInt16 nCells ) ...@@ -832,12 +834,12 @@ void HTMLTableRow::Shrink( sal_uInt16 nCells )
#if OSL_DEBUG_LEVEL > 0 #if OSL_DEBUG_LEVEL > 0
for( i=nCells; i<nEnd; i++ ) for( i=nCells; i<nEnd; i++ )
{ {
HTMLTableCell *pCell = m_aCells[i].get(); HTMLTableCell& rCell = m_aCells[i];
OSL_ENSURE( pCell->GetRowSpan() == 1, OSL_ENSURE( rCell.GetRowSpan() == 1,
"RowSpan of to be deleted cell is wrong" ); "RowSpan of to be deleted cell is wrong" );
OSL_ENSURE( pCell->GetColSpan() == nEnd - i, OSL_ENSURE( rCell.GetColSpan() == nEnd - i,
"ColSpan of to be deleted cell is wrong" ); "ColSpan of to be deleted cell is wrong" );
OSL_ENSURE( !pCell->GetContents(), "To be deleted cell has content" ); OSL_ENSURE( !rCell.GetContents(), "To be deleted cell has content" );
} }
#endif #endif
...@@ -1932,8 +1934,7 @@ sal_uInt16 HTMLTable::GetBorderWidth( const SvxBorderLine& rBLine, ...@@ -1932,8 +1934,7 @@ sal_uInt16 HTMLTable::GetBorderWidth( const SvxBorderLine& rBLine,
return nBorderWidth; return nBorderWidth;
} }
inline HTMLTableCell& HTMLTable::GetCell(sal_uInt16 nRow, const HTMLTableCell& HTMLTable::GetCell(sal_uInt16 nRow, sal_uInt16 nCell) const
sal_uInt16 nCell ) const
{ {
OSL_ENSURE(nRow < m_pRows->size(), "invalid row index in HTML table"); OSL_ENSURE(nRow < m_pRows->size(), "invalid row index in HTML table");
return (*m_pRows)[nRow]->GetCell(nCell); return (*m_pRows)[nRow]->GetCell(nCell);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment