diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2018-08-09 16:30:08 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-08-10 08:19:55 +0200 |
commit | b268ef57e97e692644335afeae834205ecb73557 (patch) | |
tree | 872299ece84d84bb335ede04c6687b287a751208 /sw/source/uibase | |
parent | d063bea95848fd3b899b9809cb8e69eb61ded2fc (diff) |
unnecessary null check before dynamic_cast, in sw
Change-Id: I4f3f3f8b8b7fdf57fe76ff9a24cd8c58e386392d
Reviewed-on: https://gerrit.libreoffice.org/58770
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw/source/uibase')
-rw-r--r-- | sw/source/uibase/app/swmodul1.cxx | 2 | ||||
-rw-r--r-- | sw/source/uibase/dialog/SwSpellDialogChildWindow.cxx | 4 | ||||
-rw-r--r-- | sw/source/uibase/dialog/regionsw.cxx | 4 | ||||
-rw-r--r-- | sw/source/uibase/dochdl/swdtflvr.cxx | 2 | ||||
-rw-r--r-- | sw/source/uibase/ribbar/concustomshape.cxx | 2 | ||||
-rw-r--r-- | sw/source/uibase/shells/mediash.cxx | 4 | ||||
-rw-r--r-- | sw/source/uibase/sidebar/PageFooterPanel.cxx | 8 | ||||
-rw-r--r-- | sw/source/uibase/sidebar/PageFormatPanel.cxx | 6 | ||||
-rw-r--r-- | sw/source/uibase/sidebar/PageHeaderPanel.cxx | 8 | ||||
-rw-r--r-- | sw/source/uibase/sidebar/PageStylesPanel.cxx | 4 | ||||
-rw-r--r-- | sw/source/uibase/uno/unotxdoc.cxx | 3 |
11 files changed, 23 insertions, 24 deletions
diff --git a/sw/source/uibase/app/swmodul1.cxx b/sw/source/uibase/app/swmodul1.cxx index 10ad0ef5d8fa..e23635f8485e 100644 --- a/sw/source/uibase/app/swmodul1.cxx +++ b/sw/source/uibase/app/swmodul1.cxx @@ -148,7 +148,7 @@ void SwModule::ApplyUsrPref(const SwViewOption &rUsrPref, SwView* pActView, SwMasterUsrPref* pPref = const_cast<SwMasterUsrPref*>(GetUsrPref( nDest == SvViewOpt::DestWeb || (nDest != SvViewOpt::DestText - && pCurrView && dynamic_cast< const SwWebView *>( pCurrView ) != nullptr) )); + && dynamic_cast< const SwWebView *>( pCurrView )) )); // with Uno, only sdbcx::View, but not the Module should be changed bool bViewOnly = SvViewOpt::DestViewOnly == nDest; diff --git a/sw/source/uibase/dialog/SwSpellDialogChildWindow.cxx b/sw/source/uibase/dialog/SwSpellDialogChildWindow.cxx index b9a5ea30a518..98c5fbf74835 100644 --- a/sw/source/uibase/dialog/SwSpellDialogChildWindow.cxx +++ b/sw/source/uibase/dialog/SwSpellDialogChildWindow.cxx @@ -732,8 +732,8 @@ bool SwSpellDialogChildWindow::FindNextDrawTextError_Impl(SwWrtShell& rSh) if ( rMarkList.GetMarkCount() == 1 ) { SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj(); - if( pObj && dynamic_cast< const SdrTextObj *>( pObj ) != nullptr ) - pCurrentTextObj = static_cast<SdrTextObj*>(pObj); + if( auto pSdrTextObj = dynamic_cast<SdrTextObj *>( pObj ) ) + pCurrentTextObj = pSdrTextObj; } // at first fill the list of drawing objects if(!m_pSpellState->m_bTextObjectsCollected ) diff --git a/sw/source/uibase/dialog/regionsw.cxx b/sw/source/uibase/dialog/regionsw.cxx index 95617aac1b0a..e0f25330ddd4 100644 --- a/sw/source/uibase/dialog/regionsw.cxx +++ b/sw/source/uibase/dialog/regionsw.cxx @@ -216,9 +216,9 @@ void SwBaseShell::EditRegionDialog(SfxRequest const & rReq) { SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); ScopedVclPtr<AbstractEditRegionDlg> pEditRegionDlg(pFact->CreateEditRegionDlg(pParentWin, rWrtShell)); - if(pItem && dynamic_cast< const SfxStringItem *>( pItem ) != nullptr) + if(auto pStringItem = dynamic_cast< const SfxStringItem *>( pItem )) { - pEditRegionDlg->SelectSection(static_cast<const SfxStringItem*>(pItem)->GetValue()); + pEditRegionDlg->SelectSection(pStringItem->GetValue()); } pEditRegionDlg->Execute(); } diff --git a/sw/source/uibase/dochdl/swdtflvr.cxx b/sw/source/uibase/dochdl/swdtflvr.cxx index a9a5fa476219..07b93273c1a7 100644 --- a/sw/source/uibase/dochdl/swdtflvr.cxx +++ b/sw/source/uibase/dochdl/swdtflvr.cxx @@ -1304,7 +1304,7 @@ bool SwTransferable::PasteData( TransferableDataHelper& rData, // drop as if from external const SwFrameFormat* pSwFrameFormat = rSh.GetFormatFromObj(*pPt); - if(pSwFrameFormat && dynamic_cast< const SwDrawFrameFormat* >(pSwFrameFormat) != nullptr) + if(dynamic_cast< const SwDrawFrameFormat* >(pSwFrameFormat)) { bPrivateDrop = false; bNeedToSelectBeforePaste = true; diff --git a/sw/source/uibase/ribbar/concustomshape.cxx b/sw/source/uibase/ribbar/concustomshape.cxx index a9f5cc718fa8..ad9351aaae6f 100644 --- a/sw/source/uibase/ribbar/concustomshape.cxx +++ b/sw/source/uibase/ribbar/concustomshape.cxx @@ -178,7 +178,7 @@ void ConstCustomShape::CreateDefaultObject() if ( rMarkList.GetMarkCount() == 1 ) { SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj(); - if ( pObj && dynamic_cast< const SdrObjCustomShape *>( pObj ) != nullptr ) + if ( dynamic_cast< const SdrObjCustomShape *>( pObj ) ) SetAttributes( pObj ); } } diff --git a/sw/source/uibase/shells/mediash.cxx b/sw/source/uibase/shells/mediash.cxx index d28f804adccf..fba429fba732 100644 --- a/sw/source/uibase/shells/mediash.cxx +++ b/sw/source/uibase/shells/mediash.cxx @@ -121,7 +121,7 @@ void SwMediaShell::ExecMedia(SfxRequest const &rReq) { SdrObject* pObj = pMarkList->GetMark( 0 )->GetMarkedSdrObj(); - if( pObj && dynamic_cast< const SdrMediaObj *>( pObj ) != nullptr ) + if( dynamic_cast< const SdrMediaObj *>( pObj ) ) { static_cast< sdr::contact::ViewContactOfSdrMediaObj& >( pObj->GetViewContact() ).executeMediaItem( static_cast< const ::avmedia::MediaItem& >( *pItem ) ); @@ -164,7 +164,7 @@ void SwMediaShell::GetMediaState(SfxItemSet &rSet) { SdrObject* pObj = pMarkList->GetMark( 0 )->GetMarkedSdrObj(); - if( pObj && dynamic_cast< const SdrMediaObj *>( pObj ) != nullptr ) + if( dynamic_cast< const SdrMediaObj *>( pObj ) ) { ::avmedia::MediaItem aItem( SID_AVMEDIA_TOOLBOX ); diff --git a/sw/source/uibase/sidebar/PageFooterPanel.cxx b/sw/source/uibase/sidebar/PageFooterPanel.cxx index 308c35b59421..e600a80b0ef5 100644 --- a/sw/source/uibase/sidebar/PageFooterPanel.cxx +++ b/sw/source/uibase/sidebar/PageFooterPanel.cxx @@ -177,7 +177,7 @@ void PageFooterPanel::NotifyItemUpdate( case SID_ATTR_PAGE_FOOTER: { if(eState >= SfxItemState::DEFAULT && - pState && dynamic_cast<const SfxBoolItem*>( pState) != nullptr ) + dynamic_cast<const SfxBoolItem*>( pState) ) { mpFooterItem.reset( static_cast<SfxBoolItem*>(pState->Clone()) ); mpFooterToggle->Check(mpFooterItem->GetValue()); @@ -188,7 +188,7 @@ void PageFooterPanel::NotifyItemUpdate( case SID_ATTR_PAGE_FOOTER_LRMARGIN: { if(eState >= SfxItemState::DEFAULT && - pState && dynamic_cast<const SvxLongLRSpaceItem*>( pState) != nullptr ) + dynamic_cast<const SvxLongLRSpaceItem*>( pState) ) { mpFooterLRMarginItem.reset( static_cast<SvxLongLRSpaceItem*>(pState->Clone()) ); UpdateMarginControl(); @@ -198,7 +198,7 @@ void PageFooterPanel::NotifyItemUpdate( case SID_ATTR_PAGE_FOOTER_SPACING: { if(eState >= SfxItemState::DEFAULT && - pState && dynamic_cast<const SvxLongULSpaceItem*>( pState) != nullptr ) + dynamic_cast<const SvxLongULSpaceItem*>( pState) ) { mpFooterSpacingItem.reset(static_cast<SvxLongULSpaceItem*>(pState->Clone()) ); UpdateSpacingControl(); @@ -208,7 +208,7 @@ void PageFooterPanel::NotifyItemUpdate( case SID_ATTR_PAGE_FOOTER_LAYOUT: { if(eState >= SfxItemState::DEFAULT && - pState && dynamic_cast<const SfxInt16Item*>( pState) != nullptr ) + dynamic_cast<const SfxInt16Item*>( pState) ) { mpFooterLayoutItem.reset(static_cast<SfxInt16Item*>(pState->Clone()) ); UpdateLayoutControl(); diff --git a/sw/source/uibase/sidebar/PageFormatPanel.cxx b/sw/source/uibase/sidebar/PageFormatPanel.cxx index 25c7018edeb4..e0d6b385acd7 100644 --- a/sw/source/uibase/sidebar/PageFormatPanel.cxx +++ b/sw/source/uibase/sidebar/PageFormatPanel.cxx @@ -178,7 +178,7 @@ void PageFormatPanel::NotifyItemUpdate( case SID_ATTR_PAGE: { if ( eState >= SfxItemState::DEFAULT && - pState && dynamic_cast< const SvxPageItem *>( pState ) != nullptr ) + dynamic_cast< const SvxPageItem *>( pState ) ) { mpPageItem.reset( static_cast<SvxPageItem*>(pState->Clone()) ); if ( mpPageItem->IsLandscape() ) @@ -191,7 +191,7 @@ void PageFormatPanel::NotifyItemUpdate( case SID_ATTR_PAGE_LRSPACE: { if ( eState >= SfxItemState::DEFAULT && - pState && dynamic_cast< const SvxLongLRSpaceItem *>( pState ) != nullptr ) + dynamic_cast< const SvxLongLRSpaceItem *>( pState ) ) { mpPageLRMarginItem.reset( static_cast<SvxLongLRSpaceItem*>(pState->Clone()) ); UpdateMarginBox(); @@ -201,7 +201,7 @@ void PageFormatPanel::NotifyItemUpdate( case SID_ATTR_PAGE_ULSPACE: { if ( eState >= SfxItemState::DEFAULT && - pState && dynamic_cast< const SvxLongULSpaceItem *>( pState ) != nullptr ) + dynamic_cast< const SvxLongULSpaceItem *>( pState ) ) { mpPageULMarginItem.reset( static_cast<SvxLongULSpaceItem*>(pState->Clone()) ); UpdateMarginBox(); diff --git a/sw/source/uibase/sidebar/PageHeaderPanel.cxx b/sw/source/uibase/sidebar/PageHeaderPanel.cxx index 0421b18e6200..b5206aeec426 100644 --- a/sw/source/uibase/sidebar/PageHeaderPanel.cxx +++ b/sw/source/uibase/sidebar/PageHeaderPanel.cxx @@ -180,7 +180,7 @@ void PageHeaderPanel::NotifyItemUpdate( case SID_ATTR_PAGE_HEADER: { if(eState >= SfxItemState::DEFAULT && - pState && dynamic_cast<const SfxBoolItem*>( pState) != nullptr ) + dynamic_cast<const SfxBoolItem*>( pState) ) { mpHeaderItem.reset( static_cast<SfxBoolItem*>(pState->Clone()) ); mpHeaderToggle->Check(mpHeaderItem->GetValue()); @@ -191,7 +191,7 @@ void PageHeaderPanel::NotifyItemUpdate( case SID_ATTR_PAGE_HEADER_LRMARGIN: { if(eState >= SfxItemState::DEFAULT && - pState && dynamic_cast<const SvxLongLRSpaceItem*>( pState) != nullptr ) + dynamic_cast<const SvxLongLRSpaceItem*>( pState) ) { mpHeaderLRMarginItem.reset( static_cast<SvxLongLRSpaceItem*>(pState->Clone()) ); UpdateMarginControl(); @@ -201,7 +201,7 @@ void PageHeaderPanel::NotifyItemUpdate( case SID_ATTR_PAGE_HEADER_SPACING: { if(eState >= SfxItemState::DEFAULT && - pState && dynamic_cast<const SvxLongULSpaceItem*>( pState) != nullptr ) + dynamic_cast<const SvxLongULSpaceItem*>( pState) ) { mpHeaderSpacingItem.reset(static_cast<SvxLongULSpaceItem*>(pState->Clone()) ); UpdateSpacingControl(); @@ -211,7 +211,7 @@ void PageHeaderPanel::NotifyItemUpdate( case SID_ATTR_PAGE_HEADER_LAYOUT: { if(eState >= SfxItemState::DEFAULT && - pState && dynamic_cast<const SfxInt16Item*>( pState) != nullptr ) + dynamic_cast<const SfxInt16Item*>( pState) ) { mpHeaderLayoutItem.reset(static_cast<SfxInt16Item*>(pState->Clone()) ); UpdateLayoutControl(); diff --git a/sw/source/uibase/sidebar/PageStylesPanel.cxx b/sw/source/uibase/sidebar/PageStylesPanel.cxx index 1e13e367c272..94a5d99c46cc 100644 --- a/sw/source/uibase/sidebar/PageStylesPanel.cxx +++ b/sw/source/uibase/sidebar/PageStylesPanel.cxx @@ -331,7 +331,7 @@ void PageStylesPanel::NotifyItemUpdate( case SID_ATTR_PAGE_COLUMN: { if ( eState >= SfxItemState::DEFAULT && - pState && dynamic_cast< const SfxInt16Item *>( pState ) != nullptr ) + dynamic_cast< const SfxInt16Item *>( pState ) ) { mpPageColumnItem.reset( static_cast<SfxInt16Item*>(pState->Clone()) ); if(mpPageColumnItem->GetValue() <= 5) @@ -352,7 +352,7 @@ void PageStylesPanel::NotifyItemUpdate( case SID_ATTR_PAGE: { if( eState >= SfxItemState::DEFAULT && - pState && dynamic_cast< const SvxPageItem*>( pState ) != nullptr ) + dynamic_cast< const SvxPageItem*>( pState ) ) { mpPageItem.reset( static_cast<SvxPageItem*>(pState->Clone()) ); SvxNumType eNumType = mpPageItem->GetNumType(); diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx index 328f3c209502..56ca22fe98d0 100644 --- a/sw/source/uibase/uno/unotxdoc.cxx +++ b/sw/source/uibase/uno/unotxdoc.cxx @@ -2446,14 +2446,13 @@ SwDoc * SwXTextDocument::GetRenderDoc( // the view shell should be SwView for documents PDF export. // for the page preview no selection should be possible // (the export dialog does not allow for this option) - if (rpView && dynamic_cast< const SwView *>( rpView ) != nullptr) + if (auto pSwView = dynamic_cast<SwView *>( rpView )) { if (!m_pRenderData) { OSL_FAIL("GetRenderDoc: no renderdata"); return nullptr; } - SwView *const pSwView(static_cast<SwView *>(rpView)); SfxObjectShellLock xDocSh(m_pRenderData->GetTempDocShell()); if (!xDocSh.Is()) { |