sw/source/ui/frmdlg/column.cxx       |   87 ++++++++++++++++++-----------------
 sw/source/uibase/inc/column.hxx      |   22 +-------
 sw/uiconfig/swriter/ui/columnpage.ui |   40 ++++++++++------
 3 files changed, 75 insertions(+), 74 deletions(-)

New commits:
commit e7e83d60e6a07eaed36a9d8d166f127cccce56f6
Author:     Michael Weghorn <[email protected]>
AuthorDate: Wed Feb 4 17:16:34 2026 +0100
Commit:     Michael Weghorn <[email protected]>
CommitDate: Thu Feb 5 13:15:10 2026 +0100

    sw: Use weld::IconView in SwColumnPage
    
    Replace the use of a custom ValueSet subclass
    ColumnValueSet with a weld::IconView, for more
    consistency with other platform/toolkit
    widgets and to reduce custom logic.
    
    This is used in the "Columns" tab page of Writer's
    "Format" -> "Page Style" dialog.
    
    Change-Id: Iaa17d93d25fad6c5d25e7c90e24dddd428939abb
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/198738
    Reviewed-by: Michael Weghorn <[email protected]>
    Tested-by: Jenkins

diff --git a/sw/source/ui/frmdlg/column.cxx b/sw/source/ui/frmdlg/column.cxx
index ed703b5c1cf2..dba3a2c41230 100644
--- a/sw/source/ui/frmdlg/column.cxx
+++ b/sw/source/ui/frmdlg/column.cxx
@@ -38,6 +38,8 @@
 #include <vcl/fieldvalues.hxx>
 #include <vcl/settings.hxx>
 #include <vcl/svapp.hxx>
+#include <vcl/virdev.hxx>
+#include <vcl/weld/IconView.hxx>
 
 #include <swmodule.hxx>
 
