svx/source/form/fmundo.cxx | 19 +++++++------------ svx/source/form/navigatortreemodel.cxx | 21 ++++++++++----------- svx/source/unodraw/unoshtxt.cxx | 10 +++------- 3 files changed, 20 insertions(+), 30 deletions(-)
New commits: commit 1918546e92ce7a60ecc4fac55f17a0b9dd0a03a0 Author: Caolán McNamara <caol...@redhat.com> Date: Mon Jul 18 21:25:12 2016 +0100 dynamic_cast followed by static_cast and elide some casts when possible Change-Id: Ib7d303bc18aebaa562bb380a8f3ab7d9fddcbca9 diff --git a/svx/source/form/fmundo.cxx b/svx/source/form/fmundo.cxx index e49af1d..db6162f 100644 --- a/svx/source/form/fmundo.cxx +++ b/svx/source/form/fmundo.cxx @@ -184,7 +184,6 @@ FmXUndoEnvironment::FmXUndoEnvironment(FmFormModel& _rModel) } } - FmXUndoEnvironment::~FmXUndoEnvironment() { if ( !m_bDisposed ) // i120746, call FormScriptingEnvironment::dispose to avoid memory leak @@ -194,7 +193,6 @@ FmXUndoEnvironment::~FmXUndoEnvironment() delete static_cast<PropertySetInfoCache*>(m_pPropertySetCache); } - void FmXUndoEnvironment::dispose() { OSL_ENSURE( !m_bDisposed, "FmXUndoEnvironment::dispose: disposed twice?" ); @@ -288,10 +286,9 @@ void FmXUndoEnvironment::ModeChanged() void FmXUndoEnvironment::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint ) { - const SdrHint* pSdrHint = dynamic_cast<const SdrHint*>(&rHint); - if (pSdrHint) + if (const SdrHint* pSdrHint = dynamic_cast<const SdrHint*>(&rHint)) { - switch( pSdrHint->GetKind() ) + switch (pSdrHint->GetKind()) { case HINT_OBJINSERTED: { @@ -308,9 +305,9 @@ void FmXUndoEnvironment::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint ) break; } } - else if (dynamic_cast<const SfxSimpleHint*>(&rHint)) + else if (const SfxSimpleHint* pSimpleHint = dynamic_cast<const SfxSimpleHint*>(&rHint)) { - switch ( static_cast<const SfxSimpleHint*>(&rHint)->GetId() ) + switch (pSimpleHint->GetId()) { case SFX_HINT_DYING: dispose(); @@ -321,20 +318,18 @@ void FmXUndoEnvironment::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint ) break; } } - else if (dynamic_cast<const SfxEventHint*>(&rHint)) + else if (const SfxEventHint* pEventHint = dynamic_cast<const SfxEventHint*>(&rHint)) { - switch ( static_cast<const SfxEventHint*>(&rHint)->GetEventId() ) + switch (pEventHint->GetEventId()) { - case SFX_EVENT_CREATEDOC: + case SFX_EVENT_CREATEDOC: case SFX_EVENT_OPENDOC: ModeChanged(); break; } } - } - void FmXUndoEnvironment::Inserted(SdrObject* pObj) { if (pObj->GetObjInventor() == FmFormInventor) diff --git a/svx/source/form/navigatortreemodel.cxx b/svx/source/form/navigatortreemodel.cxx index fbfbeb6..88bb2ac 100644 --- a/svx/source/form/navigatortreemodel.cxx +++ b/svx/source/form/navigatortreemodel.cxx @@ -672,9 +672,9 @@ namespace svxform if (rText == aEntryText) return pEntryData; - if( bRecurs && dynamic_cast<const FmFormData*>( pEntryData) != nullptr ) + if (FmFormData* pFormData = bRecurs ? dynamic_cast<FmFormData*>(pEntryData) : nullptr) { - pChildData = FindData( rText, static_cast<FmFormData*>(pEntryData) ); + pChildData = FindData(rText, pFormData); if( pChildData ) return pChildData; } @@ -683,11 +683,10 @@ namespace svxform return nullptr; } - void NavigatorTreeModel::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint ) { const SdrHint* pSdrHint = dynamic_cast<const SdrHint*>(&rHint); - if( pSdrHint ) + if (pSdrHint) { switch( pSdrHint->GetKind() ) { @@ -702,18 +701,18 @@ namespace svxform } } // is shell gone? - else if ( dynamic_cast<const SfxSimpleHint*>(&rHint) && static_cast<const SfxSimpleHint*>(&rHint)->GetId() == SFX_HINT_DYING) - UpdateContent(nullptr); - + else if (const SfxSimpleHint* pSimpleHint = dynamic_cast<const SfxSimpleHint*>(&rHint)) + { + if (pSimpleHint->GetId() == SFX_HINT_DYING) + UpdateContent(nullptr); + } // changed mark of controls? - else if (dynamic_cast<const FmNavViewMarksChanged*>(&rHint)) + else if (const FmNavViewMarksChanged* pvmcHint = dynamic_cast<const FmNavViewMarksChanged*>(&rHint)) { - const FmNavViewMarksChanged* pvmcHint = static_cast<const FmNavViewMarksChanged*>(&rHint); - BroadcastMarkedObjects( pvmcHint->GetAffectedView()->GetMarkedObjectList() ); + BroadcastMarkedObjects(pvmcHint->GetAffectedView()->GetMarkedObjectList()); } } - void NavigatorTreeModel::InsertSdrObj( const SdrObject* pObj ) { const FmFormObj* pFormObject = FmFormObj::GetFormObject( pObj ); diff --git a/svx/source/unodraw/unoshtxt.cxx b/svx/source/unodraw/unoshtxt.cxx index 8d1d382..1569807 100644 --- a/svx/source/unodraw/unoshtxt.cxx +++ b/svx/source/unodraw/unoshtxt.cxx @@ -317,11 +317,7 @@ void SvxTextEditSourceImpl::Notify(SfxBroadcaster& rBC, const SfxHint& rHint) // #i105988 keep reference to this object rtl::Reference< SvxTextEditSourceImpl > xThis( this ); - const SdrHint* pSdrHint = dynamic_cast<const SdrHint*>(&rHint); - const SvxViewHint* pViewHint = dynamic_cast<const SvxViewHint*>(&rHint); - const SfxSimpleHint* pSimpleHint = dynamic_cast<const SfxSimpleHint*>(&rHint); - - if (pSimpleHint) + if (const SfxSimpleHint* pSimpleHint = dynamic_cast<const SfxSimpleHint*>(&rHint)) { if (SFX_HINT_DYING == pSimpleHint->GetId()) { @@ -336,7 +332,7 @@ void SvxTextEditSourceImpl::Notify(SfxBroadcaster& rBC, const SfxHint& rHint) } } } - else if( pViewHint ) + else if (const SvxViewHint* pViewHint = dynamic_cast<const SvxViewHint*>(&rHint)) { switch( pViewHint->GetHintType() ) { @@ -345,7 +341,7 @@ void SvxTextEditSourceImpl::Notify(SfxBroadcaster& rBC, const SfxHint& rHint) break; } } - else if( pSdrHint ) + else if (const SdrHint* pSdrHint = dynamic_cast<const SdrHint*>(&rHint)) { switch( pSdrHint->GetKind() ) {
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits