sfx2/source/dialog/tabdlg.cxx |   10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

New commits:
commit b428c42d0dadc93b33be44107a07ededc6f0fb9e
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Thu Jul 31 14:05:20 2025 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Thu Jul 31 16:47:10 2025 +0200

    sfx2: Don't try to preselect non-existing tab page
    
    When trying to set the initially active page in a tab
    dialog to the one that was remembered, verify that
    a tab with the given ID actually exists.
    
    Only try to set it as the active one if that is the
    case, otherwise fall back to activating the first
    tab, as happens when none has been remembered.
    
    One case where this is relevant are dialogs that
    don't always show up with the same set of tabs
    available, like the chart attributes one.
    
    Without this commit in place, the following scenario
    would trigger a
    
        warn:sfx.dialog:483586:483586:sfx2/source/dialog/tabdlg.cxx:537: Tab 
Page ID '' not known, this is pretty serious and needs investigation
    
    warning and leave the dialog with no tab initially
    selected for the VCL (SalInstanceNotebook) case,
    e.g. when using the gen or qt6 VCL plugins:
    
    * start Writer
    * insert chart (using the "Insert Chart" toolbar item)
    * double-click on the first "bar" in the chart to open
      the "Data Series"   dialog
    * activate the "Options" tab
    * close the dialog
    * double-click on an "empty" area between two bars to
      open the "Chart Wall" dialog
    
    Since the "Chart Wall" dialog doesn't have an "Options" tab,
    preselecting it would fail, leaving the dialog with no tab page
    preselected.  For all other 4 tabs ("Area", "Transparency",
    "Border", "Color Palette"), the corresponding tab would be
    preselected, as both, the "Data Series" and the "Options" tab have
    such tabs (using the same ID).
    
    Change-Id: Ia25d31ca5953c3f7611defeba828a6b312766285
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/188656
    Reviewed-by: Heiko Tietze <heiko.tie...@documentfoundation.org>
    Tested-by: Jenkins

diff --git a/sfx2/source/dialog/tabdlg.cxx b/sfx2/source/dialog/tabdlg.cxx
index be47326cbda1..a93d32016298 100644
--- a/sfx2/source/dialog/tabdlg.cxx
+++ b/sfx2/source/dialog/tabdlg.cxx
@@ -1031,11 +1031,15 @@ void SfxTabDialogController::Start_Impl()
     // something that the sort dialog in calc depends on
     if (m_sAppPageId.isEmpty())
     {
+        int nInitialPage = 0;
         SvtViewOptions aDlgOpt(EViewType::TabDialog, m_xDialog->get_help_id());
         if (aDlgOpt.Exists())
-            m_xTabCtrl->set_current_page(aDlgOpt.GetPageID());
-        else
-            m_xTabCtrl->set_current_page(0);
+        {
+            const int nIndex = m_xTabCtrl->get_page_index(aDlgOpt.GetPageID());
+            if (nIndex >= 0)
+                nInitialPage = nIndex;
+        }
+        m_xTabCtrl->set_current_page(nInitialPage);
     }
 
     ActivatePage(m_xTabCtrl->get_current_page_ident());

Reply via email to