diff options
90 files changed, 862 insertions, 535 deletions
diff --git a/basctl/source/basicide/basides1.cxx b/basctl/source/basicide/basides1.cxx index 22afa37f5d2a..5fce14ec5114 100644 --- a/basctl/source/basicide/basides1.cxx +++ b/basctl/source/basicide/basides1.cxx @@ -48,6 +48,7 @@ #include <svl/visitem.hxx> #include <svl/whiter.hxx> #include <vcl/xtextedt.hxx> +#include <vcl/svapp.hxx> #include <vcl/msgbox.hxx> #include <vcl/weld.hxx> @@ -114,7 +115,11 @@ void Shell::ExecuteCurrent( SfxRequest& rReq ) OUString aReplStr(IDEResId(RID_STR_SEARCHREPLACES)); aReplStr = aReplStr.replaceAll("XX", OUString::number(nFound)); - ScopedVclPtrInstance<InfoBox>(pCurWin, aReplStr)->Execute(); + + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(pCurWin->GetFrameWeld(), + VclMessageType::Info, VclButtonsType::Ok, + aReplStr)); + xInfoBox->run(); } else { @@ -181,7 +186,12 @@ void Shell::ExecuteCurrent( SfxRequest& rReq ) SetCurWindow( pWin, true ); } if ( !nFound && !bCanceled ) - ScopedVclPtrInstance<InfoBox>(pCurWin, IDEResId(RID_STR_SEARCHNOTFOUND))->Execute(); + { + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(pCurWin->GetFrameWeld(), + VclMessageType::Info, VclButtonsType::Ok, + IDEResId(RID_STR_SEARCHNOTFOUND))); + xInfoBox->run(); + } } rReq.Done(); diff --git a/basctl/source/basicide/basidesh.cxx b/basctl/source/basicide/basidesh.cxx index e4791604572b..58b4d42c50c7 100644 --- a/basctl/source/basicide/basidesh.cxx +++ b/basctl/source/basicide/basidesh.cxx @@ -62,7 +62,7 @@ #include <com/sun/star/container/XContainer.hpp> #include <svx/xmlsecctrl.hxx> #include <sfx2/viewfac.hxx> -#include <vcl/msgbox.hxx> +#include <vcl/weld.hxx> #include <vcl/settings.hxx> #include <cppuhelper/implbase.hxx> @@ -386,8 +386,10 @@ bool Shell::PrepareClose( bool bUI ) { if( bUI ) { - vcl::Window *pParent = &GetViewFrame()->GetWindow(); - ScopedVclPtrInstance<InfoBox>(pParent, IDEResId(RID_STR_CANNOTCLOSE))->Execute(); + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetViewFrame()->GetWindow().GetFrameWeld(), + VclMessageType::Info, VclButtonsType::Ok, + IDEResId(RID_STR_CANNOTCLOSE))); + xInfoBox->run(); } return false; } diff --git a/basic/source/runtime/basrdll.cxx b/basic/source/runtime/basrdll.cxx index e7a639a5a069..b5949524ccc8 100644 --- a/basic/source/runtime/basrdll.cxx +++ b/basic/source/runtime/basrdll.cxx @@ -22,6 +22,7 @@ #include <svl/solar.hrc> #include <tools/debug.hxx> #include <vcl/msgbox.hxx> +#include <vcl/weld.hxx> #include <vcl/settings.hxx> #include <basic/sbstar.hxx> @@ -97,7 +98,10 @@ void BasicDLL::BasicBreak() { bJustStopping = true; StarBASIC::Stop(); - ScopedVclPtrInstance<InfoBox>(nullptr, BasResId(IDS_SBERR_TERMINATED))->Execute(); + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(nullptr, + VclMessageType::Info, VclButtonsType::Ok, + BasResId(IDS_SBERR_TERMINATED))); + xInfoBox->run(); bJustStopping = false; } } diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx index 5f53992360ff..fed8450f8d5b 100644 --- a/basic/source/runtime/methods.cxx +++ b/basic/source/runtime/methods.cxx @@ -28,7 +28,8 @@ #include <vcl/settings.hxx> #include <vcl/sound.hxx> #include <tools/wintypes.hxx> -#include <vcl/msgbox.hxx> +#include <vcl/button.hxx> +#include <vcl/weld.hxx> #include <basic/sbx.hxx> #include <svl/zforlist.hxx> #include <rtl/character.hxx> @@ -4207,75 +4208,30 @@ void SbRtl_SavePicture(StarBASIC *, SbxArray & rPar, bool) void SbRtl_MsgBox(StarBASIC *, SbxArray & rPar, bool) { - static const MessBoxStyle nStyleMap[] = - { - MessBoxStyle::Ok, // MB_OK - MessBoxStyle::OkCancel, // MB_OKCANCEL - MessBoxStyle::AbortRetryIgnore, // MB_ABORTRETRYIGNORE - MessBoxStyle::YesNoCancel, // MB_YESNOCANCEL - MessBoxStyle::YesNo, // MB_YESNO - MessBoxStyle::RetryCancel // MB_RETRYCANCEL - }; - static const sal_Int16 nButtonMap[] = - { - 2, // RET_CANCEL is 0 - 1, // RET_OK is 1 - 6, // RET_YES is 2 - 7, // RET_NO is 3 - 4 // RET_RETRY is 4 - }; - - sal_uInt16 nArgCount = rPar.Count(); if( nArgCount < 2 || nArgCount > 6 ) { StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT ); return; } - MessBoxStyle nWinBits; WinBits nType = 0; // MB_OK if( nArgCount >= 3 ) nType = static_cast<WinBits>(rPar.Get(2)->GetInteger()); WinBits nStyle = nType; nStyle &= 15; // delete bits 4-16 - if( nStyle > 5 ) - { + if (nStyle > 5) nStyle = 0; - } - nWinBits = nStyleMap[ nStyle ]; - MessBoxStyle nWinDefBits = MessBoxStyle::DefaultOk | MessBoxStyle::DefaultRetry | MessBoxStyle::DefaultYes; - if( nType & 256 ) - { - if( nStyle == 5 ) - { - nWinDefBits = MessBoxStyle::DefaultCancel; - } - else if( nStyle == 2 ) - { - nWinDefBits = MessBoxStyle::DefaultRetry; - } - else - { - nWinDefBits = (MessBoxStyle::DefaultCancel | MessBoxStyle::DefaultRetry | MessBoxStyle::DefaultNo); - } - } - else if( nType & 512 ) + enum BasicResponse { - if( nStyle == 2) - { - nWinDefBits = MessBoxStyle::DefaultIgnore; - } - else - { - nWinDefBits = MessBoxStyle::DefaultCancel; - } - } - else if( nStyle == 2) - { - nWinDefBits = MessBoxStyle::DefaultCancel; - } - nWinBits |= nWinDefBits; + Ok = 1, + Cancel = 2, + Abort = 3, + Retry = 4, + Ignore = 5, + Yes = 6, + No = 7 + }; OUString aMsg = rPar.Get(1)->GetOUString(); OUString aTitle; @@ -4288,46 +4244,99 @@ void SbRtl_MsgBox(StarBASIC *, SbxArray & rPar, bool) aTitle = Application::GetDisplayName(); } - nType &= (16+32+64); - VclPtr<MessBox> pBox; + WinBits nDialogType = nType & (16+32+64); SolarMutexGuard aSolarGuard; + vcl::Window* pParentWin = Application::GetDefDialogParent(); + weld::Widget* pParent = pParentWin ? pParentWin->GetFrameWeld() : nullptr; - vcl::Window* pParent = Application::GetDefDialogParent(); - switch( nType ) - { - case 16: - pBox.reset(VclPtr<ErrorBox>::Create( pParent, nWinBits, aMsg )); - break; - case 32: - pBox.reset(VclPtr<QueryBox>::Create( pParent, nWinBits, aMsg )); - break; - case 48: - pBox.reset(VclPtr<WarningBox>::Create( pParent, nWinBits, aMsg )); - break; - case 64: - pBox.reset(VclPtr<InfoBox>::Create( pParent, nWinBits, aMsg )); - break; - default: - pBox.reset(VclPtr<MessBox>::Create( pParent, nWinBits, 0, aTitle, aMsg )); - } - pBox->SetText( aTitle ); - short nRet = pBox->Execute(); - sal_Int16 nMappedRet; - if( nStyle == 2 ) + VclMessageType eType = VclMessageType::Info; + + switch (nDialogType) { - nMappedRet = nRet; - if( nMappedRet == 0 ) - { - nMappedRet = 3; // Abort - } + case 16: + eType = VclMessageType::Error; + break; + case 32: + eType = VclMessageType::Question; + break; + case 48: + eType = VclMessageType::Warning; + break; + case 64: + default: + eType = VclMessageType::Info; + break; } - else + + std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(pParent, + eType, VclButtonsType::NONE, aMsg)); + + switch (nStyle) { - nMappedRet = nButtonMap[ nRet ]; + case 0: // MB_OK + default: + xBox->add_button(Button::GetStandardText(StandardButtonType::OK), BasicResponse::Ok); + break; + case 1: // MB_OKCANCEL + xBox->add_button(Button::GetStandardText(StandardButtonType::OK), BasicResponse::Ok); + xBox->add_button(Button::GetStandardText(StandardButtonType::Cancel), BasicResponse::Cancel); + + if (nType & 256 || nType & 512) + xBox->set_default_response(BasicResponse::Cancel); + else + xBox->set_default_response(BasicResponse::Ok); + + break; + case 2: // MB_ABORTRETRYIGNORE + xBox->add_button(Button::GetStandardText(StandardButtonType::Abort), BasicResponse::Abort); + xBox->add_button(Button::GetStandardText(StandardButtonType::Retry), BasicResponse::Retry); + xBox->add_button(Button::GetStandardText(StandardButtonType::Ignore), BasicResponse::Ignore); + + if (nType & 256) + xBox->set_default_response(BasicResponse::Retry); + else if (nType & 512) + xBox->set_default_response(BasicResponse::Ignore); + else + xBox->set_default_response(BasicResponse::Cancel); + + break; + case 3: // MB_YESNOCANCEL + xBox->add_button(Button::GetStandardText(StandardButtonType::Yes), BasicResponse::Yes); + xBox->add_button(Button::GetStandardText(StandardButtonType::No), BasicResponse::No); + xBox->add_button(Button::GetStandardText(StandardButtonType::Cancel), BasicResponse::Cancel); + + if (nType & 256 || nType & 512) + xBox->set_default_response(BasicResponse::Cancel); + else + xBox->set_default_response(BasicResponse::Yes); + + break; + case 4: // MB_YESNO + xBox->add_button(Button::GetStandardText(StandardButtonType::Yes), BasicResponse::Yes); + xBox->add_button(Button::GetStandardText(StandardButtonType::No), BasicResponse::No); + + if (nType & 256 || nType & 512) + xBox->set_default_response(BasicResponse::No); + else + xBox->set_default_response(BasicResponse::Yes); + + break; + case 5: // MB_RETRYCANCEL + xBox->add_button(Button::GetStandardText(StandardButtonType::Retry), BasicResponse::Retry); + xBox->add_button(Button::GetStandardText(StandardButtonType::Cancel), BasicResponse::Cancel); + + if (nType & 256 || nType & 512) + xBox->set_default_response(BasicResponse::Cancel); + else + xBox->set_default_response(BasicResponse::Retry); + + break; } - rPar.Get(0)->PutInteger( nMappedRet ); - pBox.disposeAndClear(); + + xBox->set_title(aTitle); + sal_Int16 nRet = xBox->run(); + rPar.Get(0)->PutInteger(nRet); } void SbRtl_SetAttr(StarBASIC *, SbxArray & rPar, bool) diff --git a/chart2/source/controller/main/ChartController_Window.cxx b/chart2/source/controller/main/ChartController_Window.cxx index 151b916b37be..d00f9e73a2dc 100644 --- a/chart2/source/controller/main/ChartController_Window.cxx +++ b/chart2/source/controller/main/ChartController_Window.cxx @@ -73,6 +73,7 @@ #include <vcl/svapp.hxx> #include <vcl/settings.hxx> #include <vcl/msgbox.hxx> +#include <vcl/weld.hxx> #include <rtl/math.hxx> #include <svtools/acceleratorexecute.hxx> @@ -1536,7 +1537,10 @@ bool ChartController::execute_KeyInput( const KeyEvent& rKEvt ) bReturn = executeDispatch_Delete(); if( ! bReturn ) { - ScopedVclPtrInstance<InfoBox>(pChartWindow, SchResId(STR_ACTION_NOTPOSSIBLE))->Execute(); + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(pChartWindow ? pChartWindow->GetFrameWeld() : nullptr, + VclMessageType::Info, VclButtonsType::Ok, + SchResId(STR_ACTION_NOTPOSSIBLE))); + xInfoBox->run(); } } diff --git a/cui/source/customize/cfg.cxx b/cui/source/customize/cfg.cxx index 94b02b86b56d..7d5ce9d4da6b 100644 --- a/cui/source/customize/cfg.cxx +++ b/cui/source/customize/cfg.cxx @@ -3478,7 +3478,7 @@ SvxIconChangeDialog::SvxIconChangeDialog( pLineEditDescription->set_width_request(aSize.Width()); pLineEditDescription->set_height_request(aSize.Height()); - pFImageInfo->SetImage(InfoBox::GetStandardImage()); + pFImageInfo->SetImage(GetStandardInfoBoxImage()); pLineEditDescription->SetControlBackground( GetSettings().GetStyleSettings().GetDialogColor() ); pLineEditDescription->SetText(aMessage); } diff --git a/cui/source/dialogs/SpellDialog.cxx b/cui/source/dialogs/SpellDialog.cxx index 95e611a313cb..2bc16dc0df0e 100644 --- a/cui/source/dialogs/SpellDialog.cxx +++ b/cui/source/dialogs/SpellDialog.cxx @@ -18,6 +18,7 @@ */ #include <memory> +#include <vcl/weld.hxx> #include <vcl/wrkwin.hxx> #include <vcl/menu.hxx> #include <vcl/layout.hxx> @@ -900,7 +901,7 @@ void SpellDialog::AddToDictionaryExecute( sal_uInt16 nItemId, PopupMenu const *p } if (DictionaryError::NONE != nAddRes) { - SvxDicError( this, nAddRes ); + SvxDicError(GetFrameWeld(), nAddRes); return; // don't continue } diff --git a/cui/source/dialogs/cuigaldlg.cxx b/cui/source/dialogs/cuigaldlg.cxx index ef138dc257a2..7c64d613c1b6 100644 --- a/cui/source/dialogs/cuigaldlg.cxx +++ b/cui/source/dialogs/cuigaldlg.cxx @@ -25,7 +25,7 @@ #include <vcl/errinf.hxx> #include <ucbhelper/content.hxx> #include <vcl/svapp.hxx> -#include <vcl/msgbox.hxx> +#include <vcl/weld.hxx> #include <vcl/weld.hxx> #include <avmedia/mediawindow.hxx> #include <unotools/pathoptions.hxx> @@ -562,8 +562,10 @@ IMPL_LINK_NOARG(GalleryIdDialog, ClickOkHdl, Button*, void) aStr += " (" + pInfo->GetThemeName() + ")"; - ScopedVclPtrInstance< InfoBox > aBox( this, aStr ); - aBox->Execute(); + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(), + VclMessageType::Info, VclButtonsType::Ok, + aStr)); + xInfoBox->run(); m_pLbResName->GrabFocus(); bDifferentThemeExists = true; } diff --git a/cui/source/dialogs/multipat.cxx b/cui/source/dialogs/multipat.cxx index 27f576713467..eccc81553ebd 100644 --- a/cui/source/dialogs/multipat.cxx +++ b/cui/source/dialogs/multipat.cxx @@ -21,7 +21,8 @@ #include <osl/file.hxx> #include <tools/urlobj.hxx> -#include <vcl/msgbox.hxx> +#include <vcl/svapp.hxx> +#include <vcl/weld.hxx> #include <sfx2/filedlghelper.hxx> #include <multipat.hxx> @@ -92,7 +93,9 @@ IMPL_LINK_NOARG(SvxMultiPathDialog, AddHdl_Impl, Button*, void) { OUString sMsg( CuiResId( RID_MULTIPATH_DBL_ERR ) ); sMsg = sMsg.replaceFirst( "%1", sInsPath ); - ScopedVclPtrInstance<InfoBox>(this, sMsg)->Execute(); + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(), + VclMessageType::Info, VclButtonsType::Ok, sMsg)); + xInfoBox->run(); } SelectHdl_Impl( nullptr ); @@ -116,7 +119,9 @@ IMPL_LINK_NOARG(SvxPathSelectDialog, AddHdl_Impl, Button*, void) { OUString sMsg( CuiResId( RID_MULTIPATH_DBL_ERR ) ); sMsg = sMsg.replaceFirst( "%1", sInsPath ); - ScopedVclPtrInstance<InfoBox>(this, sMsg)->Execute(); + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(), + VclMessageType::Info, VclButtonsType::Ok, sMsg)); + xInfoBox->run(); } else { diff --git a/cui/source/options/optdict.cxx b/cui/source/options/optdict.cxx index 7b4e4ea5797e..30eb207acbc2 100644 --- a/cui/source/options/optdict.cxx +++ b/cui/source/options/optdict.cxx @@ -180,7 +180,7 @@ IMPL_LINK_NOARG(SvxNewDictionaryDialog, OKHdl_Impl, Button*, void) xNewDic = nullptr; // error: couldn't create new dictionary SfxErrorContext aContext( ERRCTX_SVX_LINGU_DICTIONARY, OUString(), - this, RID_SVXERRCTX, SvxResLocale() ); + GetFrameWeld(), RID_SVXERRCTX, SvxResLocale() ); ErrorHandler::HandleError( *new StringErrorInfo( ERRCODE_SVX_LINGU_DICT_NOTWRITEABLE, sDict ) ); EndDialog(); @@ -646,7 +646,7 @@ bool SvxEditDictionaryDialog::NewDelHdl(void const * pBtn) } } if (DictionaryError::NONE != nAddRes) - SvxDicError( this, nAddRes ); + SvxDicError(GetFrameWeld(), nAddRes); if(DictionaryError::NONE == nAddRes && !sEntry.isEmpty()) { diff --git a/cui/source/options/treeopt.cxx b/cui/source/options/treeopt.cxx index 877f2cfa6a95..8bfd3462b8c9 100644 --- a/cui/source/options/treeopt.cxx +++ b/cui/source/options/treeopt.cxx @@ -101,7 +101,7 @@ #include <unotools/viewoptions.hxx> #include <vcl/help.hxx> #include <vcl/layout.hxx> -#include <vcl/msgbox.hxx> +#include <vcl/weld.hxx> #include <vcl/waitobj.hxx> #include <vcl/settings.hxx> #include <svtools/treelistentry.hxx> @@ -974,7 +974,10 @@ void OfaTreeOptionsDialog::SelectHdl_Impl() if(!pGroupInfo->m_pModule) { pGroupInfo->m_bLoadError = true; - ScopedVclPtrInstance<InfoBox>(pBox, sNotLoadedError)->Execute(); + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(pBox->GetFrameWeld(), + VclMessageType::Info, VclButtonsType::Ok, + sNotLoadedError)); + xInfoBox->run(); return; } if(bIdentical) diff --git a/cui/source/tabpages/backgrnd.cxx b/cui/source/tabpages/backgrnd.cxx index ddf8dcb024b4..a89591b092de 100644 --- a/cui/source/tabpages/backgrnd.cxx +++ b/cui/source/tabpages/backgrnd.cxx @@ -880,7 +880,7 @@ void SvxBackgroundTabPage::RaiseLoadError_Impl() { SfxErrorContext aContext( ERRCTX_SVX_BACKGROUND, OUString(), - this, + GetFrameWeld(), RID_SVXERRCTX, SvxResLocale() ); diff --git a/dbaccess/source/ui/dlg/generalpage.cxx b/dbaccess/source/ui/dlg/generalpage.cxx index 28a79c048981..12b1e62f4fe9 100644 --- a/dbaccess/source/ui/dlg/generalpage.cxx +++ b/dbaccess/source/ui/dlg/generalpage.cxx @@ -29,7 +29,7 @@ #include <sfx2/filedlghelper.hxx> #include <sfx2/docfilt.hxx> #include <vcl/stdtext.hxx> -#include <vcl/msgbox.hxx> +#include <vcl/weld.hxx> #include <svl/stritem.hxx> #include <vcl/waitobj.hxx> #include <com/sun/star/sdbc/XDriverAccess.hpp> @@ -717,8 +717,10 @@ namespace dbaui if ( aFileDlg.GetCurrentFilter() != pFilter->GetUIName() || !pFilter->GetWildcard().Matches(sPath) ) { OUString sMessage(DBA_RES(STR_ERR_USE_CONNECT_TO)); - ScopedVclPtrInstance< InfoBox > aError(this, sMessage); - aError->Execute(); + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(), + VclMessageType::Info, VclButtonsType::Ok, + sMessage)); + xInfoBox->run(); m_pRB_ConnectDatabase->Check(); OnSetupModeSelected( m_pRB_ConnectDatabase ); return; diff --git a/dbaccess/source/ui/dlg/sqlmessage.cxx b/dbaccess/source/ui/dlg/sqlmessage.cxx index 469102a47886..315bae099e57 100644 --- a/dbaccess/source/ui/dlg/sqlmessage.cxx +++ b/dbaccess/source/ui/dlg/sqlmessage.cxx @@ -622,7 +622,7 @@ void OSQLMessageBox::Construct( MessBoxStyle _nStyle, MessageType _eImage ) OSL_FAIL( "OSQLMessageBox::impl_initImage: unsupported image type!" ); SAL_FALLTHROUGH; case Info: - m_aInfoImage->SetImage(InfoBox::GetStandardImage()); + m_aInfoImage->SetImage(GetStandardInfoBoxImage()); break; case Warning: m_aInfoImage->SetImage(WarningBox::GetStandardImage()); diff --git a/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx b/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx index 5351959eceb8..8937943db748 100644 --- a/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx +++ b/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx @@ -36,7 +36,7 @@ #include <com/sun/star/container/XNameAccess.hpp> #include <stringconstants.hxx> #include "QTableWindow.hxx" -#include <vcl/msgbox.hxx> +#include <vcl/weld.hxx> #include <vcl/settings.hxx> #include "QueryDesignFieldUndoAct.hxx" #include <sqlmessage.hxx> @@ -523,7 +523,10 @@ void OSelectionBrowseBox::InitController(CellControllerRef& /*rController*/, lon m_pVisibleCell->GetBox().EnableInput(false); OUString aMessage(DBA_RES(STR_QRY_ORDERBY_UNRELATED)); OQueryDesignView* paDView = getDesignView(); - ScopedVclPtrInstance<InfoBox>(paDView, aMessage)->Execute(); + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(paDView ? paDView->GetFrameWeld() : nullptr, + VclMessageType::Info, VclButtonsType::Ok, + aMessage)); + xInfoBox->run(); } } break; case BROW_ORDER_ROW: diff --git a/editeng/source/editeng/editdbg.cxx b/editeng/source/editeng/editdbg.cxx index 297fbf7a98dd..3dbdadb6af22 100644 --- a/editeng/source/editeng/editdbg.cxx +++ b/editeng/source/editeng/editdbg.cxx @@ -21,7 +21,7 @@ #include <memory> #include <vcl/wrkwin.hxx> #include <vcl/dialog.hxx> -#include <vcl/msgbox.hxx> +#include <vcl/weld.hxx> #include <vcl/svapp.hxx> #include <editeng/lspcitem.hxx> @@ -482,7 +482,12 @@ void EditDbg::ShowEditEngineData( EditEngine* pEE, bool bInfoBox ) } fclose( fp ); if ( bInfoBox ) - ScopedVclPtrInstance<InfoBox>(nullptr, OUString( "D:\\DEBUG.LOG !" ) )->Execute(); + { + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(nullptr, + VclMessageType::Info, VclButtonsType::Ok, + "D:\\DEBUG.LOG !" )); + xInfoBox->run(); + } } #endif diff --git a/editeng/source/editeng/editeng.cxx b/editeng/source/editeng/editeng.cxx index a822a23406ef..0e5fdd3e596a 100644 --- a/editeng/source/editeng/editeng.cxx +++ b/editeng/source/editeng/editeng.cxx @@ -21,7 +21,7 @@ #include <comphelper/lok.hxx> #include <vcl/wrkwin.hxx> #include <vcl/dialog.hxx> -#include <vcl/msgbox.hxx> +#include <vcl/weld.hxx> #include <vcl/svapp.hxx> #include <svtools/ctrltool.hxx> @@ -1042,7 +1042,11 @@ bool EditEngine::PostKeyEvent( const KeyEvent& rKeyEvent, EditView* pEditView, v bDebugPaint = !bDebugPaint; OStringBuffer aInfo("DebugPaint: "); aInfo.append(bDebugPaint ? "On" : "Off"); - ScopedVclPtrInstance<InfoBox>(nullptr, OStringToOUString(aInfo.makeStringAndClear(), RTL_TEXTENCODING_ASCII_US))->Execute(); + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(nullptr, + VclMessageType::Info, VclButtonsType::Ok, + OStringToOUString(aInfo.makeStringAndClear(), RTL_TEXTENCODING_ASCII_US))); + xInfoBox->run(); + } bDone = false; } diff --git a/editeng/source/misc/unolingu.cxx b/editeng/source/misc/unolingu.cxx index 57c03f20d26a..6263a0db5398 100644 --- a/editeng/source/misc/unolingu.cxx +++ b/editeng/source/misc/unolingu.cxx @@ -44,8 +44,8 @@ #include <unotools/localfilehelper.hxx> #include <ucbhelper/commandenvironment.hxx> #include <ucbhelper/content.hxx> -#include <vcl/msgbox.hxx> #include <vcl/svapp.hxx> +#include <vcl/weld.hxx> #include <linguistic/misc.hxx> #include <editeng/eerdll.hxx> #include <editeng/editrids.hrc> @@ -727,7 +727,7 @@ SvxDicListChgClamp::~SvxDicListChgClamp() } } -short SvxDicError( vcl::Window *pParent, linguistic::DictionaryError nError ) +short SvxDicError(weld::Window *pParent, linguistic::DictionaryError nError) { short nRes = 0; if (linguistic::DictionaryError::NONE != nError) @@ -741,7 +741,11 @@ short SvxDicError( vcl::Window *pParent, linguistic::DictionaryError nError ) pRid = RID_SVXSTR_DIC_ERR_UNKNOWN; SAL_WARN("editeng", "unexpected case"); } - nRes = ScopedVclPtrInstance<InfoBox>(pParent, EditResId(pRid))->Execute(); + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(pParent, + VclMessageType::Info, VclButtonsType::Ok, + EditResId(pRid))); + nRes = xInfoBox->run(); + } return nRes; } diff --git a/extensions/source/propctrlr/propcontroller.cxx b/extensions/source/propctrlr/propcontroller.cxx index 539e5be292d6..6b19672c004b 100644 --- a/extensions/source/propctrlr/propcontroller.cxx +++ b/extensions/source/propctrlr/propcontroller.cxx @@ -42,7 +42,7 @@ #include <toolkit/awt/vclxwindow.hxx> #include <toolkit/helper/vclunohelper.hxx> #include <comphelper/property.hxx> -#include <vcl/msgbox.hxx> +#include <vcl/weld.hxx> #include <vcl/svapp.hxx> #include <vcl/tabpage.hxx> #include <osl/mutex.hxx> @@ -1376,7 +1376,10 @@ namespace pcr } catch(const PropertyVetoException& eVetoException) { - ScopedVclPtrInstance<InfoBox>(m_pView, eVetoException.Message)->Execute(); + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(m_pView ? m_pView->GetFrameWeld() : nullptr, + VclMessageType::Info, VclButtonsType::Ok, + eVetoException.Message)); + xInfoBox->run(); PropertyHandlerRef handler = impl_getHandlerForProperty_throw( rName ); Any aNormalizedValue = handler->getPropertyValue( rName ); getPropertyBox().SetPropertyValue( rName, aNormalizedValue, false ); diff --git a/extensions/source/update/ui/updatecheckui.cxx b/extensions/source/update/ui/updatecheckui.cxx index 82e8e55a750a..b633fa7d2b58 100644 --- a/extensions/source/update/ui/updatecheckui.cxx +++ b/extensions/source/update/ui/updatecheckui.cxx @@ -269,7 +269,7 @@ Image UpdateCheckUI::GetBubbleImage( OUString const &rURL ) } if ( aImage.GetSizePixel().Width() == 0 ) - aImage = InfoBox::GetStandardImage(); + aImage = GetStandardInfoBoxImage(); return aImage; } @@ -777,7 +777,6 @@ void BubbleWindow::Paint(vcl::RenderContext& /*rRenderContext*/, const tools::Re aThickLine ); SetLineColor( aOldLine ); - //Image aImage = InfoBox::GetStandardImage(); Size aImgSize = maBubbleImage.GetSizePixel(); DrawImage( Point( BUBBLE_BORDER, BUBBLE_BORDER + TIP_HEIGHT ), maBubbleImage ); @@ -820,7 +819,6 @@ void BubbleWindow::Show( bool bVisible, ShowFlags nFlags ) Size aWindowSize = GetSizePixel(); - // Image aImage = InfoBox::GetStandardImage(); Size aImgSize = maBubbleImage.GetSizePixel(); RecalcTextRects(); diff --git a/filter/source/graphicfilter/eps/eps.cxx b/filter/source/graphicfilter/eps/eps.cxx index 4a47345a14b5..8dc125837701 100644 --- a/filter/source/graphicfilter/eps/eps.cxx +++ b/filter/source/graphicfilter/eps/eps.cxx @@ -39,6 +39,7 @@ #include <vcl/fltcall.hxx> #include <vcl/FilterConfigItem.hxx> #include <vcl/graphictools.hxx> +#include <vcl/weld.hxx> #include <strings.hrc> #include <math.h> @@ -439,8 +440,10 @@ bool PSWriter::WritePS( const Graphic& rGraphic, SvStream& rTargetStream, Filter if ( mbStatus && mnLevelWarning && pFilterConfigItem ) { std::locale loc = Translate::Create("flt"); - ScopedVclPtrInstance< InfoBox > aInfoBox(nullptr, Translate::get(KEY_VERSION_CHECK, loc)); - aInfoBox->Execute(); + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(nullptr, + VclMessageType::Info, VclButtonsType::Ok, + Translate::get(KEY_VERSION_CHECK, loc))); + xInfoBox->run(); } if ( xStatusIndicator.is() ) diff --git a/filter/source/xsltdialog/xmlfiltersettingsdialog.cxx b/filter/source/xsltdialog/xmlfiltersettingsdialog.cxx index 80023a48e089..88918bcdac29 100644 --- a/filter/source/xsltdialog/xmlfiltersettingsdialog.cxx +++ b/filter/source/xsltdialog/xmlfiltersettingsdialog.cxx @@ -30,9 +30,10 @@ #include <unotools/pathoptions.hxx> #include <osl/file.hxx> #include <o3tl/enumrange.hxx> +#include <vcl/builderfactory.hxx> #include <vcl/msgbox.hxx> #include <vcl/svapp.hxx> -#include <vcl/builderfactory.hxx> +#include <vcl/weld.hxx> #include <sfx2/filedlghelper.hxx> #include <svtools/treelistentry.hxx> @@ -902,8 +903,10 @@ void XMLFilterSettingsDialog::onSave() aMsg = aMsg.replaceFirst( sPlaceholder, aURL.GetName() ); } - ScopedVclPtrInstance< InfoBox > aBox(this, aMsg ); - aBox->Execute(); + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(), + VclMessageType::Info, VclButtonsType::Ok, + aMsg)); + xInfoBox->run(); } } @@ -967,8 +970,10 @@ void XMLFilterSettingsDialog::onOpen() aMsg = aMsg.replaceFirst( sPlaceholder, OUString::number( nFilters ) ); } - ScopedVclPtrInstance< InfoBox > aBox(this, aMsg ); - aBox->Execute(); + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(), + VclMessageType::Info, VclButtonsType::Ok, + aMsg)); + xInfoBox->run(); } } diff --git a/include/editeng/unolingu.hxx b/include/editeng/unolingu.hxx index 78807780da17..4575e201d5ac 100644 --- a/include/editeng/unolingu.hxx +++ b/include/editeng/unolingu.hxx @@ -34,7 +34,7 @@ class LinguMgrExitLstnr; -namespace vcl { class Window; } +namespace weld { class Window; } namespace linguistic { enum class DictionaryError; } @@ -125,7 +125,7 @@ public: ~SvxDicListChgClamp(); }; -EDITENG_DLLPUBLIC short SvxDicError( vcl::Window *pParent, linguistic::DictionaryError nError ); +EDITENG_DLLPUBLIC short SvxDicError(weld::Window *pParent, linguistic::DictionaryError nError); #endif diff --git a/include/svtools/ehdl.hxx b/include/svtools/ehdl.hxx index 2042d70184eb..2efbb761f4ba 100644 --- a/include/svtools/ehdl.hxx +++ b/include/svtools/ehdl.hxx @@ -29,16 +29,16 @@ typedef std::pair<const char*, ErrCode> ErrMsgCode; SVT_DLLPUBLIC extern const ErrMsgCode RID_ERRHDL[]; SVT_DLLPUBLIC extern const ErrMsgCode RID_ERRCTX[]; -namespace vcl { class Window; } +namespace weld { class Window; } class SVT_DLLPUBLIC SfxErrorContext : private ErrorContext { public: SfxErrorContext( - sal_uInt16 nCtxIdP, vcl::Window *pWin=nullptr, + sal_uInt16 nCtxIdP, weld::Window *pWin=nullptr, const ErrMsgCode* pIds = nullptr, const std::locale& rResLocaleP = SvtResLocale()); SfxErrorContext( - sal_uInt16 nCtxIdP, const OUString &aArg1, vcl::Window *pWin=nullptr, + sal_uInt16 nCtxIdP, const OUString &aArg1, weld::Window *pWin=nullptr, const ErrMsgCode* pIds = nullptr, const std::locale& rResLocaleP = SvtResLocale()); bool GetString(ErrCode nErrId, OUString &rStr) override; diff --git a/include/vcl/builder.hxx b/include/vcl/builder.hxx index d9d500051116..bb66872e786d 100644 --- a/include/vcl/builder.hxx +++ b/include/vcl/builder.hxx @@ -126,12 +126,10 @@ private: { OString m_sID; VclPtr<vcl::Window> m_pWindow; - short m_nResponseId; PackingData m_aPackingData; WinAndId(const OString &rId, vcl::Window *pWindow, bool bVertical) : m_sID(rId) , m_pWindow(pWindow) - , m_nResponseId(RET_CANCEL) , m_aPackingData(bVertical) { } diff --git a/include/vcl/dialog.hxx b/include/vcl/dialog.hxx index 24e0dfd7378f..8695cc4fa632 100644 --- a/include/vcl/dialog.hxx +++ b/include/vcl/dialog.hxx @@ -29,6 +29,7 @@ #include <vcl/abstdlg.hxx> struct DialogImpl; +class PushButton; class VclBox; class VclButtonBox; @@ -69,7 +70,8 @@ private: SAL_DLLPRIVATE Dialog (const Dialog &) = delete; SAL_DLLPRIVATE Dialog & operator= (const Dialog &) = delete; - DECL_DLLPRIVATE_LINK( ImplAsyncCloseHdl, void*, void ); + DECL_DLLPRIVATE_LINK(ImplAsyncCloseHdl, void*, void); + DECL_DLLPRIVATE_LINK(ResponseHdl, Button*, void); protected: using Window::ImplInit; @@ -78,6 +80,7 @@ protected: public: SAL_DLLPRIVATE bool IsInClose() const { return mbInClose; } virtual void doDeferredInit(WinBits nBits) override; + SAL_DLLPRIVATE void disposeOwnedButtons(); protected: explicit Dialog( WindowType nType ); @@ -170,6 +173,9 @@ public: void GrabFocusToFirstControl(); virtual void Resize() override; + + void add_button(PushButton* pButton, int nResponse, bool bTransferOwnership); + void set_default_response(int nResponse); }; class VCL_DLLPUBLIC ModelessDialog : public Dialog diff --git a/include/vcl/errinf.hxx b/include/vcl/errinf.hxx index f4edc53d46fd..95e16213981b 100644 --- a/include/vcl/errinf.hxx +++ b/include/vcl/errinf.hxx @@ -31,6 +31,7 @@ #include <limits.h> namespace vcl { class Window; } +namespace weld { class Window; } class ErrorHandler; class ErrorContext; @@ -43,7 +44,7 @@ enum class DialogMask; typedef void (* DisplayFnPtr)(); typedef DialogMask WindowDisplayErrorFunc( - vcl::Window*, DialogMask eMask, const OUString &rErr, const OUString &rAction); + weld::Window*, DialogMask eMask, const OUString &rErr, const OUString &rAction); typedef void BasicDisplayErrorFunc( const OUString &rErr, const OUString &rAction); @@ -99,7 +100,7 @@ namespace o3tl } typedef DialogMask WindowDisplayErrorFunc( - vcl::Window*, DialogMask nMask, const OUString &rErr, const OUString &rAction); + weld::Window*, DialogMask nMask, const OUString &rErr, const OUString &rAction); typedef void BasicDisplayErrorFunc( const OUString &rErr, const OUString &rAction); @@ -128,7 +129,7 @@ public: @return what sort of dialog to use, with what buttons */ - static DialogMask HandleError(ErrCode nId, vcl::Window* pParent = nullptr, DialogMask nMask = DialogMask::MAX); + static DialogMask HandleError(ErrCode nId, weld::Window* pParent = nullptr, DialogMask nMask = DialogMask::MAX); static bool GetErrorString(ErrCode nId, OUString& rStr); protected: @@ -204,11 +205,11 @@ class SAL_WARN_UNUSED VCL_DLLPUBLIC ErrorContext friend class ErrorHandler; public: - ErrorContext(vcl::Window *pWin); + ErrorContext(weld::Window *pWin); virtual ~ErrorContext(); virtual bool GetString(ErrCode nErrId, OUString& rCtxStr) = 0; - vcl::Window* GetParent(); + weld::Window* GetParent(); static ErrorContext* GetContext(); diff --git a/include/vcl/messagedialog.hxx b/include/vcl/messagedialog.hxx index 6de75a9fb9a6..1cce2f41009e 100644 --- a/include/vcl/messagedialog.hxx +++ b/include/vcl/messagedialog.hxx @@ -26,13 +26,8 @@ private: VclPtr<FixedImage> m_pImage; VclPtr<VclMultiLineEdit> m_pPrimaryMessage; VclPtr<VclMultiLineEdit> m_pSecondaryMessage; - std::vector<VclPtr<PushButton>> m_aOwnedButtons; - std::map<VclPtr<const vcl::Window>, short> m_aResponses; OUString m_sPrimaryString; OUString m_sSecondaryString; - DECL_DLLPRIVATE_LINK(ButtonHdl, Button*, void); - void setButtonHandlers(VclButtonBox const* pButtonBox); - short get_response(const vcl::Window* pWindow) const; void create_owned_areas(); friend class VclPtr<MessageDialog>; @@ -45,8 +40,6 @@ public: 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; - ///Emitted when an action widget is clicked - virtual void response(short nResponseId); OUString const& get_primary_text() const; OUString const& get_secondary_text() const; void set_primary_text(const OUString& rPrimaryString); diff --git a/include/vcl/msgbox.hxx b/include/vcl/msgbox.hxx index 7c982cc5a996..203d3ea36d80 100644 --- a/include/vcl/msgbox.hxx +++ b/include/vcl/msgbox.hxx @@ -88,16 +88,8 @@ public: virtual Size GetOptimalSize() const override; }; -class VCL_DLLPUBLIC InfoBox : public MessBox -{ -public: - InfoBox( vcl::Window* pParent, const OUString& rMessage ); - InfoBox( vcl::Window* pParent, MessBoxStyle nStyle, - const OUString& rMessage ); - - static Image const & GetStandardImage(); - static OUString GetStandardText(); -}; +VCL_DLLPUBLIC Image const & GetStandardInfoBoxImage(); +VCL_DLLPUBLIC OUString GetStandardInfoBoxText(); class VCL_DLLPUBLIC WarningBox : public MessBox { diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx index bfc6a7e10214..69674ab9ba17 100644 --- a/include/vcl/weld.hxx +++ b/include/vcl/weld.hxx @@ -96,6 +96,8 @@ class VCL_DLLPUBLIC Dialog : virtual public Window public: virtual int run() = 0; virtual void response(int response) = 0; + virtual void add_button(const OUString& rText, int response) = 0; + virtual void set_default_response(int response) = 0; }; class VCL_DLLPUBLIC MessageDialog : virtual public Dialog diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx index 0bafb21b85ca..c806f05aae6e 100644 --- a/sc/source/core/data/dpobject.cxx +++ b/sc/source/core/data/dpobject.cxx @@ -73,7 +73,8 @@ #include <tools/debug.hxx> #include <tools/diagnose_ex.h> #include <svl/zforlist.hxx> -#include <vcl/msgbox.hxx> +#include <vcl/svapp.hxx> +#include <vcl/weld.hxx> #include <utility> #include <vector> @@ -3308,8 +3309,10 @@ uno::Reference<sdbc::XRowSet> ScDPCollection::DBCaches::createRowSet( catch ( const sdbc::SQLException& rError ) { //! store error message - ScopedVclPtrInstance< InfoBox > aInfoBox( nullptr, rError.Message ); - aInfoBox->Execute(); + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(nullptr, + VclMessageType::Info, VclButtonsType::Ok, + rError.Message)); + xInfoBox->run(); } catch ( uno::Exception& ) { diff --git a/sc/source/ui/dbgui/consdlg.cxx b/sc/source/ui/dbgui/consdlg.cxx index 7d1ccc0f6b33..0e3e09839892 100644 --- a/sc/source/ui/dbgui/consdlg.cxx +++ b/sc/source/ui/dbgui/consdlg.cxx @@ -32,9 +32,19 @@ #include <strings.hrc> #include <consdlg.hxx> -#include <vcl/msgbox.hxx> +#include <vcl/svapp.hxx> +#include <vcl/weld.hxx> -#define INFOBOX(id) ScopedVclPtrInstance<InfoBox>(this, ScGlobal::GetRscString(id))->Execute() +namespace +{ + void INFOBOX(weld::Window* pWindow, const char* id) + { + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(pWindow, + VclMessageType::Info, VclButtonsType::Ok, + ScGlobal::GetRscString(id))); + xInfoBox->run(); + } +} class ScAreaData { @@ -406,7 +416,7 @@ IMPL_LINK_NOARG(ScConsolidateDlg, OkHdl, Button*, void) } else { - INFOBOX( STR_INVALID_TABREF ); + INFOBOX(GetFrameWeld(), STR_INVALID_TABREF); pEdDestArea->GrabFocus(); } } @@ -461,11 +471,11 @@ IMPL_LINK( ScConsolidateDlg, ClickHdl, Button*, pBtn, void ) if ( pLbConsAreas->GetEntryPos( aNewArea ) == LISTBOX_ENTRY_NOTFOUND ) pLbConsAreas->InsertEntry( aNewArea ); else - INFOBOX( STR_AREA_ALREADY_INSERTED ); + INFOBOX(GetFrameWeld(), STR_AREA_ALREADY_INSERTED); } else { - INFOBOX( STR_INVALID_TABREF ); + INFOBOX(GetFrameWeld(), STR_INVALID_TABREF); pEdDataArea->GrabFocus(); } } diff --git a/sc/source/ui/dbgui/scendlg.cxx b/sc/source/ui/dbgui/scendlg.cxx index b914ed2609a7..77eb9ba6f610 100644 --- a/sc/source/ui/dbgui/scendlg.cxx +++ b/sc/source/ui/dbgui/scendlg.cxx @@ -26,7 +26,7 @@ #include <svx/xtable.hxx> #include <sfx2/objsh.hxx> #include <unotools/useroptions.hxx> -#include <vcl/msgbox.hxx> +#include <vcl/weld.hxx> #include <unotools/localedatawrapper.hxx> #include <global.hxx> @@ -151,12 +151,18 @@ IMPL_LINK_NOARG(ScNewScenarioDlg, OkHdl, Button*, void) if ( !ScDocument::ValidTabName( aName ) ) { - ScopedVclPtrInstance<InfoBox>(this, ScGlobal::GetRscString(STR_INVALIDTABNAME))->Execute(); + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(), + VclMessageType::Info, VclButtonsType::Ok, + ScGlobal::GetRscString(STR_INVALIDTABNAME))); + xInfoBox->run(); m_pEdName->GrabFocus(); } else if ( !bIsEdit && !pDoc->ValidNewTabName( aName ) ) { - ScopedVclPtrInstance<InfoBox>(this, ScGlobal::GetRscString(STR_NEWTABNAMENOTUNIQUE))->Execute(); + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(), + VclMessageType::Info, VclButtonsType::Ok, + ScGlobal::GetRscString(STR_NEWTABNAMENOTUNIQUE))); + xInfoBox->run(); m_pEdName->GrabFocus(); } else diff --git a/sc/source/ui/docshell/arealink.cxx b/sc/source/ui/docshell/arealink.cxx index 63ea2ad325f0..e9ce36f11ac9 100644 --- a/sc/source/ui/docshell/arealink.cxx +++ b/sc/source/ui/docshell/arealink.cxx @@ -23,7 +23,7 @@ #include <sfx2/fcontnr.hxx> #include <sfx2/linkmgr.hxx> #include <svl/stritem.hxx> -#include <vcl/msgbox.hxx> +#include <vcl/weld.hxx> #include <arealink.hxx> @@ -463,9 +463,11 @@ bool ScAreaLink::Refresh( const OUString& rNewFile, const OUString& rNewFilter, //! Link dialog must set default parent // "cannot insert rows" - ScopedVclPtrInstance<InfoBox> aBox( Application::GetDefDialogParent(), - ScGlobal::GetRscString( STR_MSSG_DOSUBTOTALS_2 ) ); - aBox->Execute(); + vcl::Window* pWin = Application::GetDefDialogParent(); + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(pWin ? pWin->GetFrameWeld() : nullptr, + VclMessageType::Info, VclButtonsType::Ok, + ScGlobal::GetRscString(STR_MSSG_DOSUBTOTALS_2))); + xInfoBox->run(); } // clean up diff --git a/sc/source/ui/docshell/dbdocfun.cxx b/sc/source/ui/docshell/dbdocfun.cxx index 50e0f5b514e6..1c413903a35a 100644 --- a/sc/source/ui/docshell/dbdocfun.cxx +++ b/sc/source/ui/docshell/dbdocfun.cxx @@ -19,6 +19,7 @@ #include <sfx2/app.hxx> #include <vcl/msgbox.hxx> +#include <vcl/weld.hxx> #include <vcl/waitobj.hxx> #include <svx/dataaccessdescriptor.hxx> #include <svx/svdpage.hxx> @@ -1670,9 +1671,11 @@ void ScDBDocFunc::UpdateImport( const OUString& rTarget, const svx::ODataAccessD const ScDBData* pData = rDBColl.getNamedDBs().findByUpperName(ScGlobal::pCharClass->uppercase(rTarget)); if (!pData) { - ScopedVclPtrInstance<InfoBox> aInfoBox( ScDocShell::GetActiveDialogParent(), - ScGlobal::GetRscString( STR_TARGETNOTFOUND ) ); - aInfoBox->Execute(); + vcl::Window* pWin = ScDocShell::GetActiveDialogParent(); + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(pWin ? pWin->GetFrameWeld() : nullptr, + VclMessageType::Info, VclButtonsType::Ok, + ScGlobal::GetRscString(STR_TARGETNOTFOUND))); + xInfoBox->run(); return; } diff --git a/sc/source/ui/docshell/dbdocimp.cxx b/sc/source/ui/docshell/dbdocimp.cxx index d83fb8be69f4..ad0481942934 100644 --- a/sc/source/ui/docshell/dbdocimp.cxx +++ b/sc/source/ui/docshell/dbdocimp.cxx @@ -20,7 +20,7 @@ #include <vcl/errinf.hxx> #include <comphelper/processfactory.hxx> #include <comphelper/types.hxx> -#include <vcl/msgbox.hxx> +#include <vcl/weld.hxx> #include <svx/dataaccessdescriptor.hxx> #include <sfx2/viewfrm.hxx> @@ -616,8 +616,11 @@ bool ScDBDocFunc::DoImport( SCTAB nTab, const ScImportParam& rParam, pErrStringId = STR_MSSG_IMPORTDATA_0; aErrorMessage = ScGlobal::GetRscString(pErrStringId); } - ScopedVclPtrInstance< InfoBox > aInfoBox( ScDocShell::GetActiveDialogParent(), aErrorMessage ); - aInfoBox->Execute(); + vcl::Window* pWin = ScDocShell::GetActiveDialogParent(); + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(pWin ? pWin->GetFrameWeld() : nullptr, + VclMessageType::Info, VclButtonsType::Ok, + aErrorMessage)); + xInfoBox->run(); } delete pImportDoc; diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx index 430da19d4fa8..4ac78e1b67a0 100644 --- a/sc/source/ui/docshell/docfunc.cxx +++ b/sc/source/ui/docshell/docfunc.cxx @@ -25,6 +25,7 @@ #include <sfx2/linkmgr.hxx> #include <sfx2/bindings.hxx> #include <vcl/msgbox.hxx> +#include <vcl/weld.hxx> #include <vcl/virdev.hxx> #include <vcl/waitobj.hxx> #include <svl/PasswordHelper.hxx> @@ -394,8 +395,10 @@ bool ScDocFunc::DetectiveMarkInvalid(SCTAB nTab) aModificator.SetDocumentModified(); if ( bOverflow ) { - ScopedVclPtrInstance<InfoBox>( nullptr, - ScGlobal::GetRscString( STR_DETINVALID_OVERFLOW ) )->Execute(); + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(nullptr, + VclMessageType::Info, VclButtonsType::Ok, + ScGlobal::GetRscString(STR_DETINVALID_OVERFLOW))); + xInfoBox->run(); } } else @@ -3911,8 +3914,11 @@ bool ScDocFunc::Unprotect( SCTAB nTab, const OUString& rPassword, bool bApi ) { if (!bApi) { - ScopedVclPtrInstance< InfoBox > aBox( ScDocShell::GetActiveDialogParent(), ScResId( SCSTR_WRONGPASSWORD ) ); - aBox->Execute(); + vcl::Window* pWin = ScDocShell::GetActiveDialogParent(); + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(pWin ? pWin->GetFrameWeld() : nullptr, + VclMessageType::Info, VclButtonsType::Ok, + ScResId(SCSTR_WRONGPASSWORD))); + xInfoBox->run(); } return false; } @@ -3941,8 +3947,11 @@ bool ScDocFunc::Unprotect( SCTAB nTab, const OUString& rPassword, bool bApi ) { if (!bApi) { - ScopedVclPtrInstance< InfoBox > aBox( ScDocShell::GetActiveDialogParent(), ScResId( SCSTR_WRONGPASSWORD ) ); - aBox->Execute(); + vcl::Window* pWin = ScDocShell::GetActiveDialogParent(); + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(pWin ? pWin->GetFrameWeld() : nullptr, + VclMessageType::Info, VclButtonsType::Ok, + ScResId(SCSTR_WRONGPASSWORD))); + xInfoBox->run(); } return false; } diff --git a/sc/source/ui/docshell/docsh3.cxx b/sc/source/ui/docshell/docsh3.cxx index 8eae0400beee..f13a23113498 100644 --- a/sc/source/ui/docshell/docsh3.cxx +++ b/sc/source/ui/docshell/docsh3.cxx @@ -34,6 +34,7 @@ #include <unotools/misccfg.hxx> #include <vcl/virdev.hxx> #include <vcl/msgbox.hxx> +#include <vcl/weld.hxx> #include <docsh.hxx> #include "docshimp.hxx" @@ -1317,8 +1318,11 @@ bool ScDocShell::MergeSharedDocument( ScDocShell* pSharedDocShell ) PostPaintExtras(); PostPaintGridAll(); - ScopedVclPtrInstance< InfoBox > aInfoBox( GetActiveDialogParent(), ScGlobal::GetRscString( STR_DOC_UPDATED ) ); - aInfoBox->Execute(); + vcl::Window* pWin = GetActiveDialogParent(); + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(pWin ? pWin->GetFrameWeld() : nullptr, + VclMessageType::Info, VclButtonsType::Ok, + ScGlobal::GetRscString(STR_DOC_UPDATED))); + xInfoBox->run(); } return ( pThisAction != nullptr ); diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx index 8721cecc6a97..749ec29784a7 100644 --- a/sc/source/ui/docshell/docsh4.cxx +++ b/sc/source/ui/docshell/docsh4.cxx @@ -44,6 +44,7 @@ using namespace ::com::sun::star; #include <svx/ofaitem.hxx> #include <svl/whiter.hxx> #include <vcl/msgbox.hxx> +#include <vcl/weld.hxx> #include <vcl/waitobj.hxx> #include <svx/dataaccessdescriptor.hxx> #include <svx/drawitem.hxx> @@ -1293,9 +1294,11 @@ bool ScDocShell::ExecuteChangeProtectionDialog( bool bJustQueryIfProtected ) } else { - ScopedVclPtrInstance<InfoBox> aBox( GetActiveDialogParent(), - ScResId( SCSTR_WRONGPASSWORD ) ); - aBox->Execute(); + vcl::Window* pWin = ScDocShell::GetActiveDialogParent(); + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(pWin ? pWin->GetFrameWeld() : nullptr, + VclMessageType::Info, VclButtonsType::Ok, + ScResId(SCSTR_WRONGPASSWORD))); + xInfoBox->run(); } } else @@ -1629,10 +1632,12 @@ void ScDocShell::PageStyleModified( const OUString& rStyleName, bool bApi ) if (bWarn && !bApi) { - ScWaitCursorOff aWaitOff( GetActiveDialogParent() ); - ScopedVclPtrInstance<InfoBox> aInfoBox(GetActiveDialogParent(), - ScGlobal::GetRscString(STR_PRINT_INVALID_AREA)); - aInfoBox->Execute(); + vcl::Window* pWin = GetActiveDialogParent(); + ScWaitCursorOff aWaitOff(pWin); + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(pWin ? pWin->GetFrameWeld() : nullptr, + VclMessageType::Info, VclButtonsType::Ok, + ScGlobal::GetRscString(STR_PRINT_INVALID_AREA))); + xInfoBox->run(); } } diff --git a/sc/source/ui/docshell/docsh5.cxx b/sc/source/ui/docshell/docsh5.cxx index d55f0f29f9c5..8b1730af3a0d 100644 --- a/sc/source/ui/docshell/docsh5.cxx +++ b/sc/source/ui/docshell/docsh5.cxx @@ -23,7 +23,7 @@ #include <cassert> #include <scitems.hxx> -#include <vcl/msgbox.hxx> +#include <vcl/weld.hxx> #include <vcl/waitobj.hxx> #include <sfx2/app.hxx> #include <sfx2/bindings.hxx> @@ -82,8 +82,11 @@ void ScDocShell::ErrorMessage(const char* pGlobStrId) } } - ScopedVclPtrInstance< InfoBox > aBox( pParent, ScGlobal::GetRscString(pGlobStrId)); - aBox->Execute(); + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(pParent ? pParent->GetFrameWeld() : nullptr, + VclMessageType::Info, VclButtonsType::Ok, + ScGlobal::GetRscString(pGlobStrId))); + xInfoBox->run(); + if (bFocus) pParent->GrabFocus(); } @@ -519,9 +522,11 @@ void ScDocShell::DoConsolidate( const ScConsolidateParam& rParam, bool bRecord ) if (bErr) { - ScopedVclPtrInstance<InfoBox> aBox( GetActiveDialogParent(), - ScGlobal::GetRscString( STR_CONSOLIDATE_ERR1 ) ); - aBox->Execute(); + vcl::Window* pWin = GetActiveDialogParent(); + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(pWin ? pWin->GetFrameWeld() : nullptr, + VclMessageType::Info, VclButtonsType::Ok, + ScGlobal::GetRscString(STR_CONSOLIDATE_ERR1))); + xInfoBox->run(); return; } @@ -729,16 +734,20 @@ void ScDocShell::UseScenario( SCTAB nTab, const OUString& rName, bool bRecord ) } else { - ScopedVclPtrInstance<InfoBox> aBox( GetActiveDialogParent(), - ScGlobal::GetRscString( STR_PROTECTIONERR ) ); - aBox->Execute(); + vcl::Window* pWin = GetActiveDialogParent(); + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(pWin ? pWin->GetFrameWeld() : nullptr, + VclMessageType::Info, VclButtonsType::Ok, + ScGlobal::GetRscString(STR_PROTECTIONERR))); + xInfoBox->run(); } } else { - ScopedVclPtrInstance<InfoBox> aBox(GetActiveDialogParent(), - ScGlobal::GetRscString( STR_SCENARIO_NOTFOUND ) ); - aBox->Execute(); + vcl::Window* pWin = GetActiveDialogParent(); + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(pWin ? pWin->GetFrameWeld() : nullptr, + VclMessageType::Info, VclButtonsType::Ok, + ScGlobal::GetRscString(STR_SCENARIO_NOTFOUND))); + xInfoBox->run(); } } else diff --git a/sc/source/ui/docshell/docsh6.cxx b/sc/source/ui/docshell/docsh6.cxx index 508ea9f5b882..8e3a28280e2a 100644 --- a/sc/source/ui/docshell/docsh6.cxx +++ b/sc/source/ui/docshell/docsh6.cxx @@ -37,7 +37,8 @@ #include <interpre.hxx> #include <calcconfig.hxx> -#include <vcl/msgbox.hxx> +#include <vcl/svapp.hxx> +#include <vcl/weld.hxx> #include <memory> #include <utility> @@ -499,8 +500,10 @@ void ScDocShell::CheckConfigOptions() if (pViewShell) { vcl::Window* pParent = pViewShell->GetFrameWin(); - ScopedVclPtrInstance< InfoBox > aBox(pParent, ScGlobal::GetRscString(STR_OPTIONS_WARN_SEPARATORS)); - aBox->Execute(); + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(pParent ? pParent->GetFrameWeld() : nullptr, + VclMessageType::Info, VclButtonsType::Ok, + ScGlobal::GetRscString(STR_OPTIONS_WARN_SEPARATORS))); + xInfoBox->run(); } // For now, this is the only option setting that could launch info diff --git a/sc/source/ui/docshell/impex.cxx b/sc/source/ui/docshell/impex.cxx index 146c097626e1..e39abc0dc479 100644 --- a/sc/source/ui/docshell/impex.cxx +++ b/sc/source/ui/docshell/impex.cxx @@ -57,6 +57,7 @@ #include <tools/svlibrary.h> #include <unotools/configmgr.hxx> #include <vcl/svapp.hxx> +#include <vcl/weld.hxx> #include <memory> #include <osl/endian.h> @@ -227,9 +228,11 @@ bool ScImportExport::StartPaste() ScEditableTester aTester( pDoc, aRange ); if ( !aTester.IsEditable() ) { - ScopedVclPtrInstance<InfoBox> aInfoBox( Application::GetDefDialogParent(), - ScGlobal::GetRscString( aTester.GetMessageId() ) ); - aInfoBox->Execute(); + vcl::Window* pWin = Application::GetDefDialogParent(); + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(pWin ? pWin->GetFrameWeld() : nullptr, + VclMessageType::Info, VclButtonsType::Ok, + ScGlobal::GetRscString(aTester.GetMessageId()))); + xInfoBox->run(); return false; } } diff --git a/sc/source/ui/optdlg/tpusrlst.cxx b/sc/source/ui/optdlg/tpusrlst.cxx index 4eb077076728..52e671bcb33d 100644 --- a/sc/source/ui/optdlg/tpusrlst.cxx +++ b/sc/source/ui/optdlg/tpusrlst.cxx @@ -420,7 +420,10 @@ void ScTpUserLists::CopyListFromArea( const ScRefAddress& rStartPos, if ( bValueIgnored ) { - ScopedVclPtrInstance<InfoBox>(this, aStrCopyErr)->Execute(); + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(), + VclMessageType::Info, VclButtonsType::Ok, + aStrCopyErr)); + xInfoBox->run(); } } diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx index 99227a5dbd7f..f24c6b4c60a6 100644 --- a/sc/source/ui/view/cellsh1.cxx +++ b/sc/source/ui/view/cellsh1.cxx @@ -35,6 +35,7 @@ #include <sfx2/dispatch.hxx> #include <sfx2/request.hxx> #include <vcl/msgbox.hxx> +#include <vcl/weld.hxx> #include <svx/svxdlg.hxx> #include <sot/formats.hxx> #include <svx/postattr.hxx> @@ -2960,8 +2961,11 @@ void ScCellShell::ExecuteDataPilotDialog() if (pSrcErrorId) { // Error occurred during data creation. Launch an error and bail out. - ScopedVclPtrInstance< InfoBox > aBox(pTabViewShell->GetDialogParent(), ScGlobal::GetRscString(pSrcErrorId)); - aBox->Execute(); + vcl::Window* pWin = pTabViewShell->GetDialogParent(); + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(pWin ? pWin->GetFrameWeld() : nullptr, + VclMessageType::Info, VclButtonsType::Ok, + ScGlobal::GetRscString(pSrcErrorId))); + xInfoBox->run(); return; } diff --git a/sc/source/ui/view/spelleng.cxx b/sc/source/ui/view/spelleng.cxx index 15fedc1f9733..9e39ea9dfa61 100644 --- a/sc/source/ui/view/spelleng.cxx +++ b/sc/source/ui/view/spelleng.cxx @@ -27,9 +27,10 @@ #include <editeng/editobj.hxx> #include <editeng/editview.hxx> #include <sfx2/viewfrm.hxx> -#include <vcl/msgbox.hxx> -#include <vcl/svapp.hxx> #include <vcl/settings.hxx> +#include <vcl/svapp.hxx> +#include <vcl/msgbox.hxx> +#include <vcl/weld.hxx> #include <spelldialog.hxx> #include <tabvwsh.hxx> @@ -316,7 +317,10 @@ void ScSpellingEngine::ShowFinishDialog() { vcl::Window* pParent = GetDialogParent(); ScWaitCursorOff aWaitOff( pParent ); - ScopedVclPtrInstance<InfoBox>( pParent, ScGlobal::GetRscString( STR_SPELLING_STOP_OK ) )->Execute(); + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(pParent ? pParent->GetFrameWeld() : nullptr, + VclMessageType::Info, VclButtonsType::Ok, + ScGlobal::GetRscString(STR_SPELLING_STOP_OK))); + xInfoBox->run(); } vcl::Window* ScSpellingEngine::GetDialogParent() diff --git a/sc/source/ui/view/tabview2.cxx b/sc/source/ui/view/tabview2.cxx index 17d562836124..4aa52f586910 100644 --- a/sc/source/ui/view/tabview2.cxx +++ b/sc/source/ui/view/tabview2.cxx @@ -20,7 +20,7 @@ #include <scitems.hxx> #include <editeng/eeitem.hxx> #include <vcl/timer.hxx> -#include <vcl/msgbox.hxx> +#include <vcl/weld.hxx> #include <sfx2/app.hxx> #include <sfx2/viewfrm.hxx> #include <sfx2/bindings.hxx> @@ -1434,8 +1434,11 @@ void ScTabView::ErrorMessage(const char* pGlobStrId) } } - ScopedVclPtrInstance<InfoBox> aBox(pParent, ScGlobal::GetRscString(pGlobStrId)); - aBox->Execute(); + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(pParent ? pParent->GetFrameWeld() : nullptr, + VclMessageType::Info, VclButtonsType::Ok, + ScGlobal::GetRscString(pGlobStrId))); + xInfoBox->run(); + if (bFocus) pParent->GrabFocus(); } diff --git a/sc/source/ui/view/viewfun4.cxx b/sc/source/ui/view/viewfun4.cxx index f59e4b25db5c..78bdd8eb7cc2 100644 --- a/sc/source/ui/view/viewfun4.cxx +++ b/sc/source/ui/view/viewfun4.cxx @@ -41,7 +41,7 @@ #include <svtools/transfer.hxx> #include <svl/urlbmk.hxx> #include <svl/sharedstringpool.hxx> -#include <vcl/msgbox.hxx> +#include <vcl/weld.hxx> #include <avmedia/mediawindow.hxx> #include <comphelper/storagehelper.hxx> @@ -399,8 +399,12 @@ void ScViewFunc::DoThesaurus() LanguageType eLnge = ScViewUtil::GetEffLanguage( &rDoc, ScAddress( nCol, nRow, nTab ) ); OUString aErr = SvtLanguageTable::GetLanguageString(eLnge); aErr += ScGlobal::GetRscString( STR_SPELLING_NO_LANG ); - ScopedVclPtrInstance< InfoBox > aBox( GetViewData().GetDialogParent(), aErr ); - aBox->Execute(); + + vcl::Window* pWin = GetViewData().GetDialogParent(); + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(pWin ? pWin->GetFrameWeld() : nullptr, + VclMessageType::Info, VclButtonsType::Ok, + aErr)); + xInfoBox->run(); } if (pThesaurusEngine->IsModified()) { diff --git a/sd/source/ui/dlg/PhotoAlbumDialog.cxx b/sd/source/ui/dlg/PhotoAlbumDialog.cxx index 18978ee448c8..adf5a386ee9f 100644 --- a/sd/source/ui/dlg/PhotoAlbumDialog.cxx +++ b/sd/source/ui/dlg/PhotoAlbumDialog.cxx @@ -26,6 +26,7 @@ #include <officecfg/Office/Impress.hxx> #include <svx/svdview.hxx> #include <vcl/msgbox.hxx> +#include <vcl/weld.hxx> #include <svx/unoshape.hxx> #include <svx/xfltrit.hxx> #include <svx/xfillit.hxx> @@ -490,8 +491,10 @@ IMPL_LINK_NOARG(SdPhotoAlbumDialog, CreateHdl, Button*, void) } else { - ScopedVclPtrInstance< InfoBox > aInfo(this, OUString("Function is not implemented!")); - aInfo->Execute(); + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(), + VclMessageType::Info, VclButtonsType::Ok, + "Function is not implemented!")); + xInfoBox->run(); } EndDialog(); } diff --git a/sd/source/ui/func/fudraw.cxx b/sd/source/ui/func/fudraw.cxx index 8d507f4302e1..f25836ae459d 100644 --- a/sd/source/ui/func/fudraw.cxx +++ b/sd/source/ui/func/fudraw.cxx @@ -58,7 +58,7 @@ #include <drawview.hxx> #include <fusel.hxx> #include <svl/aeitem.hxx> -#include <vcl/msgbox.hxx> +#include <vcl/weld.hxx> #include <slideshow.hxx> #include <svx/sdrhittesthelper.hxx> @@ -339,7 +339,10 @@ bool FuDraw::KeyInput(const KeyEvent& rKEvt) { if (mpView->IsPresObjSelected(false, true, false, true)) { - ScopedVclPtrInstance<InfoBox>(mpWindow, SdResId(STR_ACTION_NOTPOSSIBLE))->Execute(); + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(mpWindow->GetFrameWeld(), + VclMessageType::Info, VclButtonsType::Ok, + SdResId(STR_ACTION_NOTPOSSIBLE))); + xInfoBox->run(); } else { diff --git a/sd/source/ui/func/futhes.cxx b/sd/source/ui/func/futhes.cxx index ad1907648d2c..02fca91226bb 100644 --- a/sd/source/ui/func/futhes.cxx +++ b/sd/source/ui/func/futhes.cxx @@ -67,7 +67,7 @@ rtl::Reference<FuPoor> FuThesaurus::Create( ViewShell* pViewSh, ::sd::Window* pW void FuThesaurus::DoExecute( SfxRequest& ) { SfxErrorContext aContext(ERRCTX_SVX_LINGU_THESAURUS, OUString(), - mpWindow, RID_SVXERRCTX, SvxResLocale()); + mpWindow->GetFrameWeld(), RID_SVXERRCTX, SvxResLocale()); if (mpViewShell && dynamic_cast< DrawViewShell *>( mpViewShell ) != nullptr) { diff --git a/sd/source/ui/view/drawview.cxx b/sd/source/ui/view/drawview.cxx index 7620a2cec268..d1b2832c2cc4 100644 --- a/sd/source/ui/view/drawview.cxx +++ b/sd/source/ui/view/drawview.cxx @@ -18,7 +18,7 @@ */ #include <sfx2/dispatch.hxx> -#include <vcl/msgbox.hxx> +#include <vcl/weld.hxx> #include <svx/svdpagv.hxx> #include <sfx2/request.hxx> #include <svl/style.hxx> @@ -433,8 +433,11 @@ bool DrawView::SetStyleSheet(SfxStyleSheet* pStyleSheet, bool bDontRemoveHardAtt { if (IsPresObjSelected(false)) { - ScopedVclPtrInstance<InfoBox>(mpDrawViewShell->GetActiveWindow(), - SdResId(STR_ACTION_NOTPOSSIBLE))->Execute(); + vcl::Window* pWin = mpDrawViewShell->GetActiveWindow(); + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(pWin ? pWin->GetFrameWeld() : nullptr, + VclMessageType::Info, VclButtonsType::Ok, + SdResId(STR_ACTION_NOTPOSSIBLE))); + xInfoBox->run(); bResult = false; } else diff --git a/sd/source/ui/view/drviews2.cxx b/sd/source/ui/view/drviews2.cxx index 615bfb9e9a00..6d6dcad9e855 100644 --- a/sd/source/ui/view/drviews2.cxx +++ b/sd/source/ui/view/drviews2.cxx @@ -958,7 +958,10 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq) if ( mpDrawView->IsPresObjSelected() ) { ::sd::Window* pWindow = GetActiveWindow(); - ScopedVclPtrInstance<InfoBox>(pWindow, SdResId(STR_ACTION_NOTPOSSIBLE))->Execute(); + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(pWindow ? pWindow->GetFrameWeld() : nullptr, + VclMessageType::Info, VclButtonsType::Ok, + SdResId(STR_ACTION_NOTPOSSIBLE))); + xInfoBox->run(); } else { @@ -1003,7 +1006,10 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq) if ( mpDrawView->IsPresObjSelected() ) { ::sd::Window* pWindow = GetActiveWindow(); - ScopedVclPtrInstance<InfoBox>(pWindow, SdResId(STR_ACTION_NOTPOSSIBLE))->Execute(); + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(pWindow ? pWindow->GetFrameWeld() : nullptr, + VclMessageType::Info, VclButtonsType::Ok, + SdResId(STR_ACTION_NOTPOSSIBLE))); + xInfoBox->run(); } else { @@ -1031,7 +1037,10 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq) if ( mpDrawView->IsPresObjSelected(true,true,true) ) { ::sd::Window* pWindow = GetActiveWindow(); - ScopedVclPtrInstance<InfoBox>(pWindow, SdResId(STR_ACTION_NOTPOSSIBLE))->Execute(); + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(pWindow ? pWindow->GetFrameWeld() : nullptr, + VclMessageType::Info, VclButtonsType::Ok, + SdResId(STR_ACTION_NOTPOSSIBLE))); + xInfoBox->run(); } else { @@ -1545,7 +1554,10 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq) if ( mpDrawView->IsPresObjSelected(false) ) { ::sd::Window* pWindow = GetActiveWindow(); - ScopedVclPtrInstance<InfoBox>(pWindow, SdResId(STR_ACTION_NOTPOSSIBLE))->Execute(); + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(pWindow ? pWindow->GetFrameWeld() : nullptr, + VclMessageType::Info, VclButtonsType::Ok, + SdResId(STR_ACTION_NOTPOSSIBLE))); + xInfoBox->run(); } else { @@ -1724,11 +1736,16 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq) if( !bDone ) { ::sd::Window* pWindow = GetActiveWindow(); + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(pWindow ? pWindow->GetFrameWeld() : nullptr, + VclMessageType::Info, VclButtonsType::Ok, #ifndef UNX - ScopedVclPtrInstance<InfoBox>(pWindow, SdResId(STR_TWAIN_NO_SOURCE))->Execute(); + SdResId(STR_TWAIN_NO_SOURCE) #else - ScopedVclPtrInstance<InfoBox>(pWindow, SdResId(STR_TWAIN_NO_SOURCE_UNX))->Execute(); + SdResId(STR_TWAIN_NO_SOURCE_UNX) #endif + )); + xInfoBox->run(); + } else { @@ -2449,7 +2466,10 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq) if ( mpDrawView->IsPresObjSelected( true, true, true ) ) { ::sd::Window* pWindow = GetActiveWindow(); - ScopedVclPtrInstance<InfoBox>(pWindow, SdResId(STR_ACTION_NOTPOSSIBLE))->Execute(); + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(pWindow ? pWindow->GetFrameWeld() : nullptr, + VclMessageType::Info, VclButtonsType::Ok, + SdResId(STR_ACTION_NOTPOSSIBLE))); + xInfoBox->run(); } else { @@ -2568,7 +2588,10 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq) if ( mpDrawView->IsPresObjSelected() ) { ::sd::Window* pWindow = GetActiveWindow(); - ScopedVclPtrInstance<InfoBox>(pWindow, SdResId(STR_ACTION_NOTPOSSIBLE))->Execute(); + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(pWindow ? pWindow->GetFrameWeld() : nullptr, + VclMessageType::Info, VclButtonsType::Ok, + SdResId(STR_ACTION_NOTPOSSIBLE))); + xInfoBox->run(); } else { @@ -2585,7 +2608,10 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq) if ( mpDrawView->IsPresObjSelected() ) { ::sd::Window* pWindow = GetActiveWindow(); - ScopedVclPtrInstance<InfoBox>(pWindow, SdResId(STR_ACTION_NOTPOSSIBLE))->Execute(); + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(pWindow ? pWindow->GetFrameWeld() : nullptr, + VclMessageType::Info, VclButtonsType::Ok, + SdResId(STR_ACTION_NOTPOSSIBLE))); + xInfoBox->run(); } else { @@ -2605,7 +2631,10 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq) if ( mpDrawView->IsPresObjSelected() ) { ::sd::Window* pWindow = GetActiveWindow(); - ScopedVclPtrInstance<InfoBox>(pWindow, SdResId(STR_ACTION_NOTPOSSIBLE))->Execute(); + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(pWindow ? pWindow->GetFrameWeld() : nullptr, + VclMessageType::Info, VclButtonsType::Ok, + SdResId(STR_ACTION_NOTPOSSIBLE))); + xInfoBox->run(); } else { @@ -2626,7 +2655,10 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq) if ( mpDrawView->IsPresObjSelected() ) { ::sd::Window* pWindow = GetActiveWindow(); - ScopedVclPtrInstance<InfoBox>(pWindow, SdResId(STR_ACTION_NOTPOSSIBLE))->Execute(); + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(pWindow ? pWindow->GetFrameWeld() : nullptr, + VclMessageType::Info, VclButtonsType::Ok, + SdResId(STR_ACTION_NOTPOSSIBLE))); + xInfoBox->run(); } else { @@ -2647,7 +2679,10 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq) if ( mpDrawView->IsPresObjSelected() ) { ::sd::Window* pWindow = GetActiveWindow(); - ScopedVclPtrInstance<InfoBox>(pWindow, SdResId(STR_ACTION_NOTPOSSIBLE))->Execute(); + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(pWindow ? pWindow->GetFrameWeld() : nullptr, + VclMessageType::Info, VclButtonsType::Ok, + SdResId(STR_ACTION_NOTPOSSIBLE))); + xInfoBox->run(); } else { @@ -2689,7 +2724,10 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq) if ( mpDrawView->IsPresObjSelected() ) { ::sd::Window* pWindow = GetActiveWindow(); - ScopedVclPtrInstance<InfoBox>(pWindow, SdResId(STR_ACTION_NOTPOSSIBLE))->Execute(); + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(pWindow ? pWindow->GetFrameWeld() : nullptr, + VclMessageType::Info, VclButtonsType::Ok, + SdResId(STR_ACTION_NOTPOSSIBLE))); + xInfoBox->run(); } else { @@ -2781,7 +2819,10 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq) if ( mpDrawView->IsPresObjSelected() ) { ::sd::Window* pWindow = GetActiveWindow(); - ScopedVclPtrInstance<InfoBox>(pWindow, SdResId(STR_ACTION_NOTPOSSIBLE))->Execute(); + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(pWindow ? pWindow->GetFrameWeld() : nullptr, + VclMessageType::Info, VclButtonsType::Ok, + SdResId(STR_ACTION_NOTPOSSIBLE))); + xInfoBox->run(); } else { diff --git a/sd/source/ui/view/drviewse.cxx b/sd/source/ui/view/drviewse.cxx index becb587d9e33..151c1fa10c47 100644 --- a/sd/source/ui/view/drviewse.cxx +++ b/sd/source/ui/view/drviewse.cxx @@ -34,6 +34,7 @@ #include <svl/aeitem.hxx> #include <editeng/editstat.hxx> #include <vcl/msgbox.hxx> +#include <vcl/weld.hxx> #include <svl/urlbmk.hxx> #include <svx/svdpagv.hxx> #include <svx/fmshell.hxx> @@ -328,7 +329,10 @@ void DrawViewShell::FuPermanent(SfxRequest& rReq) if ( mpDrawView->IsPresObjSelected() ) { ::sd::Window* pWindow = GetActiveWindow(); - ScopedVclPtrInstance<InfoBox>(pWindow, SdResId(STR_ACTION_NOTPOSSIBLE) )->Execute(); + 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) @@ -365,7 +369,10 @@ void DrawViewShell::FuPermanent(SfxRequest& rReq) if ( mpDrawView->IsPresObjSelected() ) { ::sd::Window* pWindow = GetActiveWindow(); - ScopedVclPtrInstance<InfoBox>(pWindow, SdResId(STR_ACTION_NOTPOSSIBLE) )->Execute(); + 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) @@ -671,7 +678,10 @@ void DrawViewShell::FuDeleteSelectedObjects() if (mpDrawView->IsPresObjSelected(false, true, false, true)) { ::sd::Window* pWindow = GetActiveWindow(); - ScopedVclPtrInstance<InfoBox>(pWindow, SdResId(STR_ACTION_NOTPOSSIBLE) )->Execute(); + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(pWindow ? pWindow->GetFrameWeld() : nullptr, + VclMessageType::Info, VclButtonsType::Ok, + SdResId(STR_ACTION_NOTPOSSIBLE))); + xInfoBox->run(); bConsumed = true; } @@ -785,7 +795,10 @@ void DrawViewShell::FuSupport(SfxRequest& rReq) if ( mpDrawView->IsPresObjSelected(false, true, false, true) ) { ::sd::Window* pWindow = GetActiveWindow(); - ScopedVclPtrInstance<InfoBox>(pWindow, SdResId(STR_ACTION_NOTPOSSIBLE))->Execute(); + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(pWindow ? pWindow->GetFrameWeld() : nullptr, + VclMessageType::Info, VclButtonsType::Ok, + SdResId(STR_ACTION_NOTPOSSIBLE))); + xInfoBox->run(); } else { @@ -807,7 +820,10 @@ void DrawViewShell::FuSupport(SfxRequest& rReq) if ( mpDrawView->IsPresObjSelected(false, true, false, true) ) { ::sd::Window* pWindow = GetActiveWindow(); - ScopedVclPtrInstance<InfoBox>(pWindow, SdResId(STR_ACTION_NOTPOSSIBLE))->Execute(); + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(pWindow ? pWindow->GetFrameWeld() : nullptr, + VclMessageType::Info, VclButtonsType::Ok, + SdResId(STR_ACTION_NOTPOSSIBLE))); + xInfoBox->run(); } else { diff --git a/sd/source/ui/view/drviewsi.cxx b/sd/source/ui/view/drviewsi.cxx index 0212473ddffb..ebd27be7672b 100644 --- a/sd/source/ui/view/drviewsi.cxx +++ b/sd/source/ui/view/drviewsi.cxx @@ -33,7 +33,7 @@ #include <svx/float3d.hxx> #include <svx/f3dchild.hxx> #include <svx/dialogs.hrc> -#include <vcl/msgbox.hxx> +#include <vcl/weld.hxx> #include <app.hrc> #include <strings.hrc> @@ -162,10 +162,11 @@ void DrawViewShell::AssignFrom3DWindow() } else { - ScopedVclPtrInstance<InfoBox> aInfoBox ( - GetActiveWindow(), - SdResId(STR_ACTION_NOTPOSSIBLE)); - aInfoBox->Execute(); + vcl::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(); } // get focus back diff --git a/sd/source/ui/view/sdview4.cxx b/sd/source/ui/view/sdview4.cxx index 37366b5bf9cb..1fa41a3485dc 100644 --- a/sd/source/ui/view/sdview4.cxx +++ b/sd/source/ui/view/sdview4.cxx @@ -26,7 +26,7 @@ #include <sfx2/docfilt.hxx> #include <sfx2/fcontnr.hxx> #include <sfx2/docfile.hxx> -#include <vcl/msgbox.hxx> +#include <vcl/weld.hxx> #include <svl/urlbmk.hxx> #include <svx/svdpagv.hxx> #include <svx/xfillit.hxx> @@ -377,7 +377,8 @@ IMPL_LINK_NOARG(View, DropInsertFileHdl, Timer *, void) if( !mpViewSh ) return; - SfxErrorContext aEc( ERRCTX_ERROR, mpViewSh->GetActiveWindow(), RID_SO_ERRCTX ); + vcl::Window* pWindow = mpViewSh->GetActiveWindow(); + SfxErrorContext aEc( ERRCTX_ERROR, pWindow ? pWindow->GetFrameWeld() : nullptr, RID_SO_ERRCTX ); ErrCode nError = ERRCODE_NONE; ::std::vector< OUString >::const_iterator aIter( maDropFileVector.begin() ); @@ -570,7 +571,11 @@ IMPL_LINK_NOARG(View, DropInsertFileHdl, Timer *, void) */ IMPL_LINK_NOARG(View, DropErrorHdl, Timer *, void) { - ScopedVclPtrInstance<InfoBox>( mpViewSh ? mpViewSh->GetActiveWindow() : nullptr, SdResId(STR_ACTION_NOTPOSSIBLE) )->Execute(); + vcl::Window* pWin = mpViewSh ? mpViewSh->GetActiveWindow() : nullptr; + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(pWin ? pWin->GetFrameWeld() : nullptr, + VclMessageType::Info, VclButtonsType::Ok, + SdResId(STR_ACTION_NOTPOSSIBLE))); + xInfoBox->run(); } /** diff --git a/sd/source/ui/view/viewshe2.cxx b/sd/source/ui/view/viewshe2.cxx index 2f31191df6f1..861bb2d1db82 100644 --- a/sd/source/ui/view/viewshe2.cxx +++ b/sd/source/ui/view/viewshe2.cxx @@ -718,7 +718,8 @@ bool ViewShell::ActivateObject(SdrOle2Obj* pObj, long nVerb) { ErrCode aErrCode = ERRCODE_NONE; - SfxErrorContext aEC(ERRCTX_SO_DOVERB, GetActiveWindow(), RID_SO_ERRCTX); + vcl::Window* pWindow = GetActiveWindow(); + SfxErrorContext aEC(ERRCTX_SO_DOVERB, pWindow ? pWindow->GetFrameWeld() : nullptr, RID_SO_ERRCTX); bool bAbort = false; GetDocSh()->SetWaitCursor( true ); SfxViewShell* pViewShell = GetViewShell(); diff --git a/sfx2/source/bastyp/fltfnc.cxx b/sfx2/source/bastyp/fltfnc.cxx index ba7cc8ac9330..d28c4ca27dad 100644 --- a/sfx2/source/bastyp/fltfnc.cxx +++ b/sfx2/source/bastyp/fltfnc.cxx @@ -37,6 +37,7 @@ #include <basic/sbxmeth.hxx> #include <basic/sbxcore.hxx> #include <vcl/msgbox.hxx> +#include <vcl/weld.hxx> #include <rtl/ustring.hxx> #include <rtl/ustrbuf.hxx> #include <svl/eitem.hxx> @@ -490,7 +491,10 @@ bool SfxFilterMatcher::IsFilterInstalled_Impl( const std::shared_ptr<const SfxFi { #ifdef DBG_UTIL // Start Setup - ScopedVclPtrInstance<InfoBox>( nullptr, "Here should the Setup now be starting!" )->Execute(); + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(nullptr, + VclMessageType::Info, VclButtonsType::Ok, + "Here should the Setup now be starting!")); + xInfoBox->run(); #endif // Installation must still give feedback if it worked or not, // then the Filterflag be deleted @@ -502,7 +506,10 @@ bool SfxFilterMatcher::IsFilterInstalled_Impl( const std::shared_ptr<const SfxFi { OUString aText( SfxResId(STR_FILTER_CONSULT_SERVICE) ); aText = aText.replaceFirst( "$(FILTER)", pFilter->GetUIName() ); - ScopedVclPtrInstance<InfoBox>( nullptr, aText )->Execute(); + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(nullptr, + VclMessageType::Info, VclButtonsType::Ok, + aText)); + xInfoBox->run(); return false; } else diff --git a/sfx2/source/dialog/securitypage.cxx b/sfx2/source/dialog/securitypage.cxx index cfc79b606335..eb45d935591d 100644 --- a/sfx2/source/dialog/securitypage.cxx +++ b/sfx2/source/dialog/securitypage.cxx @@ -32,6 +32,7 @@ #include <vcl/edit.hxx> #include <vcl/fixed.hxx> #include <vcl/msgbox.hxx> +#include <vcl/weld.hxx> #include <svl/eitem.hxx> #include <svl/poolitem.hxx> #include <svl/intitem.hxx> @@ -123,7 +124,12 @@ static bool lcl_IsPasswordCorrect( const OUString &rPassword ) if (SvPasswordHelper::CompareHashPassword( aPasswordHash, rPassword )) bRes = true; // password was correct else - ScopedVclPtrInstance<InfoBox>(nullptr, SfxResId(RID_SVXSTR_INCORRECT_PASSWORD))->Execute(); + { + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(nullptr, + VclMessageType::Info, VclButtonsType::Ok, + SfxResId(RID_SVXSTR_INCORRECT_PASSWORD))); + xInfoBox->run(); + } return bRes; } diff --git a/sfx2/source/doc/new.cxx b/sfx2/source/doc/new.cxx index 122b06eac288..cd78f4b524ca 100644 --- a/sfx2/source/doc/new.cxx +++ b/sfx2/source/doc/new.cxx @@ -214,7 +214,7 @@ IMPL_LINK_NOARG(SfxNewFileDialog_Impl, Update, Timer*, void) if (!xDocShell.Is()) { - SfxErrorContext eEC(ERRCTX_SFX_LOADTEMPLATE,pAntiImpl); + SfxErrorContext eEC(ERRCTX_SFX_LOADTEMPLATE, pAntiImpl->GetFrameWeld()); SfxApplication *pSfxApp = SfxGetpApp(); SfxItemSet* pSet = new SfxAllItemSet(pSfxApp->GetPool()); pSet->Put(SfxBoolItem(SID_TEMPLATE, true)); diff --git a/sfx2/source/view/ipclient.cxx b/sfx2/source/view/ipclient.cxx index 86aa5fa35625..81d93b38f55b 100644 --- a/sfx2/source/view/ipclient.cxx +++ b/sfx2/source/view/ipclient.cxx @@ -856,7 +856,8 @@ sal_Int64 SfxInPlaceClient::GetAspect() const ErrCode SfxInPlaceClient::DoVerb( long nVerb ) { - SfxErrorContext aEc(ERRCTX_SO_DOVERB, m_pViewSh->GetWindow(), RID_SO_ERRCTX); + vcl::Window* pWin = m_pViewSh->GetWindow(); + SfxErrorContext aEc(ERRCTX_SO_DOVERB, pWin ? pWin->GetFrameWeld() : nullptr, RID_SO_ERRCTX); ErrCode nError = ERRCODE_NONE; if ( m_xImp->m_xObject.is() ) diff --git a/svtools/source/graphic/provider.cxx b/svtools/source/graphic/provider.cxx index f0dddfc5610c..3cbbd6ba752b 100644 --- a/svtools/source/graphic/provider.cxx +++ b/svtools/source/graphic/provider.cxx @@ -198,7 +198,7 @@ uno::Reference< ::graphic::XGraphic > GraphicProvider::implLoadStandardImage( co OUString sImageName( rResourceURL.copy( nIndex ) ); if ( sImageName == "info" ) { - xRet = Graphic(InfoBox::GetStandardImage().GetBitmapEx()).GetXGraphic(); + xRet = Graphic(GetStandardInfoBoxImage().GetBitmapEx()).GetXGraphic(); } else if ( sImageName == "warning" ) { diff --git a/svtools/source/misc/ehdl.cxx b/svtools/source/misc/ehdl.cxx index dfd28ac168d6..3ab4c7cedb9c 100644 --- a/svtools/source/misc/ehdl.cxx +++ b/svtools/source/misc/ehdl.cxx @@ -18,9 +18,9 @@ */ #include <unotools/resmgr.hxx> -#include <tools/wintypes.hxx> -#include <vcl/msgbox.hxx> +#include <vcl/button.hxx> #include <vcl/svapp.hxx> +#include <vcl/weld.hxx> #include <vcl/settings.hxx> #include <svtools/ehdl.hxx> @@ -33,7 +33,7 @@ #include <strings.hxx> static DialogMask aWndFunc( - vcl::Window *pWin, // Parent of the dialog + weld::Window *pWin, // Parent of the dialog DialogMask nFlags, const OUString &rErr, // error text const OUString &rAction) // action text @@ -52,33 +52,17 @@ static DialogMask aWndFunc( SolarMutexGuard aGuard; // determine necessary WinBits from the flags - MessBoxStyle eBits = MessBoxStyle::NONE; + VclButtonsType eButtonsType = VclButtonsType::NONE; + bool bAddRetry = false; if ( (nFlags & (DialogMask::ButtonsCancel | DialogMask::ButtonsRetry)) == (DialogMask::ButtonsCancel | DialogMask::ButtonsRetry)) - eBits = MessBoxStyle::RetryCancel; - else if ( (nFlags & DialogMask::ButtonsOk) == DialogMask::ButtonsOk ) - eBits = MessBoxStyle::Ok; - else if ( (nFlags & DialogMask::ButtonsYesNo) == DialogMask::ButtonsYesNo ) - eBits = MessBoxStyle::YesNo; - - switch(nFlags & DialogMask(0x0f00)) { - case DialogMask::ButtonDefaultsOk: - eBits |= MessBoxStyle::DefaultOk; - break; - - case DialogMask::ButtonDefaultsCancel: - eBits |= MessBoxStyle::DefaultCancel; - break; - - case DialogMask::ButtonDefaultsYes: - eBits |= MessBoxStyle::DefaultYes; - break; - - case DialogMask::ButtonDefaultsNo: - eBits |= MessBoxStyle::DefaultNo; - break; - default: break; + bAddRetry = true; + eButtonsType = VclButtonsType::Cancel; } + else if ( (nFlags & DialogMask::ButtonsOk) == DialogMask::ButtonsOk ) + eButtonsType = VclButtonsType::Ok; + else if ( (nFlags & DialogMask::ButtonsYesNo) == DialogMask::ButtonsYesNo ) + eButtonsType = VclButtonsType::YesNo; OUString aErr("$(ACTION)$(ERROR)"); OUString aAction(rAction); @@ -87,19 +71,19 @@ static DialogMask aWndFunc( aErr = aErr.replaceAll("$(ACTION)", aAction); aErr = aErr.replaceAll("$(ERROR)", rErr); - VclPtr<MessBox> pBox; - switch ( nFlags & DialogMask(0xf000) ) + VclMessageType eMessageType; + switch (nFlags & DialogMask(0xf000)) { case DialogMask::MessageError: - pBox.reset(VclPtr<ErrorBox>::Create(pWin, eBits, aErr)); + eMessageType = VclMessageType::Error; break; case DialogMask::MessageWarning: - pBox.reset(VclPtr<WarningBox>::Create(pWin, eBits, aErr)); + eMessageType = VclMessageType::Warning; break; case DialogMask::MessageInfo: - pBox.reset(VclPtr<InfoBox>::Create(pWin, aErr)); + eMessageType = VclMessageType::Info; break; default: @@ -109,8 +93,32 @@ static DialogMask aWndFunc( } } + std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(pWin, + eMessageType, eButtonsType, aErr)); + + if (bAddRetry) + xBox->add_button(Button::GetStandardText(StandardButtonType::Retry), RET_RETRY); + + switch(nFlags & DialogMask(0x0f00)) + { + case DialogMask::ButtonDefaultsOk: + xBox->set_default_response(RET_OK); + break; + case DialogMask::ButtonDefaultsCancel: + xBox->set_default_response(RET_CANCEL); + break; + case DialogMask::ButtonDefaultsYes: + xBox->set_default_response(RET_YES); + break; + case DialogMask::ButtonDefaultsNo: + xBox->set_default_response(RET_NO); + break; + default: + break; + } + DialogMask nRet = DialogMask::NONE; - switch ( pBox->Execute() ) + switch (xBox->run()) { case RET_OK: nRet = DialogMask::ButtonsOk; @@ -131,7 +139,7 @@ static DialogMask aWndFunc( SAL_WARN( "svtools.misc", "Unknown MessBox return value" ); break; } - pBox.disposeAndClear(); + return nRet; } @@ -234,7 +242,7 @@ bool SfxErrorHandler::GetErrorString(ErrCode lErrId, OUString &rStr) const } SfxErrorContext::SfxErrorContext( - sal_uInt16 nCtxIdP, vcl::Window *pWindow, const ErrMsgCode* pIdsP, const std::locale& rResLocaleP) + sal_uInt16 nCtxIdP, weld::Window *pWindow, const ErrMsgCode* pIdsP, const std::locale& rResLocaleP) : ErrorContext(pWindow), nCtxId(nCtxIdP), pIds(pIdsP), aResLocale(rResLocaleP) { if (!pIds) @@ -243,7 +251,7 @@ SfxErrorContext::SfxErrorContext( SfxErrorContext::SfxErrorContext( - sal_uInt16 nCtxIdP, const OUString &aArg1P, vcl::Window *pWindow, + sal_uInt16 nCtxIdP, const OUString &aArg1P, weld::Window *pWindow, const ErrMsgCode* pIdsP, const std::locale& rResLocaleP) : ErrorContext(pWindow), nCtxId(nCtxIdP), pIds(pIdsP), aResLocale(rResLocaleP), aArg1(aArg1P) diff --git a/svx/source/dialog/imapdlg.cxx b/svx/source/dialog/imapdlg.cxx index e910cd964b40..1e200a128d18 100644 --- a/svx/source/dialog/imapdlg.cxx +++ b/svx/source/dialog/imapdlg.cxx @@ -476,7 +476,7 @@ void SvxIMapDlg::DoOpen() if( pIStm->GetError() ) { - SfxErrorContext eEC(ERRCTX_ERROR, this); + SfxErrorContext eEC(ERRCTX_ERROR, GetFrameWeld()); ErrorHandler::HandleError( ERRCODE_IO_GENERAL ); } else diff --git a/svx/source/svdraw/svdedtv1.cxx b/svx/source/svdraw/svdedtv1.cxx index beb7abfeabda..b3bc7bcea969 100644 --- a/svx/source/svdraw/svdedtv1.cxx +++ b/svx/source/svdraw/svdedtv1.cxx @@ -26,7 +26,8 @@ #include <svl/itemiter.hxx> #include <svl/whiter.hxx> #include <tools/bigint.hxx> -#include <vcl/msgbox.hxx> +#include <vcl/svapp.hxx> +#include <vcl/weld.hxx> #include <getallcharpropids.hxx> #include <svdglob.hxx> @@ -964,7 +965,10 @@ void SdrEditView::SetAttrToMarked(const SfxItemSet& rAttr, bool bReplaceAll) if(bHasEEFeatureItems) { OUString aMessage("SdrEditView::SetAttrToMarked(): Setting EE_FEATURE items at the SdrView does not make sense! It only leads to overhead and unreadable documents."); - ScopedVclPtrInstance<InfoBox>(nullptr, aMessage)->Execute(); + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(nullptr, + VclMessageType::Info, VclButtonsType::Ok, + aMessage)); + xInfoBox->run(); } } #endif diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx index 0539648713d6..f01dd86a3d2c 100644 --- a/svx/source/svdraw/svdedxv.cxx +++ b/svx/source/svdraw/svdedxv.cxx @@ -22,7 +22,7 @@ #include <svx/svdedxv.hxx> #include <svl/solar.hrc> #include <svl/itemiter.hxx> -#include <vcl/msgbox.hxx> +#include <vcl/weld.hxx> #include <vcl/hatch.hxx> #include <svl/whiter.hxx> #include <svl/style.hxx> @@ -2076,7 +2076,10 @@ bool SdrObjEditView::SetAttributes(const SfxItemSet& rSet, bool bReplaceAll) if(bHasEEFeatureItems) { OUString aMessage("SdrObjEditView::SetAttributes(): Setting EE_FEATURE items at the SdrView does not make sense! It only leads to overhead and unreadable documents."); - ScopedVclPtrInstance<InfoBox>(nullptr, aMessage)->Execute(); + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(nullptr, + VclMessageType::Info, VclButtonsType::Ok, + aMessage)); + xInfoBox->run(); } } #endif diff --git a/svx/source/svdraw/svdpntv.cxx b/svx/source/svdraw/svdpntv.cxx index fd3d6ecffc57..d5f9ab4aa988 100644 --- a/svx/source/svdraw/svdpntv.cxx +++ b/svx/source/svdraw/svdpntv.cxx @@ -20,7 +20,7 @@ #include <memory> #include <com/sun/star/awt/XWindow.hpp> #include <svx/svdpntv.hxx> -#include <vcl/msgbox.hxx> +#include <vcl/weld.hxx> #include <svx/sdrpaintwindow.hxx> #include <svtools/grfmgr.hxx> #include <svx/svdmodel.hxx> @@ -1028,7 +1028,10 @@ void SdrPaintView::SetDefaultAttr(const SfxItemSet& rAttr, bool bReplaceAll) if(bHasEEFeatureItems) { OUString aMessage("SdrPaintView::SetDefaultAttr(): Setting EE_FEATURE items at the SdrView does not make sense! It only leads to overhead and unreadable documents."); - ScopedVclPtrInstance<InfoBox>(nullptr, aMessage)->Execute(); + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(nullptr, + VclMessageType::Info, VclButtonsType::Ok, + aMessage)); + xInfoBox->run(); } } #endif diff --git a/sw/source/core/frmedt/fetab.cxx b/sw/source/core/frmedt/fetab.cxx index 4334c08a76f2..bf312fe6a642 100644 --- a/sw/source/core/frmedt/fetab.cxx +++ b/sw/source/core/frmedt/fetab.cxx @@ -176,7 +176,8 @@ void SwFEShell::InsertRow( sal_uInt16 nCnt, bool bBehind ) if( dynamic_cast< const SwDDETable* >(pFrame->ImplFindTabFrame()->GetTable()) != nullptr ) { - ErrorHandler::HandleError( ERR_TBLDDECHG_ERROR, GetWin(), + vcl::Window* pWin = GetWin(); + ErrorHandler::HandleError( ERR_TBLDDECHG_ERROR, pWin ? pWin->GetFrameWeld() : nullptr, DialogMask::MessageInfo | DialogMask::ButtonDefaultsOk ); return; } @@ -215,7 +216,8 @@ void SwFEShell::InsertCol( sal_uInt16 nCnt, bool bBehind ) if( dynamic_cast< const SwDDETable* >(pFrame->ImplFindTabFrame()->GetTable()) != nullptr ) { - ErrorHandler::HandleError( ERR_TBLDDECHG_ERROR, GetWin(), + vcl::Window* pWin = GetWin(); + ErrorHandler::HandleError( ERR_TBLDDECHG_ERROR, pWin ? pWin->GetFrameWeld() : nullptr, DialogMask::MessageInfo | DialogMask::ButtonDefaultsOk ); return; } @@ -224,7 +226,8 @@ void SwFEShell::InsertCol( sal_uInt16 nCnt, bool bBehind ) if( !CheckSplitCells( *this, nCnt + 1, SwTableSearchType::Col ) ) { - ErrorHandler::HandleError( ERR_TBLINSCOL_ERROR, GetWin(), + vcl::Window* pWin = GetWin(); + ErrorHandler::HandleError( ERR_TBLINSCOL_ERROR, pWin ? pWin->GetFrameWeld() : nullptr, DialogMask::MessageInfo | DialogMask::ButtonDefaultsOk ); return; } @@ -268,7 +271,8 @@ bool SwFEShell::DeleteCol() if( dynamic_cast< const SwDDETable* >(pFrame->ImplFindTabFrame()->GetTable()) != nullptr ) { - ErrorHandler::HandleError( ERR_TBLDDECHG_ERROR, GetWin(), + vcl::Window* pWin = GetWin(); + ErrorHandler::HandleError( ERR_TBLDDECHG_ERROR, pWin ? pWin->GetFrameWeld() : nullptr, DialogMask::MessageInfo | DialogMask::ButtonDefaultsOk ); return false; } @@ -319,7 +323,8 @@ bool SwFEShell::DeleteRow(bool bCompleteTable) if( dynamic_cast< const SwDDETable* >(pFrame->ImplFindTabFrame()->GetTable()) != nullptr ) { - ErrorHandler::HandleError( ERR_TBLDDECHG_ERROR, GetWin(), + vcl::Window* pWin = GetWin(); + ErrorHandler::HandleError( ERR_TBLDDECHG_ERROR, pWin ? pWin->GetFrameWeld() : nullptr, DialogMask::MessageInfo | DialogMask::ButtonDefaultsOk ); return false; } @@ -438,7 +443,8 @@ TableMergeErr SwFEShell::MergeTab() const SwTableNode* pTableNd = pTableCursor->GetNode().FindTableNode(); if( dynamic_cast< const SwDDETable* >(&pTableNd->GetTable()) != nullptr ) { - ErrorHandler::HandleError( ERR_TBLDDECHG_ERROR, GetWin(), + vcl::Window* pWin = GetWin(); + ErrorHandler::HandleError( ERR_TBLDDECHG_ERROR, pWin ? pWin->GetFrameWeld() : nullptr, DialogMask::MessageInfo | DialogMask::ButtonDefaultsOk ); } else @@ -469,7 +475,8 @@ void SwFEShell::SplitTab( bool bVert, sal_uInt16 nCnt, bool bSameHeight ) if( dynamic_cast< const SwDDETable* >(pFrame->ImplFindTabFrame()->GetTable()) != nullptr ) { - ErrorHandler::HandleError( ERR_TBLDDECHG_ERROR, GetWin(), + vcl::Window* pWin = GetWin(); + ErrorHandler::HandleError( ERR_TBLDDECHG_ERROR, pWin ? pWin->GetFrameWeld() : nullptr, DialogMask::MessageInfo | DialogMask::ButtonDefaultsOk ); return; } @@ -478,7 +485,8 @@ void SwFEShell::SplitTab( bool bVert, sal_uInt16 nCnt, bool bSameHeight ) if( bVert && !CheckSplitCells( *this, nCnt + 1, SwTableSearchType::NONE ) ) { - ErrorHandler::HandleError( ERR_TBLSPLIT_ERROR, GetWin(), + vcl::Window* pWin = GetWin(); + ErrorHandler::HandleError( ERR_TBLSPLIT_ERROR, pWin ? pWin->GetFrameWeld() : nullptr, DialogMask::MessageInfo | DialogMask::ButtonDefaultsOk ); return; } @@ -1271,7 +1279,8 @@ bool SwFEShell::DeleteTableSel() if( dynamic_cast< const SwDDETable* >(pFrame->ImplFindTabFrame()->GetTable()) != nullptr ) { - ErrorHandler::HandleError( ERR_TBLDDECHG_ERROR, GetWin(), + vcl::Window* pWin = GetWin(); + ErrorHandler::HandleError( ERR_TBLDDECHG_ERROR, pWin ? pWin->GetFrameWeld() : nullptr, DialogMask::MessageInfo | DialogMask::ButtonDefaultsOk ); return false; } @@ -2163,7 +2172,8 @@ void SwFEShell::SetColRowWidthHeight( TableChgWidthHeightType eType, sal_uInt16 if( (TableChgWidthHeightType::InsertDeleteMode & eType) && dynamic_cast< const SwDDETable* >(pFrame->ImplFindTabFrame()->GetTable()) != nullptr ) { - ErrorHandler::HandleError( ERR_TBLDDECHG_ERROR, GetWin(), + vcl::Window* pWin = GetWin(); + ErrorHandler::HandleError( ERR_TBLDDECHG_ERROR, pWin ? pWin->GetFrameWeld() : nullptr, DialogMask::MessageInfo | DialogMask::ButtonDefaultsOk ); return; } diff --git a/sw/source/ui/index/cnttab.cxx b/sw/source/ui/index/cnttab.cxx index 27278667bf80..e9a040450012 100644 --- a/sw/source/ui/index/cnttab.cxx +++ b/sw/source/ui/index/cnttab.cxx @@ -20,10 +20,10 @@ #include <config_folders.h> #include <comphelper/string.hxx> +#include <vcl/builderfactory.hxx> #include <svl/style.hxx> -#include <vcl/msgbox.hxx> #include <vcl/help.hxx> -#include <vcl/builderfactory.hxx> +#include <vcl/weld.hxx> #include <svl/stritem.hxx> #include <svl/urihelper.hxx> #include <unotools/pathoptions.hxx> @@ -487,8 +487,11 @@ IMPL_LINK_NOARG( SwMultiTOXTabDialog, ShowPreviewHdl, Button*, void ) OUString sInfo(SwResId(STR_FILE_NOT_FOUND)); sInfo = sInfo.replaceFirst( "%1", sTemplate ); sInfo = sInfo.replaceFirst( "%2", aOpt.GetTemplatePath() ); - ScopedVclPtrInstance< InfoBox > aInfo(GetParent(), sInfo); - aInfo->Execute(); + vcl::Window* pWin = GetParent(); + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(pWin ? pWin->GetFrameWeld() : nullptr, + VclMessageType::Info, VclButtonsType::Ok, + sInfo)); + xInfoBox->run(); } else { diff --git a/sw/source/ui/misc/bookmark.cxx b/sw/source/ui/misc/bookmark.cxx index 3e262e984b46..3720dba23a86 100644 --- a/sw/source/ui/misc/bookmark.cxx +++ b/sw/source/ui/misc/bookmark.cxx @@ -20,7 +20,7 @@ #include <comphelper/string.hxx> #include <sfx2/request.hxx> #include <svl/stritem.hxx> -#include <vcl/msgbox.hxx> +#include <vcl/weld.hxx> #include <vcl/builderfactory.hxx> #include <svtools/headbar.hxx> #include <svtools/treelistentry.hxx> @@ -63,7 +63,10 @@ IMPL_LINK_NOARG(SwInsertBookmarkDlg, ModifyHdl, Edit&, void) if (sTmp.getLength() != nLen) { m_pEditBox->SetText(sTmp); - ScopedVclPtrInstance<InfoBox>(this, sRemoveWarning + sMsg)->Execute(); + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(), + VclMessageType::Info, VclButtonsType::Ok, + sRemoveWarning + sMsg)); + xInfoBox->run(); } sal_Int32 nSelectedEntries = 0; diff --git a/sw/source/uibase/app/docsh.cxx b/sw/source/uibase/app/docsh.cxx index 1cc101938fa9..9291e0a2f763 100644 --- a/sw/source/uibase/app/docsh.cxx +++ b/sw/source/uibase/app/docsh.cxx @@ -21,7 +21,7 @@ #include <hintids.hxx> #include <vcl/layout.hxx> -#include <vcl/msgbox.hxx> +#include <vcl/weld.hxx> #include <vcl/svapp.hxx> #include <vcl/wrkwin.hxx> #include <vcl/jobset.hxx> @@ -177,7 +177,10 @@ Reader* SwDocShell::StartConvertFrom(SfxMedium& rMedium, SwReader** ppRdr, { if(!bAPICall) { - ScopedVclPtrInstance<InfoBox>(nullptr, SwResId(STR_CANTOPEN))->Execute(); + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(nullptr, + VclMessageType::Info, VclButtonsType::Ok, + SwResId(STR_CANTOPEN))); + xInfoBox->run(); } return nullptr; } @@ -550,7 +553,10 @@ bool SwDocShell::ConvertTo( SfxMedium& rMedium ) SwReaderWriter::GetWriter( pFlt->GetUserData(), rMedium.GetBaseURL( true ), xWriter ); if( !xWriter.is() ) { // Filter not available - ScopedVclPtrInstance<InfoBox>(nullptr, SwResId(STR_DLLNOTFOUND))->Execute(); + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(nullptr, + VclMessageType::Info, VclButtonsType::Ok, + SwResId(STR_DLLNOTFOUND))); + xInfoBox->run(); return false; } diff --git a/sw/source/uibase/app/docsh2.cxx b/sw/source/uibase/app/docsh2.cxx index c52304ff341a..a78e295d0604 100644 --- a/sw/source/uibase/app/docsh2.cxx +++ b/sw/source/uibase/app/docsh2.cxx @@ -1099,7 +1099,10 @@ void SwDocShell::Execute(SfxRequest& rReq) } if( !bDone && !rReq.IsAPI() ) { - ScopedVclPtrInstance<InfoBox>(nullptr, SwResId( STR_CANTCREATE))->Execute(); + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(nullptr, + VclMessageType::Info, VclButtonsType::Ok, + SwResId(STR_CANTCREATE))); + xInfoBox->run(); } } } diff --git a/sw/source/uibase/dochdl/gloshdl.cxx b/sw/source/uibase/dochdl/gloshdl.cxx index e583f189d5dc..f964d1b546cc 100644 --- a/sw/source/uibase/dochdl/gloshdl.cxx +++ b/sw/source/uibase/dochdl/gloshdl.cxx @@ -21,7 +21,7 @@ #include <editeng/wghtitem.hxx> #include <editeng/adjustitem.hxx> #include <vcl/errinf.hxx> -#include <vcl/msgbox.hxx> +#include <vcl/weld.hxx> #include <svl/macitem.hxx> #include <sfx2/fcontnr.hxx> #include <sfx2/docfile.hxx> @@ -478,7 +478,11 @@ bool SwGlossaryHdl::Expand( const OUString& rShortName, } OUString aTmp( SwResId(STR_NOGLOS)); aTmp = aTmp.replaceFirst("%1", aShortName); - ScopedVclPtrInstance<InfoBox>(pWrtShell->GetView().GetWindow(), aTmp)->Execute(); + vcl::Window* pWin = pWrtShell->GetView().GetWindow(); + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(pWin ? pWin->GetFrameWeld() : nullptr, + VclMessageType::Info, VclButtonsType::Ok, + aTmp)); + xInfoBox->run(); } return false; diff --git a/sw/source/uibase/lingu/hyp.cxx b/sw/source/uibase/lingu/hyp.cxx index 56bd99b8471d..4c8ec00ad591 100644 --- a/sw/source/uibase/lingu/hyp.cxx +++ b/sw/source/uibase/lingu/hyp.cxx @@ -22,7 +22,7 @@ #include <edtwin.hxx> #include <wrtsh.hxx> #include <globals.hrc> -#include <vcl/msgbox.hxx> +#include <vcl/weld.hxx> #include <vcl/wrkwin.hxx> #include <linguistic/lngprops.hxx> #include <com/sun/star/linguistic2/XLinguProperties.hpp> @@ -120,7 +120,12 @@ SwHyphWrapper::~SwHyphWrapper() if( nPageCount ) ::EndProgress( pView->GetDocShell() ); if( bInfoBox && !Application::IsHeadlessModeEnabled() ) - ScopedVclPtrInstance<InfoBox>(&pView->GetEditWin(), SwResId(STR_HYP_OK))->Execute(); + { + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(pView->GetEditWin().GetFrameWeld(), + VclMessageType::Info, VclButtonsType::Ok, + SwResId(STR_HYP_OK))); + xInfoBox->run(); + } } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/lingu/olmenu.cxx b/sw/source/uibase/lingu/olmenu.cxx index a411f3b25c97..a4ede37f35a4 100644 --- a/sw/source/uibase/lingu/olmenu.cxx +++ b/sw/source/uibase/lingu/olmenu.cxx @@ -746,7 +746,7 @@ void SwSpellPopup::Execute( sal_uInt16 nId ) sWord, false, OUString() ); if (linguistic::DictionaryError::NONE != nAddRes && !xDictionary->getEntry(sWord).is()) { - SvxDicError(&m_pSh->GetView().GetViewFrame()->GetWindow(), nAddRes); + SvxDicError(m_pSh->GetView().GetViewFrame()->GetWindow().GetFrameWeld(), nAddRes); } } } @@ -778,7 +778,7 @@ void SwSpellPopup::Execute( sal_uInt16 nId ) if (linguistic::DictionaryError::NONE != nAddRes && !xDic->getEntry(sWord).is()) { - SvxDicError(&m_pSh->GetView().GetViewFrame()->GetWindow(), nAddRes); + SvxDicError(m_pSh->GetView().GetViewFrame()->GetWindow().GetFrameWeld(), nAddRes); } } } diff --git a/sw/source/uibase/uiview/viewling.cxx b/sw/source/uibase/uiview/viewling.cxx index 895bf7e2ddab..4f2191f4027e 100644 --- a/sw/source/uibase/uiview/viewling.cxx +++ b/sw/source/uibase/uiview/viewling.cxx @@ -411,7 +411,7 @@ void SwView::HyphenateDocument() return; } - SfxErrorContext aContext( ERRCTX_SVX_LINGU_HYPHENATION, OUString(), m_pEditWin, + SfxErrorContext aContext( ERRCTX_SVX_LINGU_HYPHENATION, OUString(), m_pEditWin->GetFrameWeld(), RID_SVXERRCTX, SvxResLocale() ); Reference< XHyphenator > xHyph( ::GetHyphenator() ); @@ -535,7 +535,7 @@ void SwView::StartThesaurus() if (!IsValidSelectionForThesaurus()) return; - SfxErrorContext aContext( ERRCTX_SVX_LINGU_THESAURUS, OUString(), m_pEditWin, + SfxErrorContext aContext( ERRCTX_SVX_LINGU_THESAURUS, OUString(), m_pEditWin->GetFrameWeld(), RID_SVXERRCTX, SvxResLocale() ); // Determine language diff --git a/sw/source/uibase/utlui/unotools.cxx b/sw/source/uibase/utlui/unotools.cxx index 849511797d45..0aac42591a7d 100644 --- a/sw/source/uibase/utlui/unotools.cxx +++ b/sw/source/uibase/utlui/unotools.cxx @@ -24,7 +24,7 @@ #include <unotools.hxx> #include <unoprnms.hxx> #include <i18nutil/unicode.hxx> -#include <vcl/msgbox.hxx> +#include <vcl/weld.hxx> #include <vcl/svapp.hxx> #include <vcl/settings.hxx> #include <com/sun/star/text/XTextViewCursorSupplier.hpp> @@ -93,7 +93,10 @@ void SwOneExampleFrame::CreateErrorMessage() { OUString sInfo(SwResId(STR_SERVICE_UNAVAILABLE)); sInfo += "com.sun.star.frame.FrameControl"; - ScopedVclPtrInstance<InfoBox>(nullptr, sInfo)->Execute(); + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(nullptr, + VclMessageType::Info, VclButtonsType::Ok, + sInfo)); + xInfoBox->run(); SwOneExampleFrame::bShowServiceNotAvailableMessage = false; } } diff --git a/toolkit/source/awt/vclxtoolkit.cxx b/toolkit/source/awt/vclxtoolkit.cxx index 90d7ce2ce2ec..3576fb640c69 100644 --- a/toolkit/source/awt/vclxtoolkit.cxx +++ b/toolkit/source/awt/vclxtoolkit.cxx @@ -788,6 +788,19 @@ css::uno::Reference< css::awt::XRegion > VCLXToolkit::createRegion( ) return xRef; } +class InfoBox : public MessBox +{ +public: + InfoBox(vcl::Window* pParent, const OUString& rMessage) + : MessBox(pParent, MessBoxStyle::Ok | MessBoxStyle::DefaultOk, 0, OUString(), rMessage) + { + // Default Text is the display title from the application + if (GetText().isEmpty()) + SetText(GetStandardInfoBoxText()); + SetImage(GetStandardInfoBoxImage()); + } +}; + vcl::Window* VCLXToolkit::ImplCreateWindow( VCLXWindow** ppNewComp, const css::awt::WindowDescriptor& rDescriptor, vcl::Window* pParent, WinBits nWinBits, MessBoxStyle nMessBoxStyle ) diff --git a/uui/source/iahndl-errorhandler.cxx b/uui/source/iahndl-errorhandler.cxx index dca09cf4bb7f..28d1bf062636 100644 --- a/uui/source/iahndl-errorhandler.cxx +++ b/uui/source/iahndl-errorhandler.cxx @@ -19,6 +19,7 @@ #include <vcl/svapp.hxx> #include <vcl/msgbox.hxx> +#include <vcl/weld.hxx> #include <com/sun/star/task/XInteractionAbort.hpp> #include <com/sun/star/task/XInteractionApprove.hpp> @@ -59,6 +60,7 @@ executeErrorDialog( aText.append(rMessage); VclPtr< MessBox > xBox; + std::unique_ptr<weld::MessageDialog> xOtherBox; try { switch (eClassification) @@ -79,8 +81,10 @@ executeErrorDialog( # define WB_DEF_BUTTONS (MessBoxStyle::DefaultOk | MessBoxStyle::DefaultCancel | MessBoxStyle::DefaultRetry) //(want to ignore any default button settings)... if ((nButtonMask & WB_DEF_BUTTONS) == MessBoxStyle::DefaultOk) - xBox.reset(VclPtr<InfoBox>::Create(pParent, - aText.makeStringAndClear())); + { + xOtherBox.reset(Application::CreateMessageDialog(pParent ? pParent->GetFrameWeld() : nullptr, + VclMessageType::Info, VclButtonsType::Ok, aText.makeStringAndClear())); + } else xBox.reset(VclPtr<ErrorBox>::Create(pParent, nButtonMask, @@ -103,9 +107,16 @@ executeErrorDialog( throw uno::RuntimeException("out of memory"); } - sal_uInt16 aMessResult = xBox->Execute(); - - xBox.disposeAndClear(); + sal_uInt16 aMessResult; + if (xBox) + { + aMessResult = xBox->Execute(); + xBox.disposeAndClear(); + } + else + { + aMessResult = xOtherBox->run(); + } DialogMask aResult = DialogMask::NONE; switch( aMessResult ) diff --git a/uui/source/iahndl.cxx b/uui/source/iahndl.cxx index 59f62217c6ac..b45b9cea2c2d 100644 --- a/uui/source/iahndl.cxx +++ b/uui/source/iahndl.cxx @@ -1120,7 +1120,10 @@ UUIInteractionHelper::handleGenericErrorRequest( executeMessageBox(getParentProperty(), aTitle, aErrorString, MessBoxStyle::Ok); } else - ErrorHandler::HandleError(nErrorCode, getParentProperty()); + { + vcl::Window* pParent = getParentProperty(); + ErrorHandler::HandleError(nErrorCode, pParent ? pParent->GetFrameWeld() : nullptr); + } if (xApprove.is() && bWarning) xApprove->select(); diff --git a/uui/source/sslwarndlg.cxx b/uui/source/sslwarndlg.cxx index f88284a70610..5db56f855a95 100644 --- a/uui/source/sslwarndlg.cxx +++ b/uui/source/sslwarndlg.cxx @@ -27,7 +27,7 @@ using namespace css; -void SSLWarnDialog::ViewCert() +IMPL_LINK_NOARG(SSLWarnDialog, ViewCertHdl, ::Button*, void) { uno::Reference< css::security::XDocumentDigitalSignatures > xDocumentDigitalSignatures; @@ -36,27 +36,25 @@ void SSLWarnDialog::ViewCert() xDocumentDigitalSignatures.get()->showCertificate(m_rXCert); } - SSLWarnDialog::SSLWarnDialog(vcl::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_xContext(xContext) , m_rXCert(rXCert) { } -void SSLWarnDialog::response(short nResponseId) +void SSLWarnDialog::dispose() +{ + m_xView.clear(); + MessageDialog::dispose(); +} + +SSLWarnDialog::~SSLWarnDialog() { - switch (nResponseId) - { - case 101: - ViewCert(); - break; - default: - MessageDialog::response(nResponseId); - break; - } + disposeOnce(); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/uui/source/sslwarndlg.hxx b/uui/source/sslwarndlg.hxx index 2c0a992dcc2d..2183160ce2ff 100644 --- a/uui/source/sslwarndlg.hxx +++ b/uui/source/sslwarndlg.hxx @@ -19,7 +19,6 @@ #ifndef INCLUDED_UUI_SOURCE_SSLWARNDLG_HXX #define INCLUDED_UUI_SOURCE_SSLWARNDLG_HXX -#include <vcl/fixed.hxx> #include <vcl/button.hxx> #include <vcl/messagedialog.hxx> #include <com/sun/star/security/XCertificate.hpp> @@ -32,19 +31,22 @@ class SSLWarnDialog : public MessageDialog { private: + VclPtr<PushButton> m_xView; const css::uno::Reference< css::uno::XComponentContext >& m_xContext; const css::uno::Reference< css::security::XCertificate >& m_rXCert; - void ViewCert(); + DECL_LINK(ViewCertHdl, Button*, void); public: SSLWarnDialog( vcl::Window* pParent, const css::uno::Reference< css::security::XCertificate >& rXCert, const css::uno::Reference< css::uno::XComponentContext >& xContext ); - virtual void response(short nResponseId) override; - void setDescription1Text(const OUString &aText) { set_primary_text(aText); } + + virtual void dispose() override; + + virtual ~SSLWarnDialog() override; }; #endif // INCLUDED_UUI_SOURCE_SSLWARNDLG_HXX diff --git a/uui/uiconfig/ui/sslwarndialog.ui b/uui/uiconfig/ui/sslwarndialog.ui index 9770d75e74d0..70087a5b4e16 100644 --- a/uui/uiconfig/ui/sslwarndialog.ui +++ b/uui/uiconfig/ui/sslwarndialog.ui @@ -75,7 +75,6 @@ <action-widgets> <action-widget response="-5">ok</action-widget> <action-widget response="-6">cancel</action-widget> - <action-widget response="101">view</action-widget> </action-widgets> </object> </interface> diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index 77a3df7d6ed7..e7fad21b767e 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -392,6 +392,19 @@ public: { m_xDialog->EndDialog(nResponse); } + + virtual void add_button(const OUString& rText, int nResponse) override + { + VclButtonBox* pBox = m_xDialog->get_action_area(); + VclPtr<PushButton> xButton(VclPtr<PushButton>::Create(pBox, WB_CLIPCHILDREN|WB_CENTER|WB_VCENTER)); + xButton->SetText(rText); + m_xDialog->add_button(xButton, nResponse, true); + } + + virtual void set_default_response(int nResponse) override + { + m_xDialog->set_default_response(nResponse); + } }; class SalInstanceMessageDialog : public SalInstanceDialog, public virtual weld::MessageDialog diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx index 1fac71679e85..c3b8e50cc8b2 100644 --- a/vcl/source/window/builder.cxx +++ b/vcl/source/window/builder.cxx @@ -3378,38 +3378,6 @@ PopupMenu *VclBuilder::get_menu(const OString& sID) return nullptr; } -short VclBuilder::get_response(const vcl::Window *pWindow) const -{ - for (auto const& child : m_aChildren) - { - if (child.m_pWindow == pWindow) - { - return child.m_nResponseId; - } - } - - //how did we not find sID ? - assert(false); - return RET_CANCEL; -} - -IMPL_LINK(VclBuilder, ResponseHdl, ::Button*, pButton, void) -{ - short nResponse = get_response(pButton); - Dialog* pDialog = pButton->GetParentDialog(); - assert(pDialog && "who puts a response without a dialog"); - if (nResponse == RET_HELP) - { - vcl::Window* pFocusWin = Application::GetFocusWindow(); - if (!pFocusWin) - pFocusWin = pButton; - HelpEvent aEvt(pFocusWin->GetPointerPosPixel(), HelpEventMode::CONTEXT); - pFocusWin->RequestHelp(aEvt); - } - else - pDialog->EndDialog(nResponse); -} - void VclBuilder::set_response(const OString& sID, short nResponse) { switch (nResponse) @@ -3436,27 +3404,20 @@ void VclBuilder::set_response(const OString& sID, short nResponse) assert(nResponse >= 0); - bool bFound = false; - for (auto & child : m_aChildren) { if (child.m_sID == sID) { - child.m_nResponseId = nResponse; - bFound = true; - break; + PushButton* pPushButton = dynamic_cast<PushButton*>(child.m_pWindow.get()); + assert(pPushButton); + Dialog* pDialog = pPushButton->GetParentDialog(); + assert(pDialog); + pDialog->add_button(pPushButton, nResponse, false); + return; } } - if (!m_bLegacy) - { - PushButton* pPushButton = get<PushButton>(sID); - assert(pPushButton); - pPushButton->SetClickHdl(LINK(this, VclBuilder, ResponseHdl)); - } - - //how did we not find sID ? - assert(bFound); (void)bFound; + assert(false); } void VclBuilder::delete_by_name(const OString& sID) diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx index 2da8e08d7ebc..9665fa880e5e 100644 --- a/vcl/source/window/dialog.cxx +++ b/vcl/source/window/dialog.cxx @@ -343,13 +343,35 @@ static void ImplMouseAutoPos( Dialog* pDialog ) struct DialogImpl { + std::vector<VclPtr<PushButton>> maOwnedButtons; + std::map<VclPtr<vcl::Window>, short> maResponses; long mnResult; bool mbStartedModal; VclAbstractDialog::AsyncContext maEndCtx; DialogImpl() : mnResult( -1 ), mbStartedModal( false ) {} + + short get_response(vcl::Window *pWindow) const + { + auto aFind = maResponses.find(pWindow); + if (aFind != maResponses.end()) + return aFind->second; + return RET_CANCEL; + } + + ~DialogImpl() + { + for (VclPtr<PushButton> & pOwnedButton : maOwnedButtons) + pOwnedButton.disposeAndClear(); + } }; +void Dialog::disposeOwnedButtons() +{ + for (VclPtr<PushButton> & pOwnedButton : mpDialogImpl->maOwnedButtons) + pOwnedButton.disposeAndClear(); +} + void Dialog::ImplInitDialogData() { mpWindowImpl->mbDialog = true; @@ -1283,6 +1305,96 @@ FactoryFunction Dialog::GetUITestFactory() const return DialogUIObject::create; } +IMPL_LINK(Dialog, ResponseHdl, Button*, pButton, void) +{ + auto aFind = mpDialogImpl->maResponses.find(pButton); + if (aFind == mpDialogImpl->maResponses.end()) + return; + short nResponse = aFind->second; + if (nResponse == RET_HELP) + { + vcl::Window* pFocusWin = Application::GetFocusWindow(); + if (!pFocusWin) + pFocusWin = pButton; + HelpEvent aEvt(pFocusWin->GetPointerPosPixel(), HelpEventMode::CONTEXT); + pFocusWin->RequestHelp(aEvt); + return; + } + EndDialog(nResponse); +} + +void Dialog::add_button(PushButton* pButton, int response, bool bTransferOwnership) +{ + if (bTransferOwnership) + mpDialogImpl->maOwnedButtons.push_back(pButton); + mpDialogImpl->maResponses[pButton] = response; + switch (pButton->GetType()) + { + case WindowType::PUSHBUTTON: + { + if (!pButton->GetClickHdl().IsSet()) + pButton->SetClickHdl(LINK(this, Dialog, ResponseHdl)); + break; + } + //insist that the response ids match the default actions for those + //widgets, and leave their default handlers in place + case WindowType::OKBUTTON: + assert(mpDialogImpl->get_response(pButton) == RET_OK); + break; + case WindowType::CANCELBUTTON: + assert(mpDialogImpl->get_response(pButton) == RET_CANCEL || mpDialogImpl->get_response(pButton) == RET_CLOSE); + break; + case WindowType::HELPBUTTON: + assert(mpDialogImpl->get_response(pButton) == RET_HELP); + break; + default: + SAL_WARN("vcl.layout", "The type of widget " << + pButton->GetHelpId() << " is currently not handled"); + break; + } +} + +void Dialog::set_default_response(int response) +{ + //copy explicit responses + std::map<VclPtr<vcl::Window>, short> aResponses(mpDialogImpl->maResponses); + + //add implicit responses + for (vcl::Window* pChild = mpActionArea->GetWindow(GetWindowType::FirstChild); pChild; + pChild = pChild->GetWindow(GetWindowType::Next)) + { + if (aResponses.find(pChild) != aResponses.end()) + continue; + switch (pChild->GetType()) + { + case WindowType::OKBUTTON: + aResponses[pChild] = RET_OK; + break; + case WindowType::CANCELBUTTON: + aResponses[pChild] = RET_CANCEL; + break; + case WindowType::HELPBUTTON: + aResponses[pChild] = RET_HELP; + break; + default: + break; + } + } + + for (auto& a : aResponses) + { + if (a.second == response) + { + a.first->SetStyle(a.first->GetStyle() | WB_DEFBUTTON); + a.first->GrabFocus(); + } + else + { + a.first->SetStyle(a.first->GetStyle() & ~WB_DEFBUTTON); + } + } +} + VclBuilderContainer::VclBuilderContainer() : m_pUIBuilder(nullptr) { diff --git a/vcl/source/window/errinf.cxx b/vcl/source/window/errinf.cxx index 00a99f420b01..f689fbac30b3 100644 --- a/vcl/source/window/errinf.cxx +++ b/vcl/source/window/errinf.cxx @@ -108,7 +108,7 @@ bool ErrorHandler::GetErrorString(ErrCode nErrCodeId, OUString& rErrStr) return false; } -DialogMask ErrorHandler::HandleError(ErrCode nErrCodeId, vcl::Window *pParent, DialogMask nFlags) +DialogMask ErrorHandler::HandleError(ErrCode nErrCodeId, weld::Window *pParent, DialogMask nFlags) { if (nErrCodeId == ERRCODE_NONE || nErrCodeId == ERRCODE_ABORT) return DialogMask::NONE; @@ -186,10 +186,10 @@ DialogMask ErrorHandler::HandleError(ErrCode nErrCodeId, vcl::Window *pParent, D struct ImplErrorContext { - vcl::Window *pWin; // FIXME: should be VclPtr for strong lifecycle + weld::Window *pWin; }; -ErrorContext::ErrorContext(vcl::Window *pWinP) +ErrorContext::ErrorContext(weld::Window *pWinP) : pImpl( new ImplErrorContext ) { pImpl->pWin = pWinP; @@ -207,7 +207,7 @@ ErrorContext *ErrorContext::GetContext() return TheErrorRegistry::get().contexts.empty() ? nullptr : TheErrorRegistry::get().contexts.front(); } -vcl::Window* ErrorContext::GetParent() +weld::Window* ErrorContext::GetParent() { return pImpl ? pImpl->pWin : nullptr; } diff --git a/vcl/source/window/layout.cxx b/vcl/source/window/layout.cxx index 69c492b28e70..79f7bbc7a408 100644 --- a/vcl/source/window/layout.cxx +++ b/vcl/source/window/layout.cxx @@ -2203,17 +2203,13 @@ MessageDialog::MessageDialog(vcl::Window* pParent, const OString& rID, const OUS void MessageDialog::dispose() { - for (VclPtr<PushButton> & pOwnedButton : m_aOwnedButtons) - pOwnedButton.disposeAndClear(); - m_aOwnedButtons.clear(); - + disposeOwnedButtons(); m_pPrimaryMessage.disposeAndClear(); m_pSecondaryMessage.disposeAndClear(); m_pImage.disposeAndClear(); m_pGrid.disposeAndClear(); m_pOwnedActionArea.disposeAndClear(); m_pOwnedContentArea.disposeAndClear(); - m_aResponses.clear(); Dialog::dispose(); } @@ -2222,66 +2218,6 @@ MessageDialog::~MessageDialog() disposeOnce(); } -void MessageDialog::response(short nResponseId) -{ - EndDialog(nResponseId); -} - -IMPL_LINK(MessageDialog, ButtonHdl, Button *, pButton, void) -{ - response(get_response(pButton)); -} - -short MessageDialog::get_response(const vcl::Window *pWindow) const -{ - auto aFind = m_aResponses.find(pWindow); - if (aFind != m_aResponses.end()) - return aFind->second; - if (!m_pUIBuilder) - return RET_CANCEL; - return m_pUIBuilder->get_response(pWindow); -} - -void MessageDialog::setButtonHandlers(VclButtonBox const *pButtonBox) -{ - assert(pButtonBox); - for (vcl::Window* pChild = pButtonBox->GetWindow(GetWindowType::FirstChild); pChild; - pChild = pChild->GetWindow(GetWindowType::Next)) - { - switch (pChild->GetType()) - { - case WindowType::PUSHBUTTON: - { - PushButton* pButton = static_cast<PushButton*>(pChild); - if (!pButton->GetClickHdl().IsSet()) - pButton->SetClickHdl(LINK(this, MessageDialog, ButtonHdl)); - break; - } - //insist that the response ids match the default actions for those - //widgets, and leave their default handlers in place - case WindowType::OKBUTTON: - assert(get_response(pChild) == RET_OK); - break; - case WindowType::CANCELBUTTON: - assert(get_response(pChild) == RET_CANCEL); - break; - case WindowType::HELPBUTTON: - assert(get_response(pChild) == RET_HELP); - break; - default: - SAL_WARN("vcl.layout", "The type of widget " << - pChild->GetHelpId() << " is currently not handled"); - break; - } - //The default is to stick the focus into the first widget - //that accepts it, and if that happens and it's a button - //then that becomes the new default button, so explicitly - //put the focus into the default button - if (pChild->GetStyle() & WB_DEFBUTTON) - pChild->GrabFocus(); - } -} - void MessageDialog::SetMessagesWidths(vcl::Window const *pParent, VclMultiLineEdit *pPrimaryMessage, VclMultiLineEdit *pSecondaryMessage) { @@ -2317,7 +2253,7 @@ short MessageDialog::Execute() switch (m_eMessageType) { case VclMessageType::Info: - m_pImage->SetImage(InfoBox::GetStandardImage()); + m_pImage->SetImage(GetStandardInfoBoxImage()); break; case VclMessageType::Warning: m_pImage->SetImage(WarningBox::GetStandardImage()); @@ -2363,6 +2299,7 @@ short MessageDialog::Execute() assert(pButtonBox); VclPtr<PushButton> pBtn; + short nDefaultResponse = RET_CANCEL; switch (m_eButtonsType) { case VclButtonsType::NONE: @@ -2372,56 +2309,52 @@ short MessageDialog::Execute() pBtn->SetStyle(pBtn->GetStyle() & WB_DEFBUTTON); pBtn->Show(); pBtn->set_id("ok"); - m_aOwnedButtons.push_back(pBtn); - m_aResponses[pBtn] = RET_OK; + add_button(pBtn, RET_OK, true); + nDefaultResponse = RET_OK; break; case VclButtonsType::Close: pBtn.set( VclPtr<CloseButton>::Create(pButtonBox) ); pBtn->SetStyle(pBtn->GetStyle() & WB_DEFBUTTON); pBtn->Show(); pBtn->set_id("close"); - m_aOwnedButtons.push_back(pBtn); - m_aResponses[pBtn] = RET_CLOSE; + add_button(pBtn, RET_CLOSE, true); + nDefaultResponse = RET_CLOSE; break; case VclButtonsType::Cancel: pBtn.set( VclPtr<CancelButton>::Create(pButtonBox) ); pBtn->SetStyle(pBtn->GetStyle() & WB_DEFBUTTON); pBtn->set_id("cancel"); - m_aOwnedButtons.push_back(pBtn); - m_aResponses[pBtn] = RET_CANCEL; + add_button(pBtn, RET_CANCEL, true); + nDefaultResponse = RET_CANCEL; break; case VclButtonsType::YesNo: pBtn = VclPtr<PushButton>::Create(pButtonBox); pBtn->SetText(Button::GetStandardText(StandardButtonType::Yes)); pBtn->Show(); pBtn->set_id("yes"); - m_aOwnedButtons.push_back(pBtn); - m_aResponses[pBtn] = RET_YES; + add_button(pBtn, RET_YES, true); pBtn.set( VclPtr<PushButton>::Create(pButtonBox) ); - pBtn->SetStyle(pBtn->GetStyle() & WB_DEFBUTTON); pBtn->SetText(Button::GetStandardText(StandardButtonType::No)); pBtn->Show(); pBtn->set_id("no"); - m_aOwnedButtons.push_back(pBtn); - m_aResponses[pBtn] = RET_NO; + add_button(pBtn, RET_NO, true); + nDefaultResponse = RET_NO; break; case VclButtonsType::OkCancel: pBtn.set( VclPtr<OKButton>::Create(pButtonBox) ); pBtn->Show(); pBtn->set_id("ok"); - m_aOwnedButtons.push_back(pBtn); - m_aResponses[pBtn] = RET_OK; + add_button(pBtn, RET_OK, true); pBtn.set( VclPtr<CancelButton>::Create(pButtonBox) ); - pBtn->SetStyle(pBtn->GetStyle() & WB_DEFBUTTON); pBtn->Show(); pBtn->set_id("cancel"); - m_aOwnedButtons.push_back(pBtn); - m_aResponses[pBtn] = RET_CANCEL; + add_button(pBtn, RET_CANCEL, true); + nDefaultResponse = RET_CANCEL; break; } - setButtonHandlers(pButtonBox); + set_default_response(nDefaultResponse); pButtonBox->sort_native_button_order(); m_pGrid->Show(); } diff --git a/vcl/source/window/msgbox.cxx b/vcl/source/window/msgbox.cxx index ab6ff5adad1e..8fbd0475c57d 100644 --- a/vcl/source/window/msgbox.cxx +++ b/vcl/source/window/msgbox.cxx @@ -366,33 +366,13 @@ Size MessBox::GetOptimalSize() const return Size( 250, 100 ); } -InfoBox::InfoBox( vcl::Window* pParent, const OUString& rMessage ) : - MessBox( pParent, MessBoxStyle::Ok | MessBoxStyle::DefaultOk, 0, OUString(), rMessage ) -{ - // Default Text is the display title from the application - if ( GetText().isEmpty() ) - SetText( GetStandardText() ); - - SetImage( InfoBox::GetStandardImage() ); -} - -InfoBox::InfoBox( vcl::Window* pParent, MessBoxStyle nStyle, const OUString& rMessage ) : - MessBox( pParent, nStyle, 0, OUString(), rMessage ) -{ - // Default Text is the display title from the application - if ( GetText().isEmpty() ) - SetText( GetStandardText() ); - - SetImage( InfoBox::GetStandardImage() ); -} - -Image const & InfoBox::GetStandardImage() +Image const & GetStandardInfoBoxImage() { ImplInitMsgBoxImageList(); return ImplGetSVData()->maWinData.maMsgBoxImgList[3]; } -OUString InfoBox::GetStandardText() +OUString GetStandardInfoBoxText() { return VclResId(SV_MSGBOX_INFO); } diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx index 6a1a2f77c279..aa6873aaace4 100644 --- a/vcl/unx/gtk3/gtk3gtkinst.cxx +++ b/vcl/unx/gtk3/gtk3gtkinst.cxx @@ -1386,6 +1386,8 @@ public: ret = RET_OK; else if (ret == GTK_RESPONSE_CANCEL) ret = RET_CANCEL; + else if (ret == GTK_RESPONSE_CLOSE) + ret = RET_CLOSE; else if (ret == GTK_RESPONSE_YES) ret = RET_YES; else if (ret == GTK_RESPONSE_NO) @@ -1396,19 +1398,36 @@ public: return ret; } - virtual void response(int nResponse) override + static int VclToGtk(int nResponse) { if (nResponse == RET_OK) - nResponse = GTK_RESPONSE_OK; + return GTK_RESPONSE_OK; else if (nResponse == RET_CANCEL) - nResponse = GTK_RESPONSE_CANCEL; + return GTK_RESPONSE_CANCEL; + else if (nResponse == RET_CLOSE) + return GTK_RESPONSE_CLOSE; else if (nResponse == RET_YES) - nResponse = GTK_RESPONSE_YES; + return GTK_RESPONSE_YES; else if (nResponse == RET_NO) - nResponse = GTK_RESPONSE_NO; + return GTK_RESPONSE_NO; else if (nResponse == RET_HELP) - nResponse = GTK_RESPONSE_HELP; - gtk_dialog_response(m_pDialog, nResponse); + return GTK_RESPONSE_HELP; + return nResponse; + } + + virtual void response(int nResponse) override + { + gtk_dialog_response(m_pDialog, VclToGtk(nResponse)); + } + + virtual void add_button(const OUString& rText, int nResponse) override + { + gtk_dialog_add_button(m_pDialog, OUStringToOString(rText, RTL_TEXTENCODING_UTF8).getStr(), VclToGtk(nResponse)); + } + + virtual void set_default_response(int nResponse) override + { + gtk_dialog_set_default_response(m_pDialog, VclToGtk(nResponse)); } virtual ~GtkInstanceDialog() override diff --git a/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx b/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx index db47daff47db..2819368e2ccd 100644 --- a/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx +++ b/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx @@ -472,7 +472,7 @@ IMPL_LINK_NOARG(DigitalSignaturesDialog, RemoveButtonHdl, Button*, void) } } -IMPL_STATIC_LINK_NOARG(DigitalSignaturesDialog, CertMgrButtonHdl, Button*, void) +IMPL_STATIC_LINK(DigitalSignaturesDialog, CertMgrButtonHdl, Button*, pButton, void) { #ifdef _WIN32 // FIXME: call GpgME::dirInfo("bindir") somewhere in @@ -514,11 +514,12 @@ IMPL_STATIC_LINK_NOARG(DigitalSignaturesDialog, CertMgrButtonHdl, Button*, void) } else { - ScopedVclPtrInstance<InfoBox>(nullptr, XsResId(STR_XMLSECDLG_NO_CERT_MANAGER))->Execute(); + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(pButton->GetFrameWeld(), + VclMessageType::Info, VclButtonsType::Ok, + XsResId(STR_XMLSECDLG_NO_CERT_MANAGER))); + xInfoBox->run(); } - } - } IMPL_LINK_NOARG(DigitalSignaturesDialog, StartVerifySignatureHdl, LinkParamNone*, bool) @@ -746,7 +747,10 @@ void DigitalSignaturesDialog::ImplShowSignaturesDetails() } else { - ScopedVclPtrInstance<InfoBox>(nullptr, XsResId(STR_XMLSECDLG_NO_CERT_FOUND))->Execute(); + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(), + VclMessageType::Info, VclButtonsType::Ok, + XsResId(STR_XMLSECDLG_NO_CERT_FOUND))); + xInfoBox->run(); } } } |