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

Jan Holesovsky kendy at collabora.com
Wed Jul 27 13:03:51 UTC 2016


 sw/source/uibase/shells/basesh.cxx |   49 ++++++++++++++++++-------------------
 sw/source/uibase/shells/drawsh.cxx |    4 +--
 2 files changed, 26 insertions(+), 27 deletions(-)

New commits:
commit 5bd8b05f9b0adb93aec4d6ad7b67c7003092b873
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Wed Jul 27 11:44:44 2016 +0200

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

diff --git a/sw/source/uibase/shells/basesh.cxx b/sw/source/uibase/shells/basesh.cxx
index 7edbca9..041b8ea 100644
--- a/sw/source/uibase/shells/basesh.cxx
+++ b/sw/source/uibase/shells/basesh.cxx
@@ -1127,25 +1127,24 @@ void SwBaseShell::Execute(SfxRequest &rReq)
             break;
 
         case FN_XFORMS_DESIGN_MODE:
-            if( pArgs != nullptr
-                && pArgs->GetItemState( nSlot, true, &pItem ) == SfxItemState::SET
-                && pItem != nullptr
-                && dynamic_cast< const SfxBoolItem *>( pItem ) !=  nullptr )
-            {
-                bool bDesignMode =
-                    static_cast<const SfxBoolItem*>( pItem )->GetValue();
-
-                // set form design mode
-                OSL_ENSURE( GetView().GetFormShell() != nullptr, "form shell?" );
-                SfxRequest aReq( GetView().GetViewFrame(), SID_FM_DESIGN_MODE );
-                aReq.AppendItem( SfxBoolItem( SID_FM_DESIGN_MODE, bDesignMode ) );
-                GetView().GetFormShell()->Execute( aReq );
-                aReq.Done();
-
-                // also set suitable view options
-                SwViewOption aViewOption = *rSh.GetViewOptions();
-                aViewOption.SetFormView( ! bDesignMode );
-                rSh.ApplyViewOptions( aViewOption );
+            if (pArgs && pArgs->GetItemState(nSlot, true, &pItem) == SfxItemState::SET)
+            {
+                if (const SfxBoolItem* pBoolItem = dynamic_cast<const SfxBoolItem*>(pItem))
+                {
+                    bool bDesignMode = pBoolItem->GetValue();
+
+                    // set form design mode
+                    OSL_ENSURE( GetView().GetFormShell() != nullptr, "form shell?" );
+                    SfxRequest aReq( GetView().GetViewFrame(), SID_FM_DESIGN_MODE );
+                    aReq.AppendItem( SfxBoolItem( SID_FM_DESIGN_MODE, bDesignMode ) );
+                    GetView().GetFormShell()->Execute( aReq );
+                    aReq.Done();
+
+                    // also set suitable view options
+                    SwViewOption aViewOption = *rSh.GetViewOptions();
+                    aViewOption.SetFormView( ! bDesignMode );
+                    rSh.ApplyViewOptions( aViewOption );
+                }
             }
             break;
 
@@ -2127,13 +2126,13 @@ void SwBaseShell::GetTextFontCtrlState( SfxItemSet& rSet )
                 if(RES_CHRATR_FONT == nWhich)
                 {
                     vcl::Font aFont;
-                    if(pI && dynamic_cast< const SvxFontItem *>( pI ) !=  nullptr)
+                    if (const SvxFontItem* pFontItem = dynamic_cast<const SvxFontItem*>(pI))
                     {
-                        aFont.SetFamilyName( static_cast<const SvxFontItem*>(pI)->GetFamilyName());
-                        aFont.SetStyleName(static_cast<const SvxFontItem*>(pI)->GetStyleName());
-                        aFont.SetFamily(static_cast<const SvxFontItem*>(pI)->GetFamily());
-                        aFont.SetPitch(static_cast<const SvxFontItem*>(pI)->GetPitch());
-                        aFont.SetCharSet(static_cast<const SvxFontItem*>(pI)->GetCharSet());
+                        aFont.SetFamilyName(pFontItem->GetFamilyName());
+                        aFont.SetStyleName(pFontItem->GetStyleName());
+                        aFont.SetFamily(pFontItem->GetFamily());
+                        aFont.SetPitch(pFontItem->GetPitch());
+                        aFont.SetCharSet(pFontItem->GetCharSet());
                     }
 
                     bool bVertical = rSh.IsInVerticalText();
diff --git a/sw/source/uibase/shells/drawsh.cxx b/sw/source/uibase/shells/drawsh.cxx
index a1bb766..e5632b5 100644
--- a/sw/source/uibase/shells/drawsh.cxx
+++ b/sw/source/uibase/shells/drawsh.cxx
@@ -139,9 +139,9 @@ void SwDrawShell::InsertPictureFromFile(SdrObject& rObject)
 
                 rSh.StartUndo(UNDO_PASTE_CLIPBOARD);
 
-                if(dynamic_cast< SdrGrafObj* >(&rObject))
+                if (SdrGrafObj* pSdrGrafObj = dynamic_cast<SdrGrafObj*>(&rObject))
                 {
-                    SdrGrafObj* pNewGrafObj = static_cast<SdrGrafObj*>(rObject.Clone());
+                    SdrGrafObj* pNewGrafObj = pSdrGrafObj->Clone();
 
                     pNewGrafObj->SetGraphic(aGraphic);
 


More information about the Libreoffice-commits mailing list