[Libreoffice-commits] core.git: sc/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Fri Aug 10 06:22:01 UTC 2018


 sc/source/ui/app/inputwin.cxx                   |    8 ++++----
 sc/source/ui/drawfunc/chartsh.cxx               |    4 ++--
 sc/source/ui/drawfunc/drtxtob.cxx               |    4 ++--
 sc/source/ui/drawfunc/fudraw.cxx                |    4 ++--
 sc/source/ui/drawfunc/futext.cxx                |    3 +--
 sc/source/ui/drawfunc/graphsh.cxx               |   22 +++++++++++-----------
 sc/source/ui/drawfunc/mediash.cxx               |    4 ++--
 sc/source/ui/pagedlg/scuitphfedit.cxx           |   10 +++++-----
 sc/source/ui/sidebar/AlignmentPropertyPanel.cxx |    8 ++++----
 sc/source/ui/undo/undoblk.cxx                   |    2 +-
 sc/source/ui/unoobj/cellsuno.cxx                |    4 ++--
 sc/source/ui/unoobj/shapeuno.cxx                |   21 ++++++---------------
 sc/source/ui/view/cellsh3.cxx                   |    2 +-
 sc/source/ui/view/editsh.cxx                    |    4 ++--
 sc/source/ui/view/prevwsh.cxx                   |    3 +--
 sc/source/ui/view/tabvwsh4.cxx                  |    3 +--
 16 files changed, 47 insertions(+), 59 deletions(-)

New commits:
commit 76dd6bb9cc6dff0f59cdfce87b61210be6476965
Author:     Noel Grandin <noelgrandin at gmail.com>
AuthorDate: Thu Aug 9 16:30:41 2018 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri Aug 10 08:21:32 2018 +0200

    unnecessary null check before dynamic_cast, in sc
    
    Change-Id: I442dee456ccb419642e6cedee7c3ca99ce214de6
    Reviewed-on: https://gerrit.libreoffice.org/58773
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx
index bd1b7be0d30c..edab7e0023db 100644
--- a/sc/source/ui/app/inputwin.cxx
+++ b/sc/source/ui/app/inputwin.cxx
@@ -1633,10 +1633,10 @@ void ScTextWnd::SetTextString( const OUString& rNewString )
                 SvtScriptType nOldScript = SvtScriptType::NONE;
                 SvtScriptType nNewScript = SvtScriptType::NONE;
                 SfxObjectShell* pObjSh = SfxObjectShell::Current();
-                if ( pObjSh && dynamic_cast<const ScDocShell*>( pObjSh) !=  nullptr )
+                if ( auto pDocShell = dynamic_cast<ScDocShell*>( pObjSh) )
                 {
                     //  any document can be used (used only for its break iterator)
-                    ScDocument& rDoc = static_cast<ScDocShell*>(pObjSh)->GetDocument();
+                    ScDocument& rDoc = pDocShell->GetDocument();
                     nOldScript = rDoc.GetStringScriptType( aString );
                     nNewScript = rDoc.GetStringScriptType( rNewString );
                 }
@@ -1874,9 +1874,9 @@ void ScPosWnd::FillRangeNames()
     Clear();
 
     SfxObjectShell* pObjSh = SfxObjectShell::Current();
