diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-03-16 20:35:23 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-03-18 13:43:34 +0100 |
commit | 2fb266bb77722cd45af7346e99a8f214c3f8b198 (patch) | |
tree | 00901e9e800809ea30ab378be622446bb7804e46 /sc/source | |
parent | 6709db941ff3257226f48212d2c36ee1b0d68200 (diff) |
unify the message dialogs with extra widgets cases
Change-Id: I9ad3573b15d24c3d1737b9f450792952ae20a31b
Reviewed-on: https://gerrit.libreoffice.org/51476
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sc/source')
-rw-r--r-- | sc/source/filter/oox/workbookfragment.cxx | 37 | ||||
-rw-r--r-- | sc/source/ui/docshell/docsh.cxx | 60 | ||||
-rw-r--r-- | sc/source/ui/inc/warnbox.hxx | 3 | ||||
-rw-r--r-- | sc/source/ui/miscdlgs/warnbox.cxx | 16 |
4 files changed, 42 insertions, 74 deletions
diff --git a/sc/source/filter/oox/workbookfragment.cxx b/sc/source/filter/oox/workbookfragment.cxx index 7a57a2a04402..d1fef597ae2f 100644 --- a/sc/source/filter/oox/workbookfragment.cxx +++ b/sc/source/filter/oox/workbookfragment.cxx @@ -516,6 +516,19 @@ ScDocShell& getDocShell(const ScDocument& rDoc) return static_cast<ScDocShell&>(*rDoc.GetDocumentShell()); } +class MessageWithCheck : public weld::MessageDialogController +{ +private: + std::unique_ptr<weld::CheckButton> m_xWarningOnBox; +public: + MessageWithCheck(weld::Window *pParent, const OUString& rUIFile, const OString& rDialogId) + : weld::MessageDialogController(pParent, rUIFile, rDialogId, "ask") + , m_xWarningOnBox(m_xBuilder->weld_check_button("ask")) + { + } + bool get_active() const { return m_xWarningOnBox->get_active(); } +}; + } void WorkbookFragment::recalcFormulaCells() @@ -534,27 +547,13 @@ void WorkbookFragment::recalcFormulaCells() // Ask the user if full re-calculation is desired. vcl::Window* pWin = ScDocShell::GetActiveDialogParent(); - std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(pWin ? pWin->GetFrameWeld() : nullptr, - "modules/scalc/ui/recalcquerydialog.ui")); - std::unique_ptr<weld::MessageDialog> xQueryBox(xBuilder->weld_message_dialog("RecalcQueryDialog")); - xQueryBox->set_primary_text(ScGlobal::GetRscString(STR_QUERY_FORMULA_RECALC_ONLOAD_XLS)); - xQueryBox->set_default_response(RET_YES); - std::unique_ptr<weld::CheckButton> xWarningOnBox(xBuilder->weld_check_button("ask")); - - //fdo#75121, a bit tricky because the widgets we want to align with - //don't actually exist in the ui description, they're implied - std::unique_ptr<weld::Container> xOrigParent(xWarningOnBox->weld_parent()); - std::unique_ptr<weld::Container> xContentArea(xQueryBox->weld_message_area()); - xOrigParent->remove(xWarningOnBox.get()); - xContentArea->add(xWarningOnBox.get()); - - bHardRecalc = xQueryBox->run() == RET_YES; + MessageWithCheck aQueryBox(pWin ? pWin->GetFrameWeld() : nullptr, "modules/scalc/ui/recalcquerydialog.ui", "RecalcQueryDialog"); + aQueryBox.set_primary_text(ScGlobal::GetRscString(STR_QUERY_FORMULA_RECALC_ONLOAD_XLS)); + aQueryBox.set_default_response(RET_YES); - //put them back as they were - xContentArea->remove(xWarningOnBox.get()); - xOrigParent->add(xWarningOnBox.get()); + bHardRecalc = aQueryBox.run() == RET_YES; - if (xWarningOnBox->get_active()) + if (aQueryBox.get_active()) { // Always perform selected action in the future. std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create()); diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx index ec9505da8840..e59ee43400e8 100644 --- a/sc/source/ui/docshell/docsh.cxx +++ b/sc/source/ui/docshell/docsh.cxx @@ -428,6 +428,19 @@ void processDataStream( ScDocShell& rShell, const sc::ImportPostProcessData& rDa rMgr.setDataStream(pStrm); } +class MessageWithCheck : public weld::MessageDialogController +{ +private: + std::unique_ptr<weld::CheckButton> m_xWarningOnBox; +public: + MessageWithCheck(weld::Window *pParent, const OUString& rUIFile, const OString& rDialogId) + : weld::MessageDialogController(pParent, rUIFile, rDialogId, "ask") + , m_xWarningOnBox(m_xBuilder->weld_check_button("ask")) + { + } + bool get_active() const { return m_xWarningOnBox->get_active(); } +}; + } bool ScDocShell::LoadXML( SfxMedium* pLoadMedium, const css::uno::Reference< css::embed::XStorage >& xStor ) @@ -475,27 +488,14 @@ bool ScDocShell::LoadXML( SfxMedium* pLoadMedium, const css::uno::Reference< css // full re-calculation. vcl::Window* pWin = GetActiveDialogParent(); - std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(pWin ? pWin->GetFrameWeld() : nullptr, - "modules/scalc/ui/recalcquerydialog.ui")); - std::unique_ptr<weld::MessageDialog> xQueryBox(xBuilder->weld_message_dialog("RecalcQueryDialog")); - xQueryBox->set_primary_text(ScGlobal::GetRscString(STR_QUERY_FORMULA_RECALC_ONLOAD_ODS)); - xQueryBox->set_default_response(RET_YES); - std::unique_ptr<weld::CheckButton> xWarningOnBox(xBuilder->weld_check_button("ask")); - - //fdo#75121, a bit tricky because the widgets we want to align with - //don't actually exist in the ui description, they're implied - std::unique_ptr<weld::Container> xOrigParent(xWarningOnBox->weld_parent()); - std::unique_ptr<weld::Container> xContentArea(xQueryBox->weld_message_area()); - xOrigParent->remove(xWarningOnBox.get()); - xContentArea->add(xWarningOnBox.get()); - - bHardRecalc = xQueryBox->run() == RET_YES; + MessageWithCheck aQueryBox(pWin ? pWin->GetFrameWeld() : nullptr, + "modules/scalc/ui/recalcquerydialog.ui", "RecalcQueryDialog"); + aQueryBox.set_primary_text(ScGlobal::GetRscString(STR_QUERY_FORMULA_RECALC_ONLOAD_ODS)); + aQueryBox.set_default_response(RET_YES); - //put them back as they were - xContentArea->remove(xWarningOnBox.get()); - xOrigParent->add(xWarningOnBox.get()); + bHardRecalc = aQueryBox.run() == RET_YES; - if (xWarningOnBox->get_active()) + if (aQueryBox.get_active()) { // Always perform selected action in the future. std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create()); @@ -725,25 +725,11 @@ void ScDocShell::Notify( SfxBroadcaster&, const SfxHint& rHint ) { vcl::Window* pWin = ScDocShell::GetActiveDialogParent(); - std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(pWin ? pWin->GetFrameWeld() : nullptr, - "modules/scalc/ui/sharedwarningdialog.ui")); - std::unique_ptr<weld::MessageDialog> xWarningBox(xBuilder->weld_message_dialog("SharedWarningDialog")); - std::unique_ptr<weld::CheckButton> xWarningOnBox(xBuilder->weld_check_button("ask")); - - //fdo#75121, a bit tricky because the widgets we want to align with - //don't actually exist in the ui description, they're implied - std::unique_ptr<weld::Container> xOrigParent(xWarningOnBox->weld_parent()); - std::unique_ptr<weld::Container> xContentArea(xWarningBox->weld_message_area()); - xOrigParent->remove(xWarningOnBox.get()); - xContentArea->add(xWarningOnBox.get()); - - xWarningBox->run(); - - //put them back as they were - xContentArea->remove(xWarningOnBox.get()); - xOrigParent->add(xWarningOnBox.get()); + MessageWithCheck aWarningBox(pWin ? pWin->GetFrameWeld() : nullptr, + "modules/scalc/ui/sharedwarningdialog.ui", "SharedWarningDialog"); + aWarningBox.run(); - bool bChecked = xWarningOnBox->get_active(); + bool bChecked = aWarningBox.get_active(); if (bChecked) { aAppOptions.SetShowSharedDocumentWarning( !bChecked ); diff --git a/sc/source/ui/inc/warnbox.hxx b/sc/source/ui/inc/warnbox.hxx index 54bdd269ebeb..02fea50e181a 100644 --- a/sc/source/ui/inc/warnbox.hxx +++ b/sc/source/ui/inc/warnbox.hxx @@ -27,11 +27,8 @@ class ScReplaceWarnBox : public weld::MessageDialogController { std::unique_ptr<weld::CheckButton> m_xWarningOnBox; - std::unique_ptr<weld::Container> m_xOrigParent; - std::unique_ptr<weld::Container> m_xContentArea; public: ScReplaceWarnBox(weld::Window* pParent); - virtual ~ScReplaceWarnBox() override; /** Opens dialog if IsDialogEnabled() returns true. @descr If after executing the dialog the checkbox "Do not show again" is set, diff --git a/sc/source/ui/miscdlgs/warnbox.cxx b/sc/source/ui/miscdlgs/warnbox.cxx index bc0302c4bcbd..279639c7996f 100644 --- a/sc/source/ui/miscdlgs/warnbox.cxx +++ b/sc/source/ui/miscdlgs/warnbox.cxx @@ -27,26 +27,12 @@ ScReplaceWarnBox::ScReplaceWarnBox(weld::Window* pParent) : MessageDialogController(pParent, "modules/scalc/ui/checkwarningdialog.ui", - "CheckWarningDialog") + "CheckWarningDialog", "ask") // By default, the check box is ON, and the user needs to un-check it to // disable all future warnings. , m_xWarningOnBox(m_xBuilder->weld_check_button("ask")) - , m_xOrigParent(m_xWarningOnBox->weld_parent()) - , m_xContentArea(m_xDialog->weld_message_area()) { m_xDialog->set_default_response(RET_YES); - - //fdo#75121, a bit tricky because the widgets we want to align with - //don't actually exist in the ui description, they're implied - m_xOrigParent->remove(m_xWarningOnBox.get()); - m_xContentArea->add(m_xWarningOnBox.get()); -} - -ScReplaceWarnBox::~ScReplaceWarnBox() -{ - //put them back as they were - m_xContentArea->remove(m_xWarningOnBox.get()); - m_xOrigParent->add(m_xWarningOnBox.get()); } short ScReplaceWarnBox::execute() |