diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-11-07 13:55:06 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-11-09 07:31:24 +0100 |
commit | 5ba447bdcd13ba3d7c27c8609f207910227e4ab6 (patch) | |
tree | 9a59e7058ef40be90867518590e35abb6c0615f5 /sd/source/ui | |
parent | ea4a47d7d442d5d897cfa3a6e9f09ce3f1f233c5 (diff) |
new loplugin simplifydynamiccast
simplify dynamic_cast followed by static_cast
Change-Id: I965afcf05d1675094cfde53d3590a0fd00f26279
Reviewed-on: https://gerrit.libreoffice.org/44460
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sd/source/ui')
-rw-r--r-- | sd/source/ui/app/sdmod2.cxx | 4 | ||||
-rw-r--r-- | sd/source/ui/app/tmplctrl.cxx | 4 | ||||
-rw-r--r-- | sd/source/ui/func/fuconrec.cxx | 18 | ||||
-rw-r--r-- | sd/source/ui/func/futext.cxx | 3 | ||||
-rw-r--r-- | sd/source/ui/view/DocumentRenderer.cxx | 4 | ||||
-rw-r--r-- | sd/source/ui/view/drviews8.cxx | 7 | ||||
-rw-r--r-- | sd/source/ui/view/drviewsf.cxx | 8 | ||||
-rw-r--r-- | sd/source/ui/view/outlnvsh.cxx | 8 |
8 files changed, 26 insertions, 30 deletions
diff --git a/sd/source/ui/app/sdmod2.cxx b/sd/source/ui/app/sdmod2.cxx index b7b51f41917c..9fc37b1c70e4 100644 --- a/sd/source/ui/app/sdmod2.cxx +++ b/sd/source/ui/app/sdmod2.cxx @@ -91,8 +91,8 @@ static SdPage* GetCurrentPage( sd::ViewShell const * pViewSh, EditFieldInfo cons // first try to check if we are inside the outline view sd::OutlineView* pSdView = nullptr; - if( dynamic_cast<const sd::OutlineViewShell* >(pViewSh) != nullptr ) - pSdView = static_cast<sd::OutlineView*> (static_cast<sd::OutlineViewShell const *>(pViewSh)->GetView()); + if( auto pOutlineViewShell = dynamic_cast<const sd::OutlineViewShell* >(pViewSh) ) + pSdView = static_cast<sd::OutlineView*>(pOutlineViewShell->GetView()); if (pSdView != nullptr && (pOutliner == &pSdView->GetOutliner())) { diff --git a/sd/source/ui/app/tmplctrl.cxx b/sd/source/ui/app/tmplctrl.cxx index 689dde24db77..a90e0a7bf535 100644 --- a/sd/source/ui/app/tmplctrl.cxx +++ b/sd/source/ui/app/tmplctrl.cxx @@ -78,9 +78,9 @@ void SdTemplateControl::StateChanged( { if( eState != SfxItemState::DEFAULT || pState->IsVoidItem() ) GetStatusBar().SetItemText( GetId(), OUString() ); - else if ( dynamic_cast< const SfxStringItem *>( pState ) != nullptr ) + else if ( auto pStringItem = dynamic_cast< const SfxStringItem *>( pState ) ) { - msTemplate = static_cast<const SfxStringItem*>(pState)->GetValue(); + msTemplate = pStringItem->GetValue(); GetStatusBar().SetItemText( GetId(), msTemplate ); } } diff --git a/sd/source/ui/func/fuconrec.cxx b/sd/source/ui/func/fuconrec.cxx index bc5f9c5685c5..e10b37b53c0e 100644 --- a/sd/source/ui/func/fuconrec.cxx +++ b/sd/source/ui/func/fuconrec.cxx @@ -819,11 +819,11 @@ SdrObject* FuConstructRectangle::CreateDefaultObject(const sal_uInt16 nID, const case SID_DRAW_MEASURELINE: { - if( dynamic_cast< SdrMeasureObj *>( pObj ) != nullptr) + if( auto pMeasureObj = dynamic_cast< SdrMeasureObj *>( pObj ) ) { sal_Int32 nYMiddle((aRect.Top() + aRect.Bottom()) / 2); - static_cast<SdrMeasureObj*>(pObj)->SetPoint(Point(aStart.X(), nYMiddle), 0); - static_cast<SdrMeasureObj*>(pObj)->SetPoint(Point(aEnd.X(), nYMiddle), 1); + pMeasureObj->SetPoint(Point(aStart.X(), nYMiddle), 0); + pMeasureObj->SetPoint(Point(aEnd.X(), nYMiddle), 1); } else { @@ -862,10 +862,10 @@ SdrObject* FuConstructRectangle::CreateDefaultObject(const sal_uInt16 nID, const case SID_CONNECTOR_LINES_CIRCLE_END: case SID_CONNECTOR_LINES_CIRCLES: { - if( dynamic_cast< SdrEdgeObj *>( pObj ) != nullptr) + if( auto pEdgeObj = dynamic_cast< SdrEdgeObj *>( pObj ) ) { - static_cast<SdrEdgeObj*>(pObj)->SetTailPoint(false, aStart); - static_cast<SdrEdgeObj*>(pObj)->SetTailPoint(true, aEnd); + pEdgeObj->SetTailPoint(false, aStart); + pEdgeObj->SetTailPoint(true, aEnd); } else { @@ -877,7 +877,7 @@ SdrObject* FuConstructRectangle::CreateDefaultObject(const sal_uInt16 nID, const case SID_DRAW_CAPTION: case SID_DRAW_CAPTION_VERTICAL: { - if( dynamic_cast< SdrCaptionObj *>( pObj ) != nullptr) + if( auto pCaptionObj = dynamic_cast< SdrCaptionObj *>( pObj ) ) { bool bIsVertical(SID_DRAW_CAPTION_VERTICAL == nID); @@ -893,8 +893,8 @@ SdrObject* FuConstructRectangle::CreateDefaultObject(const sal_uInt16 nID, const // The default text is not inserted anymore. - static_cast<SdrCaptionObj*>(pObj)->SetLogicRect(aRect); - static_cast<SdrCaptionObj*>(pObj)->SetTailPos( + pCaptionObj->SetLogicRect(aRect); + pCaptionObj->SetTailPos( aRect.TopLeft() - Point(aRect.GetWidth() / 2, aRect.GetHeight() / 2)); } else diff --git a/sd/source/ui/func/futext.cxx b/sd/source/ui/func/futext.cxx index 9ea0570e6e17..2b4ca65526cb 100644 --- a/sd/source/ui/func/futext.cxx +++ b/sd/source/ui/func/futext.cxx @@ -1313,9 +1313,8 @@ SdrObject* FuText::CreateDefaultObject(const sal_uInt16 nID, const ::tools::Rect if(pObj) { - if( dynamic_cast< SdrTextObj *>( pObj ) != nullptr) + if( auto pText = dynamic_cast< SdrTextObj *>( pObj ) ) { - SdrTextObj* pText = static_cast<SdrTextObj*>(pObj); pText->SetLogicRect(rRectangle); bool bVertical = (SID_ATTR_CHAR_VERTICAL == nID || SID_TEXT_FITTOSIZE_VERTICAL == nID); diff --git a/sd/source/ui/view/DocumentRenderer.cxx b/sd/source/ui/view/DocumentRenderer.cxx index 608a4af642bb..426f06615983 100644 --- a/sd/source/ui/view/DocumentRenderer.cxx +++ b/sd/source/ui/view/DocumentRenderer.cxx @@ -1414,8 +1414,8 @@ private: rOutliner.SetControlWord( nCntrl ); // When in outline view then apply all pending changes to the model. - if( dynamic_cast< OutlineViewShell *>( pShell ) != nullptr) - static_cast<OutlineViewShell*>(pShell)->PrepareClose (false); + if( auto pOutlineViewShell = dynamic_cast< OutlineViewShell *>( pShell ) ) + pOutlineViewShell->PrepareClose (false); // Collect some frequently used data. if (mpOptions->IsDate()) diff --git a/sd/source/ui/view/drviews8.cxx b/sd/source/ui/view/drviews8.cxx index 29e6cb2ab683..3d0bf89a5888 100644 --- a/sd/source/ui/view/drviews8.cxx +++ b/sd/source/ui/view/drviews8.cxx @@ -97,7 +97,6 @@ void DrawViewShell::ScannerEvent() Point aPnt ( ( aPageSize.Width() - aBmpSize.Width() ) >> 1, ( aPageSize.Height() - aBmpSize.Height() ) >> 1 ); aPnt += Point( pPage->GetLeftBorder(), pPage->GetUpperBorder() ); ::tools::Rectangle aRect( aPnt, aBmpSize ); - SdrGrafObj* pGrafObj = nullptr; bool bInsertNewObject = true; if( GetView()->AreObjectsMarked() ) @@ -109,10 +108,8 @@ void DrawViewShell::ScannerEvent() SdrMark* pMark = rMarkList.GetMark(0); SdrObject* pObj = pMark->GetMarkedSdrObj(); - if( dynamic_cast< SdrGrafObj *>( pObj ) != nullptr ) + if( auto pGrafObj = dynamic_cast< SdrGrafObj *>( pObj ) ) { - pGrafObj = static_cast< SdrGrafObj* >( pObj ); - if( pGrafObj->IsEmptyPresObj() ) { bInsertNewObject = false; @@ -126,7 +123,7 @@ void DrawViewShell::ScannerEvent() if( bInsertNewObject ) { - pGrafObj = new SdrGrafObj( Graphic( aScanBmp ), aRect ); + auto pGrafObj = new SdrGrafObj( Graphic( aScanBmp ), aRect ); SdrPageView* pPV = GetView()->GetSdrPageView(); GetView()->InsertObjectAtView( pGrafObj, *pPV, SdrInsertFlags::SETDEFLAYER ); } diff --git a/sd/source/ui/view/drviewsf.cxx b/sd/source/ui/view/drviewsf.cxx index 28210ef42cb2..218312476031 100644 --- a/sd/source/ui/view/drviewsf.cxx +++ b/sd/source/ui/view/drviewsf.cxx @@ -96,11 +96,11 @@ void DrawViewShell::GetCtrlState(SfxItemSet &rSet) if ( abs( aSel.nEndPos - aSel.nStartPos ) == 1 ) { const SvxFieldData* pField = pFieldItem->GetField(); - if( dynamic_cast< const SvxURLField *>( pField ) != nullptr) + if( auto pUrlField = dynamic_cast< const SvxURLField *>( pField ) ) { - aHLinkItem.SetName(static_cast<const SvxURLField*>(pField)->GetRepresentation()); - aHLinkItem.SetURL(static_cast<const SvxURLField*>(pField)->GetURL()); - aHLinkItem.SetTargetFrame(static_cast<const SvxURLField*>(pField)->GetTargetFrame()); + aHLinkItem.SetName(pUrlField->GetRepresentation()); + aHLinkItem.SetURL(pUrlField->GetURL()); + aHLinkItem.SetTargetFrame(pUrlField->GetTargetFrame()); bField = true; } } diff --git a/sd/source/ui/view/outlnvsh.cxx b/sd/source/ui/view/outlnvsh.cxx index 842ad38be060..6b53701739b8 100644 --- a/sd/source/ui/view/outlnvsh.cxx +++ b/sd/source/ui/view/outlnvsh.cxx @@ -362,11 +362,11 @@ void OutlineViewShell::GetCtrlState(SfxItemSet &rSet) if ( abs( aSel.nEndPos - aSel.nStartPos ) == 1 ) { const SvxFieldData* pField = pFieldItem->GetField(); - if ( dynamic_cast< const SvxURLField *>( pField ) != nullptr ) + if ( auto pUrlField = dynamic_cast< const SvxURLField *>( pField ) ) { - aHLinkItem.SetName(static_cast<const SvxURLField*>(pField)->GetRepresentation()); - aHLinkItem.SetURL(static_cast<const SvxURLField*>(pField)->GetURL()); - aHLinkItem.SetTargetFrame(static_cast<const SvxURLField*>(pField)->GetTargetFrame()); + aHLinkItem.SetName(pUrlField->GetRepresentation()); + aHLinkItem.SetURL(pUrlField->GetURL()); + aHLinkItem.SetTargetFrame(pUrlField->GetTargetFrame()); } } } |