diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-05-31 08:29:01 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-06-12 08:24:04 +0200 |
commit | 51c879d8649c7aad7a0c9be0c7ea042d041254d8 (patch) | |
tree | d454d885be767ba7d113547b1fa91ee85cabcf6a /sd/source/ui/view | |
parent | af66cd6e0809982d61b962fbcf2042981084f770 (diff) |
simplify calls to *DialogFactory::Create methods
we don't need to check for nullptr here, it's never null.
Change-Id: I3cc5337a8f4dec6747821679e39ccba3cec20f56
Reviewed-on: https://gerrit.libreoffice.org/55114
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sd/source/ui/view')
-rw-r--r-- | sd/source/ui/view/drviews2.cxx | 171 | ||||
-rw-r--r-- | sd/source/ui/view/drviews3.cxx | 22 | ||||
-rw-r--r-- | sd/source/ui/view/outlnvs2.cxx | 24 | ||||
-rw-r--r-- | sd/source/ui/view/sdview2.cxx | 19 |
4 files changed, 101 insertions, 135 deletions
diff --git a/sd/source/ui/view/drviews2.cxx b/sd/source/ui/view/drviews2.cxx index d1280bae129a..1db662685938 100644 --- a/sd/source/ui/view/drviews2.cxx +++ b/sd/source/ui/view/drviews2.cxx @@ -1799,45 +1799,42 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq) SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create(); vcl::Window* pWin = GetActiveWindow(); - ScopedVclPtr<AbstractSdInsertLayerDlg> pDlg(pFact ? pFact->CreateSdInsertLayerDlg(pWin ? pWin->GetFrameWeld() : nullptr, aNewAttr, true, SdResId(STR_INSERTLAYER)) : nullptr); - if( pDlg ) - { - pDlg->SetHelpId( SD_MOD()->GetSlotPool()->GetSlot( SID_INSERTLAYER )->GetCommand() ); + ScopedVclPtr<AbstractSdInsertLayerDlg> pDlg( pFact->CreateSdInsertLayerDlg(pWin ? pWin->GetFrameWeld() : nullptr, aNewAttr, true, SdResId(STR_INSERTLAYER)) ); + pDlg->SetHelpId( SD_MOD()->GetSlotPool()->GetSlot( SID_INSERTLAYER )->GetCommand() ); - // test for already existing names - bool bLoop = true; - while( bLoop && pDlg->Execute() == RET_OK ) - { - pDlg->GetAttr( aNewAttr ); - aLayerName = static_cast<const SfxStringItem &>( aNewAttr.Get (ATTR_LAYER_NAME)).GetValue (); + // test for already existing names + bool bLoop = true; + while( bLoop && pDlg->Execute() == RET_OK ) + { + pDlg->GetAttr( aNewAttr ); + aLayerName = static_cast<const SfxStringItem &>( aNewAttr.Get (ATTR_LAYER_NAME)).GetValue (); - if( rLayerAdmin.GetLayer( aLayerName ) - || aLayerName.isEmpty() ) - { - // name already exists - std::unique_ptr<weld::MessageDialog> xWarn(Application::CreateMessageDialog(GetFrameWeld(), - VclMessageType::Warning, VclButtonsType::Ok, - SdResId(STR_WARN_NAME_DUPLICATE))); - xWarn->run(); - } - else - bLoop = false; - } - if( bLoop ) // was canceled + if( rLayerAdmin.GetLayer( aLayerName ) + || aLayerName.isEmpty() ) { - pDlg.disposeAndClear(); - Cancel(); - rReq.Ignore (); - break; + // name already exists + std::unique_ptr<weld::MessageDialog> xWarn(Application::CreateMessageDialog(GetFrameWeld(), + VclMessageType::Warning, VclButtonsType::Ok, + SdResId(STR_WARN_NAME_DUPLICATE))); + xWarn->run(); } else - { - aLayerTitle = static_cast<const SfxStringItem &>( aNewAttr.Get (ATTR_LAYER_TITLE)).GetValue (); - aLayerDesc = static_cast<const SfxStringItem &>( aNewAttr.Get (ATTR_LAYER_DESC)).GetValue (); - bIsVisible = static_cast<const SfxBoolItem &>( aNewAttr.Get (ATTR_LAYER_VISIBLE)).GetValue (); - bIsLocked = static_cast<const SfxBoolItem &>( aNewAttr.Get (ATTR_LAYER_LOCKED)).GetValue () ; - bIsPrintable = static_cast<const SfxBoolItem &>( aNewAttr.Get (ATTR_LAYER_PRINTABLE)).GetValue () ; - } + bLoop = false; + } + if( bLoop ) // was canceled + { + pDlg.disposeAndClear(); + Cancel(); + rReq.Ignore (); + break; + } + else + { + aLayerTitle = static_cast<const SfxStringItem &>( aNewAttr.Get (ATTR_LAYER_TITLE)).GetValue (); + aLayerDesc = static_cast<const SfxStringItem &>( aNewAttr.Get (ATTR_LAYER_DESC)).GetValue (); + bIsVisible = static_cast<const SfxBoolItem &>( aNewAttr.Get (ATTR_LAYER_VISIBLE)).GetValue (); + bIsLocked = static_cast<const SfxBoolItem &>( aNewAttr.Get (ATTR_LAYER_LOCKED)).GetValue () ; + bIsPrintable = static_cast<const SfxBoolItem &>( aNewAttr.Get (ATTR_LAYER_PRINTABLE)).GetValue () ; } } else if (pArgs->Count () != 4) @@ -1967,47 +1964,44 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq) SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create(); vcl::Window* pWin = GetActiveWindow(); - ScopedVclPtr<AbstractSdInsertLayerDlg> pDlg(pFact ? pFact->CreateSdInsertLayerDlg(pWin ? pWin->GetFrameWeld() : nullptr, aNewAttr, bDelete, SdResId(STR_MODIFYLAYER)) : nullptr); - if( pDlg ) - { - pDlg->SetHelpId( SD_MOD()->GetSlotPool()->GetSlot( SID_MODIFYLAYER )->GetCommand() ); + ScopedVclPtr<AbstractSdInsertLayerDlg> pDlg( pFact->CreateSdInsertLayerDlg(pWin ? pWin->GetFrameWeld() : nullptr, aNewAttr, bDelete, SdResId(STR_MODIFYLAYER)) ); + pDlg->SetHelpId( SD_MOD()->GetSlotPool()->GetSlot( SID_MODIFYLAYER )->GetCommand() ); - // test for already existing names - bool bLoop = true; - sal_uInt16 nRet = 0; - while( bLoop && ( (nRet = pDlg->Execute()) == RET_OK ) ) - { - pDlg->GetAttr( aNewAttr ); - aLayerName = static_cast<const SfxStringItem &>( aNewAttr.Get (ATTR_LAYER_NAME)).GetValue (); + // test for already existing names + bool bLoop = true; + sal_uInt16 nRet = 0; + while( bLoop && ( (nRet = pDlg->Execute()) == RET_OK ) ) + { + pDlg->GetAttr( aNewAttr ); + aLayerName = static_cast<const SfxStringItem &>( aNewAttr.Get (ATTR_LAYER_NAME)).GetValue (); - if( (rLayerAdmin.GetLayer( aLayerName ) && - aLayerName != aOldLayerName) || aLayerName.isEmpty() ) - { - // name already exists - std::unique_ptr<weld::MessageDialog> xWarn(Application::CreateMessageDialog(GetFrameWeld(), - VclMessageType::Warning, VclButtonsType::Ok, - SdResId(STR_WARN_NAME_DUPLICATE))); - xWarn->run(); - } - else - bLoop = false; - } - switch (nRet) + if( (rLayerAdmin.GetLayer( aLayerName ) && + aLayerName != aOldLayerName) || aLayerName.isEmpty() ) { - case RET_OK : - aLayerTitle = static_cast<const SfxStringItem &>( aNewAttr.Get (ATTR_LAYER_TITLE)).GetValue (); - aLayerDesc = static_cast<const SfxStringItem &>( aNewAttr.Get (ATTR_LAYER_DESC)).GetValue (); - bIsVisible = static_cast<const SfxBoolItem &>( aNewAttr.Get (ATTR_LAYER_VISIBLE)).GetValue (); - bIsLocked = static_cast<const SfxBoolItem &>( aNewAttr.Get (ATTR_LAYER_LOCKED)).GetValue (); - bIsPrintable = static_cast<const SfxBoolItem &>( aNewAttr.Get (ATTR_LAYER_PRINTABLE)).GetValue (); - break; - - default : - pDlg.disposeAndClear(); - rReq.Ignore (); - Cancel (); - return; + // name already exists + std::unique_ptr<weld::MessageDialog> xWarn(Application::CreateMessageDialog(GetFrameWeld(), + VclMessageType::Warning, VclButtonsType::Ok, + SdResId(STR_WARN_NAME_DUPLICATE))); + xWarn->run(); } + else + bLoop = false; + } + switch (nRet) + { + case RET_OK : + aLayerTitle = static_cast<const SfxStringItem &>( aNewAttr.Get (ATTR_LAYER_TITLE)).GetValue (); + aLayerDesc = static_cast<const SfxStringItem &>( aNewAttr.Get (ATTR_LAYER_DESC)).GetValue (); + bIsVisible = static_cast<const SfxBoolItem &>( aNewAttr.Get (ATTR_LAYER_VISIBLE)).GetValue (); + bIsLocked = static_cast<const SfxBoolItem &>( aNewAttr.Get (ATTR_LAYER_LOCKED)).GetValue (); + bIsPrintable = static_cast<const SfxBoolItem &>( aNewAttr.Get (ATTR_LAYER_PRINTABLE)).GetValue (); + break; + + default : + pDlg.disposeAndClear(); + rReq.Ignore (); + Cancel (); + return; } } else if (pArgs->Count () == 4) @@ -2393,8 +2387,8 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq) // Dialog... SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create(); vcl::Window* pWin = GetActiveWindow(); - ScopedVclPtr<AbstractSdModifyFieldDlg> pDlg(pFact ? pFact->CreateSdModifyFieldDlg(pWin ? pWin->GetFrameWeld() : nullptr, pFldItem->GetField(), pOLV->GetAttribs() ) : nullptr); - if( pDlg && pDlg->Execute() == RET_OK ) + ScopedVclPtr<AbstractSdModifyFieldDlg> pDlg( pFact->CreateSdModifyFieldDlg(pWin ? pWin->GetFrameWeld() : nullptr, pFldItem->GetField(), pOLV->GetAttribs() ) ); + if( pDlg->Execute() == RET_OK ) { // To make a correct SetAttribs() call at the utlinerView // it is necessary to split the actions here @@ -2792,14 +2786,8 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq) else { SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create(); - if( pFact ) - { - ScopedVclPtr<VclAbstractDialog> pDlg(pFact->CreateBreakDlg(GetFrameWeld(), mpDrawView.get(), GetDocSh(), nCount, static_cast<sal_uLong>(nCnt) )); - if( pDlg ) - { - pDlg->Execute(); - } - } + ScopedVclPtr<VclAbstractDialog> pDlg(pFact->CreateBreakDlg(GetFrameWeld(), mpDrawView.get(), GetDocSh(), nCount, static_cast<sal_uLong>(nCnt) )); + pDlg->Execute(); } } @@ -3224,12 +3212,8 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq) { #ifdef ENABLE_SDREMOTE SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create(); - if (pFact) - { - ScopedVclPtr<VclAbstractDialog> pDlg(pFact->CreateRemoteDialog(GetActiveWindow())); - if (pDlg) - pDlg->Execute(); - } + ScopedVclPtr<VclAbstractDialog> pDlg(pFact->CreateRemoteDialog(GetActiveWindow())); + pDlg->Execute(); #endif } break; @@ -3315,15 +3299,12 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq) case SID_PHOTOALBUM: { SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create(); - if (pFact) - { - vcl::Window* pWin = GetActiveWindow(); - ScopedVclPtr<VclAbstractDialog> pDlg(pFact->CreateSdPhotoAlbumDialog( - pWin ? pWin->GetFrameWeld() : nullptr, - GetDoc())); + vcl::Window* pWin = GetActiveWindow(); + ScopedVclPtr<VclAbstractDialog> pDlg(pFact->CreateSdPhotoAlbumDialog( + pWin ? pWin->GetFrameWeld() : nullptr, + GetDoc())); - pDlg->Execute(); - } + pDlg->Execute(); Cancel(); rReq.Ignore (); } diff --git a/sd/source/ui/view/drviews3.cxx b/sd/source/ui/view/drviews3.cxx index 2a286ab4ba47..068aa6f8a637 100644 --- a/sd/source/ui/view/drviews3.cxx +++ b/sd/source/ui/view/drviews3.cxx @@ -291,14 +291,11 @@ void DrawViewShell::ExecCtrl(SfxRequest& rReq) { SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create(); ScopedVclPtr<AbstractHeaderFooterDialog> pDlg(pFact ? pFact->CreateHeaderFooterDialog( this, GetActiveWindow(), GetDoc(), mpActualPage ) : nullptr); - if( pDlg ) - { - pDlg->Execute(); - pDlg.disposeAndClear(); + pDlg->Execute(); + pDlg.disposeAndClear(); - GetActiveWindow()->Invalidate(); - UpdatePreview( mpActualPage ); - } + GetActiveWindow()->Invalidate(); + UpdatePreview( mpActualPage ); Invalidate(); rReq.Done (); @@ -314,13 +311,10 @@ void DrawViewShell::ExecCtrl(SfxRequest& rReq) pPage = static_cast<SdPage*>(&pPage->TRG_GetMasterPage()); SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create(); - if (pFact) - { - vcl::Window* pWin = GetActiveWindow(); - ScopedVclPtr<VclAbstractDialog> pDlg(pFact->CreateMasterLayoutDialog(pWin ? pWin->GetFrameWeld() : nullptr, GetDoc(), pPage)); - pDlg->Execute(); - Invalidate(); - } + vcl::Window* pWin = GetActiveWindow(); + ScopedVclPtr<VclAbstractDialog> pDlg(pFact->CreateMasterLayoutDialog(pWin ? pWin->GetFrameWeld() : nullptr, GetDoc(), pPage)); + pDlg->Execute(); + Invalidate(); rReq.Done (); break; } diff --git a/sd/source/ui/view/outlnvs2.cxx b/sd/source/ui/view/outlnvs2.cxx index c398f2148224..f20a0fdcc644 100644 --- a/sd/source/ui/view/outlnvs2.cxx +++ b/sd/source/ui/view/outlnvs2.cxx @@ -287,12 +287,8 @@ void OutlineViewShell::FuTemporary(SfxRequest &rReq) { #ifdef ENABLE_SDREMOTE SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create(); - if (pFact) - { - ScopedVclPtr<VclAbstractDialog> pDlg(pFact->CreateRemoteDialog(GetActiveWindow())); - if (pDlg) - pDlg->Execute(); - } + ScopedVclPtr<VclAbstractDialog> pDlg(pFact->CreateRemoteDialog(GetActiveWindow())); + pDlg->Execute(); #endif } break; @@ -307,15 +303,13 @@ void OutlineViewShell::FuTemporary(SfxRequest &rReq) case SID_PHOTOALBUM: { SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create(); - if (pFact) - { - vcl::Window* pWin = GetActiveWindow(); - ScopedVclPtr<VclAbstractDialog> pDlg(pFact->CreateSdPhotoAlbumDialog( - pWin ? pWin->GetFrameWeld() : nullptr, - GetDoc())); + vcl::Window* pWin = GetActiveWindow(); + ScopedVclPtr<VclAbstractDialog> pDlg(pFact->CreateSdPhotoAlbumDialog( + pWin ? pWin->GetFrameWeld() : nullptr, + GetDoc())); + + pDlg->Execute(); - pDlg->Execute(); - } Cancel(); rReq.Ignore (); } @@ -575,7 +569,7 @@ void OutlineViewShell::FuTemporaryModify(SfxRequest &rReq) SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create(); vcl::Window* pWin = GetActiveWindow(); ScopedVclPtr<AbstractSdModifyFieldDlg> pDlg(pFact ? pFact->CreateSdModifyFieldDlg(pWin ? pWin->GetFrameWeld() : nullptr, pFldItem->GetField(), pOutlinerView->GetAttribs() ) : nullptr); - if( pDlg && (pDlg->Execute() == RET_OK) ) + if( pDlg->Execute() == RET_OK ) { std::unique_ptr<SvxFieldData> pField(pDlg->GetField()); if( pField ) diff --git a/sd/source/ui/view/sdview2.cxx b/sd/source/ui/view/sdview2.cxx index 81e62d1ba278..710fa4b9147f 100644 --- a/sd/source/ui/view/sdview2.cxx +++ b/sd/source/ui/view/sdview2.cxx @@ -870,20 +870,17 @@ bool View::GetExchangeList (std::vector<OUString> &rExchangeList, SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); ScopedVclPtr<AbstractSvxNameDialog> pDlg(pFact ? pFact->CreateSvxNameDialog(mpViewSh->GetFrameWeld(), aNewName, aDesc) : nullptr); - if (pDlg) - { - pDlg->SetEditHelpId( HID_SD_NAMEDIALOG_OBJECT ); + pDlg->SetEditHelpId( HID_SD_NAMEDIALOG_OBJECT ); - bNameOK = false; - pDlg->SetText( aTitle ); + bNameOK = false; + pDlg->SetText( aTitle ); - while( !bNameOK && pDlg->Execute() == RET_OK ) - { - pDlg->GetName( aNewName ); + while( !bNameOK && pDlg->Execute() == RET_OK ) + { + pDlg->GetName( aNewName ); - if( !mrDoc.GetObj( aNewName ) ) - bNameOK = true; - } + if( !mrDoc.GetObj( aNewName ) ) + bNameOK = true; } } } |