sw/source/core/layout/tabfrm.cxx | 33 +++++++++++--------- sw/source/core/layout/wsfrm.cxx | 39 ++++++++++++------------ sw/source/core/text/EnhancedPDFExportHelper.cxx | 4 +- 3 files changed, 42 insertions(+), 34 deletions(-)
New commits: commit b4ffe68dd2fc7e2f2c36bf41dd3409f000cb42ad Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Mon Jun 21 13:24:15 2021 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Mon Jun 21 18:37:26 2021 +0200 replace dynamic_cast<SwCellFrame> with cheaper check Change-Id: I672be703fb097c71303434127d832681843607e2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117580 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx index 1626e4eac315..dff33525670d 100644 --- a/sw/source/core/layout/tabfrm.cxx +++ b/sw/source/core/layout/tabfrm.cxx @@ -1431,15 +1431,17 @@ void SwInvalidateAll( SwFrame *pFrame, tools::Long nBottom ) { // NEW TABLES SwLayoutFrame* pToInvalidate = static_cast<SwLayoutFrame*>(pFrame); - SwCellFrame* pThisCell = dynamic_cast<SwCellFrame*>(pFrame); - if ( pThisCell && pThisCell->GetTabBox()->getRowSpan() < 1 ) + if (pFrame->IsCellFrame()) { - pToInvalidate = & const_cast<SwCellFrame&>(pThisCell->FindStartEndOfRowSpanCell( true )); - pToInvalidate->InvalidatePos_(); - pToInvalidate->InvalidateSize_(); - pToInvalidate->InvalidatePrt_(); + SwCellFrame* pThisCell = static_cast<SwCellFrame*>(pFrame); + if ( pThisCell->GetTabBox()->getRowSpan() < 1 ) + { + pToInvalidate = & const_cast<SwCellFrame&>(pThisCell->FindStartEndOfRowSpanCell( true )); + pToInvalidate->InvalidatePos_(); + pToInvalidate->InvalidateSize_(); + pToInvalidate->InvalidatePrt_(); + } } - if ( pToInvalidate->Lower() ) ::SwInvalidateAll( pToInvalidate->Lower(), nBottom); } @@ -1596,14 +1598,17 @@ static bool lcl_InnerCalcLayout( SwFrame *pFrame, bRet |= lcl_InnerCalcLayout( static_cast<SwLayoutFrame*>(pFrame)->Lower(), nBottom); // NEW TABLES - SwCellFrame* pThisCell = dynamic_cast<SwCellFrame*>(pFrame); - if ( pThisCell && pThisCell->GetTabBox()->getRowSpan() < 1 ) + if (pFrame->IsCellFrame()) { - SwCellFrame& rToCalc = const_cast<SwCellFrame&>(pThisCell->FindStartEndOfRowSpanCell( true )); - bRet |= !rToCalc.isFrameAreaDefinitionValid(); - rToCalc.Calc(pRenderContext); - if ( rToCalc.Lower() ) - bRet |= lcl_InnerCalcLayout( rToCalc.Lower(), nBottom); + SwCellFrame* pThisCell = static_cast<SwCellFrame*>(pFrame); + if ( pThisCell->GetTabBox()->getRowSpan() < 1 ) + { + SwCellFrame& rToCalc = const_cast<SwCellFrame&>(pThisCell->FindStartEndOfRowSpanCell( true )); + bRet |= !rToCalc.isFrameAreaDefinitionValid(); + rToCalc.Calc(pRenderContext); + if ( rToCalc.Lower() ) + bRet |= lcl_InnerCalcLayout( rToCalc.Lower(), nBottom); + } } } pFrame = pFrame->GetNext(); diff --git a/sw/source/core/layout/wsfrm.cxx b/sw/source/core/layout/wsfrm.cxx index 4e8fb2e1fa1f..cb03f3a9e1c0 100644 --- a/sw/source/core/layout/wsfrm.cxx +++ b/sw/source/core/layout/wsfrm.cxx @@ -1513,9 +1513,9 @@ SwTwips SwFrame::Grow( SwTwips nDist, bool bTst, bool bInfo ) return static_cast<SwSectionFrame*>(this)->Grow_( nDist, bTst ); else { - const SwCellFrame* pThisCell = dynamic_cast<const SwCellFrame*>(this); - if ( pThisCell ) + if (IsCellFrame()) { + const SwCellFrame* pThisCell = static_cast<const SwCellFrame*>(this); const SwTabFrame* pTab = FindTabFrame(); // NEW TABLES @@ -1523,7 +1523,6 @@ SwTwips SwFrame::Grow( SwTwips nDist, bool bTst, bool bInfo ) pThisCell->GetLayoutRowSpan() < 1 ) return 0; } - const SwTwips nReal = GrowFrame( nDist, bTst, bInfo ); if( !bTst ) { @@ -1552,9 +1551,9 @@ SwTwips SwFrame::Shrink( SwTwips nDist, bool bTst, bool bInfo ) return static_cast<SwSectionFrame*>(this)->Shrink_( nDist, bTst ); else { - const SwCellFrame* pThisCell = dynamic_cast<const SwCellFrame*>(this); - if ( pThisCell ) + if (IsCellFrame()) { + const SwCellFrame* pThisCell = static_cast<const SwCellFrame*>(this); const SwTabFrame* pTab = FindTabFrame(); // NEW TABLES @@ -1562,7 +1561,6 @@ SwTwips SwFrame::Shrink( SwTwips nDist, bool bTst, bool bInfo ) pThisCell->GetLayoutRowSpan() < 1 ) return 0; } - SwRectFnSet aRectFnSet(this); SwTwips nReal = aRectFnSet.GetHeight(getFrameArea()); ShrinkFrame( nDist, bTst, bInfo ); @@ -2688,16 +2686,18 @@ SwTwips SwLayoutFrame::GrowFrame( SwTwips nDist, bool bTst, bool bInfo ) // A cell with a row span of > 1 is allowed to grow the // line containing the end of the row span if it is // located in the same table frame: - const SwCellFrame* pThisCell = dynamic_cast<const SwCellFrame*>(this); - if ( pThisCell && pThisCell->GetLayoutRowSpan() > 1 ) + if (IsCellFrame()) { - SwCellFrame& rEndCell = const_cast<SwCellFrame&>(pThisCell->FindStartEndOfRowSpanCell( false )); - if ( -1 == rEndCell.GetTabBox()->getRowSpan() ) - pToGrow = rEndCell.GetUpper(); - else - pToGrow = nullptr; + const SwCellFrame* pThisCell = static_cast<const SwCellFrame*>(this); + if ( pThisCell->GetLayoutRowSpan() > 1 ) + { + SwCellFrame& rEndCell = const_cast<SwCellFrame&>(pThisCell->FindStartEndOfRowSpanCell( false )); + if ( -1 == rEndCell.GetTabBox()->getRowSpan() ) + pToGrow = rEndCell.GetUpper(); + else + pToGrow = nullptr; + } } - nGrow = pToGrow ? pToGrow->Grow( nReal, bTst, bInfo ) : 0; } @@ -2905,12 +2905,15 @@ SwTwips SwLayoutFrame::ShrinkFrame( SwTwips nDist, bool bTst, bool bInfo ) { SwTwips nShrink = nReal; SwFrame* pToShrink = GetUpper(); - const SwCellFrame* pThisCell = dynamic_cast<const SwCellFrame*>(this); // NEW TABLES - if ( pThisCell && pThisCell->GetLayoutRowSpan() > 1 ) + if ( IsCellFrame() ) { - SwCellFrame& rEndCell = const_cast<SwCellFrame&>(pThisCell->FindStartEndOfRowSpanCell( false )); - pToShrink = rEndCell.GetUpper(); + const SwCellFrame* pThisCell = static_cast<const SwCellFrame*>(this); + if ( pThisCell->GetLayoutRowSpan() > 1 ) + { + SwCellFrame& rEndCell = const_cast<SwCellFrame&>(pThisCell->FindStartEndOfRowSpanCell( false )); + pToShrink = rEndCell.GetUpper(); + } } nReal = pToShrink ? pToShrink->Shrink( nShrink, bTst, bInfo ) : 0; diff --git a/sw/source/core/text/EnhancedPDFExportHelper.cxx b/sw/source/core/text/EnhancedPDFExportHelper.cxx index 94014ae13c9a..53c07abe8c0f 100644 --- a/sw/source/core/text/EnhancedPDFExportHelper.cxx +++ b/sw/source/core/text/EnhancedPDFExportHelper.cxx @@ -688,9 +688,9 @@ void SwTaggedPDFHelper::SetAttributes( vcl::PDFWriter::StructElement eType ) if ( bRowSpan ) { - const SwCellFrame* pThisCell = dynamic_cast<const SwCellFrame*>(pFrame); - if ( pThisCell ) + if ( pFrame->IsCellFrame() ) { + const SwCellFrame* pThisCell = static_cast<const SwCellFrame*>(pFrame); nVal = pThisCell->GetTabBox()->getRowSpan(); if ( nVal > 1 ) mpPDFExtOutDevData->SetStructureAttributeNumerical( vcl::PDFWriter::RowSpan, nVal ); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits