tdf#54857 elide more dynamic_cast

re-arrange so we do the cheap checks before the expensive dynamic_cast

Change-Id: Ief10b42894d15ab948e64c1189e0e7abf2c5a107
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142177
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
diff --git a/editeng/source/editeng/impedit5.cxx b/editeng/source/editeng/impedit5.cxx
index 79825dc..9a02ca4 100644
--- a/editeng/source/editeng/impedit5.cxx
+++ b/editeng/source/editeng/impedit5.cxx
@@ -141,37 +141,32 @@ void ImpEditEngine::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
    // So that not a lot of unnecessary formatting is done when destructing:
    if ( !bDowning )
    {

        const SfxStyleSheetHint* pStyleSheetHint = dynamic_cast<const SfxStyleSheetHint*>(&rHint);
        if ( pStyleSheetHint )
        SfxHintId nId = rHint.GetId();
        if ( ( nId == SfxHintId::StyleSheetInDestruction ) ||
             ( nId == SfxHintId::StyleSheetErased ) )
        {
            DBG_ASSERT( dynamic_cast< const SfxStyleSheet* >(pStyleSheetHint->GetStyleSheet()) != nullptr, "No SfxStyleSheet!" );
            const SfxStyleSheetHint* pStyleSheetHint = static_cast<const SfxStyleSheetHint*>(&rHint);
            SfxStyleSheet* pStyle = static_cast<SfxStyleSheet*>( pStyleSheetHint->GetStyleSheet() );
            SfxHintId nId = pStyleSheetHint->GetId();
            if ( ( nId == SfxHintId::StyleSheetInDestruction ) ||
                 ( nId == SfxHintId::StyleSheetErased ) )
            {
                RemoveStyleFromParagraphs( pStyle );
            }
            else if ( nId == SfxHintId::StyleSheetModified )
            {
                UpdateParagraphsWithStyleSheet( pStyle );
            }
            RemoveStyleFromParagraphs( pStyle );
        }
        else if ( auto pStyle = dynamic_cast< SfxStyleSheet* >(&rBC) )
        else if ( nId == SfxHintId::StyleSheetModified )
        {
            SfxHintId nId = rHint.GetId();
            if ( nId == SfxHintId::Dying )
            {
            const SfxStyleSheetHint* pStyleSheetHint = static_cast<const SfxStyleSheetHint*>(&rHint);
            SfxStyleSheet* pStyle = static_cast<SfxStyleSheet*>( pStyleSheetHint->GetStyleSheet() );
            UpdateParagraphsWithStyleSheet( pStyle );
        }
        else if ( nId == SfxHintId::Dying )
        {
            if ( auto pStyle = dynamic_cast< SfxStyleSheet* >(&rBC) )
                RemoveStyleFromParagraphs( pStyle );
            }
            else if ( nId == SfxHintId::DataChanged )
            {
        }
        else if ( nId == SfxHintId::DataChanged )
        {
            if ( auto pStyle = dynamic_cast< SfxStyleSheet* >(&rBC) )
                UpdateParagraphsWithStyleSheet( pStyle );
            }
        }
    }
    if(dynamic_cast<const SfxApplication*>(&rBC) != nullptr && rHint.GetId() == SfxHintId::Dying)
    if (rHint.GetId() == SfxHintId::Dying && dynamic_cast<const SfxApplication*>(&rBC))
        Dispose();
}