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

coverity#705926 Dereference before null check

Change-Id: I5a475d357aed24a01cd4e1e45765f1d6e585ee45
üst fdd91a28
...@@ -479,7 +479,7 @@ static void lcl_PreprocessRowsInCells( SwTabFrm& rTab, SwRowFrm& rLastLine, ...@@ -479,7 +479,7 @@ static void lcl_PreprocessRowsInCells( SwTabFrm& rTab, SwRowFrm& rLastLine,
SwTwips nCurrentHeight = SwTwips nCurrentHeight =
lcl_CalcMinRowHeight( pTmpLastLineRow, lcl_CalcMinRowHeight( pTmpLastLineRow,
rTab.IsConsiderObjsForMinCellHeight() ); rTab.IsConsiderObjsForMinCellHeight() );
while ( pTmpLastLineRow && pTmpLastLineRow->GetNext() && nTmpCut > nCurrentHeight ) while ( pTmpLastLineRow->GetNext() && nTmpCut > nCurrentHeight )
{ {
nTmpCut -= nCurrentHeight; nTmpCut -= nCurrentHeight;
pTmpLastLineRow = (SwRowFrm*)pTmpLastLineRow->GetNext(); pTmpLastLineRow = (SwRowFrm*)pTmpLastLineRow->GetNext();
...@@ -490,74 +490,71 @@ static void lcl_PreprocessRowsInCells( SwTabFrm& rTab, SwRowFrm& rLastLine, ...@@ -490,74 +490,71 @@ static void lcl_PreprocessRowsInCells( SwTabFrm& rTab, SwRowFrm& rLastLine,
} }
// pTmpLastLineRow does not fit to the line or it is the last line // pTmpLastLineRow does not fit to the line or it is the last line
if ( pTmpLastLineRow ) // Check if we can move pTmpLastLineRow to the follow table,
// or if we have to split the line:
SwFrm* pCell = pTmpLastLineRow->Lower();
bool bTableLayoutToComplex = false;
long nMinHeight = 0;
// We have to take into account:
// 1. The fixed height of the row
// 2. The borders of the cells inside the row
// 3. The minimum height of the row
if ( pTmpLastLineRow->HasFixSize() )
nMinHeight = (pTmpLastLineRow->Frm().*fnRect->fnGetHeight)();
else
{ {
// Check if we can move pTmpLastLineRow to the follow table, while ( pCell )
// or if we have to split the line:
SwFrm* pCell = pTmpLastLineRow->Lower();
bool bTableLayoutToComplex = false;
long nMinHeight = 0;
// We have to take into account:
// 1. The fixed height of the row
// 2. The borders of the cells inside the row
// 3. The minimum height of the row
if ( pTmpLastLineRow->HasFixSize() )
nMinHeight = (pTmpLastLineRow->Frm().*fnRect->fnGetHeight)();
else
{ {
while ( pCell ) if ( ((SwCellFrm*)pCell)->Lower() &&
((SwCellFrm*)pCell)->Lower()->IsRowFrm() )
{ {
if ( ((SwCellFrm*)pCell)->Lower() && bTableLayoutToComplex = true;
((SwCellFrm*)pCell)->Lower()->IsRowFrm() ) break;
{
bTableLayoutToComplex = true;
break;
}
SwBorderAttrAccess aAccess( SwFrm::GetCache(), pCell );
const SwBorderAttrs &rAttrs = *aAccess.Get();
nMinHeight = std::max( nMinHeight, lcl_CalcTopAndBottomMargin( *(SwLayoutFrm*)pCell, rAttrs ) );
pCell = pCell->GetNext();
} }
const SwFmtFrmSize &rSz = pTmpLastLineRow->GetFmt()->GetFrmSize(); SwBorderAttrAccess aAccess( SwFrm::GetCache(), pCell );
if ( rSz.GetHeightSizeType() == ATT_MIN_SIZE ) const SwBorderAttrs &rAttrs = *aAccess.Get();
nMinHeight = std::max( nMinHeight, rSz.GetHeight() ); nMinHeight = std::max( nMinHeight, lcl_CalcTopAndBottomMargin( *(SwLayoutFrm*)pCell, rAttrs ) );
pCell = pCell->GetNext();
} }
// 1. Case: const SwFmtFrmSize &rSz = pTmpLastLineRow->GetFmt()->GetFrmSize();
// The line completely fits into the master table. if ( rSz.GetHeightSizeType() == ATT_MIN_SIZE )
// Nevertheless, we build a follow (otherwise painting problems nMinHeight = std::max( nMinHeight, rSz.GetHeight() );
// with empty cell). }
// 2. Case:
// The line has to be split, the minimum height still fits into
// the master table, and the table structure is not to complex.
if ( nTmpCut > nCurrentHeight ||
( pTmpLastLineRow->IsRowSplitAllowed() &&
!bTableLayoutToComplex && nMinHeight < nTmpCut ) )
{
// The line has to be split:
SwRowFrm* pNewRow = new SwRowFrm( *pTmpLastLineRow->GetTabLine(), &rTab, false );
pNewRow->SetFollowFlowRow( true );
pNewRow->SetFollowRow( pTmpLastLineRow->GetFollowRow() );
pTmpLastLineRow->SetFollowRow( pNewRow );
pNewRow->InsertBehind( pCurrFollowFlowLineCell, 0 );
pTmpLastLineRow = (SwRowFrm*)pTmpLastLineRow->GetNext();
}
// The following lines have to be moved: // 1. Case:
while ( pTmpLastLineRow ) // The line completely fits into the master table.
{ // Nevertheless, we build a follow (otherwise painting problems
SwRowFrm* pTmp = (SwRowFrm*)pTmpLastLineRow->GetNext(); // with empty cell).
lcl_MoveFootnotes( rTab, *rTab.GetFollow(), *pTmpLastLineRow );
pTmpLastLineRow->Remove(); // 2. Case:
pTmpLastLineRow->InsertBefore( pCurrFollowFlowLineCell, 0 ); // The line has to be split, the minimum height still fits into
pTmpLastLineRow->Shrink( ( pTmpLastLineRow->Frm().*fnRect->fnGetHeight)() ); // the master table, and the table structure is not to complex.
pCurrFollowFlowLineCell->Grow( ( pTmpLastLineRow->Frm().*fnRect->fnGetHeight)() ); if ( nTmpCut > nCurrentHeight ||
pTmpLastLineRow = pTmp; ( pTmpLastLineRow->IsRowSplitAllowed() &&
} !bTableLayoutToComplex && nMinHeight < nTmpCut ) )
{
// The line has to be split:
SwRowFrm* pNewRow = new SwRowFrm( *pTmpLastLineRow->GetTabLine(), &rTab, false );
pNewRow->SetFollowFlowRow( true );
pNewRow->SetFollowRow( pTmpLastLineRow->GetFollowRow() );
pTmpLastLineRow->SetFollowRow( pNewRow );
pNewRow->InsertBehind( pCurrFollowFlowLineCell, 0 );
pTmpLastLineRow = (SwRowFrm*)pTmpLastLineRow->GetNext();
}
// The following lines have to be moved:
while ( pTmpLastLineRow )
{
SwRowFrm* pTmp = (SwRowFrm*)pTmpLastLineRow->GetNext();
lcl_MoveFootnotes( rTab, *rTab.GetFollow(), *pTmpLastLineRow );
pTmpLastLineRow->Remove();
pTmpLastLineRow->InsertBefore( pCurrFollowFlowLineCell, 0 );
pTmpLastLineRow->Shrink( ( pTmpLastLineRow->Frm().*fnRect->fnGetHeight)() );
pCurrFollowFlowLineCell->Grow( ( pTmpLastLineRow->Frm().*fnRect->fnGetHeight)() );
pTmpLastLineRow = pTmp;
} }
} }
......
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