vcl/inc/wizdlg.hxx                   |    1 
 vcl/jsdialog/jsdialogbuilder.cxx     |    7 ++++
 vcl/source/control/roadmapwizard.cxx |   56 +++++------------------------------
 vcl/source/control/wizardmachine.cxx |    7 ++++
 vcl/source/control/wizimpldata.hxx   |   47 +++++++++++++++++++++++++++++
 5 files changed, 71 insertions(+), 47 deletions(-)

New commits:
commit 88639cdb35ff243263b04dacc794725b9e7e2703
Author:     Gülşah Köse <[email protected]>
AuthorDate: Fri Nov 10 11:32:34 2023 +0300
Commit:     Szymon Kłos <[email protected]>
CommitDate: Thu Nov 23 09:39:10 2023 +0100

    Online: Fix Wizard Help button
    
    Wizard dialog help button's response is not initialized if we don't run
    any other dialogs. It should be initialized in RoadmapWizard itself.
    
    response_help function can not detect wizard dialog's Help button. So we
    should handle this case in function too.
    
    Signed-off-by: Gülşah Köse <[email protected]>
    Change-Id: If80a2e54dcbf5eaa3d0e07347d12296ace5c9569
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159282
    Reviewed-by: Szymon Kłos <[email protected]>
    Tested-by: Jenkins
    (cherry picked from commit a6fffac0336fa7d5843f73139ec88a5eef8269d5)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159756
    Tested-by: Jenkins CollaboraOffice <[email protected]>

diff --git a/vcl/inc/wizdlg.hxx b/vcl/inc/wizdlg.hxx
index 71da672a356e..a36619f2e30c 100644
--- a/vcl/inc/wizdlg.hxx
+++ b/vcl/inc/wizdlg.hxx
@@ -129,6 +129,7 @@ namespace vcl
 
         void                AddButton( Button* pButton, tools::Long nOffset = 
0 );
         void                RemoveButton( Button* pButton );
+        void                AddButtonResponse( Button* pButton, int response);
 
         void                SetPageSizePixel( const Size& rSize ) { maPageSize 
= rSize; }
         const Size&         GetPageSizePixel() const { return maPageSize; }
diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx
index 3cdf403c6242..c2cea61a6197 100644
--- a/vcl/jsdialog/jsdialogbuilder.cxx
+++ b/vcl/jsdialog/jsdialogbuilder.cxx
@@ -57,7 +57,14 @@ void response_help(vcl::Window* pWindow)
     vcl::Window* pButtonWindow = pDialog->get_widget_for_response(RET_HELP);
     ::Button* pButton = dynamic_cast<::Button*>(pButtonWindow);
     if (!pButton)
+    {
+        // Is it a wizard dialog?
+        vcl::RoadmapWizard* pWizard = 
dynamic_cast<vcl::RoadmapWizard*>(pWindow);
+        if (!pWizard || !pWizard->m_pHelp)
+            return;
+        pWizard->m_pHelp->Click();
         return;
+    }
 
     pButton->Click();
 }
diff --git a/vcl/source/control/roadmapwizard.cxx 
b/vcl/source/control/roadmapwizard.cxx
index 0aef0d00527e..0b3834d61237 100644
--- a/vcl/source/control/roadmapwizard.cxx
+++ b/vcl/source/control/roadmapwizard.cxx
@@ -28,59 +28,12 @@
 #include <wizdlg.hxx>
 
 #include <vector>
