diff options
88 files changed, 963 insertions, 671 deletions
diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx index f25e60c91a23..b7e0fbe518ad 100644 --- a/basctl/source/basicide/baside2b.cxx +++ b/basctl/source/basicide/baside2b.cxx @@ -37,7 +37,7 @@ #include <comphelper/string.hxx> #include <officecfg/Office/Common.hxx> #include <sfx2/dispatch.hxx> -#include <vcl/msgbox.hxx> +#include <vcl/weld.hxx> #include <svl/urihelper.hxx> #include <svx/svxids.hrc> #include <vcl/xtextedt.hxx> @@ -479,7 +479,10 @@ bool EditorWindow::ImpCanModify() { // If in Trace-mode, abort the trace or refuse input // Remove markers in the modules in Notify at Basic::Stopped - if (ScopedVclPtrInstance<QueryBox>(nullptr, MessBoxStyle::OkCancel, IDEResId(RID_STR_WILLSTOPPRG))->Execute() == RET_OK) + std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(nullptr, + VclMessageType::Question, VclButtonsType::OkCancel, + IDEResId(RID_STR_WILLSTOPPRG))); + if (xQueryBox->run() == RET_OK) { rModulWindow.GetBasicStatus().bIsRunning = false; StopBasic(); diff --git a/basctl/source/basicide/baside3.cxx b/basctl/source/basicide/baside3.cxx index fa23eca1a822..322097b38105 100644 --- a/basctl/source/basicide/baside3.cxx +++ b/basctl/source/basicide/baside3.cxx @@ -803,7 +803,7 @@ NameClashQueryBox::NameClashQueryBox( vcl::Window* pParent, AddButton( IDEResId(RID_STR_DLGIMP_CLASH_REPLACE), RET_NO ); AddButton( StandardButtonType::Cancel, RET_CANCEL, ButtonDialogFlags::Cancel ); - SetImage( QueryBox::GetStandardImage() ); + SetImage(GetStandardQueryBoxImage()); } @@ -828,10 +828,9 @@ LanguageMismatchQueryBox::LanguageMismatchQueryBox( vcl::Window* pParent, AddButton( StandardButtonType::Cancel, RET_CANCEL, ButtonDialogFlags::Cancel ); AddButton( StandardButtonType::Help, RET_HELP, ButtonDialogFlags::Help, 4 ); - SetImage( QueryBox::GetStandardImage() ); + SetImage(GetStandardQueryBoxImage() ); } - bool implImportDialog( vcl::Window* pWin, const OUString& rCurPath, const ScriptDocument& rDocument, const OUString& aLibName ) { bool bDone = false; diff --git a/basctl/source/basicide/basides1.cxx b/basctl/source/basicide/basides1.cxx index 5fce14ec5114..a1f4f07f18cf 100644 --- a/basctl/source/basicide/basides1.cxx +++ b/basctl/source/basicide/basides1.cxx @@ -49,7 +49,6 @@ #include <svl/whiter.hxx> #include <vcl/xtextedt.hxx> #include <vcl/svapp.hxx> -#include <vcl/msgbox.hxx> #include <vcl/weld.hxx> namespace basctl @@ -102,7 +101,17 @@ void Shell::ExecuteCurrent( SfxRequest& rReq ) nActModWindows++; } - if ( nActModWindows <= 1 || ( !rSearchItem.GetSelection() && ScopedVclPtrInstance<QueryBox>(pCurWin, MessBoxStyle::YesNo|MessBoxStyle::DefaultYes, IDEResId(RID_STR_SEARCHALLMODULES))->Execute() == RET_YES ) ) + bool bAllModules = nActModWindows <= 1; + if (!bAllModules) + { + std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(pCurWin ? pCurWin->GetFrameWeld() : nullptr, + VclMessageType::Question, VclButtonsType::YesNo, + IDEResId(RID_STR_SEARCHALLMODULES))); + xQueryBox->set_default_response(RET_YES); + bAllModules = xQueryBox->run() == RET_YES; + } + + if (bAllModules) { for (auto const& window : aWindowTable) { @@ -145,8 +154,12 @@ void Shell::ExecuteCurrent( SfxRequest& rReq ) SfxViewFrame* pViewFrame = GetViewFrame(); SfxChildWindow* pChildWin = pViewFrame ? pViewFrame->GetChildWindow( SID_SEARCH_DLG ) : nullptr; vcl::Window* pParent = pChildWin ? pChildWin->GetWindow() : nullptr; - ScopedVclPtrInstance< QueryBox > aQuery(pParent, MessBoxStyle::YesNo|MessBoxStyle::DefaultYes, IDEResId(RID_STR_SEARCHFROMSTART)); - if ( aQuery->Execute() == RET_YES ) + + std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(pParent ? pParent->GetFrameWeld() : nullptr, + VclMessageType::Question, VclButtonsType::YesNo, + IDEResId(RID_STR_SEARCHFROMSTART))); + xQueryBox->set_default_response(RET_YES); + if (xQueryBox->run() == RET_YES) { it = aWindowTable.begin(); if ( it != aWindowTable.end() ) diff --git a/chart2/source/controller/dialogs/DataBrowser.cxx b/chart2/source/controller/dialogs/DataBrowser.cxx index 2a7a41e754cd..b16a20a57401 100644 --- a/chart2/source/controller/dialogs/DataBrowser.cxx +++ b/chart2/source/controller/dialogs/DataBrowser.cxx @@ -37,6 +37,7 @@ #include <vcl/image.hxx> #include <vcl/layout.hxx> #include <vcl/msgbox.hxx> +#include <vcl/weld.hxx> #include <vcl/settings.hxx> #include <rtl/math.hxx> @@ -757,9 +758,10 @@ void DataBrowser::ShowWarningBox() bool DataBrowser::ShowQueryBox() { - ScopedVclPtrInstance<QueryBox> pQueryBox(this, MessBoxStyle::YesNo, SchResId(STR_DATA_EDITOR_INCORRECT_INPUT)); - - return pQueryBox->Execute() == RET_YES; + std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(GetFrameWeld(), + VclMessageType::Question, VclButtonsType::YesNo, + SchResId(STR_DATA_EDITOR_INCORRECT_INPUT))); + return xQueryBox->run() == RET_YES; } bool DataBrowser::IsDataValid() diff --git a/cui/source/customize/SvxMenuConfigPage.cxx b/cui/source/customize/SvxMenuConfigPage.cxx index 1c2ad24094d6..a979233168b2 100644 --- a/cui/source/customize/SvxMenuConfigPage.cxx +++ b/cui/source/customize/SvxMenuConfigPage.cxx @@ -27,7 +27,6 @@ #include <vcl/commandinfoprovider.hxx> #include <vcl/help.hxx> #include <vcl/weld.hxx> -#include <vcl/msgbox.hxx> #include <vcl/decoview.hxx> #include <vcl/toolbox.hxx> #include <vcl/scrbar.hxx> @@ -286,9 +285,10 @@ short SvxMenuConfigPage::QueryReset() OUString label = SvxConfigPageHelper::replaceSaveInName( msg, saveInName ); - ScopedVclPtrInstance<QueryBox> qbox( this, MessBoxStyle::YesNo, label ); - - return qbox->Execute(); + std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(GetFrameWeld(), + VclMessageType::Question, VclButtonsType::YesNo, + label)); + return xQueryBox->run(); } IMPL_LINK_NOARG( SvxMenuConfigPage, SelectMenu, ListBox&, void ) diff --git a/cui/source/customize/SvxToolbarConfigPage.cxx b/cui/source/customize/SvxToolbarConfigPage.cxx index 49c4349c459b..dcd70890d45c 100644 --- a/cui/source/customize/SvxToolbarConfigPage.cxx +++ b/cui/source/customize/SvxToolbarConfigPage.cxx @@ -723,9 +723,10 @@ short SvxToolbarConfigPage::QueryReset() OUString label = SvxConfigPageHelper::replaceSaveInName( msg, saveInName ); - ScopedVclPtrInstance< QueryBox > qbox( this, MessBoxStyle::YesNo, label ); - - return qbox->Execute(); + std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(GetFrameWeld(), + VclMessageType::Question, VclButtonsType::YesNo, + label)); + return xQueryBox->run(); } IMPL_LINK_NOARG( SvxToolbarConfigPage, SelectToolbar, ListBox&, void ) diff --git a/cui/source/dialogs/linkdlg.cxx b/cui/source/dialogs/linkdlg.cxx index 73e3e4021be9..9b2478f8f746 100644 --- a/cui/source/dialogs/linkdlg.cxx +++ b/cui/source/dialogs/linkdlg.cxx @@ -27,7 +27,7 @@ #include <vcl/fixed.hxx> #include <vcl/group.hxx> #include <vcl/lstbox.hxx> -#include <vcl/msgbox.hxx> +#include <vcl/weld.hxx> #include <vcl/timer.hxx> #include <vcl/idle.hxx> #include <svtools/svtabbx.hxx> @@ -416,9 +416,12 @@ IMPL_LINK_NOARG( SvBaseLinksDlg, BreakLinkClickHdl, Button*, void ) if( !xLink.is() ) return; - ScopedVclPtrInstance< QueryBox > aBox( this, MessBoxStyle::YesNo | MessBoxStyle::DefaultYes, aStrCloselinkmsg ); + std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(GetFrameWeld(), + VclMessageType::Question, VclButtonsType::YesNo, + aStrCloselinkmsg)); + xQueryBox->set_default_response(RET_YES); - if( RET_YES == aBox->Execute() ) + if (RET_YES == xQueryBox->run()) { m_pTbLinks->GetModel()->Remove( m_pTbLinks->GetEntry( nPos ) ); @@ -447,9 +450,12 @@ IMPL_LINK_NOARG( SvBaseLinksDlg, BreakLinkClickHdl, Button*, void ) } else { - ScopedVclPtrInstance< QueryBox > aBox( this, MessBoxStyle::YesNo | MessBoxStyle::DefaultYes, aStrCloselinkmsgMulti ); + std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(GetFrameWeld(), + VclMessageType::Question, VclButtonsType::YesNo, + aStrCloselinkmsgMulti)); + xQueryBox->set_default_response(RET_YES); - if( RET_YES == aBox->Execute() ) + if (RET_YES == xQueryBox->run()) { SvBaseLinkMemberList aLinkList; diff --git a/cui/source/options/optinet2.cxx b/cui/source/options/optinet2.cxx index 1b4161575e67..19de5d14b8ad 100644 --- a/cui/source/options/optinet2.cxx +++ b/cui/source/options/optinet2.cxx @@ -23,7 +23,7 @@ #include <officecfg/Office/Common.hxx> #include <officecfg/Office/Security.hxx> #include <tools/config.hxx> -#include <vcl/msgbox.hxx> +#include <vcl/weld.hxx> #include <svl/intitem.hxx> #include <svl/stritem.hxx> #include <svl/eitem.hxx> @@ -663,8 +663,12 @@ IMPL_LINK_NOARG(SvxSecurityTabPage, SavePasswordHdl, Button*, void) } else { - ScopedVclPtrInstance< QueryBox > aQuery( this, MessBoxStyle::YesNo|MessBoxStyle::DefaultNo, m_sPasswordStoringDeactivateStr ); - sal_uInt16 nRet = aQuery->Execute(); + std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(GetFrameWeld(), + VclMessageType::Question, VclButtonsType::YesNo, + m_sPasswordStoringDeactivateStr)); + xQueryBox->set_default_response(RET_NO); + + sal_uInt16 nRet = xQueryBox->run(); if( RET_YES == nRet ) { diff --git a/cui/source/options/personalization.cxx b/cui/source/options/personalization.cxx index 9b3e482b55d2..b6af6903d0c7 100644 --- a/cui/source/options/personalization.cxx +++ b/cui/source/options/personalization.cxx @@ -21,7 +21,7 @@ #include <rtl/strbuf.hxx> #include <tools/urlobj.hxx> #include <vcl/edit.hxx> -#include <vcl/msgbox.hxx> +#include <vcl/weld.hxx> #include <vcl/lstbox.hxx> #include <vcl/svapp.hxx> #include <vcl/settings.hxx> @@ -709,8 +709,11 @@ void SearchAndParseThread::execute() sError = CuiResId(RID_SVXSTR_SEARCHERROR); sError = sError.replaceAll("%1", m_aURL); m_pPersonaDialog->SetProgress( OUString() ); - ScopedVclPtrInstance< ErrorBox > aBox( nullptr, MessBoxStyle::Ok, sError); - aBox->Execute(); + + std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(nullptr, + VclMessageType::Error, VclButtonsType::Ok, + sError)); + xBox->run(); return; } } @@ -722,8 +725,10 @@ void SearchAndParseThread::execute() sError = CuiResId(RID_SVXSTR_SEARCHERROR); sError = sError.replaceAll("%1", m_aURL); m_pPersonaDialog->SetProgress( OUString() ); - ScopedVclPtrInstance< ErrorBox > aBox( nullptr, MessBoxStyle::Ok, sError ); - aBox->Execute(); + std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(nullptr, + VclMessageType::Error, VclButtonsType::Ok, + sError)); + xBox->run(); return; } @@ -763,8 +768,10 @@ void SearchAndParseThread::execute() sError = CuiResId(RID_SVXSTR_SEARCHERROR); sError = sError.replaceAll("%1", m_aURL); m_pPersonaDialog->SetProgress( OUString() ); - ScopedVclPtrInstance< ErrorBox > aBox( nullptr, MessBoxStyle::Ok, sError); - aBox->Execute(); + std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(nullptr, + VclMessageType::Error, VclButtonsType::Ok, + sError)); + xBox->run(); return; } continue; @@ -847,8 +854,10 @@ void SearchAndParseThread::execute() sError = CuiResId( RID_SVXSTR_SEARCHERROR ); sError = sError.replaceAll("%1", m_aURL); m_pPersonaDialog->SetProgress( OUString() ); - ScopedVclPtrInstance< ErrorBox > aBox( nullptr, MessBoxStyle::Ok, sError); - aBox->Execute(); + std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(nullptr, + VclMessageType::Error, VclButtonsType::Ok, + sError)); + xBox->run(); return; } diff --git a/cui/source/tabpages/page.cxx b/cui/source/tabpages/page.cxx index dbde0bf2dc9c..97aab18fd870 100644 --- a/cui/source/tabpages/page.cxx +++ b/cui/source/tabpages/page.cxx @@ -25,7 +25,7 @@ #include <sfx2/viewsh.hxx> #include <svl/itemiter.hxx> #include <svl/languageoptions.hxx> -#include <vcl/msgbox.hxx> +#include <vcl/weld.hxx> #include <unotools/configitem.hxx> #include <sfx2/htmlmode.hxx> #include <sal/macros.h> @@ -1375,7 +1375,11 @@ DeactivateRC SvxPageDescPage::DeactivatePage( SfxItemSet* _pSet ) if ( ePaper != PAPER_SCREEN_4_3 && ePaper != PAPER_SCREEN_16_9 && ePaper != PAPER_SCREEN_16_10 && IsMarginOutOfRange() ) { - if (ScopedVclPtrInstance<QueryBox>(this, MessBoxStyle::YesNo | MessBoxStyle::DefaultNo, m_pPrintRangeQueryText->GetText())->Execute() == RET_NO) + std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(GetFrameWeld(), + VclMessageType::Question, VclButtonsType::YesNo, + m_pPrintRangeQueryText->GetText())); + xQueryBox->set_default_response(RET_NO); + if (xQueryBox->run() == RET_NO) { MetricField* pField = nullptr; if ( IsPrinterRangeOverflow( *m_pLeftMarginEdit, nFirstLeftMargin, nLastLeftMargin, MARGIN_LEFT ) ) diff --git a/dbaccess/source/ui/dlg/CollectionView.cxx b/dbaccess/source/ui/dlg/CollectionView.cxx index ebdd01a8bd23..764d4d43de0c 100644 --- a/dbaccess/source/ui/dlg/CollectionView.cxx +++ b/dbaccess/source/ui/dlg/CollectionView.cxx @@ -32,7 +32,8 @@ #include <com/sun/star/container/XChild.hpp> #include <com/sun/star/container/XNameContainer.hpp> #include <com/sun/star/beans/PropertyValue.hpp> -#include <vcl/msgbox.hxx> +#include <vcl/svapp.hxx> +#include <vcl/weld.hxx> #include <stringconstants.hxx> #include <bitmaps.hlst> #include <UITools.hxx> @@ -175,8 +176,10 @@ IMPL_LINK_NOARG(OCollectionView, Save_Click, Button*, void) { if ( xNameContainer->hasByName(sName) ) { - ScopedVclPtrInstance< QueryBox > aBox(this, MessBoxStyle::YesNo, DBA_RES(STR_ALREADYEXISTOVERWRITE)); - if ( aBox->Execute() != RET_YES ) + std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(GetFrameWeld(), + VclMessageType::Question, VclButtonsType::YesNo, + DBA_RES(STR_ALREADYEXISTOVERWRITE))); + if (xQueryBox->run() != RET_YES) return; } m_pName->SetText(sName); diff --git a/dbaccess/source/ui/dlg/ConnectionHelper.cxx b/dbaccess/source/ui/dlg/ConnectionHelper.cxx index a933efe269a4..cf41e45b01e3 100644 --- a/dbaccess/source/ui/dlg/ConnectionHelper.cxx +++ b/dbaccess/source/ui/dlg/ConnectionHelper.cxx @@ -33,6 +33,7 @@ #include <osl/process.h> #include <osl/diagnose.h> #include <vcl/msgbox.hxx> +#include <vcl/weld.hxx> #include <sfx2/filedlghelper.hxx> #include <dbadmin.hxx> #include <comphelper/types.hxx> @@ -475,8 +476,12 @@ namespace dbaui sQuery = sQuery.replaceFirst("$path$", aTransformer.get(OFileNotation::N_SYSTEM)); m_bUserGrabFocus = false; - ScopedVclPtrInstance< QueryBox > aQuery(GetParent(), MessBoxStyle::YesNo | MessBoxStyle::DefaultYes, sQuery); - sal_Int32 nQueryResult = aQuery->Execute(); + vcl::Window* pWin = GetParent(); + std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(pWin ? pWin->GetFrameWeld() : nullptr, + VclMessageType::Question, VclButtonsType::YesNo, + sQuery)); + xQueryBox->set_default_response(RET_YES); + sal_Int32 nQueryResult = xQueryBox->run(); m_bUserGrabFocus = true; switch (nQueryResult) @@ -492,8 +497,14 @@ namespace dbaui sQuery = sQuery.replaceFirst("$name$", aTransformer.get(OFileNotation::N_SYSTEM)); m_bUserGrabFocus = false; - ScopedVclPtrInstance< QueryBox > aWhatToDo(GetParent(), MessBoxStyle::RetryCancel | MessBoxStyle::DefaultRetry, sQuery); - nQueryResult = aWhatToDo->Execute(); + + std::unique_ptr<weld::MessageDialog> xWhatToDo(Application::CreateMessageDialog(pWin ? pWin->GetFrameWeld() : nullptr, + VclMessageType::Question, VclButtonsType::NONE, + sQuery)); + xWhatToDo->add_button(Button::GetStandardText(StandardButtonType::Retry), RET_RETRY); + xWhatToDo->add_button(Button::GetStandardText(StandardButtonType::Cancel), RET_CANCEL); + xWhatToDo->set_default_response(RET_RETRY); + nQueryResult = xWhatToDo->run(); m_bUserGrabFocus = true; if (RET_RETRY == nQueryResult) diff --git a/dbaccess/source/ui/dlg/sqlmessage.cxx b/dbaccess/source/ui/dlg/sqlmessage.cxx index 315bae099e57..5981fcb33ebe 100644 --- a/dbaccess/source/ui/dlg/sqlmessage.cxx +++ b/dbaccess/source/ui/dlg/sqlmessage.cxx @@ -628,10 +628,10 @@ void OSQLMessageBox::Construct( MessBoxStyle _nStyle, MessageType _eImage ) m_aInfoImage->SetImage(WarningBox::GetStandardImage()); break; case Error: - m_aInfoImage->SetImage(ErrorBox::GetStandardImage()); + m_aInfoImage->SetImage(GetStandardErrorBoxImage()); break; case Query: - m_aInfoImage->SetImage(QueryBox::GetStandardImage()); + m_aInfoImage->SetImage(GetStandardQueryBoxImage()); break; } diff --git a/dbaccess/source/ui/querydesign/querycontroller.cxx b/dbaccess/source/ui/querydesign/querycontroller.cxx index 94ffa557bcad..0102620d8f11 100644 --- a/dbaccess/source/ui/querydesign/querycontroller.cxx +++ b/dbaccess/source/ui/querydesign/querycontroller.cxx @@ -80,6 +80,7 @@ #include <osl/diagnose.h> #include <vcl/msgbox.hxx> #include <vcl/svapp.hxx> +#include <vcl/weld.hxx> #include <osl/mutex.hxx> #include <rtl/strbuf.hxx> #include <memory> @@ -1738,9 +1739,14 @@ short OQueryController::saveModified() ) { OUString sMessageText( lcl_getObjectResourceString( STR_QUERY_SAVEMODIFIED, m_nCommandType ) ); - ScopedVclPtrInstance< QueryBox > aQry( getView(), MessBoxStyle::YesNoCancel | MessBoxStyle::DefaultYes, sMessageText ); - nRet = aQry->Execute(); + std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(getFrameWeld(), + VclMessageType::Question, VclButtonsType::YesNo, + sMessageText)); + xQueryBox->add_button(Button::GetStandardText(StandardButtonType::Cancel), RET_CANCEL); + xQueryBox->set_default_response(RET_YES); + + nRet = xQueryBox->run(); if ( ( nRet == RET_YES ) && !doSaveAsDoc( false ) ) diff --git a/extensions/UIConfig_sbibliography.mk b/extensions/UIConfig_sbibliography.mk index 0a25c8f0035e..00375d9fae1e 100644 --- a/extensions/UIConfig_sbibliography.mk +++ b/extensions/UIConfig_sbibliography.mk @@ -16,6 +16,7 @@ $(eval $(call gb_UIConfig_add_menubarfiles,modules/sbibliography,\ $(eval $(call gb_UIConfig_add_uifiles,modules/sbibliography,\ extensions/uiconfig/sbibliography/ui/choosedatasourcedialog \ extensions/uiconfig/sbibliography/ui/generalpage \ + extensions/uiconfig/sbibliography/ui/querydialog \ extensions/uiconfig/sbibliography/ui/mappingdialog \ extensions/uiconfig/sbibliography/ui/toolbar \ )) diff --git a/extensions/source/bibliography/bibview.cxx b/extensions/source/bibliography/bibview.cxx index 33a0df0d564d..308c37ca4f24 100644 --- a/extensions/source/bibliography/bibview.cxx +++ b/extensions/source/bibliography/bibview.cxx @@ -32,7 +32,7 @@ #include <vcl/svapp.hxx> #include <com/sun/star/sdbc/XResultSetUpdate.hpp> #include <com/sun/star/form/XLoadable.hpp> -#include <vcl/msgbox.hxx> +#include <vcl/weld.hxx> #include <tools/debug.hxx> using namespace ::com::sun::star; @@ -138,11 +138,26 @@ namespace bib { sErrorString += "\n"; sErrorString += BibResId(RID_MAP_QUESTION); - ScopedVclPtrInstance< QueryBox > aQuery(this, MessBoxStyle::YesNo, sErrorString); - aQuery->SetDefaultCheckBoxText(); - short nResult = aQuery->Execute(); - BibModul::GetConfig()->SetShowColumnAssignmentWarning( - !aQuery->GetCheckBoxState()); + + std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(GetFrameWeld(), "modules/sbibliography/ui/querydialog.ui")); + std::unique_ptr<weld::MessageDialog> xQueryBox(xBuilder->weld_message_dialog("QueryDialog")); + xQueryBox->set_primary_text(sErrorString); + std::unique_ptr<weld::CheckButton> xWarningOnBox(xBuilder->weld_check_button("ask")); + + //fdo#75121, a bit tricky because the widgets we want to align with + //don't actually exist in the ui description, they're implied + std::unique_ptr<weld::Container> xOrigParent(xWarningOnBox->weld_parent()); + std::unique_ptr<weld::Container> xContentArea(xQueryBox->weld_message_area()); + xOrigParent->remove(xWarningOnBox.get()); + xContentArea->add(xWarningOnBox.get()); + + short nResult = xQueryBox->run(); + BibModul::GetConfig()->SetShowColumnAssignmentWarning(!xWarningOnBox->get_active()); + + //put them back as they were + xContentArea->remove(xWarningOnBox.get()); + xOrigParent->add(xWarningOnBox.get()); + if( RET_YES != nResult ) { bExecute = false; diff --git a/extensions/source/propctrlr/xsdvalidationpropertyhandler.cxx b/extensions/source/propctrlr/xsdvalidationpropertyhandler.cxx index 7203c638f353..2f5d063ddc4d 100644 --- a/extensions/source/propctrlr/xsdvalidationpropertyhandler.cxx +++ b/extensions/source/propctrlr/xsdvalidationpropertyhandler.cxx @@ -40,7 +40,8 @@ #include <com/sun/star/beans/Optional.hpp> #include <com/sun/star/inspection/XObjectInspectorUI.hpp> #include <com/sun/star/inspection/PropertyLineElement.hpp> -#include <vcl/msgbox.hxx> +#include <vcl/svapp.hxx> +#include <vcl/weld.hxx> #include <tools/debug.hxx> #include <sal/macros.h> @@ -510,7 +511,6 @@ namespace pcr m_pHelper->setValidatingDataTypeByName( _rNewName ); } - bool XSDValidationPropertyHandler::implPrepareRemoveCurrentDataType() { OSL_PRECOND( m_pHelper.get(), "XSDValidationPropertyHandler::implPrepareRemoveCurrentDataType: this will crash!" ); @@ -525,14 +525,16 @@ namespace pcr // confirmation message OUString sConfirmation( PcrRes( RID_STR_CONFIRM_DELETE_DATA_TYPE ) ); sConfirmation = sConfirmation.replaceFirst( "#type#", pType->getName() ); - ScopedVclPtrInstance<QueryBox> aQuery( nullptr, MessBoxStyle::YesNo, sConfirmation ); // TODO/eForms: proper parent - if ( aQuery->Execute() != RET_YES ) + + std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(nullptr, // TODO/eForms: proper parent + VclMessageType::Question, VclButtonsType::YesNo, + sConfirmation)); + if (xQueryBox->run() != RET_YES) return false; return true; } - bool XSDValidationPropertyHandler::implDoRemoveCurrentDataType() { OSL_PRECOND( m_pHelper.get(), "XSDValidationPropertyHandler::implDoRemoveCurrentDataType: this will crash!" ); diff --git a/extensions/uiconfig/sbibliography/ui/querydialog.ui b/extensions/uiconfig/sbibliography/ui/querydialog.ui new file mode 100644 index 000000000000..1c641670ab73 --- /dev/null +++ b/extensions/uiconfig/sbibliography/ui/querydialog.ui @@ -0,0 +1,46 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Generated with glade 3.20.2 --> +<interface domain="pcr"> + <requires lib="gtk+" version="3.20"/> + <object class="GtkMessageDialog" id="QueryDialog"> + <property name="can_focus">False</property> + <property name="type_hint">dialog</property> + <property name="message_type">question</property> + <property name="buttons">yes-no</property> + <child internal-child="vbox"> + <object class="GtkBox"> + <property name="can_focus">False</property> + <property name="orientation">vertical</property> + <property name="spacing">2</property> + <child internal-child="action_area"> + <object class="GtkButtonBox"> + <property name="can_focus">False</property> + <property name="homogeneous">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="ask"> + <property name="label" translatable="yes" context="querydialog|ask">Do not show this question again.</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="draw_indicator">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">2</property> + </packing> + </child> + </object> + </child> + <child> + <placeholder/> + </child> + </object> +</interface> diff --git a/filter/source/pdf/impdialog.cxx b/filter/source/pdf/impdialog.cxx index 5aef8a4695ff..7cdc56634414 100644 --- a/filter/source/pdf/impdialog.cxx +++ b/filter/source/pdf/impdialog.cxx @@ -1655,6 +1655,8 @@ ImplErrorDialog::ImplErrorDialog(const std::set< vcl::PDFWriter::ErrorCode >& rE } m_pErrors->SetSelectHdl( LINK( this, ImplErrorDialog, SelectHdl ) ); + + create_message_area(); } diff --git a/forms/source/runtime/formoperations.cxx b/forms/source/runtime/formoperations.cxx index 3597486f07ae..94684287a4b2 100644 --- a/forms/source/runtime/formoperations.cxx +++ b/forms/source/runtime/formoperations.cxx @@ -50,7 +50,8 @@ #include <connectivity/dbexception.hxx> #include <vcl/svapp.hxx> #include <vcl/stdtext.hxx> -#include <vcl/msgbox.hxx> +#include <vcl/button.hxx> +#include <vcl/weld.hxx> #include <vcl/waitobj.hxx> #include <tools/diagnose_ex.h> #include <comphelper/container.hxx> @@ -434,17 +435,22 @@ namespace frm if(needConfirmation) { // TODO: shouldn't this be done with an interaction handler? - ScopedVclPtrInstance< QueryBox > aQuery( nullptr, MessBoxStyle::YesNoCancel | MessBoxStyle::DefaultYes, FRM_RES_STRING( RID_STR_QUERY_SAVE_MODIFIED_ROW ) ); - switch ( aQuery->Execute() ) + std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(nullptr, + VclMessageType::Question, VclButtonsType::YesNo, + FRM_RES_STRING(RID_STR_QUERY_SAVE_MODIFIED_ROW))); + xQueryBox->add_button(Button::GetStandardText(StandardButtonType::Cancel), RET_CANCEL); + xQueryBox->set_default_response(RET_YES); + + switch (xQueryBox->run()) { - case RET_NO: - shouldCommit = false; - SAL_FALLTHROUGH; // don't ask again! - case RET_YES: - needConfirmation = false; - return true; - case RET_CANCEL: - return false; + case RET_NO: + shouldCommit = false; + SAL_FALLTHROUGH; // don't ask again! + case RET_YES: + needConfirmation = false; + return true; + case RET_CANCEL: + return false; } } return true; diff --git a/framework/source/services/autorecovery.cxx b/framework/source/services/autorecovery.cxx index f85756fe9016..a7698055e9e5 100644 --- a/framework/source/services/autorecovery.cxx +++ b/framework/source/services/autorecovery.cxx @@ -88,7 +88,7 @@ #include <ucbhelper/content.hxx> #include <osl/time.h> -#include <vcl/msgbox.hxx> +#include <vcl/weld.hxx> #include <osl/file.hxx> #include <unotools/bootstrap.hxx> #include <unotools/configmgr.hxx> @@ -4087,11 +4087,11 @@ void AutoRecovery::impl_showFullDiscError() if (sBackupPath.getLength() < 1) sBackupPath = sBackupURL; - ScopedVclPtrInstance<ErrorBox> dlgError( - nullptr, MessBoxStyle::Ok, - sMsg.replaceAll("%PATH", sBackupPath)); - dlgError->SetButtonText(dlgError->GetButtonId(0), sBtn); - dlgError->Execute(); + std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(nullptr, + VclMessageType::Error, VclButtonsType::NONE, + sMsg.replaceAll("%PATH", sBackupPath))); + xBox->add_button(sBtn, RET_OK); + xBox->run(); } void AutoRecovery::impl_establishProgress(const AutoRecovery::TDocumentInfo& rInfo , diff --git a/include/sfx2/linkmgr.hxx b/include/sfx2/linkmgr.hxx index a7def55012e5..b1057aef5f1a 100644 --- a/include/sfx2/linkmgr.hxx +++ b/include/sfx2/linkmgr.hxx @@ -37,6 +37,8 @@ namespace com { namespace sun { namespace star { } }}} +namespace weld { class Window; } + namespace sfx2 { // For the link to receive information about the status of graphics that @@ -126,9 +128,9 @@ public: static SvLinkSourceRef CreateObj( SvBaseLink const * ); - void UpdateAllLinks( bool bAskUpdate, - bool bUpdateGrfLinks, - vcl::Window* pParentWin ); + void UpdateAllLinks(bool bAskUpdate, + bool bUpdateGrfLinks, + weld::Window* pParentWin); // Call for list of links (eg for link-dialog) const SvBaseLinks& GetLinks() const { return aLinkTbl; } diff --git a/include/vcl/builder.hxx b/include/vcl/builder.hxx index bb66872e786d..6e47c022b844 100644 --- a/include/vcl/builder.hxx +++ b/include/vcl/builder.hxx @@ -36,6 +36,7 @@ class Button; class ListBox; +class MessageDialog; class NumericFormatter; class PopupMenu; class SalInstanceBuilder; @@ -276,6 +277,8 @@ private: std::vector< VclPtr<VclExpander> > m_aExpanderWidgets; + std::vector< VclPtr<MessageDialog> > m_aMessageDialogs; + sal_uInt16 m_nLastToolbarId; sal_uInt16 m_nLastMenuItemId; diff --git a/include/vcl/messagedialog.hxx b/include/vcl/messagedialog.hxx index 1cce2f41009e..f7fc3c98bc9b 100644 --- a/include/vcl/messagedialog.hxx +++ b/include/vcl/messagedialog.hxx @@ -23,6 +23,7 @@ private: VclPtr<VclBox> m_pOwnedContentArea; VclPtr<VclButtonBox> m_pOwnedActionArea; VclPtr<VclGrid> m_pGrid; + VclPtr<VclVBox> m_pMessageBox; VclPtr<FixedImage> m_pImage; VclPtr<VclMultiLineEdit> m_pPrimaryMessage; VclPtr<VclMultiLineEdit> m_pSecondaryMessage; @@ -39,7 +40,6 @@ public: VclButtonsType eButtonsType = VclButtonsType::Ok); MessageDialog(vcl::Window* pParent, const OString& rID, const OUString& rUIXMLDescription); virtual bool set_property(const OString& rKey, const OUString& rValue) override; - virtual short Execute() override; OUString const& get_primary_text() const; OUString const& get_secondary_text() const; void set_primary_text(const OUString& rPrimaryString); @@ -47,6 +47,9 @@ public: virtual ~MessageDialog() override; virtual void dispose() override; + void create_message_area(); + VclContainer* get_message_area() const { return m_pMessageBox.get(); } + static void SetMessagesWidths(vcl::Window const* pParent, VclMultiLineEdit* pPrimaryMessage, VclMultiLineEdit* pSecondaryMessage); }; diff --git a/include/vcl/msgbox.hxx b/include/vcl/msgbox.hxx index 203d3ea36d80..5df7a5f81437 100644 --- a/include/vcl/msgbox.hxx +++ b/include/vcl/msgbox.hxx @@ -105,32 +105,11 @@ public: static OUString GetStandardText(); }; -class VCL_DLLPUBLIC ErrorBox : public MessBox -{ -public: - ErrorBox( vcl::Window* pParent, const OUString& rMessage ); - ErrorBox( vcl::Window* pParent, MessBoxStyle nStyle, - const OUString& rMessage ); - ErrorBox( vcl::Window* pParent, MessBoxStyle nStyle, WinBits n, - const OUString& rMessage ); +VCL_DLLPUBLIC Image const & GetStandardErrorBoxImage(); +VCL_DLLPUBLIC OUString GetStandardErrorBoxText(); - static Image GetStandardImage(); - static OUString GetStandardText(); -}; - -class VCL_DLLPUBLIC QueryBox : public MessBox -{ -public: - QueryBox( vcl::Window* pParent, MessBoxStyle nStyle, - const OUString& rMessage ); - QueryBox( vcl::Window* pParent, MessBoxStyle nStyle, WinBits n, - const OUString& rMessage ); - - void SetDefaultCheckBoxText(); - - static Image const & GetStandardImage(); - static OUString GetStandardText(); -}; +VCL_DLLPUBLIC Image const & GetStandardQueryBoxImage(); +VCL_DLLPUBLIC OUString GetStandardQueryBoxText(); #endif // INCLUDED_VCL_MSGBOX_HXX diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx index 69674ab9ba17..5c87a005fe61 100644 --- a/include/vcl/weld.hxx +++ b/include/vcl/weld.hxx @@ -19,6 +19,8 @@ namespace weld { +class Container; + class VCL_DLLPUBLIC Widget { public: @@ -44,13 +46,16 @@ public: virtual Size get_pixel_size(const OUString& rText) const = 0; virtual OString get_buildable_name() const = 0; virtual OString get_help_id() const = 0; - virtual Widget* weld_parent() const = 0; + virtual Container* weld_parent() const = 0; virtual ~Widget() {} }; class VCL_DLLPUBLIC Container : virtual public Widget { +public: + virtual void remove(weld::Widget* pWidget) = 0; + virtual void add(weld::Widget* pWidget) = 0; }; class VCL_DLLPUBLIC Frame : virtual public Container @@ -107,6 +112,7 @@ public: virtual OUString get_primary_text() const = 0; virtual void set_secondary_text(const OUString& rText) = 0; virtual OUString get_secondary_text() const = 0; + virtual Container* weld_message_area() = 0; }; class VCL_DLLPUBLIC ComboBoxText : virtual public Container @@ -160,6 +166,7 @@ public: virtual void insert(const OUString& rText, int pos) = 0; virtual int n_children() const = 0; virtual void select(int pos) = 0; + using Container::remove; virtual void remove(int pos) = 0; virtual int find(const OUString& rText) const = 0; virtual void set_top_entry(int pos) = 0; diff --git a/sc/UIConfig_scalc.mk b/sc/UIConfig_scalc.mk index 2e8c1ad945c3..78a0674eab40 100644 --- a/sc/UIConfig_scalc.mk +++ b/sc/UIConfig_scalc.mk @@ -180,6 +180,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/scalc,\ sc/uiconfig/scalc/ui/protectsheetdlg \ sc/uiconfig/scalc/ui/queryrunstreamscriptdialog \ sc/uiconfig/scalc/ui/randomnumbergenerator \ + sc/uiconfig/scalc/ui/recalcquerydialog \ sc/uiconfig/scalc/ui/regressiondialog \ sc/uiconfig/scalc/ui/retypepassdialog \ sc/uiconfig/scalc/ui/retypepassworddialog \ diff --git a/sc/inc/globstr.hrc b/sc/inc/globstr.hrc index 75085e29bd75..cf29d865364f 100644 --- a/sc/inc/globstr.hrc +++ b/sc/inc/globstr.hrc @@ -469,7 +469,6 @@ #define STR_EDIT_EXISTING_COND_FORMATS NC_("STR_EDIT_EXISTING_COND_FORMATS", "The selected cell already contains conditional formatting. You can either edit the existing conditional format or you define a new overlapping conditional format.\n\n Do you want to edit the existing conditional format?") #define STR_QUERY_FORMULA_RECALC_ONLOAD_ODS NC_("STR_QUERY_FORMULA_RECALC_ONLOAD_ODS", "This document was last saved by an application other than %PRODUCTNAME. Some formula cells may produce different results when recalculated.\n\nDo you want to recalculate all formula cells in this document now?") #define STR_QUERY_FORMULA_RECALC_ONLOAD_XLS NC_("STR_QUERY_FORMULA_RECALC_ONLOAD_XLS", "This document was last saved by Excel. Some formula cells may produce different results when recalculated.\n\nDo you want to recalculate all formula cells now?") -#define STR_ALWAYS_PERFORM_SELECTED NC_("STR_ALWAYS_PERFORM_SELECTED", "Always perform this without prompt in the future.") #define STR_NO_INSERT_DELETE_OVER_PIVOT_TABLE NC_("STR_NO_INSERT_DELETE_OVER_PIVOT_TABLE", "You cannot insert or delete cells when the affected range intersects with pivot table.") #define STR_DPFIELD_GROUP_BY_SECONDS NC_("STR_DPFIELD_GROUP_BY_SECONDS", "Seconds") #define STR_DPFIELD_GROUP_BY_MINUTES NC_("STR_DPFIELD_GROUP_BY_MINUTES", "Minutes") diff --git a/sc/source/filter/oox/workbookfragment.cxx b/sc/source/filter/oox/workbookfragment.cxx index d80b594c730e..7a57a2a04402 100644 --- a/sc/source/filter/oox/workbookfragment.cxx +++ b/sc/source/filter/oox/workbookfragment.cxx @@ -57,7 +57,7 @@ #include <vcl/svapp.hxx> #include <vcl/timer.hxx> -#include <vcl/msgbox.hxx> +#include <vcl/weld.hxx> #include <oox/core/fastparser.hxx> #include <salhelper/thread.hxx> @@ -532,15 +532,29 @@ void WorkbookFragment::recalcFormulaCells() if (rDoc.IsUserInteractionEnabled()) { // Ask the user if full re-calculation is desired. - ScopedVclPtrInstance<QueryBox> aBox( - ScDocShell::GetActiveDialogParent(), MessBoxStyle::YesNo | MessBoxStyle::DefaultYes, - ScGlobal::GetRscString(STR_QUERY_FORMULA_RECALC_ONLOAD_XLS)); - aBox->SetCheckBoxText(ScGlobal::GetRscString(STR_ALWAYS_PERFORM_SELECTED)); + vcl::Window* pWin = ScDocShell::GetActiveDialogParent(); - sal_Int32 nRet = aBox->Execute(); - bHardRecalc = nRet == RET_YES; + std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(pWin ? pWin->GetFrameWeld() : nullptr, + "modules/scalc/ui/recalcquerydialog.ui")); + std::unique_ptr<weld::MessageDialog> xQueryBox(xBuilder->weld_message_dialog("RecalcQueryDialog")); + xQueryBox->set_primary_text(ScGlobal::GetRscString(STR_QUERY_FORMULA_RECALC_ONLOAD_XLS)); + xQueryBox->set_default_response(RET_YES); + std::unique_ptr<weld::CheckButton> xWarningOnBox(xBuilder->weld_check_button("ask")); - if (aBox->GetCheckBoxState()) + //fdo#75121, a bit tricky because the widgets we want to align with + //don't actually exist in the ui description, they're implied + std::unique_ptr<weld::Container> xOrigParent(xWarningOnBox->weld_parent()); + std::unique_ptr<weld::Container> xContentArea(xQueryBox->weld_message_area()); + xOrigParent->remove(xWarningOnBox.get()); + xContentArea->add(xWarningOnBox.get()); + + bHardRecalc = xQueryBox->run() == RET_YES; + + //put them back as they were + xContentArea->remove(xWarningOnBox.get()); + xOrigParent->add(xWarningOnBox.get()); + + if (xWarningOnBox->get_active()) { // Always perform selected action in the future. std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create()); diff --git a/sc/source/ui/dbgui/dbnamdlg.cxx b/sc/source/ui/dbgui/dbnamdlg.cxx index 5df04c90d1ae..45de6c7a64b8 100644 --- a/sc/source/ui/dbgui/dbnamdlg.cxx +++ b/sc/source/ui/dbgui/dbnamdlg.cxx @@ -23,7 +23,7 @@ #include <cassert> #include <comphelper/string.hxx> -#include <vcl/msgbox.hxx> +#include <vcl/svapp.hxx> #include <vcl/weld.hxx> #include <reffact.hxx> @@ -533,9 +533,11 @@ IMPL_LINK_NOARG(ScDbNameDlg, RemoveBtnHdl, Button*, void) aBuf.append(aStrDelMsg.getToken(0, '#')); aBuf.append(aStrEntry); aBuf.append(aStrDelMsg.getToken(1, '#')); - ScopedVclPtrInstance< QueryBox > aBox(this, MessBoxStyle::YesNo|MessBoxStyle::DefaultYes, aBuf.makeStringAndClear()); - - if (RET_YES == aBox->Execute()) + std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(GetFrameWeld(), + VclMessageType::Question, VclButtonsType::YesNo, + aBuf.makeStringAndClear())); + xQueryBox->set_default_response(RET_YES); + if (RET_YES == xQueryBox->run()) { SCTAB nTab; SCCOL nColStart, nColEnd; diff --git a/sc/source/ui/docshell/dbdocfun.cxx b/sc/source/ui/docshell/dbdocfun.cxx index 1c413903a35a..841b1c792486 100644 --- a/sc/source/ui/docshell/dbdocfun.cxx +++ b/sc/source/ui/docshell/dbdocfun.cxx @@ -1298,9 +1298,12 @@ bool ScDBDocFunc::DataPilotUpdate( ScDPObject* pOldObj, const ScDPObject* pNewOb // OutRange of pOldObj (pDestObj) is still old area if (!lcl_EmptyExcept(&rDoc, aNewOut, pOldObj->GetOutRange())) { - ScopedVclPtrInstance<QueryBox> aBox( ScDocShell::GetActiveDialogParent(), MessBoxStyle::YesNo | MessBoxStyle::DefaultYes, - ScGlobal::GetRscString(STR_PIVOT_NOTEMPTY) ); - if (aBox->Execute() == RET_NO) + vcl::Window* pWin = ScDocShell::GetActiveDialogParent(); + std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(pWin ? pWin->GetFrameWeld() : nullptr, + VclMessageType::Question, VclButtonsType::YesNo, + ScGlobal::GetRscString(STR_PIVOT_NOTEMPTY))); + xQueryBox->set_default_response(RET_YES); + if (xQueryBox->run() == RET_NO) { //! like above (not editable) *pOldObj = aUndoDPObj; @@ -1349,10 +1352,12 @@ bool ScDBDocFunc::RemovePivotTable(ScDPObject& rDPObj, bool bRecord, bool bApi) if (pModel && !aListOfObjects.empty()) { - ScopedVclPtrInstance<QueryBox> aBox( - ScDocShell::GetActiveDialogParent(), MessBoxStyle::YesNo | MessBoxStyle::DefaultYes, - ScGlobal::GetRscString(STR_PIVOT_REMOVE_PIVOTCHART)); - if (aBox->Execute() == RET_NO) + vcl::Window* pWin = ScDocShell::GetActiveDialogParent(); + std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(pWin ? pWin->GetFrameWeld() : nullptr, + VclMessageType::Question, VclButtonsType::YesNo, + ScGlobal::GetRscString(STR_PIVOT_REMOVE_PIVOTCHART))); + xQueryBox->set_default_response(RET_YES); + if (xQueryBox->run() == RET_NO) { return false; } @@ -1493,11 +1498,12 @@ bool ScDBDocFunc::CreatePivotTable(const ScDPObject& rDPObj, bool bRecord, bool if (!bEmpty) { - ScopedVclPtrInstance<QueryBox> aBox( - ScDocShell::GetActiveDialogParent(), MessBoxStyle::YesNo | MessBoxStyle::DefaultYes, - ScGlobal::GetRscString(STR_PIVOT_NOTEMPTY)); - - if (aBox->Execute() == RET_NO) + vcl::Window* pWin = ScDocShell::GetActiveDialogParent(); + std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(pWin ? pWin->GetFrameWeld() : nullptr, + VclMessageType::Question, VclButtonsType::YesNo, + ScGlobal::GetRscString(STR_PIVOT_NOTEMPTY))); + xQueryBox->set_default_response(RET_YES); + if (xQueryBox->run() == RET_NO) { //! like above (not editable) return false; @@ -1567,9 +1573,12 @@ bool ScDBDocFunc::UpdatePivotTable(ScDPObject& rDPObj, bool bRecord, bool bApi) { if (!lcl_EmptyExcept(&rDoc, aNewOut, rDPObj.GetOutRange())) { - ScopedVclPtrInstance<QueryBox> aBox( ScDocShell::GetActiveDialogParent(), MessBoxStyle::YesNo | MessBoxStyle::DefaultYes, - ScGlobal::GetRscString(STR_PIVOT_NOTEMPTY) ); - if (aBox->Execute() == RET_NO) + vcl::Window* pWin = ScDocShell::GetActiveDialogParent(); + std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(pWin ? pWin->GetFrameWeld() : nullptr, + VclMessageType::Question, VclButtonsType::YesNo, + ScGlobal::GetRscString(STR_PIVOT_NOTEMPTY))); + xQueryBox->set_default_response(RET_YES); + if (xQueryBox->run() == RET_NO) { rDPObj = aUndoDPObj; return false; diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx index 4ac78e1b67a0..e8705d760aa0 100644 --- a/sc/source/ui/docshell/docfunc.cxx +++ b/sc/source/ui/docshell/docfunc.cxx @@ -5106,9 +5106,14 @@ void ScDocFunc::CreateOneName( ScRangeName& rList, aMessage += aName; aMessage += aTemplate.getToken( 1, '#' ); - short nResult = ScopedVclPtrInstance<QueryBox>( ScDocShell::GetActiveDialogParent(), - MessBoxStyle::YesNoCancel | MessBoxStyle::DefaultYes, - aMessage )->Execute(); + vcl::Window* pWin = ScDocShell::GetActiveDialogParent(); + std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(pWin ? pWin->GetFrameWeld() : nullptr, + VclMessageType::Question, VclButtonsType::YesNo, + aMessage)); + xQueryBox->add_button(Button::GetStandardText(StandardButtonType::Cancel), RET_CANCEL); + xQueryBox->set_default_response(RET_YES); + + short nResult = xQueryBox->run(); if ( nResult == RET_YES ) { rList.erase(*pOld); diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx index 7815e68d5566..767d5a502827 100644 --- a/sc/source/ui/docshell/docsh.cxx +++ b/sc/source/ui/docshell/docsh.cxx @@ -26,6 +26,7 @@ #include <comphelper/classids.hxx> #include <formula/errorcodes.hxx> #include <vcl/msgbox.hxx> +#include <vcl/weld.hxx> #include <vcl/virdev.hxx> #include <vcl/waitobj.hxx> #include <rtl/bootstrap.hxx> @@ -473,14 +474,29 @@ bool ScDocShell::LoadXML( SfxMedium* pLoadMedium, const css::uno::Reference< css { // Generator is not LibreOffice. Ask if the user wants to perform // full re-calculation. - ScopedVclPtrInstance<QueryBox> aBox( - GetActiveDialogParent(), MessBoxStyle::YesNo | MessBoxStyle::DefaultYes, - ScGlobal::GetRscString(STR_QUERY_FORMULA_RECALC_ONLOAD_ODS)); - aBox->SetCheckBoxText(ScGlobal::GetRscString(STR_ALWAYS_PERFORM_SELECTED)); + vcl::Window* pWin = GetActiveDialogParent(); - bHardRecalc = aBox->Execute() == RET_YES; + std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(pWin ? pWin->GetFrameWeld() : nullptr, + "modules/scalc/ui/recalcquerydialog.ui")); + std::unique_ptr<weld::MessageDialog> xQueryBox(xBuilder->weld_message_dialog("RecalcQueryDialog")); + xQueryBox->set_primary_text(ScGlobal::GetRscString(STR_QUERY_FORMULA_RECALC_ONLOAD_ODS)); + xQueryBox->set_default_response(RET_YES); + std::unique_ptr<weld::CheckButton> xWarningOnBox(xBuilder->weld_check_button("ask")); - if (aBox->GetCheckBoxState()) + //fdo#75121, a bit tricky because the widgets we want to align with + //don't actually exist in the ui description, they're implied + std::unique_ptr<weld::Container> xOrigParent(xWarningOnBox->weld_parent()); + std::unique_ptr<weld::Container> xContentArea(xQueryBox->weld_message_area()); + xOrigParent->remove(xWarningOnBox.get()); + xContentArea->add(xWarningOnBox.get()); + + bHardRecalc = xQueryBox->run() == RET_YES; + + //put them back as they were + xContentArea->remove(xWarningOnBox.get()); + xOrigParent->add(xWarningOnBox.get()); + + if (xWarningOnBox->get_active()) { // Always perform selected action in the future. std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create()); diff --git a/sc/source/ui/docshell/docsh3.cxx b/sc/source/ui/docshell/docsh3.cxx index f13a23113498..582f39aad829 100644 --- a/sc/source/ui/docshell/docsh3.cxx +++ b/sc/source/ui/docshell/docsh3.cxx @@ -1204,9 +1204,12 @@ bool ScDocShell::MergeSharedDocument( ScDocShell* pSharedDocShell ) ScopedVclPtrInstance< ScConflictsDlg > aDlg( GetActiveDialogParent(), GetViewData(), &rSharedDoc, aConflictsList ); if ( aDlg->Execute() == RET_CANCEL ) { - ScopedVclPtrInstance<QueryBox> aBox( GetActiveDialogParent(), MessBoxStyle::YesNo | MessBoxStyle::DefaultYes, - ScGlobal::GetRscString( STR_DOC_WILLNOTBESAVED ) ); - if ( aBox->Execute() == RET_YES ) + vcl::Window* pWin = GetActiveDialogParent(); + std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(pWin ? pWin->GetFrameWeld() : nullptr, + VclMessageType::Question, VclButtonsType::YesNo, + ScGlobal::GetRscString(STR_DOC_WILLNOTBESAVED))); + xQueryBox->set_default_response(RET_YES); + if (xQueryBox->run() == RET_YES) { return false; } diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx index 749ec29784a7..17f597270876 100644 --- a/sc/source/ui/docshell/docsh4.cxx +++ b/sc/source/ui/docshell/docsh4.cxx @@ -261,8 +261,11 @@ void ScDocShell::Execute( SfxRequest& rReq ) aMessage += sTarget; aMessage += aTemplate.getToken( 1, '#' ); - ScopedVclPtrInstance< QueryBox > aBox( nullptr, MessBoxStyle::YesNo | MessBoxStyle::DefaultYes, aMessage ); - bDo = ( aBox->Execute() == RET_YES ); + std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(nullptr, + VclMessageType::Question, VclButtonsType::YesNo, + aMessage)); + xQueryBox->set_default_response(RET_YES); + bDo = xQueryBox->run() == RET_YES; } if (bDo) @@ -521,9 +524,12 @@ void ScDocShell::Execute( SfxRequest& rReq ) OSL_ENSURE(pViewSh,"SID_REIMPORT_AFTER_LOAD: no View"); if (pViewSh && pDBColl) { - ScopedVclPtrInstance<QueryBox> aBox( GetActiveDialogParent(), MessBoxStyle::YesNo | MessBoxStyle::DefaultYes, - ScGlobal::GetRscString(STR_REIMPORT_AFTER_LOAD) ); - if (aBox->Execute() == RET_YES) + vcl::Window* pWin = GetActiveDialogParent(); + std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(pWin ? pWin->GetFrameWeld() : nullptr, + VclMessageType::Question, VclButtonsType::YesNo, + ScGlobal::GetRscString(STR_REIMPORT_AFTER_LOAD))); + xQueryBox->set_default_response(RET_YES); + if (xQueryBox->run() == RET_YES) { ScDBCollection::NamedDBs& rDBs = pDBColl->getNamedDBs(); ScDBCollection::NamedDBs::iterator itr = rDBs.begin(), itrEnd = rDBs.end(); @@ -973,11 +979,12 @@ void ScDocShell::Execute( SfxRequest& rReq ) bool bContinue = true; if ( HasName() ) { - ScopedVclPtrInstance<QueryBox> aBox( - GetActiveDialogParent(), - MessBoxStyle::YesNo | MessBoxStyle::DefaultYes, - ScGlobal::GetRscString( STR_DOC_WILLBESAVED ) ); - if ( aBox->Execute() == RET_NO ) + vcl::Window* pWin = GetActiveDialogParent(); + std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(pWin ? pWin->GetFrameWeld() : nullptr, + VclMessageType::Question, VclButtonsType::YesNo, + ScGlobal::GetRscString(STR_REIMPORT_AFTER_LOAD))); + xQueryBox->set_default_response(RET_YES); + if (xQueryBox->run() == RET_NO) { bContinue = false; } diff --git a/sc/source/ui/miscdlgs/crnrdlg.cxx b/sc/source/ui/miscdlgs/crnrdlg.cxx index 7eae143a4565..1c464898b75b 100644 --- a/sc/source/ui/miscdlgs/crnrdlg.cxx +++ b/sc/source/ui/miscdlgs/crnrdlg.cxx @@ -23,7 +23,6 @@ #include <globstr.hrc> #include <docsh.hxx> #include <crnrdlg.hxx> -#include <vcl/msgbox.hxx> #include <vcl/weld.hxx> #include <memory> @@ -34,10 +33,19 @@ namespace std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(pParent, VclMessageType::Warning, VclButtonsType::Ok, rString)); + xBox->run(); } -} -#define QUERYBOX(m) ScopedVclPtrInstance<QueryBox>(this, MessBoxStyle::YesNo|MessBoxStyle::DefaultYes, m)->Execute() + int QUERYBOX(weld::Window* pParent, const OUString& rString) + { + std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(pParent, + VclMessageType::Question, VclButtonsType::YesNo, + rString)); + xBox->set_default_response(RET_YES); + return xBox->run(); + } + +} const sal_uLong nEntryDataCol = 0; const sal_uLong nEntryDataRow = 1; @@ -606,7 +614,7 @@ IMPL_LINK_NOARG(ScColRowNameRangesDlg, RemoveBtnHdl, Button*, void) + aRangeStr + aStrDelMsg.getToken( 1, '#' ); - if ( RET_YES == QUERYBOX(aMsg) ) + if (RET_YES == QUERYBOX(GetFrameWeld(), aMsg)) { if ( bColName ) xColNameRanges->Remove( pPair ); diff --git a/sc/source/ui/miscdlgs/scuiautofmt.cxx b/sc/source/ui/miscdlgs/scuiautofmt.cxx index 455091f6f86e..57579606eaa0 100644 --- a/sc/source/ui/miscdlgs/scuiautofmt.cxx +++ b/sc/source/ui/miscdlgs/scuiautofmt.cxx @@ -32,7 +32,7 @@ #include <editeng/udlnitem.hxx> #include <editeng/wghtitem.hxx> #include <svl/zforlist.hxx> -#include <vcl/msgbox.hxx> +#include <vcl/svapp.hxx> #include <vcl/weld.hxx> #include <comphelper/processfactory.hxx> #include <sfx2/strings.hrc> @@ -286,8 +286,12 @@ IMPL_LINK_NOARG(ScAutoFormatDlg, RemoveHdl, Button*, void) + m_pLbFormat->GetSelectedEntry() + aStrDelMsg.getToken( 1, '#' ); - if ( RET_YES == - ScopedVclPtrInstance<QueryBox>( this, MessBoxStyle::YesNo | MessBoxStyle::DefaultYes, aMsg )->Execute() ) + std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(GetFrameWeld(), + VclMessageType::Question, VclButtonsType::YesNo, + aMsg)); + xQueryBox->set_default_response(RET_YES); + + if (RET_YES == xQueryBox->run()) { m_pLbFormat->RemoveEntry( nIndex ); m_pLbFormat->SelectEntryPos( nIndex-1 ); diff --git a/sc/source/ui/navipi/scenwnd.cxx b/sc/source/ui/navipi/scenwnd.cxx index ea9dd1af7205..b0ffd8b125ab 100644 --- a/sc/source/ui/navipi/scenwnd.cxx +++ b/sc/source/ui/navipi/scenwnd.cxx @@ -24,6 +24,7 @@ #include <svl/stritem.hxx> #include <vcl/msgbox.hxx> #include <vcl/svapp.hxx> +#include <vcl/weld.hxx> #include <vcl/settings.hxx> #include <navipi.hxx> #include <scresid.hxx> @@ -183,8 +184,14 @@ void ScScenarioListBox::EditScenario() void ScScenarioListBox::DeleteScenario() { if( GetSelectedEntryCount() > 0 ) - if( ScopedVclPtrInstance<QueryBox>( nullptr, MessBoxStyle::YesNo | MessBoxStyle::DefaultYes, ScGlobal::GetRscString( STR_QUERY_DELSCENARIO ) )->Execute() == RET_YES ) + { + std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(nullptr, + VclMessageType::Question, VclButtonsType::YesNo, + ScGlobal::GetRscString(STR_QUERY_DELSCENARIO))); + xQueryBox->set_default_response(RET_YES); + if (xQueryBox->run() == RET_YES) ExecuteScenarioSlot( SID_DELETE_SCENARIO ); + } } // class ScScenarioWindow ------------------------------------------------ diff --git a/sc/source/ui/optdlg/tpusrlst.cxx b/sc/source/ui/optdlg/tpusrlst.cxx index 52e671bcb33d..1d76dd9ca94f 100644 --- a/sc/source/ui/optdlg/tpusrlst.cxx +++ b/sc/source/ui/optdlg/tpusrlst.cxx @@ -20,7 +20,6 @@ #undef SC_DLLIMPLEMENTATION #include <comphelper/string.hxx> -#include <vcl/msgbox.hxx> #include <vcl/weld.hxx> #include <global.hxx> @@ -617,10 +616,12 @@ IMPL_LINK( ScTpUserLists, BtnClickHdl, Button*, pBtn, void ) + mpLbLists->GetEntry( nRemovePos ) + aStrQueryRemove.getToken( 1, '#' ); - if ( RET_YES == ScopedVclPtrInstance<QueryBox>( this, - MessBoxStyle::YesNo | MessBoxStyle::DefaultYes, - aMsg - )->Execute() ) + std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(GetFrameWeld(), + VclMessageType::Question, VclButtonsType::YesNo, + aMsg)); + xQueryBox->set_default_response(RET_YES); + + if (RET_YES == xQueryBox->run()) { RemoveList( nRemovePos ); UpdateUserListBox(); diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx index f24c6b4c60a6..8c8ecb6b4426 100644 --- a/sc/source/ui/view/cellsh1.cxx +++ b/sc/source/ui/view/cellsh1.cxx @@ -34,7 +34,6 @@ #include <svl/zformat.hxx> #include <sfx2/dispatch.hxx> #include <sfx2/request.hxx> -#include <vcl/msgbox.hxx> #include <vcl/weld.hxx> #include <svx/svxdlg.hxx> #include <sot/formats.hxx> @@ -2015,9 +2014,12 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq ) // or should create a new overlapping conditional format if(!bCondFormatDlg && bContainsExistingCondFormat) { - ScopedVclPtrInstance<QueryBox> aBox( pTabViewShell->GetDialogParent(), MessBoxStyle::YesNo | MessBoxStyle::DefaultYes, - ScGlobal::GetRscString(STR_EDIT_EXISTING_COND_FORMATS) ); - bool bEditExisting = aBox->Execute() == RET_YES; + vcl::Window* pWin = pTabViewShell->GetDialogParent(); + std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(pWin ? pWin->GetFrameWeld() : nullptr, + VclMessageType::Question, VclButtonsType::YesNo, + ScGlobal::GetRscString(STR_EDIT_EXISTING_COND_FORMATS))); + xQueryBox->set_default_response(RET_YES); + bool bEditExisting = xQueryBox->run() == RET_YES; if(bEditExisting) { // differentiate between ranges where one conditional format is defined @@ -2930,11 +2932,12 @@ void ScCellShell::ExecuteDataPilotDialog() if ( pDoc->HasSubTotalCells( aRange ) ) { // confirm selection if it contains SubTotal cells - - ScopedVclPtrInstance<QueryBox> aBox( pTabViewShell->GetDialogParent(), - MessBoxStyle::YesNo | MessBoxStyle::DefaultYes, - ScGlobal::GetRscString(STR_DATAPILOT_SUBTOTAL) ); - if (aBox->Execute() == RET_NO) + vcl::Window* pWin = pTabViewShell->GetDialogParent(); + std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(pWin ? pWin->GetFrameWeld() : nullptr, + VclMessageType::Question, VclButtonsType::YesNo, + ScGlobal::GetRscString(STR_DATAPILOT_SUBTOTAL))); + xQueryBox->set_default_response(RET_YES); + if (xQueryBox->run() == RET_NO) bOK = false; } if (bOK) diff --git a/sc/source/ui/view/cellsh3.cxx b/sc/source/ui/view/cellsh3.cxx index ce2c030ac55c..3322d1701c56 100644 --- a/sc/source/ui/view/cellsh3.cxx +++ b/sc/source/ui/view/cellsh3.cxx @@ -25,7 +25,6 @@ #include <sfx2/dispatch.hxx> #include <sfx2/request.hxx> #include <svl/stritem.hxx> -#include <vcl/msgbox.hxx> #include <vcl/weld.hxx> #include <sfx2/app.hxx> #include <globstr.hrc> @@ -418,11 +417,19 @@ void ScCellShell::Execute( SfxRequest& rReq ) rMark.MarkToMulti(); if ( rMark.IsMultiMarked() ) { - if ( rReq.IsAPI() - || RET_YES == - ScopedVclPtrInstance<QueryBox>( pTabViewShell->GetDialogParent(), MessBoxStyle::YesNo | MessBoxStyle::DefaultYes, - ScGlobal::GetRscString(STR_UPDATE_SCENARIO) )-> - Execute() ) + + bool bExtend = rReq.IsAPI(); + if (!bExtend) + { + vcl::Window* pWin = pTabViewShell->GetDialogParent(); + std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(pWin ? pWin->GetFrameWeld() : nullptr, + VclMessageType::Question, VclButtonsType::YesNo, + ScGlobal::GetRscString(STR_UPDATE_SCENARIO))); + xQueryBox->set_default_response(RET_YES); + bExtend = xQueryBox->run() == RET_YES; + } + + if (bExtend) { pTabViewShell->ExtendScenario(); rReq.Done(); diff --git a/sc/source/ui/view/tabvwshf.cxx b/sc/source/ui/view/tabvwshf.cxx index 75f2d375a2cb..2549dbc8caad 100644 --- a/sc/source/ui/view/tabvwshf.cxx +++ b/sc/source/ui/view/tabvwshf.cxx @@ -29,7 +29,7 @@ #include <svl/languageoptions.hxx> #include <svl/stritem.hxx> #include <svl/whiter.hxx> -#include <vcl/msgbox.hxx> +#include <vcl/svapp.hxx> #include <vcl/weld.hxx> #include <sfx2/objface.hxx> #include <svx/svxdlg.hxx> @@ -621,21 +621,26 @@ void ScTabViewShell::ExecuteTable( SfxRequest& rReq ) } } + vcl::Window* pWin = GetDialogParent(); if (bTabWithPivotTable) { + std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(pWin ? pWin->GetFrameWeld() : nullptr, + VclMessageType::Question, VclButtonsType::YesNo, + ScGlobal::GetRscString(STR_QUERY_PIVOTTABLE_DELTAB))); + xQueryBox->set_default_response(RET_NO); + // Hard warning as there is potential of data loss on deletion - bDoIt = ( RET_YES == - ScopedVclPtrInstance<QueryBox>( GetDialogParent(), - MessBoxStyle::YesNo | MessBoxStyle::DefaultNo, - ScGlobal::GetRscString(STR_QUERY_PIVOTTABLE_DELTAB))->Execute() ); + bDoIt = (RET_YES == xQueryBox->run()); } else { + std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(pWin ? pWin->GetFrameWeld() : nullptr, + VclMessageType::Question, VclButtonsType::YesNo, + ScGlobal::GetRscString(STR_QUERY_DELTAB))); + xQueryBox->set_default_response(RET_YES); + // no parameter given, ask for confirmation - bDoIt = ( RET_YES == - ScopedVclPtrInstance<QueryBox>( GetDialogParent(), - MessBoxStyle::YesNo | MessBoxStyle::DefaultYes, - ScGlobal::GetRscString(STR_QUERY_DELTAB))->Execute() ); + bDoIt = (RET_YES == xQueryBox->run()); } } diff --git a/sc/source/ui/view/viewfun3.cxx b/sc/source/ui/view/viewfun3.cxx index 83b3a51edd86..623966231e62 100644 --- a/sc/source/ui/view/viewfun3.cxx +++ b/sc/source/ui/view/viewfun3.cxx @@ -32,7 +32,7 @@ #include <sot/storage.hxx> #include <vcl/graph.hxx> #include <vcl/virdev.hxx> -#include <vcl/msgbox.hxx> +#include <vcl/weld.hxx> #include <tools/urlobj.hxx> #include <sot/exchange.hxx> #include <memory> @@ -1052,9 +1052,13 @@ bool ScViewFunc::PasteFromClip( InsertDeleteFlags nFlags, ScDocument* pClipDoc, { ScWaitCursorOff aWaitOff( GetFrameWin() ); OUString aMessage = ScGlobal::GetRscString( STR_PASTE_BIGGER ); - ScopedVclPtrInstance<QueryBox> aBox( GetViewData().GetDialogParent(), - MessBoxStyle::YesNo | MessBoxStyle::DefaultNo, aMessage ); - if ( aBox->Execute() != RET_YES ) + + vcl::Window* pWin = GetViewData().GetDialogParent(); + std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(pWin ? pWin->GetFrameWeld() : nullptr, + VclMessageType::Question, VclButtonsType::YesNo, + aMessage)); + xQueryBox->set_default_response(RET_NO); + if (xQueryBox->run() != RET_YES) { return false; } diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx index 4dd346c5d3ab..bd21e085d265 100644 --- a/sc/source/ui/view/viewfunc.cxx +++ b/sc/source/ui/view/viewfunc.cxx @@ -34,7 +34,7 @@ #include <sfx2/bindings.hxx> #include <svl/zforlist.hxx> #include <svl/zformat.hxx> -#include <vcl/msgbox.hxx> +#include <vcl/weld.hxx> #include <vcl/virdev.hxx> #include <vcl/waitobj.hxx> #include <vcl/wrkwin.hxx> @@ -442,9 +442,13 @@ void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab, { OUString aMessage( ScResId( SCSTR_FORMULA_AUTOCORRECTION ) ); aMessage += aCorrectedFormula; - nResult = ScopedVclPtrInstance<QueryBox>( GetViewData().GetDialogParent(), - MessBoxStyle::YesNo | MessBoxStyle::DefaultYes, - aMessage )->Execute(); + + vcl::Window* pWin = GetViewData().GetDialogParent(); + std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(pWin ? pWin->GetFrameWeld() : nullptr, + VclMessageType::Question, VclButtonsType::YesNo, + aMessage)); + xQueryBox->set_default_response(RET_YES); + nResult = xQueryBox->run(); } if ( nResult == RET_YES ) { diff --git a/sc/uiconfig/scalc/ui/recalcquerydialog.ui b/sc/uiconfig/scalc/ui/recalcquerydialog.ui new file mode 100644 index 000000000000..3c21f9663c49 --- /dev/null +++ b/sc/uiconfig/scalc/ui/recalcquerydialog.ui @@ -0,0 +1,46 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Generated with glade 3.20.2 --> +<interface domain="pcr"> + <requires lib="gtk+" version="3.20"/> + <object class="GtkMessageDialog" id="RecalcQueryDialog"> + <property name="can_focus">False</property> + <property name="type_hint">dialog</property> + <property name="message_type">question</property> + <property name="buttons">yes-no</property> + <child internal-child="vbox"> + <object class="GtkBox"> + <property name="can_focus">False</property> + <property name="orientation">vertical</property> + <property name="spacing">2</property> + <child internal-child="action_area"> + <object class="GtkButtonBox"> + <property name="can_focus">False</property> + <property name="homogeneous">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="ask"> + <property name="label" translatable="yes" context="recalcquerydialog|ask">Always perform this without prompt in the future.</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="draw_indicator">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">2</property> + </packing> + </child> + </object> + </child> + <child> + <placeholder/> + </child> + </object> +</interface> diff --git a/sd/source/core/drawdoc3.cxx b/sd/source/core/drawdoc3.cxx index 3e50db1f9643..bd731f255465 100644 --- a/sd/source/core/drawdoc3.cxx +++ b/sd/source/core/drawdoc3.cxx @@ -466,7 +466,11 @@ bool SdDrawDocument::InsertBookmarkAsPage( pBMPage->GetLowerBorder() != pRefPage->GetLowerBorder()) { OUString aStr(SdResId(STR_SCALE_OBJECTS)); - sal_uInt16 nBut = ScopedVclPtrInstance<QueryBox>(nullptr, MessBoxStyle::YesNoCancel, aStr)->Execute(); + std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(nullptr, + VclMessageType::Question, VclButtonsType::YesNo, + aStr)); + xQueryBox->add_button(Button::GetStandardText(StandardButtonType::Cancel), RET_CANCEL); + sal_uInt16 nBut = xQueryBox->run(); bScaleObjects = nBut == RET_YES; bContinue = nBut != RET_CANCEL; diff --git a/sd/source/ui/annotations/annotationmanager.cxx b/sd/source/ui/annotations/annotationmanager.cxx index d12e80d2e91a..2294115c0394 100644 --- a/sd/source/ui/annotations/annotationmanager.cxx +++ b/sd/source/ui/annotations/annotationmanager.cxx @@ -33,7 +33,7 @@ #include <vcl/commandinfoprovider.hxx> #include <vcl/settings.hxx> #include <vcl/menu.hxx> -#include <vcl/msgbox.hxx> +#include <vcl/weld.hxx> #include <sal/macros.h> #include <svl/style.hxx> @@ -837,9 +837,11 @@ void AnnotationManagerImpl::SelectNextAnnotation(bool bForeward) // Pop up question box that asks the user whether to wrap around. // The dialog is made modal with respect to the whole application. - ScopedVclPtrInstance< QueryBox > aQuestionBox( nullptr, (MessBoxStyle::YesNo | MessBoxStyle::DefaultYes), SdResId(pStringId)); - aQuestionBox->SetImage( QueryBox::GetStandardImage() ); - if (aQuestionBox->Execute() != RET_YES) + std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(nullptr, + VclMessageType::Question, VclButtonsType::YesNo, + SdResId(pStringId))); + xQueryBox->set_default_response(RET_YES); + if (xQueryBox->run() != RET_YES) break; } while( true ); diff --git a/sd/source/ui/view/drviews4.cxx b/sd/source/ui/view/drviews4.cxx index 84ae97063822..5638ab8e3bdf 100644 --- a/sd/source/ui/view/drviews4.cxx +++ b/sd/source/ui/view/drviews4.cxx @@ -20,7 +20,7 @@ #include <com/sun/star/drawing/XDrawPagesSupplier.hpp> #include <DrawViewShell.hxx> -#include <vcl/msgbox.hxx> +#include <vcl/weld.hxx> #include <svl/urlbmk.hxx> #include <svx/svdpagv.hxx> #include <svx/svdundo.hxx> @@ -105,7 +105,11 @@ void DrawViewShell::DeleteActualLayer() // replace placeholder aString = aString.replaceFirst("$", rName); - if (ScopedVclPtrInstance<QueryBox>(GetActiveWindow(), MessBoxStyle::YesNo, aString)->Execute() == RET_YES) + vcl::Window* pWin = GetActiveWindow(); + std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(pWin ? pWin->GetFrameWeld() : nullptr, + VclMessageType::Question, VclButtonsType::YesNo, + aString)); + if (xQueryBox->run() == RET_YES) { const SdrLayer* pLayer = rAdmin.GetLayer(rName); mpDrawView->DeleteLayer( pLayer->GetName() ); diff --git a/sd/source/ui/view/drviewse.cxx b/sd/source/ui/view/drviewse.cxx index 151c1fa10c47..7abbb36c82a9 100644 --- a/sd/source/ui/view/drviewse.cxx +++ b/sd/source/ui/view/drviewse.cxx @@ -33,7 +33,6 @@ #include <vcl/waitobj.hxx> #include <svl/aeitem.hxx> #include <editeng/editstat.hxx> -#include <vcl/msgbox.hxx> #include <vcl/weld.hxx> #include <svl/urlbmk.hxx> #include <svx/svdpagv.hxx> @@ -326,21 +325,25 @@ void DrawViewShell::FuPermanent(SfxRequest& rReq) if ( mpDrawView->GetMarkedObjectList().GetMarkCount() > 0 && !mpDrawView->IsCrookAllowed( mpDrawView->IsCrookNoContortion() ) ) { + ::sd::Window* pWindow = GetActiveWindow(); if ( mpDrawView->IsPresObjSelected() ) { - ::sd::Window* pWindow = GetActiveWindow(); std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(pWindow ? pWindow->GetFrameWeld() : nullptr, VclMessageType::Info, VclButtonsType::Ok, SdResId(STR_ACTION_NOTPOSSIBLE))); xInfoBox->run(); } - else if ( ScopedVclPtrInstance<QueryBox>(GetActiveWindow(), MessBoxStyle::YesNo, - SdResId(STR_ASK_FOR_CONVERT_TO_BEZIER) - )->Execute() == RET_YES ) + else { - // implicit transformation into bezier - WaitObject aWait( GetActiveWindow() ); - mpDrawView->ConvertMarkedToPathObj(false); + std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(pWindow ? pWindow->GetFrameWeld() : nullptr, + VclMessageType::Question, VclButtonsType::YesNo, + SdResId(STR_ASK_FOR_CONVERT_TO_BEZIER))); + if (xQueryBox->run() == RET_YES ) + { + // implicit transformation into bezier + WaitObject aWait( GetActiveWindow() ); + mpDrawView->ConvertMarkedToPathObj(false); + } } } } @@ -366,21 +369,25 @@ void DrawViewShell::FuPermanent(SfxRequest& rReq) if ( nMarkCnt > 0 && !b3DObjMarked && (!mpDrawView->IsShearAllowed() || !mpDrawView->IsDistortAllowed()) ) { + ::sd::Window* pWindow = GetActiveWindow(); if ( mpDrawView->IsPresObjSelected() ) { - ::sd::Window* pWindow = GetActiveWindow(); std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(pWindow ? pWindow->GetFrameWeld() : nullptr, VclMessageType::Info, VclButtonsType::Ok, SdResId(STR_ACTION_NOTPOSSIBLE))); xInfoBox->run(); } - else if ( ScopedVclPtrInstance<QueryBox>(GetActiveWindow(), MessBoxStyle::YesNo, - SdResId(STR_ASK_FOR_CONVERT_TO_BEZIER) - )->Execute() == RET_YES ) + else { - // implicit transformation into bezier - WaitObject aWait( GetActiveWindow() ); - mpDrawView->ConvertMarkedToPathObj(false); + std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(pWindow ? pWindow->GetFrameWeld() : nullptr, + VclMessageType::Question, VclButtonsType::YesNo, + SdResId(STR_ASK_FOR_CONVERT_TO_BEZIER))); + if (xQueryBox->run() == RET_YES) + { + // implicit transformation into bezier + WaitObject aWait( GetActiveWindow() ); + mpDrawView->ConvertMarkedToPathObj(false); + } } } } diff --git a/sfx2/source/appl/linkmgr2.cxx b/sfx2/source/appl/linkmgr2.cxx index b6d5d4eb91fb..9ca22e8256e1 100644 --- a/sfx2/source/appl/linkmgr2.cxx +++ b/sfx2/source/appl/linkmgr2.cxx @@ -28,7 +28,8 @@ #include <tools/urlobj.hxx> #include <sot/exchange.hxx> #include <tools/debug.hxx> -#include <vcl/msgbox.hxx> +#include <vcl/svapp.hxx> +#include <vcl/weld.hxx> #include <sfx2/lnkbase.hxx> #include <sfx2/app.hxx> #include <vcl/graph.hxx> @@ -271,7 +272,7 @@ bool LinkManager::GetDisplayNames( const SvBaseLink * pLink, void LinkManager::UpdateAllLinks( bool bAskUpdate, bool bUpdateGrfLinks, - vcl::Window* pParentWin ) + weld::Window* pParentWin ) { // First make a copy of the array in order to update links // links in ... no contact between them! @@ -308,7 +309,12 @@ void LinkManager::UpdateAllLinks( if( bAskUpdate ) { - int nRet = ScopedVclPtrInstance<QueryBox>(pParentWin, MessBoxStyle::YesNo | MessBoxStyle::DefaultYes, SfxResId( STR_QUERY_UPDATE_LINKS ))->Execute(); + std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(pParentWin, + VclMessageType::Question, VclButtonsType::YesNo, + SfxResId(STR_QUERY_UPDATE_LINKS))); + xQueryBox->set_default_response(RET_YES); + + int nRet = xQueryBox->run(); if( RET_YES != nRet ) { SfxObjectShell* pShell = pLink->GetLinkManager()->GetPersist(); diff --git a/sfx2/source/bastyp/fltfnc.cxx b/sfx2/source/bastyp/fltfnc.cxx index d28c4ca27dad..5bbdfed0b7eb 100644 --- a/sfx2/source/bastyp/fltfnc.cxx +++ b/sfx2/source/bastyp/fltfnc.cxx @@ -36,7 +36,6 @@ #include <basic/sbxobj.hxx> #include <basic/sbxmeth.hxx> #include <basic/sbxcore.hxx> -#include <vcl/msgbox.hxx> #include <vcl/weld.hxx> #include <rtl/ustring.hxx> #include <rtl/ustrbuf.hxx> @@ -485,8 +484,12 @@ bool SfxFilterMatcher::IsFilterInstalled_Impl( const std::shared_ptr<const SfxFi // Here could a re-installation be offered OUString aText( SfxResId(STR_FILTER_NOT_INSTALLED) ); aText = aText.replaceFirst( "$(FILTER)", pFilter->GetUIName() ); - ScopedVclPtrInstance< QueryBox > aQuery(nullptr, MessBoxStyle::YesNo | MessBoxStyle::DefaultYes, aText); - short nRet = aQuery->Execute(); + std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(nullptr, + VclMessageType::Question, VclButtonsType::YesNo, + aText)); + xQueryBox->set_default_response(RET_YES); + + short nRet = xQueryBox->run(); if ( nRet == RET_YES ) { #ifdef DBG_UTIL diff --git a/sfx2/source/dialog/alienwarn.cxx b/sfx2/source/dialog/alienwarn.cxx index 66c9424067be..dd88541fbb29 100644 --- a/sfx2/source/dialog/alienwarn.cxx +++ b/sfx2/source/dialog/alienwarn.cxx @@ -22,66 +22,62 @@ #include <sfx2/sfxresid.hxx> #include <sfx2/sfxuno.hxx> #include <unotools/saveopt.hxx> -#include <vcl/msgbox.hxx> +#include <vcl/svapp.hxx> #include <alienwarn.hxx> -SfxAlienWarningDialog::SfxAlienWarningDialog(vcl::Window* pParent, const OUString& _rFormatName, +SfxAlienWarningDialog::SfxAlienWarningDialog(weld::Window* pParent, const OUString& _rFormatName, const OUString& _rDefaultExtension, bool rDefaultIsAlien) - : MessageDialog(pParent, "AlienWarnDialog", "sfx/ui/alienwarndialog.ui") + : m_xBuilder(Application::CreateBuilder(pParent, "sfx/ui/alienwarndialog.ui")) + , m_xDialog(m_xBuilder->weld_message_dialog("AlienWarnDialog")) + , m_xKeepCurrentBtn(m_xBuilder->weld_button("save")) + , m_xUseDefaultFormatBtn(m_xBuilder->weld_button("cancel")) + , m_xWarningOnBox(m_xBuilder->weld_check_button("ask")) + , m_xOrigParent(m_xWarningOnBox->weld_parent()) + , m_xContentArea(m_xDialog->weld_message_area()) { - get(m_pWarningOnBox, "ask"); //fdo#75121, a bit tricky because the widgets we want to align with //don't actually exist in the ui description, they're implied - m_pWarningOnBox->set_margin_left(QueryBox::GetStandardImage().GetSizePixel().Width() + 12); - - get(m_pKeepCurrentBtn, "save"); - get(m_pUseDefaultFormatBtn, "cancel"); + m_xOrigParent->remove(m_xWarningOnBox.get()); + m_xContentArea->add(m_xWarningOnBox.get()); OUString aExtension = "ODF"; // replace formatname (text) - OUString sInfoText = get_primary_text(); + OUString sInfoText = m_xDialog->get_primary_text(); sInfoText = sInfoText.replaceAll( "%FORMATNAME", _rFormatName ); - set_primary_text(sInfoText); + m_xDialog->set_primary_text(sInfoText); // replace formatname (button) - sInfoText = m_pKeepCurrentBtn->GetText(); + sInfoText = m_xKeepCurrentBtn->get_label(); sInfoText = sInfoText.replaceAll( "%FORMATNAME", _rFormatName ); - m_pKeepCurrentBtn->SetText( sInfoText ); + m_xKeepCurrentBtn->set_label(sInfoText); // hide ODF explanation if default format is alien // and set the proper extension in the button if( rDefaultIsAlien ) { - set_secondary_text(OUString()); + m_xDialog->set_secondary_text(OUString()); aExtension = _rDefaultExtension.toAsciiUpperCase(); } // replace defaultextension (button) - sInfoText = m_pUseDefaultFormatBtn->GetText(); + sInfoText = m_xUseDefaultFormatBtn->get_label(); sInfoText = sInfoText.replaceAll( "%DEFAULTEXTENSION", aExtension ); - m_pUseDefaultFormatBtn->SetText( sInfoText ); + m_xUseDefaultFormatBtn->set_label(sInfoText); // load value of "warning on" checkbox from save options - m_pWarningOnBox->Check( SvtSaveOptions().IsWarnAlienFormat() ); + m_xWarningOnBox->set_active(SvtSaveOptions().IsWarnAlienFormat()); } SfxAlienWarningDialog::~SfxAlienWarningDialog() { - disposeOnce(); -} - -void SfxAlienWarningDialog::dispose() -{ + m_xContentArea->remove(m_xWarningOnBox.get()); + m_xOrigParent->add(m_xWarningOnBox.get()); // save value of "warning off" checkbox, if necessary SvtSaveOptions aSaveOpt; - bool bChecked = m_pWarningOnBox->IsChecked(); - if ( aSaveOpt.IsWarnAlienFormat() != bChecked ) - aSaveOpt.SetWarnAlienFormat( bChecked ); - m_pKeepCurrentBtn.clear(); - m_pUseDefaultFormatBtn.clear(); - m_pWarningOnBox.clear(); - MessageDialog::dispose(); + bool bChecked = m_xWarningOnBox->get_active(); + if (aSaveOpt.IsWarnAlienFormat() != bChecked) + aSaveOpt.SetWarnAlienFormat(bChecked); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/dialog/recfloat.cxx b/sfx2/source/dialog/recfloat.cxx index 09fbdce65552..d023348f4548 100644 --- a/sfx2/source/dialog/recfloat.cxx +++ b/sfx2/source/dialog/recfloat.cxx @@ -18,7 +18,8 @@ */ #include <svl/eitem.hxx> -#include <vcl/msgbox.hxx> +#include <vcl/svapp.hxx> +#include <vcl/weld.hxx> #include <recfloat.hxx> #include <sfx2/strings.hrc> @@ -59,9 +60,14 @@ bool SfxRecordingFloatWrapper_Impl::QueryClose() css::uno::Reference< css::frame::XDispatchRecorder > xRecorder = pBindings->GetRecorder(); if ( xRecorder.is() && !xRecorder->getRecordedMacro().isEmpty() ) { - ScopedVclPtrInstance< QueryBox > aBox(GetWindow(), MessBoxStyle::YesNo | MessBoxStyle::DefaultNo , SfxResId(STR_MACRO_LOSS)); - aBox->SetText( SfxResId(STR_CANCEL_RECORDING) ); - bRet = ( aBox->Execute() == RET_YES ); + vcl::Window* pWin = GetWindow(); + std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(pWin ? pWin->GetFrameWeld() : nullptr, + VclMessageType::Question, VclButtonsType::YesNo, + SfxResId(STR_MACRO_LOSS))); + xQueryBox->set_default_response(RET_NO); + + xQueryBox->set_title(SfxResId(STR_CANCEL_RECORDING)); + bRet = (xQueryBox->run() == RET_YES); } return bRet; diff --git a/sfx2/source/doc/guisaveas.cxx b/sfx2/source/doc/guisaveas.cxx index 824f8598f3cc..cbdde2efbb52 100644 --- a/sfx2/source/doc/guisaveas.cxx +++ b/sfx2/source/doc/guisaveas.cxx @@ -1803,9 +1803,9 @@ bool SfxStoringHelper::WarnUnacceptableFormat( const uno::Reference< frame::XMod return true; vcl::Window* pWin = SfxStoringHelper::GetModelWindow( xModel ); - ScopedVclPtrInstance< SfxAlienWarningDialog > aDlg( pWin, aOldUIName, aDefExtension, bDefIsAlien ); + SfxAlienWarningDialog aDlg(pWin ? pWin->GetFrameWeld() : nullptr, aOldUIName, aDefExtension, bDefIsAlien); - return aDlg->Execute() == RET_OK; + return aDlg.run() == RET_OK; } vcl::Window* SfxStoringHelper::GetModelWindow( const uno::Reference< frame::XModel >& xModel ) diff --git a/sfx2/source/doc/querytemplate.cxx b/sfx2/source/doc/querytemplate.cxx index 9eef613c96e5..bc9ff49bf977 100644 --- a/sfx2/source/doc/querytemplate.cxx +++ b/sfx2/source/doc/querytemplate.cxx @@ -30,7 +30,7 @@ namespace sfx2 QueryTemplateBox::QueryTemplateBox( vcl::Window* pParent, const OUString& rMessage ) : MessBox ( pParent, MessBoxStyle::NONE, 0, Application::GetDisplayName(), rMessage ) { - SetImage( QueryBox::GetStandardImage() ); + SetImage(GetStandardQueryBoxImage()); SetHelpId( HID_QUERY_LOAD_TEMPLATE ); AddButton( SfxResId( STR_QRYTEMPL_UPDATE_BTN ), RET_YES, diff --git a/sfx2/source/inc/alienwarn.hxx b/sfx2/source/inc/alienwarn.hxx index 7d2414aad8bc..05f5a3835aee 100644 --- a/sfx2/source/inc/alienwarn.hxx +++ b/sfx2/source/inc/alienwarn.hxx @@ -19,21 +19,25 @@ #ifndef INCLUDED_SFX2_SOURCE_INC_ALIENWARN_HXX #define INCLUDED_SFX2_SOURCE_INC_ALIENWARN_HXX -#include <vcl/button.hxx> -#include <vcl/messagedialog.hxx> +#include <vcl/weld.hxx> -class SfxAlienWarningDialog : public MessageDialog +class SfxAlienWarningDialog { private: - VclPtr<PushButton> m_pKeepCurrentBtn; - VclPtr<PushButton> m_pUseDefaultFormatBtn; - VclPtr<CheckBox> m_pWarningOnBox; + std::unique_ptr<weld::Builder> m_xBuilder; + std::unique_ptr<weld::MessageDialog> m_xDialog; + std::unique_ptr<weld::Button> m_xKeepCurrentBtn; + std::unique_ptr<weld::Button> m_xUseDefaultFormatBtn; + std::unique_ptr<weld::CheckButton> m_xWarningOnBox; + + std::unique_ptr<weld::Container> m_xOrigParent; + std::unique_ptr<weld::Container> m_xContentArea; public: - SfxAlienWarningDialog(vcl::Window* pParent, const OUString& _rFormatName, + SfxAlienWarningDialog(weld::Window* pParent, const OUString& _rFormatName, const OUString& _rDefaultExtension, bool rDefaultIsAlien); - virtual ~SfxAlienWarningDialog() override; - virtual void dispose() override; + short run() { return m_xDialog->run(); } + ~SfxAlienWarningDialog(); }; #endif // INCLUDED_SFX2_SOURCE_INC_ALIENWARN_HXX diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx index 33978818fa44..c72f6a47a4a1 100644 --- a/sfx2/source/view/viewfrm.cxx +++ b/sfx2/source/view/viewfrm.cxx @@ -134,7 +134,8 @@ using ::com::sun::star::container::XIndexContainer; #include <sfx2/minfitem.hxx> #include <sfx2/strings.hrc> #include "impviewframe.hxx" -#include <vcl/msgbox.hxx> +#include <vcl/svapp.hxx> +#include <vcl/weld.hxx> #define SfxViewFrame #include <sfxslots.hxx> @@ -175,28 +176,23 @@ SfxEditDocumentDialog::SfxEditDocumentDialog(weld::Widget* pParent) { } -class SfxQueryOpenAsTemplate : public QueryBox +class SfxQueryOpenAsTemplate { +private: + std::unique_ptr<weld::MessageDialog> m_xQueryBox; public: - SfxQueryOpenAsTemplate(vcl::Window* pParent, MessBoxStyle nStyle, bool bAllowIgnoreLock); -}; - -SfxQueryOpenAsTemplate::SfxQueryOpenAsTemplate(vcl::Window* pParent, MessBoxStyle nStyle, bool bAllowIgnoreLock) - : QueryBox(pParent, nStyle, SfxResId(bAllowIgnoreLock ? STR_QUERY_OPENASTEMPLATE_ALLOW_IGNORE : STR_QUERY_OPENASTEMPLATE)) -{ - AddButton(SfxResId(STR_QUERY_OPENASTEMPLATE_OPENCOPY_BTN), RET_YES, - ButtonDialogFlags::Default | ButtonDialogFlags::OK | ButtonDialogFlags::Focus); - SetButtonHelpText(RET_YES, OUString()); - - if (bAllowIgnoreLock) + SfxQueryOpenAsTemplate(weld::Window* pParent, bool bAllowIgnoreLock) + : m_xQueryBox(Application::CreateMessageDialog(pParent, VclMessageType::Question, VclButtonsType::NONE, + SfxResId(bAllowIgnoreLock ? STR_QUERY_OPENASTEMPLATE_ALLOW_IGNORE : STR_QUERY_OPENASTEMPLATE))) { - AddButton(SfxResId(STR_QUERY_OPENASTEMPLATE_OPEN_BTN), RET_IGNORE); - SetButtonHelpText(RET_IGNORE, OUString()); + m_xQueryBox->add_button(SfxResId(STR_QUERY_OPENASTEMPLATE_OPENCOPY_BTN), RET_YES); + if (bAllowIgnoreLock) + m_xQueryBox->add_button(SfxResId(STR_QUERY_OPENASTEMPLATE_OPEN_BTN), RET_IGNORE); + m_xQueryBox->add_button(Button::GetStandardText( StandardButtonType::Cancel ), RET_CANCEL); + m_xQueryBox->set_default_response(RET_YES); } - - AddButton(StandardButtonType::Cancel, RET_CANCEL); - SetButtonHelpText(RET_CANCEL, OUString()); -} + short run() { return m_xQueryBox->run(); } +}; /// Is this read-only object shell opened via .uno:SignPDF? bool IsSignPDF(const SfxObjectShellRef& xObjSh) @@ -463,9 +459,9 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq ) if (nOpenMode == SFX_STREAM_READWRITE && !rReq.IsAPI()) { // css::sdbcx::User offering to open it as a template - ScopedVclPtrInstance<SfxQueryOpenAsTemplate> aBox(&GetWindow(), MessBoxStyle::NONE, bRetryIgnoringLock); + SfxQueryOpenAsTemplate aBox(GetWindow().GetFrameWeld(), bRetryIgnoringLock); - short nUserAnswer = aBox->Execute(); + short nUserAnswer = aBox.run(); bOpenTemplate = RET_YES == nUserAnswer; // Always reset this here to avoid infinite loop bRetryIgnoringLock = RET_IGNORE == nUserAnswer; diff --git a/solenv/bin/pack_images.py b/solenv/bin/pack_images.py index bd75b9044210..bd75b9044210 100644..100755 --- a/solenv/bin/pack_images.py +++ b/solenv/bin/pack_images.py diff --git a/svtools/source/graphic/provider.cxx b/svtools/source/graphic/provider.cxx index 3cbbd6ba752b..2afef15a646f 100644 --- a/svtools/source/graphic/provider.cxx +++ b/svtools/source/graphic/provider.cxx @@ -206,11 +206,11 @@ uno::Reference< ::graphic::XGraphic > GraphicProvider::implLoadStandardImage( co } else if ( sImageName == "error" ) { - xRet = Graphic(ErrorBox::GetStandardImage().GetBitmapEx()).GetXGraphic(); + xRet = Graphic(GetStandardErrorBoxImage().GetBitmapEx()).GetXGraphic(); } else if ( sImageName == "query" ) { - xRet = Graphic(QueryBox::GetStandardImage().GetBitmapEx()).GetXGraphic(); + xRet = Graphic(GetStandardQueryBoxImage().GetBitmapEx()).GetXGraphic(); } } return xRet; diff --git a/svx/source/dialog/prtqry.cxx b/svx/source/dialog/prtqry.cxx index 3f8ddf0934d4..6be88dff8c31 100644 --- a/svx/source/dialog/prtqry.cxx +++ b/svx/source/dialog/prtqry.cxx @@ -27,7 +27,7 @@ SvxPrtQryBox::SvxPrtQryBox(vcl::Window* pParent) : SvxResId(RID_SVXSTR_QRY_PRINT_TITLE), SvxResId(RID_SVXSTR_QRY_PRINT_MSG)) { - SetImage( QueryBox::GetStandardImage() ); + SetImage(GetStandardQueryBoxImage()); AddButton(SvxResId(RID_SVXSTR_QRY_PRINT_SELECTION), RET_OK, ButtonDialogFlags::Default | ButtonDialogFlags::OK | ButtonDialogFlags::Focus); diff --git a/svx/source/form/databaselocationinput.cxx b/svx/source/form/databaselocationinput.cxx index fd2497e38a11..1f024b4bba50 100644 --- a/svx/source/form/databaselocationinput.cxx +++ b/svx/source/form/databaselocationinput.cxx @@ -34,13 +34,11 @@ #include <unotools/confignode.hxx> #include <unotools/ucbhelper.hxx> #include <vcl/button.hxx> -#include <vcl/msgbox.hxx> - +#include <vcl/svapp.hxx> +#include <vcl/weld.hxx> namespace svx { - - using ::com::sun::star::uno::Sequence; using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::XComponentContext; @@ -124,8 +122,11 @@ namespace svx { if ( ::utl::UCBContentHelper::Exists( sURL ) ) { - ScopedVclPtrInstance< QueryBox > aBox( m_rLocationInput.GetSystemWindow(), MessBoxStyle::YesNo, SvxResId(RID_STR_ALREADYEXISTOVERWRITE) ); - if ( aBox->Execute() != RET_YES ) + vcl::Window* pWin = m_rLocationInput.GetSystemWindow(); + std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(pWin ? pWin->GetFrameWeld() : nullptr, + VclMessageType::Question, VclButtonsType::YesNo, + SvxResId(RID_STR_ALREADYEXISTOVERWRITE))); + if (xQueryBox->run() != RET_YES) return false; } } diff --git a/sw/source/core/doc/DocumentLinksAdministrationManager.cxx b/sw/source/core/doc/DocumentLinksAdministrationManager.cxx index 2d275359f57b..c30eeb382382 100644 --- a/sw/source/core/doc/DocumentLinksAdministrationManager.cxx +++ b/sw/source/core/doc/DocumentLinksAdministrationManager.cxx @@ -241,7 +241,7 @@ void DocumentLinksAdministrationManager::UpdateLinks() SfxMedium* pMedium = m_rDoc.GetDocShell()->GetMedium(); SfxFrame* pFrame = pMedium ? pMedium->GetLoadTargetFrame() : nullptr; - vcl::Window* pDlgParent = pFrame ? &pFrame->GetWindow() : nullptr; + weld::Window* pDlgParent = pFrame ? pFrame->GetWindow().GetFrameWeld() : nullptr; GetLinkManager().UpdateAllLinks( bAskUpdate, false, pDlgParent ); } diff --git a/sw/source/core/edit/edfcol.cxx b/sw/source/core/edit/edfcol.cxx index 8ace8092a783..4a0fcd5e6266 100644 --- a/sw/source/core/edit/edfcol.cxx +++ b/sw/source/core/edit/edfcol.cxx @@ -57,7 +57,7 @@ #include <svx/ClassificationCommon.hxx> #include <svl/cryptosign.hxx> #include <vcl/svapp.hxx> -#include <vcl/msgbox.hxx> +#include <vcl/weld.hxx> #include <hintids.hxx> #include <doc.hxx> @@ -2129,8 +2129,10 @@ void SwEditShell::ClassifyDocPerHighestParagraphClass() if (aClassificationCategory != sHighestClass) { - ScopedVclPtrInstance<QueryBox> aQueryBox(nullptr, MessBoxStyle::Ok, SwResId(STR_CLASSIFICATION_LEVEL_CHANGED)); - aQueryBox->Execute(); + std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(nullptr, + VclMessageType::Question, VclButtonsType::Ok, + SwResId(STR_CLASSIFICATION_LEVEL_CHANGED))); + xQueryBox->run(); } const SfxClassificationPolicyType eHighestClassType = SfxClassificationHelper::stringToPolicyType(sHighestClass); diff --git a/sw/source/ui/dbui/mmoutputtypepage.cxx b/sw/source/ui/dbui/mmoutputtypepage.cxx index 6212ae20cf5c..c77fadac9ca5 100644 --- a/sw/source/ui/dbui/mmoutputtypepage.cxx +++ b/sw/source/ui/dbui/mmoutputtypepage.cxx @@ -60,7 +60,6 @@ SwMailMergeOutputTypePage::SwMailMergeOutputTypePage(SwMailMergeWizard* pParent) else m_pMailRB->Check(); TypeHdl_Impl(m_pLetterRB); - } SwMailMergeOutputTypePage::~SwMailMergeOutputTypePage() @@ -235,6 +234,7 @@ SwSendWarningBox_Impl::SwSendWarningBox_Impl(vcl::Window* pParent, const OUStrin m_pDetailED->set_width_request(80 * m_pDetailED->approximate_char_width()); m_pDetailED->set_height_request(8 * m_pDetailED->GetTextHeight()); m_pDetailED->SetText(rDetails); + create_message_area(); } #define ITEMID_TASK 1 diff --git a/sw/source/ui/dbui/mmresultdialogs.cxx b/sw/source/ui/dbui/mmresultdialogs.cxx index 25af6e39e51b..262d10ab5e58 100644 --- a/sw/source/ui/dbui/mmresultdialogs.cxx +++ b/sw/source/ui/dbui/mmresultdialogs.cxx @@ -40,6 +40,7 @@ #include <svtools/sfxecode.hxx> #include <vcl/layout.hxx> #include <vcl/msgbox.hxx> +#include <vcl/weld.hxx> #include <sfx2/dinfdlg.hxx> #include <sfx2/printer.hxx> #include <sfx2/fcontnr.hxx> @@ -178,7 +179,7 @@ SwSendQueryBox_Impl::SwSendQueryBox_Impl(vcl::Window* pParent, const OUString& r : SwMessageAndEditDialog(pParent, rID, rUIXMLDescription) , bIsEmptyAllowed(true) { - m_pImageIM->SetImage(QueryBox::GetStandardImage()); + m_pImageIM->SetImage(GetStandardQueryBoxImage()); m_pEdit->SetModifyHdl(LINK(this, SwSendQueryBox_Impl, ModifyHdl)); ModifyHdl(*m_pEdit); } @@ -908,8 +909,11 @@ IMPL_LINK(SwMMResultEmailDialog, SendDocumentsHdl_Impl, Button*, pButton, void) if (xConfigItem->GetMailServer().isEmpty() || !SwMailMergeHelper::CheckMailAddress(xConfigItem->GetMailAddress()) ) { - ScopedVclPtrInstance< QueryBox > aQuery(pButton, MessBoxStyle::YesNoCancel, m_sConfigureMail); - sal_uInt16 nRet = aQuery->Execute(); + std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(pButton->GetFrameWeld(), + VclMessageType::Question, VclButtonsType::YesNo, + m_sConfigureMail)); + xQueryBox->add_button(Button::GetStandardText(StandardButtonType::Cancel), RET_CANCEL); + sal_uInt16 nRet = xQueryBox->run(); if (RET_YES == nRet ) { SwView* pConfigView = pTargetView ? pTargetView : pView; diff --git a/sw/source/ui/misc/glosbib.cxx b/sw/source/ui/misc/glosbib.cxx index 4d9c5f0956fa..4c84074f2e7e 100644 --- a/sw/source/ui/misc/glosbib.cxx +++ b/sw/source/ui/misc/glosbib.cxx @@ -19,8 +19,9 @@ #include <tools/urlobj.hxx> #include <tools/stream.hxx> -#include <vcl/msgbox.hxx> #include <vcl/help.hxx> +#include <vcl/svapp.hxx> +#include <vcl/weld.hxx> #include <vcl/builderfactory.hxx> #include <unotools/transliterationwrapper.hxx> #include <unotools/tempfile.hxx> @@ -158,8 +159,12 @@ void SwGlossaryGroupDlg::Apply() const OUString sMsg(SwResId(STR_QUERY_DELETE_GROUP1) + sTitle + SwResId(STR_QUERY_DELETE_GROUP2)); - ScopedVclPtrInstance< QueryBox > aQuery(GetParent(), MessBoxStyle::YesNo|MessBoxStyle::DefaultNo, sMsg ); - if(RET_YES == aQuery->Execute()) + + vcl::Window* pWin = GetParent(); + std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(pWin ? pWin->GetFrameWeld() : nullptr, + VclMessageType::Question, VclButtonsType::YesNo, sMsg)); + xQueryBox->set_default_response(RET_NO); + if (RET_YES == xQueryBox->run()) pGlosHdl->DelGroup( sDelGroup ); } diff --git a/sw/source/uibase/shells/textsh1.cxx b/sw/source/uibase/shells/textsh1.cxx index 4bf74057082c..3641c4c89978 100644 --- a/sw/source/uibase/shells/textsh1.cxx +++ b/sw/source/uibase/shells/textsh1.cxx @@ -278,7 +278,7 @@ static short lcl_AskRedlineFlags(vcl::Window *pWin) ScopedVclPtrInstance<MessBox> aQBox( pWin, MessBoxStyle::NONE, 0, SwResId( STR_REDLINE_TITLE ), SwResId( STR_REDLINE_MSG ) ); - aQBox->SetImage( QueryBox::GetStandardImage() ); + aQBox->SetImage(GetStandardQueryBoxImage()); const ButtonDialogFlags nBtnFlags = ButtonDialogFlags::Default | ButtonDialogFlags::OK | ButtonDialogFlags::Focus; diff --git a/toolkit/source/awt/vclxtoolkit.cxx b/toolkit/source/awt/vclxtoolkit.cxx index 3576fb640c69..1a3d10237bc4 100644 --- a/toolkit/source/awt/vclxtoolkit.cxx +++ b/toolkit/source/awt/vclxtoolkit.cxx @@ -801,6 +801,32 @@ public: } }; +class ErrorBox : public MessBox +{ +public: + ErrorBox(vcl::Window* pParent, MessBoxStyle nStyle, WinBits nWinBits, const OUString& rMessage) + : MessBox(pParent, nStyle, nWinBits, OUString(), rMessage) + { + // Default Text is the display title from the application + if (GetText().isEmpty()) + SetText(GetStandardErrorBoxText()); + SetImage(GetStandardErrorBoxImage()); + } +}; + +class QueryBox : public MessBox +{ +public: + QueryBox(vcl::Window* pParent, MessBoxStyle nStyle, WinBits nWinBits, const OUString& rMessage) + : MessBox(pParent, nStyle, nWinBits, OUString(), rMessage) + { + // Default Text is the display title from the application + if (GetText().isEmpty()) + SetText(GetStandardQueryBoxText()); + SetImage(GetStandardQueryBoxImage()); + } +}; + vcl::Window* VCLXToolkit::ImplCreateWindow( VCLXWindow** ppNewComp, const css::awt::WindowDescriptor& rDescriptor, vcl::Window* pParent, WinBits nWinBits, MessBoxStyle nMessBoxStyle ) diff --git a/uui/source/alreadyopen.cxx b/uui/source/alreadyopen.cxx index 64f5938e44c8..6a5660fda6b7 100644 --- a/uui/source/alreadyopen.cxx +++ b/uui/source/alreadyopen.cxx @@ -26,7 +26,7 @@ AlreadyOpenQueryBox::AlreadyOpenQueryBox( vcl::Window* pParent, const std::local Translate::get(STR_ALREADYOPEN_TITLE, rLocale), aMessage ) { - SetImage( QueryBox::GetStandardImage() ); + SetImage(GetStandardQueryBoxImage()); if ( bIsStoring ) { diff --git a/uui/source/filechanged.cxx b/uui/source/filechanged.cxx index e486da43bfaa..54917bb1bb2a 100644 --- a/uui/source/filechanged.cxx +++ b/uui/source/filechanged.cxx @@ -26,7 +26,7 @@ FileChangedQueryBox::FileChangedQueryBox( vcl::Window* pParent, const std::local Translate::get(STR_FILECHANGED_TITLE, rLocale), OUString() ) { - SetImage( QueryBox::GetStandardImage() ); + SetImage(GetStandardQueryBoxImage()); AddButton(Translate::get(STR_FILECHANGED_SAVEANYWAY_BTN, rLocale), RET_YES, ButtonDialogFlags::Default | ButtonDialogFlags::OK | ButtonDialogFlags::Focus); diff --git a/uui/source/iahndl-errorhandler.cxx b/uui/source/iahndl-errorhandler.cxx index 28d1bf062636..39755708942c 100644 --- a/uui/source/iahndl-errorhandler.cxx +++ b/uui/source/iahndl-errorhandler.cxx @@ -18,7 +18,7 @@ */ #include <vcl/svapp.hxx> -#include <vcl/msgbox.hxx> +#include <vcl/button.hxx> #include <vcl/weld.hxx> #include <com/sun/star/task/XInteractionAbort.hpp> @@ -43,13 +43,22 @@ using namespace com::sun::star; namespace { +enum class MessageBoxStyle { + NONE = 0x0000, + Ok = 0x0001, + OkCancel = 0x0002, + YesNo = 0x0004, + YesNoCancel = 0x0008, + RetryCancel = 0x0010 +}; + DialogMask executeErrorDialog( vcl::Window * pParent, task::InteractionClassification eClassification, OUString const & rContext, OUString const & rMessage, - MessBoxStyle nButtonMask) + MessageBoxStyle nButtonMask) { SolarMutexGuard aGuard; @@ -59,87 +68,59 @@ executeErrorDialog( //TODO! must be internationalized aText.append(rMessage); - VclPtr< MessBox > xBox; - std::unique_ptr<weld::MessageDialog> xOtherBox; - try + std::unique_ptr<weld::MessageDialog> xBox; + + switch (eClassification) { - switch (eClassification) - { case task::InteractionClassification_ERROR: - xBox.reset(VclPtr<ErrorBox>::Create(pParent, - nButtonMask, - aText.makeStringAndClear())); + xBox.reset(Application::CreateMessageDialog(pParent ? pParent->GetFrameWeld() : nullptr, + VclMessageType::Error, VclButtonsType::NONE, aText.makeStringAndClear())); break; - case task::InteractionClassification_WARNING: - xBox.reset(VclPtr<WarningBox>::Create(pParent, - nButtonMask, - aText.makeStringAndClear())); + xBox.reset(Application::CreateMessageDialog(pParent ? pParent->GetFrameWeld() : nullptr, + VclMessageType::Warning, VclButtonsType::NONE, aText.makeStringAndClear())); break; - case task::InteractionClassification_INFO: -# define WB_DEF_BUTTONS (MessBoxStyle::DefaultOk | MessBoxStyle::DefaultCancel | MessBoxStyle::DefaultRetry) - //(want to ignore any default button settings)... - if ((nButtonMask & WB_DEF_BUTTONS) == MessBoxStyle::DefaultOk) - { - xOtherBox.reset(Application::CreateMessageDialog(pParent ? pParent->GetFrameWeld() : nullptr, - VclMessageType::Info, VclButtonsType::Ok, aText.makeStringAndClear())); - } - else - xBox.reset(VclPtr<ErrorBox>::Create(pParent, - nButtonMask, - aText.makeStringAndClear())); + xBox.reset(Application::CreateMessageDialog(pParent ? pParent->GetFrameWeld() : nullptr, + VclMessageType::Info, VclButtonsType::NONE, aText.makeStringAndClear())); break; - case task::InteractionClassification_QUERY: - xBox.reset(VclPtr<QueryBox>::Create(pParent, - nButtonMask, - aText.makeStringAndClear())); + xBox.reset(Application::CreateMessageDialog(pParent ? pParent->GetFrameWeld() : nullptr, + VclMessageType::Question, VclButtonsType::NONE, aText.makeStringAndClear())); break; - default: - OSL_ASSERT(false); + assert(false); break; - } - } - catch (std::bad_alloc const &) - { - throw uno::RuntimeException("out of memory"); } - sal_uInt16 aMessResult; - if (xBox) - { - aMessResult = xBox->Execute(); - xBox.disposeAndClear(); - } - else - { - aMessResult = xOtherBox->run(); - } - DialogMask aResult = DialogMask::NONE; - switch( aMessResult ) + switch (nButtonMask) { - case RET_OK: - aResult = DialogMask::ButtonsOk; - break; - case RET_CANCEL: - aResult = DialogMask::ButtonsCancel; - break; - case RET_YES: - aResult = DialogMask::ButtonsYes; - break; - case RET_NO: - aResult = DialogMask::ButtonsNo; - break; - case RET_RETRY: - aResult = DialogMask::ButtonsRetry; - break; - default: assert(false); + case MessageBoxStyle::NONE: + break; + case MessageBoxStyle::Ok: + xBox->add_button(Button::GetStandardText(StandardButtonType::OK), static_cast<int>(DialogMask::ButtonsOk)); + break; + case MessageBoxStyle::OkCancel: + xBox->add_button(Button::GetStandardText(StandardButtonType::OK), static_cast<int>(DialogMask::ButtonsOk)); + xBox->add_button(Button::GetStandardText(StandardButtonType::Cancel), static_cast<int>(DialogMask::ButtonsCancel)); + break; + case MessageBoxStyle::YesNo: + xBox->add_button(Button::GetStandardText(StandardButtonType::Yes), static_cast<int>(DialogMask::ButtonsYes)); + xBox->add_button(Button::GetStandardText(StandardButtonType::No), static_cast<int>(DialogMask::ButtonsNo)); + break; + case MessageBoxStyle::YesNoCancel: + xBox->add_button(Button::GetStandardText(StandardButtonType::Yes), static_cast<int>(DialogMask::ButtonsYes)); + xBox->add_button(Button::GetStandardText(StandardButtonType::No), static_cast<int>(DialogMask::ButtonsNo)); + xBox->add_button(Button::GetStandardText(StandardButtonType::Cancel), static_cast<int>(DialogMask::ButtonsCancel)); + break; + case MessageBoxStyle::RetryCancel: + xBox->add_button(Button::GetStandardText(StandardButtonType::Retry), static_cast<int>(DialogMask::ButtonsRetry)); + xBox->add_button(Button::GetStandardText(StandardButtonType::Cancel), static_cast<int>(DialogMask::ButtonsCancel)); + break; } - return aResult; + return static_cast<DialogMask>(xBox->run()); } } @@ -225,30 +206,30 @@ UUIInteractionHelper::handleErrorHandlerRequest( // Finally, it seems to be better to leave default button // determination to VCL (the favouring of CANCEL as default button // seems to not always be what the user wants)... - MessBoxStyle const aButtonMask[16] - = { MessBoxStyle::NONE, - MessBoxStyle::Ok /*| MessBoxStyle::DefaultOk*/, // Abort - MessBoxStyle::NONE, - MessBoxStyle::RetryCancel /*| MessBoxStyle::DefaultCancel*/, // Retry, Abort - MessBoxStyle::NONE, - MessBoxStyle::NONE, - MessBoxStyle::NONE, - MessBoxStyle::NONE, - MessBoxStyle::Ok /*| MessBoxStyle::DefaultOk*/, // Approve - MessBoxStyle::OkCancel /*| MessBoxStyle::DefaultCancel*/, // Approve, Abort - MessBoxStyle::NONE, - MessBoxStyle::NONE, - MessBoxStyle::YesNo /*| MessBoxStyle::DefaultNo*/, // Approve, Disapprove - MessBoxStyle::YesNoCancel /*| MessBoxStyle::DefaultCancel*/, + MessageBoxStyle const aButtonMask[16] + = { MessageBoxStyle::NONE, + MessageBoxStyle::Ok /*| MessBoxStyle::DefaultOk*/, // Abort + MessageBoxStyle::NONE, + MessageBoxStyle::RetryCancel /*| MessBoxStyle::DefaultCancel*/, // Retry, Abort + MessageBoxStyle::NONE, + MessageBoxStyle::NONE, + MessageBoxStyle::NONE, + MessageBoxStyle::NONE, + MessageBoxStyle::Ok /*| MessBoxStyle::DefaultOk*/, // Approve + MessageBoxStyle::OkCancel /*| MessBoxStyle::DefaultCancel*/, // Approve, Abort + MessageBoxStyle::NONE, + MessageBoxStyle::NONE, + MessageBoxStyle::YesNo /*| MessBoxStyle::DefaultNo*/, // Approve, Disapprove + MessageBoxStyle::YesNoCancel /*| MessBoxStyle::DefaultCancel*/, // Approve, Disapprove, Abort - MessBoxStyle::NONE, - MessBoxStyle::NONE }; + MessageBoxStyle::NONE, + MessageBoxStyle::NONE }; - MessBoxStyle nButtonMask = aButtonMask[(xApprove.is() ? 8 : 0) + MessageBoxStyle nButtonMask = aButtonMask[(xApprove.is() ? 8 : 0) | (xDisapprove.is() ? 4 : 0) | (xRetry.is() ? 2 : 0) | (xAbort.is() ? 1 : 0)]; - if (nButtonMask == MessBoxStyle::NONE) + if (nButtonMask == MessageBoxStyle::NONE) return; //TODO! remove this backwards compatibility? diff --git a/uui/source/iahndl-ssl.cxx b/uui/source/iahndl-ssl.cxx index 960945643e25..1044b31dbbfb 100644 --- a/uui/source/iahndl-ssl.cxx +++ b/uui/source/iahndl-ssl.cxx @@ -136,7 +136,7 @@ getLocalizedDatTimeStr( bool executeUnknownAuthDialog( - vcl::Window * pParent, + weld::Window * pParent, uno::Reference< uno::XComponentContext > const & xContext, const uno::Reference< security::XCertificate >& rXCert) { @@ -144,7 +144,7 @@ executeUnknownAuthDialog( { SolarMutexGuard aGuard; - ScopedVclPtrInstance< UnknownAuthDialog > xDialog(pParent, rXCert, xContext); + UnknownAuthDialog aDialog(pParent, rXCert, xContext); // Get correct resource string OUString aMessage; @@ -158,9 +158,9 @@ executeUnknownAuthDialog( aMessage = Translate::get(STR_UUI_UNKNOWNAUTH_UNTRUSTED, aResLocale); aMessage = UUIInteractionHelper::replaceMessageWithArguments( aMessage, aArguments ); - xDialog->setDescriptionText( aMessage ); + aDialog.setDescriptionText( aMessage ); - return static_cast<bool>(xDialog->Execute()); + return static_cast<bool>(aDialog.run()); } catch (std::bad_alloc const &) { @@ -174,7 +174,7 @@ enum class SslWarnType { bool executeSSLWarnDialog( - vcl::Window * pParent, + weld::Window * pParent, uno::Reference< uno::XComponentContext > const & xContext, const uno::Reference< security::XCertificate >& rXCert, SslWarnType failure, @@ -184,7 +184,7 @@ executeSSLWarnDialog( { SolarMutexGuard aGuard; - ScopedVclPtrInstance< SSLWarnDialog > xDialog(pParent, rXCert, xContext); + SSLWarnDialog aDialog(pParent, rXCert, xContext); // Get correct resource string std::vector< OUString > aArguments_1; @@ -225,12 +225,12 @@ executeSSLWarnDialog( OUString aMessage_1 = Translate::get(pMessageKey, aResLocale); aMessage_1 = UUIInteractionHelper::replaceMessageWithArguments( aMessage_1, aArguments_1 ); - xDialog->setDescription1Text( aMessage_1 ); + aDialog.setDescription1Text( aMessage_1 ); OUString aTitle = Translate::get(pTitleKey, aResLocale); - xDialog->SetText(aTitle); + aDialog.set_title(aTitle); - return static_cast<bool>(xDialog->Execute()); + return static_cast<bool>(aDialog.run()); } catch (std::bad_alloc const &) { @@ -240,7 +240,7 @@ executeSSLWarnDialog( void handleCertificateValidationRequest_( - vcl::Window * pParent, + weld::Window * pParent, uno::Reference< uno::XComponentContext > const & xContext, ucb::CertificateValidationRequest const & rRequest, uno::Sequence< uno::Reference< task::XInteractionContinuation > > const & @@ -362,7 +362,8 @@ UUIInteractionHelper::handleCertificateValidationRequest( ucb::CertificateValidationRequest aCertificateValidationRequest; if (aAnyRequest >>= aCertificateValidationRequest) { - handleCertificateValidationRequest_(getParentProperty(), + vcl::Window* pWindow = getParentProperty(); + handleCertificateValidationRequest_(pWindow ? pWindow->GetFrameWeld() : nullptr, m_xContext, aCertificateValidationRequest, rRequest->getContinuations()); diff --git a/uui/source/lockcorrupt.cxx b/uui/source/lockcorrupt.cxx index cb3dc9c566cb..ce6a3545d13e 100644 --- a/uui/source/lockcorrupt.cxx +++ b/uui/source/lockcorrupt.cxx @@ -26,7 +26,7 @@ LockCorruptQueryBox::LockCorruptQueryBox(vcl::Window* pParent, const std::locale& rResLocale) : MessBox(pParent, MessBoxStyle::NONE, 0, Translate::get(STR_LOCKCORRUPT_TITLE, rResLocale), OUString()) { - SetImage( ErrorBox::GetStandardImage() ); + SetImage(GetStandardErrorBoxImage()); AddButton(Translate::get(STR_LOCKCORRUPT_OPENREADONLY_BTN, rResLocale), RET_OK, ButtonDialogFlags::Default | ButtonDialogFlags::OK | ButtonDialogFlags::Focus); diff --git a/uui/source/lockfailed.cxx b/uui/source/lockfailed.cxx index 15d58dca4981..51266f0b3420 100644 --- a/uui/source/lockfailed.cxx +++ b/uui/source/lockfailed.cxx @@ -25,7 +25,7 @@ LockFailedQueryBox::LockFailedQueryBox(vcl::Window* pParent, const std::locale& rResLocale) : MessBox(pParent, MessBoxStyle::NONE, 0, Translate::get(STR_LOCKFAILED_TITLE, rResLocale), OUString()) { - SetImage( ErrorBox::GetStandardImage() ); + SetImage(GetStandardErrorBoxImage()); AddButton(Translate::get(STR_LOCKFAILED_OPENREADONLY_BTN, rResLocale), RET_OK, ButtonDialogFlags::Default | ButtonDialogFlags::OK | ButtonDialogFlags::Focus); diff --git a/uui/source/openlocked.cxx b/uui/source/openlocked.cxx index 3267610b78d1..81d8b896477e 100644 --- a/uui/source/openlocked.cxx +++ b/uui/source/openlocked.cxx @@ -26,7 +26,7 @@ OpenLockedQueryBox::OpenLockedQueryBox( vcl::Window* pParent, const std::locale& Translate::get(STR_OPENLOCKED_TITLE, rResLocale), aMessage ) { - SetImage( QueryBox::GetStandardImage() ); + SetImage(GetStandardQueryBoxImage()); AddButton(Translate::get(STR_OPENLOCKED_OPENREADONLY_BTN, rResLocale), RET_YES, ButtonDialogFlags::Default | ButtonDialogFlags::OK | ButtonDialogFlags::Focus); diff --git a/uui/source/sslwarndlg.cxx b/uui/source/sslwarndlg.cxx index 5db56f855a95..df20f8f71715 100644 --- a/uui/source/sslwarndlg.cxx +++ b/uui/source/sslwarndlg.cxx @@ -17,7 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include <vcl/msgbox.hxx> +#include <vcl/svapp.hxx> #include <ids.hxx> #include "sslwarndlg.hxx" @@ -27,7 +27,7 @@ using namespace css; -IMPL_LINK_NOARG(SSLWarnDialog, ViewCertHdl, ::Button*, void) +IMPL_LINK_NOARG(SSLWarnDialog, ViewCertHdl, weld::Button&, void) { uno::Reference< css::security::XDocumentDigitalSignatures > xDocumentDigitalSignatures; @@ -36,25 +36,16 @@ IMPL_LINK_NOARG(SSLWarnDialog, ViewCertHdl, ::Button*, void) xDocumentDigitalSignatures.get()->showCertificate(m_rXCert); } -SSLWarnDialog::SSLWarnDialog(vcl::Window* pParent, +SSLWarnDialog::SSLWarnDialog(weld::Window* pParent, const css::uno::Reference< css::security::XCertificate >& rXCert, const css::uno::Reference< css::uno::XComponentContext >& xContext) - : MessageDialog(pParent, "SSLWarnDialog", "uui/ui/sslwarndialog.ui") - , m_xView(get<PushButton>("view")) + : m_xBuilder(Application::CreateBuilder(pParent, "uui/ui/sslwarndialog.ui")) + , m_xDialog(m_xBuilder->weld_message_dialog("SSLWarnDialog")) + , m_xView(m_xBuilder->weld_button("view")) , m_xContext(xContext) , m_rXCert(rXCert) { -} - -void SSLWarnDialog::dispose() -{ - m_xView.clear(); - MessageDialog::dispose(); -} - -SSLWarnDialog::~SSLWarnDialog() -{ - disposeOnce(); + m_xView->connect_clicked(LINK(this, SSLWarnDialog, ViewCertHdl)); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/uui/source/sslwarndlg.hxx b/uui/source/sslwarndlg.hxx index 2183160ce2ff..9a56314d9f21 100644 --- a/uui/source/sslwarndlg.hxx +++ b/uui/source/sslwarndlg.hxx @@ -19,8 +19,7 @@ #ifndef INCLUDED_UUI_SOURCE_SSLWARNDLG_HXX #define INCLUDED_UUI_SOURCE_SSLWARNDLG_HXX -#include <vcl/button.hxx> -#include <vcl/messagedialog.hxx> +#include <vcl/weld.hxx> #include <com/sun/star/security/XCertificate.hpp> #include <com/sun/star/xml/crypto/XSecurityEnvironment.hpp> #include <com/sun/star/uno/XComponentContext.hpp> @@ -28,25 +27,26 @@ //= Https_WarnDialog -class SSLWarnDialog : public MessageDialog +class SSLWarnDialog { private: - VclPtr<PushButton> m_xView; + std::unique_ptr<weld::Builder> m_xBuilder; + std::unique_ptr<weld::MessageDialog> m_xDialog; + std::unique_ptr<weld::Button> m_xView; const css::uno::Reference< css::uno::XComponentContext >& m_xContext; const css::uno::Reference< css::security::XCertificate >& m_rXCert; - DECL_LINK(ViewCertHdl, Button*, void); + DECL_LINK(ViewCertHdl, weld::Button&, void); public: - SSLWarnDialog( vcl::Window* pParent, + SSLWarnDialog(weld::Window* pParent, const css::uno::Reference< css::security::XCertificate >& rXCert, const css::uno::Reference< css::uno::XComponentContext >& xContext ); - void setDescription1Text(const OUString &aText) { set_primary_text(aText); } + void setDescription1Text(const OUString &rText) { m_xDialog->set_primary_text(rText); } + void set_title(const OUString &rText) { m_xDialog->set_title(rText); } - virtual void dispose() override; - - virtual ~SSLWarnDialog() override; + short run() { return m_xDialog->run(); } }; #endif // INCLUDED_UUI_SOURCE_SSLWARNDLG_HXX diff --git a/uui/source/trylater.cxx b/uui/source/trylater.cxx index d61f2e653bf8..aa9bc08cf603 100644 --- a/uui/source/trylater.cxx +++ b/uui/source/trylater.cxx @@ -24,7 +24,7 @@ TryLaterQueryBox::TryLaterQueryBox(vcl::Window* pParent, const std::locale& rResLocale, const OUString& aMessage) : MessBox(pParent, MessBoxStyle::NONE, 0, Translate::get(STR_TRYLATER_TITLE, rResLocale), aMessage) { - SetImage( QueryBox::GetStandardImage() ); + SetImage(GetStandardQueryBoxImage()); AddButton(Translate::get(STR_TRYLATER_RETRYSAVING_BTN, rResLocale), RET_YES, ButtonDialogFlags::Default | ButtonDialogFlags::OK | ButtonDialogFlags::Focus); diff --git a/uui/source/unknownauthdlg.cxx b/uui/source/unknownauthdlg.cxx index 433cfe8d6143..171d864735cd 100644 --- a/uui/source/unknownauthdlg.cxx +++ b/uui/source/unknownauthdlg.cxx @@ -17,7 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include <vcl/msgbox.hxx> +#include <vcl/svapp.hxx> #include <strings.hrc> #include "unknownauthdlg.hxx" @@ -28,19 +28,19 @@ using namespace css; -IMPL_LINK_NOARG(UnknownAuthDialog, OKHdl_Impl, Button*, void) +IMPL_LINK_NOARG(UnknownAuthDialog, OKHdl_Impl, weld::Button&, void) { - if ( m_pOptionButtonAccept->IsChecked() ) + if (m_xOptionButtonAccept->get_active()) { - EndDialog( RET_OK ); - } else + m_xDialog->response(RET_OK); + } + else { - EndDialog(); + m_xDialog->response(RET_CANCEL); } } - -IMPL_LINK_NOARG(UnknownAuthDialog, ViewCertHdl_Impl, Button*, void) +IMPL_LINK_NOARG(UnknownAuthDialog, ViewCertHdl_Impl, weld::Button&, void) { uno::Reference< css::security::XDocumentDigitalSignatures > xDocumentDigitalSignatures( css::security::DocumentDigitalSignatures::createDefault(m_xContext) ); @@ -48,36 +48,20 @@ IMPL_LINK_NOARG(UnknownAuthDialog, ViewCertHdl_Impl, Button*, void) xDocumentDigitalSignatures.get()->showCertificate(m_rXCert); } - -UnknownAuthDialog::UnknownAuthDialog(vcl::Window* pParent, +UnknownAuthDialog::UnknownAuthDialog(weld::Window* pParent, const css::uno::Reference< css::security::XCertificate >& rXCert, const css::uno::Reference< css::uno::XComponentContext >& xContext) - : MessageDialog(pParent, "UnknownAuthDialog", - "uui/ui/unknownauthdialog.ui") + : m_xBuilder(Application::CreateBuilder(pParent, "uui/ui/unknownauthdialog.ui")) + , m_xDialog(m_xBuilder->weld_message_dialog("UnknownAuthDialog")) + , m_xCommandButtonOK(m_xBuilder->weld_button("ok")) + , m_xView_Certificate(m_xBuilder->weld_button("examine")) + , m_xOptionButtonAccept(m_xBuilder->weld_radio_button("accept")) + , m_xOptionButtonDontAccept(m_xBuilder->weld_radio_button("reject")) , m_xContext(xContext) , m_rXCert(rXCert) { - get(m_pOptionButtonAccept, "accept"); - get(m_pOptionButtonDontAccept, "reject"); - get(m_pCommandButtonOK, "ok"); - get(m_pView_Certificate, "examine"); - - m_pView_Certificate->SetClickHdl(LINK(this, UnknownAuthDialog, ViewCertHdl_Impl)); - m_pCommandButtonOK->SetClickHdl(LINK(this, UnknownAuthDialog, OKHdl_Impl)); -} - -UnknownAuthDialog::~UnknownAuthDialog() -{ - disposeOnce(); -} - -void UnknownAuthDialog::dispose() -{ - m_pCommandButtonOK.clear(); - m_pView_Certificate.clear(); - m_pOptionButtonAccept.clear(); - m_pOptionButtonDontAccept.clear(); - MessageDialog::dispose(); + m_xView_Certificate->connect_clicked(LINK(this, UnknownAuthDialog, ViewCertHdl_Impl)); + m_xCommandButtonOK->connect_clicked(LINK(this, UnknownAuthDialog, OKHdl_Impl)); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/uui/source/unknownauthdlg.hxx b/uui/source/unknownauthdlg.hxx index 9c9274ef83f9..2398dfa26a2e 100644 --- a/uui/source/unknownauthdlg.hxx +++ b/uui/source/unknownauthdlg.hxx @@ -19,8 +19,7 @@ #ifndef INCLUDED_UUI_SOURCE_UNKNOWNAUTHDLG_HXX #define INCLUDED_UUI_SOURCE_UNKNOWNAUTHDLG_HXX -#include <vcl/button.hxx> -#include <vcl/messagedialog.hxx> +#include <vcl/weld.hxx> #include <com/sun/star/security/XCertificate.hpp> #include <com/sun/star/xml/crypto/XSecurityEnvironment.hpp> #include <com/sun/star/uno/XComponentContext.hpp> @@ -28,31 +27,33 @@ //= Https_UADialog -class UnknownAuthDialog : public MessageDialog +class UnknownAuthDialog { private: - VclPtr<PushButton> m_pCommandButtonOK; - VclPtr<PushButton> m_pView_Certificate; - VclPtr<RadioButton> m_pOptionButtonAccept; - VclPtr<RadioButton> m_pOptionButtonDontAccept; + std::unique_ptr<weld::Builder> m_xBuilder; + std::unique_ptr<weld::MessageDialog> m_xDialog; + std::unique_ptr<weld::Button> m_xCommandButtonOK; + std::unique_ptr<weld::Button> m_xView_Certificate; + std::unique_ptr<weld::RadioButton> m_xOptionButtonAccept; + std::unique_ptr<weld::RadioButton> m_xOptionButtonDontAccept; const css::uno::Reference< css::uno::XComponentContext >& m_xContext; const css::uno::Reference< css::security::XCertificate >& m_rXCert; - DECL_LINK(OKHdl_Impl, Button*, void); - DECL_LINK(ViewCertHdl_Impl, Button*, void); + DECL_LINK(OKHdl_Impl, weld::Button&, void); + DECL_LINK(ViewCertHdl_Impl, weld::Button&, void); public: - UnknownAuthDialog(vcl::Window* pParent, + UnknownAuthDialog(weld::Window* pParent, const css::uno::Reference< css::security::XCertificate >& rXCert, const css::uno::Reference< css::uno::XComponentContext >& xContext); - virtual ~UnknownAuthDialog() override; - virtual void dispose() override; void setDescriptionText(const OUString &rText) { - set_primary_text(rText); + m_xDialog->set_primary_text(rText); } + + short run() { return m_xDialog->run(); } }; #endif // INCLUDED_UUI_SOURCE_UNKNOWNAUTHDLG_HXX diff --git a/uui/uiconfig/ui/unknownauthdialog.ui b/uui/uiconfig/ui/unknownauthdialog.ui index 2e59c41a6859..eb8a9d32874f 100644 --- a/uui/uiconfig/ui/unknownauthdialog.ui +++ b/uui/uiconfig/ui/unknownauthdialog.ui @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.18.3 --> +<!-- Generated with glade 3.20.2 --> <interface domain="uui"> <requires lib="gtk+" version="3.0"/> <object class="GtkMessageDialog" id="UnknownAuthDialog"> @@ -85,7 +85,6 @@ <property name="xalign">0</property> <property name="active">True</property> <property name="draw_indicator">True</property> - <property name="group">reject</property> </object> <packing> <property name="left_attach">0</property> diff --git a/vcl/inc/strings.hrc b/vcl/inc/strings.hrc index f9ee189f6d90..99bcd8c79bbe 100644 --- a/vcl/inc/strings.hrc +++ b/vcl/inc/strings.hrc @@ -83,7 +83,6 @@ #define SV_STDTEXT_SERVICENOTAVAILABLE NC_("SV_STDTEXT_SERVICENOTAVAILABLE", "The component (%s) could not be loaded.\nPlease start setup with the repair option.") -#define SV_STDTEXT_DONTASKAGAIN NC_("SV_STDTEXT_DONTASKAGAIN", "Do not show this question again.") #define SV_STDTEXT_DONTWARNAGAIN NC_("SV_STDTEXT_DONTWARNAGAIN", "Do not show warning again.") #define SV_STDTEXT_ABOUT NC_("SV_STDTEXT_ABOUT", "About %PRODUCTNAME") diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index e7fad21b767e..46755b48b07c 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -263,11 +263,7 @@ public: return m_xWidget->GetHelpId(); } - virtual Widget* weld_parent() const override - { - vcl::Window* pParent = m_xWidget->GetParent(); - return pParent ? new SalInstanceWidget(pParent, false) : nullptr; - } + virtual weld::Container* weld_parent() const override; virtual ~SalInstanceWidget() override { @@ -296,8 +292,26 @@ public: , m_xContainer(pContainer) { } + virtual void remove(weld::Widget* pWidget) override + { + SalInstanceWidget* pGtkWidget = dynamic_cast<SalInstanceWidget*>(pWidget); + assert(pGtkWidget); + pGtkWidget->getWidget()->SetParent(nullptr); + } + virtual void add(weld::Widget* pWidget) override + { + SalInstanceWidget* pGtkWidget = dynamic_cast<SalInstanceWidget*>(pWidget); + assert(pGtkWidget); + pGtkWidget->getWidget()->SetParent(m_xContainer); + } }; +weld::Container* SalInstanceWidget::weld_parent() const +{ + vcl::Window* pParent = m_xWidget->GetParent(); + return pParent ? new SalInstanceContainer(pParent, false) : nullptr; +} + class SalInstanceWindow : public SalInstanceContainer, public virtual weld::Window { private: @@ -437,6 +451,11 @@ public: { return m_xMessageDialog->get_secondary_text(); } + + virtual Container* weld_message_area() override + { + return new SalInstanceContainer(m_xMessageDialog->get_message_area(), false); + } }; class SalInstanceFrame : public SalInstanceContainer, public virtual weld::Frame @@ -540,12 +559,14 @@ class SalInstanceButton : public SalInstanceContainer, public virtual weld::Butt { private: VclPtr<::Button> m_xButton; + Link<::Button*,void> m_aOldClickHdl; DECL_LINK(ClickHdl, ::Button*, void); public: SalInstanceButton(::Button* pButton, bool bTakeOwnership) : SalInstanceContainer(pButton, bTakeOwnership) , m_xButton(pButton) + , m_aOldClickHdl(pButton->GetClickHdl()) { m_xButton->SetClickHdl(LINK(this, SalInstanceButton, ClickHdl)); } @@ -573,7 +594,7 @@ IMPL_LINK(SalInstanceButton, ClickHdl, ::Button*, pButton, void) //etc buttons. if (!m_aClickHdl.IsSet()) { - pButton->SetClickHdl(Link<::Button*,void>()); + pButton->SetClickHdl(m_aOldClickHdl); pButton->Click(); pButton->SetClickHdl(LINK(this, SalInstanceButton, ClickHdl)); return; @@ -767,6 +788,8 @@ public: m_xTreeView->InsertEntry(rText, pos); } + using SalInstanceContainer::remove; + virtual void remove(int pos) override { m_xTreeView->RemoveEntry(pos); diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx index c3b8e50cc8b2..02345baa3de4 100644 --- a/vcl/source/window/builder.cxx +++ b/vcl/source/window/builder.cxx @@ -523,6 +523,10 @@ VclBuilder::VclBuilder(vcl::Window *pParent, const OUString& sUIDir, const OUStr } } + // create message dialog message area now + for (auto const& elem : m_pParserState->m_aMessageDialogs) + elem->create_message_area(); + //drop maps, etc. that we don't need again m_pParserState.reset(); @@ -1314,7 +1318,9 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString & WinBits nBits = WB_MOVEABLE|WB_3DLOOK|WB_CLOSEABLE; if (extractResizable(rMap)) nBits |= WB_SIZEABLE; - xWindow = VclPtr<MessageDialog>::Create(pParent, nBits); + VclPtr<MessageDialog> xDialog(VclPtr<MessageDialog>::Create(pParent, nBits)); + m_pParserState->m_aMessageDialogs.push_back(xDialog); + xWindow = xDialog; xWindow->set_border_width(12); } else if (name == "GtkBox") diff --git a/vcl/source/window/layout.cxx b/vcl/source/window/layout.cxx index 79f7bbc7a408..bf6918c1b426 100644 --- a/vcl/source/window/layout.cxx +++ b/vcl/source/window/layout.cxx @@ -2146,96 +2146,7 @@ void VclSizeGroup::set_property(const OString &rKey, const OUString &rValue) } } -void MessageDialog::create_owned_areas() -{ - set_border_width(12); - m_pOwnedContentArea.set(VclPtr<VclVBox>::Create(this, false, 24)); - set_content_area(m_pOwnedContentArea); - m_pOwnedContentArea->Show(); - m_pOwnedActionArea.set( VclPtr<VclHButtonBox>::Create(m_pOwnedContentArea) ); - set_action_area(m_pOwnedActionArea); - m_pOwnedActionArea->Show(); -} - -MessageDialog::MessageDialog(vcl::Window* pParent, WinBits nStyle) - : Dialog(pParent, nStyle) - , m_eButtonsType(VclButtonsType::NONE) - , m_eMessageType(VclMessageType::Info) - , m_pOwnedContentArea(nullptr) - , m_pOwnedActionArea(nullptr) - , m_pGrid(nullptr) - , m_pImage(nullptr) - , m_pPrimaryMessage(nullptr) - , m_pSecondaryMessage(nullptr) -{ - SetType(WindowType::MESSBOX); -} - -MessageDialog::MessageDialog(vcl::Window* pParent, - const OUString &rMessage, - VclMessageType eMessageType, - VclButtonsType eButtonsType) - : Dialog(pParent, WB_MOVEABLE | WB_3DLOOK | WB_CLOSEABLE) - , m_eButtonsType(eButtonsType) - , m_eMessageType(eMessageType) - , m_pGrid(nullptr) - , m_pImage(nullptr) - , m_pPrimaryMessage(nullptr) - , m_pSecondaryMessage(nullptr) - , m_sPrimaryString(rMessage) -{ - SetType(WindowType::MESSBOX); - create_owned_areas(); -} - -MessageDialog::MessageDialog(vcl::Window* pParent, const OString& rID, const OUString& rUIXMLDescription) - : Dialog(pParent, OStringToOUString(rID, RTL_TEXTENCODING_UTF8), rUIXMLDescription, WindowType::MESSBOX) - , m_eButtonsType(VclButtonsType::NONE) - , m_eMessageType(VclMessageType::Info) - , m_pOwnedContentArea(nullptr) - , m_pOwnedActionArea(nullptr) - , m_pGrid(nullptr) - , m_pImage(nullptr) - , m_pPrimaryMessage(nullptr) - , m_pSecondaryMessage(nullptr) -{ -} - -void MessageDialog::dispose() -{ - disposeOwnedButtons(); - m_pPrimaryMessage.disposeAndClear(); - m_pSecondaryMessage.disposeAndClear(); - m_pImage.disposeAndClear(); - m_pGrid.disposeAndClear(); - m_pOwnedActionArea.disposeAndClear(); - m_pOwnedContentArea.disposeAndClear(); - Dialog::dispose(); -} - -MessageDialog::~MessageDialog() -{ - disposeOnce(); -} - -void MessageDialog::SetMessagesWidths(vcl::Window const *pParent, - VclMultiLineEdit *pPrimaryMessage, VclMultiLineEdit *pSecondaryMessage) -{ - if (pSecondaryMessage) - { - assert(pPrimaryMessage); - vcl::Font aFont = pParent->GetSettings().GetStyleSettings().GetLabelFont(); - aFont.SetFontSize(Size(0, aFont.GetFontSize().Height() * 1.2)); - aFont.SetWeight(WEIGHT_BOLD); - pPrimaryMessage->SetControlFont(aFont); - pPrimaryMessage->SetMaxTextWidth(pPrimaryMessage->approximate_char_width() * 44); - pSecondaryMessage->SetMaxTextWidth(pSecondaryMessage->approximate_char_width() * 60); - } - else - pPrimaryMessage->SetMaxTextWidth(pPrimaryMessage->approximate_char_width() * 60); -} - -short MessageDialog::Execute() +void MessageDialog::create_message_area() { setDeferredProperties(); @@ -2247,7 +2158,10 @@ short MessageDialog::Execute() m_pGrid.set( VclPtr<VclGrid>::Create(pContainer) ); m_pGrid->reorderWithinParent(0); m_pGrid->set_column_spacing(12); - m_pGrid->set_row_spacing(GetTextHeight()); + m_pMessageBox.set(VclPtr<VclVBox>::Create(m_pGrid)); + m_pMessageBox->set_grid_left_attach(1); + m_pMessageBox->set_grid_top_attach(0); + m_pMessageBox->set_spacing(GetTextHeight()); m_pImage = VclPtr<FixedImage>::Create(m_pGrid, WB_CENTER | WB_VCENTER | WB_3DLOOK); switch (m_eMessageType) @@ -2259,10 +2173,10 @@ short MessageDialog::Execute() m_pImage->SetImage(WarningBox::GetStandardImage()); break; case VclMessageType::Question: - m_pImage->SetImage(QueryBox::GetStandardImage()); + m_pImage->SetImage(GetStandardQueryBoxImage()); break; case VclMessageType::Error: - m_pImage->SetImage(ErrorBox::GetStandardImage()); + m_pImage->SetImage(GetStandardErrorBoxImage()); break; } m_pImage->set_grid_left_attach(0); @@ -2274,21 +2188,17 @@ short MessageDialog::Execute() bool bHasSecondaryText = !m_sSecondaryString.isEmpty(); - m_pPrimaryMessage = VclPtr<VclMultiLineEdit>::Create(m_pGrid, nWinStyle); + m_pPrimaryMessage = VclPtr<VclMultiLineEdit>::Create(m_pMessageBox, nWinStyle); m_pPrimaryMessage->SetPaintTransparent(true); m_pPrimaryMessage->EnableCursor(false); - m_pPrimaryMessage->set_grid_left_attach(1); - m_pPrimaryMessage->set_grid_top_attach(0); m_pPrimaryMessage->set_hexpand(true); m_pPrimaryMessage->SetText(m_sPrimaryString); m_pPrimaryMessage->Show(!m_sPrimaryString.isEmpty()); - m_pSecondaryMessage = VclPtr<VclMultiLineEdit>::Create(m_pGrid, nWinStyle); + m_pSecondaryMessage = VclPtr<VclMultiLineEdit>::Create(m_pMessageBox, nWinStyle); m_pSecondaryMessage->SetPaintTransparent(true); m_pSecondaryMessage->EnableCursor(false); - m_pSecondaryMessage->set_grid_left_attach(1); - m_pSecondaryMessage->set_grid_top_attach(1); m_pSecondaryMessage->set_hexpand(true); m_pSecondaryMessage->SetText(m_sSecondaryString); m_pSecondaryMessage->Show(bHasSecondaryText); @@ -2356,9 +2266,102 @@ short MessageDialog::Execute() } set_default_response(nDefaultResponse); pButtonBox->sort_native_button_order(); + m_pMessageBox->Show(); m_pGrid->Show(); } - return Dialog::Execute(); +} + +void MessageDialog::create_owned_areas() +{ + set_border_width(12); + m_pOwnedContentArea.set(VclPtr<VclVBox>::Create(this, false, 24)); + set_content_area(m_pOwnedContentArea); + m_pOwnedContentArea->Show(); + m_pOwnedActionArea.set( VclPtr<VclHButtonBox>::Create(m_pOwnedContentArea) ); + set_action_area(m_pOwnedActionArea); + m_pOwnedActionArea->Show(); +} + +MessageDialog::MessageDialog(vcl::Window* pParent, WinBits nStyle) + : Dialog(pParent, nStyle) + , m_eButtonsType(VclButtonsType::NONE) + , m_eMessageType(VclMessageType::Info) + , m_pOwnedContentArea(nullptr) + , m_pOwnedActionArea(nullptr) + , m_pGrid(nullptr) + , m_pMessageBox(nullptr) + , m_pImage(nullptr) + , m_pPrimaryMessage(nullptr) + , m_pSecondaryMessage(nullptr) +{ + SetType(WindowType::MESSBOX); +} + +MessageDialog::MessageDialog(vcl::Window* pParent, const OString& rID, const OUString& rUIXMLDescription) + : Dialog(pParent, OStringToOUString(rID, RTL_TEXTENCODING_UTF8), rUIXMLDescription, WindowType::MESSBOX) + , m_eButtonsType(VclButtonsType::NONE) + , m_eMessageType(VclMessageType::Info) + , m_pOwnedContentArea(nullptr) + , m_pOwnedActionArea(nullptr) + , m_pGrid(nullptr) + , m_pImage(nullptr) + , m_pPrimaryMessage(nullptr) + , m_pSecondaryMessage(nullptr) +{ +} + +MessageDialog::MessageDialog(vcl::Window* pParent, + const OUString &rMessage, + VclMessageType eMessageType, + VclButtonsType eButtonsType) + : Dialog(pParent, WB_MOVEABLE | WB_3DLOOK | WB_CLOSEABLE) + , m_eButtonsType(eButtonsType) + , m_eMessageType(eMessageType) + , m_pGrid(nullptr) + , m_pMessageBox(nullptr) + , m_pImage(nullptr) + , m_pPrimaryMessage(nullptr) + , m_pSecondaryMessage(nullptr) + , m_sPrimaryString(rMessage) +{ + SetType(WindowType::MESSBOX); + create_owned_areas(); + create_message_area(); +} + +void MessageDialog::dispose() +{ + disposeOwnedButtons(); + m_pPrimaryMessage.disposeAndClear(); + m_pSecondaryMessage.disposeAndClear(); + m_pImage.disposeAndClear(); + m_pMessageBox.disposeAndClear(); + m_pGrid.disposeAndClear(); + m_pOwnedActionArea.disposeAndClear(); + m_pOwnedContentArea.disposeAndClear(); + Dialog::dispose(); +} + +MessageDialog::~MessageDialog() +{ + disposeOnce(); +} + +void MessageDialog::SetMessagesWidths(vcl::Window const *pParent, + VclMultiLineEdit *pPrimaryMessage, VclMultiLineEdit *pSecondaryMessage) +{ + if (pSecondaryMessage) + { + assert(pPrimaryMessage); + vcl::Font aFont = pParent->GetSettings().GetStyleSettings().GetLabelFont(); + aFont.SetFontSize(Size(0, aFont.GetFontSize().Height() * 1.2)); + aFont.SetWeight(WEIGHT_BOLD); + pPrimaryMessage->SetControlFont(aFont); + pPrimaryMessage->SetMaxTextWidth(pPrimaryMessage->approximate_char_width() * 44); + pSecondaryMessage->SetMaxTextWidth(pSecondaryMessage->approximate_char_width() * 60); + } + else + pPrimaryMessage->SetMaxTextWidth(pPrimaryMessage->approximate_char_width() * 60); } OUString const & MessageDialog::get_primary_text() const diff --git a/vcl/source/window/msgbox.cxx b/vcl/source/window/msgbox.cxx index efe8bfcfe175..52d0bfdbdf97 100644 --- a/vcl/source/window/msgbox.cxx +++ b/vcl/source/window/msgbox.cxx @@ -411,82 +411,24 @@ OUString WarningBox::GetStandardText() return VclResId(SV_MSGBOX_WARNING); } -ErrorBox::ErrorBox( vcl::Window* pParent, const OUString& rMessage ) : - MessBox( pParent, MessBoxStyle::Ok | MessBoxStyle::DefaultOk, 0, OUString(), rMessage ) +Image const & GetStandardErrorBoxImage() { - DBG_TESTSOLARMUTEX(); - // Default Text is the display title from the application - if ( GetText().isEmpty() ) - SetText( GetStandardText() ); - - SetImage( ErrorBox::GetStandardImage() ); -} - -ErrorBox::ErrorBox( vcl::Window* pParent, MessBoxStyle nStyle, - const OUString& rMessage ) : - ErrorBox(pParent, nStyle, 0, rMessage ) -{ -} - -ErrorBox::ErrorBox( vcl::Window* pParent, MessBoxStyle nStyle, WinBits nWinBits, - const OUString& rMessage ) : - MessBox( pParent, nStyle, nWinBits, OUString(), rMessage ) -{ - DBG_TESTSOLARMUTEX(); - // Default Text is the display title from the application - if ( GetText().isEmpty() ) - SetText( GetStandardText() ); - - SetImage( ErrorBox::GetStandardImage() ); -} - -Image ErrorBox::GetStandardImage() -{ - try - { - ImplInitMsgBoxImageList(); - } - catch (const css::uno::Exception &) - { - // During early bootstrap we can have no initialized - // ucb and hence no ability to get this image, so nop. - return Image(); - } + ImplInitMsgBoxImageList(); return ImplGetSVData()->maWinData.maMsgBoxImgList[0]; } -OUString ErrorBox::GetStandardText() +OUString GetStandardErrorBoxText() { return VclResId(SV_MSGBOX_ERROR); } -QueryBox::QueryBox( vcl::Window* pParent, MessBoxStyle nStyle, const OUString& rMessage ) : - QueryBox( pParent, nStyle, 0, rMessage ) -{ -} - -QueryBox::QueryBox( vcl::Window* pParent, MessBoxStyle nStyle, WinBits nWinBits, const OUString& rMessage ) : - MessBox( pParent, nStyle, nWinBits, OUString(), rMessage ) -{ - // Default Text is the display title from the application - if ( GetText().isEmpty() ) - SetText( GetStandardText() ); - - SetImage( QueryBox::GetStandardImage() ); -} - -void QueryBox::SetDefaultCheckBoxText() -{ - maCheckBoxText = VclResId(SV_STDTEXT_DONTASKAGAIN); -} - -Image const & QueryBox::GetStandardImage() +Image const & GetStandardQueryBoxImage() { ImplInitMsgBoxImageList(); return ImplGetSVData()->maWinData.maMsgBoxImgList[1]; } -OUString QueryBox::GetStandardText() +OUString GetStandardQueryBoxText() { return VclResId(SV_MSGBOX_QUERY); } diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx index aa6873aaace4..feec34bf58ea 100644 --- a/vcl/unx/gtk3/gtk3gtkinst.cxx +++ b/vcl/unx/gtk3/gtk3gtkinst.cxx @@ -1266,11 +1266,7 @@ public: return Size(nWidth, nHeight); } - virtual weld::Widget* weld_parent() const override - { - GtkWidget* pParent = gtk_widget_get_parent(m_pWidget); - return pParent ? new GtkInstanceWidget(pParent, false) : nullptr; - } + virtual weld::Container* weld_parent() const override; virtual OString get_buildable_name() const override { @@ -1312,10 +1308,29 @@ public: : GtkInstanceWidget(GTK_WIDGET(pContainer), bTakeOwnership) , m_pContainer(pContainer) { - (void)m_pContainer; + } + + virtual void remove(weld::Widget* pWidget) override + { + GtkInstanceWidget* pGtkWidget = dynamic_cast<GtkInstanceWidget*>(pWidget); + assert(pGtkWidget); + gtk_container_remove(m_pContainer, pGtkWidget->getWidget()); + } + + virtual void add(weld::Widget* pWidget) override + { + GtkInstanceWidget* pGtkWidget = dynamic_cast<GtkInstanceWidget*>(pWidget); + assert(pGtkWidget); + gtk_container_add(m_pContainer, pGtkWidget->getWidget()); } }; +weld::Container* GtkInstanceWidget::weld_parent() const +{ + GtkWidget* pParent = gtk_widget_get_parent(m_pWidget); + return pParent ? new GtkInstanceContainer(GTK_CONTAINER(pParent), false) : nullptr; +} + class GtkInstanceWindow : public GtkInstanceContainer, public virtual weld::Window { private: @@ -1474,6 +1489,11 @@ public: g_object_get(G_OBJECT(m_pMessageDialog), "secondary-text", &pText, nullptr); return OUString(pText, pText ? strlen(pText) : 0, RTL_TEXTENCODING_UTF8); } + + virtual Container* weld_message_area() override + { + return new GtkInstanceContainer(GTK_CONTAINER(gtk_message_dialog_get_message_area(m_pMessageDialog)), false); + } }; static OString MapToGtkAccelerator(const OUString &rStr) @@ -1837,6 +1857,8 @@ public: gtk_list_store_set(m_pListStore, &iter, 0, OUStringToOString(rText, RTL_TEXTENCODING_UTF8).getStr(), -1); } + using GtkInstanceContainer::remove; + virtual void remove(int pos) override { GtkTreeIter iter; diff --git a/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx b/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx index 2819368e2ccd..2487d37861fe 100644 --- a/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx +++ b/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx @@ -52,7 +52,6 @@ #include <strings.hrc> #include <resourcemanager.hxx> -#include <vcl/msgbox.hxx> #include <vcl/weld.hxx> #include <unotools/configitem.hxx> #include <comphelper/storagehelper.hxx> @@ -440,7 +439,10 @@ IMPL_LINK_NOARG(DigitalSignaturesDialog, AddButtonHdl, Button*, void) catch ( uno::Exception& ) { OSL_FAIL( "Exception while adding a signature!" ); - ScopedVclPtrInstance<ErrorBox>(this, XsResId(STR_XMLSECDLG_SIGNING_FAILED))->Execute(); + std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(GetFrameWeld(), + VclMessageType::Error, VclButtonsType::Ok, + XsResId(STR_XMLSECDLG_SIGNING_FAILED))); + xBox->run(); // Don't keep invalid entries... ImplGetSignatureInformations(/*bUseTempStream=*/true, /*bCacheLastSignature=*/false); ImplFillSignaturesBox(); |