sc/source/ui/undo/undodat.cxx                             |   28 +++++------
 sc/source/ui/undo/undotab.cxx                             |   28 +++++------
 sc/source/ui/unoobj/cellsuno.cxx                          |   27 ++++------
 sc/source/ui/unoobj/chart2uno.cxx                         |    8 +--
 sc/source/ui/unoobj/datauno.cxx                           |    5 --
 sc/source/ui/unoobj/linkuno.cxx                           |   30 +++++-------
 sc/source/ui/unoobj/notesuno.cxx                          |    8 ---
 sc/source/ui/vba/vbaworksheets.cxx                        |    4 -
 sc/source/ui/view/drawvie3.cxx                            |   12 ++--
 sc/source/ui/view/drawview.cxx                            |    8 +--
 sc/source/ui/view/tabcont.cxx                             |    4 -
 sd/source/ui/accessibility/AccessibleDocumentViewBase.cxx |    6 --
 sd/source/ui/accessibility/AccessibleSlideSorterView.cxx  |    5 --
 sd/source/ui/app/sdpopup.cxx                              |   24 +++------
 sd/source/ui/dlg/dlgfield.cxx                             |   35 ++++----------
 sd/source/ui/func/fuinsfil.cxx                            |    4 -
 sd/source/ui/func/fupoor.cxx                              |   14 ++---
 sd/source/ui/func/fuprlout.cxx                            |    5 --
 sd/source/ui/func/futhes.cxx                              |    5 --
 sd/source/ui/sidebar/MasterPageObserver.cxx               |   10 +---
 sd/source/ui/slidesorter/controller/SlsListener.cxx       |    5 --
 sd/source/ui/unoidl/unopage.cxx                           |   24 +++++----
 sd/source/ui/view/Outliner.cxx                            |    4 -
 sd/source/ui/view/ViewShellBase.cxx                       |    5 --
 sd/source/ui/view/drbezob.cxx                             |   16 +++---
 sd/source/ui/view/sdview2.cxx                             |    4 -
 sd/source/ui/view/sdview3.cxx                             |    3 -
 sw/source/core/layout/calcmove.cxx                        |    3 -
 sw/source/core/layout/fly.cxx                             |   13 +----
 sw/source/core/layout/flylay.cxx                          |    6 --
 sw/source/core/layout/frmtool.cxx                         |   21 ++------
 sw/source/core/layout/layact.cxx                          |   34 ++++++-------
 32 files changed, 168 insertions(+), 240 deletions(-)

