Related: tdf#155708 Clean-up - Fix validity dialog closes

Do not close Validation window if click on another Calc sheet.

Follow-up of commits:
1 - a5c61b143d53bb10430b8a486874856c16a2d86c
2 - efaa065eb7053954242c83760f897e7dba2e9fe8

Change-Id: I5352ee869f3e8a93b49abec863089f57cdf0aeba
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154369
Tested-by: Jenkins
Reviewed-by: Balazs Varga <balazs.varga.extern@allotropia.de>
(cherry picked from commit 396cbd8cd017f883946f1a0be7285c89f84f40af)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154704
Tested-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
diff --git a/include/sfx2/basedlgs.hxx b/include/sfx2/basedlgs.hxx
index f87fe22..e182b9a 100644
--- a/include/sfx2/basedlgs.hxx
+++ b/include/sfx2/basedlgs.hxx
@@ -49,6 +49,7 @@ public:
    virtual void ChildWinDispose() {} // called from the associated SfxChildWin dtor
    virtual void Close(); // called by the SfxChildWin when the dialog is closed
    virtual void EndDialog(int nResponse); // called by the SfxChildWin to close the dialog
    virtual bool CloseOnHide() const { return true; } // called from ScValidationDlg
};

class SfxModelessDialog_Impl;
diff --git a/include/sfx2/childwin.hxx b/include/sfx2/childwin.hxx
index 6e4b200..57c2369 100644
--- a/include/sfx2/childwin.hxx
+++ b/include/sfx2/childwin.hxx
@@ -156,8 +156,6 @@ public:
};

const int nCloseResponseToJustHide = -42;
// sc.hrc --> SID_VALIDITY_REFERENCE: 26161
const sal_uInt16 nScValidityWindowSlotID = 26161;

#define SFX_DECL_CHILDWINDOW(Class) \
    public  :   \
diff --git a/sc/source/ui/inc/validate.hxx b/sc/source/ui/inc/validate.hxx
index c58ae53..4a3a2e8 100644
--- a/sc/source/ui/inc/validate.hxx
+++ b/sc/source/ui/inc/validate.hxx
@@ -180,6 +180,8 @@ public:

    virtual void EndDialog(int nResponse) override;

    virtual bool CloseOnHide() const override { return false; }

    virtual void            SetReference( const ScRange& rRef, ScDocument& rDoc ) override
    {
        if ( m_pHandler && m_pSetReferenceHdl )
diff --git a/sfx2/source/appl/childwin.cxx b/sfx2/source/appl/childwin.cxx
index 633c33b..6bf2814 100644
--- a/sfx2/source/appl/childwin.cxx
+++ b/sfx2/source/appl/childwin.cxx
@@ -522,7 +522,7 @@ void SfxChildWindow::Show( ShowFlags nFlags )
    {
        if (!xController->getDialog()->get_visible())
        {
            if (nScValidityWindowSlotID == GetType())
            if (!xController->CloseOnHide())
            {
                // tdf#155708 - do not run a new (Async) validation window,
                // because we already have one in sync mode, just show the running one