diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2022-11-02 19:39:01 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-11-02 20:30:29 +0100 |
commit | 4d863fd8e38748607636d0033262baa62a3e9eb2 (patch) | |
tree | de15f5cd695199cfd56f1893bbb31cf06fc044d1 /sw | |
parent | 1a4151dcdf45a0fa946b6ddf5e1b5cca37d24619 (diff) |
tdf#54857 elide more dynamic_cast
Change-Id: I42bef355eeef15e3733a5ee57b0569887cfa5e84
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142183
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/layout/layout.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/doc/DocumentDrawModelManager.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/doc/textboxhelper.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/draw/dcontact.cxx | 5 | ||||
-rw-r--r-- | sw/source/core/frmedt/feshview.cxx | 2 | ||||
-rw-r--r-- | sw/source/filter/indexing/IndexingExport.cxx | 2 | ||||
-rw-r--r-- | sw/source/filter/ww8/rtfsdrexport.cxx | 2 | ||||
-rw-r--r-- | sw/source/filter/ww8/wrtw8sty.cxx | 6 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8graf.cxx | 4 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8par.cxx | 2 | ||||
-rw-r--r-- | sw/source/uibase/dialog/SwSpellDialogChildWindow.cxx | 2 | ||||
-rw-r--r-- | sw/source/uibase/ribbar/conrect.cxx | 2 | ||||
-rw-r--r-- | sw/source/uibase/shells/drawsh.cxx | 2 | ||||
-rw-r--r-- | sw/source/uibase/shells/drwtxtsh.cxx | 2 | ||||
-rw-r--r-- | sw/source/uibase/uiview/viewdraw.cxx | 4 |
15 files changed, 20 insertions, 21 deletions
diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx index feda2a494469..7d8f76698cb0 100644 --- a/sw/qa/extras/layout/layout.cxx +++ b/sw/qa/extras/layout/layout.cxx @@ -4932,7 +4932,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf137185) auto xTextFrame = SwXTextFrame::CreateXTextFrame(*pFormat->GetDoc(), pFormat); CPPUNIT_ASSERT_EQUAL(OUString("Align me!"), xTextFrame->getText()->getString()); - SdrTextObj* pTextObj = dynamic_cast<SdrTextObj*>(pObj); + SdrTextObj* pTextObj = DynCastSdrTextObj(pObj); CPPUNIT_ASSERT(pTextObj); const auto& aOutStr = pTextObj->GetOutlinerParaObject()->GetTextObject(); diff --git a/sw/source/core/doc/DocumentDrawModelManager.cxx b/sw/source/core/doc/DocumentDrawModelManager.cxx index 990bb8a4732b..7f3098ef6672 100644 --- a/sw/source/core/doc/DocumentDrawModelManager.cxx +++ b/sw/source/core/doc/DocumentDrawModelManager.cxx @@ -309,7 +309,7 @@ bool DocumentDrawModelManager::Search(const SwPaM& rPaM, const SvxSearchItem& rS // Does the shape have matching text? SdrOutliner& rOutliner = GetDrawModel()->GetDrawOutliner(); SdrObject* pObject = const_cast<SdrObject*>(rFrameFormat.FindSdrObject()); - SdrTextObj* pTextObj = dynamic_cast<SdrTextObj*>(pObject); + SdrTextObj* pTextObj = DynCastSdrTextObj(pObject); if (!pTextObj) continue; const OutlinerParaObject* pParaObj = pTextObj->GetOutlinerParaObject(); diff --git a/sw/source/core/doc/textboxhelper.cxx b/sw/source/core/doc/textboxhelper.cxx index 5658d1075862..6c1af8270b65 100644 --- a/sw/source/core/doc/textboxhelper.cxx +++ b/sw/source/core/doc/textboxhelper.cxx @@ -186,7 +186,7 @@ void SwTextBoxHelper::create(SwFrameFormat* pShape, SdrObject* pObject, bool bCo if (pObject) { - auto pSourceText = dynamic_cast<SdrTextObj*>(pObject); + auto pSourceText = DynCastSdrTextObj(pObject); uno::Reference<text::XTextRange> xDestText(xRealTextFrame, uno::UNO_QUERY); xDestText->setString(sCopyableText); diff --git a/sw/source/core/draw/dcontact.cxx b/sw/source/core/draw/dcontact.cxx index fe19106949b7..f1375a85eb45 100644 --- a/sw/source/core/draw/dcontact.cxx +++ b/sw/source/core/draw/dcontact.cxx @@ -1616,13 +1616,12 @@ void SwDrawContact::SwClientNotify(const SwModify& rMod, const SfxHint& rHint) //iterate inside of a grouped object while(aListIter.IsMore()) { - SdrObject* pSdrOElement = aListIter.Next(); - auto pTextObj = const_cast<SdrTextObj*>(dynamic_cast<const SdrTextObj*>(pSdrOElement)); + SdrTextObj* pTextObj = DynCastSdrTextObj(aListIter.Next()); if(pTextObj && pTextObj->HasText()) pCollectTextObjectsHint->m_rTextObjects.push_back(pTextObj); } } - else if(auto pTextObj = const_cast<SdrTextObj*>(dynamic_cast<const SdrTextObj*>(pSdrO))) + else if(SdrTextObj* pTextObj = DynCastSdrTextObj(pSdrO)) { if(pTextObj->HasText()) pCollectTextObjectsHint->m_rTextObjects.push_back(pTextObj); diff --git a/sw/source/core/frmedt/feshview.cxx b/sw/source/core/frmedt/feshview.cxx index 1b2b4ead071d..46e17971f5c7 100644 --- a/sw/source/core/frmedt/feshview.cxx +++ b/sw/source/core/frmedt/feshview.cxx @@ -3199,7 +3199,7 @@ void SwFEShell::CreateDefaultShape( SdrObjKind eSdrObjectKind, const tools::Rect pCaptionObj->SetTailPos( aRect.TopLeft() - Point(aRect.GetWidth() / 2, aRect.GetHeight() / 2)); } - else if(auto pText = dynamic_cast<SdrTextObj*>( pObj.get())) + else if(auto pText = DynCastSdrTextObj( pObj.get())) { pText->SetLogicRect(aRect); diff --git a/sw/source/filter/indexing/IndexingExport.cxx b/sw/source/filter/indexing/IndexingExport.cxx index 3839b5598875..13da0b722cf1 100644 --- a/sw/source/filter/indexing/IndexingExport.cxx +++ b/sw/source/filter/indexing/IndexingExport.cxx @@ -118,7 +118,7 @@ public: m_rXmlWriter.endElement(); - SdrTextObj* pTextObject = dynamic_cast<SdrTextObj*>(pObject); + SdrTextObj* pTextObject = DynCastSdrTextObj(pObject); if (!pTextObject) return; diff --git a/sw/source/filter/ww8/rtfsdrexport.cxx b/sw/source/filter/ww8/rtfsdrexport.cxx index 2820aa68eb89..05413a8d2eb6 100644 --- a/sw/source/filter/ww8/rtfsdrexport.cxx +++ b/sw/source/filter/ww8/rtfsdrexport.cxx @@ -587,7 +587,7 @@ sal_Int32 RtfSdrExport::StartShape() } } - auto pTextObj = dynamic_cast<const SdrTextObj*>(m_pSdrObject); + auto pTextObj = DynCastSdrTextObj(m_pSdrObject); if (pTextObj) { const OutlinerParaObject* pParaObj = nullptr; diff --git a/sw/source/filter/ww8/wrtw8sty.cxx b/sw/source/filter/ww8/wrtw8sty.cxx index 60a77ead72c8..842bf958def4 100644 --- a/sw/source/filter/ww8/wrtw8sty.cxx +++ b/sw/source/filter/ww8/wrtw8sty.cxx @@ -2273,8 +2273,8 @@ bool WW8_WrPlcSubDoc::WriteGenericText( WW8Export& rWrt, sal_uInt8 nTTyp, rWrt.GetOCXExp().ExportControl(rWrt, dynamic_cast<const SdrUnoObj&>(rObj)); rWrt.m_nTextTyp = nOldTyp; } - else if( dynamic_cast<const SdrTextObj*>( &rObj) != nullptr ) - rWrt.WriteSdrTextObj(dynamic_cast<const SdrTextObj&>(rObj), nTTyp); + else if( auto pText = DynCastSdrTextObj(&rObj) ) + rWrt.WriteSdrTextObj(*pText, nTTyp); else { const SwFrameFormat* pFormat = ::FindFrameFormat( &rObj ); @@ -2522,7 +2522,7 @@ void WW8_WrPlcSubDoc::WriteGenericPlc( WW8Export& rWrt, sal_uInt8 nTTyp, // is it a writer or sdr - textbox? const SdrObject* pObj = static_cast<SdrObject const *>(m_aContent[ i ]); sal_Int32 nCnt = 1; - if (dynamic_cast< const SdrTextObj *>( pObj )) + if (DynCastSdrTextObj( pObj )) { // find the "highest" SdrObject of this const SwFrameFormat& rFormat = *::FindFrameFormat( pObj ); diff --git a/sw/source/filter/ww8/ww8graf.cxx b/sw/source/filter/ww8/ww8graf.cxx index d803e5619614..7fcbde440d68 100644 --- a/sw/source/filter/ww8/ww8graf.cxx +++ b/sw/source/filter/ww8/ww8graf.cxx @@ -2880,7 +2880,7 @@ SwFrameFormat* SwWW8ImplReader::MungeTextIntoDrawBox(SvxMSDffImportRec& rRecord, pThisGroup->GetSubList()->NbcInsertObject(pSdrTextObj.get()); } else - pSdrTextObj = dynamic_cast<SdrTextObj*>(rRecord.pObj.get()); + pSdrTextObj = DynCastSdrTextObj(rRecord.pObj.get()); if( pSdrTextObj ) { @@ -2976,7 +2976,7 @@ SwFlyFrameFormat* SwWW8ImplReader::ConvertDrawTextToFly(rtl::Reference<SdrObject MatchSdrItemsIntoFlySet(rpObject.get(), rFlySet, rRecord.eLineStyle, rRecord.eLineDashing, rRecord.eShapeType, aInnerDist); - SdrTextObj *pSdrTextObj = dynamic_cast<SdrTextObj*>(rpObject.get()); + SdrTextObj *pSdrTextObj = DynCastSdrTextObj(rpObject.get()); if (pSdrTextObj && pSdrTextObj->IsVerticalWriting()) rFlySet.Put(SvxFrameDirectionItem(SvxFrameDirection::Vertical_RL_TB, RES_FRAMEDIR)); diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx index 700b2765e247..1d38928e0689 100644 --- a/sw/source/filter/ww8/ww8par.cxx +++ b/sw/source/filter/ww8/ww8par.cxx @@ -912,7 +912,7 @@ rtl::Reference<SdrObject> SwMSDffManager::ProcessObj(SvStream& rSt, if (bVerticalText) { - SdrTextObj *pTextObj = dynamic_cast< SdrTextObj* >(pObj.get()); + SdrTextObj *pTextObj = DynCastSdrTextObj(pObj.get()); if (pTextObj) pTextObj->SetVerticalWriting(true); } diff --git a/sw/source/uibase/dialog/SwSpellDialogChildWindow.cxx b/sw/source/uibase/dialog/SwSpellDialogChildWindow.cxx index 08b99101eee6..44e06191929a 100644 --- a/sw/source/uibase/dialog/SwSpellDialogChildWindow.cxx +++ b/sw/source/uibase/dialog/SwSpellDialogChildWindow.cxx @@ -723,7 +723,7 @@ bool SwSpellDialogChildWindow::FindNextDrawTextError_Impl(SwWrtShell& rSh) if ( rMarkList.GetMarkCount() == 1 ) { SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj(); - if( auto pSdrTextObj = dynamic_cast<SdrTextObj *>( pObj ) ) + if( auto pSdrTextObj = DynCastSdrTextObj( pObj ) ) pCurrentTextObj = pSdrTextObj; } // at first fill the list of drawing objects diff --git a/sw/source/uibase/ribbar/conrect.cxx b/sw/source/uibase/ribbar/conrect.cxx index 837d5c3074d1..577ca06a4394 100644 --- a/sw/source/uibase/ribbar/conrect.cxx +++ b/sw/source/uibase/ribbar/conrect.cxx @@ -109,7 +109,7 @@ bool ConstRectangle::MouseButtonUp(const MouseEvent& rMEvt) } else if(mbVertical) { - if (SdrTextObj* pText = dynamic_cast<SdrTextObj*>(pObj)) + if (SdrTextObj* pText = DynCastSdrTextObj(pObj)) { SfxItemSet aSet(pSdrView->GetModel()->GetItemPool()); diff --git a/sw/source/uibase/shells/drawsh.cxx b/sw/source/uibase/shells/drawsh.cxx index 0d235828e8e9..f539d5a2189e 100644 --- a/sw/source/uibase/shells/drawsh.cxx +++ b/sw/source/uibase/shells/drawsh.cxx @@ -599,7 +599,7 @@ void SwDrawShell::GetFormTextState(SfxItemSet& rSet) if ( rMarkList.GetMarkCount() == 1 ) pObj = rMarkList.GetMark(0)->GetMarkedSdrObj(); - const SdrTextObj* pTextObj = dynamic_cast< const SdrTextObj* >(pObj); + const SdrTextObj* pTextObj = DynCastSdrTextObj(pObj); const bool bDeactivate( !pObj || !pTextObj || diff --git a/sw/source/uibase/shells/drwtxtsh.cxx b/sw/source/uibase/shells/drwtxtsh.cxx index 776cd31c01da..8f86fb5fc9d1 100644 --- a/sw/source/uibase/shells/drwtxtsh.cxx +++ b/sw/source/uibase/shells/drwtxtsh.cxx @@ -234,7 +234,7 @@ void SwDrawTextShell::GetFormTextState(SfxItemSet& rSet) if ( rMarkList.GetMarkCount() == 1 ) pObj = rMarkList.GetMark(0)->GetMarkedSdrObj(); - const SdrTextObj* pTextObj = dynamic_cast< const SdrTextObj* >(pObj); + const SdrTextObj* pTextObj = DynCastSdrTextObj(pObj); const bool bDeactivate( !pObj || !pTextObj || diff --git a/sw/source/uibase/uiview/viewdraw.cxx b/sw/source/uibase/uiview/viewdraw.cxx index 4925a137f06b..dc140402412b 100644 --- a/sw/source/uibase/uiview/viewdraw.cxx +++ b/sw/source/uibase/uiview/viewdraw.cxx @@ -480,9 +480,9 @@ bool SwView::EnterDrawTextMode(const Point& aDocPos) { // To allow SwDrawVirtObj text objects to be activated, allow their type, too. auto pVirtObj = dynamic_cast<SwDrawVirtObj*>( pObj ); - if ( (pVirtObj && dynamic_cast< const SdrTextObj *>(&pVirtObj->GetReferencedObj() ) != nullptr && + if ( (pVirtObj && DynCastSdrTextObj(&pVirtObj->GetReferencedObj() ) != nullptr && m_pWrtShell->IsSelObjProtected(FlyProtectFlags::Content) == FlyProtectFlags::NONE) || - dynamic_cast< const SdrTextObj *>( pObj ) != nullptr ) + DynCastSdrTextObj( pObj ) != nullptr ) { // Refuse to edit editeng text of the shape if it has textbox attached. if (!lcl_isTextBox(pObj)) |