tdf#54857 elide more dynamic_cast
add a helper, following the same style as the ones in sw/ Change-Id: I13c673bba5ff47df6beef9d90c200e5801030cf0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142119 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
committed by
Noel Grandin
parent
d2a6bcd6a9
commit
4e24efb563
@@ -449,8 +449,7 @@ void BarChart::createShapes()
|
||||
|
||||
for (rtl::Reference<SvxShape> const & rShape : aShapeSet)
|
||||
{
|
||||
E3dScene* pScene = dynamic_cast<E3dScene*>(rShape->GetSdrObject());
|
||||
if(nullptr != pScene)
|
||||
if(E3dScene* pScene = DynCastE3dScene(rShape->GetSdrObject()))
|
||||
{
|
||||
aSceneSet.insert(pScene->getRootE3dSceneFromE3dObject());
|
||||
}
|
||||
@@ -690,10 +689,10 @@ void BarChart::doXSlot(
|
||||
aShapeSet.insert(xSeriesGroupShape_Shapes);
|
||||
aShapeSet.insert(xSeriesBackgroundShape_Shapes);
|
||||
// Suspend setting rects dirty for the duration of this call
|
||||
E3dScene* pScene = dynamic_cast<E3dScene*>(xSeriesGroupShape_Shapes->GetSdrObject());
|
||||
E3dScene* pScene = DynCastE3dScene(xSeriesGroupShape_Shapes->GetSdrObject());
|
||||
if (pScene)
|
||||
pScene->SuspendReportingDirtyRects();
|
||||
pScene = dynamic_cast<E3dScene*>(xSeriesBackgroundShape_Shapes->GetSdrObject());
|
||||
pScene = DynCastE3dScene(xSeriesBackgroundShape_Shapes->GetSdrObject());
|
||||
if (pScene)
|
||||
pScene->SuspendReportingDirtyRects();
|
||||
|
||||
|
||||
@@ -183,7 +183,7 @@ void VDiagram::createShapes_2d()
|
||||
|
||||
static E3dScene* lcl_getE3dScene( const rtl::Reference<SvxShapeGroupAnyD>& xShape )
|
||||
{
|
||||
return dynamic_cast< E3dScene* >(xShape->GetSdrObject());
|
||||
return DynCastE3dScene(xShape->GetSdrObject());
|
||||
}
|
||||
|
||||
static void lcl_setLightSources(
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
|
||||
class SfxBroadcaster;
|
||||
class AutoTimer;
|
||||
class E3dScene;
|
||||
class OutlinerParaObject;
|
||||
class Outliner;
|
||||
class SdrOutliner;
|
||||
@@ -996,6 +997,10 @@ private:
|
||||
SdrObject( const SdrObject& ) = delete;
|
||||
};
|
||||
|
||||
SVXCORE_DLLPUBLIC E3dScene* DynCastE3dScene(SdrObject*);
|
||||
inline const E3dScene* DynCastE3dScene(const SdrObject* p) { return DynCastE3dScene(const_cast<SdrObject*>(p)); }
|
||||
|
||||
|
||||
struct SdrObjCreatorParams
|
||||
{
|
||||
SdrInventor nInventor;
|
||||
|
||||
@@ -556,7 +556,7 @@ void FuDraw::ForcePointer(const MouseEvent* pMEvt)
|
||||
|
||||
if (bDefPointer
|
||||
&& (dynamic_cast<const SdrObjGroup*>(pObj) != nullptr
|
||||
|| dynamic_cast<const E3dScene*>(pObj) != nullptr))
|
||||
|| DynCastE3dScene(pObj)))
|
||||
{
|
||||
// take a glance into the group
|
||||
pObj = mpView->PickObj(aPnt, mpView->getHitTolLog(), pPV,
|
||||
@@ -698,7 +698,7 @@ bool FuDraw::RequestHelp(const HelpEvent& rHEvt)
|
||||
|
||||
bReturn = SetHelpText(pObj, aPosPixel, aVEvt);
|
||||
|
||||
if (!bReturn && (dynamic_cast< const SdrObjGroup *>( pObj ) != nullptr || dynamic_cast< const E3dScene* >(pObj) != nullptr))
|
||||
if (!bReturn && (dynamic_cast< const SdrObjGroup *>( pObj ) != nullptr || DynCastE3dScene(pObj)))
|
||||
{
|
||||
// take a glance into the group
|
||||
SdrPageView* pPV = nullptr;
|
||||
|
||||
@@ -327,7 +327,7 @@ bool FuSelection::MouseButtonDown(const MouseEvent& rMEvt)
|
||||
|
||||
if (!bReturn
|
||||
&& (dynamic_cast<const SdrObjGroup*>(pObj) != nullptr
|
||||
|| dynamic_cast<const E3dScene*>(pObj) != nullptr))
|
||||
|| DynCastE3dScene(pObj)))
|
||||
{
|
||||
if (rMEvt.GetClicks() == 1)
|
||||
{
|
||||
|
||||
@@ -136,7 +136,7 @@ void DrawViewShell::GetMenuStateSel( SfxItemSet &rSet )
|
||||
const auto* pSdrObjGroup = dynamic_cast<const SdrObjGroup*>(pObj);
|
||||
|
||||
if( !( ( pSdrObjGroup != nullptr && nInv == SdrInventor::Default ) ||
|
||||
( dynamic_cast< const E3dScene* >(pObj) != nullptr ) ) )
|
||||
DynCastE3dScene(pObj) ) )
|
||||
{
|
||||
rSet.DisableItem( SID_ENTER_GROUP );
|
||||
}
|
||||
@@ -382,7 +382,7 @@ void DrawViewShell::GetMenuStateSel( SfxItemSet &rSet )
|
||||
}
|
||||
else if (nInv == SdrInventor::E3d)
|
||||
{
|
||||
if(dynamic_cast< const E3dScene *>( pObj ) != nullptr)
|
||||
if(DynCastE3dScene(pObj))
|
||||
b3dObj = true;
|
||||
else if(dynamic_cast< const E3dCompoundObject* >(pObj) != nullptr)
|
||||
bE3dCompoundObject = true;
|
||||
|
||||
@@ -264,10 +264,7 @@ void E3dObject::StructureChanged()
|
||||
|
||||
E3dScene* E3dObject::getParentE3dSceneFromE3dObject() const
|
||||
{
|
||||
SdrObject* pParent = getParentSdrObjectFromSdrObject();
|
||||
if( pParent && pParent->GetObjIdentifier() == SdrObjKind::E3D_Scene )
|
||||
return static_cast<E3dScene* >(pParent);
|
||||
return nullptr;
|
||||
return DynCastE3dScene(getParentSdrObjectFromSdrObject());
|
||||
}
|
||||
|
||||
// Determine the top-level scene object
|
||||
|
||||
@@ -408,7 +408,7 @@ void E3dScene::removeAllNonSelectedObjects()
|
||||
{
|
||||
bool bRemoveObject(false);
|
||||
|
||||
if(auto pScene = dynamic_cast<E3dScene*>(pObj))
|
||||
if(E3dScene* pScene = DynCastE3dScene(pObj))
|
||||
{
|
||||
// iterate over this sub-scene
|
||||
pScene->removeAllNonSelectedObjects();
|
||||
|
||||
@@ -403,7 +403,7 @@ std::unique_ptr<SdrModel> E3dView::CreateMarkedObjModel() const
|
||||
{
|
||||
const SdrObject* pSrcOb=pSrcPg->GetObj(nOb);
|
||||
|
||||
if(auto p3dscene = dynamic_cast< const E3dScene* >( pSrcOb))
|
||||
if(const E3dScene* p3dscene = DynCastE3dScene( pSrcOb))
|
||||
{
|
||||
pScene = const_cast<E3dScene*>(p3dscene);
|
||||
|
||||
@@ -441,7 +441,7 @@ bool E3dView::Paste(
|
||||
return false;
|
||||
|
||||
// Get owner of the list
|
||||
E3dScene* pDstScene(dynamic_cast< E3dScene* >(pDstList->getSdrObjectFromSdrObjList()));
|
||||
E3dScene* pDstScene(DynCastE3dScene(pDstList->getSdrObjectFromSdrObjList()));
|
||||
|
||||
if(nullptr != pDstScene)
|
||||
{
|
||||
@@ -461,7 +461,7 @@ bool E3dView::Paste(
|
||||
for(size_t nOb = 0; nOb < nObjCount; ++nOb)
|
||||
{
|
||||
const SdrObject* pSrcOb = pSrcPg->GetObj(nOb);
|
||||
if(auto p3dscene = dynamic_cast< const E3dScene* >(pSrcOb))
|
||||
if(const E3dScene* p3dscene = DynCastE3dScene(pSrcOb))
|
||||
{
|
||||
E3dScene* pSrcScene = const_cast<E3dScene*>(p3dscene);
|
||||
ImpCloneAll3DObjectsToDestScene(pSrcScene, pDstScene, aDist);
|
||||
@@ -1172,7 +1172,7 @@ bool E3dView::BegDragObj(const Point& rPnt, OutputDevice* pOut,
|
||||
SdrObject *pObj = GetMarkedObjectByIndex(nObjs);
|
||||
if(pObj)
|
||||
{
|
||||
if( auto pScene = dynamic_cast< const E3dScene* >(pObj) )
|
||||
if( const E3dScene* pScene = DynCastE3dScene(pObj) )
|
||||
if( pScene->getRootE3dSceneFromE3dObject() == pObj )
|
||||
bThereAreRootScenes = true;
|
||||
|
||||
@@ -1520,7 +1520,7 @@ void E3dView::Break3DObj()
|
||||
|
||||
void E3dView::BreakSingle3DObj(E3dObject* pObj)
|
||||
{
|
||||
if(dynamic_cast< const E3dScene* >(pObj) != nullptr)
|
||||
if(DynCastE3dScene(pObj))
|
||||
{
|
||||
SdrObjList* pSubList = pObj->GetSubList();
|
||||
SdrObjListIter aIter(pSubList, SdrIterMode::Flat);
|
||||
|
||||
@@ -42,7 +42,7 @@ void E3dView::ConvertMarkedToPolyObj()
|
||||
|
||||
if (pObj)
|
||||
{
|
||||
auto pScene = dynamic_cast< const E3dScene* >(pObj);
|
||||
const E3dScene* pScene = DynCastE3dScene(pObj);
|
||||
if (pScene)
|
||||
{
|
||||
pNewObj = pScene->ConvertToPolyObj(false/*bBezier*/, false/*bLineToArea*/);
|
||||
|
||||
@@ -34,10 +34,10 @@ void CloneList::AddPair(const SdrObject* pOriginal, SdrObject* pClone)
|
||||
bool bOriginalIsGroup(pOriginal->IsGroupObject());
|
||||
bool bCloneIsGroup(pClone->IsGroupObject());
|
||||
|
||||
if(bOriginalIsGroup && dynamic_cast<const E3dObject* >(pOriginal) != nullptr && dynamic_cast<const E3dScene* >(pOriginal) == nullptr )
|
||||
if(bOriginalIsGroup && dynamic_cast<const E3dObject* >(pOriginal) != nullptr && DynCastE3dScene(pOriginal) == nullptr )
|
||||
bOriginalIsGroup = false;
|
||||
|
||||
if(bCloneIsGroup && dynamic_cast<const E3dObject* >(pClone) != nullptr && dynamic_cast<const E3dScene* >(pClone) == nullptr)
|
||||
if(bCloneIsGroup && dynamic_cast<const E3dObject* >(pClone) != nullptr && DynCastE3dScene(pClone) == nullptr)
|
||||
bCloneIsGroup = false;
|
||||
|
||||
if(!(bOriginalIsGroup && bCloneIsGroup))
|
||||
|
||||
@@ -618,8 +618,8 @@ bool SdrCreateView::EndCreateObj(SdrCreateCmd eCmd)
|
||||
// recognize creation of a new 3D object inside a 3D scene
|
||||
bool bSceneIntoScene(false);
|
||||
|
||||
E3dScene* pObjScene = dynamic_cast<E3dScene*>(pObjCreated);
|
||||
E3dScene* pCurrentScene = pObjScene ? dynamic_cast<E3dScene*>(mpCreatePV->GetCurrentGroup()) : nullptr;
|
||||
E3dScene* pObjScene = DynCastE3dScene(pObjCreated);
|
||||
E3dScene* pCurrentScene = pObjScene ? DynCastE3dScene(mpCreatePV->GetCurrentGroup()) : nullptr;
|
||||
if (pCurrentScene)
|
||||
{
|
||||
bool bDidInsert = static_cast<E3dView*>(this)->ImpCloneAll3DObjectsToDestScene(
|
||||
|
||||
@@ -150,7 +150,7 @@ bool SdrEditView::ImpDelLayerCheck(SdrObjList const * pOL, SdrLayerID nDelID) co
|
||||
SdrObjList* pSubOL = pObj->GetSubList();
|
||||
|
||||
// explicitly test for group objects and 3d scenes
|
||||
if(pSubOL && (dynamic_cast<const SdrObjGroup*>(pObj) != nullptr || dynamic_cast< const E3dScene* >(pObj) != nullptr))
|
||||
if(pSubOL && (dynamic_cast<const SdrObjGroup*>(pObj) != nullptr || DynCastE3dScene(pObj)))
|
||||
{
|
||||
if(!ImpDelLayerCheck(pSubOL, nDelID))
|
||||
{
|
||||
@@ -185,7 +185,7 @@ void SdrEditView::ImpDelLayerDelObjs(SdrObjList* pOL, SdrLayerID nDelID)
|
||||
|
||||
|
||||
// explicitly test for group objects and 3d scenes
|
||||
if(pSubOL && (dynamic_cast<const SdrObjGroup*>( pObj) != nullptr || dynamic_cast<const E3dScene* >(pObj) != nullptr))
|
||||
if(pSubOL && (dynamic_cast<const SdrObjGroup*>( pObj) != nullptr || DynCastE3dScene(pObj)))
|
||||
{
|
||||
if(ImpDelLayerCheck(pSubOL, nDelID))
|
||||
{
|
||||
@@ -249,7 +249,7 @@ void SdrEditView::DeleteLayer(const OUString& rName)
|
||||
SdrObjList* pSubOL = pObj->GetSubList();
|
||||
|
||||
// explicitly test for group objects and 3d scenes
|
||||
if(pSubOL && (dynamic_cast<const SdrObjGroup*>(pObj) != nullptr || dynamic_cast<const E3dScene* >(pObj) != nullptr))
|
||||
if(pSubOL && (dynamic_cast<const SdrObjGroup*>(pObj) != nullptr || DynCastE3dScene(pObj)))
|
||||
{
|
||||
if(ImpDelLayerCheck(pSubOL, nDelID))
|
||||
{
|
||||
|
||||
@@ -700,7 +700,7 @@ namespace sdr
|
||||
|
||||
bool bIsGroup(pObj->IsGroupObject());
|
||||
|
||||
if(bIsGroup && dynamic_cast< const E3dObject* >(pObj) != nullptr && dynamic_cast< const E3dScene* >(pObj) == nullptr)
|
||||
if(bIsGroup && dynamic_cast< const E3dObject* >(pObj) != nullptr && DynCastE3dScene(pObj) == nullptr)
|
||||
{
|
||||
bIsGroup = false;
|
||||
}
|
||||
|
||||
@@ -2052,7 +2052,7 @@ bool SdrMarkView::MarkNextObj(const Point& rPnt, short nTol, bool bPrev)
|
||||
nullptr != dynamic_cast< const E3dCompoundObject* >(pObjHit);
|
||||
if (bRemap)
|
||||
{
|
||||
pScene = dynamic_cast< E3dScene* >(pObjHit->getParentSdrObjectFromSdrObject());
|
||||
pScene = DynCastE3dScene(pObjHit->getParentSdrObjectFromSdrObject());
|
||||
bRemap = nullptr != pScene;
|
||||
}
|
||||
|
||||
@@ -2381,41 +2381,37 @@ SdrObject* SdrMarkView::CheckSingleSdrObjectHit(const Point& rPnt, sal_uInt16 nT
|
||||
{
|
||||
SdrObject* pRet=nullptr;
|
||||
rpRootObj=nullptr;
|
||||
if (pOL!=nullptr)
|
||||
if (!pOL)
|
||||
return nullptr;
|
||||
const E3dScene* pRemapScene = DynCastE3dScene(pOL->getSdrObjectFromSdrObjList());
|
||||
const size_t nObjCount(pOL->GetObjCount());
|
||||
size_t nObjNum(nObjCount);
|
||||
|
||||
while (pRet==nullptr && nObjNum>0)
|
||||
{
|
||||
const bool bRemap(
|
||||
nullptr != pOL->getSdrObjectFromSdrObjList()
|
||||
&& nullptr != dynamic_cast< const E3dScene* >(pOL->getSdrObjectFromSdrObjList()));
|
||||
const E3dScene* pRemapScene(bRemap ? static_cast< E3dScene* >(pOL->getSdrObjectFromSdrObjList()) : nullptr);
|
||||
const size_t nObjCount(pOL->GetObjCount());
|
||||
size_t nObjNum(nObjCount);
|
||||
nObjNum--;
|
||||
SdrObject* pObj;
|
||||
|
||||
while (pRet==nullptr && nObjNum>0)
|
||||
if(pRemapScene)
|
||||
{
|
||||
nObjNum--;
|
||||
SdrObject* pObj;
|
||||
|
||||
if(bRemap)
|
||||
pObj = pOL->GetObj(pRemapScene->RemapOrdNum(nObjNum));
|
||||
}
|
||||
else
|
||||
{
|
||||
pObj = pOL->GetObj(nObjNum);
|
||||
}
|
||||
if (nOptions & SdrSearchOptions::BEFOREMARK)
|
||||
{
|
||||
if (pMarkList!=nullptr)
|
||||
{
|
||||
pObj = pOL->GetObj(pRemapScene->RemapOrdNum(nObjNum));
|
||||
}
|
||||
else
|
||||
{
|
||||
pObj = pOL->GetObj(nObjNum);
|
||||
}
|
||||
if (nOptions & SdrSearchOptions::BEFOREMARK)
|
||||
{
|
||||
if (pMarkList!=nullptr)
|
||||
if ((*pMarkList).FindObject(pObj)!=SAL_MAX_SIZE)
|
||||
{
|
||||
if ((*pMarkList).FindObject(pObj)!=SAL_MAX_SIZE)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
pRet=CheckSingleSdrObjectHit(rPnt,nTol,pObj,pPV,nOptions,pMVisLay);
|
||||
if (pRet!=nullptr) rpRootObj=pObj;
|
||||
}
|
||||
pRet=CheckSingleSdrObjectHit(rPnt,nTol,pObj,pPV,nOptions,pMVisLay);
|
||||
if (pRet!=nullptr) rpRootObj=pObj;
|
||||
}
|
||||
return pRet;
|
||||
}
|
||||
|
||||
@@ -3094,7 +3094,7 @@ void SdrObject::MakeNameUnique()
|
||||
{
|
||||
if (GetName().isEmpty())
|
||||
{
|
||||
if (const E3dScene* pE3dObj = dynamic_cast<const E3dScene*>(this))
|
||||
if (const E3dScene* pE3dObj = DynCastE3dScene(this))
|
||||
{
|
||||
SdrObjList* pObjList = pE3dObj->GetSubList();
|
||||
if (pObjList)
|
||||
@@ -3195,6 +3195,13 @@ void SdrObject::moveOutRectangle(sal_Int32 nXDelta, sal_Int32 nYDelta)
|
||||
m_aOutRect.Move(nXDelta, nYDelta);
|
||||
}
|
||||
|
||||
E3dScene* DynCastE3dScene(SdrObject* pObj)
|
||||
{
|
||||
if( pObj && pObj->GetObjInventor() == SdrInventor::E3d && pObj->GetObjIdentifier() == SdrObjKind::E3D_Scene )
|
||||
return static_cast<E3dScene*>(pObj);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
rtl::Reference<SdrObject> SdrObjFactory::CreateObjectFromFactory(SdrModel& rSdrModel, SdrInventor nInventor, SdrObjKind nObjIdentifier)
|
||||
{
|
||||
SdrObjCreatorParams aParams { nInventor, nObjIdentifier, rSdrModel };
|
||||
|
||||
@@ -257,7 +257,7 @@ SdrUndoAttrObj::SdrUndoAttrObj(SdrObject& rNewObj, bool bStyleSheet1, bool bSave
|
||||
|
||||
SdrObjList* pOL = rNewObj.GetSubList();
|
||||
bool bIsGroup(pOL!=nullptr && pOL->GetObjCount());
|
||||
bool bIs3DScene(bIsGroup && dynamic_cast< E3dScene* >(mxObj.get()) != nullptr);
|
||||
bool bIs3DScene(bIsGroup && DynCastE3dScene(mxObj.get()));
|
||||
|
||||
if(bIsGroup)
|
||||
{
|
||||
@@ -300,7 +300,7 @@ SdrUndoAttrObj::~SdrUndoAttrObj()
|
||||
void SdrUndoAttrObj::Undo()
|
||||
{
|
||||
E3DModifySceneSnapRectUpdater aUpdater(mxObj.get());
|
||||
bool bIs3DScene(dynamic_cast< E3dScene* >(mxObj.get()) != nullptr);
|
||||
bool bIs3DScene(DynCastE3dScene(mxObj.get()));
|
||||
|
||||
// Trigger PageChangeCall
|
||||
ImpShowPageOfThisObject();
|
||||
@@ -409,7 +409,7 @@ void SdrUndoAttrObj::Undo()
|
||||
void SdrUndoAttrObj::Redo()
|
||||
{
|
||||
E3DModifySceneSnapRectUpdater aUpdater(mxObj.get());
|
||||
bool bIs3DScene(dynamic_cast< E3dScene* >(mxObj.get()) != nullptr);
|
||||
bool bIs3DScene(DynCastE3dScene(mxObj.get()));
|
||||
|
||||
if(!pUndoGroup || bIs3DScene)
|
||||
{
|
||||
@@ -560,7 +560,7 @@ SdrUndoGeoObj::SdrUndoGeoObj(SdrObject& rNewObj)
|
||||
, mbSkipChangeLayout(false)
|
||||
{
|
||||
SdrObjList* pOL=rNewObj.GetSubList();
|
||||
if (pOL!=nullptr && pOL->GetObjCount() && dynamic_cast<const E3dScene* >( &rNewObj) == nullptr)
|
||||
if (pOL!=nullptr && pOL->GetObjCount() && DynCastE3dScene(&rNewObj))
|
||||
{
|
||||
// this is a group object!
|
||||
// If this were 3D scene, we'd only add an Undo for the scene itself
|
||||
|
||||
@@ -191,7 +191,7 @@ sal_Int32 SAL_CALL Svx3DSceneObject::getCount()
|
||||
|
||||
sal_Int32 nRetval = 0;
|
||||
|
||||
if(HasSdrObject() && dynamic_cast<const E3dScene* >(GetSdrObject()) != nullptr && GetSdrObject()->GetSubList())
|
||||
if(HasSdrObject() && DynCastE3dScene(GetSdrObject()) && GetSdrObject()->GetSubList())
|
||||
nRetval = GetSdrObject()->GetSubList()->GetObjCount();
|
||||
return nRetval;
|
||||
}
|
||||
|
||||
@@ -367,7 +367,7 @@ uno::Reference< drawing::XShape > SwFmDrawPage::CreateShape( SdrObject *pObj ) c
|
||||
xShapeTunnel = nullptr;
|
||||
uno::Reference< uno::XInterface > xCreate(xRet, uno::UNO_QUERY);
|
||||
xRet = nullptr;
|
||||
if ( pObj->IsGroupObject() && (!pObj->Is3DObj() || (dynamic_cast<const E3dScene*>( pObj) != nullptr)) )
|
||||
if ( pObj->IsGroupObject() && (!pObj->Is3DObj() || DynCastE3dScene(pObj)) )
|
||||
pShape = new SwXGroupShape(xCreate, nullptr);
|
||||
else
|
||||
pShape = new SwXShape(xCreate, nullptr);
|
||||
|
||||
Reference in New Issue
Block a user