[Libreoffice-commits] core.git: sfx2/source svx/source

Noel (via logerrit) logerrit at kemper.freedesktop.org
Tue Oct 13 11:29:52 UTC 2020


 sfx2/source/control/dispatch.cxx                        |    4 +-
 svx/source/customshapes/EnhancedCustomShapeFontWork.cxx |    4 +-
 svx/source/engine3d/dragmt3d.cxx                        |    8 ++--
 svx/source/engine3d/scene3d.cxx                         |   12 ++----
 svx/source/fmcomp/gridcell.cxx                          |    4 +-
 svx/source/form/fmexpl.cxx                              |    8 ++--
 svx/source/form/navigatortree.cxx                       |   30 +++++-----------
 svx/source/form/navigatortreemodel.cxx                  |   27 ++++++--------
 svx/source/sdr/contact/viewcontactofsdrobj.cxx          |    9 ++--
 svx/source/sdr/properties/properties.cxx                |    4 +-
 svx/source/svdraw/svdedtv1.cxx                          |    4 --
 svx/source/svdraw/svdmrkv.cxx                           |    4 +-
 svx/source/svdraw/svdotxat.cxx                          |   16 ++++----
 svx/source/svdraw/svdotxdr.cxx                          |    8 ++--
 svx/source/svdraw/svdpage.cxx                           |    6 +--
 svx/source/unodraw/unomod.cxx                           |    4 +-
 svx/source/unodraw/unopage.cxx                          |   10 ++---
 17 files changed, 72 insertions(+), 90 deletions(-)

New commits:
commit 530d0e0569342742d7bcf529b77ba4a409cf01a9
Author:     Noel <noelgrandin at gmail.com>
AuthorDate: Tue Oct 13 11:30:37 2020 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Tue Oct 13 13:29:08 2020 +0200

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

diff --git a/sfx2/source/control/dispatch.cxx b/sfx2/source/control/dispatch.cxx
index 9c6f3c5200c2..6e6104883fe0 100644
--- a/sfx2/source/control/dispatch.cxx
+++ b/sfx2/source/control/dispatch.cxx
@@ -1964,8 +1964,8 @@ SfxModule* SfxDispatcher::GetModule() const
         SfxShell *pSh = GetShell(nShell);
         if ( pSh == nullptr )
             return nullptr;
-        if ( dynamic_cast< const SfxModule *>( pSh ) !=  nullptr )
-            return static_cast<SfxModule*>(pSh);
+        if ( auto pModule = dynamic_cast<SfxModule *>( pSh ) )
+            return pModule;
     }
 }
 