-#include <map>
-#include <set>
 
 #include "wizimpldata.hxx"
 #include <uiobject-internal.hxx>
 
 namespace vcl
 {
-    using namespace RoadmapWizardTypes;
-
-    namespace
-    {
-        typedef ::std::set< WizardTypes::WizardState > StateSet;
-
-        typedef ::std::map<
-                    PathId,
-                    WizardPath
-                > Paths;
-
-        typedef ::std::map<
-                    WizardTypes::WizardState,
-                    ::std::pair<
-                        OUString,
-                        RoadmapPageFactory
-                    >
-                > StateDescriptions;
-    }
-
-    struct RoadmapWizardImpl
-    {
-        ScopedVclPtr<ORoadmap> pRoadmap;
-        Paths               aPaths;
-        PathId              nActivePath;
-        StateDescriptions   aStateDescriptors;
-        StateSet            aDisabledStates;
-        bool                bActivePathIsDefinite;
-
-        RoadmapWizardImpl()
-            :pRoadmap( nullptr )
-            ,nActivePath( -1 )
-            ,bActivePathIsDefinite( false )
-        {
-        }
-
-        /// returns the index of the current state in given path, or -1
-        static sal_Int32 getStateIndexInPath( WizardTypes::WizardState 
_nState, const WizardPath& _rPath );
-        /// returns the index of the current state in the path with the given 
id, or -1
-        sal_Int32 getStateIndexInPath( WizardTypes::WizardState _nState, 
PathId _nPathId );
-        /// returns the index of the first state in which the two given paths 
differ
-        static sal_Int32 getFirstDifferentIndex( const WizardPath& _rLHS, 
const WizardPath& _rRHS );
-    };
-
-
     sal_Int32 RoadmapWizardImpl::getStateIndexInPath( WizardTypes::WizardState 
_nState, const WizardPath& _rPath )
     {
         sal_Int32 nStateIndexInPath = 0;
@@ -818,6 +771,15 @@ namespace vcl
         sal_Int32 nStartPos = sDialogId.lastIndexOf('/');
         nStartPos = nStartPos >= 0 ? nStartPos + 1 : 0;
         rJsonWriter.put("dialogid", sDialogId.copy(nStartPos));
+        {
+            auto aResponses = rJsonWriter.startArray("responses");
+            for (const auto& rResponse : m_xRoadmapImpl->maResponses)
+            {
+                auto aResponse = rJsonWriter.startStruct();
+                rJsonWriter.put("id", rResponse.first->get_id());
+                rJsonWriter.put("response", rResponse.second);
+            }
+        }
 
         vcl::Window* pFocusControl = GetFirstControlForFocus();
         if (pFocusControl)
diff --git a/vcl/source/control/wizardmachine.cxx 
b/vcl/source/control/wizardmachine.cxx
index 0071ecc089a0..2a61526261ef 100644
--- a/vcl/source/control/wizardmachine.cxx
+++ b/vcl/source/control/wizardmachine.cxx
@@ -303,6 +303,11 @@ namespace vcl
         return nullptr;
     }
 
+    void RoadmapWizard::AddButtonResponse( Button* pButton, int response)
+    {
+        m_xRoadmapImpl->maResponses[pButton] = response;
+    }
+
     void RoadmapWizard::implConstruct( const WizardButtonFlags _nButtonFlags )
     {
         m_xWizardImpl->sTitleBase = GetText();
@@ -314,6 +319,8 @@ namespace vcl
             m_pHelp= VclPtr<HelpButton>::Create(this, WB_TABSTOP);
             m_pHelp->SetSizePixel(LogicToPixel(Size(50, 14), 
MapMode(MapUnit::MapAppFont)));
             m_pHelp->Show();
+            m_pHelp->set_id("help");
+            AddButtonResponse(m_pHelp, RET_HELP);
             AddButton( m_pHelp, WIZARDDIALOG_BUTTON_STDOFFSET_X);
         }
 
diff --git a/vcl/source/control/wizimpldata.hxx 
b/vcl/source/control/wizimpldata.hxx
index 7565cb0897e4..9502e8ba4e81 100644
--- a/vcl/source/control/wizimpldata.hxx
+++ b/vcl/source/control/wizimpldata.hxx
@@ -20,6 +20,9 @@
 #pragma once
 
 #include <stack>
+#include <map>
+#include <set>
+#include <vcl/toolkit/roadmap.hxx>
 
 struct WizPageData
 {
@@ -56,6 +59,50 @@ namespace vcl
         {
         }
     };
+
+    using namespace RoadmapWizardTypes;
+    namespace
+    {
+        typedef ::std::set< WizardTypes::WizardState > StateSet;
+
+        typedef ::std::map<
+                    PathId,
+                    WizardPath
+                > Paths;
+
+        typedef ::std::map<
+                    WizardTypes::WizardState,
+                    ::std::pair<
+                        OUString,
+                        RoadmapPageFactory
+                    >
+                > StateDescriptions;
+    }
+
+    struct RoadmapWizardImpl
+    {
+        ScopedVclPtr<ORoadmap> pRoadmap;
+        std::map<VclPtr<vcl::Window>, short> maResponses;
+        Paths               aPaths;
+        PathId              nActivePath;
+        StateDescriptions   aStateDescriptors;
+        StateSet            aDisabledStates;
+        bool                bActivePathIsDefinite;
+
+        RoadmapWizardImpl()
+            :pRoadmap( nullptr )
+            ,nActivePath( -1 )
+            ,bActivePathIsDefinite( false )
+        {
+        }
+
+        /// returns the index of the current state in given path, or -1
+        static sal_Int32 getStateIndexInPath( WizardTypes::WizardState 
_nState, const WizardPath& _rPath );
+        /// returns the index of the current state in the path with the given 
id, or -1
+        sal_Int32 getStateIndexInPath( WizardTypes::WizardState _nState, 
PathId _nPathId );
+        /// returns the index of the first state in which the two given paths 
differ
+        static sal_Int32 getFirstDifferentIndex( const WizardPath& _rLHS, 
const WizardPath& _rRHS );
+    };
 }   // namespace svt
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Reply via email to