diff options
Diffstat (limited to 'sfx2/source/view')
-rw-r--r-- | sfx2/source/view/classificationhelper.cxx | 16 | ||||
-rw-r--r-- | sfx2/source/view/viewfrm.cxx | 56 | ||||
-rw-r--r-- | sfx2/source/view/viewprn.cxx | 37 | ||||
-rw-r--r-- | sfx2/source/view/viewsh.cxx | 24 |
4 files changed, 82 insertions, 51 deletions
diff --git a/sfx2/source/view/classificationhelper.cxx b/sfx2/source/view/classificationhelper.cxx index f167dc8428a8..a642d19b65e8 100644 --- a/sfx2/source/view/classificationhelper.cxx +++ b/sfx2/source/view/classificationhelper.cxx @@ -33,7 +33,7 @@ #include <sfx2/viewfrm.hxx> #include <tools/datetime.hxx> #include <unotools/datetime.hxx> -#include <vcl/layout.hxx> +#include <vcl/weld.hxx> #include <svl/fstathelper.hxx> #include <config_folders.h> @@ -528,14 +528,24 @@ bool SfxClassificationHelper::ShowPasteInfo(SfxClassificationCheckPasteResult eR case SfxClassificationCheckPasteResult::TargetDocNotClassified: { if (!Application::IsHeadlessModeEnabled()) - ScopedVclPtrInstance<MessageDialog>(nullptr, SfxResId(STR_TARGET_DOC_NOT_CLASSIFIED), VclMessageType::Info)->Execute(); + { + std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(nullptr, + VclMessageType::Info, VclButtonsType::Ok, + SfxResId(STR_TARGET_DOC_NOT_CLASSIFIED))); + xBox->run(); + } return false; } break; case SfxClassificationCheckPasteResult::DocClassificationTooLow: { if (!Application::IsHeadlessModeEnabled()) - ScopedVclPtrInstance<MessageDialog>(nullptr, SfxResId(STR_DOC_CLASSIFICATION_TOO_LOW), VclMessageType::Info)->Execute(); + { + std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(nullptr, + VclMessageType::Info, VclButtonsType::Ok, + SfxResId(STR_DOC_CLASSIFICATION_TOO_LOW))); + xBox->run(); + } return false; } break; diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx index ea7e02d26475..a7874e1934b0 100644 --- a/sfx2/source/view/viewfrm.cxx +++ b/sfx2/source/view/viewfrm.cxx @@ -40,7 +40,7 @@ #include <svl/slstitm.hxx> #include <svl/whiter.hxx> #include <svl/undo.hxx> -#include <vcl/layout.hxx> +#include <vcl/weld.hxx> #include <svtools/sfxecode.hxx> #include <svtools/miscopt.hxx> #include <svtools/ehdl.hxx> @@ -154,35 +154,25 @@ void SfxViewFrame::InitInterface_Impl() namespace { /// Asks the user if editing a read-only document is really wanted. -class SfxEditDocumentDialog : public MessageDialog +class SfxEditDocumentDialog { private: - VclPtr<PushButton> m_pEditDocument; - VclPtr<PushButton> m_pCancel; + std::unique_ptr<weld::Builder> m_xBuilder; + std::unique_ptr<weld::MessageDialog> m_xDialog; + std::unique_ptr<weld::Button> m_xEditDocument; + std::unique_ptr<weld::Button> m_xCancel; public: - SfxEditDocumentDialog(vcl::Window* pParent); - ~SfxEditDocumentDialog() override; - void dispose() override; + SfxEditDocumentDialog(weld::Widget* pParent); + short run() { return m_xDialog->run(); } }; -SfxEditDocumentDialog::SfxEditDocumentDialog(vcl::Window* pParent) - : MessageDialog(pParent, "EditDocumentDialog", "sfx/ui/editdocumentdialog.ui") +SfxEditDocumentDialog::SfxEditDocumentDialog(weld::Widget* pParent) + : m_xBuilder(Application::CreateBuilder(pParent, "sfx/ui/editdocumentdialog.ui")) + , m_xDialog(m_xBuilder->weld_message_dialog("EditDocumentDialog")) + , m_xEditDocument(m_xBuilder->weld_button("edit")) + , m_xCancel(m_xBuilder->weld_button("cancel")) { - get(m_pEditDocument, "edit"); - get(m_pCancel, "cancel"); -} - -SfxEditDocumentDialog::~SfxEditDocumentDialog() -{ - disposeOnce(); -} - -void SfxEditDocumentDialog::dispose() -{ - m_pEditDocument.clear(); - m_pCancel.clear(); - MessageDialog::dispose(); } class SfxQueryOpenAsTemplate : public QueryBox @@ -588,9 +578,10 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq ) if ( bDo && GetFrame().DocIsModified_Impl() && !rReq.IsAPI() && ( !pSilentItem || !pSilentItem->GetValue() ) ) { - ScopedVclPtrInstance<MessageDialog> aBox(&GetWindow(), SfxResId(STR_QUERY_LASTVERSION), - VclMessageType::Question, VclButtonsType::YesNo); - bDo = ( RET_YES == aBox->Execute() ); + std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(GetWindow().GetFrameWeld(), + VclMessageType::Question, VclButtonsType::YesNo, + SfxResId(STR_QUERY_LASTVERSION))); + bDo = RET_YES == xBox->run(); } if ( bDo ) @@ -756,9 +747,10 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq ) if ( bForEdit && ( SID_EDITDOC == rReq.GetSlot() || SID_READONLYDOC == rReq.GetSlot() ) ) { // ask user for opening as template - ScopedVclPtrInstance<MessageDialog> aBox(&GetWindow(), SfxResId(STR_QUERY_OPENASTEMPLATE), - VclMessageType::Question, VclButtonsType::YesNo); - if ( RET_YES == aBox->Execute() ) + std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(GetWindow().GetFrameWeld(), + VclMessageType::Question, VclButtonsType::YesNo, + SfxResId(STR_QUERY_OPENASTEMPLATE))); + if (RET_YES == xBox->run()) { SfxAllItemSet aSet( pApp->GetPool() ); aSet.Put( SfxStringItem( SID_FILE_NAME, pMedium->GetName() ) ); @@ -1345,12 +1337,12 @@ void SfxViewFrame::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint ) } } -IMPL_LINK_NOARG(SfxViewFrame, SwitchReadOnlyHandler, Button*, void) +IMPL_LINK(SfxViewFrame, SwitchReadOnlyHandler, Button*, pButton, void) { if (m_xObjSh.is() && IsSignPDF(m_xObjSh)) { - ScopedVclPtrInstance<SfxEditDocumentDialog> pDialog(nullptr); - if (pDialog->Execute() != RET_OK) + SfxEditDocumentDialog aDialog(pButton->GetFrameWeld()); + if (aDialog.run() != RET_OK) return; } GetDispatcher()->Execute(SID_EDITDOC); diff --git a/sfx2/source/view/viewprn.cxx b/sfx2/source/view/viewprn.cxx index a5be4fff8b7d..1d070d54e978 100644 --- a/sfx2/source/view/viewprn.cxx +++ b/sfx2/source/view/viewprn.cxx @@ -23,7 +23,7 @@ #include <com/sun/star/view/XRenderable.hpp> #include <svl/itempool.hxx> -#include <vcl/layout.hxx> +#include <vcl/weld.hxx> #include <svtools/prnsetup.hxx> #include <svl/flagitem.hxx> #include <svl/stritem.hxx> @@ -333,7 +333,13 @@ void SfxPrinterController::jobFinished( css::view::PrintableState nState ) // "real" problem (not simply printing cancelled by user) OUString aMsg( SfxResId(STR_NOSTARTPRINTER) ); if ( !m_bApi ) - ScopedVclPtrInstance<MessageDialog>(mpViewShell->GetWindow(), aMsg)->Execute(); + { + vcl::Window* pWindow = mpViewShell->GetWindow(); + std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(pWindow ? pWindow->GetFrameWeld() : nullptr, + VclMessageType::Warning, VclButtonsType::Ok, + aMsg)); + xBox->run(); + } SAL_FALLTHROUGH; } case view::PrintableState_JOB_ABORTED : @@ -505,11 +511,16 @@ void SfxViewShell::SetPrinter_Impl( VclPtr<SfxPrinter>& pNewPrinter ) SfxPrinterChangeFlags nChangedFlags = SfxPrinterChangeFlags::NONE; // Ask if possible, if page format should be taken over from printer. - if ( ( bOriChg || bPgSzChg ) && - RET_YES == ScopedVclPtrInstance<MessageDialog>(nullptr, aMsg, VclMessageType::Question, VclButtonsType::YesNo)->Execute() ) + if (bOriChg || bPgSzChg) { - // Flags with changes for <SetPrinter(SfxPrinter*)> are maintained - nChangedFlags |= nNewOpt; + std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(nullptr, + VclMessageType::Question, VclButtonsType::YesNo, + aMsg)); + if (RET_YES == xBox->run()) + { + // Flags with changes for <SetPrinter(SfxPrinter*)> are maintained + nChangedFlags |= nNewOpt; + } } // For the MAC to have its "temporary of class String" in next if() @@ -778,7 +789,12 @@ void SfxViewShell::ExecPrint_Impl( SfxRequest &rReq ) { // no valid printer either in ItemSet or at the document if ( !bSilent ) - ScopedVclPtrInstance<MessageDialog>(nullptr, SfxResId(STR_NODEFPRINTER))->Execute(); + { + std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(nullptr, + VclMessageType::Warning, VclButtonsType::Ok, + SfxResId(STR_NODEFPRINTER))); + xBox->run(); + } rReq.SetReturnValue(SfxBoolItem(0,false)); @@ -790,7 +806,12 @@ void SfxViewShell::ExecPrint_Impl( SfxRequest &rReq ) { // if printer is busy, abort configuration if ( !bSilent ) - ScopedVclPtrInstance<MessageDialog>(nullptr, SfxResId(STR_ERROR_PRINTER_BUSY), VclMessageType::Info)->Execute(); + { + std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(nullptr, + VclMessageType::Info, VclButtonsType::Ok, + SfxResId(STR_ERROR_PRINTER_BUSY))); + xBox->run(); + } rReq.SetReturnValue(SfxBoolItem(0,false)); return; diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx index d7962e72be16..f5b0f7399318 100644 --- a/sfx2/source/view/viewsh.cxx +++ b/sfx2/source/view/viewsh.cxx @@ -22,9 +22,9 @@ #include <svl/stritem.hxx> #include <svl/eitem.hxx> #include <svl/whiter.hxx> -#include <vcl/layout.hxx> #include <vcl/msgbox.hxx> #include <vcl/toolbox.hxx> +#include <vcl/weld.hxx> #include <svl/intitem.hxx> #include <svtools/langhelp.hxx> #include <svtools/sfxecode.hxx> @@ -497,8 +497,11 @@ void SfxViewShell::ExecMisc_Impl( SfxRequest &rReq ) if ( eResult == SfxMailModel::SEND_MAIL_ERROR ) { - ScopedVclPtrInstance< MessageDialog > aBox(SfxGetpApp()->GetTopWindow(), SfxResId( STR_ERROR_SEND_MAIL ), VclMessageType::Info); - aBox->Execute(); + vcl::Window* pWin = SfxGetpApp()->GetTopWindow(); + std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(pWin ? pWin->GetFrameWeld() : nullptr, + VclMessageType::Info, VclButtonsType::Ok, + SfxResId(STR_ERROR_SEND_MAIL))); + xBox->run(); rReq.Ignore(); } else @@ -517,9 +520,12 @@ void SfxViewShell::ExecMisc_Impl( SfxRequest &rReq ) SfxMailModel::SendMailResult eResult = aModel.SaveAndSend( xFrame ); if( eResult == SfxMailModel::SEND_MAIL_ERROR ) { - ScopedVclPtrInstance< MessageDialog > aBox(SfxGetpApp()->GetTopWindow(), SfxResId( STR_ERROR_SEND_MAIL ), VclMessageType::Info); - aBox->Execute(); - rReq.Ignore(); + vcl::Window* pWin = SfxGetpApp()->GetTopWindow(); + std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(pWin ? pWin->GetFrameWeld() : nullptr, + VclMessageType::Info, VclButtonsType::Ok, + SfxResId(STR_ERROR_SEND_MAIL))); + xBox->run(); + rReq.Ignore(); } else rReq.Done(); @@ -1116,8 +1122,10 @@ bool SfxViewShell::PrepareClose { if ( bUI ) { - ScopedVclPtrInstance< MessageDialog > aInfoBox(&GetViewFrame()->GetWindow(), SfxResId( STR_CANT_CLOSE ), VclMessageType::Info ); - aInfoBox->Execute(); + std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(GetViewFrame()->GetWindow().GetFrameWeld(), + VclMessageType::Info, VclButtonsType::Ok, + SfxResId(STR_CANT_CLOSE))); + xBox->run(); } return false; |