From f9ac067da9e61f479e2433d500b9b940e5a45470 Mon Sep 17 00:00:00 2001 From: Noel Date: Mon, 12 Oct 2020 16:09:19 +0200 Subject: static_cast after dynamic_cast Change-Id: I487b5dc148f5a3d0d45f198c00179002841242ce Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104213 Tested-by: Jenkins Reviewed-by: Noel Grandin --- sw/source/filter/html/swhtml.cxx | 4 ++-- sw/source/filter/ww8/wrtw8nds.cxx | 3 +-- sw/source/filter/ww8/wrtww8gr.cxx | 3 +-- sw/source/filter/ww8/ww8atr.cxx | 23 ++++++++++------------- 4 files changed, 14 insertions(+), 19 deletions(-) (limited to 'sw/source/filter') diff --git a/sw/source/filter/html/swhtml.cxx b/sw/source/filter/html/swhtml.cxx index d7bbb52ac908..d5cd46f5e3db 100644 --- a/sw/source/filter/html/swhtml.cxx +++ b/sw/source/filter/html/swhtml.cxx @@ -2617,8 +2617,8 @@ SwViewShell *SwHTMLParser::CallStartAction( SwViewShell *pVSh, bool bChkPtr ) if( m_pActionViewShell ) { - if( dynamic_cast< const SwEditShell *>( m_pActionViewShell ) != nullptr ) - static_cast(m_pActionViewShell)->StartAction(); + if( auto pEditShell = dynamic_cast< SwEditShell *>( m_pActionViewShell ) ) + pEditShell->StartAction(); else m_pActionViewShell->StartAction(); } diff --git a/sw/source/filter/ww8/wrtw8nds.cxx b/sw/source/filter/ww8/wrtw8nds.cxx index 6b61fd14e519..0c04d094e505 100644 --- a/sw/source/filter/ww8/wrtw8nds.cxx +++ b/sw/source/filter/ww8/wrtw8nds.cxx @@ -1579,9 +1579,8 @@ SvxFrameDirection MSWordExportBase::GetDefaultFrameDirection( ) const { nDir = TrueFrameDirection( *static_cast< const SwFrameFormat * >(m_pOutFormatNode) ); } - else if ( dynamic_cast< const SwContentNode *>( m_pOutFormatNode ) != nullptr ) //paragraph + else if ( auto pNd = dynamic_cast< const SwContentNode *>( m_pOutFormatNode ) ) //paragraph { - const SwContentNode *pNd = static_cast(m_pOutFormatNode); SwPosition aPos( *pNd ); nDir = m_rDoc.GetTextDirection( aPos ); } diff --git a/sw/source/filter/ww8/wrtww8gr.cxx b/sw/source/filter/ww8/wrtww8gr.cxx index e0600d4cb33d..73d31b68245b 100644 --- a/sw/source/filter/ww8/wrtww8gr.cxx +++ b/sw/source/filter/ww8/wrtww8gr.cxx @@ -401,9 +401,8 @@ void WW8Export::OutGrf(const ww8::Frame &rFrame) bool bVert = false; //The default for word in vertical text mode is to center, //otherwise a sub/super script hack is employed - if (dynamic_cast< const SwContentNode *>( m_pOutFormatNode ) ) + if (auto pTextNd = dynamic_cast< const SwContentNode *>( m_pOutFormatNode ) ) { - const SwTextNode* pTextNd = static_cast(m_pOutFormatNode); SwPosition aPos(*pTextNd); bVert = m_rDoc.IsInVerticalText(aPos); } diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx index d6b0fabe8701..068601af0637 100644 --- a/sw/source/filter/ww8/ww8atr.cxx +++ b/sw/source/filter/ww8/ww8atr.cxx @@ -3637,9 +3637,8 @@ void AttributeOutputBase::ParaNumRule( const SwNumRuleItem& rNumRule ) nNumId = 0; } } - else if ( dynamic_cast< const SwTextFormatColl *>( GetExport().m_pOutFormatNode ) != nullptr ) + else if ( auto pC = dynamic_cast< const SwTextFormatColl *>( GetExport().m_pOutFormatNode ) ) { - const SwTextFormatColl* pC = static_cast(GetExport().m_pOutFormatNode); if ( pC && pC->IsAssignedToListLevelOfOutlineStyle() ) nLvl = static_cast< sal_uInt8 >( pC->GetAssignedOutlineStyleLevel() ); } @@ -3801,12 +3800,12 @@ void WW8AttributeOutput::TableRowEnd(sal_uInt32 nDepth) void AttributeOutputBase::FormatPageDescription( const SwFormatPageDesc& rPageDesc ) { - if ( GetExport().m_bStyDef && dynamic_cast< const SwTextFormatColl *>( GetExport().m_pOutFormatNode ) ) - { - const SwTextFormatColl* pC = static_cast(GetExport().m_pOutFormatNode); - if ( (SfxItemState::SET != pC->GetItemState( RES_BREAK, false ) ) && rPageDesc.KnowsPageDesc() ) - FormatBreak( SvxFormatBreakItem( SvxBreak::PageBefore, RES_BREAK ) ); - } + if ( GetExport().m_bStyDef ) + if (auto pC = dynamic_cast< const SwTextFormatColl *>( GetExport().m_pOutFormatNode ) ) + { + if ( (SfxItemState::SET != pC->GetItemState( RES_BREAK, false ) ) && rPageDesc.KnowsPageDesc() ) + FormatBreak( SvxFormatBreakItem( SvxBreak::PageBefore, RES_BREAK ) ); + } } void WW8AttributeOutput::PageBreakBefore( bool bBreak ) @@ -4803,15 +4802,13 @@ void WW8AttributeOutput::ParaAdjust( const SvxAdjustItem& rAdjust ) if (m_rWW8Export.m_pOutFormatNode) { SvxFrameDirection nDirection = SvxFrameDirection::Horizontal_LR_TB; - if (dynamic_cast(m_rWW8Export.m_pOutFormatNode) != nullptr) + if (auto pTN = dynamic_cast(m_rWW8Export.m_pOutFormatNode)) { - SwPosition aPos(*static_cast(m_rWW8Export.m_pOutFormatNode)); + SwPosition aPos(*pTN); nDirection = m_rWW8Export.m_rDoc.GetTextDirection(aPos); } - else if (dynamic_cast(m_rWW8Export.m_pOutFormatNode) != nullptr) + else if (auto pC = dynamic_cast(m_rWW8Export.m_pOutFormatNode)) { - const SwTextFormatColl* pC = - static_cast(m_rWW8Export.m_pOutFormatNode); const SvxFrameDirectionItem &rItem = ItemGet(*pC, RES_FRAMEDIR); nDirection = rItem.GetValue(); -- cgit