include/sfx2/basedlgs.hxx | 4 ++-- include/sfx2/childwin.hxx | 1 + sc/source/ui/dbgui/validate.cxx | 4 ++-- sc/source/ui/inc/validate.hxx | 6 +++--- sfx2/source/appl/childwin.cxx | 8 ++++++-- sfx2/source/appl/workwin.cxx | 6 +++++- sfx2/source/dialog/basedlgs.cxx | 8 ++++---- sw/source/ui/fldui/fldtdlg.cxx | 13 ++++++++++--- sw/source/uibase/inc/fldtdlg.hxx | 2 +- 9 files changed, 34 insertions(+), 18 deletions(-)
New commits: commit 09d496b2f57e31631784bb9234ce21961cd52275 Author: Caolán McNamara <[email protected]> AuthorDate: Mon Jan 24 17:10:48 2022 +0000 Commit: Balazs Varga <[email protected]> CommitDate: Tue Jul 18 09:47:48 2023 +0200 tdf#146913 don't destroy the dialog if we just want to hide it Change-Id: Ie534aba915120d12e65aa965e5435bc7575ecb29 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128879 Tested-by: Jenkins Reviewed-by: Caolán McNamara <[email protected]> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154511 Tested-by: Gabor Kelemen <[email protected]> Reviewed-by: Balazs Varga <[email protected]> diff --git a/include/sfx2/basedlgs.hxx b/include/sfx2/basedlgs.hxx index fedaa598109c..65a781d5e598 100644 --- a/include/sfx2/basedlgs.hxx +++ b/include/sfx2/basedlgs.hxx @@ -50,7 +50,7 @@ public: // when the dialog has an associated SfxChildWin, typically for Modeless interaction virtual void ChildWinDispose() {} // called from the associated SfxChildWin dtor virtual void Close() {} // called by the SfxChildWin when the dialog is closed - virtual void EndDialog(); // called by the SfxChildWin to close the dialog + virtual void EndDialog(int nResponse); // called by the SfxChildWin to close the dialog }; class SfxModelessDialog_Impl; @@ -75,7 +75,7 @@ public: void Initialize (SfxChildWinInfo const * pInfo); bool IsClosing() const; virtual void Close() override; - virtual void EndDialog() override; + virtual void EndDialog(int nRespose) override; virtual void Activate() override; virtual void Deactivate() override; virtual void ChildWinDispose() override; diff --git a/include/sfx2/childwin.hxx b/include/sfx2/childwin.hxx index f5e64fdfedf3..d3fb36947a83 100644 --- a/include/sfx2/childwin.hxx +++ b/include/sfx2/childwin.hxx @@ -211,6 +211,7 @@ public: SAL_DLLPRIVATE void SetFactory_Impl( SfxChildWinFactory* ); }; +const int nCloseResponseToJustHide = -42; //! The Macro of the future ... #define SFX_DECL_CHILDWINDOWCONTEXT(Class) \ diff --git a/sc/source/ui/dbgui/validate.cxx b/sc/source/ui/dbgui/validate.cxx index 73e04cc44706..150cfb889df8 100644 --- a/sc/source/ui/dbgui/validate.cxx +++ b/sc/source/ui/dbgui/validate.cxx @@ -95,12 +95,12 @@ ScValidationDlg::ScValidationDlg(weld::Window* pParent, const SfxItemSet* pArgSe AddTabPage("erroralert", ScTPValidationError::Create, nullptr); } -void ScValidationDlg::EndDialog() +void ScValidationDlg::EndDialog(int nResponse) { // tdf#137215 ensure original modalality of true is restored before dialog loop ends if (m_bOwnRefHdlr) RemoveRefDlg(true); - ScValidationDlgBase::EndDialog(); + ScValidationDlgBase::EndDialog(nResponse); } ScValidationDlg::~ScValidationDlg() diff --git a/sc/source/ui/inc/validate.hxx b/sc/source/ui/inc/validate.hxx index 744de1a843bd..e2edf6bc5b30 100644 --- a/sc/source/ui/inc/validate.hxx +++ b/sc/source/ui/inc/validate.hxx @@ -176,14 +176,14 @@ public: void SetModal(bool bModal) { m_xDialog->set_modal(bModal); } - virtual void SetReference( const ScRange& rRef, ScDocument* pDoc ) override + virtual void EndDialog(int nResponse) override; + + virtual void SetReference( const ScRange& rRef, ScDocument* pDoc ) override { if ( m_pHandler && m_pSetReferenceHdl ) (m_pHandler->*m_pSetReferenceHdl)( rRef, pDoc ); } - virtual void EndDialog() override; - virtual void SetActive() override { if ( m_pHandler && m_pSetActiveHdl ) diff --git a/sfx2/source/appl/childwin.cxx b/sfx2/source/appl/childwin.cxx index a7013fa6c530..451a4d305df1 100644 --- a/sfx2/source/appl/childwin.cxx +++ b/sfx2/source/appl/childwin.cxx @@ -628,7 +628,7 @@ void SfxChildWindow::SetVisible_Impl( bool bVis ) void SfxChildWindow::Hide() { if (xController) - xController->EndDialog(); + xController->EndDialog(nCloseResponseToJustHide); else pWindow->Hide(); } @@ -640,7 +640,11 @@ void SfxChildWindow::Show( ShowFlags nFlags ) if (!xController->getDialog()->get_visible()) { weld::DialogController::runAsync(xController, - [this](sal_Int32 /*nResult*/){ xController->Close(); }); + [this](sal_Int32 nResult) { + if (nResult == nCloseResponseToJustHide) + return; + xController->Close(); + }); } } else diff --git a/sfx2/source/appl/workwin.cxx b/sfx2/source/appl/workwin.cxx index 5feb326243fc..5fba0e02079f 100644 --- a/sfx2/source/appl/workwin.cxx +++ b/sfx2/source/appl/workwin.cxx @@ -1009,7 +1009,11 @@ void SfxWorkWindow::ShowChildren_Impl() { auto xController = pCli->xController; weld::DialogController::runAsync(xController, - [=](sal_Int32 /*nResult*/){ xController->Close(); }); + [=](sal_Int32 nResult){ + if (nResult == nCloseResponseToJustHide) + return; + xController->Close(); + }); } } else diff --git a/sfx2/source/dialog/basedlgs.cxx b/sfx2/source/dialog/basedlgs.cxx index 905d27fd3a3e..187a030fab4d 100644 --- a/sfx2/source/dialog/basedlgs.cxx +++ b/sfx2/source/dialog/basedlgs.cxx @@ -169,11 +169,11 @@ SfxModelessDialogController::~SfxModelessDialogController() m_pBindings->SetActiveFrame(nullptr); } -void SfxDialogController::EndDialog() +void SfxDialogController::EndDialog(int nResponse) { if (!m_xDialog->get_visible()) return; - response(RET_CLOSE); + response(nResponse); } bool SfxModelessDialogController::IsClosing() const @@ -181,7 +181,7 @@ bool SfxModelessDialogController::IsClosing() const return m_xImpl->bClosing; } -void SfxModelessDialogController::EndDialog() +void SfxModelessDialogController::EndDialog(int nResponse) { if (m_xImpl->bClosing) return; @@ -190,7 +190,7 @@ void SfxModelessDialogController::EndDialog() // stack frame. auto aHoldSelf = shared_from_this(); m_xImpl->bClosing = true; - SfxDialogController::EndDialog(); + SfxDialogController::EndDialog(nResponse); if (!m_xImpl) return; m_xImpl->bClosing = false; diff --git a/sw/source/ui/fldui/fldtdlg.cxx b/sw/source/ui/fldui/fldtdlg.cxx index 8c1bb998fb85..6172d2bc7b8d 100644 --- a/sw/source/ui/fldui/fldtdlg.cxx +++ b/sw/source/ui/fldui/fldtdlg.cxx @@ -99,10 +99,10 @@ SwFieldDlg::~SwFieldDlg() { } -void SwFieldDlg::EndDialog() +void SwFieldDlg::EndDialog(int nResponse) { m_bClosing = true; - SfxTabDialogController::EndDialog(); + SfxTabDialogController::EndDialog(nResponse); m_bClosing = false; } @@ -110,9 +110,16 @@ void SwFieldDlg::Close() { if (m_bClosing) return; - m_pBindings->GetDispatcher()-> + const SfxPoolItem* pResult = m_pBindings->GetDispatcher()-> Execute(m_bDataBaseMode ? FN_INSERT_FIELD_DATA_ONLY : FN_INSERT_FIELD, SfxCallMode::SYNCHRON|SfxCallMode::RECORD); + if (!pResult) + { + // If Execute action did fail for whatever reason, this means that request + // to close did fail or wasn't delivered to SwTextShell::ExecField(). + // Just explicitly close dialog in this case. + SfxTabDialogController::EndDialog(RET_CLOSE); + } } void SwFieldDlg::Initialize(SfxChildWinInfo const *pInfo) diff --git a/sw/source/uibase/inc/fldtdlg.hxx b/sw/source/uibase/inc/fldtdlg.hxx index 159881ed1192..9546b99ffa0d 100644 --- a/sw/source/uibase/inc/fldtdlg.hxx +++ b/sw/source/uibase/inc/fldtdlg.hxx @@ -53,7 +53,7 @@ public: void ActivateDatabasePage(); void ShowReferencePage(); virtual void Close() override; - virtual void EndDialog() override; + virtual void EndDialog(int nResponse) override; virtual void Activate() override; };
