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

Jan Holesovsky kendy at collabora.com
Thu Jul 21 17:55:48 UTC 2016


 sw/source/uibase/shells/drwtxtex.cxx |   10 +++++-----
 sw/source/uibase/uiview/pview.cxx    |    8 ++++----
 sw/source/uibase/uiview/view.cxx     |   17 ++++++++---------
 3 files changed, 17 insertions(+), 18 deletions(-)

New commits:
commit 0788ce918fd0c3bca06e6cff045cc4dba9de5ad7
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Thu Jul 21 16:55:31 2016 +0200

    Simplify dynamic_cast followed by a static_cast.
    
    Change-Id: I9a37110b5d7b89e41393f1b4344b3ab3d673d700

diff --git a/sw/source/uibase/shells/drwtxtex.cxx b/sw/source/uibase/shells/drwtxtex.cxx
index 0943a1f..24b6914 100644
--- a/sw/source/uibase/shells/drwtxtex.cxx
+++ b/sw/source/uibase/shells/drwtxtex.cxx
@@ -1058,13 +1058,13 @@ void SwDrawTextShell::StateInsert(SfxItemSet &rSet)
 
                     if (pFieldItem)
                     {
-                        const SvxFieldData* pField = pFieldItem->GetField();
+                        const SvxURLField* pURLField = dynamic_cast<const SvxURLField*>(pFieldItem->GetField());
 
-                        if (dynamic_cast< const SvxURLField *>( pField ) !=  nullptr)
+                        if (pURLField)
                         {
-                            aHLinkItem.SetName(static_cast<const SvxURLField*>( pField)->GetRepresentation());
-                            aHLinkItem.SetURL(static_cast<const SvxURLField*>( pField)->GetURL());
-                            aHLinkItem.SetTargetFrame(static_cast<const SvxURLField*>( pField)->GetTargetFrame());
+                            aHLinkItem.SetName(pURLField->GetRepresentation());
+                            aHLinkItem.SetURL(pURLField->GetURL());
+                            aHLinkItem.SetTargetFrame(pURLField->GetTargetFrame());
                         }
                     }
                     else
diff --git a/sw/source/uibase/uiview/pview.cxx b/sw/source/uibase/uiview/pview.cxx
index 3754e0e..12f6d27 100644
--- a/sw/source/uibase/uiview/pview.cxx
+++ b/sw/source/uibase/uiview/pview.cxx
@@ -1210,13 +1210,13 @@ SwPagePreview::SwPagePreview(SfxViewFrame *pViewFrame, SfxViewShell* pOldSh):
 
     SwViewShell *pVS, *pNew;
 
-    if( pOldSh && dynamic_cast<const SwPagePreview *>(pOldSh) != nullptr )
-        pVS = static_cast<SwPagePreview*>(pOldSh)->GetViewShell();
+    if (SwPagePreview* pPagePreview = dynamic_cast<SwPagePreview*>(pOldSh))
+        pVS = pPagePreview->GetViewShell();
     else
     {
-        if( pOldSh && dynamic_cast<const SwView *>(pOldSh) != nullptr )
+        if (SwView* pView = dynamic_cast<SwView *>(pOldSh))
         {
-            pVS = static_cast<SwView*>(pOldSh)->GetWrtShellPtr();
+            pVS = pView->GetWrtShellPtr();
             // save the current ViewData of the previous SwView
             pOldSh->WriteUserData( sSwViewData );
         }
diff --git a/sw/source/uibase/uiview/view.cxx b/sw/source/uibase/uiview/view.cxx
index 09d2e83..fd69c6f 100644
--- a/sw/source/uibase/uiview/view.cxx
+++ b/sw/source/uibase/uiview/view.cxx
@@ -775,15 +775,15 @@ SwView::SwView( SfxViewFrame *_pFrame, SfxViewShell* pOldSh )
     {
         pExistingSh = pOldSh;
         // determine type of existing view
-        if( dynamic_cast<const SwPagePreview *>(pExistingSh) != nullptr )
+        if (SwPagePreview* pPagePreview = dynamic_cast<SwPagePreview *>(pExistingSh))
         {
-            m_sSwViewData = static_cast<SwPagePreview*>(pExistingSh)->GetPrevSwViewData();
-            m_sNewCursorPos = static_cast<SwPagePreview*>(pExistingSh)->GetNewCursorPos();
-            m_nNewPage = static_cast<SwPagePreview*>(pExistingSh)->GetNewPage();
+            m_sSwViewData = pPagePreview->GetPrevSwViewData();
+            m_sNewCursorPos = pPagePreview->GetNewCursorPos();
+            m_nNewPage = pPagePreview->GetNewPage();
             m_bOldShellWasPagePreview = true;
             m_bIsPreviewDoubleClick = !m_sNewCursorPos.isEmpty() || m_nNewPage != USHRT_MAX;
         }
-        else if( dynamic_cast<const SwSrcView *>(pExistingSh) != nullptr )
+        else if (dynamic_cast<const SwSrcView *>(pExistingSh) != nullptr)
             bOldShellWasSrcView = true;
     }
 
@@ -1566,9 +1566,9 @@ SwGlossaryHdl* SwView::GetGlosHdl()
 void SwView::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
 {
     bool bCallBase = true;
-    if ( dynamic_cast<const SfxSimpleHint*>(&rHint) )
+    if (const SfxSimpleHint* pSimpleHint = dynamic_cast<const SfxSimpleHint*>(&rHint))
     {
-        sal_uInt32 nId = static_cast<const SfxSimpleHint&>(rHint).GetId();
+        sal_uInt32 nId = pSimpleHint->GetId();
         switch ( nId )
         {
             // sub shells will be destroyed by the
@@ -1628,8 +1628,7 @@ void SwView::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
                     bCallBase = false;
                     if ( GetFormShell() )
                     {
-                        GetFormShell()->SetView(
-                            dynamic_cast<FmFormView*>( GetWrtShell().GetDrawView())  );
+                        GetFormShell()->SetView(dynamic_cast<FmFormView*>(GetWrtShell().GetDrawView()));
                         SfxBoolItem aItem( SID_FM_DESIGN_MODE, !GetDocShell()->IsReadOnly());
                         GetDispatcher().ExecuteList(SID_FM_DESIGN_MODE,
                                 SfxCallMode::SYNCHRON, { &aItem });


More information about the Libreoffice-commits mailing list