diff --git a/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx b/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx
index 6a88afe524df..8ccc0337389c 100644
--- a/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx
+++ b/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx
@@ -554,9 +554,9 @@ static basegfx::B2DPolyPolygon GetOutlinesFromShape2d( const SdrObject* pShape2d
     while( aObjListIter.IsMore() )
     {
         SdrObject* pPartObj = aObjListIter.Next();
-        if ( dynamic_cast<const SdrPathObj*>( pPartObj) !=  nullptr )
+        if ( auto pPathObj = dynamic_cast<const SdrPathObj*>( pPartObj))
         {
-            basegfx::B2DPolyPolygon aCandidate(static_cast<SdrPathObj*>(pPartObj)->GetPathPoly());
+            basegfx::B2DPolyPolygon aCandidate(pPathObj->GetPathPoly());
             if(aCandidate.areControlPointsUsed())
             {
                 aCandidate = basegfx::utils::adaptiveSubdivideByAngle(aCandidate);
diff --git a/svx/source/engine3d/dragmt3d.cxx b/svx/source/engine3d/dragmt3d.cxx
index 9e7425a02ed0..3020e19a4ab0 100644
--- a/svx/source/engine3d/dragmt3d.cxx
+++ b/svx/source/engine3d/dragmt3d.cxx
@@ -338,9 +338,9 @@ void E3dDragRotate::MoveSdrDrag(const Point& rPnt)
 
     // Get modifier
     sal_uInt16 nModifier = 0;
-    if(dynamic_cast<const E3dView*>(&getSdrDragView()))
+    if(auto pDragView = dynamic_cast<const E3dView*>(&getSdrDragView()))
     {
-        const MouseEvent& rLastMouse = static_cast<E3dView&>(getSdrDragView()).GetMouseEvent();
+        const MouseEvent& rLastMouse = pDragView->GetMouseEvent();
         nModifier = rLastMouse.GetModifier();
     }
 
@@ -520,9 +520,9 @@ void E3dDragMove::MoveSdrDrag(const Point& rPnt)
         // Get modifier
         sal_uInt16 nModifier(0);
 
-        if(dynamic_cast<const E3dView*>(&getSdrDragView()))
+        if(auto pDragView = dynamic_cast<const E3dView*>(&getSdrDragView()))
         {
-            const MouseEvent& rLastMouse = static_cast<E3dView&>(getSdrDragView()).GetMouseEvent();
+            const MouseEvent& rLastMouse = pDragView->GetMouseEvent();
             nModifier = rLastMouse.GetModifier();
         }
 
diff --git a/svx/source/engine3d/scene3d.cxx b/svx/source/engine3d/scene3d.cxx
index 09a7bbdfa973..9cd91246071a 100644
--- a/svx/source/engine3d/scene3d.cxx
+++ b/svx/source/engine3d/scene3d.cxx
@@ -116,10 +116,10 @@ Imp3DDepthRemapper::Imp3DDepthRemapper(E3dScene const & rScene)
 
         if(pCandidate)
         {
-            if(dynamic_cast< const E3dCompoundObject*>(pCandidate))
+            if(auto pCompoundObj = dynamic_cast< const E3dCompoundObject*>(pCandidate))
             {
                 // single 3d object, calc depth
-                const double fMinimalDepth(getMinimalDepthInViewCoordinates(static_cast< const E3dCompoundObject& >(*pCandidate)));
+                const double fMinimalDepth(getMinimalDepthInViewCoordinates(*pCompoundObj));
                 ImpRemap3DDepth aEntry(a, fMinimalDepth);
                 maVector.push_back(aEntry);
             }
@@ -378,10 +378,8 @@ void E3dScene::removeAllNonSelectedObjects()
         {
             bool bRemoveObject(false);
 
-            if(dynamic_cast< const E3dScene*>(pObj))
+            if(auto pScene = dynamic_cast<E3dScene*>(pObj))
             {
-                E3dScene* pScene = static_cast<E3dScene*>(pObj);
-
                 // iterate over this sub-scene
                 pScene->removeAllNonSelectedObjects();
 
@@ -394,10 +392,8 @@ void E3dScene::removeAllNonSelectedObjects()
                     bRemoveObject = true;
                 }
             }
-            else if(dynamic_cast< const E3dCompoundObject*>(pObj))
+            else if(auto pCompound = dynamic_cast<E3dCompoundObject*>(pObj))
             {
-                E3dCompoundObject* pCompound = static_cast<E3dCompoundObject*>(pObj);
-
                 if(!pCompound->GetSelected())
                 {
                     bRemoveObject = true;
diff --git a/svx/source/fmcomp/gridcell.cxx b/svx/source/fmcomp/gridcell.cxx
index 8c8206d31b10..67a17de94699 100644
--- a/svx/source/fmcomp/gridcell.cxx
+++ b/svx/source/fmcomp/gridcell.cxx
@@ -502,8 +502,8 @@ void DbGridColumn::Paint(OutputDevice& rDev,
             rDev.DrawText(rRect, OUString(OBJECTTEXT), nStyle);
         }
     }
-    else if ( dynamic_cast<const FmXFilterCell*>( m_pCell.get() ) !=  nullptr )
-        static_cast< FmXFilterCell* >( m_pCell.get() )->PaintCell( rDev, rRect );
+    else if ( auto pFilterCell = dynamic_cast<FmXFilterCell*>( m_pCell.get() ) )
+        pFilterCell->PaintCell( rDev, rRect );
 }
 
 
diff --git a/svx/source/form/fmexpl.cxx b/svx/source/form/fmexpl.cxx
index b86e2cf7a8a1..aeb070082c1d 100644
--- a/svx/source/form/fmexpl.cxx
+++ b/svx/source/form/fmexpl.cxx
@@ -256,9 +256,9 @@ bool FmFormData::IsEqualWithoutChildren( FmEntryData* pEntryData )
 {
     if(this == pEntryData)
         return true;
-    if( dynamic_cast<const FmFormData*>( pEntryData) ==  nullptr )
+    FmFormData* pFormData = dynamic_cast<FmFormData*>(pEntryData);
+    if( !pFormData )
         return false;
-    FmFormData* pFormData = static_cast<FmFormData*>(pEntryData);
     if( m_xForm.get() != pFormData->GetFormIface().get() )
         return false;
 
@@ -412,9 +412,9 @@ bool FmControlData::IsEqualWithoutChildren( FmEntryData* pEntryData )
     if(this == pEntryData)
         return true;
 
-    if( dynamic_cast<const FmControlData*>( pEntryData) ==  nullptr )
+    FmControlData* pControlData = dynamic_cast<FmControlData*>(pEntryData);
+    if( !pControlData )
         return false;
-    FmControlData* pControlData = static_cast<FmControlData*>(pEntryData);
 
     if( m_xFormComponent.get() != pControlData->GetFormComponent().get() )
         return false;
diff --git a/svx/source/form/navigatortree.cxx b/svx/source/form/navigatortree.cxx
index ef4bc95a68a3..310a1dd1b507 100644
--- a/svx/source/form/navigatortree.cxx
+++ b/svx/source/form/navigatortree.cxx
@@ -554,24 +554,20 @@ namespace svxform
 
     void NavigatorTree::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
     {
-        if( dynamic_cast<const FmNavRemovedHint*>(&rHint) )
+        if( auto pRemovedHint = dynamic_cast<const FmNavRemovedHint*>(&rHint) )
         {
-            const FmNavRemovedHint* pRemovedHint = static_cast<const FmNavRemovedHint*>(&rHint);
             FmEntryData* pEntryData = pRemovedHint->GetEntryData();
             Remove( pEntryData );
         }
-
-        else if( dynamic_cast<const FmNavInsertedHint*>(&rHint) )
+        else if( auto pInsertedHint = dynamic_cast<const FmNavInsertedHint*>(&rHint) )
         {
-            const FmNavInsertedHint* pInsertedHint = static_cast<const FmNavInsertedHint*>(&rHint);
             FmEntryData* pEntryData = pInsertedHint->GetEntryData();
             sal_uInt32 nRelPos = pInsertedHint->GetRelPos();
             Insert( pEntryData, nRelPos );
         }
-
-        else if( dynamic_cast<const FmNavModelReplacedHint*>(&rHint) )
+        else if( auto pReplacedHint = dynamic_cast<const FmNavModelReplacedHint*>(&rHint) )
         {
-            FmEntryData* pData = static_cast<const FmNavModelReplacedHint*>(&rHint)->GetEntryData();
+            FmEntryData* pData = pReplacedHint->GetEntryData();
             std::unique_ptr<weld::TreeIter> xEntry = FindEntry(pData);
             if (xEntry)
             {
@@ -579,14 +575,11 @@ namespace svxform
                 m_xTreeView->set_image(*xEntry, pData->GetNormalImage());
             }
         }
-
-        else if( dynamic_cast<const FmNavNameChangedHint*>(&rHint) )
+        else if( auto pNameChangedHint = dynamic_cast<const FmNavNameChangedHint*>(&rHint) )
         {
-            const FmNavNameChangedHint* pNameChangedHint = static_cast<const FmNavNameChangedHint*>(&rHint);
             std::unique_ptr<weld::TreeIter> xEntry = FindEntry(pNameChangedHint->GetEntryData());
             m_xTreeView->set_text(*xEntry, pNameChangedHint->GetNewName());
         }
-
         else if( dynamic_cast<const FmNavClearedHint*>(&rHint) )
         {
             m_aCutEntries.clear();
@@ -1686,9 +1679,9 @@ namespace svxform
 
             // one remaining subtile problem, before deleting it : if it's a form and the shell
             // knows it as CurrentObject, I have to tell it something else
-            if (dynamic_cast<const FmFormData*>( pCurrent) !=  nullptr)
+            if (auto pFormData = dynamic_cast<FmFormData*>( pCurrent))
             {
-                Reference< XForm >  xCurrentForm( static_cast< FmFormData* >( pCurrent )->GetFormIface() );
+                Reference< XForm >  xCurrentForm( pFormData->GetFormIface() );
                 if (pFormShell->GetImpl()->getCurrentForm_Lock() == xCurrentForm)  // shell knows form to be deleted ?
                     pFormShell->GetImpl()->forgetCurrentForm_Lock();                 // -> take away ...
             }
@@ -1980,17 +1973,16 @@ namespace svxform
     void NavigatorTree::CollectObjects(FmFormData const * pFormData, bool bDeep, ::std::set< Reference< XFormComponent > >& _rObjects)
     {
         FmEntryDataList* pChildList = pFormData->GetChildList();
-        FmControlData* pControlData;
         for( size_t i = 0; i < pChildList->size(); ++i )
         {
             FmEntryData* pEntryData = pChildList->at( i );
-            if( dynamic_cast<const FmControlData*>( pEntryData) !=  nullptr )
+            if( auto pControlData = dynamic_cast<FmControlData*>( pEntryData) )
             {
-                pControlData = static_cast<FmControlData*>(pEntryData);
                 _rObjects.insert(pControlData->GetFormComponent());
             } // if( dynamic_cast<const FmControlData*>( pEntryData) !=  nullptr )
-            else if (bDeep && (dynamic_cast<const FmFormData*>( pEntryData) !=  nullptr))
-                CollectObjects(static_cast<FmFormData*>(pEntryData), bDeep, _rObjects);
+            else if (bDeep)
+                if (auto pEntryFormData = dynamic_cast<FmFormData*>( pEntryData))
+                    CollectObjects(pEntryFormData, bDeep, _rObjects);
         } // for( sal_uInt32 i=0; i<pChildList->Count(); i++ )
     }
 
diff --git a/svx/source/form/navigatortreemodel.cxx b/svx/source/form/navigatortreemodel.cxx
index 945592a0b730..5b2a1ce3fd79 100644
--- a/svx/source/form/navigatortreemodel.cxx
+++ b/svx/source/form/navigatortreemodel.cxx
@@ -379,8 +379,8 @@ namespace svxform
         }
 
         // now real deletion of data form model
-        if (dynamic_cast<const FmFormData*>( pEntry) !=  nullptr)
-            RemoveForm(static_cast<FmFormData*>(pEntry));
+        if (auto pFormData = dynamic_cast<FmFormData*>( pEntry))
+            RemoveForm(pFormData);
         else
             RemoveFormComponent(static_cast<FmControlData*>(pEntry));
 
@@ -451,10 +451,10 @@ namespace svxform
 
 
             // Child is form -> recursive call
-            if( dynamic_cast<const FmFormData*>( pEntryData) !=  nullptr )
-                RemoveForm( static_cast<FmFormData*>(pEntryData));
-            else if( dynamic_cast<const FmControlData*>( pEntryData) !=  nullptr )
-                RemoveFormComponent(static_cast<FmControlData*>(pEntryData));
+            if( auto pChildFormData = dynamic_cast<FmFormData*>( pEntryData) )
+                RemoveForm(pChildFormData);
+            else if( auto pChildControlData = dynamic_cast<FmControlData*>( pEntryData) )
+                RemoveFormComponent(pChildControlData);
         }
 
 
@@ -594,9 +594,10 @@ namespace svxform
     {
         FmEntryData* pData = FindData(xOld, GetRootList());
         assert(dynamic_cast<const FmControlData*>( pData)); //NavigatorTreeModel::ReplaceFormComponent : invalid argument
-        if (!dynamic_cast<const FmControlData*>( pData))
+        auto pControlData = dynamic_cast<FmControlData*>( pData);
+        if (!pControlData)
             return;
-        static_cast<FmControlData*>(pData)->ModelReplaced(xNew);
+        pControlData->ModelReplaced(xNew);
 
         FmNavModelReplacedHint aReplacedHint( pData );
         Broadcast( aReplacedHint );
@@ -737,9 +738,9 @@ namespace svxform
 
     bool NavigatorTreeModel::InsertFormComponent(FmNavRequestSelectHint& rHint, SdrObject* pObject)
     {
-        if ( dynamic_cast<const SdrObjGroup*>( pObject) !=  nullptr )
+        if ( auto pObjGroup = dynamic_cast<const SdrObjGroup*>( pObject) )
         {   // descend recursively
-            const SdrObjList *pChildren = static_cast<SdrObjGroup*>(pObject)->GetSubList();
+            const SdrObjList *pChildren = pObjGroup->GetSubList();
             for ( size_t i=0; i<pChildren->GetObjCount(); ++i )
             {
                 SdrObject* pCurrent = pChildren->GetObj(i);
@@ -879,15 +880,13 @@ namespace svxform
         // get PropertySet
         Reference< XFormComponent >  xFormComponent;
 
-        if( dynamic_cast<const FmFormData*>( pEntryData) !=  nullptr )
+        if( auto pFormData = dynamic_cast<FmFormData*>( pEntryData))
         {
-            FmFormData* pFormData = static_cast<FmFormData*>(pEntryData);
             xFormComponent = pFormData->GetFormIface();
         }
 
-        if( dynamic_cast<const FmControlData*>( pEntryData) !=  nullptr )
+        if( auto pControlData = dynamic_cast<FmControlData*>( pEntryData) )
         {
-            FmControlData* pControlData = static_cast<FmControlData*>(pEntryData);
             xFormComponent = pControlData->GetFormComponent();
         }
 
diff --git a/svx/source/sdr/contact/viewcontactofsdrobj.cxx b/svx/source/sdr/contact/viewcontactofsdrobj.cxx
index 6741c3bfe553..91a29cf56534 100644
--- a/svx/source/sdr/contact/viewcontactofsdrobj.cxx
+++ b/svx/source/sdr/contact/viewcontactofsdrobj.cxx
@@ -46,10 +46,9 @@ ViewContactOfSdrObj::ViewContactOfSdrObj(SdrObject& rObj)
     meRememberedAnimationKind(SdrTextAniKind::NONE)
 {
     // init AnimationKind
-    if(dynamic_cast<const SdrTextObj*>( &GetSdrObject() ) != nullptr)
+    if(auto pTextObj = dynamic_cast<const SdrTextObj*>( &GetSdrObject() ))
     {
-        SdrTextObj& rTextObj = static_cast<SdrTextObj&>(GetSdrObject());
-        meRememberedAnimationKind = rTextObj.GetTextAniKind();
+        meRememberedAnimationKind = pTextObj->GetTextAniKind();
     }
 }
 
@@ -84,10 +83,10 @@ ViewContact* ViewContactOfSdrObj::GetParentContact() const
 
     if(pObjList)
     {
-        if(dynamic_cast<const SdrPage*>( pObjList) !=  nullptr)
+        if(auto pPage = dynamic_cast<SdrPage*>( pObjList))
         {
             // Is a page
-            pRetval = &(static_cast<SdrPage*>(pObjList)->GetViewContact());
+            pRetval = &(pPage->GetViewContact());
         }
         else
         {
diff --git a/svx/source/sdr/properties/properties.cxx b/svx/source/sdr/properties/properties.cxx
index 95a9e9e433ce..c3ffd1d86313 100644
--- a/svx/source/sdr/properties/properties.cxx
+++ b/svx/source/sdr/properties/properties.cxx
@@ -126,9 +126,9 @@ namespace sdr::properties
             const sal_uInt32 nCount(rChange.GetRectangleCount());
 
             // invalidate all new rectangles
-            if(dynamic_cast<const SdrObjGroup*>( &GetSdrObject() ) != nullptr)
+            if(auto pObjGroup = dynamic_cast<SdrObjGroup*>( &GetSdrObject() ))
             {
-                SdrObjListIter aIter(static_cast<SdrObjGroup&>(GetSdrObject()), SdrIterMode::DeepNoGroups);
+                SdrObjListIter aIter(pObjGroup, SdrIterMode::DeepNoGroups);
 
                 while(aIter.IsMore())
                 {
diff --git a/svx/source/svdraw/svdedtv1.cxx b/svx/source/svdraw/svdedtv1.cxx
index debad4d28747..39ebd7c7acb4 100644
--- a/svx/source/svdraw/svdedtv1.cxx
+++ b/svx/source/svdraw/svdedtv1.cxx
@@ -1195,10 +1195,8 @@ void SdrEditView::SetAttrToMarked(const SfxItemSet& rAttr, bool bReplaceAll)
             }
         }
 
-        if(dynamic_cast<const SdrTextObj*>( pObj) !=  nullptr)
+        if(auto pTextObj = dynamic_cast<SdrTextObj*>( pObj))
         {
-            SdrTextObj* pTextObj = static_cast<SdrTextObj*>(pObj);
-
             if(!aCharWhichIds.empty())
             {
                 tools::Rectangle aOldBoundRect = pTextObj->GetLastBoundRect();
diff --git a/svx/source/svdraw/svdmrkv.cxx b/svx/source/svdraw/svdmrkv.cxx
index c3e6bd81f42a..82c5695fead4 100644
--- a/svx/source/svdraw/svdmrkv.cxx
+++ b/svx/source/svdraw/svdmrkv.cxx
@@ -2110,9 +2110,9 @@ SdrObject* SdrMarkView::CheckSingleSdrObjectHit(const Point& rPnt, sal_uInt16 nT
                 // adjustment hit point for virtual objects
                 Point aPnt( rPnt );
 
-                if ( dynamic_cast<const SdrVirtObj*>( pObj) !=  nullptr )
+                if ( auto pVirtObj = dynamic_cast<const SdrVirtObj*>( pObj) )
                 {
-                    Point aOffset = static_cast<SdrVirtObj*>(pObj)->GetOffset();
+                    Point aOffset = pVirtObj->GetOffset();
                     aPnt.Move( -aOffset.X(), -aOffset.Y() );
                 }
 
diff --git a/svx/source/svdraw/svdotxat.cxx b/svx/source/svdraw/svdotxat.cxx
index 7ede09f1a8f4..4d7b5ee8434c 100644
--- a/svx/source/svdraw/svdotxat.cxx
+++ b/svx/source/svdraw/svdotxat.cxx
@@ -242,11 +242,11 @@ bool SdrTextObj::NbcAdjustTextFrameWidthAndHeight(bool bHgt, bool bWdt)
     if (bRet)
     {
         SetRectsDirty();
-        if (dynamic_cast<const SdrRectObj *>(this) != nullptr) { // this is a hack
-            static_cast<SdrRectObj*>(this)->SetXPolyDirty();
+        if (auto pRectObj = dynamic_cast<SdrRectObj *>(this)) { // this is a hack
+            pRectObj->SetXPolyDirty();
         }
-        if (dynamic_cast<const SdrCaptionObj *>(this) != nullptr) { // this is a hack
-            static_cast<SdrCaptionObj*>(this)->ImpRecalcTail();
+        if (auto pCaptionObj = dynamic_cast<SdrCaptionObj *>(this)) { // this is a hack
+            pCaptionObj->ImpRecalcTail();
         }
     }
     return bRet;
@@ -260,11 +260,11 @@ bool SdrTextObj::AdjustTextFrameWidthAndHeight()
         tools::Rectangle aBoundRect0; if (pUserCall!=nullptr) aBoundRect0=GetLastBoundRect();
         maRect = aNewRect;
         SetRectsDirty();
-        if (dynamic_cast<const SdrRectObj *>(this) != nullptr) { // this is a hack
-            static_cast<SdrRectObj*>(this)->SetXPolyDirty();
+        if (auto pRectObj = dynamic_cast<SdrRectObj *>(this)) { // this is a hack
+            pRectObj->SetXPolyDirty();
         }
-        if (dynamic_cast<const SdrCaptionObj *>(this) != nullptr) { // this is a hack
-            static_cast<SdrCaptionObj*>(this)->ImpRecalcTail();
+        if (auto pCaptionObj = dynamic_cast<SdrCaptionObj *>(this)) { // this is a hack
+            pCaptionObj->ImpRecalcTail();
         }
 
         // to not slow down EditView visualization on Overlay (see
diff --git a/svx/source/svdraw/svdotxdr.cxx b/svx/source/svdraw/svdotxdr.cxx
index 182f4d99f9fc..f33f7cfe668a 100644
--- a/svx/source/svdraw/svdotxdr.cxx
+++ b/svx/source/svdraw/svdotxdr.cxx
@@ -198,8 +198,8 @@ bool SdrTextObj::MovCreate(SdrDragStat& rStat)
     maRect = aRect1; // for ObjName
     SetBoundRectDirty();
     bSnapRectDirty=true;
-    if (dynamic_cast<const SdrRectObj *>(this) != nullptr) {
-        static_cast<SdrRectObj*>(this)->SetXPolyDirty();
+    if (auto pRectObj = dynamic_cast<SdrRectObj *>(this)) {
+        pRectObj->SetXPolyDirty();
     }
     return true;
 }
@@ -212,8 +212,8 @@ bool SdrTextObj::EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd)
     AdaptTextMinSize();
 
     SetRectsDirty();
-    if (dynamic_cast<const SdrRectObj *>(this) != nullptr) {
-        static_cast<SdrRectObj*>(this)->SetXPolyDirty();
+    if (auto pRectObj = dynamic_cast<SdrRectObj *>(this)) {
+        pRectObj->SetXPolyDirty();
     }
     return (eCmd==SdrCreateCmd::ForceEnd || rStat.GetPointCount()>=2);
 }
diff --git a/svx/source/svdraw/svdpage.cxx b/svx/source/svdraw/svdpage.cxx
index 6ede6aa36108..c1f8980f4236 100644
--- a/svx/source/svdraw/svdpage.cxx
+++ b/svx/source/svdraw/svdpage.cxx
@@ -1649,12 +1649,12 @@ void SdrPage::SetInserted( bool bIns )
     while ( aIter.IsMore() )
     {
         SdrObject* pObj = aIter.Next();
-        if ( dynamic_cast<const SdrOle2Obj* >(pObj) !=  nullptr )
+        if ( auto pOleObj = dynamic_cast<SdrOle2Obj* >(pObj) )
         {
             if( mbInserted )
-                static_cast<SdrOle2Obj*>(pObj)->Connect();
+                pOleObj->Connect();
             else
-                static_cast<SdrOle2Obj*>(pObj)->Disconnect();
+                pOleObj->Disconnect();
         }
     }
 }
diff --git a/svx/source/unodraw/unomod.cxx b/svx/source/unodraw/unomod.cxx
index 5fdc880c7cad..eb80ab186deb 100644
--- a/svx/source/unodraw/unomod.cxx
+++ b/svx/source/unodraw/unomod.cxx
@@ -604,8 +604,8 @@ uno::Reference< drawing::XDrawPage > SAL_CALL SvxUnoDrawPagesAccess::insertNewBy
     {
         SdrPage* pPage;
 
-        if( dynamic_cast<FmFormModel*>( mrModel.mpDoc )  )
-            pPage = new FmFormPage(*static_cast<FmFormModel*>(mrModel.mpDoc));
+        if( auto pFormModel = dynamic_cast<FmFormModel*>( mrModel.mpDoc )  )
+            pPage = new FmFormPage(*pFormModel);
         else
             pPage = new SdrPage(*mrModel.mpDoc);
 
diff --git a/svx/source/unodraw/unopage.cxx b/svx/source/unodraw/unopage.cxx
index d58980400961..efaf53aa915c 100644
--- a/svx/source/unodraw/unopage.cxx
+++ b/svx/source/unodraw/unopage.cxx
@@ -538,9 +538,8 @@ SdrObject* SvxDrawPage::CreateSdrObject_(const Reference< drawing::XShape > & xS
 
         pScene->SetRectsDirty();
     }
-    else if(dynamic_cast<const E3dExtrudeObj* >(pNewObj) !=  nullptr)
+    else if(auto pObj = dynamic_cast<E3dExtrudeObj* >(pNewObj))
     {
-        E3dExtrudeObj* pObj = static_cast<E3dExtrudeObj*>(pNewObj);
         basegfx::B2DPolygon aNewPolygon;
         aNewPolygon.append(basegfx::B2DPoint(0.0, 0.0));
         aNewPolygon.append(basegfx::B2DPoint(0.0, 1.0));
@@ -551,18 +550,17 @@ SdrObject* SvxDrawPage::CreateSdrObject_(const Reference< drawing::XShape > & xS
         // #107245# pObj->SetExtrudeCharacterMode(sal_True);
         pObj->SetMergedItem(Svx3DCharacterModeItem(true));
     }
-    else if(dynamic_cast<const E3dLatheObj* >(pNewObj) !=  nullptr)
+    else if(auto pLatheObj = dynamic_cast<E3dLatheObj* >(pNewObj))
     {
-        E3dLatheObj* pObj = static_cast<E3dLatheObj*>(pNewObj);
         basegfx::B2DPolygon aNewPolygon;
         aNewPolygon.append(basegfx::B2DPoint(0.0, 0.0));
         aNewPolygon.append(basegfx::B2DPoint(0.0, 1.0));
         aNewPolygon.append(basegfx::B2DPoint(1.0, 0.0));
         aNewPolygon.setClosed(true);
-        pObj->SetPolyPoly2D(basegfx::B2DPolyPolygon(aNewPolygon));
+        pLatheObj->SetPolyPoly2D(basegfx::B2DPolyPolygon(aNewPolygon));
 
         // #107245# pObj->SetLatheCharacterMode(sal_True);
-        pObj->SetMergedItem(Svx3DCharacterModeItem(true));
+        pLatheObj->SetMergedItem(Svx3DCharacterModeItem(true));
     }
 
     return pNewObj;


More information about the Libreoffice-commits mailing list