include/sfx2/childwin.hxx       |    2 ++
 sc/source/ui/dbgui/validate.cxx |    8 +++++++-
 sc/source/ui/inc/validate.hxx   |    2 ++
 sfx2/source/appl/childwin.cxx   |   21 +++++++++++++++------
 4 files changed, 26 insertions(+), 7 deletions(-)

New commits:
commit e103944cb7a95fe648d5d3fb53581b32bb0230d6
Author:     Balazs Varga <[email protected]>
AuthorDate: Mon Jul 3 19:56:43 2023 +0200
Commit:     Balazs Varga <[email protected]>
CommitDate: Tue Jul 18 09:48:17 2023 +0200

    tdf#155708 Fix validity dialog closes when moving focus to another window
    
    Do not close Validation window if click on another Calc sheet.
    
    (cherry picked from commit a5c61b143d53bb10430b8a486874856c16a2d86c)
    and
    (cherry picked from commit efaa065eb7053954242c83760f897e7dba2e9fe8)
    
    Change-Id: I75569cbb91ebd445ac57f7a52d914297c21349e3
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153930
    Tested-by: Balazs Varga <[email protected]>
    Reviewed-by: Balazs Varga <[email protected]>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154512
    Tested-by: Gabor Kelemen <[email protected]>

diff --git a/include/sfx2/childwin.hxx b/include/sfx2/childwin.hxx
index d3fb36947a83..485aa70bbd3e 100644
--- a/include/sfx2/childwin.hxx
+++ b/include/sfx2/childwin.hxx
@@ -212,6 +212,8 @@ public:
 };
 
 const int nCloseResponseToJustHide = -42;
+// sc.hrc --> SID_VALIDITY_REFERENCE: 26161
+const sal_uInt16 nScValidityWindowSlotID = 26161;
 
 //! 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 150cfb889df8..c9fbd5501a39 100644
--- a/sc/source/ui/dbgui/validate.cxx
+++ b/sc/source/ui/dbgui/validate.cxx
@@ -97,7 +97,13 @@ ScValidationDlg::ScValidationDlg(weld::Window* pParent, 
const SfxItemSet* pArgSe
 
 void ScValidationDlg::EndDialog(int nResponse)
 {
-    // tdf#137215 ensure original modalality of true is restored before dialog 
loop ends
+    // tdf#155708 - do not close, just hide validation window if we click in 
another sheet
+    if (nResponse == nCloseResponseToJustHide && getDialog()->get_visible())
+    {
+        getDialog()->hide();
+        return;
+    }
+    // tdf#137215 ensure original modality of true is restored before dialog 
loop ends
     if (m_bOwnRefHdlr)
         RemoveRefDlg(true);
     ScValidationDlgBase::EndDialog(nResponse);
diff --git a/sc/source/ui/inc/validate.hxx b/sc/source/ui/inc/validate.hxx
index e2edf6bc5b30..9ee85231f609 100644
--- a/sc/source/ui/inc/validate.hxx
+++ b/sc/source/ui/inc/validate.hxx
@@ -154,6 +154,8 @@ class ScValidationDlg
     bool    m_bOwnRefHdlr:1;
     bool    m_bRefInputting:1;
 
+    const int nCloseResponseToJustHide = -42;
+
     std::unique_ptr<weld::Container> m_xHBox;
 
     bool    EnterRefStatus();
diff --git a/sfx2/source/appl/childwin.cxx b/sfx2/source/appl/childwin.cxx
index 451a4d305df1..05257229fd89 100644
--- a/sfx2/source/appl/childwin.cxx
+++ b/sfx2/source/appl/childwin.cxx
@@ -639,12 +639,21 @@ void SfxChildWindow::Show( ShowFlags nFlags )
     {
         if (!xController->getDialog()->get_visible())
         {
-            weld::DialogController::runAsync(xController,
-                [this](sal_Int32 nResult) {
-                    if (nResult == nCloseResponseToJustHide)
-                        return;
-                    xController->Close();
-                });
+            if (nScValidityWindowSlotID == GetType())
+            {
+                // tdf#155708 - do not run a new (Async) validation window,
+                // because we already have one in sync mode, just show the 
running one
+                xController->getDialog()->show();
+            }
+            else
+            {
+                weld::DialogController::runAsync(xController,
+                    [this](sal_Int32 nResult) {
+                        if (nResult == nCloseResponseToJustHide)
+                            return;
+                        xController->Close();
+                    });
+            }
         }
     }
     else

Reply via email to