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

just use a simple vector

Change-Id: I4aeb611ba7e50c008a9d28d1f7efa308c77ba0a1
Reviewed-on: https://gerrit.libreoffice.org/47647Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst cbebd533
...@@ -360,9 +360,9 @@ public: ...@@ -360,9 +360,9 @@ public:
}; };
// HTML table // HTML table
typedef std::vector<std::unique_ptr<HTMLTableRow>> HTMLTableRows; typedef std::vector<HTMLTableRow> HTMLTableRows;
typedef std::vector<std::unique_ptr<HTMLTableColumn>> HTMLTableColumns; typedef std::vector<HTMLTableColumn> HTMLTableColumns;
typedef std::vector<SdrObject *> SdrObjects; typedef std::vector<SdrObject *> SdrObjects;
...@@ -1019,6 +1019,7 @@ HTMLTable::HTMLTable( SwHTMLParser* pPars, HTMLTable *pTopTab, ...@@ -1019,6 +1019,7 @@ HTMLTable::HTMLTable( SwHTMLParser* pPars, HTMLTable *pTopTab,
bool bParHead, bool bParHead,
bool bHasParentSec, bool bHasToFlw, bool bHasParentSec, bool bHasToFlw,
const HTMLTableOptions *pOptions ) : const HTMLTableOptions *pOptions ) :
m_aColumns(pOptions->nCols),
m_nCols( pOptions->nCols ), m_nCols( pOptions->nCols ),
m_nFilledColumns( 0 ), m_nFilledColumns( 0 ),
m_nCellPadding( pOptions->nCellPadding ), m_nCellPadding( pOptions->nCellPadding ),
...@@ -1043,10 +1044,6 @@ HTMLTable::HTMLTable( SwHTMLParser* pPars, HTMLTable *pTopTab, ...@@ -1043,10 +1044,6 @@ HTMLTable::HTMLTable( SwHTMLParser* pPars, HTMLTable *pTopTab,
m_bFirstCell( !pTopTab ) m_bFirstCell( !pTopTab )
{ {
InitCtor( pOptions ); InitCtor( pOptions );
for( sal_uInt16 i=0; i<m_nCols; i++ )
m_aColumns.push_back(o3tl::make_unique<HTMLTableColumn>());
m_pParser->RegisterHTMLTable(this); m_pParser->RegisterHTMLTable(this);
} }
...@@ -1068,7 +1065,7 @@ const std::shared_ptr<SwHTMLTableLayout>& HTMLTable::CreateLayoutInfo() ...@@ -1068,7 +1065,7 @@ const std::shared_ptr<SwHTMLTableLayout>& HTMLTable::CreateLayoutInfo()
sal_uInt16 nBorderWidth = GetBorderWidth( m_aBorderLine, true ); sal_uInt16 nBorderWidth = GetBorderWidth( m_aBorderLine, true );
sal_uInt16 nLeftBorderWidth = sal_uInt16 nLeftBorderWidth =
m_aColumns[0]->bLeftBorder ? GetBorderWidth(m_aLeftBorderLine, true) : 0; m_aColumns[0].bLeftBorder ? GetBorderWidth(m_aLeftBorderLine, true) : 0;
sal_uInt16 nRightBorderWidth = sal_uInt16 nRightBorderWidth =
m_bRightBorder ? GetBorderWidth( m_aRightBorderLine, true ) : 0; m_bRightBorder ? GetBorderWidth( m_aRightBorderLine, true ) : 0;
...@@ -1084,10 +1081,10 @@ const std::shared_ptr<SwHTMLTableLayout>& HTMLTable::CreateLayoutInfo() ...@@ -1084,10 +1081,10 @@ const std::shared_ptr<SwHTMLTableLayout>& HTMLTable::CreateLayoutInfo()
sal_uInt16 i; sal_uInt16 i;
for( i=0; i<m_nRows; i++ ) for( i=0; i<m_nRows; i++ )
{ {
HTMLTableRow *const pRow = m_aRows[i].get(); HTMLTableRow& rRow = m_aRows[i];
for( sal_uInt16 j=0; j<m_nCols; j++ ) for( sal_uInt16 j=0; j<m_nCols; j++ )
{ {
m_xLayoutInfo->SetCell(pRow->GetCell(j).CreateLayoutInfo(), i, j); m_xLayoutInfo->SetCell(rRow.GetCell(j).CreateLayoutInfo(), i, j);
SwHTMLTableLayoutCell* pLayoutCell = m_xLayoutInfo->GetCell(i, j ); SwHTMLTableLayoutCell* pLayoutCell = m_xLayoutInfo->GetCell(i, j );
if( bExportable ) if( bExportable )
...@@ -1103,7 +1100,7 @@ const std::shared_ptr<SwHTMLTableLayout>& HTMLTable::CreateLayoutInfo() ...@@ -1103,7 +1100,7 @@ const std::shared_ptr<SwHTMLTableLayout>& HTMLTable::CreateLayoutInfo()
m_xLayoutInfo->SetExportable( bExportable ); m_xLayoutInfo->SetExportable( bExportable );
for( i=0; i<m_nCols; i++ ) for( i=0; i<m_nCols; i++ )
m_xLayoutInfo->SetColumn( m_aColumns[i]->CreateLayoutInfo(), i ); m_xLayoutInfo->SetColumn(m_aColumns[i].CreateLayoutInfo(), i);
return m_xLayoutInfo; return m_xLayoutInfo;
} }
...@@ -1161,14 +1158,14 @@ const SwStartNode* HTMLTable::GetPrevBoxStartNode( sal_uInt16 nRow, sal_uInt16 n ...@@ -1161,14 +1158,14 @@ const SwStartNode* HTMLTable::GetPrevBoxStartNode( sal_uInt16 nRow, sal_uInt16 n
else else
{ {
sal_uInt16 i; sal_uInt16 i;
HTMLTableRow *const pPrevRow = m_aRows[nRow-1].get(); const HTMLTableRow& rPrevRow = m_aRows[nRow-1];
// maybe a cell in the current row // maybe a cell in the current row
i = nCol; i = nCol;
while( i ) while( i )
{ {
i--; i--;
if( 1 == pPrevRow->GetCell(i).GetRowSpan() ) if( 1 == rPrevRow.GetCell(i).GetRowSpan() )
{ {
pPrevCnts = GetCell(nRow, i).GetContents().get(); pPrevCnts = GetCell(nRow, i).GetContents().get();
break; break;
...@@ -1182,7 +1179,7 @@ const SwStartNode* HTMLTable::GetPrevBoxStartNode( sal_uInt16 nRow, sal_uInt16 n ...@@ -1182,7 +1179,7 @@ const SwStartNode* HTMLTable::GetPrevBoxStartNode( sal_uInt16 nRow, sal_uInt16 n
while( !pPrevCnts && i ) while( !pPrevCnts && i )
{ {
i--; i--;
pPrevCnts = pPrevRow->GetCell(i).GetContents().get(); pPrevCnts = rPrevRow.GetCell(i).GetContents().get();
} }
} }
} }
...@@ -1262,7 +1259,7 @@ void HTMLTable::FixFrameFormat( SwTableBox *pBox, ...@@ -1262,7 +1259,7 @@ void HTMLTable::FixFrameFormat( SwTableBox *pBox,
sal_uInt32 nNumFormat = 0; sal_uInt32 nNumFormat = 0;
double nValue = 0.0; double nValue = 0.0;
HTMLTableColumn *const pColumn = m_aColumns[nCol].get(); const HTMLTableColumn& rColumn = m_aColumns[nCol];
if( pBox->GetSttNd() ) if( pBox->GetSttNd() )
{ {
...@@ -1278,7 +1275,7 @@ void HTMLTable::FixFrameFormat( SwTableBox *pBox, ...@@ -1278,7 +1275,7 @@ void HTMLTable::FixFrameFormat( SwTableBox *pBox,
// since the line is gonna be GC-ed (correctly). // since the line is gonna be GC-ed (correctly).
if( nRowSpan > 1 || (this != m_pTopTable && nRowSpan==m_nRows) ) if( nRowSpan > 1 || (this != m_pTopTable && nRowSpan==m_nRows) )
{ {
pBGBrushItem = m_aRows[nRow]->GetBGBrush().get(); pBGBrushItem = m_aRows[nRow].GetBGBrush().get();
if( !pBGBrushItem && this != m_pTopTable ) if( !pBGBrushItem && this != m_pTopTable )
{ {
pBGBrushItem = GetBGBrush().get(); pBGBrushItem = GetBGBrush().get();
...@@ -1289,9 +1286,9 @@ void HTMLTable::FixFrameFormat( SwTableBox *pBox, ...@@ -1289,9 +1286,9 @@ void HTMLTable::FixFrameFormat( SwTableBox *pBox,
} }
bTopLine = 0==nRow && m_bTopBorder && bFirstPara; bTopLine = 0==nRow && m_bTopBorder && bFirstPara;
if (m_aRows[nRow+nRowSpan-1]->bBottomBorder && bLastPara) if (m_aRows[nRow+nRowSpan-1].bBottomBorder && bLastPara)
{ {
nEmptyRows = m_aRows[nRow+nRowSpan-1]->GetEmptyRows(); nEmptyRows = m_aRows[nRow+nRowSpan-1].GetEmptyRows();
if( nRow+nRowSpan == m_nRows ) if( nRow+nRowSpan == m_nRows )
bLastBottomLine = true; bLastBottomLine = true;
else else
...@@ -1306,7 +1303,7 @@ void HTMLTable::FixFrameFormat( SwTableBox *pBox, ...@@ -1306,7 +1303,7 @@ void HTMLTable::FixFrameFormat( SwTableBox *pBox,
if( nColSpan==1 && !bTopLine && !bLastBottomLine && !nEmptyRows && if( nColSpan==1 && !bTopLine && !bLastBottomLine && !nEmptyRows &&
!pBGBrushItem && !bHasNumFormat && !pBoxItem) !pBGBrushItem && !bHasNumFormat && !pBoxItem)
{ {
pFrameFormat = pColumn->GetFrameFormat( bBottomLine, eVOri ); pFrameFormat = rColumn.GetFrameFormat( bBottomLine, eVOri );
bReUsable = !pFrameFormat; bReUsable = !pFrameFormat;
} }
} }
...@@ -1361,7 +1358,7 @@ void HTMLTable::FixFrameFormat( SwTableBox *pBox, ...@@ -1361,7 +1358,7 @@ void HTMLTable::FixFrameFormat( SwTableBox *pBox,
} }
bSet = true; bSet = true;
} }
if ((m_aColumns[nCol])->bLeftBorder) if (m_aColumns[nCol].bLeftBorder)
{ {
const SvxBorderLine& rBorderLine = const SvxBorderLine& rBorderLine =
0==nCol ? m_aLeftBorderLine : m_aBorderLine; 0==nCol ? m_aLeftBorderLine : m_aBorderLine;
...@@ -1451,7 +1448,7 @@ void HTMLTable::FixFrameFormat( SwTableBox *pBox, ...@@ -1451,7 +1448,7 @@ void HTMLTable::FixFrameFormat( SwTableBox *pBox,
pFrameFormat->ResetFormatAttr( RES_VERT_ORIENT ); pFrameFormat->ResetFormatAttr( RES_VERT_ORIENT );
if( bReUsable ) if( bReUsable )
pColumn->SetFrameFormat( pFrameFormat, bBottomLine, eVOri ); const_cast<HTMLTableColumn&>(rColumn).SetFrameFormat(pFrameFormat, bBottomLine, eVOri);
} }
else else
{ {
...@@ -1544,14 +1541,14 @@ SwTableLine *HTMLTable::MakeTableLine( SwTableBox *pUpper, ...@@ -1544,14 +1541,14 @@ SwTableLine *HTMLTable::MakeTableLine( SwTableBox *pUpper,
: m_pLineFormat, : m_pLineFormat,
0, pUpper ); 0, pUpper );
HTMLTableRow *pTopRow = m_aRows[nTopRow].get(); const HTMLTableRow& rTopRow = m_aRows[nTopRow];
sal_uInt16 nRowHeight = pTopRow->GetHeight(); sal_uInt16 nRowHeight = rTopRow.GetHeight();
const SvxBrushItem *pBGBrushItem = nullptr; const SvxBrushItem *pBGBrushItem = nullptr;
if( this == m_pTopTable || nTopRow>0 || nBottomRow<m_nRows ) if( this == m_pTopTable || nTopRow>0 || nBottomRow<m_nRows )
{ {
// It doesn't make sense to set a color on a line, // It doesn't make sense to set a color on a line,
// if it's the outermost and simultaneously sole line of a table in a table // if it's the outermost and simultaneously sole line of a table in a table
pBGBrushItem = pTopRow->GetBGBrush().get(); pBGBrushItem = rTopRow.GetBGBrush().get();
if( !pBGBrushItem && this != m_pTopTable ) if( !pBGBrushItem && this != m_pTopTable )
{ {
...@@ -1782,9 +1779,9 @@ void HTMLTable::InheritBorders( const HTMLTable *pParent, ...@@ -1782,9 +1779,9 @@ void HTMLTable::InheritBorders( const HTMLTable *pParent,
m_bFillerTopBorder = true; // fillers get a border too m_bFillerTopBorder = true; // fillers get a border too
m_aTopBorderLine = pParent->m_aTopBorderLine; m_aTopBorderLine = pParent->m_aTopBorderLine;
} }
if (pParent->m_aRows[nRow+nRowSpan-1]->bBottomBorder && bLastPara) if (pParent->m_aRows[nRow+nRowSpan-1].bBottomBorder && bLastPara)
{ {
m_aRows[m_nRows-1]->bBottomBorder = true; m_aRows[m_nRows-1].bBottomBorder = true;
m_bFillerBottomBorder = true; // fillers get a border too m_bFillerBottomBorder = true; // fillers get a border too
m_aBottomBorderLine = m_aBottomBorderLine =
nRow+nRowSpan==pParent->m_nRows ? pParent->m_aBottomBorderLine nRow+nRowSpan==pParent->m_nRows ? pParent->m_aBottomBorderLine
...@@ -1794,7 +1791,7 @@ void HTMLTable::InheritBorders( const HTMLTable *pParent, ...@@ -1794,7 +1791,7 @@ void HTMLTable::InheritBorders( const HTMLTable *pParent,
// The child table mustn't get an upper or lower border, if that's already done by the surrounding table // The child table mustn't get an upper or lower border, if that's already done by the surrounding table
// It can get an upper border if the table is not the first paragraph in that cell // It can get an upper border if the table is not the first paragraph in that cell
m_bTopAllowed = ( !bFirstPara || (pParent->m_bTopAllowed && m_bTopAllowed = ( !bFirstPara || (pParent->m_bTopAllowed &&
(0==nRow || !(pParent->m_aRows[nRow-1])->bBottomBorder)) ); (0==nRow || !pParent->m_aRows[nRow-1].bBottomBorder)) );
// The child table has to inherit the color of the cell it's contained in, if it doesn't have one // The child table has to inherit the color of the cell it's contained in, if it doesn't have one
const SvxBrushItem *pInhBG = pParent->GetCell(nRow, nCol).GetBGBrush().get(); const SvxBrushItem *pInhBG = pParent->GetCell(nRow, nCol).GetBGBrush().get();
...@@ -1803,7 +1800,7 @@ void HTMLTable::InheritBorders( const HTMLTable *pParent, ...@@ -1803,7 +1800,7 @@ void HTMLTable::InheritBorders( const HTMLTable *pParent,
{ {
// the whole surrounding table is a table in a table and consists only of a single line // the whole surrounding table is a table in a table and consists only of a single line
// that's gonna be GC-ed (correctly). That's why the background of that line is copied. // that's gonna be GC-ed (correctly). That's why the background of that line is copied.
pInhBG = pParent->m_aRows[nRow]->GetBGBrush().get(); pInhBG = pParent->m_aRows[nRow].GetBGBrush().get();
if( !pInhBG ) if( !pInhBG )
pInhBG = pParent->GetBGBrush().get(); pInhBG = pParent->GetBGBrush().get();
if( !pInhBG ) if( !pInhBG )
...@@ -1827,7 +1824,7 @@ void HTMLTable::InheritVertBorders( const HTMLTable *pParent, ...@@ -1827,7 +1824,7 @@ void HTMLTable::InheritVertBorders( const HTMLTable *pParent,
GetBorderWidth( m_aInheritedRightBorderLine, true ) + MIN_BORDER_DIST; GetBorderWidth( m_aInheritedRightBorderLine, true ) + MIN_BORDER_DIST;
} }
if ((pParent->m_aColumns[nCol])->bLeftBorder) if (pParent->m_aColumns[nCol].bLeftBorder)
{ {
m_bInheritedLeftBorder = true; // just remember for now m_bInheritedLeftBorder = true; // just remember for now
m_aInheritedLeftBorderLine = 0==nCol ? pParent->m_aLeftBorderLine m_aInheritedLeftBorderLine = 0==nCol ? pParent->m_aLeftBorderLine
...@@ -1845,7 +1842,7 @@ void HTMLTable::InheritVertBorders( const HTMLTable *pParent, ...@@ -1845,7 +1842,7 @@ void HTMLTable::InheritVertBorders( const HTMLTable *pParent,
m_bRightAllowed = ( pParent->m_bRightAllowed && m_bRightAllowed = ( pParent->m_bRightAllowed &&
(nCol+nColSpan==pParent->m_nCols || (nCol+nColSpan==pParent->m_nCols ||
!(pParent->m_aColumns[nCol+nColSpan])->bLeftBorder) ); !pParent->m_aColumns[nCol+nColSpan].bLeftBorder) );
} }
void HTMLTable::SetBorders() void HTMLTable::SetBorders()
...@@ -1854,17 +1851,17 @@ void HTMLTable::SetBorders() ...@@ -1854,17 +1851,17 @@ void HTMLTable::SetBorders()
for( i=1; i<m_nCols; i++ ) for( i=1; i<m_nCols; i++ )
if( HTMLTableRules::All==m_eRules || HTMLTableRules::Cols==m_eRules || if( HTMLTableRules::All==m_eRules || HTMLTableRules::Cols==m_eRules ||
((HTMLTableRules::Rows==m_eRules || HTMLTableRules::Groups==m_eRules) && ((HTMLTableRules::Rows==m_eRules || HTMLTableRules::Groups==m_eRules) &&
(m_aColumns[i-1])->IsEndOfGroup())) m_aColumns[i-1].IsEndOfGroup()))
{ {
(m_aColumns[i])->bLeftBorder = true; m_aColumns[i].bLeftBorder = true;
} }
for( i=0; i<m_nRows-1; i++ ) for( i=0; i<m_nRows-1; i++ )
if( HTMLTableRules::All==m_eRules || HTMLTableRules::Rows==m_eRules || if( HTMLTableRules::All==m_eRules || HTMLTableRules::Rows==m_eRules ||
((HTMLTableRules::Cols==m_eRules || HTMLTableRules::Groups==m_eRules) && ((HTMLTableRules::Cols==m_eRules || HTMLTableRules::Groups==m_eRules) &&
m_aRows[i]->IsEndOfGroup())) m_aRows[i].IsEndOfGroup()))
{ {
m_aRows[i]->bBottomBorder = true; m_aRows[i].bBottomBorder = true;
} }
if( m_bTopAllowed && (HTMLTableFrame::Above==m_eFrame || HTMLTableFrame::HSides==m_eFrame || if( m_bTopAllowed && (HTMLTableFrame::Above==m_eFrame || HTMLTableFrame::HSides==m_eFrame ||
...@@ -1873,22 +1870,22 @@ void HTMLTable::SetBorders() ...@@ -1873,22 +1870,22 @@ void HTMLTable::SetBorders()
if( HTMLTableFrame::Below==m_eFrame || HTMLTableFrame::HSides==m_eFrame || if( HTMLTableFrame::Below==m_eFrame || HTMLTableFrame::HSides==m_eFrame ||
HTMLTableFrame::Box==m_eFrame ) HTMLTableFrame::Box==m_eFrame )
{ {
m_aRows[m_nRows-1]->bBottomBorder = true; m_aRows[m_nRows-1].bBottomBorder = true;
} }
if( HTMLTableFrame::RHS==m_eFrame || HTMLTableFrame::VSides==m_eFrame || if( HTMLTableFrame::RHS==m_eFrame || HTMLTableFrame::VSides==m_eFrame ||
HTMLTableFrame::Box==m_eFrame ) HTMLTableFrame::Box==m_eFrame )
m_bRightBorder = true; m_bRightBorder = true;
if( HTMLTableFrame::LHS==m_eFrame || HTMLTableFrame::VSides==m_eFrame || HTMLTableFrame::Box==m_eFrame ) if( HTMLTableFrame::LHS==m_eFrame || HTMLTableFrame::VSides==m_eFrame || HTMLTableFrame::Box==m_eFrame )
{ {
(m_aColumns[0])->bLeftBorder = true; m_aColumns[0].bLeftBorder = true;
} }
for( i=0; i<m_nRows; i++ ) for( i=0; i<m_nRows; i++ )
{ {
HTMLTableRow *const pRow = m_aRows[i].get(); HTMLTableRow& rRow = m_aRows[i];
for( sal_uInt16 j=0; j<m_nCols; j++ ) for (sal_uInt16 j=0; j<m_nCols; ++j)
{ {
HTMLTableCell& rCell = pRow->GetCell(j); HTMLTableCell& rCell = rRow.GetCell(j);
if (rCell.GetContents()) if (rCell.GetContents())
{ {
HTMLTableCnts *pCnts = rCell.GetContents().get(); HTMLTableCnts *pCnts = rCell.GetContents().get();
...@@ -1932,15 +1929,15 @@ sal_uInt16 HTMLTable::GetBorderWidth( const SvxBorderLine& rBLine, ...@@ -1932,15 +1929,15 @@ sal_uInt16 HTMLTable::GetBorderWidth( const SvxBorderLine& rBLine,
const HTMLTableCell& HTMLTable::GetCell(sal_uInt16 nRow, sal_uInt16 nCell) const const HTMLTableCell& HTMLTable::GetCell(sal_uInt16 nRow, sal_uInt16 nCell) const
{ {
OSL_ENSURE(nRow < m_aRows.size(), "invalid row index in HTML table"); OSL_ENSURE(nRow < m_aRows.size(), "invalid row index in HTML table");
return m_aRows[nRow]->GetCell(nCell); return m_aRows[nRow].GetCell(nCell);
} }
SvxAdjust HTMLTable::GetInheritedAdjust() const SvxAdjust HTMLTable::GetInheritedAdjust() const
{ {
SvxAdjust eAdjust = (m_nCurrentColumn<m_nCols ? (m_aColumns[m_nCurrentColumn])->GetAdjust() SvxAdjust eAdjust = (m_nCurrentColumn<m_nCols ? m_aColumns[m_nCurrentColumn].GetAdjust()
: SvxAdjust::End ); : SvxAdjust::End );
if( SvxAdjust::End==eAdjust ) if( SvxAdjust::End==eAdjust )
eAdjust = m_aRows[m_nCurrentRow]->GetAdjust(); eAdjust = m_aRows[m_nCurrentRow].GetAdjust();
return eAdjust; return eAdjust;
} }
...@@ -1948,9 +1945,9 @@ SvxAdjust HTMLTable::GetInheritedAdjust() const ...@@ -1948,9 +1945,9 @@ SvxAdjust HTMLTable::GetInheritedAdjust() const
sal_Int16 HTMLTable::GetInheritedVertOri() const sal_Int16 HTMLTable::GetInheritedVertOri() const
{ {
// text::VertOrientation::TOP is default! // text::VertOrientation::TOP is default!
sal_Int16 eVOri = m_aRows[m_nCurrentRow]->GetVertOri(); sal_Int16 eVOri = m_aRows[m_nCurrentRow].GetVertOri();
if( text::VertOrientation::TOP==eVOri && m_nCurrentColumn<m_nCols ) if( text::VertOrientation::TOP==eVOri && m_nCurrentColumn<m_nCols )
eVOri = (m_aColumns[m_nCurrentColumn])->GetVertOri(); eVOri = m_aColumns[m_nCurrentColumn].GetVertOri();
if( text::VertOrientation::TOP==eVOri ) if( text::VertOrientation::TOP==eVOri )
eVOri = m_eVertOrientation; eVOri = m_eVertOrientation;
...@@ -1979,10 +1976,9 @@ void HTMLTable::InsertCell( std::shared_ptr<HTMLTableCnts> const& rCnts, ...@@ -1979,10 +1976,9 @@ void HTMLTable::InsertCell( std::shared_ptr<HTMLTableCnts> const& rCnts,
// if we need more columns than we currently have, we need to add cells for all rows // if we need more columns than we currently have, we need to add cells for all rows
if( m_nCols < nColsReq ) if( m_nCols < nColsReq )
{ {
for( i=m_nCols; i<nColsReq; i++ ) m_aColumns.resize(nColsReq);
m_aColumns.push_back(o3tl::make_unique<HTMLTableColumn>());
for( i=0; i<m_nRows; i++ ) for( i=0; i<m_nRows; i++ )
m_aRows[i]->Expand( nColsReq, i<m_nCurrentRow ); m_aRows[i].Expand( nColsReq, i<m_nCurrentRow );
m_nCols = nColsReq; m_nCols = nColsReq;
OSL_ENSURE(m_aColumns.size() == m_nCols, OSL_ENSURE(m_aColumns.size() == m_nCols,
"wrong number of columns after expanding"); "wrong number of columns after expanding");
...@@ -1994,7 +1990,7 @@ void HTMLTable::InsertCell( std::shared_ptr<HTMLTableCnts> const& rCnts, ...@@ -1994,7 +1990,7 @@ void HTMLTable::InsertCell( std::shared_ptr<HTMLTableCnts> const& rCnts,
if( m_nRows < nRowsReq ) if( m_nRows < nRowsReq )
{ {
for( i=m_nRows; i<nRowsReq; i++ ) for( i=m_nRows; i<nRowsReq; i++ )
m_aRows.push_back(o3tl::make_unique<HTMLTableRow>(m_nCols)); m_aRows.emplace_back(m_nCols);
m_nRows = nRowsReq; m_nRows = nRowsReq;
OSL_ENSURE(m_nRows == m_aRows.size(), "wrong number of rows in Insert"); OSL_ENSURE(m_nRows == m_aRows.size(), "wrong number of rows in Insert");
} }
...@@ -2003,10 +1999,10 @@ void HTMLTable::InsertCell( std::shared_ptr<HTMLTableCnts> const& rCnts, ...@@ -2003,10 +1999,10 @@ void HTMLTable::InsertCell( std::shared_ptr<HTMLTableCnts> const& rCnts,
sal_uInt16 nSpanedCols = 0; sal_uInt16 nSpanedCols = 0;
if( m_nCurrentRow>0 ) if( m_nCurrentRow>0 )
{ {
HTMLTableRow *const pCurRow = m_aRows[m_nCurrentRow].get(); HTMLTableRow& rCurRow = m_aRows[m_nCurrentRow];
for( i=m_nCurrentColumn; i<nColsReq; i++ ) for( i=m_nCurrentColumn; i<nColsReq; i++ )
{ {
HTMLTableCell& rCell = pCurRow->GetCell(i); HTMLTableCell& rCell = rCurRow.GetCell(i);
if (rCell.GetContents()) if (rCell.GetContents())
{ {
// A cell from a row further above overlaps this one. // A cell from a row further above overlaps this one.
...@@ -2022,7 +2018,7 @@ void HTMLTable::InsertCell( std::shared_ptr<HTMLTableCnts> const& rCnts, ...@@ -2022,7 +2018,7 @@ void HTMLTable::InsertCell( std::shared_ptr<HTMLTableCnts> const& rCnts,
for( i=nColsReq; i<nSpanedCols; i++ ) for( i=nColsReq; i<nSpanedCols; i++ )
{ {
// These contents are anchored in the row above in any case // These contents are anchored in the row above in any case
HTMLTableCell& rCell = pCurRow->GetCell(i); HTMLTableCell& rCell = rCurRow.GetCell(i);
FixRowSpan( m_nCurrentRow-1, i, rCell.GetContents().get() ); FixRowSpan( m_nCurrentRow-1, i, rCell.GetContents().get() );
ProtectRowSpan( m_nCurrentRow, i, rCell.GetRowSpan() ); ProtectRowSpan( m_nCurrentRow, i, rCell.GetRowSpan() );
} }
...@@ -2057,7 +2053,7 @@ void HTMLTable::InsertCell( std::shared_ptr<HTMLTableCnts> const& rCnts, ...@@ -2057,7 +2053,7 @@ void HTMLTable::InsertCell( std::shared_ptr<HTMLTableCnts> const& rCnts,
// Remember height // Remember height
if( nCellHeight && 1==nRowSpan ) if( nCellHeight && 1==nRowSpan )
{ {
m_aRows[m_nCurrentRow]->SetHeight(static_cast<sal_uInt16>(aTwipSz.Height())); m_aRows[m_nCurrentRow].SetHeight(static_cast<sal_uInt16>(aTwipSz.Height()));
} }
// Set the column counter behind the new cells // Set the column counter behind the new cells
...@@ -2075,7 +2071,7 @@ inline void HTMLTable::CloseSection( bool bHead ) ...@@ -2075,7 +2071,7 @@ inline void HTMLTable::CloseSection( bool bHead )
// Close the preceding sections if there's already a row // Close the preceding sections if there's already a row
OSL_ENSURE( m_nCurrentRow<=m_nRows, "invalid current row" ); OSL_ENSURE( m_nCurrentRow<=m_nRows, "invalid current row" );
if( m_nCurrentRow>0 && m_nCurrentRow<=m_nRows ) if( m_nCurrentRow>0 && m_nCurrentRow<=m_nRows )
m_aRows[m_nCurrentRow-1]->SetEndOfGroup(); m_aRows[m_nCurrentRow-1].SetEndOfGroup();
if( bHead ) if( bHead )
m_nHeadlineRepeat = m_nCurrentRow; m_nHeadlineRepeat = m_nCurrentRow;
} }
...@@ -2089,17 +2085,17 @@ void HTMLTable::OpenRow(SvxAdjust eAdjust, sal_Int16 eVertOrient, ...@@ -2089,17 +2085,17 @@ void HTMLTable::OpenRow(SvxAdjust eAdjust, sal_Int16 eVertOrient,
if( m_nRows<nRowsReq ) if( m_nRows<nRowsReq )
{ {
for( sal_uInt16 i=m_nRows; i<nRowsReq; i++ ) for( sal_uInt16 i=m_nRows; i<nRowsReq; i++ )
m_aRows.push_back(o3tl::make_unique<HTMLTableRow>(m_nCols)); m_aRows.emplace_back(m_nCols);
m_nRows = nRowsReq; m_nRows = nRowsReq;
OSL_ENSURE( m_nRows == m_aRows.size(), OSL_ENSURE( m_nRows == m_aRows.size(),
"Row number in OpenRow is wrong" ); "Row number in OpenRow is wrong" );
} }
HTMLTableRow *const pCurRow = m_aRows[m_nCurrentRow].get(); HTMLTableRow& rCurRow = m_aRows[m_nCurrentRow];
pCurRow->SetAdjust( eAdjust ); rCurRow.SetAdjust(eAdjust);
pCurRow->SetVertOri( eVertOrient ); rCurRow.SetVertOri(eVertOrient);
if (rBGBrushItem) if (rBGBrushItem)
m_aRows[m_nCurrentRow]->SetBGBrush(rBGBrushItem); m_aRows[m_nCurrentRow].SetBGBrush(rBGBrushItem);
// reset the column counter // reset the column counter
m_nCurrentColumn=0; m_nCurrentColumn=0;
...@@ -2117,18 +2113,18 @@ void HTMLTable::CloseRow( bool bEmpty ) ...@@ -2117,18 +2113,18 @@ void HTMLTable::CloseRow( bool bEmpty )
if( bEmpty ) if( bEmpty )
{ {
if( m_nCurrentRow > 0 ) if( m_nCurrentRow > 0 )
m_aRows[m_nCurrentRow-1]->IncEmptyRows(); m_aRows[m_nCurrentRow-1].IncEmptyRows();
return; return;
} }
HTMLTableRow *const pRow = m_aRows[m_nCurrentRow].get(); HTMLTableRow& rRow = m_aRows[m_nCurrentRow];
// modify the COLSPAN of all empty cells at the row end in a way, that they're forming a single cell // modify the COLSPAN of all empty cells at the row end in a way, that they're forming a single cell
// that can be done here (and not earlier) since there's no more cells in that row // that can be done here (and not earlier) since there's no more cells in that row
sal_uInt16 i=m_nCols; sal_uInt16 i=m_nCols;
while( i ) while( i )
{ {
HTMLTableCell& rCell = pRow->GetCell(--i); HTMLTableCell& rCell = rRow.GetCell(--i);
if (!rCell.GetContents()) if (!rCell.GetContents())
{ {
sal_uInt16 nColSpan = m_nCols-i; sal_uInt16 nColSpan = m_nCols-i;
...@@ -2151,7 +2147,7 @@ inline void HTMLTable::CloseColGroup( sal_uInt16 nSpan, sal_uInt16 _nWidth, ...@@ -2151,7 +2147,7 @@ inline void HTMLTable::CloseColGroup( sal_uInt16 nSpan, sal_uInt16 _nWidth,
OSL_ENSURE( m_nCurrentColumn<=m_nCols, "invalid column" ); OSL_ENSURE( m_nCurrentColumn<=m_nCols, "invalid column" );
if( m_nCurrentColumn>0 && m_nCurrentColumn<=m_nCols ) if( m_nCurrentColumn>0 && m_nCurrentColumn<=m_nCols )
(m_aColumns[m_nCurrentColumn-1])->SetEndOfGroup(); m_aColumns[m_nCurrentColumn-1].SetEndOfGroup();
} }
void HTMLTable::InsertCol( sal_uInt16 nSpan, sal_uInt16 nColWidth, bool bRelWidth, void HTMLTable::InsertCol( sal_uInt16 nSpan, sal_uInt16 nColWidth, bool bRelWidth,
...@@ -2170,8 +2166,7 @@ void HTMLTable::InsertCol( sal_uInt16 nSpan, sal_uInt16 nColWidth, bool bRelWidt ...@@ -2170,8 +2166,7 @@ void HTMLTable::InsertCol( sal_uInt16 nSpan, sal_uInt16 nColWidth, bool bRelWidt
if( m_nCols < nColsReq ) if( m_nCols < nColsReq )
{ {
for( i=m_nCols; i<nColsReq; i++ ) m_aColumns.resize(nColsReq);
m_aColumns.push_back(o3tl::make_unique<HTMLTableColumn>());
m_nCols = nColsReq; m_nCols = nColsReq;
} }
...@@ -2184,11 +2179,11 @@ void HTMLTable::InsertCol( sal_uInt16 nSpan, sal_uInt16 nColWidth, bool bRelWidt ...@@ -2184,11 +2179,11 @@ void HTMLTable::InsertCol( sal_uInt16 nSpan, sal_uInt16 nColWidth, bool bRelWidt
for( i=m_nCurrentColumn; i<nColsReq; i++ ) for( i=m_nCurrentColumn; i<nColsReq; i++ )
{ {
HTMLTableColumn *const pCol = m_aColumns[i].get(); HTMLTableColumn& rCol = m_aColumns[i];
sal_uInt16 nTmp = bRelWidth ? nColWidth : (sal_uInt16)aTwipSz.Width(); sal_uInt16 nTmp = bRelWidth ? nColWidth : (sal_uInt16)aTwipSz.Width();
pCol->SetWidth( nTmp, bRelWidth ); rCol.SetWidth( nTmp, bRelWidth );
pCol->SetAdjust( eAdjust ); rCol.SetAdjust( eAdjust );
pCol->SetVertOri( eVertOrient ); rCol.SetVertOri( eVertOrient );
} }
m_bColSpec = true; m_bColSpec = true;
...@@ -2205,14 +2200,14 @@ void HTMLTable::CloseTable() ...@@ -2205,14 +2200,14 @@ void HTMLTable::CloseTable()
// and we need to adjust the ROWSPAN in the rows above // and we need to adjust the ROWSPAN in the rows above
if( m_nRows>m_nCurrentRow ) if( m_nRows>m_nCurrentRow )
{ {
HTMLTableRow *const pPrevRow = m_aRows[m_nCurrentRow-1].get(); HTMLTableRow& rPrevRow = m_aRows[m_nCurrentRow-1];
for( i=0; i<m_nCols; i++ ) for( i=0; i<m_nCols; i++ )
{ {
HTMLTableCell& rCell = pPrevRow->GetCell(i); HTMLTableCell& rCell = rPrevRow.GetCell(i);
if (rCell.GetRowSpan() > 1) if (rCell.GetRowSpan() > 1)
{ {
FixRowSpan(m_nCurrentRow-1, i, rCell.GetContents().get()); FixRowSpan(m_nCurrentRow-1, i, rCell.GetContents().get());
ProtectRowSpan(m_nCurrentRow, i, m_aRows[m_nCurrentRow]->GetCell(i).GetRowSpan()); ProtectRowSpan(m_nCurrentRow, i, m_aRows[m_nCurrentRow].GetCell(i).GetRowSpan());
} }
} }
for( i=m_nRows-1; i>=m_nCurrentRow; i-- ) for( i=m_nRows-1; i>=m_nCurrentRow; i-- )
...@@ -2223,9 +2218,9 @@ void HTMLTable::CloseTable() ...@@ -2223,9 +2218,9 @@ void HTMLTable::CloseTable()
// if the table has no column, we need to add one // if the table has no column, we need to add one
if( 0==m_nCols ) if( 0==m_nCols )
{ {
m_aColumns.push_back(o3tl::make_unique<HTMLTableColumn>()); m_aColumns.resize(1);
for( i=0; i<m_nRows; i++ ) for( i=0; i<m_nRows; i++ )
m_aRows[i]->Expand(1); m_aRows[i].Expand(1);
m_nCols = 1; m_nCols = 1;
m_nFilledColumns = 1; m_nFilledColumns = 1;
} }
...@@ -2233,7 +2228,7 @@ void HTMLTable::CloseTable() ...@@ -2233,7 +2228,7 @@ void HTMLTable::CloseTable()
// if the table has no row, we need to add one // if the table has no row, we need to add one
if( 0==m_nRows ) if( 0==m_nRows )
{ {
m_aRows.push_back(o3tl::make_unique<HTMLTableRow>(m_nCols)); m_aRows.emplace_back(m_nCols);
m_nRows = 1; m_nRows = 1;
m_nCurrentRow = 1; m_nCurrentRow = 1;
} }
...@@ -2242,7 +2237,7 @@ void HTMLTable::CloseTable() ...@@ -2242,7 +2237,7 @@ void HTMLTable::CloseTable()
{ {
m_aColumns.erase(m_aColumns.begin() + m_nFilledColumns, m_aColumns.begin() + m_nCols); m_aColumns.erase(m_aColumns.begin() + m_nFilledColumns, m_aColumns.begin() + m_nCols);
for( i=0; i<m_nRows; i++ ) for( i=0; i<m_nRows; i++ )
m_aRows[i]->Shrink( m_nFilledColumns ); m_aRows[i].Shrink( m_nFilledColumns );
m_nCols = m_nFilledColumns; m_nCols = m_nFilledColumns;
} }
} }
...@@ -2342,11 +2337,11 @@ void HTMLTable::MakeTable( SwTableBox *pBox, sal_uInt16 nAbsAvail, ...@@ -2342,11 +2337,11 @@ void HTMLTable::MakeTable( SwTableBox *pBox, sal_uInt16 nAbsAvail,
} }
if( m_xLayoutInfo->GetRelLeftFill() == 0 && if( m_xLayoutInfo->GetRelLeftFill() == 0 &&
!m_aColumns[0]->bLeftBorder && !m_aColumns[0].bLeftBorder &&
m_bInheritedLeftBorder ) m_bInheritedLeftBorder )
{ {
// If applicable, inherit right border of outer table // If applicable, inherit right border of outer table
m_aColumns[0]->bLeftBorder = true; m_aColumns[0].bLeftBorder = true;
m_aLeftBorderLine = m_aInheritedLeftBorderLine; m_aLeftBorderLine = m_aInheritedLeftBorderLine;
} }
} }
......
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