New commits:
commit 1374f5fdcbbd24b9ba614b378fd94f5ff95ad102
Author:     Noel <noelgran...@gmail.com>
AuthorDate: Tue Oct 13 11:02:30 2020 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Tue Oct 13 12:47:38 2020 +0200

    static_cast after dynamic_cast
    
    Change-Id: I53e10fbebfd07c471ddd9b264562317251700500
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104225
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sc/source/ui/undo/undodat.cxx b/sc/source/ui/undo/undodat.cxx
index 16148d5e61a9..c3a9476d7804 100644
--- a/sc/source/ui/undo/undodat.cxx
+++ b/sc/source/ui/undo/undodat.cxx
@@ -213,9 +213,9 @@ void ScUndoMakeOutline::Redo()
 
 void ScUndoMakeOutline::Repeat(SfxRepeatTarget& rTarget)
 {
-    if (dynamic_cast<const ScTabViewTarget*>( &rTarget) !=  nullptr)
+    if (auto pViewTarget = dynamic_cast<ScTabViewTarget*>( &rTarget))
     {
-        ScTabViewShell& rViewShell = 
*static_cast<ScTabViewTarget&>(rTarget).GetViewShell();
+        ScTabViewShell& rViewShell = *pViewTarget->GetViewShell();
 
         if (bMake)
             rViewShell.MakeOutline( bColumns );
@@ -303,8 +303,8 @@ void ScUndoOutlineLevel::Redo()
 
 void ScUndoOutlineLevel::Repeat(SfxRepeatTarget& rTarget)
 {
-    if (dynamic_cast<const ScTabViewTarget*>( &rTarget) !=  nullptr)
-        static_cast<ScTabViewTarget&>(rTarget).GetViewShell()->SelectLevel( 
bColumns, nLevel );
+    if (auto pViewTarget = dynamic_cast<ScTabViewTarget*>( &rTarget))
+        pViewTarget->GetViewShell()->SelectLevel( bColumns, nLevel );
 }
 
 bool ScUndoOutlineLevel::CanRepeat(SfxRepeatTarget& rTarget) const
@@ -400,9 +400,9 @@ void ScUndoOutlineBlock::Redo()
 
 void ScUndoOutlineBlock::Repeat(SfxRepeatTarget& rTarget)
 {
-    if (dynamic_cast<const ScTabViewTarget*>( &rTarget) !=  nullptr)
+    if (auto pViewTarget = dynamic_cast<ScTabViewTarget*>( &rTarget))
     {
-        ScTabViewShell& rViewShell = 
*static_cast<ScTabViewTarget&>(rTarget).GetViewShell();
+        ScTabViewShell& rViewShell = *pViewTarget->GetViewShell();
 
         if (bShow)
             rViewShell.ShowMarkedOutlines();
@@ -493,8 +493,8 @@ void ScUndoRemoveAllOutlines::Redo()
 
 void ScUndoRemoveAllOutlines::Repeat(SfxRepeatTarget& rTarget)
 {
-    if (dynamic_cast<const ScTabViewTarget*>( &rTarget) !=  nullptr)
-        
static_cast<ScTabViewTarget&>(rTarget).GetViewShell()->RemoveAllOutlines();
+    if (auto pViewTarget = dynamic_cast<ScTabViewTarget*>( &rTarget))
+        pViewTarget->GetViewShell()->RemoveAllOutlines();
 }
 
 bool ScUndoRemoveAllOutlines::CanRepeat(SfxRepeatTarget& rTarget) const
@@ -590,8 +590,8 @@ void ScUndoAutoOutline::Redo()
 
 void ScUndoAutoOutline::Repeat(SfxRepeatTarget& rTarget)
 {
-    if (dynamic_cast<const ScTabViewTarget*>( &rTarget) !=  nullptr)
-        static_cast<ScTabViewTarget&>(rTarget).GetViewShell()->AutoOutline();
+    if (auto pViewTarget = dynamic_cast<ScTabViewTarget*>( &rTarget))
+        pViewTarget->GetViewShell()->AutoOutline();
 }
 
 bool ScUndoAutoOutline::CanRepeat(SfxRepeatTarget& rTarget) const
@@ -1217,9 +1217,9 @@ void ScUndoImportData::Redo()
 
 void ScUndoImportData::Repeat(SfxRepeatTarget& rTarget)
 {
-    if (dynamic_cast<const ScTabViewTarget*>( &rTarget) !=  nullptr)
+    if (auto pViewTarget = dynamic_cast<ScTabViewTarget*>( &rTarget))
     {
-        ScTabViewShell& rViewShell = 
*static_cast<ScTabViewTarget&>(rTarget).GetViewShell();
+        ScTabViewShell& rViewShell = *pViewTarget->GetViewShell();
 
         SCTAB nDummy;
         ScImportParam aNewParam(aImportParam);
@@ -1393,8 +1393,8 @@ void ScUndoRepeatDB::Redo()
 
 void ScUndoRepeatDB::Repeat(SfxRepeatTarget& rTarget)
 {
-    if (dynamic_cast<const ScTabViewTarget*>( &rTarget) !=  nullptr)
-        static_cast<ScTabViewTarget&>(rTarget).GetViewShell()->RepeatDB();
+    if (auto pViewTarget = dynamic_cast<ScTabViewTarget*>( &rTarget))
+        pViewTarget->GetViewShell()->RepeatDB();
 }
 
 bool ScUndoRepeatDB::CanRepeat(SfxRepeatTarget& rTarget) const
diff --git a/sc/source/ui/undo/undotab.cxx b/sc/source/ui/undo/undotab.cxx
index f9956bded40c..4118b1bcbd5d 100644
--- a/sc/source/ui/undo/undotab.cxx
+++ b/sc/source/ui/undo/undotab.cxx
@@ -142,8 +142,8 @@ void ScUndoInsertTab::Redo()
 
 void ScUndoInsertTab::Repeat(SfxRepeatTarget& rTarget)
 {
-    if (dynamic_cast<const ScTabViewTarget*>( &rTarget) !=  nullptr)
-        
static_cast<ScTabViewTarget&>(rTarget).GetViewShell()->GetViewData().GetDispatcher().
+    if (auto pViewTarget = dynamic_cast<ScTabViewTarget*>( &rTarget))
+        pViewTarget->GetViewShell()->GetViewData().GetDispatcher().
             Execute(FID_INS_TABLE, SfxCallMode::SLOT | SfxCallMode::RECORD);
 }
 
@@ -236,8 +236,8 @@ void ScUndoInsertTables::Redo()
 
 void ScUndoInsertTables::Repeat(SfxRepeatTarget& rTarget)
 {
-    if (dynamic_cast<const ScTabViewTarget*>( &rTarget) !=  nullptr)
-        
static_cast<ScTabViewTarget&>(rTarget).GetViewShell()->GetViewData().GetDispatcher().
+    if (auto pViewTarget = dynamic_cast<ScTabViewTarget*>( &rTarget))
+        pViewTarget->GetViewShell()->GetViewData().GetDispatcher().
             Execute(FID_INS_TABLE, SfxCallMode::SLOT | SfxCallMode::RECORD);
 }
 
@@ -394,9 +394,9 @@ void ScUndoDeleteTab::Redo()
 
 void ScUndoDeleteTab::Repeat(SfxRepeatTarget& rTarget)
 {
-    if (dynamic_cast<const ScTabViewTarget*>( &rTarget) !=  nullptr)
+    if (auto pViewTarget = dynamic_cast<ScTabViewTarget*>( &rTarget))
     {
-        ScTabViewShell* pViewShell = 
static_cast<ScTabViewTarget&>(rTarget).GetViewShell();
+        ScTabViewShell* pViewShell = pViewTarget->GetViewShell();
         pViewShell->DeleteTable( pViewShell->GetViewData().GetTabNo() );
     }
 }
@@ -842,9 +842,9 @@ void ScUndoMakeScenario::Redo()
 
 void ScUndoMakeScenario::Repeat(SfxRepeatTarget& rTarget)
 {
-    if (dynamic_cast<const ScTabViewTarget*>( &rTarget) !=  nullptr)
+    if (auto pViewTarget = dynamic_cast<ScTabViewTarget*>( &rTarget))
     {
-        static_cast<ScTabViewTarget&>(rTarget).GetViewShell()->MakeScenario( 
aName, aComment, aColor, nFlags );
+        pViewTarget->GetViewShell()->MakeScenario( aName, aComment, aColor, 
nFlags );
     }
 }
 
@@ -996,8 +996,8 @@ void ScUndoImportTab::Redo()
 
 void ScUndoImportTab::Repeat(SfxRepeatTarget& rTarget)
 {
-    if (dynamic_cast<const ScTabViewTarget*>( &rTarget) !=  nullptr)
-        
static_cast<ScTabViewTarget&>(rTarget).GetViewShell()->GetViewData().GetDispatcher().
+    if (auto pViewTarget = dynamic_cast<ScTabViewTarget*>( &rTarget))
+        pViewTarget->GetViewShell()->GetViewData().GetDispatcher().
             Execute(FID_INS_TABLE, SfxCallMode::SLOT | SfxCallMode::RECORD);
 }
 
@@ -1123,8 +1123,8 @@ void ScUndoShowHideTab::Redo()
 
 void ScUndoShowHideTab::Repeat(SfxRepeatTarget& rTarget)
 {
-    if (dynamic_cast<const ScTabViewTarget*>( &rTarget) !=  nullptr)
-        
static_cast<ScTabViewTarget&>(rTarget).GetViewShell()->GetViewData().GetDispatcher().
+    if (auto pViewTarget = dynamic_cast<ScTabViewTarget*>( &rTarget))
+        pViewTarget->GetViewShell()->GetViewData().GetDispatcher().
             Execute( bShow ? FID_TABLE_SHOW : FID_TABLE_HIDE,
                                 SfxCallMode::SLOT | SfxCallMode::RECORD);
 }
@@ -1532,8 +1532,8 @@ void ScUndoLayoutRTL::Redo()
 
 void ScUndoLayoutRTL::Repeat(SfxRepeatTarget& rTarget)
 {
-    if (dynamic_cast<const ScTabViewTarget*>( &rTarget) !=  nullptr)
-        
static_cast<ScTabViewTarget&>(rTarget).GetViewShell()->GetViewData().GetDispatcher().
+    if (auto pViewTarget = dynamic_cast<ScTabViewTarget*>( &rTarget))
+        pViewTarget->GetViewShell()->GetViewData().GetDispatcher().
             Execute( FID_TAB_RTL, SfxCallMode::SLOT | SfxCallMode::RECORD);
 }
 
diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx
index b60984d7b53b..8e5667800811 100644
--- a/sc/source/ui/unoobj/cellsuno.cxx
+++ b/sc/source/ui/unoobj/cellsuno.cxx
@@ -1544,19 +1544,17 @@ void ScCellRangesBase::Notify( SfxBroadcaster&, const 
SfxHint& rHint )
         }
         return;
     }
-    if ( dynamic_cast<const ScUpdateRefHint*>(&rHint) )
+    if ( auto pRefHint = dynamic_cast<const ScUpdateRefHint*>(&rHint) )
     {
-        const ScUpdateRefHint& rRef = static_cast<const 
ScUpdateRefHint&>(rHint);
-
         ScDocument& rDoc = pDocShell->GetDocument();
         std::unique_ptr<ScRangeList> pUndoRanges;
         if ( rDoc.HasUnoRefUndo() )
             pUndoRanges.reset(new ScRangeList( aRanges ));
 
-        if ( aRanges.UpdateReference( rRef.GetMode(), &rDoc, rRef.GetRange(),
-                                    rRef.GetDx(), rRef.GetDy(), rRef.GetDz() ) 
)
+        if ( aRanges.UpdateReference( pRefHint->GetMode(), &rDoc, 
pRefHint->GetRange(),
+                                    pRefHint->GetDx(), pRefHint->GetDy(), 
pRefHint->GetDz() ) )
         {
-            if (  rRef.GetMode() == URM_INSDEL
+            if (  pRefHint->GetMode() == URM_INSDEL
                && aRanges.size() == 1
                && 
comphelper::getUnoTunnelImplementation<ScTableSheetObj>(xThis)
                )
@@ -1578,14 +1576,13 @@ void ScCellRangesBase::Notify( SfxBroadcaster&, const 
SfxHint& rHint )
                 rDoc.AddUnoRefChange( nObjectId, *pUndoRanges );
         }
     }
-    else if ( dynamic_cast<const ScUnoRefUndoHint*>(&rHint) )
+    else if ( auto pUndoHint = dynamic_cast<const ScUnoRefUndoHint*>(&rHint) )
     {
-        const ScUnoRefUndoHint& rUndoHint = static_cast<const 
ScUnoRefUndoHint&>(rHint);
-        if ( rUndoHint.GetObjectId() == nObjectId )
+        if ( pUndoHint->GetObjectId() == nObjectId )
         {
             // restore ranges from hint
 
-            aRanges = rUndoHint.GetRanges();
+            aRanges = pUndoHint->GetRanges();
 
             RefChanged();
             if ( !aValueListeners.empty() )
@@ -7408,9 +7405,8 @@ void SAL_CALL ScTableSheetObj::link( const OUString& 
aUrl, const OUString& aShee
     for ( sal_uInt16 i=0; i<nCount; i++ )
     {
         ::sfx2::SvBaseLink* pBase = pLinkManager->GetLinks()[i].get();
-        if (dynamic_cast<const ScTableLink*>( pBase) !=  nullptr)
+        if (auto pTabLink = dynamic_cast<ScTableLink*>( pBase))
         {
-            ScTableLink* pTabLink = static_cast<ScTableLink*>(pBase);
             if ( aFileString == pTabLink->GetFileName() )
                 pTabLink->Update();                         // include 
Paint&Undo
 
@@ -8673,11 +8669,10 @@ ScCellsObj::~ScCellsObj()
 
 void ScCellsObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
 {
-    if ( dynamic_cast<const ScUpdateRefHint*>(&rHint) )
+    if ( auto pRefHint = dynamic_cast<const ScUpdateRefHint*>(&rHint) )
     {
-        const ScUpdateRefHint& rRef = static_cast<const 
ScUpdateRefHint&>(rHint);
-        aRanges.UpdateReference( rRef.GetMode(), &pDocShell->GetDocument(), 
rRef.GetRange(),
-                                        rRef.GetDx(), rRef.GetDy(), 
rRef.GetDz() );
+        aRanges.UpdateReference( pRefHint->GetMode(), 
&pDocShell->GetDocument(), pRefHint->GetRange(),
+                                        pRefHint->GetDx(), pRefHint->GetDy(), 
pRefHint->GetDz() );
     }
     else if ( rHint.GetId() == SfxHintId::Dying )
     {
diff --git a/sc/source/ui/unoobj/chart2uno.cxx 
b/sc/source/ui/unoobj/chart2uno.cxx
index 2d3a61972efa..ffbcba6c234f 100644
--- a/sc/source/ui/unoobj/chart2uno.cxx
+++ b/sc/source/ui/unoobj/chart2uno.cxx
@@ -2737,13 +2737,11 @@ void ScChart2DataSequence::Notify( SfxBroadcaster& 
/*rBC*/, const SfxHint& rHint
                 m_pDocument->AddUnoRefChange(m_nObjectId, *pUndoRanges);
         }
     }
-    else if ( dynamic_cast<const ScUnoRefUndoHint*>(&rHint) )
+    else if ( auto pUndoHint = dynamic_cast<const ScUnoRefUndoHint*>(&rHint) )
     {
-        const ScUnoRefUndoHint& rUndoHint = static_cast<const 
ScUnoRefUndoHint&>(rHint);
-
         do
         {
-            if (rUndoHint.GetObjectId() != m_nObjectId)
+            if (pUndoHint->GetObjectId() != m_nObjectId)
                 break;
 
             // The hint object provides the old ranges.  Restore the old state
@@ -2755,7 +2753,7 @@ void ScChart2DataSequence::Notify( SfxBroadcaster& 
/*rBC*/, const SfxHint& rHint
                 break;
             }
 
-            const ScRangeList& rRanges = rUndoHint.GetRanges();
+            const ScRangeList& rRanges = pUndoHint->GetRanges();
 
             size_t nCount = rRanges.size();
             if (nCount != m_pRangeIndices->size())
diff --git a/sc/source/ui/unoobj/datauno.cxx b/sc/source/ui/unoobj/datauno.cxx
index 677a6852fe2c..2f2bdae144a4 100644
--- a/sc/source/ui/unoobj/datauno.cxx
+++ b/sc/source/ui/unoobj/datauno.cxx
@@ -1554,13 +1554,12 @@ void ScDatabaseRangeObj::Notify( SfxBroadcaster&, const 
SfxHint& rHint )
 
     if ( rHint.GetId() == SfxHintId::Dying )
         pDocShell = nullptr;
-    else if ( dynamic_cast<const ScDBRangeRefreshedHint*>(&rHint) )
+    else if ( auto pRefreshHint = dynamic_cast<const 
ScDBRangeRefreshedHint*>(&rHint) )
     {
         ScDBData* pDBData = GetDBData_Impl();
-        const ScDBRangeRefreshedHint& rRef = static_cast<const 
ScDBRangeRefreshedHint&>(rHint);
         ScImportParam aParam;
         pDBData->GetImportParam(aParam);
-        if (aParam == rRef.GetImportParam())
+        if (aParam == pRefreshHint->GetImportParam())
             Refreshed_Impl();
     }
 }
diff --git a/sc/source/ui/unoobj/linkuno.cxx b/sc/source/ui/unoobj/linkuno.cxx
index 7dea06ff2a9b..46a0755d802b 100644
--- a/sc/source/ui/unoobj/linkuno.cxx
+++ b/sc/source/ui/unoobj/linkuno.cxx
@@ -93,10 +93,9 @@ void ScSheetLinkObj::Notify( SfxBroadcaster&, const SfxHint& 
rHint )
     //! notify if links in document are changed
     //  UpdateRef is not needed here
 
-    if ( dynamic_cast<const ScLinkRefreshedHint*>(&rHint) )
+    if ( auto pRefreshHint = dynamic_cast<const ScLinkRefreshedHint*>(&rHint) )
     {
-        const ScLinkRefreshedHint& rLH = static_cast<const 
ScLinkRefreshedHint&>(rHint);
-        if ( rLH.GetLinkType() == ScLinkRefType::SHEET && rLH.GetUrl() == 
aFileName )
+        if ( pRefreshHint->GetLinkType() == ScLinkRefType::SHEET && 
pRefreshHint->GetUrl() == aFileName )
             Refreshed_Impl();
     }
     else
@@ -115,9 +114,8 @@ ScTableLink* ScSheetLinkObj::GetLink_Impl() const
         for (size_t i=0; i<nCount; i++)
         {
             ::sfx2::SvBaseLink* pBase = pLinkManager->GetLinks()[i].get();
-            if (dynamic_cast<const ScTableLink*>( pBase) !=  nullptr)
+            if (auto pTabLink = dynamic_cast<ScTableLink*>( pBase))
             {
-                ScTableLink* pTabLink = static_cast<ScTableLink*>(pBase);
                 if ( pTabLink->GetFileName() == aFileName )
                     return pTabLink;
             }
@@ -560,10 +558,10 @@ static ScAreaLink* lcl_GetAreaLink( ScDocShell* 
pDocShell, size_t nPos )
         for (size_t i=0; i<nTotalCount; i++)
         {
             ::sfx2::SvBaseLink* pBase = pLinkManager->GetLinks()[i].get();
-            if (dynamic_cast<const ScAreaLink*>( pBase) !=  nullptr)
+            if (auto pAreaLink = dynamic_cast<ScAreaLink*>( pBase))
             {
                 if ( nAreaCount == nPos )
-                    return static_cast<ScAreaLink*>(pBase);
+                    return pAreaLink;
                 ++nAreaCount;
             }
         }
@@ -592,14 +590,13 @@ void ScAreaLinkObj::Notify( SfxBroadcaster&, const 
SfxHint& rHint )
     //! notify if links in document are changed
     //  UpdateRef is not needed here
 
-    if ( dynamic_cast<const ScLinkRefreshedHint*>(&rHint) )
+    if ( auto pRefreshedHint = dynamic_cast<const 
ScLinkRefreshedHint*>(&rHint) )
     {
-        const ScLinkRefreshedHint& rLH = static_cast<const 
ScLinkRefreshedHint&>(rHint);
-        if ( rLH.GetLinkType() == ScLinkRefType::AREA )
+        if ( pRefreshedHint->GetLinkType() == ScLinkRefType::AREA )
         {
             //  get this link to compare dest position
             ScAreaLink* pLink = lcl_GetAreaLink(pDocShell, nPos);
-            if ( pLink && pLink->GetDestArea().aStart == rLH.GetDestPos() )
+            if ( pLink && pLink->GetDestArea().aStart == 
pRefreshedHint->GetDestPos() )
                 Refreshed_Impl();
         }
     }
@@ -1014,13 +1011,12 @@ void ScDDELinkObj::Notify( SfxBroadcaster&, const 
SfxHint& rHint )
     //! notify if links in document are changed
     //  UpdateRef is not needed here
 
-    if ( dynamic_cast<const ScLinkRefreshedHint*>(&rHint) )
+    if ( auto pRefreshedHint = dynamic_cast<const 
ScLinkRefreshedHint*>(&rHint) )
     {
-        const ScLinkRefreshedHint& rLH = static_cast<const 
ScLinkRefreshedHint&>(rHint);
-        if ( rLH.GetLinkType() == ScLinkRefType::DDE &&
-             rLH.GetDdeAppl()  == aAppl &&
-             rLH.GetDdeTopic() == aTopic &&
-             rLH.GetDdeItem()  == aItem )       //! mode is ignored
+        if ( pRefreshedHint->GetLinkType() == ScLinkRefType::DDE &&
+             pRefreshedHint->GetDdeAppl()  == aAppl &&
+             pRefreshedHint->GetDdeTopic() == aTopic &&
+             pRefreshedHint->GetDdeItem()  == aItem )       //! mode is ignored
             Refreshed_Impl();
     }
     else
diff --git a/sc/source/ui/unoobj/notesuno.cxx b/sc/source/ui/unoobj/notesuno.cxx
index e43fec8eb86b..8929192825b6 100644
--- a/sc/source/ui/unoobj/notesuno.cxx
+++ b/sc/source/ui/unoobj/notesuno.cxx
@@ -75,13 +75,7 @@ ScAnnotationObj::~ScAnnotationObj()
 
 void ScAnnotationObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
 {
-    if ( dynamic_cast<const ScUpdateRefHint*>(&rHint) )
-    {
-//        const ScUpdateRefHint& rRef = (const ScUpdateRefHint&)rHint;
-
-        //! Ref-Update
-    }
-    else if ( rHint.GetId() == SfxHintId::Dying )
+    if ( rHint.GetId() == SfxHintId::Dying )
     {
         pDocShell = nullptr;       // became invalid
     }
diff --git a/sc/source/ui/vba/vbaworksheets.cxx 
b/sc/source/ui/vba/vbaworksheets.cxx
index fbef67a68e32..616440ac0daa 100644
--- a/sc/source/ui/vba/vbaworksheets.cxx
+++ b/sc/source/ui/vba/vbaworksheets.cxx
@@ -500,10 +500,10 @@ void ScVbaWorksheets::PrintPreview( const css::uno::Any& 
/*EnableChanges*/ )
     dispatchExecute( pViewShell, SID_VIEWSHELL1 );
     SfxViewShell*  pShell = SfxViewShell::Get( 
pViewFrame->GetFrame().GetFrameInterface()->getController() );
 
-    if (  dynamic_cast<const ScPreviewShell*>( pShell) ==  nullptr )
+    ScPreviewShell* pPrvShell = dynamic_cast< ScPreviewShell* >( pShell );
+    if ( !pPrvShell )
         return;
 
-    ScPreviewShell* pPrvShell = static_cast<  ScPreviewShell* >( pShell );
     ScPreview* pPrvView = pPrvShell->GetPreview();
     const ScDocument& rDoc = pViewShell->GetViewData().GetDocument();
     ScMarkData aMarkData(rDoc.GetSheetLimits());
diff --git a/sc/source/ui/view/drawvie3.cxx b/sc/source/ui/view/drawvie3.cxx
index b8e9623fe172..2305083b4739 100644
--- a/sc/source/ui/view/drawvie3.cxx
+++ b/sc/source/ui/view/drawvie3.cxx
@@ -180,9 +180,9 @@ void ScDrawView::Notify( SfxBroadcaster& rBC, const 
SfxHint& rHint )
         adjustAnchoredPosition(*pSdrHint, rDoc, nTab);
         FmFormView::Notify( rBC,rHint );
     }
-    else if (dynamic_cast<const ScTabDeletedHint*>(&rHint))                    
    // Sheet has been deleted
+    else if (auto pDeletedHint = dynamic_cast<const 
ScTabDeletedHint*>(&rHint))                        // Sheet has been deleted
     {
-        SCTAB nDelTab = static_cast<const ScTabDeletedHint&>(rHint).GetTab();
+        SCTAB nDelTab = pDeletedHint->GetTab();
         if (ValidTab(nDelTab))
         {
             // used to be: HidePagePgNum(nDelTab) - hide only if the deleted 
sheet is shown here
@@ -190,9 +190,9 @@ void ScDrawView::Notify( SfxBroadcaster& rBC, const 
SfxHint& rHint )
                 HideSdrPage();
         }
     }
-    else if (dynamic_cast<const ScTabSizeChangedHint*>(&rHint))               
// Size has been changed
+    else if (auto pChangedHint = dynamic_cast<const 
ScTabSizeChangedHint*>(&rHint))               // Size has been changed
     {
-        if ( nTab == static_cast<const ScTabSizeChangedHint&>(rHint).GetTab() )
+        if ( nTab == pChangedHint->GetTab() )
             UpdateWorkArea();
     }
     else
@@ -217,8 +217,8 @@ void ScDrawView::UpdateIMap( SdrObject* pObj )
     SfxViewFrame::GetTargetList( aTargetList );
 
     // handle graphics from object
-    if ( dynamic_cast<const SdrGrafObj*>( pObj) !=  nullptr )
-        aGraphic = static_cast<SdrGrafObj*>(pObj)->GetGraphic();
+    if ( auto pGrafObj = dynamic_cast<SdrGrafObj*>( pObj) )
+        aGraphic = pGrafObj->GetGraphic();
     else
     {
         const Graphic* pGraphic = static_cast<const 
SdrOle2Obj*>(pObj)->GetGraphic();
diff --git a/sc/source/ui/view/drawview.cxx b/sc/source/ui/view/drawview.cxx
index 029220816f25..50d8f32334b1 100644
--- a/sc/source/ui/view/drawview.cxx
+++ b/sc/source/ui/view/drawview.cxx
@@ -434,9 +434,9 @@ void ScDrawView::MarkListHasChanged()
         for (size_t i=0; i<nMarkCount; ++i)
         {
             SdrObject* pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
-            if ( dynamic_cast<const SdrObjGroup*>( pObj) !=  nullptr )
+            if ( auto pObjGroup = dynamic_cast<const SdrObjGroup*>( pObj) )
             {
-                const SdrObjList *pLst = 
static_cast<SdrObjGroup*>(pObj)->GetSubList();
+                const SdrObjList *pLst = pObjGroup->GetSubList();
                 const size_t nListCount = pLst->GetObjCount();
                 if ( nListCount == 0 )
                 {
@@ -923,9 +923,9 @@ void ScDrawView::MarkDropObj( SdrObject* pObj )
 void ScDrawView::SyncForGrid( SdrObject* pObj )
 {
     // process members of a group shape separately
-    if ( dynamic_cast<const SdrObjGroup*>( pObj) !=  nullptr )
+    if ( auto pObjGroup = dynamic_cast<const SdrObjGroup*>( pObj) )
     {
-        SdrObjList *pLst = static_cast<SdrObjGroup*>(pObj)->GetSubList();
+        SdrObjList *pLst = pObjGroup->GetSubList();
         for ( size_t i = 0, nCount = pLst->GetObjCount(); i < nCount; ++i )
             SyncForGrid( pLst->GetObj( i ) );
     }
diff --git a/sc/source/ui/view/tabcont.cxx b/sc/source/ui/view/tabcont.cxx
index a27339a914ef..4d61b2e06fec 100644
--- a/sc/source/ui/view/tabcont.cxx
+++ b/sc/source/ui/view/tabcont.cxx
@@ -512,9 +512,9 @@ static sal_uInt16 lcl_DocShellNr( const ScDocument& rDoc )
     SfxObjectShell* pShell = SfxObjectShell::GetFirst();
     while ( pShell )
     {
-        if ( dynamic_cast<const ScDocShell *>(pShell) != nullptr )
+        if ( auto pDocShell = dynamic_cast<const ScDocShell *>(pShell) )
         {
-            if ( &static_cast<ScDocShell*>(pShell)->GetDocument() == &rDoc )
+            if ( &pDocShell->GetDocument() == &rDoc )
                 return nShellCnt;
 
             ++nShellCnt;
diff --git a/sd/source/ui/accessibility/AccessibleDocumentViewBase.cxx 
b/sd/source/ui/accessibility/AccessibleDocumentViewBase.cxx
index 92ac8bdf1c0c..67238cb3154c 100644
--- a/sd/source/ui/accessibility/AccessibleDocumentViewBase.cxx
+++ b/sd/source/ui/accessibility/AccessibleDocumentViewBase.cxx
@@ -655,9 +655,8 @@ uno::Any SAL_CALL 
AccessibleDocumentViewBase::getExtendedAttributes()
 
     uno::Any anyAttribute;
     OUStringBuffer sValue;
-    if (nullptr != dynamic_cast<const ::sd::DrawViewShell* > (mpViewShell))
+    if (auto pDrViewSh = dynamic_cast<::sd::DrawViewShell* > (mpViewShell))
     {
-        ::sd::DrawViewShell* pDrViewSh = static_cast< 
::sd::DrawViewShell*>(mpViewShell);
         OUString sDisplay;
         OUString sName = "page-name:";
         // MT IA2: Not used...
@@ -708,9 +707,8 @@ uno::Any SAL_CALL 
AccessibleDocumentViewBase::getExtendedAttributes()
             sValue.append(";");
         }
     }
-    if (dynamic_cast<const ::sd::PresentationViewShell* >(mpViewShell) !=  
nullptr )
+    if (auto pPresViewSh = dynamic_cast<::sd::PresentationViewShell* 
>(mpViewShell))
     {
-        ::sd::PresentationViewShell* pPresViewSh = static_cast< 
::sd::PresentationViewShell*>(mpViewShell);
         SdPage* pCurrPge = pPresViewSh->getCurrentPage();
         SdDrawDocument* pDoc = pPresViewSh->GetDoc();
         SdPage* pNotesPge = pDoc->GetSdPage((pCurrPge->GetPageNum()-1)>>1, 
PageKind::Notes);
diff --git a/sd/source/ui/accessibility/AccessibleSlideSorterView.cxx 
b/sd/source/ui/accessibility/AccessibleSlideSorterView.cxx
index 99f38b4d3d79..b35c1a57e6f0 100644
--- a/sd/source/ui/accessibility/AccessibleSlideSorterView.cxx
+++ b/sd/source/ui/accessibility/AccessibleSlideSorterView.cxx
@@ -822,10 +822,9 @@ void AccessibleSlideSorterView::Implementation::Notify (
                 break;
         }
     }
-    else if (dynamic_cast<const sd::ViewShellHint*>(&rHint))
+    else if (auto pViewShellHint = dynamic_cast<const 
sd::ViewShellHint*>(&rHint))
     {
-        const sd::ViewShellHint& rViewShellHint = static_cast<const 
sd::ViewShellHint&>(rHint);
-        switch (rViewShellHint.GetHintId())
+        switch (pViewShellHint->GetHintId())
         {
             case sd::ViewShellHint::HINT_COMPLEX_MODEL_CHANGE_START:
                 mbModelChangeLocked = true;
diff --git a/sd/source/ui/app/sdpopup.cxx b/sd/source/ui/app/sdpopup.cxx
index eeadaef35bf9..d4b81ea7fde5 100644
--- a/sd/source/ui/app/sdpopup.cxx
+++ b/sd/source/ui/app/sdpopup.cxx
@@ -50,9 +50,8 @@ void SdFieldPopup::Fill( LanguageType eLanguage )
     InsertItem( nID++, SdResId( STR_VAR ), nStyle );
     InsertSeparator();
 
-    if( dynamic_cast< const SvxDateField *>( pField ) !=  nullptr )
+    if( auto pDateField = dynamic_cast< const SvxDateField *>( pField ) )
     {
-        const SvxDateField* pDateField = static_cast<const SvxDateField*>( 
pField );
         SvxDateField aDateField( *pDateField );
 
         if( pDateField->GetType() == SvxDateType::Fix )
@@ -82,9 +81,8 @@ void SdFieldPopup::Fill( LanguageType eLanguage )
 
         CheckItem( static_cast<sal_uInt16>( pDateField->GetFormat() ) + 1 ); 
// - 2 + 3 !
     }
-    else if( dynamic_cast< const SvxExtTimeField *>( pField ) !=  nullptr )
+    else if( auto pTimeField = dynamic_cast< const SvxExtTimeField *>( pField 
) )
     {
-        const SvxExtTimeField* pTimeField = static_cast<const 
SvxExtTimeField*>( pField );
         SvxExtTimeField aTimeField( *pTimeField );
 
         if( pTimeField->GetType() == SvxTimeType::Fix )
@@ -116,9 +114,8 @@ void SdFieldPopup::Fill( LanguageType eLanguage )
 
         CheckItem( static_cast<sal_uInt16>( pTimeField->GetFormat() ) + 1 ); 
// - 2 + 3 !
     }
-    else if( dynamic_cast< const SvxExtFileField *>( pField ) !=  nullptr )
+    else if( auto pFileField = dynamic_cast< const SvxExtFileField *>( pField 
) )
     {
-        const SvxExtFileField* pFileField = static_cast<const 
SvxExtFileField*>(pField);
         //SvxExtFileField aFileField( *pFileField );
 
         if( pFileField->GetType() == SvxFileType::Fix )
@@ -133,9 +130,8 @@ void SdFieldPopup::Fill( LanguageType eLanguage )
 
         CheckItem( static_cast<sal_uInt16>( pFileField->GetFormat() ) + 3 );
     }
-    else if( dynamic_cast< const SvxAuthorField *>( pField ) !=  nullptr )
+    else if( auto pAuthorField = dynamic_cast< const SvxAuthorField *>( pField 
) )
     {
-        const SvxAuthorField* pAuthorField = static_cast<const 
SvxAuthorField*>(pField);
         SvxAuthorField aAuthorField( *pAuthorField );
 
         if( pAuthorField->GetType() == SvxAuthorType::Fix )
@@ -161,9 +157,8 @@ SvxFieldData* SdFieldPopup::GetField()
     SvxFieldData* pNewField = nullptr;
     sal_uInt16 nCount = GetItemCount();
 
-    if( dynamic_cast< const SvxDateField *>( pField ) !=  nullptr )
+    if( auto pDateField = dynamic_cast< const SvxDateField *>( pField ) )
     {
-        const SvxDateField* pDateField = static_cast<const 
SvxDateField*>(pField);
         SvxDateType   eType;
         SvxDateFormat eFormat;
         sal_uInt16 i;
@@ -194,9 +189,8 @@ SvxFieldData* SdFieldPopup::GetField()
             }
         }
     }
-    else if( dynamic_cast< const SvxExtTimeField *>( pField ) !=  nullptr )
+    else if( auto pTimeField = dynamic_cast< const SvxExtTimeField *>( pField 
) )
     {
-        const SvxExtTimeField* pTimeField = static_cast<const 
SvxExtTimeField*>(pField);
         SvxTimeType   eType;
         SvxTimeFormat eFormat;
         sal_uInt16 i;
@@ -228,9 +222,8 @@ SvxFieldData* SdFieldPopup::GetField()
 
         }
     }
-    else if( dynamic_cast< const SvxExtFileField *>( pField ) !=  nullptr )
+    else if( auto pFileField = dynamic_cast< const SvxExtFileField *>( pField 
) )
     {
-        const SvxExtFileField* pFileField = static_cast<const 
SvxExtFileField*>(pField);
         SvxFileType   eType;
         SvxFileFormat eFormat;
         sal_uInt16 i;
@@ -265,9 +258,8 @@ SvxFieldData* SdFieldPopup::GetField()
             }
         }
     }
-    else if( dynamic_cast< const SvxAuthorField *>( pField ) !=  nullptr )
+    else if( auto pAuthorField = dynamic_cast< const SvxAuthorField *>( pField 
) )
     {
-        const SvxAuthorField* pAuthorField = static_cast<const 
SvxAuthorField*>(pField);
         SvxAuthorType   eType;
         SvxAuthorFormat eFormat;
         sal_uInt16 i;
diff --git a/sd/source/ui/dlg/dlgfield.cxx b/sd/source/ui/dlg/dlgfield.cxx
index 9a7bc1d0b2b0..dd8b4535d045 100644
--- a/sd/source/ui/dlg/dlgfield.cxx
+++ b/sd/source/ui/dlg/dlgfield.cxx
@@ -65,9 +65,8 @@ SvxFieldData* SdModifyFieldDlg::GetField()
         m_xRbtVar->get_state_changed_from_saved() ||
         m_xLbFormat->get_value_changed_from_saved() )
     {
-        if( dynamic_cast< const SvxDateField *>( m_pField ) !=  nullptr )
+        if( auto pDateField = dynamic_cast< const SvxDateField *>( m_pField ) )
         {
-            const SvxDateField* pDateField = static_cast<const 
SvxDateField*>(m_pField);
             SvxDateType   eType;
             SvxDateFormat eFormat;
 
@@ -82,9 +81,8 @@ SvxFieldData* SdModifyFieldDlg::GetField()
             static_cast<SvxDateField*>( pNewField )->SetType( eType );
             static_cast<SvxDateField*>( pNewField )->SetFormat( eFormat );
         }
-        else if( dynamic_cast< const SvxExtTimeField *>( m_pField ) !=  
nullptr )
+        else if( auto pTimeField = dynamic_cast< const SvxExtTimeField *>( 
m_pField ) )
         {
-            const SvxExtTimeField* pTimeField = static_cast<const 
SvxExtTimeField*>( m_pField );
             SvxTimeType   eType;
             SvxTimeFormat eFormat;
 
@@ -154,9 +152,8 @@ void SdModifyFieldDlg::FillFormatList()
 
     m_xLbFormat->clear();
 
-    if( dynamic_cast< const SvxDateField *>( m_pField ) !=  nullptr )
+    if( auto pDateField = dynamic_cast< const SvxDateField *>( m_pField ) )
     {
-        const SvxDateField* pDateField = static_cast<const SvxDateField*>( 
m_pField );
         SvxDateField aDateField( *pDateField );
 
         //SvxDateFormat::AppDefault,     // not used
@@ -180,9 +177,8 @@ void SdModifyFieldDlg::FillFormatList()
 
         m_xLbFormat->set_active( 
static_cast<sal_uInt16>(pDateField->GetFormat()) - 2 );
     }
-    else if( dynamic_cast< const SvxExtTimeField *>( m_pField ) !=  nullptr )
+    else if( auto pTimeField = dynamic_cast< const SvxExtTimeField *>( 
m_pField ) )
     {
-        const SvxExtTimeField* pTimeField = static_cast<const 
SvxExtTimeField*>( m_pField );
         SvxExtTimeField aTimeField( *pTimeField );
 
         //SvxTimeFormat::AppDefault,     // not used
@@ -208,10 +204,8 @@ void SdModifyFieldDlg::FillFormatList()
 
         m_xLbFormat->set_active( 
static_cast<sal_uInt16>(pTimeField->GetFormat()) - 2 );
     }
-    else if( dynamic_cast< const SvxExtFileField *>( m_pField ) !=  nullptr )
+    else if( auto pFileField = dynamic_cast< const SvxExtFileField *>( 
m_pField ) )
     {
-        const SvxExtFileField* pFileField = static_cast<const 
SvxExtFileField*>( m_pField );
-
         m_xLbFormat->append_text( SdResId( STR_FILEFORMAT_NAME_EXT ) );
         m_xLbFormat->append_text( SdResId( STR_FILEFORMAT_FULLPATH ) );
         m_xLbFormat->append_text( SdResId( STR_FILEFORMAT_PATH ) );
@@ -219,9 +213,8 @@ void SdModifyFieldDlg::FillFormatList()
 
         m_xLbFormat->set_active( static_cast<sal_uInt16>( 
pFileField->GetFormat() ) );
     }
-    else if( dynamic_cast< const SvxAuthorField *>( m_pField ) !=  nullptr )
+    else if( auto pAuthorField = dynamic_cast< const SvxAuthorField *>( 
m_pField ) )
     {
-        const SvxAuthorField* pAuthorField = static_cast<const 
SvxAuthorField*>( m_pField );
         SvxAuthorField aAuthorField( *pAuthorField );
 
         for( sal_uInt16 i = 0; i < 4; i++ )
@@ -240,37 +233,29 @@ void SdModifyFieldDlg::FillControls()
 {
     m_xLbFormat->clear();
 
-    if( dynamic_cast< const SvxDateField *>( m_pField ) !=  nullptr )
+    if( auto pDateField = dynamic_cast< const SvxDateField *>( m_pField ) )
     {
-        const SvxDateField* pDateField = static_cast<const 
SvxDateField*>(m_pField);
-
         if( pDateField->GetType() == SvxDateType::Fix )
             m_xRbtFix->set_active(true);
         else
             m_xRbtVar->set_active(true);
     }
-    else if( dynamic_cast< const SvxExtTimeField *>( m_pField ) !=  nullptr )
+    else if( auto pTimeField = dynamic_cast< const SvxExtTimeField *>( 
m_pField ) )
     {
-        const SvxExtTimeField* pTimeField = static_cast<const 
SvxExtTimeField*>(m_pField);
-
         if( pTimeField->GetType() == SvxTimeType::Fix )
             m_xRbtFix->set_active(true);
         else
             m_xRbtVar->set_active(true);
     }
-    else if( dynamic_cast< const SvxExtFileField *>( m_pField ) !=  nullptr )
+    else if( auto pFileField = dynamic_cast< const SvxExtFileField *>( 
m_pField ) )
     {
-        const SvxExtFileField* pFileField = static_cast<const 
SvxExtFileField*>(m_pField);
-
         if( pFileField->GetType() == SvxFileType::Fix )
             m_xRbtFix->set_active(true);
         else
             m_xRbtVar->set_active(true);
     }
-    else if( dynamic_cast< const SvxAuthorField *>( m_pField ) !=  nullptr )
+    else if( auto pAuthorField = dynamic_cast< const SvxAuthorField *>( 
m_pField ) )
     {
-        const SvxAuthorField* pAuthorField = static_cast<const 
SvxAuthorField*>(m_pField);
-
         if( pAuthorField->GetType() == SvxAuthorType::Fix )
             m_xRbtFix->set_active(true);
         else
diff --git a/sd/source/ui/func/fuinsfil.cxx b/sd/source/ui/func/fuinsfil.cxx
index abff3b1c7046..08684ae41a5a 100644
--- a/sd/source/ui/func/fuinsfil.cxx
+++ b/sd/source/ui/func/fuinsfil.cxx
@@ -334,9 +334,9 @@ bool FuInsertFile::InsSDDinDrMode(SfxMedium* pMedium)
 
         if (pView)
         {
-            if( dynamic_cast< const OutlineView *>( pView ) !=  nullptr)
+            if( auto pOutlineView = dynamic_cast<OutlineView *>( pView ))
             {
-                pPage = static_cast<OutlineView*>(pView)->GetActualPage();
+                pPage = pOutlineView->GetActualPage();
             }
             else
             {
diff --git a/sd/source/ui/func/fupoor.cxx b/sd/source/ui/func/fupoor.cxx
index d3ceffea98e7..47225d7bb2c5 100644
--- a/sd/source/ui/func/fupoor.cxx
+++ b/sd/source/ui/func/fupoor.cxx
@@ -179,10 +179,8 @@ bool FuPoor::KeyInput(const KeyEvent& rKEvt)
         {
             if(rKEvt.GetKeyCode().IsMod1())
             {
-                if( dynamic_cast< const DrawViewShell *>( mpViewShell ) !=  
nullptr)
+                if( auto pDrawViewShell = dynamic_cast<DrawViewShell *>( 
mpViewShell ))
                 {
-                    DrawViewShell* pDrawViewShell =
-                        static_cast<DrawViewShell*>(mpViewShell);
                     SdPage* pActualPage = pDrawViewShell->GetActualPage();
                     SdrTextObj* pCandidate = nullptr;
 
@@ -298,9 +296,8 @@ bool FuPoor::KeyInput(const KeyEvent& rKEvt)
                 // increase zoom
                 mpViewShell->SetZoom(mpWindow->GetZoom() * 3 / 2);
 
-                if( dynamic_cast< const DrawViewShell *>( mpViewShell ) !=  
nullptr)
-                    static_cast<DrawViewShell*>(mpViewShell)
-                        ->SetZoomOnPage(false);
+                if( auto pViewShell = dynamic_cast<DrawViewShell *>( 
mpViewShell ))
+                    pViewShell->SetZoomOnPage(false);
 
                 bReturn = true;
             }
@@ -314,9 +311,8 @@ bool FuPoor::KeyInput(const KeyEvent& rKEvt)
                 // decrease zoom
                 mpViewShell->SetZoom(mpWindow->GetZoom() * 2 / 3);
 
-                if( dynamic_cast< const DrawViewShell *>( mpViewShell ) !=  
nullptr)
-                    static_cast<DrawViewShell*>(mpViewShell)
-                        ->SetZoomOnPage(false);
+                if( auto pViewShell = dynamic_cast<DrawViewShell *>( 
mpViewShell ))
+                    pViewShell->SetZoomOnPage(false);
 
                 bReturn = true;
             }
diff --git a/sd/source/ui/func/fuprlout.cxx b/sd/source/ui/func/fuprlout.cxx
index 08b608717e63..8ee1a4899740 100644
--- a/sd/source/ui/func/fuprlout.cxx
+++ b/sd/source/ui/func/fuprlout.cxx
@@ -230,10 +230,9 @@ void FuPresentationLayout::DoExecute( SfxRequest& rReq )
     {
         if (bOnMaster)
         {
-            if( dynamic_cast< const DrawViewShell *>( mpViewShell ) !=  
nullptr)
+            if( auto pDrawViewShell = dynamic_cast<DrawViewShell *>( 
mpViewShell ))
             {
-                ::sd::View* pView =
-                      static_cast<DrawViewShell*>(mpViewShell)->GetView();
+                ::sd::View* pView = pDrawViewShell->GetView();
                 for (auto pSelectedPage : aSelectedPages)
                 {
                     sal_uInt16 nPgNum = 
pSelectedPage->TRG_GetMasterPage().GetPageNum();
diff --git a/sd/source/ui/func/futhes.cxx b/sd/source/ui/func/futhes.cxx
index e30ac5e2ea5e..63d5ff021c9c 100644
--- a/sd/source/ui/func/futhes.cxx
+++ b/sd/source/ui/func/futhes.cxx
@@ -76,10 +76,7 @@ void FuThesaurus::DoExecute( SfxRequest& )
                 SdrMark* pMark = rMarkList.GetMark(0);
                 SdrObject* pObj = pMark->GetMarkedSdrObj();
 
-                if ( dynamic_cast< const SdrTextObj *>( pObj ) !=  nullptr )
-                {
-                    pTextObj = static_cast<SdrTextObj*>(pObj);
-                }
+                pTextObj = dynamic_cast<SdrTextObj *>( pObj );
             }
         }
 
diff --git a/sd/source/ui/sidebar/MasterPageObserver.cxx 
b/sd/source/ui/sidebar/MasterPageObserver.cxx
index b103fbaa620c..017a0bcdf991 100644
--- a/sd/source/ui/sidebar/MasterPageObserver.cxx
+++ b/sd/source/ui/sidebar/MasterPageObserver.cxx
@@ -234,14 +234,12 @@ void MasterPageObserver::Implementation::Notify(
             // filters out events that are sent in between the insertion
             // of a new standard master page and a new notes master
             // page.
-            if (dynamic_cast< const SdDrawDocument *>( &rBroadcaster ) !=  
nullptr)
+            if (auto pDrawDocument = dynamic_cast<SdDrawDocument *>( 
&rBroadcaster ))
             {
-                SdDrawDocument& rDocument (
-                    static_cast<SdDrawDocument&>(rBroadcaster));
-                if (rDocument.GetMasterSdPageCount(PageKind::Standard)
-                    == rDocument.GetMasterSdPageCount(PageKind::Notes))
+                if (pDrawDocument->GetMasterSdPageCount(PageKind::Standard)
+                    == pDrawDocument->GetMasterSdPageCount(PageKind::Notes))
                 {
-                    AnalyzeUsedMasterPages (rDocument);
+                    AnalyzeUsedMasterPages (*pDrawDocument);
                 }
             }
             break;
diff --git a/sd/source/ui/slidesorter/controller/SlsListener.cxx 
b/sd/source/ui/slidesorter/controller/SlsListener.cxx
index 5c1d58d32390..8f6b0268842f 100644
--- a/sd/source/ui/slidesorter/controller/SlsListener.cxx
+++ b/sd/source/ui/slidesorter/controller/SlsListener.cxx
@@ -287,10 +287,9 @@ void Listener::Notify (
         mrController.CheckForMasterPageAssignment();
         mrController.CheckForSlideTransitionAssignment();
     }
-    else if (dynamic_cast<const ViewShellHint*>(&rHint))
+    else if (auto pViewShellHint = dynamic_cast<const ViewShellHint*>(&rHint))
     {
-        const ViewShellHint& rViewShellHint = static_cast<const 
ViewShellHint&>(rHint);
-        switch (rViewShellHint.GetHintId())
+        switch (pViewShellHint->GetHintId())
         {
             case ViewShellHint::HINT_PAGE_RESIZE_START:
                 // Initiate a model change but do nothing (well, not much)
diff --git a/sd/source/ui/unoidl/unopage.cxx b/sd/source/ui/unoidl/unopage.cxx
index 1c95cb1820a6..5b2debfcd06e 100644
--- a/sd/source/ui/unoidl/unopage.cxx
+++ b/sd/source/ui/unoidl/unopage.cxx
@@ -1760,8 +1760,8 @@ static void refreshpage( SdDrawDocument* pDoc, const 
PageKind ePageKind )
     if( !pViewSh )
         return;
 
-    if( dynamic_cast<const ::sd::DrawViewShell* >(pViewSh) !=  nullptr )
-        static_cast< ::sd::DrawViewShell*>(pViewSh)->ResetActualPage();
+    if( auto pDrawViewShell = dynamic_cast<::sd::DrawViewShell* >(pViewSh) )
+        pDrawViewShell->ResetActualPage();
 
     Size aPageSize = pDoc->GetSdPage(0, ePageKind)->GetSize();
     const long nWidth = aPageSize.Width();
@@ -1891,8 +1891,9 @@ sal_Bool SAL_CALL SdPageLinkTargets::hasElements()
         {
             SdrObject* pObj = aIter.Next();
             OUString aStr( pObj->GetName() );
-            if( aStr.isEmpty() && dynamic_cast< const SdrOle2Obj *>( pObj ) != 
 nullptr )
-                aStr = static_cast< const SdrOle2Obj* >( pObj 
)->GetPersistName();
+            if( aStr.isEmpty() )
+                if (auto pOleObj = dynamic_cast< const SdrOle2Obj *>( pObj ))
+                    aStr = pOleObj->GetPersistName();
             if( !aStr.isEmpty() )
                 return true;
         }
@@ -1936,8 +1937,9 @@ Sequence< OUString > SAL_CALL 
SdPageLinkTargets::getElementNames()
         {
             SdrObject* pObj = aIter.Next();
             OUString aStr( pObj->GetName() );
-            if( aStr.isEmpty() && dynamic_cast< const SdrOle2Obj *>( pObj ) != 
 nullptr )
-                aStr = static_cast< const SdrOle2Obj* >( pObj 
)->GetPersistName();
+            if( aStr.isEmpty() )
+                if (auto pOleObj = dynamic_cast< const SdrOle2Obj *>( pObj ))
+                    aStr = pOleObj->GetPersistName();
             if( !aStr.isEmpty() )
                 nObjCount++;
         }
@@ -1953,8 +1955,9 @@ Sequence< OUString > SAL_CALL 
SdPageLinkTargets::getElementNames()
         {
             SdrObject* pObj = aIter.Next();
             OUString aStr( pObj->GetName() );
-            if( aStr.isEmpty() && dynamic_cast< const SdrOle2Obj *>( pObj ) != 
 nullptr )
-                aStr = static_cast< const SdrOle2Obj* >( pObj 
)->GetPersistName();
+            if( aStr.isEmpty() )
+                if (auto pOleObj = dynamic_cast< const SdrOle2Obj *>( pObj ))
+                    aStr = pOleObj->GetPersistName();
             if( !aStr.isEmpty() )
                 *pStr++ = aStr;
         }
@@ -1982,8 +1985,9 @@ SdrObject* SdPageLinkTargets::FindObject( const OUString& 
rName ) const throw()
     {
         SdrObject* pObj = aIter.Next();
         OUString aStr( pObj->GetName() );
-        if( aStr.isEmpty() && dynamic_cast< const SdrOle2Obj *>( pObj ) !=  
nullptr )
-            aStr = static_cast< const SdrOle2Obj* >( pObj )->GetPersistName();
+        if( aStr.isEmpty() )
+            if (auto pOleObj = dynamic_cast< const SdrOle2Obj *>( pObj ))
+                aStr = pOleObj->GetPersistName();
         if( !aStr.isEmpty() && (aStr == rName) )
             return pObj;
     }
diff --git a/sd/source/ui/view/Outliner.cxx b/sd/source/ui/view/Outliner.cxx
index 6f8e5b76d10f..59e740b4bda1 100644
--- a/sd/source/ui/view/Outliner.cxx
+++ b/sd/source/ui/view/Outliner.cxx
@@ -355,8 +355,8 @@ bool SdOutliner::SpellNextDocument()
     }
     else
     {
-        if( dynamic_cast< const sd::OutlineView *>( mpView ) !=  nullptr)
-            static_cast<sd::OutlineView*>(mpView)->PrepareClose();
+        if( auto pOutlineView = dynamic_cast<sd::OutlineView *>( mpView ))
+            pOutlineView->PrepareClose();
         mpDrawDocument->GetDocSh()->SetWaitCursor( true );
 
         Initialize (true);
diff --git a/sd/source/ui/view/ViewShellBase.cxx 
b/sd/source/ui/view/ViewShellBase.cxx
index df1091cced75..303ea3355a53 100644
--- a/sd/source/ui/view/ViewShellBase.cxx
+++ b/sd/source/ui/view/ViewShellBase.cxx
@@ -234,9 +234,8 @@ ViewShellBase::ViewShellBase (
     
_pFrame->GetWindow().SetBackground(Application::GetSettings().GetStyleSettings().GetLightColor());
 
     // Set up the members in the correct order.
-    if (nullptr != dynamic_cast< DrawDocShell *>( 
GetViewFrame()->GetObjectShell() ))
-        mpDocShell = static_cast<DrawDocShell*>(
-            GetViewFrame()->GetObjectShell());
+    if (auto pDrawDocShell = dynamic_cast< DrawDocShell *>( 
GetViewFrame()->GetObjectShell() ))
+        mpDocShell = pDrawDocShell;
     if (mpDocShell != nullptr)
         mpDocument = mpDocShell->GetDoc();
     mpImpl->mpViewShellManager = std::make_shared<ViewShellManager>(*this);
diff --git a/sd/source/ui/view/drbezob.cxx b/sd/source/ui/view/drbezob.cxx
index 2ab2bc56be3f..c84489042672 100644
--- a/sd/source/ui/view/drbezob.cxx
+++ b/sd/source/ui/view/drbezob.cxx
@@ -88,14 +88,14 @@ void BezierObjectBar::GetAttrState(SfxItemSet& rSet)
 
     if(xFunc.is())
     {
-        if( nullptr != dynamic_cast< const FuSelection *>( xFunc.get() ))
+        if( auto pFuSelection = dynamic_cast< const FuSelection *>( 
xFunc.get() ))
         {
-            sal_uInt16 nEditMode = 
static_cast<FuSelection*>(xFunc.get())->GetEditMode();
+            sal_uInt16 nEditMode = pFuSelection->GetEditMode();
             rSet.Put(SfxBoolItem(nEditMode, true));
         }
-        else if( nullptr != dynamic_cast< const FuConstructBezierPolygon *>( 
xFunc.get() ))
+        else if( auto pFuPolygon = dynamic_cast< const 
FuConstructBezierPolygon *>( xFunc.get() ))
         {
-            sal_uInt16 nEditMode = 
static_cast<FuConstructBezierPolygon*>(xFunc.get())->GetEditMode();
+            sal_uInt16 nEditMode = pFuPolygon->GetEditMode();
             rSet.Put(SfxBoolItem(nEditMode, true));
         }
     }
@@ -294,13 +294,13 @@ void BezierObjectBar::Execute(SfxRequest& rReq)
 
             if(xFunc.is())
             {
-                if( nullptr != dynamic_cast< const FuSelection *>( xFunc.get() 
))
+                if( auto pFuSelection = dynamic_cast<FuSelection *>( 
xFunc.get() ))
                 {
-                    
static_cast<FuSelection*>(xFunc.get())->SetEditMode(rReq.GetSlot());
+                    pFuSelection->SetEditMode(rReq.GetSlot());
                 }
-                else if( nullptr != dynamic_cast< const 
FuConstructBezierPolygon *>( xFunc.get() ))
+                else if( auto pFuPolygon = 
dynamic_cast<FuConstructBezierPolygon *>( xFunc.get() ))
                 {
-                    
static_cast<FuConstructBezierPolygon*>(xFunc.get())->SetEditMode(rReq.GetSlot());
+                    pFuPolygon->SetEditMode(rReq.GetSlot());
                 }
             }
 
diff --git a/sd/source/ui/view/sdview2.cxx b/sd/source/ui/view/sdview2.cxx
index cbe8281af0eb..e550a2291f87 100644
--- a/sd/source/ui/view/sdview2.cxx
+++ b/sd/source/ui/view/sdview2.cxx
@@ -775,10 +775,10 @@ sal_Int8 View::ExecuteDrop( const ExecuteDropEvent& rEvt,
                                 nRet = nDropAction;
                             }
                         }
-                        else if( dynamic_cast< const DrawViewShell *>( 
mpViewSh ) !=  nullptr )
+                        else if( auto pDrawViewShell = dynamic_cast< 
DrawViewShell *>( mpViewSh ) )
                         {
                             // insert as normal URL button
-                            static_cast<DrawViewShell*>( mpViewSh 
)->InsertURLButton( aINetBookmark.GetURL(), aINetBookmark.GetDescription(), 
OUString(), &aPos );
+                            pDrawViewShell->InsertURLButton( 
aINetBookmark.GetURL(), aINetBookmark.GetDescription(), OUString(), &aPos );
                             nRet = nDropAction;
                         }
                     }
diff --git a/sd/source/ui/view/sdview3.cxx b/sd/source/ui/view/sdview3.cxx
index c3508ec217fc..eca9b996d9dd 100644
--- a/sd/source/ui/view/sdview3.cxx
+++ b/sd/source/ui/view/sdview3.cxx
@@ -511,10 +511,9 @@ bool View::InsertData( const TransferableDataHelper& 
rDataHelper,
                                     {
                                         ImpRememberOrigAndClone* pRem = 
&aConnectorContainer[a];
 
-                                        if(dynamic_cast< const SdrEdgeObj *>( 
pRem->pClone ) !=  nullptr)
+                                        if(auto pCloneEdge = 
dynamic_cast<SdrEdgeObj *>( pRem->pClone ))
                                         {
                                             SdrEdgeObj* pOrigEdge = 
static_cast<SdrEdgeObj*>(pRem->pOrig);
-                                            SdrEdgeObj* pCloneEdge = 
static_cast<SdrEdgeObj*>(pRem->pClone);
 
                                             // test first connection
                                             SdrObjConnection& rConn0 = 
pOrigEdge->GetConnection(false);
diff --git a/sw/source/core/layout/calcmove.cxx 
b/sw/source/core/layout/calcmove.cxx
index 649068c841f3..170384800c46 100644
--- a/sw/source/core/layout/calcmove.cxx
+++ b/sw/source/core/layout/calcmove.cxx
@@ -716,9 +716,8 @@ static void lcl_CheckObjects(SwSortedObjs& rSortedObjs, 
const SwFrame* pFrame, l
         // #i28701# - consider changed type of <SwSortedObjs>
         // entries.
         long nTmp = 0;
-        if ( dynamic_cast<const SwFlyFrame*>( pObj) !=  nullptr )
+        if ( auto pFly = dynamic_cast<SwFlyFrame*>( pObj) )
         {
-            SwFlyFrame *pFly = static_cast<SwFlyFrame*>(pObj);
             if( pFly->getFrameArea().Top() != FAR_AWAY &&
                 ( pFrame->IsPageFrame() ? pFly->IsFlyLayFrame() :
                   ( pFly->IsFlyAtContentFrame() &&
diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx
index 29059f02bc2f..8cffa05679f6 100644
--- a/sw/source/core/layout/fly.cxx
+++ b/sw/source/core/layout/fly.cxx
@@ -328,9 +328,8 @@ void SwFlyFrame::DeleteCnt()
             {
                 // consider 'virtual' drawing objects
                 SdrObject* pObj = pAnchoredObj->DrawObj();
-                if ( dynamic_cast<const SwDrawVirtObj*>( pObj) !=  nullptr )
+                if ( auto pDrawVirtObj = dynamic_cast<SwDrawVirtObj*>( pObj) )
                 {
-                    SwDrawVirtObj* pDrawVirtObj = 
static_cast<SwDrawVirtObj*>(pObj);
                     pDrawVirtObj->RemoveFromWriterLayout();
                     pDrawVirtObj->RemoveFromDrawingPage();
                 }
@@ -2331,9 +2330,8 @@ void SwFrame::InvalidateObjs( const bool 
_bNoInvaOfAsCharAnchoredObjs )
             pAnchoredObj->SetClearedEnvironment( false );
         }
         // distinguish between writer fly frames and drawing objects
-        if ( dynamic_cast<const SwFlyFrame*>( pAnchoredObj) !=  nullptr )
+        if ( auto pFly = dynamic_cast<SwFlyFrame*>( pAnchoredObj) )
         {
-            SwFlyFrame* pFly = static_cast<SwFlyFrame*>(pAnchoredObj);
             pFly->Invalidate_();
             pFly->InvalidatePos_();
         }
@@ -2366,10 +2364,8 @@ void SwLayoutFrame::NotifyLowerObjs( const bool 
_bUnlockPosOfObjs )
         // for at-character/as-character anchored objects the anchor character
         // text frame is taken.
         const SwFrame* pAnchorFrame = pObj->GetAnchorFrameContainingAnchPos();
-        if ( dynamic_cast<const SwFlyFrame*>( pObj) !=  nullptr )
+        if ( auto pFly = dynamic_cast<SwFlyFrame*>( pObj) )
         {
-            SwFlyFrame* pFly = static_cast<SwFlyFrame*>(pObj);
-
             if ( pFly->getFrameArea().Left() == FAR_AWAY )
                 continue;
 
@@ -2865,9 +2861,8 @@ SwTwips SwFlyFrame::CalcContentHeight(const SwBorderAttrs 
*pAttrs, const SwTwips
             for ( size_t i = 0; i < nCnt; ++i )
             {
                 SwAnchoredObject* pAnchoredObj = (*GetDrawObjs())[i];
-                if ( dynamic_cast<const SwFlyFrame*>( pAnchoredObj) !=  
nullptr )
+                if ( auto pFly = dynamic_cast<SwFlyFrame*>( pAnchoredObj) )
                 {
-                    SwFlyFrame* pFly = static_cast<SwFlyFrame*>(pAnchoredObj);
                     // consider only Writer fly frames, which follow the text 
flow.
                     if ( pFly->IsFlyLayFrame() &&
                         pFly->getFrameArea().Top() != FAR_AWAY &&
diff --git a/sw/source/core/layout/flylay.cxx b/sw/source/core/layout/flylay.cxx
index e25d805c1971..41dd6e67d4b5 100644
--- a/sw/source/core/layout/flylay.cxx
+++ b/sw/source/core/layout/flylay.cxx
@@ -877,9 +877,8 @@ void SwPageFrame::AppendFlyToPage( SwFlyFrame *pNew )
     SwSortedObjs &rObjs = *pNew->GetDrawObjs();
     for (SwAnchoredObject* pTmpObj : rObjs)
     {
-        if ( dynamic_cast<const SwFlyFrame*>( pTmpObj) !=  nullptr )
+        if ( auto pTmpFly = dynamic_cast<SwFlyFrame*>( pTmpObj) )
         {
-            SwFlyFrame* pTmpFly = static_cast<SwFlyFrame*>(pTmpObj);
             // #i28701# - use new method <GetPageFrame()>
             if ( pTmpFly->IsFlyFreeFrame() && !pTmpFly->GetPageFrame() )
                 AppendFlyToPage( pTmpFly );
@@ -1022,9 +1021,8 @@ void SwPageFrame::MoveFly( SwFlyFrame *pToMove, 
SwPageFrame *pDest )
     SwSortedObjs &rObjs = *pToMove->GetDrawObjs();
     for (SwAnchoredObject* pObj : rObjs)
     {
-        if ( dynamic_cast<const SwFlyFrame*>( pObj) !=  nullptr )
+        if ( auto pFly = dynamic_cast<SwFlyFrame*>( pObj) )
         {
-            SwFlyFrame* pFly = static_cast<SwFlyFrame*>(pObj);
             if ( pFly->IsFlyFreeFrame() )
             {
                 // #i28701# - use new method <GetPageFrame()>
diff --git a/sw/source/core/layout/frmtool.cxx 
b/sw/source/core/layout/frmtool.cxx
index f983aedb69fd..3fa8a1a38452 100644
--- a/sw/source/core/layout/frmtool.cxx
+++ b/sw/source/core/layout/frmtool.cxx
@@ -338,9 +338,8 @@ SwFrameNotify::~SwFrameNotify() COVERITY_NOEXCEPT_FALSE
                 // perform notification via the corresponding invalidations
                 if ( bNotify )
                 {
-                    if ( dynamic_cast<const SwFlyFrame*>( pObj) !=  nullptr )
+                    if ( auto pFlyFrame = dynamic_cast<SwFlyFrame*>( pObj) )
                     {
-                        SwFlyFrame* pFlyFrame = static_cast<SwFlyFrame*>(pObj);
                         if ( bNotifySize )
                             pFlyFrame->InvalidateSize_();
                         // #115759# - no invalidation of
@@ -2252,9 +2251,8 @@ static bool lcl_hasTabFrame(const SwTextFrame* pTextFrame)
         if (pSortedObjs->size() > 0)
         {
             SwAnchoredObject* pObject = (*pSortedObjs)[0];
-            if (dynamic_cast<const SwFlyFrame*>(pObject) !=  nullptr)
+            if (auto pFly = dynamic_cast<SwFlyFrame*>(pObject))
             {
-                SwFlyFrame* pFly = static_cast<SwFlyFrame*>(pObject);
                 if (pFly->Lower() && pFly->Lower()->IsTabFrame())
                     return true;
             }
@@ -2701,10 +2699,8 @@ static void lcl_RemoveObjsFromPage( SwFrame* _pFrame )
         pObj->ResetLayoutProcessBools();
         // #115759# - remove also lower objects of as-character
         // anchored Writer fly frames from page
-        if ( dynamic_cast<const SwFlyFrame*>( pObj) !=  nullptr )
+        if ( auto pFlyFrame = dynamic_cast<SwFlyFrame*>( pObj) )
         {
-            SwFlyFrame* pFlyFrame = static_cast<SwFlyFrame*>(pObj);
-
             // #115759# - remove also direct lowers of Writer
             // fly frame from page
             if ( pFlyFrame->GetDrawObjs() )
@@ -2727,13 +2723,12 @@ static void lcl_RemoveObjsFromPage( SwFrame* _pFrame )
             }
         }
         // #115759# - remove also drawing objects from page
-        else if ( dynamic_cast<const SwAnchoredDrawObject*>( pObj) !=  nullptr 
)
+        else if ( auto pDrawObj = dynamic_cast<SwAnchoredDrawObject*>( pObj) )
         {
             if (pObj->GetFrameFormat().GetAnchor().GetAnchorId() != 
RndStdIds::FLY_AS_CHAR)
             {
                 if (SwPageFrame *pPg = pObj->GetPageFrame())
-                    pPg->RemoveDrawObjFromPage(
-                                *static_cast<SwAnchoredDrawObject*>(pObj) );
+                    pPg->RemoveDrawObjFromPage( *pDrawObj );
             }
         }
     }
@@ -2863,9 +2858,8 @@ static void lcl_AddObjsToPage( SwFrame* _pFrame, 
SwPageFrame* _pPage )
         pObj->UnlockPosition();
         // #115759# - add also lower objects of as-character
         // anchored Writer fly frames from page
-        if ( dynamic_cast<const SwFlyFrame*>( pObj) !=  nullptr )
+        if ( auto pFlyFrame = dynamic_cast<SwFlyFrame*>( pObj) )
         {
-            SwFlyFrame* pFlyFrame = static_cast<SwFlyFrame*>(pObj);
             if ( dynamic_cast<const SwFlyFreeFrame*>( pObj) !=  nullptr )
             {
                 _pPage->AppendFlyToPage( pFlyFrame );
@@ -3256,9 +3250,8 @@ static void lcl_NotifyContent( const SdrObject *pThis, 
SwContentFrame *pCnt,
     const SwSortedObjs &rObjs = *pCnt->GetDrawObjs();
     for (SwAnchoredObject* pObj : rObjs)
     {
-        if ( dynamic_cast<const SwFlyFrame*>( pObj) !=  nullptr )
+        if ( auto pFly = dynamic_cast<SwFlyFrame*>( pObj) )
         {
-            SwFlyFrame *pFly = static_cast<SwFlyFrame*>(pObj);
             if ( pFly->IsFlyInContentFrame() )
             {
                 SwContentFrame *pContent = pFly->ContainsContent();
diff --git a/sw/source/core/layout/layact.cxx b/sw/source/core/layout/layact.cxx
index 93076422c5dd..605ec7fdeaef 100644
--- a/sw/source/core/layout/layact.cxx
+++ b/sw/source/core/layout/layact.cxx
@@ -1936,15 +1936,16 @@ bool SwLayIdle::DoIdleJob_( const SwContentFrame *pCnt, 
IdleJobType eJob )
         if( COMPLETE_STRING == nTextPos )
         {
             --nTextPos;
-            if( dynamic_cast< const SwCursorShell *>( pSh ) != nullptr  && 
!static_cast<SwCursorShell*>(pSh)->IsTableMode() )
-            {
-                SwPaM *pCursor = static_cast<SwCursorShell*>(pSh)->GetCursor();
-                if( !pCursor->HasMark() && !pCursor->IsMultiSelection() )
+            if( auto pCursorShell = dynamic_cast<SwCursorShell *>( pSh ) )
+                if( !pCursorShell->IsTableMode() )
                 {
-                    pContentNode = pCursor->GetContentNode();
-                    nTextPos =  pCursor->GetPoint()->nContent.GetIndex();
+                    SwPaM *pCursor = pCursorShell->GetCursor();
+                    if( !pCursor->HasMark() && !pCursor->IsMultiSelection() )
+                    {
+                        pContentNode = pCursor->GetContentNode();
+                        nTextPos =  pCursor->GetPoint()->nContent.GetIndex();
+                    }
                 }
-            }
         }
         sal_Int32 const nPos((pContentNode && pTextNode == pContentNode)
                 ? nTextPos
@@ -2003,9 +2004,8 @@ bool SwLayIdle::DoIdleJob_( const SwContentFrame *pCnt, 
IdleJobType eJob )
         const SwSortedObjs &rObjs = *pCnt->GetDrawObjs();
         for (SwAnchoredObject* pObj : rObjs)
         {
-            if ( dynamic_cast< const SwFlyFrame *>( pObj ) !=  nullptr )
+            if ( auto pFly = dynamic_cast<SwFlyFrame *>( pObj ) )
             {
-                SwFlyFrame* pFly = static_cast<SwFlyFrame*>(pObj);
                 if ( pFly->IsFlyInContentFrame() )
                 {
                     const SwContentFrame *pC = pFly->ContainsContent();
@@ -2173,9 +2173,9 @@ SwLayIdle::SwLayIdle( SwRootFrame *pRt, SwViewShellImp 
*pI ) :
         {
             ++rSh.mnStartAction;
             bool bVis = false;
-            if ( dynamic_cast<const SwCursorShell*>( &rSh) !=  nullptr )
+            if ( auto pCursorShell = dynamic_cast<SwCursorShell*>( &rSh) )
             {
-                bVis = 
static_cast<SwCursorShell*>(&rSh)->GetCharRect().IsOver(rSh.VisArea());
+                bVis = pCursorShell->GetCharRect().IsOver(rSh.VisArea());
             }
             aBools.push_back( bVis );
         }
@@ -2210,11 +2210,9 @@ SwLayIdle::SwLayIdle( SwRootFrame *pRt, SwViewShellImp 
*pI ) :
                 // aBools[ i ] is true, if the i-th shell is a cursor shell 
(!!!)
                 // and the cursor is visible.
                 bActions |= aTmp != rSh.VisArea();
-                if ( aTmp == rSh.VisArea() && dynamic_cast<const 
SwCursorShell*>( &rSh) !=  nullptr )
-                {
-                    bActions |= aBools[nBoolIdx] !=
-                                 
static_cast<SwCursorShell*>(&rSh)->GetCharRect().IsOver( rSh.VisArea() );
-                }
+                if ( aTmp == rSh.VisArea() )
+                    if ( auto pCursorShell = dynamic_cast< SwCursorShell*>( 
&rSh) )
+                        bActions |= aBools[nBoolIdx] != 
pCursorShell->GetCharRect().IsOver( rSh.VisArea() );
             }
 
             ++nBoolIdx;
@@ -2227,9 +2225,7 @@ SwLayIdle::SwLayIdle( SwRootFrame *pRt, SwViewShellImp 
*pI ) :
             nBoolIdx = 0;
             for(SwViewShell& rSh : pImp->GetShell()->GetRingContainer())
             {
-                SwCursorShell* pCursorShell = nullptr;
-                if(dynamic_cast<const SwCursorShell*>( &rSh) !=  nullptr)
-                    pCursorShell = static_cast<SwCursorShell*>(&rSh);
+                SwCursorShell* pCursorShell = dynamic_cast<SwCursorShell*>( 
&rSh);
 
                 if ( pCursorShell )
                     pCursorShell->SttCursorMove();
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to