@@ -376,6 +378,7 @@ SwColumnPage::SwColumnPage(weld::Container* pPage, 
weld::DialogController* pCont
     , m_bFrame(false)
     , m_bHtmlMode(false)
     , m_bLockUpdate(false)
+    , m_xDefaultIconView(m_xBuilder->weld_icon_view(u"iconview"_ustr))
     , m_xCLNrEdt(m_xBuilder->weld_spin_button(u"colsnf"_ustr))
     , m_xBalanceColsCB(m_xBuilder->weld_check_button(u"balance"_ustr))
     , m_xBtnBack(m_xBuilder->weld_button(u"back"_ustr))
@@ -402,7 +405,6 @@ SwColumnPage::SwColumnPage(weld::Container* pPage, 
weld::DialogController* pCont
     , m_xEd3(new 
SwPercentField(m_xBuilder->weld_metric_spin_button(u"width3mf"_ustr, 
FieldUnit::CM)))
     , m_xDistEd1(new 
SwPercentField(m_xBuilder->weld_metric_spin_button(u"spacing1mf"_ustr, 
FieldUnit::CM)))
     , m_xDistEd2(new 
SwPercentField(m_xBuilder->weld_metric_spin_button(u"spacing2mf"_ustr, 
FieldUnit::CM)))
-    , m_xDefaultVS(new weld::CustomWeld(*m_xBuilder, u"valueset"_ustr, 
m_aDefaultVS))
     , m_xPgeExampleWN(new weld::CustomWeld(*m_xBuilder, u"pageexample"_ustr, 
m_aPgeExampleWN))
     , m_xFrameExampleWN(new weld::CustomWeld(*m_xBuilder, 
u"frameexample"_ustr, m_aFrameExampleWN))
     , m_xApplyToFT(m_xBuilder->weld_label(u"applytoft"_ustr))
@@ -420,10 +422,7 @@ SwColumnPage::SwColumnPage(weld::Container* pPage, 
weld::DialogController* pCont
 
     SetExchangeSupport();
 
-    m_aDefaultVS.SetColCount(5);
-
     for (int i = 0; i < 5; ++i)
-    //Set accessible name one by one
     {
         OUString aItemText;
         switch( i )
@@ -444,10 +443,17 @@ SwColumnPage::SwColumnPage(weld::Container* pPage, 
weld::DialogController* pCont
                 aItemText =  SwResId( STR_COLUMN_VALUESET_ITEM4 );
                 break;
         }
-        m_aDefaultVS.InsertItem( i + 1, aItemText, i );
+
+        const OUString* pNullIconName = nullptr;
+        m_xDefaultIconView->insert(i, nullptr, nullptr, pNullIconName, 
nullptr);
+        m_xDefaultIconView->set_item_tooltip_text(i, aItemText);
+        m_xDefaultIconView->set_item_accessible_name(i, aItemText);
+
+        ScopedVclPtr<VirtualDevice> pDev = CreateIconViewImage(i);
+        m_xDefaultIconView->set_image(i, *pDev);
     }
 
-    m_aDefaultVS.SetSelectHdl(LINK(this, SwColumnPage, SetDefaultsHdl));
+    m_xDefaultIconView->connect_selection_changed(LINK(this, SwColumnPage, 
SetDefaultsHdl));
 
     Link<weld::SpinButton&,void> aCLNrLk = LINK(this, SwColumnPage, ColModify);
     m_xCLNrEdt->connect_value_changed(aCLNrLk);
@@ -916,7 +922,7 @@ void SwColumnPage::ColModify(bool bForceColReset)
         return;
 
     if (!bForceColReset)
-        m_aDefaultVS.SetNoSelection();
+        m_xDefaultIconView->unselect_all();
     tools::Long nDist = static_cast< tools::Long 
>(m_xDistEd1->DenormalizePercent(m_xDistEd1->get_value(FieldUnit::TWIP)));
     m_xColMgr->SetCount(m_nCols, o3tl::narrowing<sal_uInt16>(nDist));
     for(sal_uInt16 i = 0; i < m_nCols; i++)
@@ -1258,12 +1264,16 @@ DeactivateRC SwColumnPage::DeactivatePage(SfxItemSet 
*_pSet)
     return DeactivateRC::LeavePage;
 }
 
-IMPL_LINK(SwColumnPage, SetDefaultsHdl, ValueSet *, pVS, void)
+IMPL_LINK_NOARG(SwColumnPage, SetDefaultsHdl, weld::IconView&, void)
 {
-    const sal_uInt16 nItem = pVS->GetSelectedItemId();
-    if( nItem < 4 )
+    std::unique_ptr<weld::TreeIter> pSelected = 
m_xDefaultIconView->get_selected();
+    if (!pSelected)
+        return;
+
+    const int nIndex = 
m_xDefaultIconView->get_iter_index_in_parent(*pSelected);
+    if (nIndex < 3)
     {
-        m_xCLNrEdt->set_value(nItem);
+        m_xCLNrEdt->set_value(nIndex + 1);
         m_xAutoWidthBox->set_active(true);
         m_xDistEd1->set_value(50, FieldUnit::CM);
         ColModify(/*bForceColReset=*/true);
@@ -1277,7 +1287,7 @@ IMPL_LINK(SwColumnPage, SetDefaultsHdl, ValueSet *, pVS, 
void)
         ColModify(/*bForceColReset=*/true);
         // now set the width ratio to 2 : 1 or 1 : 2 respectively
         const tools::Long nSmall = static_cast< tools::Long 
>(m_xColMgr->GetActualSize() / 3);
-        if(nItem == 4)
+        if (nIndex == 3)
         {
             m_xEd2->set_value(m_xEd2->NormalizePercent(nSmall), 
FieldUnit::TWIP);
             m_pModifiedField = m_xEd2.get();
@@ -1307,20 +1317,22 @@ void SwColumnPage::SetInSection(bool bSet)
     m_xTextDirectionLB->set_visible(bSet);
 }
 
-void ColumnValueSet::UserDraw(const UserDrawEvent& rUDEvt)
+VclPtr<VirtualDevice> SwColumnPage::CreateIconViewImage(int nIndex)
 {
-    vcl::RenderContext* pDev = rUDEvt.GetRenderContext();
     const StyleSettings& rStyleSettings = 
Application::GetSettings().GetStyleSettings();
 
-    tools::Rectangle aRect = rUDEvt.GetRect();
-    const sal_uInt16 nItemId = rUDEvt.GetItemId();
-    tools::Long nRectWidth = aRect.GetWidth();
-    tools::Long nRectHeight = aRect.GetHeight();
+    const Size aSize(25, 28);
+    tools::Long nRectWidth = aSize.getWidth();
+    tools::Long nRectHeight = aSize.getHeight();
+
+    VclPtr<VirtualDevice> pDev = m_xDefaultIconView->create_virtual_device();
+    pDev->SetOutputSizePixel(aSize);
 
-    Point aBLPos = aRect.TopLeft();
-    auto popIt = pDev->ScopedPush(vcl::PushFlags::LINECOLOR | 
vcl::PushFlags::FILLCOLOR);
     pDev->SetFillColor(rStyleSettings.GetFieldColor());
     pDev->SetLineColor(rStyleSettings.GetFieldTextColor());
+    pDev->SetBackground(rStyleSettings.GetFieldColor());
+    pDev->Erase();
+
 
     tools::Long nStep = std::abs(std::abs(nRectHeight * 95 /100) / 11);
     tools::Long nTop = (nRectHeight - 11 * nStep ) / 2;
@@ -1328,53 +1340,48 @@ void ColumnValueSet::UserDraw(const UserDrawEvent& 
rUDEvt)
     tools::Long nStarts[3];
     tools::Long nEnds[3];
     nStarts[0] = nRectWidth * 10 / 100;
-    switch( nItemId )
+    switch(nIndex)
     {
-        case 1:
+        case 0:
             nEnds[0] = nRectWidth * 9 / 10;
             nCols = 1;
-        break;
-        case 2: nCols = 2;
+            break;
+        case 1: nCols = 2;
             nEnds[0] = nRectWidth * 45 / 100;
             nStarts[1] = nEnds[0] + nStep;
             nEnds[1] = nRectWidth * 9 / 10;
-        break;
-        case 3: nCols = 3;
+            break;
+        case 2: nCols = 3;
             nEnds[0]    = nRectWidth * 30 / 100;
             nStarts[1]  = nEnds[0] + nStep;
             nEnds[1]    = nRectWidth * 63 / 100;
             nStarts[2]  = nEnds[1] + nStep;
             nEnds[2]    = nRectWidth * 9 / 10;
-        break;
-        case 4: nCols = 2;
+            break;
+        case 3: nCols = 2;
             nEnds[0] = nRectWidth * 63 / 100;
             nStarts[1] = nEnds[0] + nStep;
             nEnds[1] = nRectWidth * 9 / 10;
-        break;
-        case 5: nCols = 2;
+            break;
+        case 4: nCols = 2;
             nEnds[0] = nRectWidth * 30 / 100;
             nStarts[1] = nEnds[0] + nStep;
             nEnds[1] = nRectWidth * 9 / 10;
-        break;
+            break;
     }
     for(sal_uInt16 j = 0; j < nCols; j++ )
     {
-        Point aStart(aBLPos.X() + nStarts[j], 0);
-        Point aEnd(aBLPos.X() + nEnds[j], 0);
+        Point aStart(nStarts[j], 0);
+        Point aEnd(nEnds[j], 0);
         for( sal_uInt16 i = 0; i < 12; i ++)
         {
-            aStart.setY( aBLPos.Y() + nTop + i * nStep);
+            aStart.setY(nTop + i * nStep);
             aEnd.setY( aStart.Y() );
             pDev->DrawLine(aStart, aEnd);
         }
     }
-}
 
-void ColumnValueSet::StyleUpdated()
-{
-    SetFormat();
-    Invalidate();
-    ValueSet::StyleUpdated();
+    return pDev;
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/uibase/inc/column.hxx b/sw/source/uibase/inc/column.hxx
index b5a9c83770eb..e179768c76cc 100644
--- a/sw/source/uibase/inc/column.hxx
+++ b/sw/source/uibase/inc/column.hxx
@@ -19,7 +19,6 @@
 #pragma once
 
 #include <svtools/ctrlbox.hxx>
-#include <svtools/valueset.hxx>
 #include <sfx2/basedlgs.hxx>
 #include <sfx2/tabdlg.hxx>
 #include <svx/colorbox.hxx>
@@ -67,22 +66,6 @@ public:
     virtual ~SwColumnDlg() override;
 };
 
-class ColumnValueSet final : public ValueSet
-{
-public:
-    ColumnValueSet()
-        : ValueSet(nullptr)
-    {
-    }
-    virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override
-    {
-        ValueSet::SetDrawingArea(pDrawingArea);
-        SetStyle(WB_TABSTOP | WB_ITEMBORDER | WB_DOUBLEBORDER);
-    }
-    virtual void UserDraw(const UserDrawEvent& rUDEvt) override;
-    virtual void StyleUpdated() override;
-};
-
 // column dialog now as TabPage
 class SwColumnPage final : public SfxTabPage
 {
@@ -101,10 +84,10 @@ class SwColumnPage final : public SfxTabPage
     bool            m_bHtmlMode;
     bool            m_bLockUpdate;
 
-    ColumnValueSet m_aDefaultVS;
     SwColExample m_aPgeExampleWN;
     SwColumnOnlyExample m_aFrameExampleWN;
 
+    std::unique_ptr<weld::IconView>  m_xDefaultIconView;
     std::unique_ptr<weld::SpinButton>  m_xCLNrEdt;
     std::unique_ptr<weld::CheckButton> m_xBalanceColsCB;
     std::unique_ptr<weld::Button> m_xBtnBack;
@@ -144,7 +127,7 @@ class SwColumnPage final : public SfxTabPage
     DECL_LINK(GapModify, weld::MetricSpinButton&, void);
     DECL_LINK(EdModify, weld::MetricSpinButton&, void);
     DECL_LINK(AutoWidthHdl, weld::Toggleable&, void );
-    DECL_LINK(SetDefaultsHdl, ValueSet *, void);
+    DECL_LINK(SetDefaultsHdl, weld::IconView&, void);
 
     DECL_LINK(Up, weld::Button&, void);
     DECL_LINK(Down, weld::Button&, void);
@@ -154,6 +137,7 @@ class SwColumnPage final : public SfxTabPage
     DECL_LINK(UpdateColMgrColorBox, ColorListBox&, void);
     void Timeout();
 
+    VclPtr<VirtualDevice> CreateIconViewImage(int nIndex);
     void            Update(const weld::MetricSpinButton* pInteractiveField);
     void            UpdateCols();
     void            Init();
diff --git a/sw/uiconfig/swriter/ui/columnpage.ui 
b/sw/uiconfig/swriter/ui/columnpage.ui
index 6860e1f819c3..571c3647ed62 100644
--- a/sw/uiconfig/swriter/ui/columnpage.ui
+++ b/sw/uiconfig/swriter/ui/columnpage.ui
@@ -51,6 +51,16 @@
     <property name="step-increment">0.10</property>
     <property name="page-increment">1</property>
   </object>
+  <object class="GtkTreeStore" id="iconview_treestore">
+    <columns>
+      <!-- column-name pixbuf -->
+      <column type="GdkPixbuf"/>
+      <!-- column-name id -->
+      <column type="gchararray"/>
+      <!-- column-name tooltip -->
+      <column type="gchararray"/>
+    </columns>
+  </object>
   <object class="GtkImage" id="image7">
     <property name="visible">True</property>
     <property name="can-focus">False</property>
@@ -830,17 +840,17 @@
                   </packing>
                 </child>
                 <child>
-                  <object class="GtkDrawingArea" id="valueset">
-                    <property name="width-request">160</property>
-                    <property name="height-request">35</property>
+                  <object class="GtkIconView" id="iconview">
                     <property name="visible">True</property>
                     <property name="can-focus">True</property>
-                    <property name="events">GDK_BUTTON_PRESS_MASK | 
GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | 
GDK_STRUCTURE_MASK</property>
-                    <property name="hexpand">True</property>
-                    <property name="vexpand">True</property>
+                    <property name="margin">6</property>
+                    <property name="model">iconview_treestore</property>
+                    <property name="columns">5</property>
+                    <property name="pixbuf-column">0</property>
+                    <property name="tooltip-column">2</property>
                     <child internal-child="accessible">
-                      <object class="AtkObject" id="valueset-atkobject">
-                        <property name="AtkObject::accessible-description" 
translatable="yes" context="columnpage|extended_tip|valueset">Enter the number 
of columns that you want in the page, frame, or section.</property>
+                      <object class="AtkObject" id="iconview-atkobject">
+                        <property name="AtkObject::accessible-description" 
translatable="yes" context="columnpage|extended_tip|iconview">Enter the number 
of columns that you want in the page, frame, or section.</property>
                       </object>
                     </child>
                   </object>
commit a2e68bf7fb18c0549d69b012da219b23c39e14cc
Author:     Michael Weghorn <[email protected]>
AuthorDate: Thu Feb 5 10:12:29 2026 +0100
Commit:     Michael Weghorn <[email protected]>
CommitDate: Thu Feb 5 13:15:03 2026 +0100

    sw: Resave columnpage.ui with glade 3.40
    
    Resave to minimize the diff in an upcoming
    change that "actually" changes the logic.
    
    However, manually restore the
    
        <property name="label" translatable="no"></property>
    
    that got dropped when resaving, to avoid potential
    unwanted side-effects.
    
    Change-Id: I7eb53e03cba653d0381690912e6ad4333cab2e04
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/198737
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <[email protected]>

diff --git a/sw/uiconfig/swriter/ui/columnpage.ui 
b/sw/uiconfig/swriter/ui/columnpage.ui
index 67fbff149158..6860e1f819c3 100644
--- a/sw/uiconfig/swriter/ui/columnpage.ui
+++ b/sw/uiconfig/swriter/ui/columnpage.ui
@@ -120,10 +120,10 @@
                     <property name="visible">True</property>
                     <property name="can-focus">False</property>
                     <property name="label" translatable="yes" 
context="columnpage|columnft">Column</property>
+                    <property name="xalign">0</property>
                     <attributes>
                       <attribute name="weight" value="bold"/>
                     </attributes>
-                    <property name="xalign">0</property>
                     <accessibility>
                       <relation type="label-for" target="back"/>
                       <relation type="label-for" target="next"/>
@@ -140,11 +140,11 @@
                     <property name="can-focus">False</property>
                     <property name="hexpand">True</property>
                     <property name="label">_1</property>
+                    <property name="use-underline">True</property>
+                    <property name="mnemonic-widget">width1mf</property>
                     <attributes>
                       <attribute name="weight" value="bold"/>
                     </attributes>
-                    <property name="use-underline">True</property>
-                    <property name="mnemonic-widget">width1mf</property>
                   </object>
                   <packing>
                     <property name="left-attach">2</property>
@@ -157,11 +157,11 @@
                     <property name="can-focus">False</property>
                     <property name="hexpand">True</property>
                     <property name="label">_2</property>
+                    <property name="use-underline">True</property>
+                    <property name="mnemonic-widget">width2mf</property>
                     <attributes>
                       <attribute name="weight" value="bold"/>
                     </attributes>
-                    <property name="use-underline">True</property>
-                    <property name="mnemonic-widget">width2mf</property>
                   </object>
                   <packing>
                     <property name="left-attach">3</property>
@@ -174,11 +174,11 @@
                     <property name="can-focus">False</property>
                     <property name="hexpand">True</property>
                     <property name="label">_3</property>
+                    <property name="use-underline">True</property>
+                    <property name="mnemonic-widget">width3mf</property>
                     <attributes>
                       <attribute name="weight" value="bold"/>
                     </attributes>
-                    <property name="use-underline">True</property>
-                    <property name="mnemonic-widget">width3mf</property>
                   </object>
                   <packing>
                     <property name="left-attach">4</property>

Reply via email to