From 48bca65f1cf381cba7cb7a4c3916155a1bca0955 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Thu, 8 Mar 2018 09:49:36 +0000 Subject: inherit welded dialogs from a common ancestor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ifa6c871a134cf89bfba71b1049a115cf7c953c42 Reviewed-on: https://gerrit.libreoffice.org/50936 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- sfx2/source/appl/appserv.cxx | 24 ++++++++---------------- sfx2/source/dialog/alienwarn.cxx | 3 +-- sfx2/source/dialog/inputdlg.cxx | 3 +-- sfx2/source/dialog/passwd.cxx | 6 ++---- sfx2/source/dialog/securitypage.cxx | 2 +- sfx2/source/doc/docinsert.cxx | 2 +- sfx2/source/doc/new.cxx | 3 +-- sfx2/source/doc/saveastemplatedlg.cxx | 3 +-- sfx2/source/inc/alienwarn.hxx | 7 ++----- sfx2/source/view/viewfrm.cxx | 9 +++------ 10 files changed, 21 insertions(+), 41 deletions(-) (limited to 'sfx2/source') diff --git a/sfx2/source/appl/appserv.cxx b/sfx2/source/appl/appserv.cxx index 550578327d0b..f7765defa192 100644 --- a/sfx2/source/appl/appserv.cxx +++ b/sfx2/source/appl/appserv.cxx @@ -304,22 +304,18 @@ namespace return nullptr; } - class LicenseDialog + class LicenseDialog : public weld::GenericDialogController { - private: - std::unique_ptr m_xBuilder; - std::unique_ptr m_xDialog; std::unique_ptr m_xLabel; public: LicenseDialog(weld::Window* pParent) - : m_xBuilder(Application::CreateBuilder(pParent, "sfx/ui/licensedialog.ui")) - , m_xDialog(m_xBuilder->weld_dialog("LicenseDialog")) + : GenericDialogController(pParent, "sfx/ui/licensedialog.ui", "LicenseDialog") , m_xLabel(m_xBuilder->weld_label("label")) { m_xLabel->set_label(Translate::GetReadStringHook()(m_xLabel->get_label())); } - short run() + short execute() { short nRet = m_xDialog->run(); if (nRet == RET_OK) @@ -328,20 +324,16 @@ namespace } }; - class SafeModeQueryDialog + class SafeModeQueryDialog : public weld::MessageDialogController { - private: - std::unique_ptr m_xBuilder; - std::unique_ptr m_xDialog; public: SafeModeQueryDialog(weld::Window* pParent) - : m_xBuilder(Application::CreateBuilder(pParent, "sfx/ui/safemodequerydialog.ui")) - , m_xDialog(m_xBuilder->weld_message_dialog("SafeModeQueryDialog")) + : MessageDialogController(pParent, "sfx/ui/safemodequerydialog.ui", "SafeModeQueryDialog") { m_xDialog->set_primary_text(Translate::GetReadStringHook()(m_xDialog->get_primary_text())); } - short run() + short execute() { short nRet = m_xDialog->run(); if (nRet == RET_OK) @@ -572,7 +564,7 @@ void SfxApplication::MiscExec_Impl( SfxRequest& rReq ) case SID_SHOW_LICENSE: { LicenseDialog aDialog(rReq.GetFrameWeld()); - aDialog.run(); + aDialog.execute(); break; } @@ -1036,7 +1028,7 @@ void SfxApplication::MiscExec_Impl( SfxRequest& rReq ) case SID_SAFE_MODE: { SafeModeQueryDialog aDialog(rReq.GetFrameWeld()); - aDialog.run(); + aDialog.execute(); break; } diff --git a/sfx2/source/dialog/alienwarn.cxx b/sfx2/source/dialog/alienwarn.cxx index dd88541fbb29..d9eeed1bd956 100644 --- a/sfx2/source/dialog/alienwarn.cxx +++ b/sfx2/source/dialog/alienwarn.cxx @@ -27,8 +27,7 @@ SfxAlienWarningDialog::SfxAlienWarningDialog(weld::Window* pParent, const OUString& _rFormatName, const OUString& _rDefaultExtension, bool rDefaultIsAlien) - : m_xBuilder(Application::CreateBuilder(pParent, "sfx/ui/alienwarndialog.ui")) - , m_xDialog(m_xBuilder->weld_message_dialog("AlienWarnDialog")) + : MessageDialogController(pParent, "sfx/ui/alienwarndialog.ui", "AlienWarnDialog") , m_xKeepCurrentBtn(m_xBuilder->weld_button("save")) , m_xUseDefaultFormatBtn(m_xBuilder->weld_button("cancel")) , m_xWarningOnBox(m_xBuilder->weld_check_button("ask")) diff --git a/sfx2/source/dialog/inputdlg.cxx b/sfx2/source/dialog/inputdlg.cxx index ff864ddd01a5..33015e788f9d 100644 --- a/sfx2/source/dialog/inputdlg.cxx +++ b/sfx2/source/dialog/inputdlg.cxx @@ -12,8 +12,7 @@ #include InputDialog::InputDialog(weld::Window* pParent, const OUString &rLabelText) - : m_xBuilder(Application::CreateBuilder(pParent, "sfx/ui/inputdialog.ui")) - , m_xDialog(m_xBuilder->weld_dialog("InputDialog")) + : GenericDialogController(pParent, "sfx/ui/inputdialog.ui", "InputDialog") , m_xEntry(m_xBuilder->weld_entry("entry")) , m_xLabel(m_xBuilder->weld_label("label")) , m_xHelp(m_xBuilder->weld_button("help")) diff --git a/sfx2/source/dialog/passwd.cxx b/sfx2/source/dialog/passwd.cxx index 7b4f236f39af..71df5e7d8d72 100644 --- a/sfx2/source/dialog/passwd.cxx +++ b/sfx2/source/dialog/passwd.cxx @@ -82,8 +82,7 @@ IMPL_LINK_NOARG(SfxPasswordDialog, OKHdl, weld::Button&, void) // CTOR / DTOR ----------------------------------------------------------- SfxPasswordDialog::SfxPasswordDialog(weld::Window* pParent, const OUString* pGroupText) - : m_xBuilder(Application::CreateBuilder(pParent, "sfx/ui/password.ui")) - , m_xDialog(m_xBuilder->weld_dialog("PasswordDialog")) + : GenericDialogController(pParent, "sfx/ui/password.ui", "PasswordDialog") , m_xPassword1Box(m_xBuilder->weld_frame("password1frame")) , m_xUserFT(m_xBuilder->weld_label("userft")) , m_xUserED(m_xBuilder->weld_entry("usered")) @@ -151,7 +150,7 @@ void SfxPasswordDialog::ShowMinLengthText(bool bShow) m_xMinLengthFT->show(bShow); } -short SfxPasswordDialog::run() +short SfxPasswordDialog::execute() { m_xUserFT->hide(); m_xUserED->hide(); @@ -192,5 +191,4 @@ short SfxPasswordDialog::run() return m_xDialog->run(); } - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/dialog/securitypage.cxx b/sfx2/source/dialog/securitypage.cxx index fcd78d3f0ab5..8633a5e0eff9 100644 --- a/sfx2/source/dialog/securitypage.cxx +++ b/sfx2/source/dialog/securitypage.cxx @@ -101,7 +101,7 @@ static bool lcl_GetPassword( aPasswdDlg.SetMinLen(1); if (bProtect) aPasswdDlg.ShowExtras( SfxShowExtras::CONFIRM ); - if (RET_OK == aPasswdDlg.run() && !aPasswdDlg.GetPassword().isEmpty()) + if (RET_OK == aPasswdDlg.execute() && !aPasswdDlg.GetPassword().isEmpty()) { rPassword = aPasswdDlg.GetPassword(); bRes = true; diff --git a/sfx2/source/doc/docinsert.cxx b/sfx2/source/doc/docinsert.cxx index 2f53b7519163..bdb083a58334 100644 --- a/sfx2/source/doc/docinsert.cxx +++ b/sfx2/source/doc/docinsert.cxx @@ -218,7 +218,7 @@ IMPL_LINK_NOARG(DocumentInserter, DialogClosedHdl, sfx2::FileDialogHelper*, void // ask for the password SfxPasswordDialog aPasswordDlg(m_xParent ? m_xParent->GetFrameWeld() : nullptr); aPasswordDlg.ShowExtras( SfxShowExtras::CONFIRM ); - short nRet = aPasswordDlg.run(); + short nRet = aPasswordDlg.execute(); if ( RET_OK == nRet ) { m_pItemSet->Put( SfxStringItem( SID_PASSWORD, aPasswordDlg.GetPassword() ) ); diff --git a/sfx2/source/doc/new.cxx b/sfx2/source/doc/new.cxx index 2a50c964bc71..eed042b7d60e 100644 --- a/sfx2/source/doc/new.cxx +++ b/sfx2/source/doc/new.cxx @@ -237,8 +237,7 @@ sal_uInt16 SfxNewFileDialog::GetSelectedTemplatePos() const } SfxNewFileDialog::SfxNewFileDialog(weld::Window *pParent, SfxNewFileDialogMode nFlags) - : m_xBuilder(Application::CreateBuilder(pParent, "sfx/ui/loadtemplatedialog.ui")) - , m_xDialog(m_xBuilder->weld_dialog("LoadTemplateDialog")) + : GenericDialogController(pParent, "sfx/ui/loadtemplatedialog.ui", "LoadTemplateDialog") , m_xRegionLb(m_xBuilder->weld_tree_view("categories")) , m_xTemplateLb(m_xBuilder->weld_tree_view("templates")) , m_xTextStyleCB(m_xBuilder->weld_check_button("text")) diff --git a/sfx2/source/doc/saveastemplatedlg.cxx b/sfx2/source/doc/saveastemplatedlg.cxx index efdb861d86a8..e1f8101fa78d 100644 --- a/sfx2/source/doc/saveastemplatedlg.cxx +++ b/sfx2/source/doc/saveastemplatedlg.cxx @@ -34,8 +34,7 @@ using namespace ::com::sun::star::frame; // Class SfxSaveAsTemplateDialog -------------------------------------------------- SfxSaveAsTemplateDialog::SfxSaveAsTemplateDialog(weld::Window* pParent, const uno::Reference &rModel) - : m_xBuilder(Application::CreateBuilder(pParent, "sfx/ui/saveastemplatedlg.ui")) - , m_xDialog(m_xBuilder->weld_dialog("SaveAsTemplateDialog")) + : GenericDialogController(pParent, "sfx/ui/saveastemplatedlg.ui", "SaveAsTemplateDialog") , m_xLBCategory(m_xBuilder->weld_tree_view("categorylb")) , m_xCBXDefault(m_xBuilder->weld_check_button("defaultcb")) , m_xTemplateNameEdit(m_xBuilder->weld_entry("name_entry")) diff --git a/sfx2/source/inc/alienwarn.hxx b/sfx2/source/inc/alienwarn.hxx index 05f5a3835aee..5b93430882d8 100644 --- a/sfx2/source/inc/alienwarn.hxx +++ b/sfx2/source/inc/alienwarn.hxx @@ -21,11 +21,9 @@ #include -class SfxAlienWarningDialog +class SfxAlienWarningDialog : public weld::MessageDialogController { private: - std::unique_ptr m_xBuilder; - std::unique_ptr m_xDialog; std::unique_ptr m_xKeepCurrentBtn; std::unique_ptr m_xUseDefaultFormatBtn; std::unique_ptr m_xWarningOnBox; @@ -36,8 +34,7 @@ private: public: SfxAlienWarningDialog(weld::Window* pParent, const OUString& _rFormatName, const OUString& _rDefaultExtension, bool rDefaultIsAlien); - short run() { return m_xDialog->run(); } - ~SfxAlienWarningDialog(); + virtual ~SfxAlienWarningDialog() override; }; #endif // INCLUDED_SFX2_SOURCE_INC_ALIENWARN_HXX diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx index b640f5f4aff9..dd37efc0016e 100644 --- a/sfx2/source/view/viewfrm.cxx +++ b/sfx2/source/view/viewfrm.cxx @@ -154,22 +154,19 @@ void SfxViewFrame::InitInterface_Impl() namespace { /// Asks the user if editing a read-only document is really wanted. -class SfxEditDocumentDialog +class SfxEditDocumentDialog : public weld::MessageDialogController { private: - std::unique_ptr m_xBuilder; - std::unique_ptr m_xDialog; std::unique_ptr m_xEditDocument; std::unique_ptr m_xCancel; public: SfxEditDocumentDialog(weld::Widget* pParent); - short run() { return m_xDialog->run(); } }; SfxEditDocumentDialog::SfxEditDocumentDialog(weld::Widget* pParent) - : m_xBuilder(Application::CreateBuilder(pParent, "sfx/ui/editdocumentdialog.ui")) - , m_xDialog(m_xBuilder->weld_message_dialog("EditDocumentDialog")) + : MessageDialogController(pParent, "sfx/ui/editdocumentdialog.ui", + "EditDocumentDialog") , m_xEditDocument(m_xBuilder->weld_button("edit")) , m_xCancel(m_xBuilder->weld_button("cancel")) { -- cgit