svx/source/form/datanavi.cxx |   13 +++++++++++++
 svx/source/inc/datanavi.hxx  |    1 +
 2 files changed, 14 insertions(+)

New commits:
commit cf48e0236e0f1f5d2479573d73ec0f5325164406
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Thu Mar 23 11:25:10 2023 +0000
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Fri Apr 7 18:43:25 2023 +0200

    tdf#154322 select the first entry of the current page by default
    
    rather than default to nothing selected, if we switch pages and then
    back to page 1 this will be selected anyway, so start off that way
    
    Change-Id: Ia684a5e44b12c984df3920f18b34c99693a2702c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149428
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/svx/source/form/datanavi.cxx b/svx/source/form/datanavi.cxx
index 5d3242e84683..635e55cdf2ab 100644
--- a/svx/source/form/datanavi.cxx
+++ b/svx/source/form/datanavi.cxx
@@ -189,6 +189,15 @@ namespace svxform
         m_xItemList->clear();
     }
 
+    void XFormsPage::SelectFirstEntry()
+    {
+        if (m_xItemList->get_iter_first(*m_xScratchIter))
+        {
+            m_xItemList->select(*m_xScratchIter);
+            ItemSelectHdl(*m_xItemList);
+        }
+    }
+
     XFormsPage::XFormsPage(weld::Container* pPage, DataNavigatorWindow* 
_pNaviWin, DataGroupType _eGroup)
         : BuilderPage(pPage, nullptr, "svx/ui/xformspage.ui", "XFormsPage")
         , m_pParent(pPage)
@@ -1316,6 +1325,10 @@ namespace svxform
 
         // load xforms models of the current document
         LoadModels();
+
+        // tdf#154322 select the first entry of the current page by default
+        if (XFormsPage* pPage = GetPage(sPageId))
+            pPage->SelectFirstEntry();
     }
 
     DataNavigatorWindow::~DataNavigatorWindow()
diff --git a/svx/source/inc/datanavi.hxx b/svx/source/inc/datanavi.hxx
index b165b9a94531..fe26bd27b407 100644
--- a/svx/source/inc/datanavi.hxx
+++ b/svx/source/inc/datanavi.hxx
@@ -237,6 +237,7 @@ namespace svxform
 
         bool                 DoMenuAction(std::string_view rMenuID);
         void                 EnableMenuItems();
+        void                 SelectFirstEntry();
 
         const OUString&      GetInstanceName() const { return m_sInstanceName; 
}
         const OUString&      GetInstanceURL() const { return m_sInstanceURL; }

Reply via email to