ofz#25881 use std::vector with bounds checking accessor
Change-Id: Ic557e85bce5f3ebe7224b0aa2192a74969f4fce2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103247 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
This commit is contained in:
@@ -860,7 +860,7 @@ sal_uInt16 LwpTableLayout::ConvertHeadingRow(
|
|||||||
ConvertTable(pTmpTable.get(),nStartHeadRow,nEndHeadRow,0,nCol);
|
ConvertTable(pTmpTable.get(),nStartHeadRow,nEndHeadRow,0,nCol);
|
||||||
|
|
||||||
sal_uInt16 nRowNum = pTmpTable->GetRowCount();
|
sal_uInt16 nRowNum = pTmpTable->GetRowCount();
|
||||||
std::unique_ptr<sal_uInt8[]> CellMark( new sal_uInt8[nRowNum] );
|
std::vector<sal_uInt8> CellMark(nRowNum);
|
||||||
|
|
||||||
if (nRowNum == 1)
|
if (nRowNum == 1)
|
||||||
{
|
{
|
||||||
@@ -872,11 +872,11 @@ sal_uInt16 LwpTableLayout::ConvertHeadingRow(
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
sal_uInt8 nFirstColSpann = 1;
|
sal_uInt8 nFirstColSpann = 1;
|
||||||
const bool bFindFlag = FindSplitColMark(pTmpTable.get(),CellMark.get(),nFirstColSpann);
|
const bool bFindFlag = FindSplitColMark(pTmpTable.get(), CellMark, nFirstColSpann);
|
||||||
|
|
||||||
if (bFindFlag)//split to 2 cells
|
if (bFindFlag)//split to 2 cells
|
||||||
{
|
{
|
||||||
SplitRowToCells(pTmpTable.get(),pXFTable,nFirstColSpann,CellMark.get());
|
SplitRowToCells(pTmpTable.get(), pXFTable, nFirstColSpann, CellMark.data());
|
||||||
nContentRow = nEndHeadRow;
|
nContentRow = nEndHeadRow;
|
||||||
}
|
}
|
||||||
else//can not split,the first row will be the heading row,the rest will be content row
|
else//can not split,the first row will be the heading row,the rest will be content row
|
||||||
@@ -992,7 +992,7 @@ void LwpTableLayout::SplitRowToCells(XFTable* pTmpTable, rtl::Reference<XFTable>
|
|||||||
* @param pXFTable - pointer of tmp XFtable
|
* @param pXFTable - pointer of tmp XFtable
|
||||||
* @param CellMark - pointer of cell mark array
|
* @param CellMark - pointer of cell mark array
|
||||||
*/
|
*/
|
||||||
bool LwpTableLayout::FindSplitColMark(XFTable* pXFTable, sal_uInt8* pCellMark,
|
bool LwpTableLayout::FindSplitColMark(XFTable* pXFTable, std::vector<sal_uInt8>& rCellMark,
|
||||||
sal_uInt8& nMaxColSpan)
|
sal_uInt8& nMaxColSpan)
|
||||||
{
|
{
|
||||||
sal_uInt16 nRowNum = pXFTable->GetRowCount();
|
sal_uInt16 nRowNum = pXFTable->GetRowCount();
|
||||||
@@ -1022,7 +1022,7 @@ bool LwpTableLayout::FindSplitColMark(XFTable* pXFTable, sal_uInt8* pCellMark,
|
|||||||
}
|
}
|
||||||
if (nColSpan > nMaxColSpan)
|
if (nColSpan > nMaxColSpan)
|
||||||
nMaxColSpan = nColSpan;
|
nMaxColSpan = nColSpan;
|
||||||
pCellMark[nRowLoop] = 0;//reset all cell mark to zero
|
rCellMark.at(nRowLoop) = 0;//reset all cell mark to zero
|
||||||
}
|
}
|
||||||
|
|
||||||
//find if other row has the same column
|
//find if other row has the same column
|
||||||
@@ -1045,11 +1045,11 @@ bool LwpTableLayout::FindSplitColMark(XFTable* pXFTable, sal_uInt8* pCellMark,
|
|||||||
if (nCellMark == 0)
|
if (nCellMark == 0)
|
||||||
break;
|
break;
|
||||||
else
|
else
|
||||||
pCellMark[nRowLoop] = nCellMark;
|
rCellMark.at(nRowLoop) = nCellMark;
|
||||||
}
|
}
|
||||||
for(nRowLoop=1;nRowLoop<=nRowNum;nRowLoop++)//check if all ==0,break
|
for(nRowLoop=1;nRowLoop<=nRowNum;nRowLoop++)//check if all ==0,break
|
||||||
{
|
{
|
||||||
if (pCellMark[nRowLoop] == 0)
|
if (rCellMark.at(nRowLoop) == 0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (nRowLoop == nRowNum+1)
|
if (nRowLoop == nRowNum+1)
|
||||||
|
@@ -156,7 +156,7 @@ private:
|
|||||||
sal_uInt8 nEndCol, sal_uInt16 nRowID);
|
sal_uInt8 nEndCol, sal_uInt16 nRowID);
|
||||||
void ConvertColumn(rtl::Reference<XFTable> const & pXFTable, sal_uInt8 nStartCol, sal_uInt8 nEndCol);
|
void ConvertColumn(rtl::Reference<XFTable> const & pXFTable, sal_uInt8 nStartCol, sal_uInt8 nEndCol);
|
||||||
sal_uInt16 ConvertHeadingRow(rtl::Reference<XFTable> const & pXFTable,sal_uInt16 nStartHeadRow,sal_uInt16 nEndHeadRow);
|
sal_uInt16 ConvertHeadingRow(rtl::Reference<XFTable> const & pXFTable,sal_uInt16 nStartHeadRow,sal_uInt16 nEndHeadRow);
|
||||||
static bool FindSplitColMark(XFTable* pXFTable,sal_uInt8* pCellMark,sal_uInt8& nMaxColSpan);
|
static bool FindSplitColMark(XFTable* pXFTable, std::vector<sal_uInt8>& rCellMark, sal_uInt8& nMaxColSpan);
|
||||||
void SplitRowToCells(XFTable* pTmpTable, rtl::Reference<XFTable> const & pXFTable,
|
void SplitRowToCells(XFTable* pTmpTable, rtl::Reference<XFTable> const & pXFTable,
|
||||||
sal_uInt8 nFirstColSpann, const sal_uInt8* pCellMark);
|
sal_uInt8 nFirstColSpann, const sal_uInt8* pCellMark);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user