sw/source/ui/index/cnttab.cxx            |   71 +++++++++++++++++++------------
 sw/source/uibase/inc/swuicnttab.hxx      |    3 +
 sw/uiconfig/swriter/ui/tocentriespage.ui |    5 --
 3 files changed, 49 insertions(+), 30 deletions(-)

New commits:
commit ec062c472ad58eafbb4392241119d5b53760120c
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Tue May 24 10:33:55 2022 +0100
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Tue May 24 13:56:23 2022 +0200

    tdf#149186: Table of contents editor not showing buttons in Dutch UI
    
    an alternative approach that doesn't leave things too wide for the
    English UI
    
    Change-Id: I17d87702fcf49e593e87710bde44c1a2cba14a86
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134861
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/sw/source/ui/index/cnttab.cxx b/sw/source/ui/index/cnttab.cxx
index 3d1becdd5871..1aac737639b9 100644
--- a/sw/source/ui/index/cnttab.cxx
+++ b/sw/source/ui/index/cnttab.cxx
@@ -1789,6 +1789,7 @@ SwTOXEntryTabPage::SwTOXEntryTabPage(weld::Container* 
pPage, weld::DialogControl
     , m_xChapterInfoPB(m_xBuilder->weld_button("chapterinfo"))
     , m_xPageNoPB(m_xBuilder->weld_button("pageno"))
     , m_xHyperLinkPB(m_xBuilder->weld_button("hyperlink"))
+    , m_xFieldBox(m_xBuilder->weld_widget("fieldbox"))
     , m_xAuthFieldsLB(m_xBuilder->weld_combo_box("authfield"))
     , m_xAuthInsertPB(m_xBuilder->weld_button("insert"))
     , m_xAuthRemovePB(m_xBuilder->weld_button("remove"))
@@ -1916,8 +1917,17 @@ SwTOXEntryTabPage::SwTOXEntryTabPage(weld::Container* 
pPage, weld::DialogControl
     m_xSecondKeyLB->set_active(0);
     m_xThirdKeyLB->set_active(0);
 
-    //lock size
+    // lock size of dialog. Determine the field box's widest possible
+    // configuration (tdf#149186) before doing so.
+    int nFieldBoxWidth = 0;
+    for (int eType = TOX_CITATION; eType >= TOX_INDEX; --eType)
+    {
+        ShowHideControls(eType);
+        nFieldBoxWidth = 
std::max<int>(m_xFieldBox->get_preferred_size().Width(), nFieldBoxWidth);
+    }
+    m_xFieldBox->set_size_request(nFieldBoxWidth, -1);
     Size aPrefSize(m_xContainer->get_preferred_size());
+    m_xFieldBox->set_size_request(-1, -1);
     m_xContainer->set_size_request(aPrefSize.Width(), aPrefSize.Height());
 }
 
@@ -1997,6 +2007,39 @@ void SwTOXEntryTabPage::Reset( const SfxItemSet* )
     m_xCommaSeparatedCB->set_active(m_pCurrentForm->IsCommaSeparated());
 }
 
