diff options
author | Noel <noel.grandin@collabora.co.uk> | 2021-03-07 18:41:56 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-03-08 07:40:01 +0100 |
commit | c7b898df4d452746399621f6adc8e7da088f0f3a (patch) | |
tree | eb4cb09ceef899c3015724b6d3f81f1e8a4a6ce1 /svx | |
parent | 04e7a34a19b3658de57c4f2b3b0fa8445b01f199 (diff) |
clean up some more dynamic/static casting
using a hacked version of the staticdynamic plugin
and some judgement
Change-Id: I5e6668b19320025e419f84bebceade4239577729
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112137
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/engine3d/view3d.cxx | 19 | ||||
-rw-r--r-- | svx/source/form/filtnav.cxx | 17 | ||||
-rw-r--r-- | svx/source/gallery2/galmisc.cxx | 40 | ||||
-rw-r--r-- | svx/source/toolbars/fontworkbar.cxx | 4 |
4 files changed, 41 insertions, 39 deletions
diff --git a/svx/source/engine3d/view3d.cxx b/svx/source/engine3d/view3d.cxx index 4ab95d4b5ca2..decbf61b7b0c 100644 --- a/svx/source/engine3d/view3d.cxx +++ b/svx/source/engine3d/view3d.cxx @@ -324,17 +324,18 @@ std::unique_ptr<SdrModel> E3dView::CreateMarkedObjModel() const { const SdrObject* pObj = GetMarkedObjectByIndex(nObjs); - if(!bSpecialHandling && dynamic_cast< const E3dCompoundObject*>(pObj)) - { - // if the object is selected, but it's scene not, - // we need special handling - pScene = static_cast<const E3dCompoundObject*>(pObj)->getRootE3dSceneFromE3dObject(); - - if(nullptr != pScene && !IsObjMarked(pScene)) + if(!bSpecialHandling) + if(auto pCompoundObj = dynamic_cast< const E3dCompoundObject*>(pObj)) { - bSpecialHandling = true; + // if the object is selected, but it's scene not, + // we need special handling + pScene = pCompoundObj->getRootE3dSceneFromE3dObject(); + + if(nullptr != pScene && !IsObjMarked(pScene)) + { + bSpecialHandling = true; + } } - } if(auto p3dObject = dynamic_cast< const E3dObject*>(pObj)) { diff --git a/svx/source/form/filtnav.cxx b/svx/source/form/filtnav.cxx index cee9f5d3c71b..2e5ba4b0db38 100644 --- a/svx/source/form/filtnav.cxx +++ b/svx/source/form/filtnav.cxx @@ -696,7 +696,7 @@ void FmFilterModel::Remove(FmFilterData* pData) DBG_ASSERT(i != rItems.end(), "FmFilterModel::Remove(): unknown Item"); // position within the parent sal_Int32 nPos = i - rItems.begin(); - if (dynamic_cast<const FmFilterItems*>( pData) != nullptr) + if (auto pFilterItems = dynamic_cast<FmFilterItems*>( pData)) { FmFormItem* pFormItem = static_cast<FmFormItem*>(pParent); @@ -708,7 +708,7 @@ void FmFilterModel::Remove(FmFilterData* pData) if ( bEmptyLastTerm ) { // remove all children (by setting an empty predicate expression) - ::std::vector< std::unique_ptr<FmFilterData> >& rChildren = static_cast<FmFilterItems*>(pData)->GetChildren(); + ::std::vector< std::unique_ptr<FmFilterData> >& rChildren = pFilterItems->GetChildren(); while ( !rChildren.empty() ) { auto removePos = rChildren.end() - 1; @@ -1506,7 +1506,8 @@ IMPL_LINK(FmFilterNavigator, PopupMenuHdl, const CommandEvent&, rEvt, bool) } FmFilterData* pFilterEntry = reinterpret_cast<FmFilterData*>(m_xTreeView->get_id(*xClicked).toInt64()); - bool bEdit = dynamic_cast<FmFilterItem*>(pFilterEntry) != nullptr && + auto pFilterItem = dynamic_cast<FmFilterItem*>(pFilterEntry); + bool bEdit = pFilterItem && m_xTreeView->is_selected(*xClicked) && m_xTreeView->count_selected_rows() == 1; if (bNoDelete && !bEdit) @@ -1531,18 +1532,16 @@ IMPL_LINK(FmFilterNavigator, PopupMenuHdl, const CommandEvent&, rEvt, bool) { OUString aErrorMsg; OUString aText = "IS NULL"; - m_pModel->ValidateText(static_cast<FmFilterItem*>(pFilterEntry), - aText, aErrorMsg); - m_pModel->SetTextForItem(static_cast<FmFilterItem*>(pFilterEntry), aText); + m_pModel->ValidateText(pFilterItem, aText, aErrorMsg); + m_pModel->SetTextForItem(pFilterItem, aText); } else if (sIdent == "isnotnull") { OUString aErrorMsg; OUString aText = "IS NOT NULL"; - m_pModel->ValidateText(static_cast<FmFilterItem*>(pFilterEntry), - aText, aErrorMsg); - m_pModel->SetTextForItem(static_cast<FmFilterItem*>(pFilterEntry), aText); + m_pModel->ValidateText(pFilterItem, aText, aErrorMsg); + m_pModel->SetTextForItem(pFilterItem, aText); } else if (sIdent == "delete") { diff --git a/svx/source/gallery2/galmisc.cxx b/svx/source/gallery2/galmisc.cxx index a3613424f041..eb90fd0895d4 100644 --- a/svx/source/gallery2/galmisc.cxx +++ b/svx/source/gallery2/galmisc.cxx @@ -118,30 +118,32 @@ bool GallerySvDrawImport( SvStream& rIStm, SdrModel& rModel ) bool CreateIMapGraphic( const FmFormModel& rModel, Graphic& rGraphic, ImageMap& rImageMap ) { + if (! rModel.GetPageCount() ) + return false; + + const SdrPage* pPage = rModel.GetPage( 0 ); + const SdrObject* pObj = pPage->GetObj( 0 ); + + if ( pPage->GetObjCount() != 1 ) + return false; + auto pGrafObj = dynamic_cast<const SdrGrafObj*>( pObj); + if (!pGrafObj) + return false; + bool bRet = false; + const sal_uInt16 nCount = pObj->GetUserDataCount(); - if ( rModel.GetPageCount() ) + // Exist in the user data an IMap information? + for ( sal_uInt16 i = 0; i < nCount; i++ ) { - const SdrPage* pPage = rModel.GetPage( 0 ); - const SdrObject* pObj = pPage->GetObj( 0 ); + const SdrObjUserData* pUserData = pObj->GetUserData( i ); - if ( pPage->GetObjCount() == 1 && dynamic_cast<const SdrGrafObj*>( pObj) != nullptr ) + if ( ( pUserData->GetInventor() == SdrInventor::SgaImap ) && ( pUserData->GetId() == ID_IMAPINFO ) ) { - const sal_uInt16 nCount = pObj->GetUserDataCount(); - - // Exist in the user data an IMap information? - for ( sal_uInt16 i = 0; i < nCount; i++ ) - { - const SdrObjUserData* pUserData = pObj->GetUserData( i ); - - if ( ( pUserData->GetInventor() == SdrInventor::SgaImap ) && ( pUserData->GetId() == ID_IMAPINFO ) ) - { - rGraphic = static_cast<const SdrGrafObj*>( pObj )->GetGraphic(); - rImageMap = static_cast<const SgaIMapInfo*>( pUserData )->GetImageMap(); - bRet = true; - break; - } - } + rGraphic = pGrafObj->GetGraphic(); + rImageMap = static_cast<const SgaIMapInfo*>( pUserData )->GetImageMap(); + bRet = true; + break; } } diff --git a/svx/source/toolbars/fontworkbar.cxx b/svx/source/toolbars/fontworkbar.cxx index 36cd9652b2aa..3399b20d79ea 100644 --- a/svx/source/toolbars/fontworkbar.cxx +++ b/svx/source/toolbars/fontworkbar.cxx @@ -436,7 +436,7 @@ void FontworkBar::execute( SdrView& rSdrView, SfxRequest const & rReq, SfxBindin for( size_t i = 0; i < nCount; ++i ) { SdrObject* pObj = rMarkList.GetMark( i )->GetMarkedSdrObj(); - if( dynamic_cast<const SdrObjCustomShape*>( pObj) != nullptr ) + if( auto pCustomShape = dynamic_cast<SdrObjCustomShape*>( pObj) ) { const bool bUndo = rSdrView.IsUndoEnabled(); @@ -450,7 +450,7 @@ void FontworkBar::execute( SdrView& rSdrView, SfxRequest const & rReq, SfxBindin GetGeometryForCustomShape( aGeometryItem, aCustomShape ); pObj->SetMergedItem( aGeometryItem ); - Reference< drawing::XShape > aXShape = GetXShapeForSdrObject( static_cast<SdrObjCustomShape*>(pObj) ); + Reference< drawing::XShape > aXShape = GetXShapeForSdrObject( pCustomShape ); if ( aXShape.is() ) { Reference< drawing::XEnhancedCustomShapeDefaulter > xDefaulter( aXShape, UNO_QUERY ); |