summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2019-12-13 13:31:57 +0000
committerCaolán McNamara <caolanm@redhat.com>2019-12-13 17:51:33 +0100
commita54b3e8b8b7bf063117eaed19a590ce6c8a14e07 (patch)
tree8f757b61daddc8f8f2ebb26e5d226ed5695646c8
parent418b6589752525a9937089a73f0e116109b27657 (diff)
Resolves: tdf#128077 cancel goalseek subdialogs on forced removal
Change-Id: Ifd0d81d8b5e1b6bea68e74be1cebf082e24d6dde Reviewed-on: https://gerrit.libreoffice.org/85114 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--sc/source/ui/inc/solvrdlg.hxx2
-rw-r--r--sc/source/ui/miscdlgs/solvrdlg.cxx49
2 files changed, 20 insertions, 31 deletions
diff --git a/sc/source/ui/inc/solvrdlg.hxx b/sc/source/ui/inc/solvrdlg.hxx
index 3fcadd881e0a..66a031fbd041 100644
--- a/sc/source/ui/inc/solvrdlg.hxx
+++ b/sc/source/ui/inc/solvrdlg.hxx
@@ -72,6 +72,8 @@ private:
std::unique_ptr<weld::Button> m_xBtnOk;
std::unique_ptr<weld::Button> m_xBtnCancel;
+ std::shared_ptr<weld::MessageDialog> m_xMessageBox;
+
void Init();
bool CheckTargetValue( const OUString& rStrVal );
void RaiseError( ScSolverErr eError );
diff --git a/sc/source/ui/miscdlgs/solvrdlg.cxx b/sc/source/ui/miscdlgs/solvrdlg.cxx
index 6608ea8e9488..729d73fee034 100644
--- a/sc/source/ui/miscdlgs/solvrdlg.cxx
+++ b/sc/source/ui/miscdlgs/solvrdlg.cxx
@@ -31,17 +31,6 @@
#include <sc.hrc>
#include <solvrdlg.hxx>
-namespace
-{
- void lclErrorDialog(weld::Window* pParent, const OUString& rString, const std::function<void(sal_Int32)>& func)
- {
- std::shared_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(pParent,
- VclMessageType::Warning, VclButtonsType::Ok,
- rString));
- xBox->runAsync(xBox, func);
- }
-}
-
ScSolverDlg::ScSolverDlg( SfxBindings* pB, SfxChildWindow* pCW, weld::Window* pParent,
ScDocument* pDocument,
const ScAddress& aCursorPos )
@@ -76,6 +65,9 @@ ScSolverDlg::ScSolverDlg( SfxBindings* pB, SfxChildWindow* pCW, weld::Window* pP
ScSolverDlg::~ScSolverDlg()
{
+ if (m_xMessageBox)
+ m_xMessageBox->response(RET_CANCEL);
+ assert(!m_xMessageBox);
}
void ScSolverDlg::Init()
@@ -152,36 +144,31 @@ void ScSolverDlg::SetReference( const ScRange& rRef, ScDocument& rDocP )
void ScSolverDlg::RaiseError( ScSolverErr eError )
{
- switch ( eError )
+ OUString sMessage;
+
+ switch (eError)
{
case SOLVERR_NOFORMULA:
- lclErrorDialog(m_xDialog.get(), errMsgNoFormula,
- [this](sal_Int32 /*nResult*/) {
- m_xEdFormulaCell->GrabFocus();
- });
+ sMessage = errMsgNoFormula;
break;
-
case SOLVERR_INVALID_FORMULA:
- lclErrorDialog(m_xDialog.get(), errMsgInvalidForm,
- [this](sal_Int32 /*nResult*/) {
- m_xEdFormulaCell->GrabFocus();
- });
+ sMessage = errMsgInvalidForm;
break;
-
case SOLVERR_INVALID_VARIABLE:
- lclErrorDialog(m_xDialog.get(), errMsgInvalidVar,
- [this](sal_Int32 /*nResult*/) {
- m_xEdVariableCell->GrabFocus();
- });
+ sMessage = errMsgInvalidVar;
break;
-
case SOLVERR_INVALID_TARGETVALUE:
- lclErrorDialog(m_xDialog.get(), errMsgInvalidVal,
- [this](sal_Int32 /*nResult*/) {
- m_xEdTargetVal->grab_focus();
- });
+ sMessage = errMsgInvalidVal;
break;
}
+
+ m_xMessageBox.reset(Application::CreateMessageDialog(m_xDialog.get(),
+ VclMessageType::Warning, VclButtonsType::Ok,
+ sMessage));
+ m_xMessageBox->runAsync(m_xMessageBox, [this](sal_Int32 /*nResult*/) {
+ m_xEdTargetVal->grab_focus();
+ m_xMessageBox.reset();
+ });
}
bool ScSolverDlg::IsRefInputMode() const