+void SwTOXEntryTabPage::ShowHideControls(int eType)
+{
+    bool bToxIsAuthorities = TOX_AUTHORITIES == eType;
+    bool bToxIsIndex =       TOX_INDEX == eType;
+    bool bToxIsContent =     TOX_CONTENT == eType;
+    bool bToxSupportsLinks = TOX_CONTENT == eType ||
+                             TOX_ILLUSTRATIONS == eType ||
+                             TOX_TABLES == eType ||
+                             TOX_OBJECTS == eType ||
+                             TOX_USER == eType;
+
+    //show or hide controls
+    m_xEntryNoPB->set_visible(bToxIsContent);
+    m_xHyperLinkPB->set_visible(bToxSupportsLinks);
+    m_xRelToStyleCB->set_visible(!bToxIsAuthorities);
+    m_xChapterInfoPB->set_visible(!bToxIsContent && !bToxIsAuthorities);
+    m_xEntryPB->set_visible(!bToxIsAuthorities);
+    m_xPageNoPB->set_visible(!bToxIsAuthorities);
+    m_xAuthFieldsLB->set_visible(bToxIsAuthorities);
+    m_xAuthInsertPB->set_visible(bToxIsAuthorities);
+    m_xAuthRemovePB->set_visible(bToxIsAuthorities);
+
+    m_xFormatFrame->set_visible(!bToxIsAuthorities);
+
+    m_xSortingFrame->set_visible(bToxIsAuthorities);
+    m_xSortKeyFrame->set_visible(bToxIsAuthorities);
+
+    m_xMainEntryStyleFT->set_visible(bToxIsIndex);
+    m_xMainEntryStyleLB->set_visible(bToxIsIndex);
+    m_xAlphaDelimCB->set_visible(bToxIsIndex);
+    m_xCommaSeparatedCB->set_visible(bToxIsIndex);
+}
+
 void SwTOXEntryTabPage::ActivatePage( const SfxItemSet& /*rSet*/)
 {
     SwMultiTOXTabDialog* pTOXDlg = 
static_cast<SwMultiTOXTabDialog*>(GetDialogController());
@@ -2007,12 +2050,6 @@ void SwTOXEntryTabPage::ActivatePage( const SfxItemSet& 
/*rSet*/)
     {
         bool bToxIsAuthorities = TOX_AUTHORITIES == aCurType.eType;
         bool bToxIsIndex =       TOX_INDEX == aCurType.eType;
-        bool bToxIsContent =     TOX_CONTENT == aCurType.eType;
-        bool bToxSupportsLinks = TOX_CONTENT == aCurType.eType ||
-                                 TOX_ILLUSTRATIONS == aCurType.eType ||
-                                 TOX_TABLES == aCurType.eType ||
-                                 TOX_OBJECTS == aCurType.eType ||
-                                 TOX_USER == aCurType.eType;
 
         m_xLevelLB->clear();
         for(sal_uInt16 i = 1; i < m_pCurrentForm->GetFormMax(); i++)
@@ -2075,25 +2112,7 @@ void SwTOXEntryTabPage::ActivatePage( const SfxItemSet& 
/*rSet*/)
         m_xLevelLB->select(bToxIsIndex ? 1 : 0);
 
         //show or hide controls
-        m_xEntryNoPB->set_visible(bToxIsContent);
-        m_xHyperLinkPB->set_visible(bToxSupportsLinks);
-        m_xRelToStyleCB->set_visible(!bToxIsAuthorities);
-        m_xChapterInfoPB->set_visible(!bToxIsContent && !bToxIsAuthorities);
-        m_xEntryPB->set_visible(!bToxIsAuthorities);
-        m_xPageNoPB->set_visible(!bToxIsAuthorities);
-        m_xAuthFieldsLB->set_visible(bToxIsAuthorities);
-        m_xAuthInsertPB->set_visible(bToxIsAuthorities);
-        m_xAuthRemovePB->set_visible(bToxIsAuthorities);
-
-        m_xFormatFrame->set_visible(!bToxIsAuthorities);
-
-        m_xSortingFrame->set_visible(bToxIsAuthorities);
-        m_xSortKeyFrame->set_visible(bToxIsAuthorities);
-
-        m_xMainEntryStyleFT->set_visible(bToxIsIndex);
-        m_xMainEntryStyleLB->set_visible(bToxIsIndex);
-        m_xAlphaDelimCB->set_visible(bToxIsIndex);
-        m_xCommaSeparatedCB->set_visible(bToxIsIndex);
+        ShowHideControls(aCurType.eType);
     }
     aLastTOXType = aCurType;
 
diff --git a/sw/source/uibase/inc/swuicnttab.hxx 
b/sw/source/uibase/inc/swuicnttab.hxx
index 2433c0faa307..359e58dc62eb 100644
--- a/sw/source/uibase/inc/swuicnttab.hxx
+++ b/sw/source/uibase/inc/swuicnttab.hxx
@@ -324,6 +324,7 @@ class SwTOXEntryTabPage final : public SfxTabPage
     std::unique_ptr<weld::Button> m_xChapterInfoPB;
     std::unique_ptr<weld::Button> m_xPageNoPB;
     std::unique_ptr<weld::Button> m_xHyperLinkPB;
+    std::unique_ptr<weld::Widget> m_xFieldBox;
     std::unique_ptr<weld::ComboBox> m_xAuthFieldsLB;
     std::unique_ptr<weld::Button> m_xAuthInsertPB;
     std::unique_ptr<weld::Button> m_xAuthRemovePB;
@@ -384,6 +385,8 @@ class SwTOXEntryTabPage final : public SfxTabPage
     void OnModify(bool bAllLevels);
     DECL_LINK(ModifyClickHdl, weld::Toggleable&, void);
 
+    void ShowHideControls(int eType);
+
 public:
     SwTOXEntryTabPage(weld::Container* pPage, weld::DialogController* 
pController, const SfxItemSet& rAttrSet);
     virtual ~SwTOXEntryTabPage() override;
diff --git a/sw/uiconfig/swriter/ui/tocentriespage.ui 
b/sw/uiconfig/swriter/ui/tocentriespage.ui
index 9d951f2d201d..5d522dfb51ec 100644
--- a/sw/uiconfig/swriter/ui/tocentriespage.ui
+++ b/sw/uiconfig/swriter/ui/tocentriespage.ui
@@ -513,7 +513,7 @@
                       </packing>
                     </child>
                     <child>
-                      <object class="GtkBox" id="box2">
+                      <object class="GtkBox" id="fieldbox">
                         <property name="visible">True</property>
                         <property name="can-focus">False</property>
                         <property name="margin-bottom">6</property>
@@ -544,7 +544,6 @@
                             <child>
                               <object class="GtkButton" id="insert">
                                 <property name="label" translatable="yes" 
context="tocentriespage|insert">_Insert</property>
-                                <property name="visible">True</property>
                                 <property name="can-focus">True</property>
                                 <property 
name="receives-default">True</property>
                                 <property name="no-show-all">True</property>
@@ -564,7 +563,6 @@
                             <child>
                               <object class="GtkButton" id="remove">
                                 <property name="label" translatable="yes" 
context="tocentriespage|remove">_Remove</property>
-                                <property name="visible">True</property>
                                 <property name="can-focus">True</property>
                                 <property 
name="receives-default">True</property>
                                 <property name="no-show-all">True</property>
@@ -584,7 +582,6 @@
                             <child>
                               <object class="GtkButton" id="chapterno">
                                 <property name="label" translatable="yes" 
context="tocentriespage|chapterno">Chapter No.</property>
-                                <property name="visible">True</property>
                                 <property name="can-focus">True</property>
                                 <property 
name="receives-default">True</property>
                                 <property name="no-show-all">True</property>

Reply via email to