Kaydet (Commit) 071d1432 authored tarafından Noel Grandin's avatar Noel Grandin

tdf#119007 Crash when paste table from web

regression from
    commit 51003378
    loplugin:useuniqueptr in ScHTMLLayoutParser

Change-Id: I3c6f04ac2c8f188856ec4c9eb6bf520fa03ee97a
Reviewed-on: https://gerrit.libreoffice.org/58480
Tested-by: Jenkins
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 4f891d87
...@@ -226,12 +226,7 @@ ScHTMLLayoutParser::ScHTMLLayoutParser( ...@@ -226,12 +226,7 @@ ScHTMLLayoutParser::ScHTMLLayoutParser(
ScHTMLLayoutParser::~ScHTMLLayoutParser() ScHTMLLayoutParser::~ScHTMLLayoutParser()
{ {
while ( !aTableStack.empty() ) while ( !aTableStack.empty() )
{
ScHTMLTableStackEntry* pS = aTableStack.top().get();
if ( pS->pLocalColOffset != pLocalColOffset.get() )
delete pS->pLocalColOffset;
aTableStack.pop(); aTableStack.pop();
}
pLocalColOffset.reset(); pLocalColOffset.reset();
if ( pTables ) if ( pTables )
{ {
...@@ -1032,7 +1027,7 @@ void ScHTMLLayoutParser::TableOn( HtmlImportInfo* pInfo ) ...@@ -1032,7 +1027,7 @@ void ScHTMLLayoutParser::TableOn( HtmlImportInfo* pInfo )
sal_uInt16 nTmpColOffset = nColOffset; // Will be changed in Colonize() sal_uInt16 nTmpColOffset = nColOffset; // Will be changed in Colonize()
Colonize(mxActEntry.get()); Colonize(mxActEntry.get());
aTableStack.push( o3tl::make_unique<ScHTMLTableStackEntry>( aTableStack.push( o3tl::make_unique<ScHTMLTableStackEntry>(
mxActEntry, xLockedList, pLocalColOffset.get(), nFirstTableCell, mxActEntry, xLockedList, std::move(pLocalColOffset), nFirstTableCell,
nRowCnt, nColCntStart, nMaxCol, nTable, nRowCnt, nColCntStart, nMaxCol, nTable,
nTableWidth, nColOffset, nColOffsetStart, nTableWidth, nColOffset, nColOffsetStart,
bFirstRow ) ); bFirstRow ) );
...@@ -1088,7 +1083,7 @@ void ScHTMLLayoutParser::TableOn( HtmlImportInfo* pInfo ) ...@@ -1088,7 +1083,7 @@ void ScHTMLLayoutParser::TableOn( HtmlImportInfo* pInfo )
NextRow( pInfo ); NextRow( pInfo );
} }
aTableStack.push( o3tl::make_unique<ScHTMLTableStackEntry>( aTableStack.push( o3tl::make_unique<ScHTMLTableStackEntry>(
mxActEntry, xLockedList, pLocalColOffset.get(), nFirstTableCell, mxActEntry, xLockedList, std::move(pLocalColOffset), nFirstTableCell,
nRowCnt, nColCntStart, nMaxCol, nTable, nRowCnt, nColCntStart, nMaxCol, nTable,
nTableWidth, nColOffset, nColOffsetStart, nTableWidth, nColOffset, nColOffsetStart,
bFirstRow ) ); bFirstRow ) );
...@@ -1238,7 +1233,7 @@ void ScHTMLLayoutParser::TableOff( const HtmlImportInfo* pInfo ) ...@@ -1238,7 +1233,7 @@ void ScHTMLLayoutParser::TableOff( const HtmlImportInfo* pInfo )
{ {
sal_uInt16 nOldOffset = pE->nOffset + pE->nWidth; sal_uInt16 nOldOffset = pE->nOffset + pE->nWidth;
sal_uInt16 nNewOffset = pE->nOffset + nTableWidth; sal_uInt16 nNewOffset = pE->nOffset + nTableWidth;
ModifyOffset( pS->pLocalColOffset, nOldOffset, nNewOffset, nOffsetTolerance ); ModifyOffset( pS->pLocalColOffset.get(), nOldOffset, nNewOffset, nOffsetTolerance );
sal_uInt16 nTmp = nNewOffset - pE->nOffset - pE->nWidth; sal_uInt16 nTmp = nNewOffset - pE->nOffset - pE->nWidth;
pE->nWidth = nNewOffset - pE->nOffset; pE->nWidth = nNewOffset - pE->nOffset;
pS->nTableWidth = pS->nTableWidth + nTmp; pS->nTableWidth = pS->nTableWidth + nTmp;
...@@ -1257,7 +1252,7 @@ void ScHTMLLayoutParser::TableOff( const HtmlImportInfo* pInfo ) ...@@ -1257,7 +1252,7 @@ void ScHTMLLayoutParser::TableOff( const HtmlImportInfo* pInfo )
nColOffsetStart = pS->nColOffsetStart; nColOffsetStart = pS->nColOffsetStart;
bFirstRow = pS->bFirstRow; bFirstRow = pS->bFirstRow;
xLockedList = pS->xLockedList; xLockedList = pS->xLockedList;
pLocalColOffset.reset( pS->pLocalColOffset ); pLocalColOffset = std::move( pS->pLocalColOffset );
// mxActEntry is kept around if a table is started in the same row // mxActEntry is kept around if a table is started in the same row
// (anything's possible in HTML); will be deleted by CloseEntry // (anything's possible in HTML); will be deleted by CloseEntry
mxActEntry = pE; mxActEntry = pE;
...@@ -1274,7 +1269,7 @@ void ScHTMLLayoutParser::TableOff( const HtmlImportInfo* pInfo ) ...@@ -1274,7 +1269,7 @@ void ScHTMLLayoutParser::TableOff( const HtmlImportInfo* pInfo )
{ {
std::unique_ptr<ScHTMLTableStackEntry> pS = std::move(aTableStack.top()); std::unique_ptr<ScHTMLTableStackEntry> pS = std::move(aTableStack.top());
aTableStack.pop(); aTableStack.pop();
pLocalColOffset.reset( pS->pLocalColOffset ); pLocalColOffset = std::move( pS->pLocalColOffset );
} }
} }
} }
......
...@@ -99,7 +99,7 @@ struct ScHTMLTableStackEntry ...@@ -99,7 +99,7 @@ struct ScHTMLTableStackEntry
{ {
ScRangeListRef xLockedList; ScRangeListRef xLockedList;
std::shared_ptr<ScEEParseEntry> xCellEntry; std::shared_ptr<ScEEParseEntry> xCellEntry;
ScHTMLColOffset* pLocalColOffset; std::unique_ptr<ScHTMLColOffset> pLocalColOffset;
sal_uLong nFirstTableCell; sal_uLong nFirstTableCell;
SCROW nRowCnt; SCROW nRowCnt;
SCCOL nColCntStart; SCCOL nColCntStart;
...@@ -110,14 +110,14 @@ struct ScHTMLTableStackEntry ...@@ -110,14 +110,14 @@ struct ScHTMLTableStackEntry
sal_uInt16 nColOffsetStart; sal_uInt16 nColOffsetStart;
bool bFirstRow; bool bFirstRow;
ScHTMLTableStackEntry( const std::shared_ptr<ScEEParseEntry>& rE, ScHTMLTableStackEntry( const std::shared_ptr<ScEEParseEntry>& rE,
const ScRangeListRef& rL, ScHTMLColOffset* pTO, const ScRangeListRef& rL, std::unique_ptr<ScHTMLColOffset> pTO,
sal_uLong nFTC, sal_uLong nFTC,
SCROW nRow, SCROW nRow,
SCCOL nStart, SCCOL nMax, sal_uInt16 nTab, SCCOL nStart, SCCOL nMax, sal_uInt16 nTab,
sal_uInt16 nTW, sal_uInt16 nCO, sal_uInt16 nCOS, sal_uInt16 nTW, sal_uInt16 nCO, sal_uInt16 nCOS,
bool bFR ) bool bFR )
: xLockedList( rL ), xCellEntry(rE), : xLockedList( rL ), xCellEntry(rE),
pLocalColOffset( pTO ), pLocalColOffset( std::move(pTO) ),
nFirstTableCell( nFTC ), nFirstTableCell( nFTC ),
nRowCnt( nRow ), nRowCnt( nRow ),
nColCntStart( nStart ), nMaxCol( nMax ), nColCntStart( nStart ), nMaxCol( nMax ),
......
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