From 6a4c464b49dbfa2801818ead1b50bc9580824d00 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Mon, 19 Feb 2018 16:33:35 +0000 Subject: weld native message dialogs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit just the straight-forward MessageDialog cases first a) remove border_width from message dialog .ui so as to take the default border width b) retain 12 as default message dialog border for vcl widget case c) remove layour_style from message dialog button boxes so as to take the default mode (a no-op for vcl widget case) d) use gtk response ids (vcl builder will converts to vcl ones) Change-Id: I7de281093a1b64f92f71ca11e7cbba42bb658154 Reviewed-on: https://gerrit.libreoffice.org/50143 Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- sfx2/source/appl/appopen.cxx | 10 +++--- sfx2/source/appl/appserv.cxx | 7 ++-- sfx2/source/appl/lnkbase2.cxx | 5 ++- sfx2/source/appl/newhelp.cxx | 16 +++++---- sfx2/source/appl/openuriexternally.cxx | 19 +++++----- sfx2/source/appl/sfxhelp.cxx | 32 ++++------------- sfx2/source/control/templatelocalview.cxx | 28 ++++++++------- sfx2/source/control/templatesearchview.cxx | 14 ++++---- sfx2/source/dialog/dinfdlg.cxx | 6 ++-- sfx2/source/dialog/filedlghelper.cxx | 9 ++--- sfx2/source/dialog/mailmodel.cxx | 7 ++-- sfx2/source/dialog/mgetempl.cxx | 20 +++++++---- sfx2/source/dialog/newstyle.cxx | 14 +++++--- sfx2/source/dialog/passwd.cxx | 13 +++---- sfx2/source/dialog/templdlg.cxx | 12 +++---- sfx2/source/doc/QuerySaveDocument.cxx | 11 +++--- sfx2/source/doc/guisaveas.cxx | 15 ++++---- sfx2/source/doc/objmisc.cxx | 6 ++-- sfx2/source/doc/objserv.cxx | 46 ++++++++++++++++-------- sfx2/source/doc/objxtor.cxx | 3 +- sfx2/source/doc/saveastemplatedlg.cxx | 14 ++++---- sfx2/source/doc/templatedlg.cxx | 45 ++++++++++++++++-------- sfx2/source/inc/alienwarn.hxx | 2 +- sfx2/source/inc/templdgi.hxx | 6 ++++ sfx2/source/view/classificationhelper.cxx | 16 +++++++-- sfx2/source/view/viewfrm.cxx | 56 +++++++++++++----------------- sfx2/source/view/viewprn.cxx | 37 +++++++++++++++----- sfx2/source/view/viewsh.cxx | 24 ++++++++----- sfx2/uiconfig/ui/alienwarndialog.ui | 8 ++--- sfx2/uiconfig/ui/editdocumentdialog.ui | 8 ++--- sfx2/uiconfig/ui/errorfindemaildialog.ui | 2 -- sfx2/uiconfig/ui/helpmanual.ui | 1 - sfx2/uiconfig/ui/querysavedialog.ui | 10 +++--- 33 files changed, 299 insertions(+), 223 deletions(-) (limited to 'sfx2') diff --git a/sfx2/source/appl/appopen.cxx b/sfx2/source/appl/appopen.cxx index c9a4d8ace070..2f3744e3fc04 100644 --- a/sfx2/source/appl/appopen.cxx +++ b/sfx2/source/appl/appopen.cxx @@ -65,6 +65,7 @@ #include #include #include +#include #include #include @@ -837,11 +838,10 @@ void SfxApplication::OpenDocExec_Impl( SfxRequest& rReq ) SolarMutexGuard aGuard; vcl::Window *pWindow = SfxGetpApp()->GetTopWindow(); - ScopedVclPtrInstance aSecurityWarningBox(pWindow, - SfxResId(STR_SECURITY_WARNING_NO_HYPERLINKS), - VclMessageType::Warning); - aSecurityWarningBox->SetText( SfxResId(RID_SECURITY_WARNING_TITLE) ); - aSecurityWarningBox->Execute(); + std::unique_ptr xSecurityWarningBox(Application::CreateMessageDialog(pWindow ? pWindow->GetFrameWeld() : nullptr, + VclMessageType::Warning, VclButtonsType::Ok, SfxResId(STR_SECURITY_WARNING_NO_HYPERLINKS))); + xSecurityWarningBox->set_title(SfxResId(RID_SECURITY_WARNING_TITLE)); + xSecurityWarningBox->run(); return; } diff --git a/sfx2/source/appl/appserv.cxx b/sfx2/source/appl/appserv.cxx index e118bbafae24..f8b08137a326 100644 --- a/sfx2/source/appl/appserv.cxx +++ b/sfx2/source/appl/appserv.cxx @@ -59,8 +59,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -1605,7 +1605,10 @@ void SfxApplication::OfaExec_Impl( SfxRequest& rReq ) SvtModuleOptions aModuleOpt; if ( !aModuleOpt.IsImpress() ) { - ScopedVclPtrInstance( nullptr, SfxResId( STR_MODULENOTINSTALLED ))->Execute(); + std::unique_ptr xBox(Application::CreateMessageDialog(nullptr, + VclMessageType::Warning, VclButtonsType::Ok, + SfxResId(STR_MODULENOTINSTALLED))); + xBox->run(); return; } diff --git a/sfx2/source/appl/lnkbase2.cxx b/sfx2/source/appl/lnkbase2.cxx index cf59639cde9e..82c6129b11bf 100644 --- a/sfx2/source/appl/lnkbase2.cxx +++ b/sfx2/source/appl/lnkbase2.cxx @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -515,7 +516,9 @@ bool SvBaseLink::ExecuteEdit( const OUString& _rNewName ) else return false; - ScopedVclPtrInstance(pImpl->m_pParentWin, sError)->Execute(); + std::unique_ptr xBox(Application::CreateMessageDialog(pImpl->m_pParentWin->GetFrameWeld(), + VclMessageType::Warning, VclButtonsType::Ok, sError)); + xBox->run(); } } else if( !pImpl->m_bIsConnect ) diff --git a/sfx2/source/appl/newhelp.cxx b/sfx2/source/appl/newhelp.cxx index 9ecbf4672d46..61ef0588bf30 100644 --- a/sfx2/source/appl/newhelp.cxx +++ b/sfx2/source/appl/newhelp.cxx @@ -89,10 +89,11 @@ #include #include #include -#include #include #include +#include #include +#include #include #include @@ -1046,8 +1047,10 @@ IMPL_LINK_NOARG(SearchTabPage_Impl, SearchHdl, LinkParamNone*, void) if ( aFactories.empty() ) { - ScopedVclPtrInstance< MessageDialog > aBox(this, SfxResId( STR_INFO_NOSEARCHRESULTS ), VclMessageType::Info); - aBox->Execute(); + std::unique_ptr xBox(Application::CreateMessageDialog(GetFrameWeld(), + VclMessageType::Info, VclButtonsType::Ok, + SfxResId(STR_INFO_NOSEARCHRESULTS))); + xBox->run(); } } } @@ -2265,9 +2268,10 @@ void SfxHelpTextWindow_Impl::FindHdl(sfx2::SearchDialog* pDlg) } else { - DBG_ASSERT( pSrchDlg, "no search dialog" ); - ScopedVclPtrInstance< MessageDialog > aBox(pSrchDlg, SfxResId( STR_INFO_NOSEARCHTEXTFOUND ), VclMessageType::Info); - aBox->Execute(); + assert(pSrchDlg && "no search dialog"); + std::unique_ptr xBox(Application::CreateMessageDialog(pSrchDlg->GetFrameWeld(), + VclMessageType::Info, VclButtonsType::Ok, SfxResId(STR_INFO_NOSEARCHTEXTFOUND))); + xBox->run(); pSrchDlg->SetFocusOnEdit(); } } diff --git a/sfx2/source/appl/openuriexternally.cxx b/sfx2/source/appl/openuriexternally.cxx index 5b3e4821b200..c412d40aeb39 100644 --- a/sfx2/source/appl/openuriexternally.cxx +++ b/sfx2/source/appl/openuriexternally.cxx @@ -21,8 +21,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -57,24 +57,27 @@ bool sfx2::openUriExternally( "unexpected IllegalArgumentException: " + e.Message); } SolarMutexGuard g; - ScopedVclPtrInstance eb( - SfxGetpApp()->GetTopWindow(), SfxResId(STR_NO_ABS_URI_REF)); + vcl::Window *pWindow = SfxGetpApp()->GetTopWindow(); + std::unique_ptr eb(Application::CreateMessageDialog(pWindow ? pWindow->GetFrameWeld() : nullptr, + VclMessageType::Warning, VclButtonsType::Ok, + SfxResId(STR_NO_ABS_URI_REF))); eb->set_primary_text(eb->get_primary_text().replaceFirst("$(ARG1)", uri)); - eb->Execute(); + eb->run(); } catch (css::system::SystemShellExecuteException & e) { if (!handleSystemShellExecuteException) { throw; } SolarMutexGuard g; - ScopedVclPtrInstance eb( - SfxGetpApp()->GetTopWindow(), - SfxResId(STR_NO_WEBBROWSER_FOUND)); + vcl::Window *pWindow = SfxGetpApp()->GetTopWindow(); + std::unique_ptr eb(Application::CreateMessageDialog(pWindow ? pWindow->GetFrameWeld() : nullptr, + VclMessageType::Warning, VclButtonsType::Ok, + SfxResId(STR_NO_WEBBROWSER_FOUND))); eb->set_primary_text( eb->get_primary_text().replaceFirst("$(ARG1)", uri) .replaceFirst("$(ARG2)", OUString::number(e.PosixError)) .replaceFirst("$(ARG3)", e.Message)); //TODO: avoid subsequent replaceFirst acting on previous replacement - eb->Execute(); + eb->run(); } return false; } diff --git a/sfx2/source/appl/sfxhelp.cxx b/sfx2/source/appl/sfxhelp.cxx index 9803d63fdb75..7fe8d968dbe7 100644 --- a/sfx2/source/appl/sfxhelp.cxx +++ b/sfx2/source/appl/sfxhelp.cxx @@ -83,24 +83,6 @@ using namespace ::com::sun::star::util; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::system; -namespace old -{ - class NoHelpErrorBox : public MessageDialog - { - public: - explicit NoHelpErrorBox(vcl::Window* _pParent) - : MessageDialog(_pParent, SfxResId(RID_STR_HLPFILENOTEXIST)) - { - // Error message: "No help available" - } - - virtual void RequestHelp( const HelpEvent& ) override - { - // do nothing, because no help available - } - }; -} - class NoHelpErrorBox { private: @@ -836,14 +818,14 @@ bool SfxHelp::Start_Impl(const OUString& rURL, const vcl::Window* pWindow, const if ( !impl_hasHelpInstalled() ) { - ScopedVclPtrInstance< MessageDialog > aQueryBox(const_cast< vcl::Window* >( pWindow ), - "onlinehelpmanual", "sfx/ui/helpmanual.ui"); + std::unique_ptr xBuilder(Application::CreateBuilder(pWindow ? pWindow->GetFrameWeld() : nullptr, "sfx/ui/helpmanual.ui")); + std::unique_ptr xQueryBox(xBuilder->weld_message_dialog("onlinehelpmanual")); LanguageTag aLangTag = Application::GetSettings().GetUILanguageTag(); OUString sLocaleString = SvtLanguageTable::GetLanguageString( aLangTag.getLanguageType() ); - OUString sPrimTex = aQueryBox->get_primary_text(); - aQueryBox->set_primary_text(sPrimTex.replaceAll("$UILOCALE", sLocaleString)); - short OnlineHelpBox = aQueryBox->Execute(); + OUString sPrimTex = xQueryBox->get_primary_text(); + xQueryBox->set_primary_text(sPrimTex.replaceAll("$UILOCALE", sLocaleString)); + short OnlineHelpBox = xQueryBox->run(); if(OnlineHelpBox == RET_OK) { @@ -851,8 +833,8 @@ bool SfxHelp::Start_Impl(const OUString& rURL, const vcl::Window* pWindow, const return true; else { - ScopedVclPtrInstance< old::NoHelpErrorBox > aErrBox(const_cast< vcl::Window* >( pWindow )); - aErrBox->Execute(); + NoHelpErrorBox aErrBox(pWindow ? pWindow->GetFrameWeld() : nullptr); + aErrBox.run(); return false; } } diff --git a/sfx2/source/control/templatelocalview.cxx b/sfx2/source/control/templatelocalview.cxx index ec4321606bfb..b95a7f60c535 100644 --- a/sfx2/source/control/templatelocalview.cxx +++ b/sfx2/source/control/templatelocalview.cxx @@ -23,7 +23,8 @@ #include #include #include -#include +#include +#include #include #include @@ -281,8 +282,9 @@ IMPL_LINK(TemplateLocalView, ContextMenuSelectHdl, Menu*, pMenu, bool) break; case MNI_DELETE: { - ScopedVclPtrInstance< MessageDialog > aQueryDlg(this, SfxResId(STR_QMSG_SEL_TEMPLATE_DELETE), VclMessageType::Question, VclButtonsType::YesNo); - if ( aQueryDlg->Execute() != RET_YES ) + std::unique_ptr xQueryDlg(Application::CreateMessageDialog(GetFrameWeld(), VclMessageType::Question, VclButtonsType::YesNo, + SfxResId(STR_QMSG_SEL_TEMPLATE_DELETE))); + if (xQueryDlg->run() != RET_YES) break; maDeleteTemplateHdl.Call(maSelectedItem); @@ -511,8 +513,9 @@ bool TemplateLocalView::moveTemplate (const ThumbnailViewItem *pItem, const sal_ { OUString sQuery = SfxResId(STR_MSG_QUERY_COPY).replaceFirst("$1", pViewItem->maTitle).replaceFirst("$2", getRegionName(nTargetRegion)); - ScopedVclPtrInstance< MessageDialog > aQueryDlg(this, sQuery, VclMessageType::Question, VclButtonsType::YesNo); - if ( aQueryDlg->Execute() != RET_YES ) + + std::unique_ptr xQueryDlg(Application::CreateMessageDialog(GetFrameWeld(), VclMessageType::Question, VclButtonsType::YesNo, sQuery)); + if (xQueryDlg->run() != RET_YES) return false; if (!mpDocTemplates->Copy(nTargetRegion,nTargetIdx,nSrcRegionId,pViewItem->mnDocId)) @@ -609,13 +612,14 @@ void TemplateLocalView::moveTemplates(const std::setmaTitle).replaceFirst("$2", getRegionName(nTargetRegion)); - ScopedVclPtrInstance< MessageDialog > aQueryDlg(this, sQuery, VclMessageType::Question, VclButtonsType::YesNo); - - if ( aQueryDlg->Execute() != RET_YES ) + std::unique_ptr xQueryDlg(Application::CreateMessageDialog(GetFrameWeld(), VclMessageType::Question, VclButtonsType::YesNo, sQuery)); + if (xQueryDlg->run() != RET_YES) { OUString sMsg(SfxResId(STR_MSG_ERROR_LOCAL_MOVE)); sMsg = sMsg.replaceFirst("$1",getRegionName(nTargetRegion)); - ScopedVclPtrInstance(this, sMsg.replaceFirst( "$2",pViewItem->maTitle))->Execute(); + std::unique_ptr xBox(Application::CreateMessageDialog(GetFrameWeld(), + VclMessageType::Warning, VclButtonsType::Ok, sMsg.replaceFirst( "$2",pViewItem->maTitle))); + xBox->run(); return; //return if any single move operation fails } @@ -890,9 +894,9 @@ void TemplateLocalView::KeyInput( const KeyEvent& rKEvt ) } else if( aKeyCode == KEY_DELETE && !mFilteredItemList.empty()) { - ScopedVclPtrInstance< MessageDialog > aQueryDlg(this, SfxResId(STR_QMSG_SEL_TEMPLATE_DELETE), VclMessageType::Question, VclButtonsType::YesNo); - - if ( aQueryDlg->Execute() != RET_YES ) + std::unique_ptr xQueryDlg(Application::CreateMessageDialog(GetFrameWeld(), VclMessageType::Question, VclButtonsType::YesNo, + SfxResId(STR_QMSG_SEL_TEMPLATE_DELETE))); + if (xQueryDlg->run() != RET_YES) return; //copy to avoid changing filtered item list during deletion diff --git a/sfx2/source/control/templatesearchview.cxx b/sfx2/source/control/templatesearchview.cxx index 374a3b268ef3..ace6b4fcb32e 100644 --- a/sfx2/source/control/templatesearchview.cxx +++ b/sfx2/source/control/templatesearchview.cxx @@ -12,7 +12,8 @@ #include #include #include -#include +#include +#include #include #include @@ -60,9 +61,9 @@ void TemplateSearchView::KeyInput( const KeyEvent& rKEvt ) } else if( aKeyCode == KEY_DELETE && !mFilteredItemList.empty()) { - ScopedVclPtrInstance< MessageDialog > aQueryDlg(this, SfxResId(STR_QMSG_SEL_TEMPLATE_DELETE), VclMessageType::Question, VclButtonsType::YesNo); - - if ( aQueryDlg->Execute() != RET_YES ) + std::unique_ptr xQueryDlg(Application::CreateMessageDialog(GetFrameWeld(), VclMessageType::Question, VclButtonsType::YesNo, + SfxResId(STR_QMSG_SEL_TEMPLATE_DELETE))); + if (xQueryDlg->run() != RET_YES) return; //copy to avoid changing filtered item list during deletion @@ -159,8 +160,9 @@ IMPL_LINK(TemplateSearchView, ContextMenuSelectHdl, Menu*, pMenu, bool) break; case MNI_DELETE: { - ScopedVclPtrInstance< MessageDialog > aQueryDlg(this, SfxResId(STR_QMSG_SEL_TEMPLATE_DELETE), VclMessageType::Question, VclButtonsType::YesNo); - if ( aQueryDlg->Execute() != RET_YES ) + std::unique_ptr xQueryDlg(Application::CreateMessageDialog(GetFrameWeld(), VclMessageType::Question, VclButtonsType::YesNo, + SfxResId(STR_QMSG_SEL_TEMPLATE_DELETE))); + if (xQueryDlg->run() != RET_YES) break; maDeleteTemplateHdl.Call(maSelectedItem); diff --git a/sfx2/source/dialog/dinfdlg.cxx b/sfx2/source/dialog/dinfdlg.cxx index 91e21b80360a..d7703f62a73e 100644 --- a/sfx2/source/dialog/dinfdlg.cxx +++ b/sfx2/source/dialog/dinfdlg.cxx @@ -21,9 +21,9 @@ #include #include #include -#include #include #include +#include #include #include #include @@ -1658,7 +1658,9 @@ void CustomPropertiesWindow::ValidateLine( CustomPropertyLine* pLine, bool bIsFr if ( bIsFromTypeBox ) // LoseFocus of TypeBox pLine->m_bTypeLostFocus = true; vcl::Window* pParent = GetParent()->GetParent(); - if (ScopedVclPtrInstance(pParent, SfxResId(STR_SFX_QUERY_WRONG_TYPE), VclMessageType::Question, VclButtonsType::OkCancel)->Execute() == RET_OK) + std::unique_ptr xMessageBox(Application::CreateMessageDialog(pParent ? pParent->GetFrameWeld() : nullptr, + VclMessageType::Question, VclButtonsType::OkCancel, SfxResId(STR_SFX_QUERY_WRONG_TYPE))); + if (xMessageBox->run() == RET_OK) pLine->m_aTypeBox->SelectEntryPos(pLine->m_aTypeBox->GetEntryPos(reinterpret_cast(CUSTOM_TYPE_TEXT))); else pLine->m_aValueEdit->GrabFocus(); diff --git a/sfx2/source/dialog/filedlghelper.cxx b/sfx2/source/dialog/filedlghelper.cxx index 3d20a6a3333d..32249bd1db6b 100644 --- a/sfx2/source/dialog/filedlghelper.cxx +++ b/sfx2/source/dialog/filedlghelper.cxx @@ -51,6 +51,7 @@ #include #include #include +#include #include #include #include @@ -1540,10 +1541,10 @@ ErrCode FileDialogHelper_Impl::execute( std::vector& rpURLList, } catch( const IllegalArgumentException& ) { - ScopedVclPtrInstance< MessageDialog > aBox( - mpPreferredParentWindow, - SfxResId(RID_SVXSTR_GPG_ENCRYPT_FAILURE)); - aBox->Execute(); + std::unique_ptr xBox(Application::CreateMessageDialog(mpPreferredParentWindow ? mpPreferredParentWindow->GetFrameWeld() : nullptr, + VclMessageType::Warning, VclButtonsType::Ok, + SfxResId(RID_SVXSTR_GPG_ENCRYPT_FAILURE))); + xBox->run(); } } diff --git a/sfx2/source/dialog/mailmodel.cxx b/sfx2/source/dialog/mailmodel.cxx index 00fdcb0a2264..aa712142cf6b 100644 --- a/sfx2/source/dialog/mailmodel.cxx +++ b/sfx2/source/dialog/mailmodel.cxx @@ -52,7 +52,7 @@ #include #include #include -#include +#include #include #include @@ -784,8 +784,9 @@ SfxMailModel::SendMailResult SfxMailModel::Send( const css::uno::Reference< css: SolarMutexGuard aGuard; VclPtr pParentWindow = VCLUnoHelper::GetWindow( xParentWindow ); - ScopedVclPtrInstance< MessageDialog > aBox(pParentWindow, "ErrorFindEmailDialog", "sfx/ui/errorfindemaildialog.ui"); - aBox->Execute(); + std::unique_ptr xBuilder(Application::CreateBuilder(pParentWindow ? pParentWindow->GetFrameWeld() : nullptr, "sfx/ui/errorfindemaildialog.ui")); + std::unique_ptr xBox(xBuilder->weld_message_dialog("ErrorFindEmailDialog")); + xBox->run(); eResult = SEND_MAIL_CANCELLED; } else diff --git a/sfx2/source/dialog/mgetempl.cxx b/sfx2/source/dialog/mgetempl.cxx index 1dc87a2c537d..6268c5d61ace 100644 --- a/sfx2/source/dialog/mgetempl.cxx +++ b/sfx2/source/dialog/mgetempl.cxx @@ -18,7 +18,7 @@ */ #include -#include +#include #include #include #include @@ -602,8 +602,10 @@ DeactivateRC SfxManageStyleSheetPage::DeactivatePage( SfxItemSet* pItemSet ) if (!pStyle->SetName(comphelper::string::stripStart(m_pNameRw->GetText(), ' '))) { - ScopedVclPtrInstance< MessageDialog > aBox(this, SfxResId( STR_TABPAGE_INVALIDNAME ), VclMessageType::Info); - aBox->Execute(); + std::unique_ptr xBox(Application::CreateMessageDialog(GetFrameWeld(), + VclMessageType::Info, VclButtonsType::Ok, + SfxResId(STR_TABPAGE_INVALIDNAME))); + xBox->run(); m_pNameRw->GrabFocus(); m_pNameRw->SetSelection( Selection( SELECTION_MIN, SELECTION_MAX ) ); return DeactivateRC::KeepPage; @@ -619,8 +621,10 @@ DeactivateRC SfxManageStyleSheetPage::DeactivatePage( SfxItemSet* pItemSet ) { if ( !pStyle->SetFollow( aFollowEntry ) ) { - ScopedVclPtrInstance< MessageDialog > aBox(this, SfxResId( STR_TABPAGE_INVALIDSTYLE ), VclMessageType::Info); - aBox->Execute(); + std::unique_ptr xBox(Application::CreateMessageDialog(GetFrameWeld(), + VclMessageType::Info, VclButtonsType::Ok, + SfxResId(STR_TABPAGE_INVALIDSTYLE))); + xBox->run(); m_pFollowLb->GrabFocus(); return DeactivateRC::KeepPage; } @@ -639,8 +643,10 @@ DeactivateRC SfxManageStyleSheetPage::DeactivatePage( SfxItemSet* pItemSet ) { if ( !pStyle->SetParent( aParentEntry ) ) { - ScopedVclPtrInstance< MessageDialog > aBox(this, SfxResId( STR_TABPAGE_INVALIDPARENT ), VclMessageType::Info); - aBox->Execute(); + std::unique_ptr xBox(Application::CreateMessageDialog(GetFrameWeld(), + VclMessageType::Info, VclButtonsType::Ok, + SfxResId(STR_TABPAGE_INVALIDPARENT))); + xBox->run(); m_pBaseLb->GrabFocus(); return DeactivateRC::KeepPage; } diff --git a/sfx2/source/dialog/newstyle.cxx b/sfx2/source/dialog/newstyle.cxx index 76dd62b0539d..e72f454a0795 100644 --- a/sfx2/source/dialog/newstyle.cxx +++ b/sfx2/source/dialog/newstyle.cxx @@ -25,6 +25,7 @@ #include #include #include +#include // Private methods ------------------------------------------------------ @@ -40,11 +41,14 @@ IMPL_LINK_NOARG( SfxNewStyleDlg, OKHdl, ComboBox&, void ) { if ( !pStyle->IsUserDefined() ) { - ScopedVclPtrInstance( this, SfxResId( STR_POOL_STYLE_NAME ), VclMessageType::Info )->Execute(); + std::unique_ptr xBox(Application::CreateMessageDialog(GetFrameWeld(), + VclMessageType::Info, VclButtonsType::Ok, + SfxResId(STR_POOL_STYLE_NAME))); + xBox->run(); return; } - if ( RET_YES == aQueryOverwriteBox->Execute() ) + if (RET_YES == xQueryOverwriteBox->run()) EndDialog( RET_OK ); } else @@ -58,8 +62,8 @@ IMPL_LINK( SfxNewStyleDlg, ModifyHdl, Edit&, rBox, void ) SfxNewStyleDlg::SfxNewStyleDlg( vcl::Window* pParent, SfxStyleSheetBasePool& rInPool ) : ModalDialog(pParent, "CreateStyleDialog", "sfx/ui/newstyle.ui") - , aQueryOverwriteBox(VclPtr::Create(this, SfxResId(STR_QUERY_OVERWRITE), - VclMessageType::Question, VclButtonsType::YesNo)) + , xQueryOverwriteBox(Application::CreateMessageDialog(GetFrameWeld(), VclMessageType::Question, VclButtonsType::YesNo, + SfxResId(STR_QUERY_OVERWRITE))) , rPool(rInPool) { get(m_pColBox, "stylename"); @@ -86,7 +90,7 @@ SfxNewStyleDlg::~SfxNewStyleDlg() void SfxNewStyleDlg::dispose() { - aQueryOverwriteBox.disposeAndClear(); + xQueryOverwriteBox.reset(); m_pColBox.clear(); m_pOKBtn.clear(); ModalDialog::dispose(); diff --git a/sfx2/source/dialog/passwd.cxx b/sfx2/source/dialog/passwd.cxx index 347629fc7615..8c0f2378329c 100644 --- a/sfx2/source/dialog/passwd.cxx +++ b/sfx2/source/dialog/passwd.cxx @@ -17,16 +17,11 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ - -// Include --------------------------------------------------------------- -#include - #include #include #include - #include - +#include IMPL_LINK( SfxPasswordDialog, EditModifyHdl, Edit&, rEdit, void ) { @@ -71,8 +66,10 @@ IMPL_LINK_NOARG(SfxPasswordDialog, OKHdl, Button*, void) bConfirmFailed = true; if ( bConfirmFailed ) { - ScopedVclPtrInstance< MessageDialog > aBox(this, SfxResId(STR_ERROR_WRONG_CONFIRM)); - aBox->Execute(); + std::unique_ptr xBox(Application::CreateMessageDialog(GetFrameWeld(), + VclMessageType::Warning, VclButtonsType::Ok, + SfxResId(STR_ERROR_WRONG_CONFIRM))); + xBox->run(); mpConfirm1ED->SetText( OUString() ); mpConfirm1ED->GrabFocus(); } diff --git a/sfx2/source/dialog/templdlg.cxx b/sfx2/source/dialog/templdlg.cxx index 38d9fd8b4cc4..412b02f35110 100644 --- a/sfx2/source/dialog/templdlg.cxx +++ b/sfx2/source/dialog/templdlg.cxx @@ -1885,14 +1885,10 @@ void SfxCommonTemplateDialog_Impl::DeleteHdl() // we only want to show the dialog once and if we want to delete a style in use (UX-advice) if ( bUsedStyle ) { - #if defined UNX - ScopedVclPtrInstance aBox(SfxGetpApp()->GetTopWindow(), aMsg, - VclMessageType::Question, VclButtonsType::YesNo); - #else - ScopedVclPtrInstance aBox(GetWindow(), aMsg, - VclMessageType::Question, VclButtonsType::YesNo); - #endif - aApproved = aBox->Execute() == RET_YES; + std::unique_ptr xBox(Application::CreateMessageDialog(GetFrameWeld(), + VclMessageType::Question, VclButtonsType::YesNo, + aMsg)); + aApproved = xBox->run() == RET_YES; } // if there are no used styles selected or the user approved the changes diff --git a/sfx2/source/doc/QuerySaveDocument.cxx b/sfx2/source/doc/QuerySaveDocument.cxx index a6f5ec97b73f..9d66a164563c 100644 --- a/sfx2/source/doc/QuerySaveDocument.cxx +++ b/sfx2/source/doc/QuerySaveDocument.cxx @@ -18,10 +18,10 @@ */ #include -#include #include +#include -short ExecuteQuerySaveDocument(vcl::Window* _pParent, const OUString& _rTitle) +short ExecuteQuerySaveDocument(weld::Widget* _pParent, const OUString& _rTitle) { if (Application::IsHeadlessModeEnabled()) { @@ -29,9 +29,10 @@ short ExecuteQuerySaveDocument(vcl::Window* _pParent, const OUString& _rTitle) return RET_NO; } - ScopedVclPtrInstance< MessageDialog > aQBox(_pParent, "QuerySaveDialog", "sfx/ui/querysavedialog.ui"); - aQBox->set_primary_text(aQBox->get_primary_text().replaceFirst("$(DOC)", _rTitle)); - return aQBox->Execute(); + std::unique_ptr xBuilder(Application::CreateBuilder(_pParent, "sfx/ui/querysavedialog.ui")); + std::unique_ptr xQBox(xBuilder->weld_message_dialog("QuerySaveDialog")); + xQBox->set_primary_text(xQBox->get_primary_text().replaceFirst("$(DOC)", _rTitle)); + return xQBox->run(); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/doc/guisaveas.cxx b/sfx2/source/doc/guisaveas.cxx index 4f878d32f14d..824f8598f3cc 100644 --- a/sfx2/source/doc/guisaveas.cxx +++ b/sfx2/source/doc/guisaveas.cxx @@ -64,7 +64,7 @@ #include #include #include -#include +#include #include #include #include @@ -666,10 +666,10 @@ sal_Int8 ModelData_Impl::CheckSaveAcceptable( sal_Int8 nCurStatus ) && GetMediaDescr().find( OUString("VersionComment") ) == GetMediaDescr().end() ) { // notify the user that SaveAs is going to be done - vcl::Window* pWin = SfxStoringHelper::GetModelWindow( m_xModel ); - ScopedVclPtrInstance aMessageBox(pWin, SfxResId(STR_NEW_FILENAME_SAVE), - VclMessageType::Question, VclButtonsType::OkCancel); - if ( aMessageBox->Execute() == RET_OK ) + vcl::Window* pWin = SfxStoringHelper::GetModelWindow(m_xModel); + std::unique_ptr xMessageBox(Application::CreateMessageDialog(pWin ? pWin->GetFrameWeld() : nullptr, + VclMessageType::Question, VclButtonsType::OkCancel, SfxResId(STR_NEW_FILENAME_SAVE))); + if (xMessageBox->run() == RET_OK) nResult = STATUS_SAVEAS; else nResult = STATUS_NO_ACTION; @@ -1388,8 +1388,9 @@ bool SfxStoringHelper::GUIStoreModel( const uno::Reference< frame::XModel >& xMo || SignatureState::NOTVALIDATED == nDocumentSignatureState || SignatureState::PARTIAL_OK == nDocumentSignatureState) { - if (ScopedVclPtrInstance(nullptr, SfxResId(RID_SVXSTR_XMLSEC_QUERY_LOSINGSIGNATURE), - VclMessageType::Question, VclButtonsType::YesNo)->Execute() != RET_YES) + std::unique_ptr xMessageBox(Application::CreateMessageDialog(nullptr, + VclMessageType::Question, VclButtonsType::YesNo, SfxResId(RID_SVXSTR_XMLSEC_QUERY_LOSINGSIGNATURE))); + if (xMessageBox->run() != RET_YES) { // the user has decided not to store the document throw task::ErrorCodeIOException( diff --git a/sfx2/source/doc/objmisc.cxx b/sfx2/source/doc/objmisc.cxx index 52af0eb7a3c1..2d59f8fc6bbe 100644 --- a/sfx2/source/doc/objmisc.cxx +++ b/sfx2/source/doc/objmisc.cxx @@ -63,6 +63,7 @@ #include #include #include +#include #include #include #include @@ -1826,8 +1827,9 @@ bool SfxObjectShell::IsContinueImportOnFilterExceptions(const OUString& aErrMess if (!aErrMessage.isEmpty()) aMessage += SfxResId(STR_QMSG_ERROR_OPENING_FILE_DETAILS) + aErrMessage; aMessage += SfxResId(STR_QMSG_ERROR_OPENING_FILE_CONTINUE); - ScopedVclPtrInstance< MessageDialog > aBox(nullptr, aMessage, VclMessageType::Question, VclButtonsType::YesNo); - mbContinueImportOnFilterExceptions = (aBox->Execute() == RET_YES) ? yes : no; + std::unique_ptr xBox(Application::CreateMessageDialog(nullptr, + VclMessageType::Question, VclButtonsType::YesNo, aMessage)); + mbContinueImportOnFilterExceptions = (xBox->run() == RET_YES) ? yes : no; } else mbContinueImportOnFilterExceptions = no; diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx index 51e1a1ecfe16..c69cbe927643 100644 --- a/sfx2/source/doc/objserv.cxx +++ b/sfx2/source/doc/objserv.cxx @@ -45,10 +45,10 @@ #include #include #include -#include #include #include #include +#include #include #include #include @@ -319,8 +319,9 @@ void SfxObjectShell::CheckOut( ) } catch ( const uno::RuntimeException& e ) { - ScopedVclPtrInstance< MessageDialog > pErrorBox( &GetFrame()->GetWindow(), e.Message ); - pErrorBox->Execute( ); + std::unique_ptr xBox(Application::CreateMessageDialog(GetFrame()->GetWindow().GetFrameWeld(), + VclMessageType::Warning, VclButtonsType::Ok, e.Message)); + xBox->run(); } } @@ -337,8 +338,9 @@ void SfxObjectShell::CancelCheckOut( ) } catch ( const uno::RuntimeException& e ) { - ScopedVclPtrInstance< MessageDialog > pErrorBox(&GetFrame()->GetWindow(), e.Message); - pErrorBox->Execute( ); + std::unique_ptr xBox(Application::CreateMessageDialog(GetFrame()->GetWindow().GetFrameWeld(), + VclMessageType::Warning, VclButtonsType::Ok, e.Message)); + xBox->run(); } } @@ -359,8 +361,9 @@ void SfxObjectShell::CheckIn( ) } catch ( const uno::RuntimeException& e ) { - ScopedVclPtrInstance< MessageDialog > pErrorBox(&GetFrame()->GetWindow(), e.Message); - pErrorBox->Execute( ); + std::unique_ptr xBox(Application::CreateMessageDialog(GetFrame()->GetWindow().GetFrameWeld(), + VclMessageType::Warning, VclButtonsType::Ok, e.Message)); + xBox->run(); } } @@ -373,8 +376,9 @@ uno::Sequence< document::CmisVersion > SfxObjectShell::GetCmisVersions( ) } catch ( const uno::RuntimeException& e ) { - ScopedVclPtrInstance< MessageDialog > pErrorBox(&GetFrame()->GetWindow(), e.Message); - pErrorBox->Execute( ); + std::unique_ptr xBox(Application::CreateMessageDialog(GetFrame()->GetWindow().GetFrameWeld(), + VclMessageType::Warning, VclButtonsType::Ok, e.Message)); + xBox->run(); } return uno::Sequence< document::CmisVersion > ( ); } @@ -795,7 +799,9 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq) } case SID_CANCELCHECKOUT: { - if (ScopedVclPtrInstance(nullptr, SfxResId(STR_QUERY_CANCELCHECKOUT), VclMessageType::Question, VclButtonsType::YesNo)->Execute() == RET_YES) + std::unique_ptr xBox(Application::CreateMessageDialog(nullptr, + VclMessageType::Question, VclButtonsType::YesNo, SfxResId(STR_QUERY_CANCELCHECKOUT))); + if (xBox->run() == RET_YES) { CancelCheckOut( ); @@ -1344,7 +1350,10 @@ void SfxObjectShell::ImplSign( bool bScriptingContent ) ) { // Only OASIS and OOo6.x formats will be handled further - ScopedVclPtrInstance( nullptr, SfxResId( STR_INFO_WRONGDOCFORMAT ), VclMessageType::Info )->Execute(); + std::unique_ptr xBox(Application::CreateMessageDialog(nullptr, + VclMessageType::Info, VclButtonsType::Ok, SfxResId(STR_INFO_WRONGDOCFORMAT))); + + xBox->run(); return; } @@ -1388,9 +1397,12 @@ void SfxObjectShell::ImplSign( bool bScriptingContent ) if ( nVersion >= SvtSaveOptions::ODFVER_012 ) { + OUString sQuestion(bHasSign ? SfxResId(STR_XMLSEC_QUERY_SAVESIGNEDBEFORESIGN) : SfxResId(RID_SVXSTR_XMLSEC_QUERY_SAVEBEFORESIGN)); + std::unique_ptr xQuestion(Application::CreateMessageDialog(nullptr, + VclMessageType::Question, VclButtonsType::YesNo, sQuestion)); + - if ( (bHasSign && ScopedVclPtrInstance(nullptr, SfxResId(STR_XMLSEC_QUERY_SAVESIGNEDBEFORESIGN), VclMessageType::Question, VclButtonsType::YesNo)->Execute() == RET_YES) - || (!bHasSign && ScopedVclPtrInstance(nullptr, SfxResId(RID_SVXSTR_XMLSEC_QUERY_SAVEBEFORESIGN), VclMessageType::Question, VclButtonsType::YesNo)->Execute() == RET_YES) ) + if (xQuestion->run() == RET_YES) { sal_uInt16 nId = SID_SAVEDOC; if ( !GetMedium() || GetMedium()->GetName().isEmpty() ) @@ -1406,7 +1418,9 @@ void SfxObjectShell::ImplSign( bool bScriptingContent ) || SotStorage::GetVersion( GetMedium()->GetStorage() ) <= SOFFICE_FILEFORMAT_60 ) ) { // Only OASIS format will be handled further - ScopedVclPtrInstance( nullptr, SfxResId( STR_INFO_WRONGDOCFORMAT ), VclMessageType::Info )->Execute(); + std::unique_ptr xBox(Application::CreateMessageDialog(nullptr, + VclMessageType::Info, VclButtonsType::Ok, SfxResId(STR_INFO_WRONGDOCFORMAT))); + xBox->run(); return; } } @@ -1421,7 +1435,9 @@ void SfxObjectShell::ImplSign( bool bScriptingContent ) } else { - ScopedVclPtrInstance(nullptr, SfxResId(STR_XMLSEC_ODF12_EXPECTED))->Execute(); + std::unique_ptr xBox(Application::CreateMessageDialog(nullptr, + VclMessageType::Warning, VclButtonsType::Ok, SfxResId(STR_XMLSEC_ODF12_EXPECTED))); + xBox->run(); return; } diff --git a/sfx2/source/doc/objxtor.cxx b/sfx2/source/doc/objxtor.cxx index f22557e7ce24..53ec4e2af9c6 100644 --- a/sfx2/source/doc/objxtor.cxx +++ b/sfx2/source/doc/objxtor.cxx @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -576,7 +577,7 @@ bool SfxObjectShell::PrepareClose { const Reference< XTitle > xTitle( *pImpl->pBaseModel.get(), UNO_QUERY_THROW ); const OUString sTitle = xTitle->getTitle (); - nRet = ExecuteQuerySaveDocument(&pFrame->GetWindow(),sTitle); + nRet = ExecuteQuerySaveDocument(pFrame->GetWindow().GetFrameWeld(), sTitle); } /*HACK for plugin::destroy()*/ diff --git a/sfx2/source/doc/saveastemplatedlg.cxx b/sfx2/source/doc/saveastemplatedlg.cxx index 8096f60b9de9..168c39bc7e79 100644 --- a/sfx2/source/doc/saveastemplatedlg.cxx +++ b/sfx2/source/doc/saveastemplatedlg.cxx @@ -19,8 +19,8 @@ #include #include #include -#include #include +#include #include #include @@ -77,15 +77,15 @@ void SfxSaveAsTemplateDialog::setDocumentModel(const uno::Reference aQueryDlg(this, OUString(), VclMessageType::Question, VclButtonsType::YesNo); - + std::unique_ptr xQueryDlg(Application::CreateMessageDialog(GetFrameWeld(), VclMessageType::Question, VclButtonsType::YesNo, + OUString())); if(!IsTemplateNameUnique()) { OUString sQueryMsg(SfxResId(STR_QMSG_TEMPLATE_OVERWRITE)); sQueryMsg = sQueryMsg.replaceFirst("$1",msTemplateName); - aQueryDlg->set_primary_text(sQueryMsg.replaceFirst("$2", msSelectedCategory)); + xQueryDlg->set_primary_text(sQueryMsg.replaceFirst("$2", msSelectedCategory)); - if( aQueryDlg->Execute() == RET_NO ) + if (xQueryDlg->run() == RET_NO) return; } @@ -94,7 +94,9 @@ IMPL_LINK_NOARG(SfxSaveAsTemplateDialog, OkClickHdl, Button*, void) else { OUString sText( SfxResId(STR_ERROR_SAVEAS) ); - ScopedVclPtrInstance(this, sText.replaceFirst("$1", msTemplateName))->Execute(); + std::unique_ptr xBox(Application::CreateMessageDialog(GetFrameWeld(), VclMessageType::Warning, VclButtonsType::Ok, + sText.replaceFirst("$1", msTemplateName))); + xBox->run(); } } diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx index 6ab085296433..a5388e1a5649 100644 --- a/sfx2/source/doc/templatedlg.cxx +++ b/sfx2/source/doc/templatedlg.cxx @@ -36,9 +36,9 @@ #include #include #include -#include #include #include +#include #include #include @@ -630,7 +630,9 @@ IMPL_LINK_NOARG(SfxTemplateManagerDlg, ImportClickHdl, Button*, void) else { OUString aMsg( SfxResId(STR_CREATE_ERROR) ); - ScopedVclPtrInstance(this, aMsg.replaceFirst("$1", sCategory))->Execute(); + std::unique_ptr xBox(Application::CreateMessageDialog(GetFrameWeld(), VclMessageType::Warning, VclButtonsType::Ok, + aMsg.replaceFirst("$1", sCategory))); + xBox->run(); return; } } @@ -748,7 +750,9 @@ IMPL_LINK(SfxTemplateManagerDlg, DeleteTemplateHdl, ThumbnailViewItem*, pItem, v if (!aDeletedTemplate.isEmpty()) { OUString aMsg( SfxResId(STR_MSG_ERROR_DELETE_TEMPLATE) ); - ScopedVclPtrInstance(this, aMsg.replaceFirst("$1",aDeletedTemplate))->Execute(); + std::unique_ptr xBox(Application::CreateMessageDialog(GetFrameWeld(), VclMessageType::Warning, VclButtonsType::Ok, + aMsg.replaceFirst("$1",aDeletedTemplate))); + xBox->run(); } } @@ -967,7 +971,9 @@ void SfxTemplateManagerDlg::OnTemplateImportCategory(const OUString& sCategory) { OUString aMsg(SfxResId(STR_MSG_ERROR_IMPORT)); aMsg = aMsg.replaceFirst("$1",pContItem->maTitle); - ScopedVclPtrInstance(this, aMsg.replaceFirst("$2",aTemplateList))->Execute(); + std::unique_ptr xBox(Application::CreateMessageDialog(GetFrameWeld(), VclMessageType::Warning, VclButtonsType::Ok, + aMsg.replaceFirst("$2",aTemplateList))); + xBox->run(); } } } @@ -1056,12 +1062,16 @@ void SfxTemplateManagerDlg::OnTemplateExport() if (!aTemplateList.isEmpty()) { OUString aText( SfxResId(STR_MSG_ERROR_EXPORT) ); - ScopedVclPtrInstance(this, aText.replaceFirst("$1",aTemplateList))->Execute(); + std::unique_ptr xBox(Application::CreateMessageDialog(GetFrameWeld(), VclMessageType::Warning, VclButtonsType::Ok, + aText.replaceFirst("$1",aTemplateList))); + xBox->run(); } else { OUString sText( SfxResId(STR_MSG_EXPORT_SUCCESS) ); - ScopedVclPtrInstance(this, sText.replaceFirst("$1", OUString::number(nCount)), VclMessageType::Info)->Execute(); + std::unique_ptr xBox(Application::CreateMessageDialog(GetFrameWeld(), VclMessageType::Info, VclButtonsType::Ok, + sText.replaceFirst("$1", OUString::number(nCount)))); + xBox->run(); } } } @@ -1117,7 +1127,9 @@ void SfxTemplateManagerDlg::OnCategoryNew() else { OUString aMsg( SfxResId(STR_CREATE_ERROR) ); - ScopedVclPtrInstance(this, aMsg.replaceFirst("$1", aName))->Execute(); + std::unique_ptr xBox(Application::CreateMessageDialog(GetFrameWeld(), VclMessageType::Warning, VclButtonsType::Ok, + aMsg.replaceFirst("$1", aName))); + xBox->run(); } } } @@ -1147,7 +1159,9 @@ void SfxTemplateManagerDlg::OnCategoryRename() else { OUString aMsg( SfxResId(STR_CREATE_ERROR) ); - ScopedVclPtrInstance(this, aMsg.replaceFirst("$1", aName))->Execute(); + std::unique_ptr xBox(Application::CreateMessageDialog(GetFrameWeld(), VclMessageType::Warning, VclButtonsType::Ok, + aMsg.replaceFirst("$1", aName))); + xBox->run(); } } } @@ -1164,10 +1178,9 @@ void SfxTemplateManagerDlg::OnCategoryDelete() { OUString sCategory = aDlg->GetSelectedCategory(); aDlg.disposeAndClear(); - ScopedVclPtrInstance< MessageDialog > popupDlg(this, SfxResId(STR_QMSG_SEL_FOLDER_DELETE), - VclMessageType::Question, VclButtonsType::YesNo); - - if ( popupDlg->Execute() != RET_YES ) + std::unique_ptr popupDlg(Application::CreateMessageDialog(GetFrameWeld(), VclMessageType::Question, VclButtonsType::YesNo, + SfxResId(STR_QMSG_SEL_FOLDER_DELETE))); + if (popupDlg->run() != RET_YES) return; sal_Int16 nItemId = mpLocalView->getRegionId(sCategory); @@ -1175,7 +1188,9 @@ void SfxTemplateManagerDlg::OnCategoryDelete() if (!mpLocalView->removeRegion(nItemId)) { OUString sMsg( SfxResId(STR_MSG_ERROR_DELETE_FOLDER) ); - ScopedVclPtrInstance(this, sMsg.replaceFirst("$1",sCategory))->Execute(); + std::unique_ptr xBox(Application::CreateMessageDialog(GetFrameWeld(), VclMessageType::Warning, VclButtonsType::Ok, + sMsg.replaceFirst("$1",sCategory))); + xBox->run(); } else { @@ -1241,7 +1256,9 @@ void SfxTemplateManagerDlg::localSearchMoveTo(sal_uInt16 nItemId) OUString sDst = mpLocalView->getRegionItemName(nItemId); OUString sMsg(SfxResId(STR_MSG_ERROR_LOCAL_MOVE)); sMsg = sMsg.replaceFirst("$1",sDst); - ScopedVclPtrInstance(this, sMsg.replaceFirst( "$2",pItem->maTitle))->Execute(); + std::unique_ptr xBox(Application::CreateMessageDialog(GetFrameWeld(), VclMessageType::Warning, VclButtonsType::Ok, + sMsg.replaceFirst( "$2",pItem->maTitle))); + xBox->run(); } } } diff --git a/sfx2/source/inc/alienwarn.hxx b/sfx2/source/inc/alienwarn.hxx index fc4a52bfad1a..7d2414aad8bc 100644 --- a/sfx2/source/inc/alienwarn.hxx +++ b/sfx2/source/inc/alienwarn.hxx @@ -20,7 +20,7 @@ #define INCLUDED_SFX2_SOURCE_INC_ALIENWARN_HXX #include -#include +#include class SfxAlienWarningDialog : public MessageDialog { diff --git a/sfx2/source/inc/templdgi.hxx b/sfx2/source/inc/templdgi.hxx index 381da18b8916..5263a8b74b16 100644 --- a/sfx2/source/inc/templdgi.hxx +++ b/sfx2/source/inc/templdgi.hxx @@ -28,6 +28,7 @@ class SfxTemplateControllerItem; #include #include #include +#include #include #include #include @@ -316,6 +317,11 @@ public: return pWindow; } + weld::Widget* GetFrameWeld() + { + return pWindow ? pWindow->GetFrameWeld() : nullptr; + } + void EnableTreeDrag(bool b); void EnableExample_Impl(sal_uInt16 nId, bool bEnable); SfxStyleFamily GetActualFamily() const; diff --git a/sfx2/source/view/classificationhelper.cxx b/sfx2/source/view/classificationhelper.cxx index f167dc8428a8..a642d19b65e8 100644 --- a/sfx2/source/view/classificationhelper.cxx +++ b/sfx2/source/view/classificationhelper.cxx @@ -33,7 +33,7 @@ #include #include #include -#include +#include #include #include @@ -528,14 +528,24 @@ bool SfxClassificationHelper::ShowPasteInfo(SfxClassificationCheckPasteResult eR case SfxClassificationCheckPasteResult::TargetDocNotClassified: { if (!Application::IsHeadlessModeEnabled()) - ScopedVclPtrInstance(nullptr, SfxResId(STR_TARGET_DOC_NOT_CLASSIFIED), VclMessageType::Info)->Execute(); + { + std::unique_ptr xBox(Application::CreateMessageDialog(nullptr, + VclMessageType::Info, VclButtonsType::Ok, + SfxResId(STR_TARGET_DOC_NOT_CLASSIFIED))); + xBox->run(); + } return false; } break; case SfxClassificationCheckPasteResult::DocClassificationTooLow: { if (!Application::IsHeadlessModeEnabled()) - ScopedVclPtrInstance(nullptr, SfxResId(STR_DOC_CLASSIFICATION_TOO_LOW), VclMessageType::Info)->Execute(); + { + std::unique_ptr xBox(Application::CreateMessageDialog(nullptr, + VclMessageType::Info, VclButtonsType::Ok, + SfxResId(STR_DOC_CLASSIFICATION_TOO_LOW))); + xBox->run(); + } return false; } break; diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx index ea7e02d26475..a7874e1934b0 100644 --- a/sfx2/source/view/viewfrm.cxx +++ b/sfx2/source/view/viewfrm.cxx @@ -40,7 +40,7 @@ #include #include #include -#include +#include #include #include #include @@ -154,35 +154,25 @@ void SfxViewFrame::InitInterface_Impl() namespace { /// Asks the user if editing a read-only document is really wanted. -class SfxEditDocumentDialog : public MessageDialog +class SfxEditDocumentDialog { private: - VclPtr m_pEditDocument; - VclPtr m_pCancel; + std::unique_ptr m_xBuilder; + std::unique_ptr m_xDialog; + std::unique_ptr m_xEditDocument; + std::unique_ptr m_xCancel; public: - SfxEditDocumentDialog(vcl::Window* pParent); - ~SfxEditDocumentDialog() override; - void dispose() override; + SfxEditDocumentDialog(weld::Widget* pParent); + short run() { return m_xDialog->run(); } }; -SfxEditDocumentDialog::SfxEditDocumentDialog(vcl::Window* pParent) - : MessageDialog(pParent, "EditDocumentDialog", "sfx/ui/editdocumentdialog.ui") +SfxEditDocumentDialog::SfxEditDocumentDialog(weld::Widget* pParent) + : m_xBuilder(Application::CreateBuilder(pParent, "sfx/ui/editdocumentdialog.ui")) + , m_xDialog(m_xBuilder->weld_message_dialog("EditDocumentDialog")) + , m_xEditDocument(m_xBuilder->weld_button("edit")) + , m_xCancel(m_xBuilder->weld_button("cancel")) { - get(m_pEditDocument, "edit"); - get(m_pCancel, "cancel"); -} - -SfxEditDocumentDialog::~SfxEditDocumentDialog() -{ - disposeOnce(); -} - -void SfxEditDocumentDialog::dispose() -{ - m_pEditDocument.clear(); - m_pCancel.clear(); - MessageDialog::dispose(); } class SfxQueryOpenAsTemplate : public QueryBox @@ -588,9 +578,10 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq ) if ( bDo && GetFrame().DocIsModified_Impl() && !rReq.IsAPI() && ( !pSilentItem || !pSilentItem->GetValue() ) ) { - ScopedVclPtrInstance aBox(&GetWindow(), SfxResId(STR_QUERY_LASTVERSION), - VclMessageType::Question, VclButtonsType::YesNo); - bDo = ( RET_YES == aBox->Execute() ); + std::unique_ptr xBox(Application::CreateMessageDialog(GetWindow().GetFrameWeld(), + VclMessageType::Question, VclButtonsType::YesNo, + SfxResId(STR_QUERY_LASTVERSION))); + bDo = RET_YES == xBox->run(); } if ( bDo ) @@ -756,9 +747,10 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq ) if ( bForEdit && ( SID_EDITDOC == rReq.GetSlot() || SID_READONLYDOC == rReq.GetSlot() ) ) { // ask user for opening as template - ScopedVclPtrInstance aBox(&GetWindow(), SfxResId(STR_QUERY_OPENASTEMPLATE), - VclMessageType::Question, VclButtonsType::YesNo); - if ( RET_YES == aBox->Execute() ) + std::unique_ptr xBox(Application::CreateMessageDialog(GetWindow().GetFrameWeld(), + VclMessageType::Question, VclButtonsType::YesNo, + SfxResId(STR_QUERY_OPENASTEMPLATE))); + if (RET_YES == xBox->run()) { SfxAllItemSet aSet( pApp->GetPool() ); aSet.Put( SfxStringItem( SID_FILE_NAME, pMedium->GetName() ) ); @@ -1345,12 +1337,12 @@ void SfxViewFrame::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint ) } } -IMPL_LINK_NOARG(SfxViewFrame, SwitchReadOnlyHandler, Button*, void) +IMPL_LINK(SfxViewFrame, SwitchReadOnlyHandler, Button*, pButton, void) { if (m_xObjSh.is() && IsSignPDF(m_xObjSh)) { - ScopedVclPtrInstance pDialog(nullptr); - if (pDialog->Execute() != RET_OK) + SfxEditDocumentDialog aDialog(pButton->GetFrameWeld()); + if (aDialog.run() != RET_OK) return; } GetDispatcher()->Execute(SID_EDITDOC); diff --git a/sfx2/source/view/viewprn.cxx b/sfx2/source/view/viewprn.cxx index a5be4fff8b7d..1d070d54e978 100644 --- a/sfx2/source/view/viewprn.cxx +++ b/sfx2/source/view/viewprn.cxx @@ -23,7 +23,7 @@ #include #include -#include +#include #include #include #include @@ -333,7 +333,13 @@ void SfxPrinterController::jobFinished( css::view::PrintableState nState ) // "real" problem (not simply printing cancelled by user) OUString aMsg( SfxResId(STR_NOSTARTPRINTER) ); if ( !m_bApi ) - ScopedVclPtrInstance(mpViewShell->GetWindow(), aMsg)->Execute(); + { + vcl::Window* pWindow = mpViewShell->GetWindow(); + std::unique_ptr xBox(Application::CreateMessageDialog(pWindow ? pWindow->GetFrameWeld() : nullptr, + VclMessageType::Warning, VclButtonsType::Ok, + aMsg)); + xBox->run(); + } SAL_FALLTHROUGH; } case view::PrintableState_JOB_ABORTED : @@ -505,11 +511,16 @@ void SfxViewShell::SetPrinter_Impl( VclPtr& pNewPrinter ) SfxPrinterChangeFlags nChangedFlags = SfxPrinterChangeFlags::NONE; // Ask if possible, if page format should be taken over from printer. - if ( ( bOriChg || bPgSzChg ) && - RET_YES == ScopedVclPtrInstance(nullptr, aMsg, VclMessageType::Question, VclButtonsType::YesNo)->Execute() ) + if (bOriChg || bPgSzChg) { - // Flags with changes for are maintained - nChangedFlags |= nNewOpt; + std::unique_ptr xBox(Application::CreateMessageDialog(nullptr, + VclMessageType::Question, VclButtonsType::YesNo, + aMsg)); + if (RET_YES == xBox->run()) + { + // Flags with changes for are maintained + nChangedFlags |= nNewOpt; + } } // For the MAC to have its "temporary of class String" in next if() @@ -778,7 +789,12 @@ void SfxViewShell::ExecPrint_Impl( SfxRequest &rReq ) { // no valid printer either in ItemSet or at the document if ( !bSilent ) - ScopedVclPtrInstance(nullptr, SfxResId(STR_NODEFPRINTER))->Execute(); + { + std::unique_ptr xBox(Application::CreateMessageDialog(nullptr, + VclMessageType::Warning, VclButtonsType::Ok, + SfxResId(STR_NODEFPRINTER))); + xBox->run(); + } rReq.SetReturnValue(SfxBoolItem(0,false)); @@ -790,7 +806,12 @@ void SfxViewShell::ExecPrint_Impl( SfxRequest &rReq ) { // if printer is busy, abort configuration if ( !bSilent ) - ScopedVclPtrInstance(nullptr, SfxResId(STR_ERROR_PRINTER_BUSY), VclMessageType::Info)->Execute(); + { + std::unique_ptr xBox(Application::CreateMessageDialog(nullptr, + VclMessageType::Info, VclButtonsType::Ok, + SfxResId(STR_ERROR_PRINTER_BUSY))); + xBox->run(); + } rReq.SetReturnValue(SfxBoolItem(0,false)); return; diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx index d7962e72be16..f5b0f7399318 100644 --- a/sfx2/source/view/viewsh.cxx +++ b/sfx2/source/view/viewsh.cxx @@ -22,9 +22,9 @@ #include #include #include -#include #include #include +#include #include #include #include @@ -497,8 +497,11 @@ void SfxViewShell::ExecMisc_Impl( SfxRequest &rReq ) if ( eResult == SfxMailModel::SEND_MAIL_ERROR ) { - ScopedVclPtrInstance< MessageDialog > aBox(SfxGetpApp()->GetTopWindow(), SfxResId( STR_ERROR_SEND_MAIL ), VclMessageType::Info); - aBox->Execute(); + vcl::Window* pWin = SfxGetpApp()->GetTopWindow(); + std::unique_ptr xBox(Application::CreateMessageDialog(pWin ? pWin->GetFrameWeld() : nullptr, + VclMessageType::Info, VclButtonsType::Ok, + SfxResId(STR_ERROR_SEND_MAIL))); + xBox->run(); rReq.Ignore(); } else @@ -517,9 +520,12 @@ void SfxViewShell::ExecMisc_Impl( SfxRequest &rReq ) SfxMailModel::SendMailResult eResult = aModel.SaveAndSend( xFrame ); if( eResult == SfxMailModel::SEND_MAIL_ERROR ) { - ScopedVclPtrInstance< MessageDialog > aBox(SfxGetpApp()->GetTopWindow(), SfxResId( STR_ERROR_SEND_MAIL ), VclMessageType::Info); - aBox->Execute(); - rReq.Ignore(); + vcl::Window* pWin = SfxGetpApp()->GetTopWindow(); + std::unique_ptr xBox(Application::CreateMessageDialog(pWin ? pWin->GetFrameWeld() : nullptr, + VclMessageType::Info, VclButtonsType::Ok, + SfxResId(STR_ERROR_SEND_MAIL))); + xBox->run(); + rReq.Ignore(); } else rReq.Done(); @@ -1116,8 +1122,10 @@ bool SfxViewShell::PrepareClose { if ( bUI ) { - ScopedVclPtrInstance< MessageDialog > aInfoBox(&GetViewFrame()->GetWindow(), SfxResId( STR_CANT_CLOSE ), VclMessageType::Info ); - aInfoBox->Execute(); + std::unique_ptr xBox(Application::CreateMessageDialog(GetViewFrame()->GetWindow().GetFrameWeld(), + VclMessageType::Info, VclButtonsType::Ok, + SfxResId(STR_CANT_CLOSE))); + xBox->run(); } return false; diff --git a/sfx2/uiconfig/ui/alienwarndialog.ui b/sfx2/uiconfig/ui/alienwarndialog.ui index d92c8bbbf757..feabad732dd7 100644 --- a/sfx2/uiconfig/ui/alienwarndialog.ui +++ b/sfx2/uiconfig/ui/alienwarndialog.ui @@ -1,10 +1,9 @@ - + False - 6 Confirm File Format False True @@ -21,7 +20,6 @@ False - end Use %DEFAULTEXTENSION _Format @@ -82,8 +80,8 @@ - cancel - save + cancel + save diff --git a/sfx2/uiconfig/ui/editdocumentdialog.ui b/sfx2/uiconfig/ui/editdocumentdialog.ui index e879e95dcfc9..f47c31b06c55 100644 --- a/sfx2/uiconfig/ui/editdocumentdialog.ui +++ b/sfx2/uiconfig/ui/editdocumentdialog.ui @@ -1,10 +1,9 @@ - + False - 6 Confirm editing of document False True @@ -21,7 +20,6 @@ False - end Edit Document @@ -66,8 +64,8 @@ - edit - cancel + edit + cancel diff --git a/sfx2/uiconfig/ui/errorfindemaildialog.ui b/sfx2/uiconfig/ui/errorfindemaildialog.ui index 0f0195015ba0..be42a0c6c723 100644 --- a/sfx2/uiconfig/ui/errorfindemaildialog.ui +++ b/sfx2/uiconfig/ui/errorfindemaildialog.ui @@ -4,7 +4,6 @@ False - 6 No e-mail configuration False dialog @@ -21,7 +20,6 @@ False - end False diff --git a/sfx2/uiconfig/ui/helpmanual.ui b/sfx2/uiconfig/ui/helpmanual.ui index 4104d13ce9bb..b5942c301e27 100644 --- a/sfx2/uiconfig/ui/helpmanual.ui +++ b/sfx2/uiconfig/ui/helpmanual.ui @@ -4,7 +4,6 @@ False - 6 %PRODUCTNAME Help Not Installed False dialog diff --git a/sfx2/uiconfig/ui/querysavedialog.ui b/sfx2/uiconfig/ui/querysavedialog.ui index 4d48d2379296..4f0b54aecb40 100644 --- a/sfx2/uiconfig/ui/querysavedialog.ui +++ b/sfx2/uiconfig/ui/querysavedialog.ui @@ -1,10 +1,9 @@ - + False - 6 Save Document? False dialog @@ -20,7 +19,6 @@ False - end _Don’t Save @@ -77,9 +75,9 @@ - discard - cancel - save + discard + cancel + save -- cgit