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

valgrind: more leaks on loading abi3279-1.html

Change-Id: I88d400cdd142094ece9d829a6f54a57e1b967962
Reviewed-on: https://gerrit.libreoffice.org/46106Tested-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 bb966d78
......@@ -37,11 +37,11 @@ class SwFrameFormat;
class SwHTMLTableLayoutCnts
{
SwHTMLTableLayoutCnts *pNext; ///< The next content.
std::shared_ptr<SwHTMLTableLayoutCnts> xNext; ///< The next content.
/// Only one of the following two pointers may be set!
SwTableBox *pBox; ///< A Box.
SwHTMLTableLayout *pTable; ///< A "table within a table".
std::shared_ptr<SwHTMLTableLayout> xTable; ///< A "table within a table".
/** During first run there are still no boxes. In this case
pStartNode is used instead of pBox. */
......@@ -58,20 +58,18 @@ class SwHTMLTableLayoutCnts
public:
SwHTMLTableLayoutCnts( const SwStartNode* pSttNd, SwHTMLTableLayout* pTab,
bool bNoBreakTag, SwHTMLTableLayoutCnts* pNxt );
~SwHTMLTableLayoutCnts();
SwHTMLTableLayoutCnts(const SwStartNode* pSttNd, SwHTMLTableLayout* pTab,
bool bNoBreakTag, std::shared_ptr<SwHTMLTableLayoutCnts> const& rNxt);
void SetTableBox( SwTableBox *pBx ) { pBox = pBx; }
SwTableBox *GetTableBox() const { return pBox; }
SwHTMLTableLayout *GetTable() const { return pTable; }
SwHTMLTableLayout *GetTable() const { return xTable.get(); }
const SwStartNode *GetStartNode() const;
/// Calculation of next node.
SwHTMLTableLayoutCnts *GetNext() const { return pNext; }
const std::shared_ptr<SwHTMLTableLayoutCnts>& GetNext() const { return xNext; }
void SetWidthSet( sal_uInt8 nRef ) { nWidthSet = nRef; }
bool IsWidthSet( sal_uInt8 nRef ) const { return nRef==nWidthSet; }
......@@ -84,7 +82,7 @@ public:
class SwHTMLTableLayoutCell
{
SwHTMLTableLayoutCnts *pContents; ///< Content of cell.
std::shared_ptr<SwHTMLTableLayoutCnts> xContents; ///< Content of cell.
sal_uInt16 nRowSpan; ///< ROWSPAN of cell.
sal_uInt16 nColSpan; ///< COLSPAN of cell.
......@@ -95,16 +93,14 @@ class SwHTMLTableLayoutCell
public:
SwHTMLTableLayoutCell( SwHTMLTableLayoutCnts *pCnts,
SwHTMLTableLayoutCell(std::shared_ptr<SwHTMLTableLayoutCnts> const& rCnts,
sal_uInt16 nRSpan, sal_uInt16 nCSpan,
sal_uInt16 nWidthOpt, bool bPrcWdthOpt,
bool bNWrapOpt );
~SwHTMLTableLayoutCell();
/// Set or get content of a cell.
void SetContents( SwHTMLTableLayoutCnts *pCnts ) { pContents = pCnts; }
SwHTMLTableLayoutCnts *GetContents() const { return pContents; }
void SetContents(std::shared_ptr<SwHTMLTableLayoutCnts> const& rCnts) { xContents = rCnts; }
const std::shared_ptr<SwHTMLTableLayoutCnts>& GetContents() const { return xContents; }
inline void SetProtected();
......@@ -353,8 +349,7 @@ inline void SwHTMLTableLayoutCell::SetProtected()
{
nRowSpan = 1;
nColSpan = 1;
pContents = nullptr;
xContents.reset();
}
inline void SwHTMLTableLayoutColumn::MergeMinMaxNoAlign( sal_uLong nCMin,
......
......@@ -78,40 +78,26 @@ public:
SwHTMLTableLayoutCnts::SwHTMLTableLayoutCnts( const SwStartNode *pSttNd,
SwHTMLTableLayout* pTab,
bool bNoBrTag,
SwHTMLTableLayoutCnts* pNxt ) :
pNext( pNxt ), pBox( nullptr ), pTable( pTab ), pStartNode( pSttNd ),
std::shared_ptr<SwHTMLTableLayoutCnts> const& rNxt ) :
xNext( rNxt ), pBox( nullptr ), xTable( pTab ), pStartNode( pSttNd ),
nPass1Done( 0 ), nWidthSet( 0 ), bNoBreakTag( bNoBrTag )
{}
SwHTMLTableLayoutCnts::~SwHTMLTableLayoutCnts()
{
delete pNext;
delete pTable;
}
const SwStartNode *SwHTMLTableLayoutCnts::GetStartNode() const
{
return pBox ? pBox->GetSttNd() : pStartNode;
}
SwHTMLTableLayoutCell::SwHTMLTableLayoutCell( SwHTMLTableLayoutCnts *pCnts,
SwHTMLTableLayoutCell::SwHTMLTableLayoutCell(std::shared_ptr<SwHTMLTableLayoutCnts> const& rCnts,
sal_uInt16 nRSpan, sal_uInt16 nCSpan,
sal_uInt16 nWidth, bool bPrcWidth,
bool bNWrapOpt ) :
pContents( pCnts ),
xContents(rCnts),
nRowSpan( nRSpan ), nColSpan( nCSpan ),
nWidthOption( nWidth ), bPrcWidthOption( bPrcWidth ),
bNoWrapOption( bNWrapOpt )
{}
SwHTMLTableLayoutCell::~SwHTMLTableLayoutCell()
{
if( nRowSpan==1 && nColSpan==1 )
{
delete pContents;
}
}
SwHTMLTableLayoutColumn::SwHTMLTableLayoutColumn( sal_uInt16 nWidth,
bool bRelWidth,
bool bLBorder ) :
......@@ -471,7 +457,7 @@ void SwHTMLTableLayout::AutoLayoutPass1()
for( sal_uInt16 j=0; j<m_nRows; j++ )
{
SwHTMLTableLayoutCell *pCell = GetCell(j,i);
SwHTMLTableLayoutCnts *pCnts = pCell->GetContents();
SwHTMLTableLayoutCnts *pCnts = pCell->GetContents().get();
// We need to examine all rows in order to
// get the column that should be calculated next.
......@@ -589,7 +575,7 @@ void SwHTMLTableLayout::AutoLayoutPass1()
nAbsMinTableCell = nAbsMinTableCnts;
}
pCnts->SetPass1Done( m_nPass1Done );
pCnts = pCnts->GetNext();
pCnts = pCnts->GetNext().get();
}
// This code previously came after AddBorderWidth
......@@ -1598,7 +1584,7 @@ void SwHTMLTableLayout::SetWidths( bool bCallPass2, sal_uInt16 nAbsAvail,
{
SwHTMLTableLayoutCell *pCell = GetCell( i, j );
SwHTMLTableLayoutCnts* pContents = pCell->GetContents();
SwHTMLTableLayoutCnts* pContents = pCell->GetContents().get();
while( pContents && !pContents->IsWidthSet(m_nWidthSet) )
{
SwTableBox *pBox = pContents->GetTableBox();
......@@ -1624,7 +1610,7 @@ void SwHTMLTableLayout::SetWidths( bool bCallPass2, sal_uInt16 nAbsAvail,
}
pContents->SetWidthSet( m_nWidthSet );
pContents = pContents->GetNext();
pContents = pContents->GetNext().get();
}
}
}
......
......@@ -167,7 +167,7 @@ class HTMLTableCnts
const SwStartNode *m_pStartNode; // a paragraph
HTMLTable *m_pTable; // a table
SwHTMLTableLayoutCnts* m_pLayoutInfo;
std::shared_ptr<SwHTMLTableLayoutCnts> m_xLayoutInfo;
bool m_bNoBreak;
......@@ -196,7 +196,7 @@ public:
void SetNoBreak() { m_bNoBreak = true; }
SwHTMLTableLayoutCnts *CreateLayoutInfo();
const std::shared_ptr<SwHTMLTableLayoutCnts>& CreateLayoutInfo();
};
// Cell of a HTML table
......@@ -616,8 +616,7 @@ public:
void HTMLTableCnts::InitCtor()
{
m_pNext = nullptr;
m_pLayoutInfo = nullptr;
m_xLayoutInfo.reset();
m_bNoBreak = false;
}
......@@ -651,23 +650,24 @@ void HTMLTableCnts::Add( HTMLTableCnts* pNewCnts )
inline void HTMLTableCnts::SetTableBox( SwTableBox *pBox )
{
OSL_ENSURE( m_pLayoutInfo, "There is no layout info" );
if( m_pLayoutInfo )
m_pLayoutInfo->SetTableBox( pBox );
OSL_ENSURE(m_xLayoutInfo.get(), "There is no layout info");
if (m_xLayoutInfo)
m_xLayoutInfo->SetTableBox(pBox);
}
SwHTMLTableLayoutCnts *HTMLTableCnts::CreateLayoutInfo()
const std::shared_ptr<SwHTMLTableLayoutCnts>& HTMLTableCnts::CreateLayoutInfo()
{
if( !m_pLayoutInfo )
if (!m_xLayoutInfo)
{
SwHTMLTableLayoutCnts *pNextInfo = m_pNext ? m_pNext->CreateLayoutInfo() : nullptr;
std::shared_ptr<SwHTMLTableLayoutCnts> xNextInfo;
if (m_pNext)
xNextInfo = m_pNext->CreateLayoutInfo();
SwHTMLTableLayout *pTableInfo = m_pTable ? m_pTable->CreateLayoutInfo() : nullptr;
m_pLayoutInfo = new SwHTMLTableLayoutCnts( m_pStartNode, pTableInfo,
m_bNoBreak, pNextInfo );
m_xLayoutInfo.reset(new SwHTMLTableLayoutCnts(m_pStartNode, pTableInfo, m_bNoBreak, xNextInfo));
}
return m_pLayoutInfo;
return m_xLayoutInfo;
}
HTMLTableCell::HTMLTableCell():
......@@ -744,10 +744,11 @@ inline bool HTMLTableCell::GetValue( double& rValue ) const
std::unique_ptr<SwHTMLTableLayoutCell> HTMLTableCell::CreateLayoutInfo()
{
SwHTMLTableLayoutCnts *pCntInfo = m_xContents ? m_xContents->CreateLayoutInfo() : nullptr;
return std::unique_ptr<SwHTMLTableLayoutCell>(new SwHTMLTableLayoutCell( pCntInfo, nRowSpan, nColSpan, nWidth,
bRelWidth, bNoWrap ));
std::shared_ptr<SwHTMLTableLayoutCnts> xCntInfo;
if (m_xContents)
xCntInfo = m_xContents->CreateLayoutInfo();
return std::unique_ptr<SwHTMLTableLayoutCell>(new SwHTMLTableLayoutCell(xCntInfo, nRowSpan, nColSpan, nWidth,
bRelWidth, bNoWrap));
}
HTMLTableRow::HTMLTableRow(sal_uInt16 const nCells)
......@@ -1097,11 +1098,10 @@ SwHTMLTableLayout *HTMLTable::CreateLayoutInfo()
if( bExportable )
{
SwHTMLTableLayoutCnts *pLayoutCnts =
const std::shared_ptr<SwHTMLTableLayoutCnts>& rLayoutCnts =
pLayoutCell->GetContents();
bExportable = !pLayoutCnts ||
( pLayoutCnts->GetStartNode() &&
!pLayoutCnts->GetNext() );
bExportable = !rLayoutCnts ||
(rLayoutCnts->GetStartNode() && !rLayoutCnts->GetNext());
}
}
}
......@@ -1625,12 +1625,12 @@ SwTableLine *HTMLTable::MakeTableLine( SwTableBox *pUpper,
GetPrevBoxStartNode( nTopRow, nStartCol );
std::shared_ptr<HTMLTableCnts> xCnts(new HTMLTableCnts(
m_pParser->InsertTableSection(pPrevStartNd)));
SwHTMLTableLayoutCnts *pCntsLayoutInfo =
const std::shared_ptr<SwHTMLTableLayoutCnts> xCntsLayoutInfo =
xCnts->CreateLayoutInfo();
pCell2->SetContents(xCnts);
SwHTMLTableLayoutCell *pCurrCell = m_pLayoutInfo->GetCell( nTopRow, nStartCol );
pCurrCell->SetContents( pCntsLayoutInfo );
pCurrCell->SetContents(xCntsLayoutInfo);
if( nBoxRowSpan < 0 )
pCurrCell->SetRowSpan( 0 );
......@@ -1639,7 +1639,7 @@ SwTableLine *HTMLTable::MakeTableLine( SwTableBox *pUpper,
{
GetCell(nTopRow,j)->SetContents(xCnts);
m_pLayoutInfo->GetCell( nTopRow, j )
->SetContents( pCntsLayoutInfo );
->SetContents(xCntsLayoutInfo);
}
}
......
......@@ -817,13 +817,13 @@ SwWriteTable::SwWriteTable(const SwTable* pTable, const SwHTMLTableLayout *pLayo
pLayoutInfo->GetCell( nRow, nCol );
const SwHTMLTableLayoutCnts *pLayoutCnts =
pLayoutCell->GetContents();
pLayoutCell->GetContents().get();
// The cell begins actually a row above or further forward?
if( ( nRow>0 && pLayoutCnts == pLayoutInfo->GetCell(nRow-1,nCol)
->GetContents() ) ||
->GetContents().get() ) ||
( nCol>0 && pLayoutCnts == pLayoutInfo->GetCell(nRow,nCol-1)
->GetContents() ) )
->GetContents().get() ) )
{
continue;
}
......
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