[Libreoffice-commits] core.git: basic/source chart2/source filter/source forms/source oox/source reportdesign/source sc/source sd/source sfx2/source svx/source sw/source

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Sun Jan 10 14:00:16 UTC 2021


 basic/source/classes/sb.cxx                          |    4 
 chart2/source/controller/main/SelectionHelper.cxx    |    4 
 filter/source/msfilter/escherex.cxx                  |   13 -
 forms/source/richtext/rtattributehandler.cxx         |    4 
 oox/source/export/shapes.cxx                         |   13 -
 reportdesign/source/ui/misc/UITools.cxx              |  160 ++++++++-----------
 sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx |   27 +--
 sc/source/ui/app/scmod.cxx                           |    3 
 sc/source/ui/drawfunc/drtxtob.cxx                    |    9 -
 sc/source/ui/undo/undoblk.cxx                        |   12 -
 sc/source/ui/unoobj/PivotTableDataProvider.cxx       |    7 
 sc/source/ui/unoobj/dapiuno.cxx                      |   13 -
 sc/source/ui/view/cellsh1.cxx                        |    9 -
 sc/source/ui/view/editsh.cxx                         |    9 -
 sc/source/ui/view/formatsh.cxx                       |    7 
 sc/source/ui/view/tabvwsh2.cxx                       |    5 
 sc/source/ui/view/tabvwsh5.cxx                       |   11 -
 sd/source/core/drawdoc4.cxx                          |   24 +-
 sd/source/core/sdpage.cxx                            |   23 +-
 sd/source/filter/ppt/pptinanimations.cxx             |    6 
 sd/source/ui/accessibility/AccessibleOutlineView.cxx |    6 
 sd/source/ui/app/sdxfer.cxx                          |   10 -
 sd/source/ui/dlg/sdtreelb.cxx                        |    5 
 sfx2/source/control/bindings.cxx                     |   28 +--
 sfx2/source/toolbox/tbxitem.cxx                      |   14 -
 svx/source/form/navigatortree.cxx                    |    7 
 svx/source/svdraw/svdcrtv.cxx                        |    9 -
 svx/source/svdraw/svddrgv.cxx                        |    4 
 svx/source/svdraw/svdpage.cxx                        |   35 ++--
 svx/source/tbxctrls/colrctrl.cxx                     |   14 -
 sw/source/core/frmedt/feshview.cxx                   |    8 
 sw/source/core/layout/fly.cxx                        |    4 
 sw/source/core/view/vdraw.cxx                        |    7 
 sw/source/filter/ww8/ww8graf.cxx                     |   11 -
 sw/source/filter/xml/xmltble.cxx                     |    5 
 sw/source/ui/dialog/docstdlg.cxx                     |    8 
 sw/source/uibase/app/apphdl.cxx                      |    8 
 sw/source/uibase/app/docsh.cxx                       |   12 -
 sw/source/uibase/uiview/view.cxx                     |    4 
 39 files changed, 266 insertions(+), 296 deletions(-)