-    if ( pObjSh && dynamic_cast<const ScDocShell*>( pObjSh) !=  nullptr )
+    if ( auto pDocShell = dynamic_cast<ScDocShell*>( pObjSh) )
     {
-        ScDocument& rDoc = static_cast<ScDocShell*>(pObjSh)->GetDocument();
+        ScDocument& rDoc = pDocShell->GetDocument();
 
         InsertEntry(ScResId( STR_MANAGE_NAMES ));
         SetSeparatorPos(0);
diff --git a/sc/source/ui/drawfunc/chartsh.cxx b/sc/source/ui/drawfunc/chartsh.cxx
index 45e4b76e98ea..4e9edfad103b 100644
--- a/sc/source/ui/drawfunc/chartsh.cxx
+++ b/sc/source/ui/drawfunc/chartsh.cxx
@@ -76,7 +76,7 @@ void ScChartShell::GetExportAsGraphicState( SfxItemSet& rSet )
     {
         SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
 
-        if( pObj && dynamic_cast<const SdrOle2Obj*>( pObj) !=  nullptr )
+        if( dynamic_cast<const SdrOle2Obj*>( pObj) )
             bEnable = true;
     }
 
@@ -93,7 +93,7 @@ void ScChartShell::ExecuteExportAsGraphic( SfxRequest& )
     {
         SdrObject* pObject = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
 
-        if( pObject && dynamic_cast<const SdrOle2Obj*>( pObject) !=  nullptr )
+        if( dynamic_cast<const SdrOle2Obj*>( pObject) )
         {
             vcl::Window* pWin = GetViewData()->GetActiveWin();
             Reference< drawing::XShape > xSourceDoc( pObject->getUnoShape(), UNO_QUERY_THROW );
diff --git a/sc/source/ui/drawfunc/drtxtob.cxx b/sc/source/ui/drawfunc/drtxtob.cxx
index b4418e7f8750..466e62ba4b5f 100644
--- a/sc/source/ui/drawfunc/drtxtob.cxx
+++ b/sc/source/ui/drawfunc/drtxtob.cxx
@@ -271,7 +271,7 @@ void ScDrawTextObjectBar::Execute( SfxRequest &rReq )
                         if (pFieldItem)
                         {
                             const SvxFieldData* pField = pFieldItem->GetField();
-                            if ( pField && dynamic_cast<const SvxURLField*>( pField) !=  nullptr )
+                            if ( dynamic_cast<const SvxURLField*>( pField) )
                             {
                                 //  select old field
 
@@ -418,7 +418,7 @@ void ScDrawTextObjectBar::GetState( SfxItemSet& rSet )
             if ( pFieldItem )
             {
                 const SvxFieldData* pField = pFieldItem->GetField();
-                bEnable = pField && dynamic_cast<const SvxURLField*>( pField) !=  nullptr;
+                bEnable = dynamic_cast<const SvxURLField*>( pField) !=  nullptr;
             }
         }
         if( !bEnable )
diff --git a/sc/source/ui/drawfunc/fudraw.cxx b/sc/source/ui/drawfunc/fudraw.cxx
index ed9bf9e81bf9..65a3f0b843da 100644
--- a/sc/source/ui/drawfunc/fudraw.cxx
+++ b/sc/source/ui/drawfunc/fudraw.cxx
@@ -141,7 +141,7 @@ bool FuDraw::MouseButtonUp(const MouseEvent& rMEvt)
 static bool lcl_KeyEditMode( SdrObject* pObj, ScTabViewShell& rViewShell, const KeyEvent* pInitialKey )
 {
     bool bReturn = false;
-    if ( pObj && dynamic_cast<const SdrTextObj*>( pObj) != nullptr && dynamic_cast<const SdrUnoObj*>( pObj) ==  nullptr )
+    if ( dynamic_cast<const SdrTextObj*>( pObj) != nullptr && dynamic_cast<const SdrUnoObj*>( pObj) ==  nullptr )
     {
         // start text edit - like FuSelection::MouseButtonUp,
         // but with bCursorToEnd instead of mouse position
@@ -224,7 +224,7 @@ bool FuDraw::KeyInput(const KeyEvent& rKEvt)
                 {
                     bool bOle = rViewShell.GetViewFrame()->GetFrame().IsInPlace();
                     SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
-                    if( pObj && dynamic_cast<const SdrOle2Obj*>( pObj) !=  nullptr && !bOle )
+                    if( dynamic_cast<const SdrOle2Obj*>( pObj) && !bOle )
                     {
                         rViewShell.ActivateObject( static_cast< SdrOle2Obj* >( pObj ), 0 );
 
diff --git a/sc/source/ui/drawfunc/futext.cxx b/sc/source/ui/drawfunc/futext.cxx
index e9646de57610..7c86db1ab53e 100644
--- a/sc/source/ui/drawfunc/futext.cxx
+++ b/sc/source/ui/drawfunc/futext.cxx
@@ -432,9 +432,8 @@ bool FuText::MouseButtonUp(const MouseEvent& rMEvt)
                 if(rMarkList.GetMark(0))
                 {
                     SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
-                    if(pObj && dynamic_cast<const SdrTextObj*>( pObj) !=  nullptr)
+                    if(auto pText = dynamic_cast<SdrTextObj*>( pObj))
                     {
-                        SdrTextObj* pText = static_cast<SdrTextObj*>(pObj);
                         SfxItemSet aSet(pDrDoc->GetItemPool());
 
                         pText->SetVerticalWriting(true);
diff --git a/sc/source/ui/drawfunc/graphsh.cxx b/sc/source/ui/drawfunc/graphsh.cxx
index ddaf1c38139e..c0368ee09b80 100644
--- a/sc/source/ui/drawfunc/graphsh.cxx
+++ b/sc/source/ui/drawfunc/graphsh.cxx
@@ -93,7 +93,7 @@ void ScGraphicShell::GetFilterState( SfxItemSet& rSet )
     {
         SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
 
-        if( pObj && dynamic_cast<const SdrGrafObj*>( pObj) != nullptr && ( static_cast<SdrGrafObj*>(pObj)->GetGraphicType() == GraphicType::Bitmap ) )
+        if( dynamic_cast<const SdrGrafObj*>( pObj) && ( static_cast<SdrGrafObj*>(pObj)->GetGraphicType() == GraphicType::Bitmap ) )
             bEnable = true;
     }
 
@@ -110,7 +110,7 @@ void ScGraphicShell::ExecuteFilter( const SfxRequest& rReq )
     {
         SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
 
-        if( pObj &&  dynamic_cast<const SdrGrafObj*>( pObj)  != nullptr && static_cast<SdrGrafObj*>(pObj)->GetGraphicType() == GraphicType::Bitmap )
+        if( dynamic_cast<const SdrGrafObj*>( pObj) && static_cast<SdrGrafObj*>(pObj)->GetGraphicType() == GraphicType::Bitmap )
         {
             GraphicObject aFilterObj( static_cast<SdrGrafObj*>(pObj)->GetGraphicObject() );
 
@@ -144,7 +144,7 @@ void ScGraphicShell::GetExternalEditState( SfxItemSet& rSet )
     {
         SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
 
-        if( pObj && dynamic_cast<const SdrGrafObj*>( pObj) != nullptr  && ( static_cast<SdrGrafObj*>(pObj)->GetGraphicType() == GraphicType::Bitmap ) )
+        if( dynamic_cast<const SdrGrafObj*>( pObj) && ( static_cast<SdrGrafObj*>(pObj)->GetGraphicType() == GraphicType::Bitmap ) )
             bEnable = true;
     }
 
@@ -161,7 +161,7 @@ void ScGraphicShell::ExecuteExternalEdit( SAL_UNUSED_PARAMETER SfxRequest& )
     {
         SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
 
-        if( pObj && dynamic_cast<const SdrGrafObj*>( pObj) != nullptr && static_cast<SdrGrafObj*>(pObj)->GetGraphicType() == GraphicType::Bitmap )
+        if( dynamic_cast<const SdrGrafObj*>( pObj) && static_cast<SdrGrafObj*>(pObj)->GetGraphicType() == GraphicType::Bitmap )
         {
             GraphicObject aGraphicObject( static_cast<SdrGrafObj*>(pObj)->GetGraphicObject() );
             m_ExternalEdits.push_back( o3tl::make_unique<SdrExternalToolEdit>(
@@ -182,7 +182,7 @@ void ScGraphicShell::GetCompressGraphicState( SfxItemSet& rSet )
     {
         SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
 
-        if( pObj && dynamic_cast<const SdrGrafObj*>( pObj) != nullptr && ( static_cast<SdrGrafObj*>(pObj)->GetGraphicType() == GraphicType::Bitmap ) )
+        if( dynamic_cast<const SdrGrafObj*>( pObj) && ( static_cast<SdrGrafObj*>(pObj)->GetGraphicType() == GraphicType::Bitmap ) )
             bEnable = true;
     }
 
@@ -199,7 +199,7 @@ void ScGraphicShell::ExecuteCompressGraphic( SAL_UNUSED_PARAMETER SfxRequest& )
     {
         SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
 
-        if( pObj && dynamic_cast<const SdrGrafObj*>( pObj)  != nullptr && static_cast<SdrGrafObj*>(pObj)->GetGraphicType() == GraphicType::Bitmap )
+        if( dynamic_cast<const SdrGrafObj*>( pObj) && static_cast<SdrGrafObj*>(pObj)->GetGraphicType() == GraphicType::Bitmap )
         {
             SdrGrafObj* pGraphicObj = static_cast<SdrGrafObj*>(pObj);
             vcl::Window* pWin = GetViewData()->GetDialogParent();
@@ -228,7 +228,7 @@ void ScGraphicShell::GetCropGraphicState( SfxItemSet& rSet )
     {
         SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
 
-        if( pObj && nullptr != dynamic_cast<const SdrGrafObj*>( pObj) && ( static_cast<SdrGrafObj*>(pObj)->GetGraphicType() == GraphicType::Bitmap ) )
+        if( dynamic_cast<const SdrGrafObj*>( pObj) && ( static_cast<SdrGrafObj*>(pObj)->GetGraphicType() == GraphicType::Bitmap ) )
             bEnable = true;
     }
 
@@ -245,7 +245,7 @@ void ScGraphicShell::ExecuteCropGraphic( SAL_UNUSED_PARAMETER SfxRequest& )
     {
         SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
 
-        if( pObj && dynamic_cast<const SdrGrafObj*>( pObj) != nullptr && static_cast<SdrGrafObj*>(pObj)->GetGraphicType() == GraphicType::Bitmap )
+        if( dynamic_cast<const SdrGrafObj*>( pObj) && static_cast<SdrGrafObj*>(pObj)->GetGraphicType() == GraphicType::Bitmap )
         {
             pView->SetEditMode(SdrViewEditMode::Edit);
             pView->SetDragMode(SdrDragMode::Crop);
@@ -304,7 +304,7 @@ void ScGraphicShell::GetSaveGraphicState(SfxItemSet &rSet)
     {
         SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
 
-        if( pObj && dynamic_cast<const SdrGrafObj*>( pObj) != nullptr && ( static_cast<SdrGrafObj*>(pObj)->GetGraphicType() == GraphicType::Bitmap ) )
+        if( dynamic_cast<const SdrGrafObj*>( pObj) && ( static_cast<SdrGrafObj*>(pObj)->GetGraphicType() == GraphicType::Bitmap ) )
             bEnable = true;
     }
 
@@ -321,7 +321,7 @@ void ScGraphicShell::ExecuteChangePicture( SAL_UNUSED_PARAMETER SfxRequest& /*rR
     {
         SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
 
-        if( pObj && nullptr != dynamic_cast<const SdrGrafObj*>( pObj) && static_cast<SdrGrafObj*>(pObj)->GetGraphicType() == GraphicType::Bitmap )
+        if( dynamic_cast<const SdrGrafObj*>( pObj) && static_cast<SdrGrafObj*>(pObj)->GetGraphicType() == GraphicType::Bitmap )
         {
             SdrGrafObj* pGraphicObj = static_cast<SdrGrafObj*>(pObj);
             vcl::Window* pWin = GetViewData()->GetActiveWin();
@@ -357,7 +357,7 @@ void ScGraphicShell::GetChangePictureState(SfxItemSet &rSet)
     {
         SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
 
-        if( pObj && dynamic_cast<const SdrGrafObj*>( pObj) != nullptr && ( static_cast<SdrGrafObj*>(pObj)->GetGraphicType() == GraphicType::Bitmap ) )
+        if( dynamic_cast<const SdrGrafObj*>( pObj) && ( static_cast<SdrGrafObj*>(pObj)->GetGraphicType() == GraphicType::Bitmap ) )
             bEnable = true;
     }
 
diff --git a/sc/source/ui/drawfunc/mediash.cxx b/sc/source/ui/drawfunc/mediash.cxx
index 0515b38bfe19..5e236fe3cd36 100644
--- a/sc/source/ui/drawfunc/mediash.cxx
+++ b/sc/source/ui/drawfunc/mediash.cxx
@@ -77,7 +77,7 @@ void ScMediaShell::GetMediaState( SfxItemSet& rSet )
                 {
                     SdrObject* pObj = pMarkList->GetMark( 0 )->GetMarkedSdrObj();
 
-                    if( pObj && dynamic_cast<const SdrMediaObj*>( pObj) !=  nullptr )
+                    if( dynamic_cast<const SdrMediaObj*>( pObj) )
                     {
                         ::avmedia::MediaItem aItem( SID_AVMEDIA_TOOLBOX );
 
@@ -116,7 +116,7 @@ void ScMediaShell::ExecuteMedia( const SfxRequest& rReq )
             {
                 SdrObject* pObj = pMarkList->GetMark( 0 )->GetMarkedSdrObj();
 
-                if( pObj && dynamic_cast<const SdrMediaObj*>( pObj) !=  nullptr )
+                if( dynamic_cast<const SdrMediaObj*>( pObj) )
                 {
                     static_cast< sdr::contact::ViewContactOfSdrMediaObj& >( pObj->GetViewContact() ).executeMediaItem(
                         static_cast< const ::avmedia::MediaItem& >( *pItem ) );
diff --git a/sc/source/ui/pagedlg/scuitphfedit.cxx b/sc/source/ui/pagedlg/scuitphfedit.cxx
index d43b585c78fe..5596a1df7b20 100644
--- a/sc/source/ui/pagedlg/scuitphfedit.cxx
+++ b/sc/source/ui/pagedlg/scuitphfedit.cxx
@@ -370,7 +370,7 @@ void ScHFEditPage::SetSelectDefinedList()
                         if(pFieldItem)
                         {
                             const SvxFieldData* pField = pFieldItem->GetField();
-                            if(pField && dynamic_cast<const SvxTableField*>( pField) !=  nullptr)
+                            if(dynamic_cast<const SvxTableField*>( pField))
                             {
                                 eSelectEntry = eSheetEntry;
                                 bFound = true;
@@ -508,7 +508,7 @@ bool ScHFEditPage::IsPageEntry(EditEngine*pEngine, const EditTextObject* pTextOb
                     if(pFieldItem)
                     {
                         const SvxFieldData* pField = pFieldItem->GetField();
-                        if(pField && dynamic_cast<const SvxPageField*>( pField) !=  nullptr)
+                        if(dynamic_cast<const SvxPageField*>( pField))
                             bReturn = true;
                     }
                 }
@@ -530,7 +530,7 @@ bool ScHFEditPage::IsDateEntry(const EditTextObject* pTextObj)
         if(pFieldItem)
         {
             const SvxFieldData* pField = pFieldItem->GetField();
-            if(pField && dynamic_cast<const SvxDateField*>( pField) !=  nullptr)
+            if(dynamic_cast<const SvxDateField*>( pField))
                 bReturn = true;
         }
     }
@@ -546,9 +546,9 @@ bool ScHFEditPage::IsExtFileNameEntry(const EditTextObject* pTextObj)
     {
         const SvxFieldItem* pFieldItem = pTextObj->GetField();
         if(pFieldItem)
-    {
+        {
             const SvxFieldData* pField = pFieldItem->GetField();
-            if(pField && dynamic_cast<const SvxExtFileField*>( pField) !=  nullptr)
+            if(dynamic_cast<const SvxExtFileField*>( pField))
                 bReturn = true;
         }
     }
diff --git a/sc/source/ui/sidebar/AlignmentPropertyPanel.cxx b/sc/source/ui/sidebar/AlignmentPropertyPanel.cxx
index f6801e6b078d..5e8a377c9d05 100644
--- a/sc/source/ui/sidebar/AlignmentPropertyPanel.cxx
+++ b/sc/source/ui/sidebar/AlignmentPropertyPanel.cxx
@@ -265,7 +265,7 @@ void AlignmentPropertyPanel::NotifyItemUpdate(
     case SID_H_ALIGNCELL:
         {
             SvxCellHorJustify meHorAlignState = SvxCellHorJustify::Standard;
-            if(eState >= SfxItemState::DEFAULT && pState && dynamic_cast<const SvxHorJustifyItem*>( pState) !=  nullptr )
+            if(eState >= SfxItemState::DEFAULT && dynamic_cast<const SvxHorJustifyItem*>( pState) )
             {
                 const SvxHorJustifyItem* pItem = static_cast<const SvxHorJustifyItem*>(pState);
                 meHorAlignState = pItem->GetValue();
@@ -287,7 +287,7 @@ void AlignmentPropertyPanel::NotifyItemUpdate(
         }
         break;
     case SID_ATTR_ALIGN_INDENT:
-        if(eState >= SfxItemState::DEFAULT && pState && dynamic_cast<const SfxUInt16Item*>( pState) !=  nullptr )
+        if(eState >= SfxItemState::DEFAULT && dynamic_cast<const SfxUInt16Item*>( pState) )
         {
                 const SfxUInt16Item* pItem = static_cast<const SfxUInt16Item*>(pState);
                 sal_uInt16 nVal = pItem->GetValue();
@@ -300,7 +300,7 @@ void AlignmentPropertyPanel::NotifyItemUpdate(
         }
         break;
     case FID_MERGE_TOGGLE:
-        if(eState >= SfxItemState::DEFAULT && pState && dynamic_cast<const SfxBoolItem*>( pState) !=  nullptr )
+        if(eState >= SfxItemState::DEFAULT && dynamic_cast<const SfxBoolItem*>( pState) )
         {
             mpCBXMergeCell->Enable();
             const SfxBoolItem* pItem = static_cast<const SfxBoolItem*>(pState);
@@ -323,7 +323,7 @@ void AlignmentPropertyPanel::NotifyItemUpdate(
         else
         {
             mpCBXWrapText->Enable();
-            if(eState >= SfxItemState::DEFAULT && pState && dynamic_cast<const SfxBoolItem*>( pState) !=  nullptr )
+            if(eState >= SfxItemState::DEFAULT && dynamic_cast<const SfxBoolItem*>( pState) )
             {
                 mpCBXWrapText->EnableTriState(false);
                 const SfxBoolItem* pItem = static_cast<const SfxBoolItem*>(pState);
diff --git a/sc/source/ui/undo/undoblk.cxx b/sc/source/ui/undo/undoblk.cxx
index ac948a31ddc6..f50ad069579a 100644
--- a/sc/source/ui/undo/undoblk.cxx
+++ b/sc/source/ui/undo/undoblk.cxx
@@ -114,7 +114,7 @@ bool ScUndoInsertCells::Merge( SfxUndoAction* pNextAction )
     {
         ScUndoWrapper* pWrapper = static_cast<ScUndoWrapper*>(pNextAction);
         SfxUndoAction* pWrappedAction = pWrapper->GetWrappedUndo();
-        if ( pWrappedAction && dynamic_cast<const ScUndoPaste*>( pWrappedAction) !=  nullptr )
+        if ( dynamic_cast<const ScUndoPaste*>( pWrappedAction) )
         {
             //  Store paste action if this is part of paste with inserting cells.
             //  A list action isn't used because Repeat wouldn't work (insert wrong cells).
diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx
index 9273ed844c47..682d201556a4 100644
--- a/sc/source/ui/unoobj/cellsuno.cxx
+++ b/sc/source/ui/unoobj/cellsuno.cxx
@@ -4697,8 +4697,8 @@ uno::Sequence<OUString> SAL_CALL ScCellRangesObj::getSupportedServiceNames()
 uno::Reference<table::XCellRange> ScCellRangeObj::CreateRangeFromDoc( const ScDocument* pDoc, const ScRange& rR )
 {
     SfxObjectShell* pObjSh = pDoc->GetDocumentShell();
-    if ( pObjSh && dynamic_cast<const ScDocShell*>( pObjSh) !=  nullptr )
-        return new ScCellRangeObj( static_cast<ScDocShell*>(pObjSh), rR );
+    if ( auto pDocShell = dynamic_cast<ScDocShell*>( pObjSh) )
+        return new ScCellRangeObj( pDocShell, rR );
     return nullptr;
 }
 
diff --git a/sc/source/ui/unoobj/shapeuno.cxx b/sc/source/ui/unoobj/shapeuno.cxx
index 04ef95a81e9f..bf0d87d60038 100644
--- a/sc/source/ui/unoobj/shapeuno.cxx
+++ b/sc/source/ui/unoobj/shapeuno.cxx
@@ -343,10 +343,8 @@ void SAL_CALL ScShapeObj::setPropertyValue(const OUString& aPropertyName, const
                 if ( pDoc )
                 {
                     SfxObjectShell* pObjSh = pDoc->GetDocumentShell();
-                    if ( pObjSh && dynamic_cast<const ScDocShell*>( pObjSh) !=  nullptr )
+                    if ( auto pDocSh = dynamic_cast<ScDocShell*>( pObjSh) )
                     {
-                        ScDocShell* pDocSh = static_cast<ScDocShell*>(pObjSh);
-
                         SCTAB nTab = 0;
                         if ( lcl_GetPageNum( pPage, rModel, nTab ) )
                         {
@@ -477,9 +475,8 @@ void SAL_CALL ScShapeObj::setPropertyValue(const OUString& aPropertyName, const
                         if ( pDoc )
                         {
                             SfxObjectShell* pObjSh = pDoc->GetDocumentShell();
-                            if ( pObjSh && dynamic_cast<const ScDocShell*>( pObjSh) !=  nullptr )
+                            if ( auto pDocSh = dynamic_cast<ScDocShell*>( pObjSh) )
                             {
-                                ScDocShell* pDocSh = static_cast<ScDocShell*>(pObjSh);
                                 uno::Reference<drawing::XShape> xShape( mxShapeAgg, uno::UNO_QUERY );
                                 if (xShape.is())
                                 {
@@ -576,9 +573,8 @@ void SAL_CALL ScShapeObj::setPropertyValue(const OUString& aPropertyName, const
                         if ( pDoc )
                         {
                             SfxObjectShell* pObjSh = pDoc->GetDocumentShell();
-                            if ( pObjSh && dynamic_cast<const ScDocShell*>( pObjSh) !=  nullptr )
+                            if ( auto pDocSh = dynamic_cast<ScDocShell*>( pObjSh) )
                             {
-                                ScDocShell* pDocSh = static_cast<ScDocShell*>(pObjSh);
                                 uno::Reference<drawing::XShape> xShape( mxShapeAgg, uno::UNO_QUERY );
                                 if (xShape.is())
                                 {
@@ -673,9 +669,8 @@ uno::Any SAL_CALL ScShapeObj::getPropertyValue( const OUString& aPropertyName )
                     if ( lcl_GetPageNum( pPage, rModel, nTab ) )
                     {
                         SfxObjectShell* pObjSh = pDoc->GetDocumentShell();
-                        if ( pObjSh && dynamic_cast<const ScDocShell*>( pObjSh) !=  nullptr )
+                        if ( auto pDocSh = dynamic_cast<ScDocShell*>( pObjSh) )
                         {
-                            ScDocShell* pDocSh = static_cast<ScDocShell*>(pObjSh);
                             uno::Reference< uno::XInterface > xAnchor;
                             if (ScDrawObjData *pAnchor = ScDrawLayer::GetObjDataTab(pObj, nTab))
                                 xAnchor.set(static_cast<cppu::OWeakObject*>(new ScCellObj( pDocSh, pAnchor->maStart)));
@@ -1011,10 +1006,8 @@ uno::Reference<text::XTextRange> SAL_CALL ScShapeObj::getAnchor()
         if ( pPage && pDoc )
         {
             SfxObjectShell* pObjSh = pDoc->GetDocumentShell();
-            if ( pObjSh && dynamic_cast<const ScDocShell*>( pObjSh) !=  nullptr )
+            if ( auto pDocSh = dynamic_cast<ScDocShell*>( pObjSh) )
             {
-                ScDocShell* pDocSh = static_cast<ScDocShell*>(pObjSh);
-
                 SCTAB nTab = 0;
                 if ( lcl_GetPageNum( pPage, rModel, nTab ) )
                 {
@@ -1254,10 +1247,8 @@ uno::Reference< uno::XInterface > SAL_CALL ScShapeObj::getParent()
         if ( pPage && pDoc )
         {
             SfxObjectShell* pObjSh = pDoc->GetDocumentShell();
-            if ( pObjSh && dynamic_cast<const ScDocShell*>( pObjSh) !=  nullptr )
+            if ( auto pDocSh = dynamic_cast<ScDocShell*>( pObjSh) )
             {
-                ScDocShell* pDocSh = static_cast<ScDocShell*>(pObjSh);
-
                 SCTAB nTab = 0;
                 if ( lcl_GetPageNum( pPage, rModel, nTab ) )
                 {
diff --git a/sc/source/ui/view/cellsh3.cxx b/sc/source/ui/view/cellsh3.cxx
index 8da6bfbf0195..2a2956a0fa8d 100644
--- a/sc/source/ui/view/cellsh3.cxx
+++ b/sc/source/ui/view/cellsh3.cxx
@@ -791,7 +791,7 @@ void ScCellShell::Execute( SfxRequest& rReq )
                     if ( pReqArgs &&
                         pReqArgs->GetItemState(nSlot, true, &pItem) == SfxItemState::SET )
                     {
-                        OSL_ENSURE(pItem && dynamic_cast<const SfxBoolItem*>( pItem) !=  nullptr, "wrong item");
+                        OSL_ENSURE(dynamic_cast<const SfxBoolItem*>( pItem), "wrong item");
                         bMoveContents = static_cast<const SfxBoolItem*>(pItem)->GetValue();
                     }
 
diff --git a/sc/source/ui/view/editsh.cxx b/sc/source/ui/view/editsh.cxx
index ff519a49dd48..fe9ed2b53448 100644
--- a/sc/source/ui/view/editsh.cxx
+++ b/sc/source/ui/view/editsh.cxx
@@ -793,8 +793,8 @@ const SvxURLField* ScEditShell::GetURLField()
         if (pFieldItem)
         {
             const SvxFieldData* pField = pFieldItem->GetField();
-            if ( pField && dynamic_cast<const SvxURLField*>( pField) !=  nullptr )
-                return static_cast<const SvxURLField*>(pField);
+            if ( auto pURLField = dynamic_cast<const SvxURLField*>( pField) )
+                return pURLField;
         }
     }
 
diff --git a/sc/source/ui/view/prevwsh.cxx b/sc/source/ui/view/prevwsh.cxx
index 735e715311b7..3417cee7b66d 100644
--- a/sc/source/ui/view/prevwsh.cxx
+++ b/sc/source/ui/view/prevwsh.cxx
@@ -155,13 +155,12 @@ ScPreviewShell::ScPreviewShell( SfxViewFrame* pViewFrame,
 {
     Construct( &pViewFrame->GetWindow() );
 
-    if ( pOldSh && dynamic_cast<const ScTabViewShell*>( pOldSh) !=  nullptr )
+    if ( auto pTabViewShell = dynamic_cast<ScTabViewShell*>( pOldSh) )
     {
         //  store view settings, show table from TabView
         //! store live ScViewData instead, and update on ScTablesHint?
         //! or completely forget aSourceData on ScTablesHint?
 
-        ScTabViewShell* pTabViewShell = static_cast<ScTabViewShell*>(pOldSh);
         const ScViewData& rData = pTabViewShell->GetViewData();
         pPreview->SetSelectedTabs(rData.GetMarkData());
         InitStartTable( rData.GetTabNo() );
diff --git a/sc/source/ui/view/tabvwsh4.cxx b/sc/source/ui/view/tabvwsh4.cxx
index 556880a93ac7..c128f81c27f1 100644
--- a/sc/source/ui/view/tabvwsh4.cxx
+++ b/sc/source/ui/view/tabvwsh4.cxx
@@ -1673,9 +1673,8 @@ ScTabViewShell::ScTabViewShell( SfxViewFrame* pViewFrame,
     //  old DesignMode state from form layer must be restored, too
 
     TriState nForceDesignMode = TRISTATE_INDET;
-    if ( pOldSh && dynamic_cast<const ScPreviewShell*>( pOldSh) !=  nullptr )
+    if ( auto pPreviewShell = dynamic_cast<ScPreviewShell*>( pOldSh) )
     {
-        ScPreviewShell* pPreviewShell = static_cast<ScPreviewShell*>(pOldSh);
         nForceDesignMode = pPreviewShell->GetSourceDesignMode();
         ScPreview* p = pPreviewShell->GetPreview();
         if (p)


More information about the Libreoffice-commits mailing list