diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-10-20 20:51:50 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2017-10-21 15:44:11 +0200 |
commit | ead920a48aa8c35075fdb980b9d213ff1c580dd1 (patch) | |
tree | bb1628fd293f03b22920bc74e89657320da6442e | |
parent | fe5b70723fc83f229fb4b41231a663a8700f48c4 (diff) |
loplugin:redundantcast handle dynamic_cast
Change-Id: I7855c76e820efce96778b1c19ec71dffcc4b4abb
Reviewed-on: https://gerrit.libreoffice.org/43621
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
26 files changed, 96 insertions, 65 deletions
diff --git a/basic/source/classes/sbunoobj.cxx b/basic/source/classes/sbunoobj.cxx index 0b63ea746e13..0dea0076bc90 100644 --- a/basic/source/classes/sbunoobj.cxx +++ b/basic/source/classes/sbunoobj.cxx @@ -2428,7 +2428,7 @@ void clearUnoMethodsForBasic( StarBASIC const * pBasic ) SbUnoMethod* pMeth = pFirst; while( pMeth ) { - SbxObject* pObject = dynamic_cast< SbxObject* >( pMeth->GetParent() ); + SbxObject* pObject = pMeth->GetParent(); if ( pObject ) { StarBASIC* pModBasic = dynamic_cast< StarBASIC* >( pObject->GetParent() ); diff --git a/basic/source/classes/sbxmod.cxx b/basic/source/classes/sbxmod.cxx index 25b2cf418923..85b5a2412653 100644 --- a/basic/source/classes/sbxmod.cxx +++ b/basic/source/classes/sbxmod.cxx @@ -1303,7 +1303,7 @@ void SbModule::ClearPrivateVars() { for( sal_uInt16 j = 0 ; j < pArray->Count() ; j++ ) { - SbxVariable* pj = dynamic_cast<SbxVariable*>( pArray->Get( j ) ); + SbxVariable* pj = pArray->Get( j ); pj->SbxValue::Clear(); } } @@ -1356,7 +1356,7 @@ void SbModule::ClearVarsDependingOnDeletedBasic( StarBASIC* pDeletedBasic ) { for( sal_uInt16 j = 0 ; j < pArray->Count() ; j++ ) { - SbxVariable* pVar = dynamic_cast<SbxVariable*>( pArray->Get( j ) ); + SbxVariable* pVar = pArray->Get( j ); implClearIfVarDependsOnDeletedBasic( pVar, pDeletedBasic ); } } diff --git a/basic/source/sbx/sbxobj.cxx b/basic/source/sbx/sbxobj.cxx index 4bdc64e86c1f..56bec717b8aa 100644 --- a/basic/source/sbx/sbxobj.cxx +++ b/basic/source/sbx/sbxobj.cxx @@ -845,9 +845,9 @@ void SbxObject::Dump( SvStream& rStrm, bool bFill ) { pSbxObj->Dump(rStrm, bFill); } - else if (SbxVariable *pSbxVar = dynamic_cast<SbxVariable*>(pVar)) + else { - pSbxVar->Dump(rStrm, bFill); + pVar->Dump(rStrm, bFill); } } } diff --git a/compilerplugins/clang/redundantcast.cxx b/compilerplugins/clang/redundantcast.cxx index 30914a460dc4..c28878e9e536 100644 --- a/compilerplugins/clang/redundantcast.cxx +++ b/compilerplugins/clang/redundantcast.cxx @@ -128,6 +128,8 @@ public: bool VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr const * expr); + bool VisitCXXDynamicCastExpr(CXXDynamicCastExpr const * expr); + bool VisitCallExpr(CallExpr const * expr); bool VisitCXXDeleteExpr(CXXDeleteExpr const * expr); @@ -676,6 +678,28 @@ bool RedundantCast::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr const * exp return true; } +bool RedundantCast::VisitCXXDynamicCastExpr(CXXDynamicCastExpr const * expr) { + if (ignoreLocation(expr)) { + return true; + } + // ignore dynamic_cast<T1>(static_cast<T1>(void*)), it's necessary + if (auto subStaticCast = dyn_cast<CXXStaticCastExpr>(expr->getSubExpr())) { + if (loplugin::TypeCheck(subStaticCast->getSubExpr()->getType()).Pointer().Void()) + return true; + } + // so far this only deals with dynamic casting from T to T + auto const sub = compat::getSubExprAsWritten(expr); + auto const t1 = expr->getTypeAsWritten(); + auto const t2 = sub->getType(); + if (t1.getCanonicalType() != t2.getCanonicalType()) + return true; + report( + DiagnosticsEngine::Warning, + "redundant dynamic cast from %0 to %1", expr->getExprLoc()) + << t2 << t1 << expr->getSourceRange(); + return true; +} + bool RedundantCast::VisitCallExpr(CallExpr const * expr) { if (ignoreLocation(expr)) { return true; diff --git a/compilerplugins/clang/test/redundantcast.cxx b/compilerplugins/clang/test/redundantcast.cxx index ff3e8392906a..38c44f837cbc 100644 --- a/compilerplugins/clang/test/redundantcast.cxx +++ b/compilerplugins/clang/test/redundantcast.cxx @@ -325,6 +325,25 @@ void testReinterpretConstCast() { (void) reinterpret_cast<std::size_t>((const_cast<int const *>(&n))); // expected-error-re {{redundant const_cast from 'int *' to 'const int *' within reinterpret_cast to fundamental type 'std::size_t' (aka 'unsigned {{.+}}') [loplugin:redundantcast]}} } +void testDynamicCast() { + + struct S1 { virtual ~S1(); }; + struct S2 final: S1 {}; + struct S3: S1 {}; + + S1 * s1 = nullptr; + S2 * s2 = nullptr; + void * v1 = nullptr; + + (void) dynamic_cast<S2 *>(s1); + (void) dynamic_cast<S1 *>(s2); + (void) dynamic_cast<S2 *>(s2); // expected-error {{redundant dynamic cast from 'S2 *' to 'S2 *' [loplugin:redundantcast]}} + (void) dynamic_cast<S3 *>(s2); + // used in some assert in vcl + (void) dynamic_cast<S1 *>(static_cast<S1*>(v1)); + (void) dynamic_cast<S2 *>(static_cast<S2*>(s1)); // expected-error {{redundant dynamic cast from 'S2 *' to 'S2 *' [loplugin:redundantcast]}} +} + int main() { testConstCast(); testStaticCast(); @@ -332,6 +351,7 @@ int main() { testCStyleCast(); testCStyleCastOfTemplateMethodResult(nullptr); testReinterpretConstCast(); + testDynamicCast(); } /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/drawinglayer/source/primitive2d/textbreakuphelper.cxx b/drawinglayer/source/primitive2d/textbreakuphelper.cxx index 3383b66f87cd..93f14e4926de 100644 --- a/drawinglayer/source/primitive2d/textbreakuphelper.cxx +++ b/drawinglayer/source/primitive2d/textbreakuphelper.cxx @@ -37,7 +37,6 @@ namespace drawinglayer maDecTrans(), mbNoDXArray(false) { - OSL_ENSURE(dynamic_cast< const TextSimplePortionPrimitive2D* >(&mrSource), "TextBreakupHelper with illegal primitive created (!)"); maDecTrans = mrSource.getTextTransform(); mbNoDXArray = mrSource.getDXArray().empty(); diff --git a/lotuswordpro/source/filter/lwpframelayout.cxx b/lotuswordpro/source/filter/lwpframelayout.cxx index a4d7f0be796d..e2cb4fa84611 100644 --- a/lotuswordpro/source/filter/lwpframelayout.cxx +++ b/lotuswordpro/source/filter/lwpframelayout.cxx @@ -714,7 +714,7 @@ void LwpFrame::ParseAnchorType(XFFrame *pXFFrame) bool LwpFrame::IsLeftWider() { rtl::Reference<LwpVirtualLayout> xLayout(m_pLayout->GetContainerLayout()); - LwpVirtualLayout* pParent = dynamic_cast<LwpVirtualLayout*>(xLayout.get()); + LwpVirtualLayout* pParent = xLayout.get(); if (pParent) { LwpPoint aPoint = m_pLayout->GetOrigin(); diff --git a/oox/source/ppt/backgroundproperties.cxx b/oox/source/ppt/backgroundproperties.cxx index b7ddcbcb5543..49a12c7aa2f3 100644 --- a/oox/source/ppt/backgroundproperties.cxx +++ b/oox/source/ppt/backgroundproperties.cxx @@ -44,7 +44,7 @@ BackgroundPropertiesContext::BackgroundPropertiesContext( FragmentHandler2 const return this; } - return dynamic_cast <ContextHandler *> (::oox::drawingml::FillPropertiesContext::createFillContext( *this, aElementToken, rAttribs, mrFillProperties ).get()); + return ::oox::drawingml::FillPropertiesContext::createFillContext( *this, aElementToken, rAttribs, mrFillProperties ).get(); } } } diff --git a/sd/qa/unit/export-tests-ooxml1.cxx b/sd/qa/unit/export-tests-ooxml1.cxx index 548352ae0fa6..88a38e7835a4 100644 --- a/sd/qa/unit/export-tests-ooxml1.cxx +++ b/sd/qa/unit/export-tests-ooxml1.cxx @@ -373,12 +373,12 @@ void SdOOXMLExportTest1::testBnc880763() // First object in the background has blue background color const SdrObjGroup *pObjGroup = dynamic_cast<SdrObjGroup *>(pPage->GetObj(0)); CPPUNIT_ASSERT(pObjGroup); - const SdrObject *pObj = dynamic_cast<SdrObject *>(pObjGroup->GetSubList()->GetObj(0)); + const SdrObject *pObj = pObjGroup->GetSubList()->GetObj(0); CPPUNIT_ASSERT_MESSAGE( "no object", pObj != nullptr); CPPUNIT_ASSERT_EQUAL( sal_uInt32(0x0000ff),(static_cast< const XColorItem& >(pObj->GetMergedItem(XATTR_FILLCOLOR))).GetColorValue().GetColor()); // Second object at the front has green background color - pObj = dynamic_cast<SdrObject *>(pPage->GetObj(2)); // FIXME should be 1, smartart import creates an additional empty group for some reason + pObj = pPage->GetObj(2); // FIXME should be 1, smartart import creates an additional empty group for some reason CPPUNIT_ASSERT_MESSAGE( "no object", pObj != nullptr); CPPUNIT_ASSERT_EQUAL( sal_uInt32(0x00ff00),(static_cast< const XColorItem& >(pObj->GetMergedItem(XATTR_FILLCOLOR))).GetColorValue().GetColor()); @@ -395,7 +395,7 @@ void SdOOXMLExportTest1::testBnc862510_5() // Same as testBnc870237, but here we check the horizontal spacing const SdrObjGroup *pObjGroup = dynamic_cast<SdrObjGroup *>(pPage->GetObj(0)); CPPUNIT_ASSERT(pObjGroup); - const SdrObject* pObj = dynamic_cast<SdrObject*>(pObjGroup->GetSubList()->GetObj(1)); + const SdrObject* pObj = pObjGroup->GetSubList()->GetObj(1); CPPUNIT_ASSERT_MESSAGE( "no object", pObj != nullptr); CPPUNIT_ASSERT_EQUAL( sal_Int32(0), (static_cast< const SdrMetricItem& >(pObj->GetMergedItem(SDRATTR_TEXT_UPPERDIST))).GetValue()); CPPUNIT_ASSERT_EQUAL( sal_Int32(0), (static_cast< const SdrMetricItem& >(pObj->GetMergedItem(SDRATTR_TEXT_LOWERDIST))).GetValue()); diff --git a/sd/qa/unit/export-tests-ooxml2.cxx b/sd/qa/unit/export-tests-ooxml2.cxx index 586700e39863..e430e37b4c4a 100644 --- a/sd/qa/unit/export-tests-ooxml2.cxx +++ b/sd/qa/unit/export-tests-ooxml2.cxx @@ -240,7 +240,7 @@ void SdOOXMLExportTest2::testBnc822341() const SdrPage *pPage = GetPage( 1, xDocShRef.get() ); - const SdrObject* pObj = dynamic_cast<SdrObject*>( pPage->GetObj(0) ); + const SdrObject* pObj = pPage->GetObj(0); CPPUNIT_ASSERT_MESSAGE( "no object", pObj != nullptr); CPPUNIT_ASSERT_EQUAL( static_cast<sal_uInt16>(OBJ_OLE2), pObj->GetObjIdentifier() ); } @@ -273,7 +273,7 @@ void SdOOXMLExportTest2::testBnc822341() const SdrPage *pPage = pDoc->GetPage(1); CPPUNIT_ASSERT_MESSAGE( "no page", pPage != nullptr ); - const SdrObject* pObj = dynamic_cast<SdrObject*>( pPage->GetObj(0) ); + const SdrObject* pObj = pPage->GetObj(0); CPPUNIT_ASSERT_MESSAGE( "no object", pObj != nullptr); CPPUNIT_ASSERT_EQUAL( static_cast<sal_uInt16>(OBJ_OLE2), pObj->GetObjIdentifier() ); } @@ -300,7 +300,7 @@ void SdOOXMLExportTest2::testMathObject() "a"); const SdrPage *pPage = GetPage(1, xDocShRef); - const SdrObject* pObj = dynamic_cast<SdrObject*>(pPage->GetObj(0)); + const SdrObject* pObj = pPage->GetObj(0); CPPUNIT_ASSERT_MESSAGE("no object", pObj != nullptr); CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(OBJ_OLE2), pObj->GetObjIdentifier()); } @@ -320,7 +320,7 @@ void SdOOXMLExportTest2::testMathObject() "a"); const SdrPage *pPage = GetPage(1, xDocShRef); - const SdrObject* pObj = dynamic_cast<SdrObject*>(pPage->GetObj(0)); + const SdrObject* pObj = pPage->GetObj(0); CPPUNIT_ASSERT_MESSAGE("no object", pObj != nullptr); CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(OBJ_OLE2), pObj->GetObjIdentifier()); } @@ -347,7 +347,7 @@ void SdOOXMLExportTest2::testMathObjectPPT2010() u"\U0001D44E"); // non-BMP char const SdrPage *pPage = GetPage(1, xDocShRef); - const SdrObject* pObj = dynamic_cast<SdrObject*>(pPage->GetObj(0)); + const SdrObject* pObj = pPage->GetObj(0); CPPUNIT_ASSERT_MESSAGE("no object", pObj != nullptr); CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(OBJ_OLE2), pObj->GetObjIdentifier()); } diff --git a/sd/source/ui/dlg/sdtreelb.cxx b/sd/source/ui/dlg/sdtreelb.cxx index c573ffdbf0f8..b6b97a595ae7 100644 --- a/sd/source/ui/dlg/sdtreelb.cxx +++ b/sd/source/ui/dlg/sdtreelb.cxx @@ -1290,7 +1290,7 @@ SvTreeListEntry* SdPageObjsTLB::GetDropTarget (const Point& rLocation) sal_uInt16 nDepth (0); do { - pNext = dynamic_cast<SvTreeListEntry*>(NextVisible(pEntry, &nDepth)); + pNext = NextVisible(pEntry, &nDepth); if (pNext != nullptr && nDepth > 0 && nDepth!=0xffff) pEntry = pNext; else diff --git a/sd/source/ui/slidesorter/controller/SlsSelectionManager.cxx b/sd/source/ui/slidesorter/controller/SlsSelectionManager.cxx index bc73878e8d30..6f4c15ac059e 100644 --- a/sd/source/ui/slidesorter/controller/SlsSelectionManager.cxx +++ b/sd/source/ui/slidesorter/controller/SlsSelectionManager.cxx @@ -108,7 +108,7 @@ void SelectionManager::DeleteSelectedPages (const bool bSelectFollowingPage) const auto pViewShell = mrSlideSorter.GetViewShell(); const auto pDrawViewShell = pViewShell ? std::dynamic_pointer_cast<sd::DrawViewShell>(pViewShell->GetViewShellBase().GetMainViewShell()) : nullptr; - const auto pDrawView = pDrawViewShell ? dynamic_cast<sd::DrawView*>(pDrawViewShell->GetDrawView()) : nullptr; + const auto pDrawView = pDrawViewShell ? pDrawViewShell->GetDrawView() : nullptr; if (pDrawView) pDrawView->BlockPageOrderChangedHint(true); diff --git a/svtools/source/contnr/treelistbox.cxx b/svtools/source/contnr/treelistbox.cxx index beaeb7a7beeb..46286451c11c 100644 --- a/svtools/source/contnr/treelistbox.cxx +++ b/svtools/source/contnr/treelistbox.cxx @@ -3413,20 +3413,13 @@ void SvTreeListBox::ModelNotification( SvListAction nActionId, SvTreeListEntry* { case SvListAction::INSERTED: { - SvTreeListEntry* pEntry( dynamic_cast< SvTreeListEntry* >( pEntry1 ) ); - if ( !pEntry ) - { - SAL_WARN( "svtools.contnr", "SvTreeListBox::ModelNotification: invalid entry!" ); - break; - } - - SvLBoxContextBmp* pBmpItem = static_cast< SvLBoxContextBmp* >( pEntry->GetFirstItem( SvLBoxItemType::ContextBmp ) ); + SvLBoxContextBmp* pBmpItem = static_cast< SvLBoxContextBmp* >( pEntry1->GetFirstItem( SvLBoxItemType::ContextBmp ) ); if ( !pBmpItem ) break; const Image& rBitmap1( pBmpItem->GetBitmap1() ); const Image& rBitmap2( pBmpItem->GetBitmap2() ); short nMaxWidth = short( std::max( rBitmap1.GetSizePixel().Width(), rBitmap2.GetSizePixel().Width() ) ); - nMaxWidth = pImpl->UpdateContextBmpWidthVector( pEntry, nMaxWidth ); + nMaxWidth = pImpl->UpdateContextBmpWidthVector( pEntry1, nMaxWidth ); if( nMaxWidth > nContextBmpWidthMax ) { nContextBmpWidthMax = nMaxWidth; diff --git a/svx/source/engine3d/view3d.cxx b/svx/source/engine3d/view3d.cxx index 076668af6fcf..7ce414051170 100644 --- a/svx/source/engine3d/view3d.cxx +++ b/svx/source/engine3d/view3d.cxx @@ -507,7 +507,7 @@ bool E3dView::ImpCloneAll3DObjectsToDestScene(E3dScene const * pSrcScene, E3dSce if(pCompoundObj) { - E3dCompoundObject* pNewCompoundObj = dynamic_cast< E3dCompoundObject* >(pCompoundObj->Clone()); + E3dCompoundObject* pNewCompoundObj = pCompoundObj->Clone(); if(pNewCompoundObj) { diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx index f4f61d646ee4..c8ee3a7b5fff 100644 --- a/svx/source/svdraw/svdedxv.cxx +++ b/svx/source/svdraw/svdedxv.cxx @@ -1490,18 +1490,17 @@ SdrEndTextEditKind SdrObjEditView::SdrEndTextEdit(bool bDontDeleteReally) // check deletion of entire TextObj SdrUndoAction* pDelUndo=nullptr; bool bDelObj=false; - SdrTextObj* pTextObj=dynamic_cast<SdrTextObj*>( pTEObj ); - if (pTextObj!=nullptr && bTextEditNewObj) + if (pTEObj!=nullptr && bTextEditNewObj) { - bDelObj=pTextObj->IsTextFrame() && - !pTextObj->HasText() && - !pTextObj->IsEmptyPresObj() && - !pTextObj->HasFill() && - !pTextObj->HasLine(); + bDelObj=pTEObj->IsTextFrame() && + !pTEObj->HasText() && + !pTEObj->IsEmptyPresObj() && + !pTEObj->HasFill() && + !pTEObj->HasLine(); - if(pTEObj->IsInserted() && bDelObj && pTextObj->GetObjInventor()==SdrInventor::Default && !bDontDeleteReally) + if(pTEObj->IsInserted() && bDelObj && pTEObj->GetObjInventor()==SdrInventor::Default && !bDontDeleteReally) { - SdrObjKind eIdent=(SdrObjKind)pTextObj->GetObjIdentifier(); + SdrObjKind eIdent=(SdrObjKind)pTEObj->GetObjIdentifier(); if(eIdent==OBJ_TEXT || eIdent==OBJ_TEXTEXT) { pDelUndo= GetModel()->GetSdrUndoFactory().CreateUndoDeleteObject(*pTEObj); diff --git a/sw/qa/core/uwriter.cxx b/sw/qa/core/uwriter.cxx index 98ed54f2d2fb..aad835ef4202 100644 --- a/sw/qa/core/uwriter.cxx +++ b/sw/qa/core/uwriter.cxx @@ -337,8 +337,8 @@ SwTextNode* getModelToViewTestDocument2(SwDoc *pDoc) pDoc->getIDocumentContentOperations().AppendTextNode(*aPaM.GetPoint()); pDoc->getIDocumentContentOperations().InsertString(aPaM, "AAAAA"); IDocumentMarkAccess* pMarksAccess = pDoc->getIDocumentMarkAccess(); - sw::mark::IFieldmark *pFieldmark = dynamic_cast<sw::mark::IFieldmark*>( - pMarksAccess->makeNoTextFieldBookmark(aPaM, "test", ODF_FORMDROPDOWN)); + sw::mark::IFieldmark *pFieldmark = + pMarksAccess->makeNoTextFieldBookmark(aPaM, "test", ODF_FORMDROPDOWN); CPPUNIT_ASSERT(pFieldmark); uno::Sequence< OUString > vListEntries { "BBBBB" }; (*pFieldmark->GetParameters())[ODF_FORMDROPDOWN_LISTENTRY] <<= vListEntries; diff --git a/sw/source/core/access/acctextframe.cxx b/sw/source/core/access/acctextframe.cxx index 267587eb2f05..66f01f51046a 100644 --- a/sw/source/core/access/acctextframe.cxx +++ b/sw/source/core/access/acctextframe.cxx @@ -48,8 +48,7 @@ SwAccessibleTextFrame::SwAccessibleTextFrame( msTitle(), msDesc() { - const SwFlyFrameFormat* pFlyFrameFormat = - dynamic_cast<const SwFlyFrameFormat*>( rFlyFrame.GetFormat() ); + const SwFlyFrameFormat* pFlyFrameFormat = rFlyFrame.GetFormat(); msTitle = pFlyFrameFormat->GetObjTitle(); msDesc = pFlyFrameFormat->GetObjDescription(); @@ -99,8 +98,7 @@ void SwAccessibleTextFrame::Modify( const SfxPoolItem* pOld, const SfxPoolItem * aEvent.NewValue <<= msTitle; FireAccessibleEvent( aEvent ); - const SwFlyFrameFormat* pFlyFrameFormat = - dynamic_cast<const SwFlyFrameFormat*>( pFlyFrame->GetFormat() ); + const SwFlyFrameFormat* pFlyFrameFormat = pFlyFrame->GetFormat(); if (!pFlyFrameFormat || !pFlyFrameFormat->GetObjDescription().isEmpty()) { break; @@ -113,8 +111,7 @@ void SwAccessibleTextFrame::Modify( const SfxPoolItem* pOld, const SfxPoolItem * { const OUString sOldDesc( msDesc ); - const SwFlyFrameFormat* pFlyFrameFormat = - dynamic_cast<const SwFlyFrameFormat*>( pFlyFrame->GetFormat() ); + const SwFlyFrameFormat* pFlyFrameFormat = pFlyFrame->GetFormat(); const OUString& rDesc = pFlyFrameFormat->GetObjDescription(); msDesc = rDesc; if ( msDesc.isEmpty() && diff --git a/sw/source/core/doc/notxtfrm.cxx b/sw/source/core/doc/notxtfrm.cxx index a1154b2977d5..172187fc83b2 100644 --- a/sw/source/core/doc/notxtfrm.cxx +++ b/sw/source/core/doc/notxtfrm.cxx @@ -1126,7 +1126,7 @@ bool SwNoTextFrame::IsTransparent() const void SwNoTextFrame::StopAnimation( OutputDevice* pOut ) const { // Stop animated graphics - const SwGrfNode* pGrfNd = dynamic_cast< const SwGrfNode* >(GetNode()->GetGrfNode()); + const SwGrfNode* pGrfNd = GetNode()->GetGrfNode(); if( pGrfNd && pGrfNd->IsAnimated() ) { diff --git a/sw/source/core/edit/editsh.cxx b/sw/source/core/edit/editsh.cxx index 4c622b8fb6bf..f481eacbad09 100644 --- a/sw/source/core/edit/editsh.cxx +++ b/sw/source/core/edit/editsh.cxx @@ -460,7 +460,7 @@ OUString SwEditShell::GetDropText( const sal_Int32 nChars ) const SwPaM* pTemp = pCursor; while ( bPrev ) { - SwPaM* pPrev2 = dynamic_cast< SwPaM* >( pTemp->GetPrev() ); + SwPaM* pPrev2 = pTemp->GetPrev(); bPrev = ( pPrev2 && pPrev2 != pLast ); if ( bPrev ) { diff --git a/sw/source/core/undo/undraw.cxx b/sw/source/core/undo/undraw.cxx index f516c50eba6a..40d5a33dc782 100644 --- a/sw/source/core/undo/undraw.cxx +++ b/sw/source/core/undo/undraw.cxx @@ -237,7 +237,7 @@ void SwUndoDrawGroup::UndoImpl(::sw::UndoRedoContext &) // #i45718# - follow-up of #i35635# move object to visible layer pContact->MoveObjToVisibleLayer( pObj ); - SwDrawFrameFormat* pDrawFrameFormat = dynamic_cast<SwDrawFrameFormat*>(rSave.pFormat); + SwDrawFrameFormat* pDrawFrameFormat = rSave.pFormat; // #i45952# - notify that position attributes are already set OSL_ENSURE(pDrawFrameFormat, @@ -285,7 +285,7 @@ void SwUndoDrawGroup::RedoImpl(::sw::UndoRedoContext &) // #i45718# - follow-up of #i35635# move object to visible layer pContact->MoveObjToVisibleLayer( pObjArr[0].pObj ); - SwDrawFrameFormat* pDrawFrameFormat = dynamic_cast<SwDrawFrameFormat*>(pObjArr[0].pFormat); + SwDrawFrameFormat* pDrawFrameFormat = pObjArr[0].pFormat; // #i45952# - notify that position attributes are already set OSL_ENSURE(pDrawFrameFormat, @@ -382,7 +382,7 @@ void SwUndoDrawUnGroup::UndoImpl(::sw::UndoRedoContext & rContext) // #i45718# - follow-up of #i35635# move object to visible layer pContact->MoveObjToVisibleLayer( pObjArr[0].pObj ); - SwDrawFrameFormat* pDrawFrameFormat = dynamic_cast<SwDrawFrameFormat*>(pObjArr[0].pFormat); + SwDrawFrameFormat* pDrawFrameFormat = pObjArr[0].pFormat; // #i45952# - notify that position attributes are already set OSL_ENSURE(pDrawFrameFormat, @@ -417,7 +417,7 @@ void SwUndoDrawUnGroup::RedoImpl(::sw::UndoRedoContext &) ::lcl_RestoreAnchor( rSave.pFormat, rSave.nNodeIdx ); rFlyFormats.push_back( rSave.pFormat ); - SwDrawFrameFormat* pDrawFrameFormat = dynamic_cast<SwDrawFrameFormat*>(rSave.pFormat); + SwDrawFrameFormat* pDrawFrameFormat = rSave.pFormat; // #i45952# - notify that position attributes are already set OSL_ENSURE(pDrawFrameFormat, @@ -514,7 +514,7 @@ void SwUndoDrawDelete::UndoImpl(::sw::UndoRedoContext & rContext) // #i45718# - follow-up of #i35635# move object to visible layer pContact->MoveObjToVisibleLayer( pObj ); - SwDrawFrameFormat* pDrawFrameFormat = dynamic_cast<SwDrawFrameFormat*>(rSave.pFormat); + SwDrawFrameFormat* pDrawFrameFormat = rSave.pFormat; // #i45952# - notify that position attributes are already set OSL_ENSURE(pDrawFrameFormat, diff --git a/sw/source/core/unocore/unoflatpara.cxx b/sw/source/core/unocore/unoflatpara.cxx index 2d615bc0c1be..d25d6fffbdac 100644 --- a/sw/source/core/unocore/unoflatpara.cxx +++ b/sw/source/core/unocore/unoflatpara.cxx @@ -387,7 +387,7 @@ uno::Reference< text::XFlatParagraph > SwXFlatParagraphIterator::getNextPara() while( pCnt && pCurrentPage->IsAnLower( pCnt ) ) { - SwTextNode* pTextNode = dynamic_cast<SwTextNode*>( pCnt->GetNode()->GetTextNode() ); + SwTextNode* pTextNode = pCnt->GetNode()->GetTextNode(); if ( pTextNode && ((mnType == text::TextMarkupType::SPELLCHECK && diff --git a/sw/source/filter/ww8/ww8par3.cxx b/sw/source/filter/ww8/ww8par3.cxx index 0cb10ddecc7a..1c0c9eeccdf8 100644 --- a/sw/source/filter/ww8/ww8par3.cxx +++ b/sw/source/filter/ww8/ww8par3.cxx @@ -199,8 +199,8 @@ eF_ResT SwWW8ImplReader::Read_F_FormCheckBox( WW8FieldDesc* pF, OUString& rStr ) if (!aBookmarkName.isEmpty()) { IDocumentMarkAccess* pMarksAccess = m_rDoc.getIDocumentMarkAccess( ); - IFieldmark* pFieldmark = dynamic_cast<IFieldmark*>( pMarksAccess->makeNoTextFieldBookmark( - *m_pPaM, aBookmarkName, ODF_FORMCHECKBOX ) ); + IFieldmark* pFieldmark = pMarksAccess->makeNoTextFieldBookmark( + *m_pPaM, aBookmarkName, ODF_FORMCHECKBOX ); OSL_ENSURE(pFieldmark!=nullptr, "hmmm; why was the bookmark not created?"); if (pFieldmark!=nullptr) { IFieldmark::parameter_map_t* const pParameters = pFieldmark->GetParameters(); @@ -271,8 +271,8 @@ eF_ResT SwWW8ImplReader::Read_F_FormListBox( WW8FieldDesc* pF, OUString& rStr) if (!aBookmarkName.isEmpty()) { IDocumentMarkAccess* pMarksAccess = m_rDoc.getIDocumentMarkAccess( ); - IFieldmark *pFieldmark = dynamic_cast<IFieldmark*>( - pMarksAccess->makeNoTextFieldBookmark( *m_pPaM, aBookmarkName, ODF_FORMDROPDOWN ) ); + IFieldmark *pFieldmark = + pMarksAccess->makeNoTextFieldBookmark( *m_pPaM, aBookmarkName, ODF_FORMDROPDOWN ); OSL_ENSURE(pFieldmark!=nullptr, "hmmm; why was the bookmark not created?"); if ( pFieldmark != nullptr ) { diff --git a/sw/source/filter/ww8/ww8par5.cxx b/sw/source/filter/ww8/ww8par5.cxx index 14ea2963bab9..ef2530318fc0 100644 --- a/sw/source/filter/ww8/ww8par5.cxx +++ b/sw/source/filter/ww8/ww8par5.cxx @@ -530,8 +530,8 @@ sal_uInt16 SwWW8ImplReader::End_Field() SwPosition aEndPos = *m_pPaM->GetPoint(); SwPaM aFieldPam( m_aFieldStack.back().GetPtNode(), m_aFieldStack.back().GetPtContent(), aEndPos.nNode, aEndPos.nContent.GetIndex()); IDocumentMarkAccess* pMarksAccess = m_rDoc.getIDocumentMarkAccess( ); - IFieldmark *pFieldmark = dynamic_cast<IFieldmark*>( pMarksAccess->makeFieldBookmark( - aFieldPam, m_aFieldStack.back().GetBookmarkName(), ODF_FORMTEXT ) ); + IFieldmark *pFieldmark = pMarksAccess->makeFieldBookmark( + aFieldPam, m_aFieldStack.back().GetBookmarkName(), ODF_FORMTEXT ); OSL_ENSURE(pFieldmark!=nullptr, "hmmm; why was the bookmark not created?"); if (pFieldmark!=nullptr) { const IFieldmark::parameter_map_t& rParametersToAdd = m_aFieldStack.back().getParameters(); diff --git a/sw/source/uibase/app/swmodul1.cxx b/sw/source/uibase/app/swmodul1.cxx index 148323373780..192511fa587b 100644 --- a/sw/source/uibase/app/swmodul1.cxx +++ b/sw/source/uibase/app/swmodul1.cxx @@ -135,7 +135,7 @@ SwView* SwModule::GetFirstView() SwView* SwModule::GetNextView(SwView const * pView) { - OSL_ENSURE(dynamic_cast<SwView const *>( pView),"return no SwView" ); + OSL_ENSURE( pView,"return no SwView" ); SwView* pNView = static_cast<SwView*>(SfxViewShell::GetNext(*pView, true, checkSfxViewShell<SwView>)); return pNView; } diff --git a/sw/source/uibase/docvw/PostItMgr.cxx b/sw/source/uibase/docvw/PostItMgr.cxx index 7a6b2495ddf0..543c95273bf6 100644 --- a/sw/source/uibase/docvw/PostItMgr.cxx +++ b/sw/source/uibase/docvw/PostItMgr.cxx @@ -1680,7 +1680,7 @@ sw::annotation::SwAnnotationWin* SwPostItMgr::GetAnnotationWin(const SwPostItFie for(const_iterator i = mvPostItFields.begin(); i != mvPostItFields.end() ; ++i) { if ( (*i)->GetFormatField().GetField() == pField ) - return dynamic_cast<sw::annotation::SwAnnotationWin*>((*i)->pPostIt.get()); + return (*i)->pPostIt.get(); } return nullptr; } @@ -1690,7 +1690,7 @@ sw::annotation::SwAnnotationWin* SwPostItMgr::GetAnnotationWin(const sal_uInt32 for(const_iterator i = mvPostItFields.begin(); i != mvPostItFields.end() ; ++i) { if ( static_cast<const SwPostItField*>((*i)->GetFormatField().GetField())->GetPostItId() == nPostItId ) - return dynamic_cast<sw::annotation::SwAnnotationWin*>((*i)->pPostIt.get()); + return (*i)->pPostIt.get(); } return nullptr; } @@ -2269,7 +2269,7 @@ bool SwPostItMgr::HasActiveSidebarWin() const bool SwPostItMgr::HasActiveAnnotationWin() const { return HasActiveSidebarWin() && - dynamic_cast<sw::annotation::SwAnnotationWin*>(mpActivePostIt.get()) != nullptr; + mpActivePostIt != nullptr; } void SwPostItMgr::GrabFocusOnActiveSidebarWin() diff --git a/writerfilter/source/dmapper/NumberingManager.cxx b/writerfilter/source/dmapper/NumberingManager.cxx index c6165aad8784..43358e41ed01 100644 --- a/writerfilter/source/dmapper/NumberingManager.cxx +++ b/writerfilter/source/dmapper/NumberingManager.cxx @@ -1058,8 +1058,7 @@ void ListsManager::lcl_sprm( Sprm& rSprm ) case NS_ooxml::LN_CT_AbstractNum_numStyleLink: { OUString sStyleName = rSprm.getValue( )->getString( ); - AbstractListDef* pAbstractListDef = dynamic_cast< AbstractListDef* >( m_pCurrentDefinition.get( ) ); - pAbstractListDef->SetNumStyleLink(sStyleName); + m_pCurrentDefinition->SetNumStyleLink(sStyleName); } break; case NS_ooxml::LN_EG_RPrBase_rFonts: //contains font properties |