New commits:
commit 8f453c674f19188360ba5895c2bd9bd80273a83b
Author:     Noel Grandin <noelgrandin at gmail.com>
AuthorDate: Sun Jan 10 13:58:50 2021 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Sun Jan 10 14:59:31 2021 +0100

    static_cast after dynamic_cast
    
    Change-Id: I3792ddadad9582a7e6f4740829c081d9571ddaff
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109049
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/basic/source/classes/sb.cxx b/basic/source/classes/sb.cxx
index 2fda33fffebf..4ebab52ee2c4 100644
--- a/basic/source/classes/sb.cxx
+++ b/basic/source/classes/sb.cxx
@@ -1047,9 +1047,9 @@ SbModule* StarBASIC::MakeModule( const OUString& rName, const ModuleInfo& mInfo,
 
 void StarBASIC::Insert( SbxVariable* pVar )
 {
-    if( dynamic_cast<const SbModule*>(pVar) != nullptr)
+    if( auto pModule = dynamic_cast<SbModule*>(pVar) )
     {
-        pModules.emplace_back(static_cast<SbModule*>(pVar));
+        pModules.emplace_back(pModule);
         pVar->SetParent( this );
         StartListening(pVar->GetBroadcaster(), DuplicateHandling::Prevent);
     }
diff --git a/chart2/source/controller/main/SelectionHelper.cxx b/chart2/source/controller/main/SelectionHelper.cxx
index 5475be204c00..29c71c5c1097 100644
--- a/chart2/source/controller/main/SelectionHelper.cxx
+++ b/chart2/source/controller/main/SelectionHelper.cxx
@@ -584,11 +584,11 @@ bool SelectionHelper::getMarkHandles( SdrHdlList& rHdlList )
     if( m_pMarkObj && m_pMarkObj != m_pSelectedObj)
     {
         rHdlList.Clear();
-        if( dynamic_cast<const SdrPathObj*>( m_pMarkObj) !=  nullptr )
+        if( auto pPathObj = dynamic_cast<const SdrPathObj*>( m_pMarkObj) )
         {
             //if th object is a polygon
             //from each point a handle is generated
-            const ::basegfx::B2DPolyPolygon& rPolyPolygon = static_cast<SdrPathObj*>(m_pMarkObj)->GetPathPoly();
+            const ::basegfx::B2DPolyPolygon& rPolyPolygon = pPathObj->GetPathPoly();
             for( sal_uInt32 nN = 0; nN < rPolyPolygon.count(); nN++)
             {
                 const ::basegfx::B2DPolygon& aPolygon(rPolyPolygon.getB2DPolygon(nN));
diff --git a/filter/source/msfilter/escherex.cxx b/filter/source/msfilter/escherex.cxx
index bde712649af4..1cc14d87ff83 100644
--- a/filter/source/msfilter/escherex.cxx
+++ b/filter/source/msfilter/escherex.cxx
@@ -4518,13 +4518,10 @@ sal_uInt32 EscherConnectorListEntry::GetConnectorRule( bool bFirst )
 
         if (aType == "drawing.Custom")
         {
-            const bool bIsSdrObjCustomShape(nullptr != dynamic_cast< SdrObjCustomShape* >(GetSdrObjectFromXShape(aXShape)));
-
-            if(bIsSdrObjCustomShape)
+            if (auto pSdrObjCustomShape = dynamic_cast< SdrObjCustomShape* >(GetSdrObjectFromXShape(aXShape)))
             {
-                SdrObjCustomShape& rSdrObjCustomShape(static_cast< SdrObjCustomShape& >(*GetSdrObjectFromXShape(aXShape)));
                 const SdrCustomShapeGeometryItem& rGeometryItem =
-                    rSdrObjCustomShape.GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY );
+                    pSdrObjCustomShape->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY );
 
                 OUString sShapeType;
                 const uno::Any* pType = rGeometryItem.GetPropertyValueByName( "Type" );
@@ -4541,7 +4538,7 @@ sal_uInt32 EscherConnectorListEntry::GetConnectorRule( bool bFirst )
 
                 if ( nGluePointType == drawing::EnhancedCustomShapeGluePointType::CUSTOM )
                 {
-                    const SdrGluePointList* pList = rSdrObjCustomShape.GetGluePointList();
+                    const SdrGluePointList* pList = pSdrObjCustomShape->GetGluePointList();
                     if ( pList )
                     {
                         tools::Polygon aPoly;
@@ -4551,7 +4548,7 @@ sal_uInt32 EscherConnectorListEntry::GetConnectorRule( bool bFirst )
                             for ( nNum = 0; nNum < nCnt; nNum++ )
                             {
                                 const SdrGluePoint& rGP = (*pList)[ nNum ];
-                                Point aPt(rGP.GetAbsolutePos(rSdrObjCustomShape));
+                                Point aPt(rGP.GetAbsolutePos(*pSdrObjCustomShape));
                                 aPoly.Insert( POLY_APPEND, aPt );
                             }
                             nRule = GetClosestPoint( aPoly, aRefPoint );
@@ -4562,7 +4559,7 @@ sal_uInt32 EscherConnectorListEntry::GetConnectorRule( bool bFirst )
                 else if ( nGluePointType == drawing::EnhancedCustomShapeGluePointType::SEGMENTS )
                 {
                     tools::PolyPolygon aPolyPoly;
-                    SdrObjectUniquePtr pTemporaryConvertResultObject(rSdrObjCustomShape.DoConvertToPolyObj(true, true));
+                    SdrObjectUniquePtr pTemporaryConvertResultObject(pSdrObjCustomShape->DoConvertToPolyObj(true, true));
                     SdrPathObj* pSdrPathObj(dynamic_cast< SdrPathObj* >(pTemporaryConvertResultObject.get()));
 
                     if(pSdrPathObj)
diff --git a/forms/source/richtext/rtattributehandler.cxx b/forms/source/richtext/rtattributehandler.cxx
index e1a9c231d71a..804d6bb2d42d 100644
--- a/forms/source/richtext/rtattributehandler.cxx
+++ b/forms/source/richtext/rtattributehandler.cxx
@@ -419,8 +419,8 @@ namespace frm
     AttributeCheckState BooleanHandler::implGetCheckState( const SfxPoolItem& _rItem ) const
     {
         OSL_ENSURE( dynamic_cast<const SfxBoolItem*>( &_rItem) !=  nullptr, "BooleanHandler::implGetCheckState: invalid item!" );
-        if ( dynamic_cast<const SfxBoolItem*>( &_rItem) !=  nullptr )
-            return static_cast< const SfxBoolItem& >( _rItem ).GetValue() ? eChecked : eUnchecked;
+        if ( auto pBoolItem = dynamic_cast<const SfxBoolItem*>( &_rItem) )
+            return pBoolItem->GetValue() ? eChecked : eUnchecked;
 
         return eIndetermined;
     }
diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index aae5ed633d85..58246d08f231 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -2141,12 +2141,13 @@ ShapeExport& ShapeExport::WriteOLE2Shape( const Reference< XShape >& xShape )
     SdrObject* pSdrOLE2( GetSdrObjectFromXShape( xShape ) );
     // The spec doesn't allow <p:pic> here, but PowerPoint requires it.
     bool bEcma = mpFB->getVersion() == oox::core::ECMA_DIALECT;
-    if (dynamic_cast<const SdrOle2Obj*>( pSdrOLE2) && bEcma)
-    {
-        const Graphic* pGraphic = static_cast<SdrOle2Obj*>(pSdrOLE2)->GetGraphic();
-        if (pGraphic)
-            WriteGraphicObjectShapePart( xShape, pGraphic );
-    }
+    if (bEcma)
+        if (auto pOle2Obj = dynamic_cast<SdrOle2Obj*>(pSdrOLE2))
+        {
+            const Graphic* pGraphic = pOle2Obj->GetGraphic();
+            if (pGraphic)
+                WriteGraphicObjectShapePart( xShape, pGraphic );
+        }
 
     mpFS->endElementNS( mnXmlNamespace, XML_oleObj );
 
diff --git a/reportdesign/source/ui/misc/UITools.cxx b/reportdesign/source/ui/misc/UITools.cxx
index c4a0a2080e29..60b0b48bdb6a 100644
--- a/reportdesign/source/ui/misc/UITools.cxx
+++ b/reportdesign/source/ui/misc/UITools.cxx
@@ -457,87 +457,63 @@ namespace
         lcl_pushBack( _out_rProperties, "FontComplex", uno::makeAny( aAwtFont ) );
 
         // properties which cannot be represented in an AWT font need to be preserved directly
-        if ( SfxItemState::SET == _rItemSet.GetItemState( ITEMID_SHADOWED,true,&pItem) && dynamic_cast< const SvxShadowedItem *>( pItem ) !=  nullptr)
-        {
-            const SvxShadowedItem* pFontItem = static_cast<const SvxShadowedItem*>(pItem);
-            lcl_pushBack( _out_rProperties, PROPERTY_CHARSHADOWED, uno::makeAny( pFontItem->GetValue() ) );
-        }
-        if ( SfxItemState::SET == _rItemSet.GetItemState( ITEMID_CONTOUR,true,&pItem) && dynamic_cast< const SvxContourItem *>( pItem ) !=  nullptr)
-        {
-            const SvxContourItem* pFontItem = static_cast<const SvxContourItem*>(pItem);
-            lcl_pushBack( _out_rProperties, PROPERTY_CHARCONTOURED, uno::makeAny( pFontItem->GetValue() ) );
-        }
-        if ( SfxItemState::SET == _rItemSet.GetItemState( ITEMID_UNDERLINE,true,&pItem) && dynamic_cast< const SvxUnderlineItem *>( pItem ) !=  nullptr)
-        {
-            const SvxUnderlineItem* pFontItem = static_cast<const SvxUnderlineItem*>(pItem);
-            lcl_pushBack( _out_rProperties, PROPERTY_CHARUNDERLINECOLOR, uno::makeAny( pFontItem->GetColor() ) );
-        }
-        if ( SfxItemState::SET == _rItemSet.GetItemState( ITEMID_HORJUSTIFY,true,&pItem) && dynamic_cast< const SvxHorJustifyItem *>( pItem ) !=  nullptr)
-        {
-            const SvxHorJustifyItem* pJustifyItem = static_cast<const SvxHorJustifyItem*>(pItem);
-            uno::Any aValue;
-            pJustifyItem->QueryValue(aValue,MID_HORJUST_ADJUST);
-            lcl_pushBack( _out_rProperties, PROPERTY_PARAADJUST, aValue );
-        }
-        if ( SfxItemState::SET == _rItemSet.GetItemState( ITEMID_VERJUSTIFY,true,&pItem) && dynamic_cast< const SvxVerJustifyItem *>( pItem ) !=  nullptr)
-        {
-            const SvxVerJustifyItem* pJustifyItem = static_cast<const SvxVerJustifyItem*>(pItem);
-            uno::Any aValue;
-            pJustifyItem->QueryValue(aValue,MID_HORJUST_ADJUST);
-            lcl_pushBack( _out_rProperties, PROPERTY_VERTICALALIGN, aValue );
-        }
-        if ( SfxItemState::SET == _rItemSet.GetItemState( ITEMID_CHARRELIEF,true,&pItem) && dynamic_cast< const SvxCharReliefItem *>( pItem ) !=  nullptr)
-        {
-            const SvxCharReliefItem* pFontItem = static_cast<const SvxCharReliefItem*>(pItem);
-            lcl_pushBack( _out_rProperties, PROPERTY_CHARRELIEF, uno::makeAny( static_cast< sal_Int16 >( pFontItem->GetEnumValue() ) ) );
-        }
-        if ( SfxItemState::SET == _rItemSet.GetItemState( ITEMID_CHARHIDDEN,true,&pItem) && dynamic_cast< const SvxCharHiddenItem *>( pItem ) !=  nullptr)
-        {
-            const SvxCharHiddenItem* pFontItem = static_cast<const SvxCharHiddenItem*>(pItem);
-            lcl_pushBack( _out_rProperties, PROPERTY_CHARHIDDEN, uno::makeAny( pFontItem->GetValue() ) );
-        }
-        if ( SfxItemState::SET == _rItemSet.GetItemState( ITEMID_AUTOKERN,true,&pItem) && dynamic_cast< const SvxAutoKernItem *>( pItem ) !=  nullptr)
-        {
-            const SvxAutoKernItem* pFontItem = static_cast<const SvxAutoKernItem*>(pItem);
-            lcl_pushBack( _out_rProperties, PROPERTY_CHARAUTOKERNING, uno::makeAny( pFontItem->GetValue() ) );
-        }
-        if ( SfxItemState::SET == _rItemSet.GetItemState( ITEMID_BRUSH,true,&pItem) && dynamic_cast< const SvxBrushItem *>( pItem ) !=  nullptr)
-        {
-            const SvxBrushItem* pFontItem = static_cast<const SvxBrushItem*>(pItem);
-            lcl_pushBack( _out_rProperties, PROPERTY_CONTROLBACKGROUND, uno::makeAny( pFontItem->GetColor() ) );
-        }
-        if ( SfxItemState::SET == _rItemSet.GetItemState( ITEMID_BLINK,true,&pItem) && dynamic_cast< const SvxBlinkItem *>( pItem ) !=  nullptr)
-        {
-            const SvxBlinkItem* pFontItem = static_cast<const SvxBlinkItem*>(pItem);
-            lcl_pushBack( _out_rProperties, PROPERTY_CHARFLASH, uno::makeAny( pFontItem->GetValue() ) );
-        }
-        if ( SfxItemState::SET == _rItemSet.GetItemState( ITEMID_EMPHASISMARK,true,&pItem) && dynamic_cast< const SvxEmphasisMarkItem *>( pItem ) !=  nullptr)
-        {
-            const SvxEmphasisMarkItem* pFontItem = static_cast<const SvxEmphasisMarkItem*>(pItem);
-            lcl_pushBack( _out_rProperties, PROPERTY_CHAREMPHASIS, uno::makeAny( static_cast< sal_Int16 >( pFontItem->GetEmphasisMark() ) ) );
-        }
-        if ( SfxItemState::SET == _rItemSet.GetItemState( ITEMID_TWOLINES,true,&pItem) && dynamic_cast< const SvxTwoLinesItem *>( pItem ) !=  nullptr)
-        {
-            const SvxTwoLinesItem* pFontItem = static_cast<const SvxTwoLinesItem*>(pItem);
-            lcl_pushBack( _out_rProperties, PROPERTY_CHARCOMBINEISON, uno::makeAny( pFontItem->GetValue() ) );
-            lcl_pushBack( _out_rProperties, PROPERTY_CHARCOMBINEPREFIX, uno::makeAny( OUString( pFontItem->GetStartBracket() ) ) );
-            lcl_pushBack( _out_rProperties, PROPERTY_CHARCOMBINESUFFIX, uno::makeAny( OUString( pFontItem->GetEndBracket() ) ) );
-        }
-        if ( SfxItemState::SET == _rItemSet.GetItemState( ITEMID_COLOR,true,&pItem) && dynamic_cast< const SvxColorItem *>( pItem ) !=  nullptr)
-        {
-            const SvxColorItem* pFontItem = static_cast<const SvxColorItem*>(pItem);
-            lcl_pushBack( _out_rProperties, PROPERTY_CHARCOLOR, uno::makeAny( pFontItem->GetValue() ) );
-        }
-        if ( SfxItemState::SET == _rItemSet.GetItemState( ITEMID_KERNING,true,&pItem) && dynamic_cast< const SvxKerningItem *>( pItem ) !=  nullptr)
-        {
-            const SvxKerningItem* pFontItem = static_cast<const SvxKerningItem*>(pItem);
-            lcl_pushBack( _out_rProperties, PROPERTY_CHARKERNING, uno::makeAny( pFontItem->GetValue() ) );
-        }
-        if ( SfxItemState::SET == _rItemSet.GetItemState( ITEMID_CASEMAP,true,&pItem) && dynamic_cast< const SvxCaseMapItem *>( pItem ) !=  nullptr)
-        {
-            const SvxCaseMapItem* pFontItem = static_cast<const SvxCaseMapItem*>(pItem);
-            lcl_pushBack( _out_rProperties, PROPERTY_CHARCASEMAP, uno::makeAny( pFontItem->GetEnumValue() ) );
-        }
+        if ( SfxItemState::SET == _rItemSet.GetItemState( ITEMID_SHADOWED,true,&pItem) )
+            if (auto pShadowedItem = dynamic_cast<const SvxShadowedItem *>( pItem ))
+                lcl_pushBack( _out_rProperties, PROPERTY_CHARSHADOWED, uno::makeAny( pShadowedItem->GetValue() ) );
+        if ( SfxItemState::SET == _rItemSet.GetItemState( ITEMID_CONTOUR,true,&pItem) )
+            if (auto pContourItem = dynamic_cast<const SvxContourItem *>( pItem ))
+                lcl_pushBack( _out_rProperties, PROPERTY_CHARCONTOURED, uno::makeAny( pContourItem->GetValue() ) );
+        if ( SfxItemState::SET == _rItemSet.GetItemState( ITEMID_UNDERLINE,true,&pItem) )
+            if (auto pUnderlineItem = dynamic_cast< const SvxUnderlineItem *>( pItem ))
+                lcl_pushBack( _out_rProperties, PROPERTY_CHARUNDERLINECOLOR, uno::makeAny( pUnderlineItem->GetColor() ) );
+        if ( SfxItemState::SET == _rItemSet.GetItemState( ITEMID_HORJUSTIFY,true,&pItem) )
+            if (auto pJustifyItem = dynamic_cast< const SvxHorJustifyItem *>( pItem ))
+            {
+                uno::Any aValue;
+                pJustifyItem->QueryValue(aValue,MID_HORJUST_ADJUST);
+                lcl_pushBack( _out_rProperties, PROPERTY_PARAADJUST, aValue );
+            }
+        if ( SfxItemState::SET == _rItemSet.GetItemState( ITEMID_VERJUSTIFY,true,&pItem) )
+            if (auto pJustifyItem = dynamic_cast< const SvxVerJustifyItem *>( pItem ))
+            {
+                uno::Any aValue;
+                pJustifyItem->QueryValue(aValue,MID_HORJUST_ADJUST);
+                lcl_pushBack( _out_rProperties, PROPERTY_VERTICALALIGN, aValue );
+            }
+        if ( SfxItemState::SET == _rItemSet.GetItemState( ITEMID_CHARRELIEF,true,&pItem) )
+            if (auto pReliefItem = dynamic_cast< const SvxCharReliefItem *>( pItem ))
+                lcl_pushBack( _out_rProperties, PROPERTY_CHARRELIEF, uno::makeAny( static_cast< sal_Int16 >( pReliefItem->GetEnumValue() ) ) );
+        if ( SfxItemState::SET == _rItemSet.GetItemState( ITEMID_CHARHIDDEN,true,&pItem) )
+            if (auto pHiddenItem = dynamic_cast< const SvxCharHiddenItem *>( pItem ))
+                lcl_pushBack( _out_rProperties, PROPERTY_CHARHIDDEN, uno::makeAny( pHiddenItem->GetValue() ) );
+        if ( SfxItemState::SET == _rItemSet.GetItemState( ITEMID_AUTOKERN,true,&pItem) )
+            if (auto pKernItem = dynamic_cast< const SvxAutoKernItem *>( pItem ))
+                lcl_pushBack( _out_rProperties, PROPERTY_CHARAUTOKERNING, uno::makeAny( pKernItem->GetValue() ) );
+        if ( SfxItemState::SET == _rItemSet.GetItemState( ITEMID_BRUSH,true,&pItem) )
+            if (auto pBrushItem = dynamic_cast< const SvxBrushItem *>( pItem ))
+                lcl_pushBack( _out_rProperties, PROPERTY_CONTROLBACKGROUND, uno::makeAny( pBrushItem->GetColor() ) );
+        if ( SfxItemState::SET == _rItemSet.GetItemState( ITEMID_BLINK,true,&pItem) )
+            if (auto pBlinkItem = dynamic_cast< const SvxBlinkItem *>( pItem ))
+                lcl_pushBack( _out_rProperties, PROPERTY_CHARFLASH, uno::makeAny( pBlinkItem->GetValue() ) );
+        if ( SfxItemState::SET == _rItemSet.GetItemState( ITEMID_EMPHASISMARK,true,&pItem) )
+            if (auto pMarkItem = dynamic_cast< const SvxEmphasisMarkItem *>( pItem ))
+                lcl_pushBack( _out_rProperties, PROPERTY_CHAREMPHASIS, uno::makeAny( static_cast< sal_Int16 >( pMarkItem->GetEmphasisMark() ) ) );
+        if ( SfxItemState::SET == _rItemSet.GetItemState( ITEMID_TWOLINES,true,&pItem) )
+            if (auto pLinesItem = dynamic_cast< const SvxTwoLinesItem *>( pItem ))
+            {
+                lcl_pushBack( _out_rProperties, PROPERTY_CHARCOMBINEISON, uno::makeAny( pLinesItem->GetValue() ) );
+                lcl_pushBack( _out_rProperties, PROPERTY_CHARCOMBINEPREFIX, uno::makeAny( OUString( pLinesItem->GetStartBracket() ) ) );
+                lcl_pushBack( _out_rProperties, PROPERTY_CHARCOMBINESUFFIX, uno::makeAny( OUString( pLinesItem->GetEndBracket() ) ) );
+            }
+        if ( SfxItemState::SET == _rItemSet.GetItemState( ITEMID_COLOR,true,&pItem) )
+            if (auto pColorItem = dynamic_cast< const SvxColorItem *>( pItem ))
+                lcl_pushBack( _out_rProperties, PROPERTY_CHARCOLOR, uno::makeAny( pColorItem->GetValue() ) );
+        if ( SfxItemState::SET == _rItemSet.GetItemState( ITEMID_KERNING,true,&pItem) )
+            if (auto pKernItem = dynamic_cast< const SvxKerningItem *>( pItem ))
+                lcl_pushBack( _out_rProperties, PROPERTY_CHARKERNING, uno::makeAny( pKernItem->GetValue() ) );
+        if ( SfxItemState::SET == _rItemSet.GetItemState( ITEMID_CASEMAP,true,&pItem) )
+            if (auto pCaseMapItem = dynamic_cast< const SvxCaseMapItem *>( pItem ))
+                lcl_pushBack( _out_rProperties, PROPERTY_CHARCASEMAP, uno::makeAny( pCaseMapItem->GetEnumValue() ) );
         struct Items {
                 sal_uInt16 nWhich;
                 OUString sPropertyName;
@@ -548,19 +524,19 @@ namespace
         };
         for(const auto & k : pItems)
         {
-            if ( SfxItemState::SET == _rItemSet.GetItemState( k.nWhich,true,&pItem) && dynamic_cast< const SvxLanguageItem *>( pItem ) !=  nullptr)
+            if ( SfxItemState::SET == _rItemSet.GetItemState( k.nWhich,true,&pItem) )
+                if (auto pLanguageItem = dynamic_cast< const SvxLanguageItem *>( pItem ))
+                {
+                    lang::Locale aCharLocale( LanguageTag( pLanguageItem->GetLanguage()).getLocale());
+                    lcl_pushBack( _out_rProperties, k.sPropertyName, uno::makeAny( aCharLocale ) );
+                }
+        }
+        if ( SfxItemState::SET == _rItemSet.GetItemState( ITEMID_ESCAPEMENT,true,&pItem) )
+            if (auto pEscapementItem = dynamic_cast< const SvxEscapementItem *>( pItem ))
             {
-                const SvxLanguageItem* pFontItem = static_cast<const SvxLanguageItem*>(pItem);
-                lang::Locale aCharLocale( LanguageTag( pFontItem->GetLanguage()).getLocale());
-                lcl_pushBack( _out_rProperties, k.sPropertyName, uno::makeAny( aCharLocale ) );
+                lcl_pushBack( _out_rProperties, PROPERTY_CHARESCAPEMENT, uno::makeAny( pEscapementItem->GetEsc() ) );
+                lcl_pushBack( _out_rProperties, PROPERTY_CHARESCAPEMENTHEIGHT, uno::makeAny(static_cast<sal_Int8>(pEscapementItem->GetProportionalHeight())) );
             }
-        }
-        if ( SfxItemState::SET == _rItemSet.GetItemState( ITEMID_ESCAPEMENT,true,&pItem) && dynamic_cast< const SvxEscapementItem *>( pItem ) !=  nullptr)
-        {
-            const SvxEscapementItem* pFontItem = static_cast<const SvxEscapementItem*>(pItem);
-            lcl_pushBack( _out_rProperties, PROPERTY_CHARESCAPEMENT, uno::makeAny( pFontItem->GetEsc() ) );
-            lcl_pushBack( _out_rProperties, PROPERTY_CHARESCAPEMENTHEIGHT, uno::makeAny(static_cast<sal_Int8>(pFontItem->GetProportionalHeight())) );
-        }
     }
 
 
diff --git a/sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx b/sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx
index 553180e21e7a..c2017c1f5f5f 100644
--- a/sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx
+++ b/sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx
@@ -407,23 +407,22 @@ void ScAccessibleSpreadsheet::VisAreaChanged()
 
 void ScAccessibleSpreadsheet::Notify( SfxBroadcaster& rBC, 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);
-        if (rRef.GetMode() == URM_INSDEL && rRef.GetDz() == 0) //test whether table is inserted or deleted
+        if (pRefHint->GetMode() == URM_INSDEL && pRefHint->GetDz() == 0) //test whether table is inserted or deleted
         {
-            if (((rRef.GetRange().aStart.Col() == maRange.aStart.Col()) &&
-                (rRef.GetRange().aEnd.Col() == maRange.aEnd.Col())) ||
-                ((rRef.GetRange().aStart.Row() == maRange.aStart.Row()) &&
-                (rRef.GetRange().aEnd.Row() == maRange.aEnd.Row())))
+            if (((pRefHint->GetRange().aStart.Col() == maRange.aStart.Col()) &&
+                (pRefHint->GetRange().aEnd.Col() == maRange.aEnd.Col())) ||
+                ((pRefHint->GetRange().aStart.Row() == maRange.aStart.Row()) &&
+                (pRefHint->GetRange().aEnd.Row() == maRange.aEnd.Row())))
             {
                 // ignore next SfxHintId::ScDataChanged notification
                 mbDelIns = true;
 
                 sal_Int16 nId(0);
-                SCCOL nX(rRef.GetDx());
-                SCROW nY(rRef.GetDy());
-                ScRange aRange(rRef.GetRange());
+                SCCOL nX(pRefHint->GetDx());
+                SCROW nY(pRefHint->GetDy());
+                ScRange aRange(pRefHint->GetRange());
                 if ((nX < 0) || (nY < 0))
                 {
                     OSL_ENSURE(!((nX < 0) && (nY < 0)), "should not be possible to remove row and column at the same time");
@@ -450,10 +449,10 @@ void ScAccessibleSpreadsheet::Notify( SfxBroadcaster& rBC, const SfxHint& rHint
                     OSL_FAIL("is it a deletion or an insertion?");
                 }
 
-                CommitTableModelChange(rRef.GetRange().aStart.Row(),
-                    rRef.GetRange().aStart.Col(),
-                    rRef.GetRange().aStart.Row() + nY,
-                    rRef.GetRange().aStart.Col() + nX, nId);
+                CommitTableModelChange(pRefHint->GetRange().aStart.Row(),
+                    pRefHint->GetRange().aStart.Col(),
+                    pRefHint->GetRange().aStart.Row() + nY,
+                    pRefHint->GetRange().aStart.Col() + nX, nId);
 
                 AccessibleEventObject aEvent;
                 aEvent.EventId = AccessibleEventId::ACTIVE_DESCENDANT_CHANGED;
diff --git a/sc/source/ui/app/scmod.cxx b/sc/source/ui/app/scmod.cxx
index b268e9d6d47e..84b620fa2c19 100644
--- a/sc/source/ui/app/scmod.cxx
+++ b/sc/source/ui/app/scmod.cxx
@@ -1264,9 +1264,8 @@ void ScModule::ModifyOptions( const SfxItemSet& rOptSet )
     SfxObjectShell* pObjSh = SfxObjectShell::GetFirst();
     while ( pObjSh )
     {
-        if ( dynamic_cast<const ScDocShell *>(pObjSh) != nullptr )
+        if ( auto pOneDocSh = dynamic_cast<ScDocShell *>(pObjSh) )
         {
-            ScDocShell* pOneDocSh = static_cast<ScDocShell*>(pObjSh);
             pOneDocSh->CalcOutputFactor();
             SCTAB nTabCount = pOneDocSh->GetDocument().GetTableCount();
             for (SCTAB nTab=0; nTab<nTabCount; nTab++)
diff --git a/sc/source/ui/drawfunc/drtxtob.cxx b/sc/source/ui/drawfunc/drtxtob.cxx
index 6d3ae53c2bcc..117e47a5bd02 100644
--- a/sc/source/ui/drawfunc/drtxtob.cxx
+++ b/sc/source/ui/drawfunc/drtxtob.cxx
@@ -170,12 +170,9 @@ void ScDrawTextObjectBar::Execute( SfxRequest &rReq )
             {
                 SotClipboardFormatId nFormat = SotClipboardFormatId::NONE;
                 const SfxPoolItem* pItem;
-                if ( pReqArgs &&
-                     pReqArgs->GetItemState(nSlot, true, &pItem) == SfxItemState::SET &&
-                     dynamic_cast<const SfxUInt32Item*>( pItem) !=  nullptr )
-                {
-                    nFormat = static_cast<SotClipboardFormatId>(static_cast<const SfxUInt32Item*>(pItem)->GetValue());
-                }
+                if ( pReqArgs && pReqArgs->GetItemState(nSlot, true, &pItem) == SfxItemState::SET )
+                    if (auto pIntItem = dynamic_cast<const SfxUInt32Item*>( pItem))
+                        nFormat = static_cast<SotClipboardFormatId>(pIntItem->GetValue());
 
                 if ( nFormat != SotClipboardFormatId::NONE )
                 {
diff --git a/sc/source/ui/undo/undoblk.cxx b/sc/source/ui/undo/undoblk.cxx
index f7347ecc1c2f..2acc26313b9a 100644
--- a/sc/source/ui/undo/undoblk.cxx
+++ b/sc/source/ui/undo/undoblk.cxx
@@ -802,8 +802,8 @@ void ScUndoDeleteMulti::Redo()
 void ScUndoDeleteMulti::Repeat(SfxRepeatTarget& rTarget)
 {
     // if single selection
-    if (dynamic_cast<const ScTabViewTarget*>( &rTarget) !=  nullptr)
-        static_cast<ScTabViewTarget&>(rTarget).GetViewShell()->DeleteCells( DelCellCmd::Rows );
+    if (auto pTabViewTarget = dynamic_cast<ScTabViewTarget*>( &rTarget))
+        pTabViewTarget->GetViewShell()->DeleteCells( DelCellCmd::Rows );
 }
 
 bool ScUndoDeleteMulti::CanRepeat(SfxRepeatTarget& rTarget) const
@@ -1535,8 +1535,8 @@ void ScUndoListNames::Redo()
 
 void ScUndoListNames::Repeat(SfxRepeatTarget& rTarget)
 {
-    if (dynamic_cast<const ScTabViewTarget*>( &rTarget) !=  nullptr)
-        static_cast<ScTabViewTarget&>(rTarget).GetViewShell()->InsertNameList();
+    if (auto pTabViewTarget = dynamic_cast<ScTabViewTarget*>(&rTarget))
+        pTabViewTarget->GetViewShell()->InsertNameList();
 }
 
 bool ScUndoListNames::CanRepeat(SfxRepeatTarget& rTarget) const
@@ -1948,11 +1948,11 @@ void ScUndoEnterMatrix::Redo()
 
 void ScUndoEnterMatrix::Repeat(SfxRepeatTarget& rTarget)
 {
-    if (dynamic_cast<const ScTabViewTarget*>( &rTarget) !=  nullptr)
+    if (auto pTabViewTarget = dynamic_cast<ScTabViewTarget*>(&rTarget))
     {
         OUString aTemp = aFormula;
         ScDocument& rDoc = pDocShell->GetDocument();
-        static_cast<ScTabViewTarget&>(rTarget).GetViewShell()->EnterMatrix(aTemp, rDoc.GetGrammar());
+        pTabViewTarget->GetViewShell()->EnterMatrix(aTemp, rDoc.GetGrammar());
     }
 }
 
diff --git a/sc/source/ui/unoobj/PivotTableDataProvider.cxx b/sc/source/ui/unoobj/PivotTableDataProvider.cxx
index 8288be2e530b..4a459f06437e 100644
--- a/sc/source/ui/unoobj/PivotTableDataProvider.cxx
+++ b/sc/source/ui/unoobj/PivotTableDataProvider.cxx
@@ -158,12 +158,11 @@ void PivotTableDataProvider::Notify(SfxBroadcaster& /*rBroadcaster*/, const SfxH
     {
         m_pDocument = nullptr;
     }
-    else if (dynamic_cast<const ScDataPilotModifiedHint*>(&rHint))
+    else if (m_pDocument)
     {
-        if (m_pDocument)
+        if (auto pDataPilotHint = dynamic_cast<const ScDataPilotModifiedHint*>(&rHint))
         {
-            OUString sPivotTableName = static_cast<const ScDataPilotModifiedHint&>(rHint).GetName();
-            if (sPivotTableName == m_sPivotTableName)
+            if (pDataPilotHint->GetName() == m_sPivotTableName)
             {
                 m_bNeedsUpdate = true;
                 for (uno::Reference<util::XModifyListener> const & xListener : m_aValueListeners)
diff --git a/sc/source/ui/unoobj/dapiuno.cxx b/sc/source/ui/unoobj/dapiuno.cxx
index d848b05ceb2f..3840745882ac 100644
--- a/sc/source/ui/unoobj/dapiuno.cxx
+++ b/sc/source/ui/unoobj/dapiuno.cxx
@@ -1235,18 +1235,17 @@ void SAL_CALL ScDataPilotTableObj::removeModifyListener( const uno::Reference<ut
 
 void ScDataPilotTableObj::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
 {
-    if ( dynamic_cast<const ScDataPilotModifiedHint*>(&rHint) &&
-         static_cast<const ScDataPilotModifiedHint&>(rHint).GetName() == aName )
+    if ( auto pDataPilotHint = dynamic_cast<const ScDataPilotModifiedHint*>(&rHint) )
     {
-        Refreshed_Impl();
+        if (pDataPilotHint->GetName() == aName)
+            Refreshed_Impl();
     }
-    else if ( dynamic_cast<const ScUpdateRefHint*>(&rHint) )
+    else if ( auto pRefHint = dynamic_cast<const ScUpdateRefHint*>(&rHint) )
     {
         ScRange aRange( 0, 0, nTab );
         ScRangeList aRanges( aRange );
-        const ScUpdateRefHint& rRef = static_cast< const ScUpdateRefHint& >( rHint );
-        if ( aRanges.UpdateReference( rRef.GetMode(), &GetDocShell()->GetDocument(), rRef.GetRange(),
-                 rRef.GetDx(), rRef.GetDy(), rRef.GetDz() ) &&
+        if ( aRanges.UpdateReference( pRefHint->GetMode(), &GetDocShell()->GetDocument(), pRefHint->GetRange(),
+                 pRefHint->GetDx(), pRefHint->GetDy(), pRefHint->GetDz() ) &&
              aRanges.size() == 1 )
         {
             nTab = aRanges.front().aStart.Tab();
diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx
index f38184ac3b1b..75f2e670ae91 100644
--- a/sc/source/ui/view/cellsh1.cxx
+++ b/sc/source/ui/view/cellsh1.cxx
@@ -1305,12 +1305,9 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
 
                 SotClipboardFormatId nFormat = SotClipboardFormatId::NONE;
                 const SfxPoolItem* pItem;
-                if ( pReqArgs &&
-                     pReqArgs->GetItemState(nSlot, true, &pItem) == SfxItemState::SET &&
-                     dynamic_cast<const SfxUInt32Item*>( pItem) !=  nullptr )
-                {
-                    nFormat = static_cast<SotClipboardFormatId>(static_cast<const SfxUInt32Item*>(pItem)->GetValue());
-                }
+                if ( pReqArgs && pReqArgs->GetItemState(nSlot, true, &pItem) == SfxItemState::SET )
+                    if (auto pIntItem = dynamic_cast<const SfxUInt32Item*>(pItem) )
+                        nFormat = static_cast<SotClipboardFormatId>(pIntItem->GetValue());
 
                 if ( nFormat != SotClipboardFormatId::NONE )
                 {
diff --git a/sc/source/ui/view/editsh.cxx b/sc/source/ui/view/editsh.cxx
index 619001a27d8c..4b1b414f329e 100644
--- a/sc/source/ui/view/editsh.cxx
+++ b/sc/source/ui/view/editsh.cxx
@@ -246,12 +246,9 @@ void ScEditShell::Execute( SfxRequest& rReq )
             {
                 SotClipboardFormatId nFormat = SotClipboardFormatId::NONE;
                 const SfxPoolItem* pItem;
-                if ( pReqArgs &&
-                     pReqArgs->GetItemState(nSlot, true, &pItem) == SfxItemState::SET &&
-                     dynamic_cast<const SfxUInt32Item*>( pItem) !=  nullptr )
-                {
-                    nFormat = static_cast<SotClipboardFormatId>(static_cast<const SfxUInt32Item*>(pItem)->GetValue());
-                }
+                if ( pReqArgs && pReqArgs->GetItemState(nSlot, true, &pItem) == SfxItemState::SET )
+                    if (auto pIntItem = dynamic_cast<const SfxUInt32Item*>( pItem))
+                        nFormat = static_cast<SotClipboardFormatId>(pIntItem->GetValue());
 
                 if ( nFormat != SotClipboardFormatId::NONE )
                 {
diff --git a/sc/source/ui/view/formatsh.cxx b/sc/source/ui/view/formatsh.cxx
index 80a1dd68378c..8e6b9d26a5be 100644
--- a/sc/source/ui/view/formatsh.cxx
+++ b/sc/source/ui/view/formatsh.cxx
@@ -1474,12 +1474,11 @@ void ScFormatShell::ExecuteTextAttr( SfxRequest& rReq )
                             pTabViewShell->ApplyAttr( rUnderline );
                             pNewSet->Put( rUnderline,rUnderline.Which() );
                         }
-                        else if ( dynamic_cast<const SvxTextLineItem*>( &rUnderline) !=  nullptr )
+                        else if ( auto pTextLineItem = dynamic_cast<const SvxTextLineItem*>( &rUnderline) )
                         {
                             // #i106580# also allow SvxTextLineItem (base class of SvxUnderlineItem)
-                            const SvxTextLineItem& rTextLineItem = static_cast<const SvxTextLineItem&>(rUnderline);
-                            SvxUnderlineItem aNewItem( rTextLineItem.GetLineStyle(), rTextLineItem.Which() );
-                            aNewItem.SetColor( rTextLineItem.GetColor() );
+                            SvxUnderlineItem aNewItem( pTextLineItem->GetLineStyle(), pTextLineItem->Which() );
+                            aNewItem.SetColor( pTextLineItem->GetColor() );
                             pTabViewShell->ApplyAttr( aNewItem );
                             pNewSet->Put( aNewItem, aNewItem.Which() );
                         }
diff --git a/sc/source/ui/view/tabvwsh2.cxx b/sc/source/ui/view/tabvwsh2.cxx
index 83f47834c0b6..1550b733c522 100644
--- a/sc/source/ui/view/tabvwsh2.cxx
+++ b/sc/source/ui/view/tabvwsh2.cxx
@@ -106,8 +106,9 @@ void ScTabViewShell::ExecDraw(SfxRequest& rReq)
     if ( pArgs )
     {
         const SfxPoolItem* pItem;
-        if ( pArgs->GetItemState( nNewId, true, &pItem ) == SfxItemState::SET && dynamic_cast<const SfxStringItem*>( pItem) !=  nullptr )
-            sStringItemValue = static_cast<const SfxStringItem*>(pItem)->GetValue();
+        if ( pArgs->GetItemState( nNewId, true, &pItem ) == SfxItemState::SET )
+            if (auto pStringItem = dynamic_cast<const SfxStringItem*>(pItem) )
+                sStringItemValue = pStringItem->GetValue();
     }
     bool bSwitchCustom = ( !sStringItemValue.isEmpty() && !sDrawCustom.isEmpty() && sStringItemValue != sDrawCustom );
 
diff --git a/sc/source/ui/view/tabvwsh5.cxx b/sc/source/ui/view/tabvwsh5.cxx
index c8e5f31a58f1..e8a4c857ecc7 100644
--- a/sc/source/ui/view/tabvwsh5.cxx
+++ b/sc/source/ui/view/tabvwsh5.cxx
@@ -74,20 +74,19 @@ void ScTabViewShell::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
             HideNoteMarker();
         }
     }
-    else if (dynamic_cast<const ScEditViewHint*>(&rHint))                 // create Edit-View
+    else if (auto pEditViewHint = dynamic_cast<const ScEditViewHint*>(&rHint))                 // create Edit-View
     {
         //  ScEditViewHint is only received at active view
 
-        const ScEditViewHint* pHint = static_cast<const ScEditViewHint*>(&rHint);
         SCTAB nTab = GetViewData().GetTabNo();
-        if ( pHint->GetTab() == nTab )
+        if ( pEditViewHint->GetTab() == nTab )
         {
-            SCCOL nCol = pHint->GetCol();
-            SCROW nRow = pHint->GetRow();
+            SCCOL nCol = pEditViewHint->GetCol();
+            SCROW nRow = pEditViewHint->GetRow();
             {
                 HideNoteMarker();
 
-                MakeEditView( pHint->GetEngine(), nCol, nRow );
+                MakeEditView( pEditViewHint->GetEngine(), nCol, nRow );
 
                 StopEditShell();                    // shouldn't be set
 
diff --git a/sd/source/core/drawdoc4.cxx b/sd/source/core/drawdoc4.cxx
index f8cb995a5941..48ad50b89ced 100644
--- a/sd/source/core/drawdoc4.cxx
+++ b/sd/source/core/drawdoc4.cxx
@@ -927,11 +927,10 @@ IMPL_LINK_NOARG(SdDrawDocument, OnlineSpellingHdl, Timer *, void)
                 {
                     SdrObject* pSubObj = aGroupIter.Next();
 
-                    if (pSubObj->GetOutlinerParaObject() && dynamic_cast< SdrTextObj *>( pSubObj ) !=  nullptr)
-                    {
-                        // Found a text object in a group object
-                        SpellObject(static_cast<SdrTextObj*>(pSubObj));
-                    }
+                    if (pSubObj->GetOutlinerParaObject())
+                        if (auto pTextObj = dynamic_cast< SdrTextObj *>( pSubObj ))
+                            // Found a text object in a group object
+                            SpellObject(pTextObj);
                 }
             }
         }
@@ -1050,13 +1049,14 @@ void SdDrawDocument::ImpOnlineSpellCallback(SpellCallbackInfo const * pInfo, Sdr
         // restart when add to dictionary takes place, too.
         || nCommand == SpellCallbackCommand::ADDTODICTIONARY)
     {
-        if(pOutl && dynamic_cast< const SdrTextObj *>( pObj ))
-        {
-            bool bModified(IsChanged());
-            static_cast<SdrTextObj*>(pObj)->SetOutlinerParaObject(pOutl->CreateParaObject());
-            SetChanged(bModified);
-            pObj->BroadcastObjectChange();
-        }
+        if(pOutl)
+            if (auto pTextObj = dynamic_cast<SdrTextObj *>( pObj ))
+            {
+                bool bModified(IsChanged());
+                pTextObj->SetOutlinerParaObject(pOutl->CreateParaObject());
+                SetChanged(bModified);
+                pObj->BroadcastObjectChange();
+            }
 
         mpOnlineSearchItem.reset(new SvxSearchItem( SID_SEARCH_ITEM ) );
         mpOnlineSearchItem->SetSearchString(pInfo->aWord);
diff --git a/sd/source/core/sdpage.cxx b/sd/source/core/sdpage.cxx
index bc876afdac0a..800b69808639 100644
--- a/sd/source/core/sdpage.cxx
+++ b/sd/source/core/sdpage.cxx
@@ -486,20 +486,21 @@ SdrObject* SdPage::CreatePresObj(PresObjKind eObjKind, bool bVertical, const ::t
         }
 
         OUString aString = GetPresObjText(eObjKind);
-        if( (!aString.isEmpty() || bForceText) && dynamic_cast< const SdrTextObj *>( pSdrObj ) !=  nullptr )
-        {
-            SdrOutliner* pOutliner = static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetInternalOutliner();
+        if(!aString.isEmpty() || bForceText)
+            if (auto pTextObj = dynamic_cast<SdrTextObj *>( pSdrObj ) )
+            {
+                SdrOutliner* pOutliner = static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetInternalOutliner();
 
-            OutlinerMode nOutlMode = pOutliner->GetMode();
-            pOutliner->Init( OutlinerMode::TextObject );
-            pOutliner->SetStyleSheet( 0, nullptr );
-            pOutliner->SetVertical( bVertical );
+                OutlinerMode nOutlMode = pOutliner->GetMode();
+                pOutliner->Init( OutlinerMode::TextObject );
+                pOutliner->SetStyleSheet( 0, nullptr );
+                pOutliner->SetVertical( bVertical );
 
-            SetObjText( static_cast<SdrTextObj*>(pSdrObj), pOutliner, eObjKind, aString );
+                SetObjText( pTextObj, pOutliner, eObjKind, aString );
 
-            pOutliner->Init( nOutlMode );
-            pOutliner->SetStyleSheet( 0, nullptr );
-        }
+                pOutliner->Init( nOutlMode );
+                pOutliner->SetStyleSheet( 0, nullptr );
+            }
 
         if( (eObjKind == PresObjKind::Header) || (eObjKind == PresObjKind::Footer) || (eObjKind == PresObjKind::SlideNumber) || (eObjKind == PresObjKind::DateTime) )
         {
diff --git a/sd/source/filter/ppt/pptinanimations.cxx b/sd/source/filter/ppt/pptinanimations.cxx
index c833780473ac..02afa719863d 100644
--- a/sd/source/filter/ppt/pptinanimations.cxx
+++ b/sd/source/filter/ppt/pptinanimations.cxx
@@ -2488,10 +2488,12 @@ void AnimationImporter::importTargetElementContainer( const Atom* pAtom, Any& rT
                 case 8: rSubType = ShapeAnimationSubType::ONLY_TEXT; break;
                 case 2: // one paragraph
                 {
-                    if( ((begin == -1) && (end == -1)) || dynamic_cast< SdrTextObj *>( pSdrObject ) ==  nullptr  )
+                    if((begin == -1) && (end == -1))
                         break;
 
-                    SdrTextObj* pTextObj = static_cast< SdrTextObj* >( pSdrObject );
+                    SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( pSdrObject );
+                    if(!pTextObj)
+                        break;
 
                     const OutlinerParaObject* pOPO = pTextObj->GetOutlinerParaObject();
                     if( pOPO == nullptr )
diff --git a/sd/source/ui/accessibility/AccessibleOutlineView.cxx b/sd/source/ui/accessibility/AccessibleOutlineView.cxx
index 1da0c44bc14e..60edcdadf92e 100644
--- a/sd/source/ui/accessibility/AccessibleOutlineView.cxx
+++ b/sd/source/ui/accessibility/AccessibleOutlineView.cxx
@@ -58,11 +58,11 @@ AccessibleOutlineView::AccessibleOutlineView (
 
     ::sd::View* pView = pViewShell->GetView();
 
-    if (dynamic_cast<const ::sd::OutlineView* >( pView ) ==  nullptr)
+    auto pShellView = dynamic_cast<::sd::OutlineView* >( pView );
+    if(!pShellView)
         return;
 
-    OutlinerView* pOutlineView = static_cast< ::sd::OutlineView*>(
-        pView)->GetViewByWindow( pSdWindow );
+    OutlinerView* pOutlineView = pShellView->GetViewByWindow( pSdWindow );
     SdrOutliner& rOutliner =
         static_cast< ::sd::OutlineView*>(pView)->GetOutliner();
 
diff --git a/sd/source/ui/app/sdxfer.cxx b/sd/source/ui/app/sdxfer.cxx
index 4752d85f16b0..1b8698d0f6a1 100644
--- a/sd/source/ui/app/sdxfer.cxx
+++ b/sd/source/ui/app/sdxfer.cxx
@@ -150,11 +150,11 @@ void SdTransferable::CreateObjectReplacement( SdrObject* pObj )
     mpBookmark.reset();
     mpImageMap.reset();
 
-    if( nullptr!= dynamic_cast< const SdrOle2Obj* >( pObj ) )
+    if( auto pOleObj = dynamic_cast< SdrOle2Obj* >( pObj ) )
     {
         try
         {
-            uno::Reference < embed::XEmbeddedObject > xObj = static_cast< SdrOle2Obj* >( pObj )->GetObjRef();
+            uno::Reference < embed::XEmbeddedObject > xObj = pOleObj->GetObjRef();
             uno::Reference < embed::XEmbedPersist > xPersist( xObj, uno::UNO_QUERY );
             if( xObj.is() && xPersist.is() && xPersist->hasEntry() )
             {
@@ -162,7 +162,7 @@ void SdTransferable::CreateObjectReplacement( SdrObject* pObj )
 
                 // TODO/LATER: the standalone handling of the graphic should not be used any more in future
                 // The EmbedDataHelper should bring the graphic in future
-                const Graphic* pObjGr = static_cast< SdrOle2Obj* >( pObj )->GetGraphic();
+                const Graphic* pObjGr = pOleObj->GetGraphic();
                 if ( pObjGr )
                     mpGraphic.reset( new Graphic( *pObjGr ) );
             }
@@ -204,11 +204,11 @@ void SdTransferable::CreateObjectReplacement( SdrObject* pObj )
             }
         }
     }
-    else if( dynamic_cast< const SdrTextObj *>( pObj ) !=  nullptr )
+    else if( auto pTextObj = dynamic_cast< SdrTextObj *>( pObj ) )
     {
         const OutlinerParaObject* pPara;
 
-        if( (pPara = static_cast< SdrTextObj* >( pObj )->GetOutlinerParaObject()) != nullptr )
+        if( (pPara = pTextObj->GetOutlinerParaObject()) != nullptr )
         {
             const SvxFieldItem* pField;
 
diff --git a/sd/source/ui/dlg/sdtreelb.cxx b/sd/source/ui/dlg/sdtreelb.cxx
index 332b5f646747..fadcd450b170 100644
--- a/sd/source/ui/dlg/sdtreelb.cxx
+++ b/sd/source/ui/dlg/sdtreelb.cxx
@@ -767,8 +767,9 @@ OUString SdPageObjsTLV::GetObjectName(
     {
         aRet = pObject->GetName();
 
-        if (aRet.isEmpty() && dynamic_cast<const SdrOle2Obj* >(pObject) !=  nullptr)
-            aRet = static_cast< const SdrOle2Obj* >( pObject )->GetPersistName();
+        if (aRet.isEmpty())
+            if (auto pOleObj = dynamic_cast<const SdrOle2Obj* >(pObject))
+                aRet = pOleObj->GetPersistName();
     }
 
     if (bCreate
diff --git a/sfx2/source/control/bindings.cxx b/sfx2/source/control/bindings.cxx
index d648fdf87537..32021d47285c 100644
--- a/sfx2/source/control/bindings.cxx
+++ b/sfx2/source/control/bindings.cxx
@@ -1011,14 +1011,16 @@ void SfxBindings::Execute_Impl( SfxRequest& aReq, const SfxSlot* pSlot, SfxShell
                     pNewItem->SetValue( !bOldValue );
                     aReq.AppendItem( *pNewItem );
                 }
-                else if ( dynamic_cast< const SfxEnumItemInterface *>( pOldItem ) !=  nullptr &&
-                        static_cast<const SfxEnumItemInterface *>(pOldItem)->HasBoolValue())
+                else if ( auto pOldEnumItem = dynamic_cast< const SfxEnumItemInterface *>( pOldItem ) )
                 {
-                    // and Enums with Bool-Interface
-                    std::unique_ptr<SfxEnumItemInterface> pNewItem(
-                        static_cast<SfxEnumItemInterface*>(pOldItem->Clone()));
-                    pNewItem->SetBoolValue(!static_cast<const SfxEnumItemInterface *>(pOldItem)->GetBoolValue());
-                    aReq.AppendItem( *pNewItem );
+                    if (pOldEnumItem->HasBoolValue())
+                    {
+                        // and Enums with Bool-Interface
+                        std::unique_ptr<SfxEnumItemInterface> pNewItem(
+                            static_cast<SfxEnumItemInterface*>(pOldEnumItem->Clone()));
+                        pNewItem->SetBoolValue(!pOldEnumItem->GetBoolValue());
+                        aReq.AppendItem( *pNewItem );
+                    }
                 }
                 else {
                     OSL_FAIL( "Toggle only for Enums and Bools allowed" );
@@ -1037,12 +1039,14 @@ void SfxBindings::Execute_Impl( SfxRequest& aReq, const SfxSlot* pSlot, SfxShell
                     pNewBoolItem->SetValue( true );
                     aReq.AppendItem( *pNewItem );
                 }
-                else if ( dynamic_cast< const SfxEnumItemInterface *>( pNewItem.get() ) !=  nullptr &&
-                        static_cast<SfxEnumItemInterface *>(pNewItem.get())->HasBoolValue())
+                else if ( auto pEnumItem = dynamic_cast<SfxEnumItemInterface *>( pNewItem.get() ) )
                 {
-                    // and Enums with Bool-Interface
-                    static_cast<SfxEnumItemInterface*>(pNewItem.get())->SetBoolValue(true);
-                    aReq.AppendItem( *pNewItem );
+                    if (pEnumItem->HasBoolValue())
+                    {
+                        // and Enums with Bool-Interface
+                        pEnumItem->SetBoolValue(true);
+                        aReq.AppendItem( *pNewItem );
+                    }
                 }
                 else {
                     OSL_FAIL( "Toggle only for Enums and Bools allowed" );
diff --git a/sfx2/source/toolbox/tbxitem.cxx b/sfx2/source/toolbox/tbxitem.cxx
index 88b04852b95d..038b65d55914 100644
--- a/sfx2/source/toolbox/tbxitem.cxx
+++ b/sfx2/source/toolbox/tbxitem.cxx
@@ -497,13 +497,15 @@ void SfxToolBoxControl::StateChanged
                     eTri = TRISTATE_TRUE;
                 nItemBits |= ToolBoxItemBits::CHECKABLE;
             }
-            else if ( dynamic_cast< const SfxEnumItemInterface *>( pState ) !=  nullptr &&
-                static_cast<const SfxEnumItemInterface *>(pState)->HasBoolValue())
+            else if ( auto pEnumItem = dynamic_cast< const SfxEnumItemInterface *>( pState ) )
             {
-                // EnumItem is handled as Bool
-                if ( static_cast<const SfxEnumItemInterface *>(pState)->GetBoolValue() )
-                    eTri = TRISTATE_TRUE;
-                nItemBits |= ToolBoxItemBits::CHECKABLE;
+                if (pEnumItem->HasBoolValue())
+                {
+                    // EnumItem is handled as Bool
+                    if (pEnumItem->GetBoolValue())
+                        eTri = TRISTATE_TRUE;
+                    nItemBits |= ToolBoxItemBits::CHECKABLE;
+                }
             }
             else if ( pImpl->bShowString && dynamic_cast< const SfxStringItem *>( pState ) !=  nullptr )
                 pImpl->pBox->SetItemText(nId, static_cast<const SfxStringItem*>(pState)->GetValue() );
diff --git a/svx/source/form/navigatortree.cxx b/svx/source/form/navigatortree.cxx
index 310a1dd1b507..4d6fc09559b8 100644
--- a/svx/source/form/navigatortree.cxx
+++ b/svx/source/form/navigatortree.cxx
@@ -595,13 +595,12 @@ namespace svxform
             m_xTreeView->set_image(*m_xRootEntry, RID_SVXBMP_FORMS);
             m_xTreeView->set_sensitive(*m_xRootEntry, true);
         }
-        else if (dynamic_cast<const FmNavRequestSelectHint*>(&rHint))
+        else if (auto pSelectHint = dynamic_cast<FmNavRequestSelectHint*>(const_cast<SfxHint*>(&rHint)))
         {
-            FmNavRequestSelectHint* pershHint = const_cast<FmNavRequestSelectHint*>(static_cast<const FmNavRequestSelectHint*>(&rHint));
-            FmEntryDataArray& arredToSelect = pershHint->GetItems();
+            FmEntryDataArray& arredToSelect = pSelectHint->GetItems();
             SynchronizeSelection(arredToSelect);
 
-            if (pershHint->IsMixedSelection())
+            if (pSelectHint->IsMixedSelection())
                 // in this case I deselect all, although the view had a mixed selection
                 // during next selection, I must adapt the navigator to the view
                 m_bPrevSelectionMixed = true;
diff --git a/svx/source/svdraw/svdcrtv.cxx b/svx/source/svdraw/svdcrtv.cxx
index de4d6b0ef466..936bbbfb269a 100644
--- a/svx/source/svdraw/svdcrtv.cxx
+++ b/svx/source/svdraw/svdcrtv.cxx
@@ -804,19 +804,18 @@ void SdrCreateView::ShowCreateObj(/*OutputDevice* pOut, sal_Bool bFull*/)
                 }
             }
 
-            if(dynamic_cast<const SdrPathObj*>( pCurrentCreate) !=  nullptr)
+            if(auto pPathObj = dynamic_cast<SdrPathObj*>( pCurrentCreate))
             {
                 // The up-to-now created path needs to be set at the object to have something
                 // that can be visualized
-                SdrPathObj& rPathObj(static_cast<SdrPathObj&>(*pCurrentCreate));
-                const basegfx::B2DPolyPolygon aCurrentPolyPolygon(rPathObj.getObjectPolyPolygon(maDragStat));
+                const basegfx::B2DPolyPolygon aCurrentPolyPolygon(pPathObj->getObjectPolyPolygon(maDragStat));
 
                 if(aCurrentPolyPolygon.count())
                 {
-                    rPathObj.NbcSetPathPoly(aCurrentPolyPolygon);
+                    pPathObj->NbcSetPathPoly(aCurrentPolyPolygon);
                 }
 
-                aDragPolyPolygon = rPathObj.getDragPolyPolygon(maDragStat);
+                aDragPolyPolygon = pPathObj->getDragPolyPolygon(maDragStat);
             }
 
             // use the SdrObject directly for overlay
diff --git a/svx/source/svdraw/svddrgv.cxx b/svx/source/svdraw/svddrgv.cxx
index 62aea371e758..bd5c0249f31f 100644
--- a/svx/source/svdraw/svddrgv.cxx
+++ b/svx/source/svdraw/svddrgv.cxx
@@ -145,9 +145,9 @@ bool SdrDragView::TakeDragObjAnchorPos(Point& rPos, bool bTR ) const
         dynamic_cast<const SdrDragMovHdl*>( mpCurrentSdrDragMethod.get() ) ==  nullptr) // not when moving handles
     {
         SdrObject* pObj=GetMarkedObjectByIndex(0);
-        if (dynamic_cast<const SdrCaptionObj*>( pObj) !=  nullptr)
+        if (auto pCaptionObj = dynamic_cast<SdrCaptionObj*>(pObj))
         {
-            Point aPt(static_cast<SdrCaptionObj*>(pObj)->GetTailPos());
+            Point aPt(pCaptionObj->GetTailPos());
             bool bTail=meDragHdl==SdrHdlKind::Poly; // drag tail
             bool bOwn=dynamic_cast<const SdrDragObjOwn*>( mpCurrentSdrDragMethod.get() ) !=  nullptr; // specific to object
             if (!bTail)
diff --git a/svx/source/svdraw/svdpage.cxx b/svx/source/svdraw/svdpage.cxx
index c1f8980f4236..e199d38b43c5 100644
--- a/svx/source/svdraw/svdpage.cxx
+++ b/svx/source/svdraw/svdpage.cxx
@@ -793,28 +793,27 @@ void SdrObjList::UnGroupObj( size_t nObjNum )
     if( pUngroupObj )
     {
         SdrObjList* pSrcLst = pUngroupObj->GetSubList();
-        if( dynamic_cast<const SdrObjGroup*>( pUngroupObj) !=  nullptr && pSrcLst )
-        {
-            SdrObjGroup* pUngroupGroup = static_cast< SdrObjGroup* > (pUngroupObj);
+        if(pSrcLst)
+            if(auto pUngroupGroup = dynamic_cast<SdrObjGroup*>( pUngroupObj))
+            {
+                // ungroup recursively (has to be head recursion,
+                // otherwise our indices will get trashed when doing it in
+                // the loop)
+                pSrcLst->FlattenGroups();
 
-            // ungroup recursively (has to be head recursion,
-            // otherwise our indices will get trashed when doing it in
-            // the loop)
-            pSrcLst->FlattenGroups();
+                // the position at which we insert the members of rUngroupGroup
+                size_t nInsertPos( pUngroupGroup->GetOrdNum() );
 
-            // the position at which we insert the members of rUngroupGroup
-            size_t nInsertPos( pUngroupGroup->GetOrdNum() );
+                const size_t nCount = pSrcLst->GetObjCount();
+                for( size_t i=0; i<nCount; ++i )
+                {
+                    SdrObject* pObj = pSrcLst->RemoveObject(0);
+                    InsertObject(pObj, nInsertPos);
+                    ++nInsertPos;
+                }
 
-            const size_t nCount = pSrcLst->GetObjCount();
-            for( size_t i=0; i<nCount; ++i )
-            {
-                SdrObject* pObj = pSrcLst->RemoveObject(0);
-                InsertObject(pObj, nInsertPos);
-                ++nInsertPos;
+                RemoveObject(nInsertPos);
             }
-
-            RemoveObject(nInsertPos);
-        }
     }
 #ifdef DBG_UTIL
     else
diff --git a/svx/source/tbxctrls/colrctrl.cxx b/svx/source/tbxctrls/colrctrl.cxx
index e38c49e4916c..ae4153954130 100644
--- a/svx/source/tbxctrls/colrctrl.cxx
+++ b/svx/source/tbxctrls/colrctrl.cxx
@@ -249,13 +249,13 @@ void SvxColorDockingWindow::dispose()
 void SvxColorDockingWindow::Notify( SfxBroadcaster& , const SfxHint& rHint )
 {
     const SfxPoolItemHint* pPoolItemHint = dynamic_cast<const SfxPoolItemHint*>(&rHint);
-    if ( pPoolItemHint
-         && ( dynamic_cast<const SvxColorListItem*>(pPoolItemHint->GetObject()) != nullptr ) )
-    {
-        // The list of colors has changed
-        pColorList = static_cast<SvxColorListItem*>( pPoolItemHint->GetObject() )->GetColorList();
-        FillValueSet();
-    }
+    if ( pPoolItemHint )
+        if (auto pColorListItem = dynamic_cast<const SvxColorListItem*>(pPoolItemHint->GetObject()))
+        {
+            // The list of colors has changed
+            pColorList = pColorListItem->GetColorList();
+            FillValueSet();
+        }
 }
 
 void SvxColorDockingWindow::FillValueSet()
diff --git a/sw/source/core/frmedt/feshview.cxx b/sw/source/core/frmedt/feshview.cxx
index 4250a11f8684..691f60ca3592 100644
--- a/sw/source/core/frmedt/feshview.cxx
+++ b/sw/source/core/frmedt/feshview.cxx
@@ -3087,11 +3087,11 @@ void SwFEShell::CreateDefaultShape( SdrObjKind eSdrObjectKind, const tools::Rect
             SetLineEnds(aAttr, *pObj, nSlotId);
             pObj->SetMergedItemSet(aAttr);
         }
-        else if(auto pCationObj = dynamic_cast<SdrCaptionObj*>( pObj))
+        else if(auto pCaptionObj = dynamic_cast<SdrCaptionObj*>( pObj))
         {
             bool bVerticalText = ( SID_DRAW_TEXT_VERTICAL == nSlotId ||
                                             SID_DRAW_CAPTION_VERTICAL == nSlotId );
-            static_cast<SdrTextObj*>(pObj)->SetVerticalWriting(bVerticalText);
+            pCaptionObj->SetVerticalWriting(bVerticalText);
             if(bVerticalText)
             {
                 SfxItemSet aSet(pObj->GetMergedItemSet());
@@ -3100,8 +3100,8 @@ void SwFEShell::CreateDefaultShape( SdrObjKind eSdrObjectKind, const tools::Rect
                 pObj->SetMergedItemSet(aSet);
             }
 
-            pCationObj->SetLogicRect(aRect);
-            pCationObj->SetTailPos(
+            pCaptionObj->SetLogicRect(aRect);
+            pCaptionObj->SetTailPos(
                 aRect.TopLeft() - Point(aRect.GetWidth() / 2, aRect.GetHeight() / 2));
         }
         else if(auto pText = dynamic_cast<SdrTextObj*>( pObj))
diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx
index 299932e8fa7c..9d79621c5d15 100644
--- a/sw/source/core/layout/fly.cxx
+++ b/sw/source/core/layout/fly.cxx
@@ -319,9 +319,9 @@ void SwFlyFrame::DeleteCnt()
         while ( pFrame->GetDrawObjs() && pFrame->GetDrawObjs()->size() )
         {
             SwAnchoredObject *pAnchoredObj = (*pFrame->GetDrawObjs())[0];
-            if ( dynamic_cast<const SwFlyFrame*>( pAnchoredObj) !=  nullptr )
+            if ( auto pFlyFrame = dynamic_cast<SwFlyFrame*>( pAnchoredObj) )
             {
-                SwFrame::DestroyFrame(static_cast<SwFlyFrame*>(pAnchoredObj));
+                SwFrame::DestroyFrame(pFlyFrame);
             }
             else if ( dynamic_cast<const SwAnchoredDrawObject*>( pAnchoredObj) !=  nullptr )
             {
diff --git a/sw/source/core/view/vdraw.cxx b/sw/source/core/view/vdraw.cxx
index c0a30276b251..94f2f2240655 100644
--- a/sw/source/core/view/vdraw.cxx
+++ b/sw/source/core/view/vdraw.cxx
@@ -223,10 +223,13 @@ void SwViewShellImp::NotifySizeChg( const Size &rNewSz )
             // this function might be called by the InsertDocument, when
             // a PageDesc-Attribute is set on a node. Then the SdrObject
             // must not have an UserCall.
-            if( !pCont || dynamic_cast<const SwDrawContact*>( pCont) ==  nullptr )
+            if( !pCont )
+                continue;
+            auto pDrawContact = dynamic_cast<const SwDrawContact*>( pCont);
+            if( !pDrawContact )
                 continue;
 
-            const SwFrame *pAnchor = static_cast<const SwDrawContact*>(pCont)->GetAnchorFrame();
+            const SwFrame *pAnchor = pDrawContact->GetAnchorFrame();
             if ( !pAnchor || pAnchor->IsInFly() || !pAnchor->isFrameAreaDefinitionValid() ||
                  !pAnchor->GetUpper() || !pAnchor->FindPageFrame() ||
                  (RndStdIds::FLY_AS_CHAR == pCont->GetFormat()->GetAnchor().GetAnchorId()) )
diff --git a/sw/source/filter/ww8/ww8graf.cxx b/sw/source/filter/ww8/ww8graf.cxx
index c2efe73c3830..de8a1866ba36 100644
--- a/sw/source/filter/ww8/ww8graf.cxx
+++ b/sw/source/filter/ww8/ww8graf.cxx
@@ -2200,11 +2200,12 @@ SdrObject* SwWW8ImplReader::CreateContactObject(SwFrameFormat* pFlyFormat)
         SdrObject* pNewObject = m_bNewDoc ? nullptr : pFlyFormat->FindRealSdrObject();
         if (!pNewObject)
             pNewObject = pFlyFormat->FindSdrObject();
-        if (!pNewObject && dynamic_cast< const SwFlyFrameFormat *>( pFlyFormat ) !=  nullptr)
-        {
-            SwFlyDrawContact* pContactObject(static_cast<SwFlyFrameFormat*>(pFlyFormat)->GetOrCreateContact());
-            pNewObject = pContactObject->GetMaster();
-        }
+        if (!pNewObject )
+            if (auto pFlyFrameFormat = dynamic_cast<SwFlyFrameFormat *>( pFlyFormat ))
+            {
+                SwFlyDrawContact* pContactObject = pFlyFrameFormat->GetOrCreateContact();
+                pNewObject = pContactObject->GetMaster();
+            }
         return pNewObject;
     }
     return nullptr;
diff --git a/sw/source/filter/xml/xmltble.cxx b/sw/source/filter/xml/xmltble.cxx
index a681fc4cf38d..ad79a92e3732 100644
--- a/sw/source/filter/xml/xmltble.cxx
+++ b/sw/source/filter/xml/xmltble.cxx
@@ -1122,11 +1122,10 @@ void SwXMLExport::ExportTable( const SwTableNode& rTableNd )
     SvXMLElementExport aElem(*this, *oPrefix, XML_TABLE, true, true);
 
     // export DDE source (if this is a DDE table)
-    if ( dynamic_cast<const SwDDETable*>( &rTable) !=  nullptr )
+    if ( auto pSwDdeTable = dynamic_cast<const SwDDETable*>( &rTable) )
     {
         // get DDE Field Type (contains the DDE connection)
-        const SwDDEFieldType* pDDEFieldType =
-            static_cast<const SwDDETable&>(rTable).GetDDEFieldType();
+        const SwDDEFieldType* pDDEFieldType = pSwDdeTable->GetDDEFieldType();
 
         // connection name
         AddAttribute( XML_NAMESPACE_OFFICE, XML_NAME,
diff --git a/sw/source/ui/dialog/docstdlg.cxx b/sw/source/ui/dialog/docstdlg.cxx
index 7aacfd94cd5f..c9b362355c6e 100644
--- a/sw/source/ui/dialog/docstdlg.cxx
+++ b/sw/source/ui/dialog/docstdlg.cxx
@@ -95,10 +95,10 @@ void SwDocStatPage::Update()
 {
     SfxViewShell *pVSh = SfxViewShell::Current();
     SwViewShell *pSh = nullptr;
-    if ( dynamic_cast< const SwView *>( pVSh ) !=  nullptr )
-        pSh = static_cast<SwView*>(pVSh)->GetWrtShellPtr();
-    else if ( dynamic_cast< const SwPagePreview *>( pVSh ) !=  nullptr )
-        pSh = static_cast<SwPagePreview*>(pVSh)->GetViewShell();
+    if ( auto pSwView = dynamic_cast<SwView *>( pVSh ) )
+        pSh = pSwView->GetWrtShellPtr();
+    else if ( auto pPagePreview = dynamic_cast<SwPagePreview *>( pVSh ) )
+        pSh = pPagePreview->GetViewShell();
 
     OSL_ENSURE( pSh, "Shell not found" );
 
diff --git a/sw/source/uibase/app/apphdl.cxx b/sw/source/uibase/app/apphdl.cxx
index d4bcf37d4fca..3074d96f7bab 100644
--- a/sw/source/uibase/app/apphdl.cxx
+++ b/sw/source/uibase/app/apphdl.cxx
@@ -964,10 +964,10 @@ void SwModule::ConfigurationChanged( utl::ConfigurationBroadcaster* pBrdCst, Con
                 {
                     if(bAccessibility)
                     {
-                        if(dynamic_cast< const SwView *>( pViewShell ) !=  nullptr)
-                            static_cast<SwView*>(pViewShell)->ApplyAccessibilityOptions(*m_pAccessibilityOptions);
-                        else if(dynamic_cast< const SwPagePreview *>( pViewShell ) !=  nullptr)
-                            static_cast<SwPagePreview*>(pViewShell)->ApplyAccessibilityOptions(*m_pAccessibilityOptions);
+                        if(auto pSwView = dynamic_cast<SwView *>( pViewShell ))
+                            pSwView->ApplyAccessibilityOptions(*m_pAccessibilityOptions);
+                        else if(auto pPagePreview = dynamic_cast<SwPagePreview *>( pViewShell ))
+                            pPagePreview->ApplyAccessibilityOptions(*m_pAccessibilityOptions);
                     }
                     pViewShell->GetWindow()->Invalidate();
                 }
diff --git a/sw/source/uibase/app/docsh.cxx b/sw/source/uibase/app/docsh.cxx
index 16b3a66d8460..b6937382ebe8 100644
--- a/sw/source/uibase/app/docsh.cxx
+++ b/sw/source/uibase/app/docsh.cxx
@@ -994,12 +994,12 @@ void SwDocShell::GetState(SfxItemSet& rSet)
                 SfxViewFrame *pTmpFrame = SfxViewFrame::GetFirst(this);
                 while (pTmpFrame)     // Look for Preview
                 {
-                    if ( dynamic_cast<SwView*>( pTmpFrame->GetViewShell() ) &&
-                         static_cast<SwView*>(pTmpFrame->GetViewShell())->GetWrtShell().GetViewOptions()->getBrowseMode() )
-                    {
-                        bDisable = true;
-                        break;
-                    }
+                    if ( auto pSwView = dynamic_cast<SwView*>( pTmpFrame->GetViewShell() ) )
+                        if (pSwView->GetWrtShell().GetViewOptions()->getBrowseMode())
+                        {
+                            bDisable = true;
+                            break;
+                        }
                     pTmpFrame = SfxViewFrame::GetNext(*pTmpFrame, this);
                 }
             }
diff --git a/sw/source/uibase/uiview/view.cxx b/sw/source/uibase/uiview/view.cxx
index 0e12a868f88d..5f5fd34029af 100644
--- a/sw/source/uibase/uiview/view.cxx
+++ b/sw/source/uibase/uiview/view.cxx
@@ -1613,9 +1613,9 @@ SwGlossaryHdl* SwView::GetGlosHdl()
 void SwView::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
 {
     bool bCallBase = true;
-    if(dynamic_cast<const FmDesignModeChangedHint*>(&rHint))
+    if(auto pChangedHint = dynamic_cast<const FmDesignModeChangedHint*>(&rHint))
     {
-        bool bDesignMode = static_cast<const FmDesignModeChangedHint&>(rHint).GetDesignMode();
+        bool bDesignMode = pChangedHint->GetDesignMode();
         if (!bDesignMode && GetDrawFuncPtr())
         {
             GetDrawFuncPtr()->Deactivate();


More information about the Libreoffice-commits mailing list