diff options
author | Caolán McNamara <caolanm@redhat.com> | 2019-12-13 13:04:43 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2019-12-13 15:44:09 +0100 |
commit | dff70ffce88b69a1d75036abb6a9e28cfd51c315 (patch) | |
tree | 4cf95d6c06de730e1dfd68be5dd1a4f20fbdd6ee /sc | |
parent | 63e36e30beeaef36d5071cc94c7a3424ccfd48fd (diff) |
cancel solver subdialogs on forced removal
Change-Id: Idd99af070c1ed20ecc458fb17f194a56b9d37cc3
Reviewed-on: https://gerrit.libreoffice.org/85113
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/ui/inc/optsolver.hxx | 4 | ||||
-rw-r--r-- | sc/source/ui/inc/solveroptions.hxx | 6 | ||||
-rw-r--r-- | sc/source/ui/miscdlgs/optsolver.cxx | 12 | ||||
-rw-r--r-- | sc/source/ui/miscdlgs/solveroptions.cxx | 28 |
4 files changed, 36 insertions, 14 deletions
diff --git a/sc/source/ui/inc/optsolver.hxx b/sc/source/ui/inc/optsolver.hxx index 3208416989a4..d5586172c0fa 100644 --- a/sc/source/ui/inc/optsolver.hxx +++ b/sc/source/ui/inc/optsolver.hxx @@ -86,6 +86,8 @@ public: { return maProperties; } }; +class ScSolverOptionsDialog; + class ScOptSolverDlg : public ScAnyRefDlgController { public: @@ -179,6 +181,8 @@ private: std::unique_ptr<weld::Label> m_xResultFT; std::unique_ptr<weld::Widget> m_xContents; + std::shared_ptr<ScSolverOptionsDialog> m_xOptDlg; + void Init(const ScAddress& rCursorPos); bool CallSolver(); void ReadConditions(); diff --git a/sc/source/ui/inc/solveroptions.hxx b/sc/source/ui/inc/solveroptions.hxx index 41875a07b7d5..3ad4891d7a02 100644 --- a/sc/source/ui/inc/solveroptions.hxx +++ b/sc/source/ui/inc/solveroptions.hxx @@ -52,6 +52,9 @@ public: void SetIntValue( sal_Int32 nNew ) { mbIsDouble = false; mnIntValue = nNew; } }; +class ScSolverIntegerDialog; +class ScSolverValueDialog; + class ScSolverOptionsDialog : public weld::GenericDialogController { css::uno::Sequence<OUString> maImplNames; @@ -65,6 +68,9 @@ class ScSolverOptionsDialog : public weld::GenericDialogController std::unique_ptr<weld::TreeView> m_xLbSettings; std::unique_ptr<weld::Button> m_xBtnEdit; + std::shared_ptr<ScSolverIntegerDialog> m_xIntDialog; + std::shared_ptr<ScSolverValueDialog> m_xValDialog; + DECL_LINK( EngineSelectHdl, weld::ComboBox&, void ); DECL_LINK( SettingsSelHdl, weld::TreeView&, void ); DECL_LINK( SettingsDoubleClickHdl, weld::TreeView&, bool ); diff --git a/sc/source/ui/miscdlgs/optsolver.cxx b/sc/source/ui/miscdlgs/optsolver.cxx index c1e7c5a22b2a..ec69d43f0eb8 100644 --- a/sc/source/ui/miscdlgs/optsolver.cxx +++ b/sc/source/ui/miscdlgs/optsolver.cxx @@ -425,6 +425,9 @@ void ScOptSolverDlg::EnableButtons() void ScOptSolverDlg::Close() { + if (m_xOptDlg) + m_xOptDlg->response(RET_CANCEL); + assert(!m_xOptDlg); DoClose( ScOptSolverDlgWrapper::GetChildWindowId() ); } @@ -533,13 +536,14 @@ IMPL_LINK(ScOptSolverDlg, BtnHdl, weld::Button&, rBtn, void) else if (&rBtn == m_xBtnOpt.get()) { //! move options dialog to UI lib? - auto xOptDlg = std::make_shared<ScSolverOptionsDialog>(m_xDialog.get(), maImplNames, maDescriptions, maEngine, maProperties); - weld::DialogController::runAsync(xOptDlg, [xOptDlg, this](sal_Int32 nResult){ + m_xOptDlg = std::make_shared<ScSolverOptionsDialog>(m_xDialog.get(), maImplNames, maDescriptions, maEngine, maProperties); + weld::DialogController::runAsync(m_xOptDlg, [this](sal_Int32 nResult){ if (nResult == RET_OK) { - maEngine = xOptDlg->GetEngine(); - maProperties = xOptDlg->GetProperties(); + maEngine = m_xOptDlg->GetEngine(); + maProperties = m_xOptDlg->GetProperties(); } + m_xOptDlg.reset(); }); } } diff --git a/sc/source/ui/miscdlgs/solveroptions.cxx b/sc/source/ui/miscdlgs/solveroptions.cxx index cb86ce10c31c..14914cdebc29 100644 --- a/sc/source/ui/miscdlgs/solveroptions.cxx +++ b/sc/source/ui/miscdlgs/solveroptions.cxx @@ -112,6 +112,12 @@ ScSolverOptionsDialog::ScSolverOptionsDialog(weld::Window* pParent, ScSolverOptionsDialog::~ScSolverOptionsDialog() { + if (m_xIntDialog) + m_xIntDialog->response(RET_CANCEL); + assert(!m_xIntDialog); + if (m_xValDialog) + m_xValDialog->response(RET_CANCEL); + assert(!m_xValDialog); } const uno::Sequence<beans::PropertyValue>& ScSolverOptionsDialog::GetProperties() @@ -242,13 +248,13 @@ void ScSolverOptionsDialog::EditOption() if (pStringItem->IsDouble()) { - auto xValDialog = std::make_shared<ScSolverValueDialog>(m_xDialog.get()); - xValDialog->SetOptionName(pStringItem->GetText()); - xValDialog->SetValue(pStringItem->GetDoubleValue()); - weld::DialogController::runAsync(xValDialog, [xValDialog, nEntry, pStringItem, this](sal_Int32 nResult){ + m_xValDialog = std::make_shared<ScSolverValueDialog>(m_xDialog.get()); + m_xValDialog->SetOptionName(pStringItem->GetText()); + m_xValDialog->SetValue(pStringItem->GetDoubleValue()); + weld::DialogController::runAsync(m_xValDialog, [nEntry, pStringItem, this](sal_Int32 nResult){ if (nResult == RET_OK) { - pStringItem->SetDoubleValue(xValDialog->GetValue()); + pStringItem->SetDoubleValue(m_xValDialog->GetValue()); OUString sTxt(pStringItem->GetText() + ": "); sTxt += rtl::math::doubleToUString(pStringItem->GetDoubleValue(), @@ -257,23 +263,25 @@ void ScSolverOptionsDialog::EditOption() m_xLbSettings->set_text(nEntry, sTxt, 1); } + m_xValDialog.reset(); }); } else { - auto xIntDialog = std::make_shared<ScSolverIntegerDialog>(m_xDialog.get()); - xIntDialog->SetOptionName( pStringItem->GetText() ); - xIntDialog->SetValue( pStringItem->GetIntValue() ); - weld::DialogController::runAsync(xIntDialog, [xIntDialog, nEntry, pStringItem, this](sal_Int32 nResult){ + m_xIntDialog = std::make_shared<ScSolverIntegerDialog>(m_xDialog.get()); + m_xIntDialog->SetOptionName( pStringItem->GetText() ); + m_xIntDialog->SetValue( pStringItem->GetIntValue() ); + weld::DialogController::runAsync(m_xIntDialog, [nEntry, pStringItem, this](sal_Int32 nResult){ if (nResult == RET_OK) { - pStringItem->SetIntValue(xIntDialog->GetValue()); + pStringItem->SetIntValue(m_xIntDialog->GetValue()); OUString sTxt(pStringItem->GetText() + ": "); sTxt += OUString::number(pStringItem->GetIntValue()); m_xLbSettings->set_text(nEntry, sTxt, 1); } + m_xIntDialog.reset(); }); } } |