diff options
author | Jan Holesovsky <kendy@collabora.com> | 2016-07-27 11:44:44 +0200 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2016-07-27 15:03:16 +0200 |
commit | 5bd8b05f9b0adb93aec4d6ad7b67c7003092b873 (patch) | |
tree | 3be3349ea135faf5c55d5048c8754dc852ad695a /sw | |
parent | 91ad1017b609be6fceccd392006dd9ab60724352 (diff) |
Simplify dynamic_cast followed by a static_cast.
Change-Id: Ic95ca9b07e73a9f5b25834cd2d23c9180861b7c1
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/uibase/shells/basesh.cxx | 49 | ||||
-rw-r--r-- | sw/source/uibase/shells/drawsh.cxx | 4 |
2 files changed, 26 insertions, 27 deletions
diff --git a/sw/source/uibase/shells/basesh.cxx b/sw/source/uibase/shells/basesh.cxx index 7edbca93dc7d..041b8eaa4e43 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 a1bb7666e471..e5632b507d33 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); |