cui/qa/uitest/dialogs/chardlg.py       |   11 +-
 cui/qa/uitest/tabpages/tpcolor.py      |    4 
 cui/source/tabpages/border.cxx         |    1 
 include/svx/PaletteManager.hxx         |    1 
 include/svx/colorwindow.hxx            |   24 ++--
 svx/source/tbxctrls/PaletteManager.cxx |   22 ----
 svx/source/tbxctrls/tbcontrl.cxx       |  173 ++++++++++++++++++++++-----------
 svx/uiconfig/ui/colorwindow.ui         |   66 +++++++++---
 8 files changed, 194 insertions(+), 108 deletions(-)

New commits:
commit 50fcfd08429212d8d931cf2fed92b86a863d93ae
Author:     Parth Raiyani <parth.raiy...@collabora.com>
AuthorDate: Wed Aug 6 19:40:48 2025 +0530
Commit:     Szymon Kłos <szymon.k...@collabora.com>
CommitDate: Thu Aug 7 15:59:33 2025 +0200

    Switch to IconView in color selection for improved UI handling
    
    - Replaced SvxColorValueSet with weld::IconView for color selection in 
colorwindow
    - Updated UI in colorwindow.ui to include GtkIconView and GtkTreeStore for 
colors and recent colors
    - Adjusted event handling for color selection and tooltip queries in 
tbcontrl
    - Added caching color list and recent colors for performance improvement by 
reducing calls to GetColors() and GetRecentColors()
    - Removed unused method ReloadRecentColorSet having SvxColorValueSet param 
from PaletteManager
    - fixed import issue in border.cxx
    - removed the changes made as part of tdf#157034 as after iconview 
conversion nItemId will always begin with 0
    - updated the affected test cases
    
    Change-Id: I82fec2a2e6fc1cfd1eb0051a03df445a9812ab5a
    Signed-off-by: Parth Raiyani <parth.raiy...@collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/188921
    Reviewed-by: Szymon Kłos <szymon.k...@collabora.com>
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>

diff --git a/cui/qa/uitest/dialogs/chardlg.py b/cui/qa/uitest/dialogs/chardlg.py
index ee754b3c0f3a..15b9aa15ccd6 100644
--- a/cui/qa/uitest/dialogs/chardlg.py
+++ b/cui/qa/uitest/dialogs/chardlg.py
@@ -93,9 +93,12 @@ class Test(UITestCase):
                 floatWindow = self.xUITest.getFloatWindow()
                 paletteSelector = floatWindow.getChild("palette_listbox")
                 select_by_text(paletteSelector, "Theme colors")
-                colorSet = floatWindow.getChild("colorset")
+                colorIconView = floatWindow.getChild("colorwindow_iv_colors")
                 # 4 would be accent1, +12 is the first from the effect 
variants.
-                colorSet.executeAction("CHOOSE", mkPropertyValues({"POS": 
"16"}))
+                color_element = colorIconView.getChild("16")
+                color_element.executeAction("SELECT", mkPropertyValues({}))
+                color_element.executeAction("DOUBLECLICK", tuple())
+                
self.assertEqual(get_state_as_dict(colorIconView)["SelectEntryText"], "Accent 
1, 50% Lighter")
 
             # Then make sure the doc model has the correct color theme index:
             drawPage = component.getDrawPages()[0]
@@ -106,9 +109,9 @@ class Test(UITestCase):
             portion = portions.nextElement()
 
             # Without the accompanying fix in place, this test would have 
failed with:
-            # AssertionError: -1 != 3
+            # AssertionError: -1 != 4
             # i.e. no theme index was set, instead of accent1 (index into the 
above color scheme).
-            self.assertEqual(portion.CharColorTheme, 3)
+            self.assertEqual(portion.CharColorTheme, 4)
 
             # Then make sure that '80% lighter' is lum-mod=2000 and 
lum-off=8000:
             # Without the accompanying fix in place, this test would have 
failed with:
diff --git a/cui/qa/uitest/tabpages/tpcolor.py 
b/cui/qa/uitest/tabpages/tpcolor.py
index 3a8fedbdd0e3..4a48c6f3f913 100644
--- a/cui/qa/uitest/tabpages/tpcolor.py
+++ b/cui/qa/uitest/tabpages/tpcolor.py
@@ -64,9 +64,9 @@ class Test(UITestCase):
             # Then make sure the doc model is updated accordingly:
             shape = drawPage[0]
             # Without the accompanying fix in place, this test would have 
failed with:
-            # AssertionError: -1 != 3
+            # AssertionError: -1 != 4
             # i.e. the theme metadata of the selected fill color was lost.
-            self.assertEqual(shape.FillColorTheme, 3)
+            self.assertEqual(shape.FillColorTheme, 4)
 
 
 # vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/cui/source/tabpages/border.cxx b/cui/source/tabpages/border.cxx
index bc1ca29b1d5b..d7fe2a381389 100644
--- a/cui/source/tabpages/border.cxx
+++ b/cui/source/tabpages/border.cxx
@@ -46,6 +46,7 @@
 #include <comphelper/lok.hxx>
 #include <svtools/unitconv.hxx>
 #include <vcl/virdev.hxx>
+#include <vcl/image.hxx>
 
 using namespace ::editeng;
 using ::com::sun::star::uno::Reference;
diff --git a/include/svx/PaletteManager.hxx b/include/svx/PaletteManager.hxx
index c65cfd507b95..90c71a368b45 100644
--- a/include/svx/PaletteManager.hxx
+++ b/include/svx/PaletteManager.hxx
@@ -68,7 +68,6 @@ public:
     void        LoadPalettes();
     void        ReloadColorSet(SvxColorValueSet& rColorSet);
     void        ReloadColorSet(weld::IconView& pIconView);
-    void        ReloadRecentColorSet(SvxColorValueSet& rColorSet);
     void        ReloadRecentColorSet(weld::IconView& pIconView);
     std::vector<OUString> GetPaletteList();
     void        SetPalette( sal_Int32 nPos );
diff --git a/include/svx/colorwindow.hxx b/include/svx/colorwindow.hxx
index d88db32426a7..e52b77303558 100644
--- a/include/svx/colorwindow.hxx
+++ b/include/svx/colorwindow.hxx
@@ -21,7 +21,7 @@
 
 #include <svtools/toolbarmenu.hxx>
 #include <rtl/ustring.hxx>
-#include <svx/SvxColorValueSet.hxx>
+#include <svx/SvxColorIconView.hxx>
 #include <svx/Palette.hxx>
 #include <vcl/toolboxid.hxx>
 
@@ -88,25 +88,31 @@ private:
     TopLevelParentFunction maTopLevelParentFunction;
     ColorSelectFunction maColorSelectFunction;
 
-    std::unique_ptr<SvxColorValueSet> mxColorSet;
-    std::unique_ptr<SvxColorValueSet> mxRecentColorSet;
+    std::unique_ptr<weld::IconView> mxColorIconView;
+    std::unique_ptr<weld::IconView> mxRecentColorIconView;
     std::unique_ptr<weld::ComboBox> mxPaletteListBox;
     std::unique_ptr<weld::Button> mxButtonAutoColor;
     std::unique_ptr<weld::Button> mxButtonNoneColor;
     std::unique_ptr<weld::Button> mxButtonPicker;
     std::unique_ptr<weld::Widget> mxAutomaticSeparator;
-    std::unique_ptr<weld::CustomWeld> mxColorSetWin;
-    std::unique_ptr<weld::CustomWeld> mxRecentColorSetWin;
     weld::Button* mpDefaultButton;
 
-    DECL_DLLPRIVATE_LINK(SelectHdl, ValueSet*, void);
+    std::vector<NamedColor> vColors;
+    std::vector<NamedColor> vRecentColors;
+
+    DECL_DLLPRIVATE_LINK(SelectionChangedHdl, weld::IconView&, void);
+    DECL_DLLPRIVATE_LINK(ItemActivatedHdl, weld::IconView&, bool);
     DECL_DLLPRIVATE_LINK(SelectPaletteHdl, weld::ComboBox&, void);
     DECL_DLLPRIVATE_LINK(AutoColorClickHdl, weld::Button&, void);
     DECL_DLLPRIVATE_LINK(OpenPickerClickHdl, weld::Button&, void);
+    DECL_DLLPRIVATE_LINK(QueryColorIVTooltipHdl, const weld::TreeIter&, 
OUString);
+    DECL_DLLPRIVATE_LINK(QueryRecentIVTooltipHdl, const weld::TreeIter&, 
OUString);
+    OUString QueryTooltipHdl_Impl(weld::IconView* pIconView, 
std::u16string_view);
 
-    static bool SelectValueSetEntry(SvxColorValueSet* pColorSet, const Color& 
rColor);
-    static NamedColor GetSelectEntryColor(ValueSet const * pColorSet);
+    bool SelectIconViewEntry(weld::IconView* pIconView, const Color& rColor);
+    NamedColor GetSelectEntryColor(weld::IconView* pIconView);
     NamedColor GetAutoColor() const;
+    std::vector<NamedColor> GetColors(weld::IconView* pIconView);
 
 public:
     ColorWindow(OUString  rCommand,
@@ -123,7 +129,7 @@ public:
     bool                IsNoSelection() const;
     void                SelectEntry(const NamedColor& rColor);
     void                SelectEntry(const Color& rColor);
-    NamedColor          GetSelectEntryColor() const;
+    NamedColor          GetSelectEntryColor();
 
     virtual void        statusChanged( const css::frame::FeatureStateEvent& 
rEvent ) override;
 
diff --git a/svx/source/tbxctrls/PaletteManager.cxx 
b/svx/source/tbxctrls/PaletteManager.cxx
index 6837a081c1a5..cbad66557c5a 100644
--- a/svx/source/tbxctrls/PaletteManager.cxx
+++ b/svx/source/tbxctrls/PaletteManager.cxx
@@ -177,10 +177,6 @@ bool PaletteManager::IsThemePaletteSelected() const
 
 bool PaletteManager::GetThemeAndEffectIndex(sal_uInt16 nItemId, sal_uInt16& 
rThemeIndex, sal_uInt16& rEffectIndex)
 {
-    // tdf#157034, nItemId begins with 1 but list of themes begin with 0
-    // so decrement nItemId
-    --nItemId;
-
     // Each column is the same color with different effects.
     rThemeIndex = nItemId % 12;
 
@@ -335,24 +331,6 @@ void PaletteManager::ReloadColorSet(weld::IconView 
&pIconView)
     }
 }
 
-void PaletteManager::ReloadRecentColorSet(SvxColorValueSet& rColorSet)
-{
-    maRecentColors.clear();
-    rColorSet.Clear();
-    css::uno::Sequence< sal_Int32 > 
Colorlist(officecfg::Office::Common::UserColors::RecentColor::get());
-    css::uno::Sequence< OUString > 
ColorNamelist(officecfg::Office::Common::UserColors::RecentColorName::get());
-    int nIx = 1;
-    const bool bHasColorNames = Colorlist.getLength() == 
ColorNamelist.getLength();
-    for (int i = 0; i < Colorlist.getLength(); ++i)
-    {
-        Color aColor(ColorTransparency, Colorlist[i]);
-        OUString sColorName = bHasColorNames ? ColorNamelist[i] : ("#" + 
aColor.AsRGBHexString().toAsciiUpperCase());
-        maRecentColors.emplace_back(aColor, sColorName);
-        rColorSet.InsertItem(nIx, aColor, sColorName);
-        ++nIx;
-    }
-}
-
 void PaletteManager::ReloadRecentColorSet(weld::IconView& pIconView)
 {
     maRecentColors.clear();
diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx
index 32f26729db5a..81dea624b8e4 100644
--- a/svx/source/tbxctrls/tbcontrl.cxx
+++ b/svx/source/tbxctrls/tbcontrl.cxx
@@ -2071,19 +2071,15 @@ ColorWindow::ColorWindow(OUString  rCommand,
     , mrColorStatus(rColorStatus)
     , maTopLevelParentFunction(std::move(aTopLevelParentFunction))
     , maColorSelectFunction(std::move(aColorSelectFunction))
-    , mxColorSet(new 
SvxColorValueSet(m_xBuilder->weld_scrolled_window(u"colorsetwin"_ustr, true)))
-    , mxRecentColorSet(new SvxColorValueSet(nullptr))
+    , 
mxColorIconView(m_xBuilder->weld_icon_view(u"colorwindow_iv_colors"_ustr))
+    , 
mxRecentColorIconView(m_xBuilder->weld_icon_view(u"colorwindow_iv_recentcolors"_ustr))
     , mxPaletteListBox(m_xBuilder->weld_combo_box(u"palette_listbox"_ustr))
     , mxButtonAutoColor(m_xBuilder->weld_button(u"auto_color_button"_ustr))
     , mxButtonNoneColor(m_xBuilder->weld_button(u"none_color_button"_ustr))
     , mxButtonPicker(m_xBuilder->weld_button(u"color_picker_button"_ustr))
     , mxAutomaticSeparator(m_xBuilder->weld_widget(u"separator4"_ustr))
-    , mxColorSetWin(new weld::CustomWeld(*m_xBuilder, u"colorset"_ustr, 
*mxColorSet))
-    , mxRecentColorSetWin(new weld::CustomWeld(*m_xBuilder, 
u"recent_colorset"_ustr, *mxRecentColorSet))
     , mpDefaultButton(nullptr)
 {
-    mxColorSet->SetStyle( WinBits(WB_FLATVALUESET | WB_ITEMBORDER | WB_3DLOOK 
| WB_NO_DIRECTSELECT | WB_TABSTOP) );
-    mxRecentColorSet->SetStyle( WinBits(WB_FLATVALUESET | WB_ITEMBORDER | 
WB_3DLOOK | WB_NO_DIRECTSELECT | WB_TABSTOP) );
 
     switch ( theSlotId )
     {
@@ -2149,19 +2145,28 @@ ColorWindow::ColorWindow(OUString  rCommand,
     mxButtonNoneColor->connect_clicked(LINK(this, ColorWindow, 
AutoColorClickHdl));
     mxButtonPicker->connect_clicked(LINK(this, ColorWindow, 
OpenPickerClickHdl));
 
-    mxColorSet->SetSelectHdl(LINK( this, ColorWindow, SelectHdl));
-    mxRecentColorSet->SetSelectHdl(LINK( this, ColorWindow, SelectHdl));
-    m_xTopLevel->set_help_id(HID_POPUP_COLOR);
-    mxColorSet->SetHelpId(HID_POPUP_COLOR_CTRL);
+    mxColorIconView->connect_selection_changed(LINK(this, ColorWindow, 
SelectionChangedHdl));
+    mxColorIconView->connect_item_activated(LINK(this, ColorWindow, 
ItemActivatedHdl));
 
-    mxPaletteManager->ReloadColorSet(*mxColorSet);
-    const sal_uInt32 nMaxItems(SvxColorValueSet::getMaxRowCount() * 
SvxColorValueSet::getColumnCount());
-    Size aSize = mxColorSet->layoutAllVisible(nMaxItems);
-    mxColorSet->set_size_request(aSize.Width(), aSize.Height());
+    mxRecentColorIconView->connect_selection_changed(LINK(this, ColorWindow, 
SelectionChangedHdl));
+    mxRecentColorIconView->connect_item_activated(LINK(this, ColorWindow, 
ItemActivatedHdl));
 
-    mxPaletteManager->ReloadRecentColorSet(*mxRecentColorSet);
-    aSize = 
mxRecentColorSet->layoutAllVisible(mxPaletteManager->GetRecentColorCount());
-    mxRecentColorSet->set_size_request(aSize.Width(), aSize.Height());
+    // Avoid LibreOffice Kit crash: tooltip handlers cause segfault during 
JSDialog
+    // serialization when popup widgets are destroyed/recreated during 
character formatting resets.
+    // Tooltip event binding is not needed for LibreOffice Kit
+    if (!comphelper::LibreOfficeKit::isActive())
+    {
+        mxColorIconView->connect_query_tooltip(LINK(this, ColorWindow, 
QueryColorIVTooltipHdl));
+        mxRecentColorIconView->connect_query_tooltip(LINK(this, ColorWindow, 
QueryRecentIVTooltipHdl));
+    }
+
+    m_xTopLevel->set_help_id(HID_POPUP_COLOR);
+    mxColorIconView->set_help_id(HID_POPUP_COLOR_CTRL);
+
+    mxPaletteManager->ReloadColorSet(*mxColorIconView);
+    mxPaletteManager->ReloadRecentColorSet(*mxRecentColorIconView);
+    vColors = mxPaletteManager->GetColors();
+    vRecentColors = mxPaletteManager->GetRecentColors();
 
     AddStatusListener( u".uno:ColorTableState"_ustr );
     AddStatusListener( maCommand );
@@ -2174,10 +2179,10 @@ ColorWindow::ColorWindow(OUString  rCommand,
 
 void ColorWindow::GrabFocus()
 {
-    if (mxColorSet->IsNoSelection() && mpDefaultButton)
+    if (mxColorIconView->get_selected_id().isEmpty() && mpDefaultButton)
         mpDefaultButton->grab_focus();
     else
-        mxColorSet->GrabFocus();
+        mxColorIconView->grab_focus();
 }
 
 void ColorWindow::ShowNoneButton()
@@ -2189,11 +2194,18 @@ ColorWindow::~ColorWindow()
 {
 }
 
-NamedColor ColorWindow::GetSelectEntryColor(ValueSet const * pColorSet)
+NamedColor ColorWindow::GetSelectEntryColor(weld::IconView* pIconView)
 {
-    Color aColor = pColorSet->GetItemColor(pColorSet->GetSelectedItemId());
-    const OUString& sColorName = 
pColorSet->GetItemText(pColorSet->GetSelectedItemId());
-    return { aColor, sColorName };
+    NamedColor aColor(COL_BLACK, SvxResId(RID_SVXSTR_COLOR_BLACK)); //default 
black color
+
+    OUString sId = pIconView->get_selected_id();
+    sal_Int32 nId = !sId.isEmpty() ? sId.toInt32() : -1;
+
+    std::vector<NamedColor> vColorList = GetColors(pIconView);
+    if(nId > -1 && o3tl::make_unsigned(nId) < vColorList.size())
+        aColor = vColorList[nId];
+
+    return aColor;
 }
 
 namespace
@@ -2244,27 +2256,35 @@ namespace
     }
 }
 
-NamedColor ColorWindow::GetSelectEntryColor() const
+NamedColor ColorWindow::GetSelectEntryColor()
 {
-    if (!mxColorSet->IsNoSelection())
-        return GetSelectEntryColor(mxColorSet.get());
-    if (!mxRecentColorSet->IsNoSelection())
-        return GetSelectEntryColor(mxRecentColorSet.get());
+    if (!mxColorIconView->get_selected_id().isEmpty())
+        return GetSelectEntryColor(mxColorIconView.get());
+    if (!mxRecentColorIconView->get_selected_id().isEmpty())
+        return GetSelectEntryColor(mxRecentColorIconView.get());
     if (mxButtonNoneColor.get() == mpDefaultButton)
         return GetNoneColor();
     return GetAutoColor();
 }
 
-IMPL_LINK(ColorWindow, SelectHdl, ValueSet*, pColorSet, void)
+IMPL_LINK(ColorWindow, SelectionChangedHdl, weld::IconView&, rIconView, void)
 {
-    NamedColor aNamedColor = GetSelectEntryColor(pColorSet);
+    NamedColor aNamedColor = GetSelectEntryColor(&rIconView);
 
-    if (pColorSet != mxRecentColorSet.get())
+    if (&rIconView != mxRecentColorIconView.get())
     {
-         mxPaletteManager->AddRecentColor(aNamedColor.m_aColor, 
aNamedColor.m_aName);
-         if (!maMenuButton.get_active())
-            mxPaletteManager->ReloadRecentColorSet(*mxRecentColorSet);
+        mxPaletteManager->AddRecentColor(aNamedColor.m_aColor, 
aNamedColor.m_aName);
+        if (!maMenuButton.get_active())
+        {
+            mxPaletteManager->ReloadRecentColorSet(*mxRecentColorIconView);
+            vRecentColors = mxPaletteManager->GetRecentColors();
+        }
     }
+}
+
+IMPL_LINK(ColorWindow, ItemActivatedHdl, weld::IconView&, rIconView, bool)
+{
+    NamedColor aNamedColor = GetSelectEntryColor(&rIconView);
 
     mxPaletteManager->SetSplitButtonColor(aNamedColor);
 
@@ -2274,13 +2294,14 @@ IMPL_LINK(ColorWindow, SelectHdl, ValueSet*, pColorSet, 
void)
     OUString sCommand(maCommand);
     // Same for querying IsTheme early.
     bool bThemePaletteSelected = mxPaletteManager->IsThemePaletteSelected();
-    sal_uInt16 nSelectedItemId = pColorSet->GetSelectedItemId();
+    OUString sId = rIconView.get_selected_id();
 
     if (bThemePaletteSelected)
     {
+        sal_Int32 nId = !sId.isEmpty() ? sId.toInt32() : 0;
         sal_uInt16 nThemeIndex;
         sal_uInt16 nEffectIndex;
-        if (PaletteManager::GetThemeAndEffectIndex(nSelectedItemId, 
nThemeIndex, nEffectIndex))
+        if (PaletteManager::GetThemeAndEffectIndex(nId, nThemeIndex, 
nEffectIndex))
         {
             aNamedColor.m_nThemeIndex = nThemeIndex;
             mxPaletteManager->GetLumModOff(nThemeIndex, nEffectIndex, 
aNamedColor.m_nLumMod, aNamedColor.m_nLumOff);
@@ -2289,14 +2310,16 @@ IMPL_LINK(ColorWindow, SelectHdl, ValueSet*, pColorSet, 
void)
 
     maMenuButton.set_inactive();
     aColorSelectFunction(sCommand, aNamedColor);
+
+    return true;
 }
 
 IMPL_LINK_NOARG(ColorWindow, SelectPaletteHdl, weld::ComboBox&, void)
 {
     int nPos = mxPaletteListBox->get_active();
     mxPaletteManager->SetPalette( nPos );
-    mxPaletteManager->ReloadColorSet(*mxColorSet);
-    mxColorSet->layoutToGivenHeight(mxColorSet->GetOutputSizePixel().Height(), 
mxPaletteManager->GetColorCount());
+    mxPaletteManager->ReloadColorSet(*mxColorIconView);
+    vColors = mxPaletteManager->GetColors();
 }
 
 NamedColor ColorWindow::GetAutoColor() const
@@ -2308,8 +2331,8 @@ IMPL_LINK(ColorWindow, AutoColorClickHdl, weld::Button&, 
rButton, void)
 {
     NamedColor aNamedColor = &rButton == mxButtonAutoColor.get() ? 
GetAutoColor() : GetNoneColor();
 
-    mxColorSet->SetNoSelection();
-    mxRecentColorSet->SetNoSelection();
+    mxColorIconView->unselect_all();
+    mxRecentColorIconView->unselect_all();
     mpDefaultButton = &rButton;
 
     mxPaletteManager->SetSplitButtonColor(aNamedColor);
@@ -2337,18 +2360,57 @@ IMPL_LINK_NOARG(ColorWindow, OpenPickerClickHdl, 
weld::Button&, void)
     xPaletteManager->PopupColorPicker(pParentWindow, sCommand, nColor);
 }
 
+IMPL_LINK(ColorWindow, QueryColorIVTooltipHdl, const weld::TreeIter&, rIter, 
OUString)
+{
+    OUString sId = mxColorIconView->get_id(rIter);
+    return QueryTooltipHdl_Impl(mxColorIconView.get(), sId);
+}
+
+IMPL_LINK(ColorWindow, QueryRecentIVTooltipHdl, const weld::TreeIter&, rIter, 
OUString)
+{
+    OUString sId = mxRecentColorIconView->get_id(rIter);
+    return QueryTooltipHdl_Impl(mxRecentColorIconView.get(), sId);
+}
+
+OUString ColorWindow::QueryTooltipHdl_Impl(weld::IconView* pIconView, 
std::u16string_view sId)
+{
+    if (sId.empty())
+        return OUString();
+
+    const rtl::OUString aOUString(sId.data(), sId.length());
+    const sal_Int32 nPos = aOUString.toInt32();
+
+    // Return the name of the color at position nPos, if valid.
+    const auto colorList = GetColors(pIconView);
+    if (o3tl::make_unsigned(nPos) < colorList.size())
+        return colorList[nPos].m_aName;
+
+    return OUString();
+}
+
+std::vector<NamedColor> ColorWindow::GetColors(weld::IconView* pIconView)
+{
+    if(mxRecentColorIconView.get() == pIconView) {
+        vRecentColors = vRecentColors.size() > 0 ? vRecentColors : 
mxPaletteManager->GetRecentColors();
+        return vRecentColors;
+    }
+
+    vColors = vColors.size() > 0 ? vColors : mxPaletteManager->GetColors();
+    return vColors;
+}
+
 void ColorWindow::SetNoSelection()
 {
-    mxColorSet->SetNoSelection();
-    mxRecentColorSet->SetNoSelection();
+    mxColorIconView->unselect_all();
+    mxRecentColorIconView->unselect_all();
     mpDefaultButton = nullptr;
 }
 
 bool ColorWindow::IsNoSelection() const
 {
-    if (!mxColorSet->IsNoSelection())
+    if (!mxColorIconView->get_selected_id().isEmpty())
         return false;
-    if (!mxRecentColorSet->IsNoSelection())
+    if (!mxRecentColorIconView->get_selected_id().isEmpty())
         return false;
     return !mxButtonAutoColor->get_visible() && 
!mxButtonNoneColor->get_visible();
 }
@@ -2359,8 +2421,8 @@ void ColorWindow::statusChanged( const 
css::frame::FeatureStateEvent& rEvent )
     {
         if (rEvent.IsEnabled && mxPaletteManager->GetPalette() == 0)
         {
-            mxPaletteManager->ReloadColorSet(*mxColorSet);
-            
mxColorSet->layoutToGivenHeight(mxColorSet->GetOutputSizePixel().Height(), 
mxPaletteManager->GetColorCount());
+            mxPaletteManager->ReloadColorSet(*mxColorIconView);
+            vColors = mxPaletteManager->GetColors();
         }
     }
     else
@@ -2370,13 +2432,15 @@ void ColorWindow::statusChanged( const 
css::frame::FeatureStateEvent& rEvent )
     }
 }
 
-bool ColorWindow::SelectValueSetEntry(SvxColorValueSet* pColorSet, const 
Color& rColor)
+bool ColorWindow::SelectIconViewEntry(weld::IconView* pIconView, const Color& 
rColor)
 {
-    for (size_t i = 1; i <= pColorSet->GetItemCount(); ++i)
+    std::vector<NamedColor> vNamedColors = GetColors(pIconView);
+
+    for (size_t i = 0; i < vNamedColors.size(); ++i)
     {
-        if (rColor == pColorSet->GetItemColor(i))
+        if (rColor == vNamedColors[i].m_aColor)
         {
-            pColorSet->SelectItem(i);
+            pIconView->select(i);
             return true;
         }
     }
@@ -2402,10 +2466,10 @@ void ColorWindow::SelectEntry(const NamedColor& 
rNamedColor)
     }
 
     // try current palette
-    bool bFoundColor = SelectValueSetEntry(mxColorSet.get(), rColor);
+    bool bFoundColor = SelectIconViewEntry(mxColorIconView.get(), rColor);
     // try recently used
     if (!bFoundColor)
-        bFoundColor = SelectValueSetEntry(mxRecentColorSet.get(), rColor);
+        bFoundColor = SelectIconViewEntry(mxRecentColorIconView.get(), rColor);
     // if it's not there, add it there now to the end of the recently used
     // so its available somewhere handy, but not without trashing the
     // whole recently used
@@ -2413,8 +2477,9 @@ void ColorWindow::SelectEntry(const NamedColor& 
rNamedColor)
     {
         const OUString& rColorName = rNamedColor.m_aName;
         mxPaletteManager->AddRecentColor(rColor, rColorName, false);
-        mxPaletteManager->ReloadRecentColorSet(*mxRecentColorSet);
-        SelectValueSetEntry(mxRecentColorSet.get(), rColor);
+        mxPaletteManager->ReloadRecentColorSet(*mxRecentColorIconView);
+        vRecentColors = mxPaletteManager->GetRecentColors();
+        SelectIconViewEntry(mxRecentColorIconView.get(), rColor);
     }
 }
 
diff --git a/svx/uiconfig/ui/colorwindow.ui b/svx/uiconfig/ui/colorwindow.ui
index 437f9e8719db..391f6ef53832 100644
--- a/svx/uiconfig/ui/colorwindow.ui
+++ b/svx/uiconfig/ui/colorwindow.ui
@@ -24,6 +24,22 @@
     <property name="border-width">4</property>
     <property name="constrain-to">none</property>
     <child>
+      <object class="GtkTreeStore" id="colors_liststore">
+        <columns>
+          <!-- column-name pixbuf -->
+          <column type="GdkPixbuf"/>
+          <!-- column-name id -->
+          <column type="gchararray"/>
+        </columns>
+      </object>
+      <object class="GtkTreeStore" id="recent_colors_liststore">
+        <columns>
+          <!-- column-name pixbuf -->
+          <column type="GdkPixbuf"/>
+          <!-- column-name id -->
+          <column type="gchararray"/>
+        </columns>
+      </object>
       <object class="GtkBox" id="container">
         <property name="visible">True</property>
         <property name="can-focus">False</property>
@@ -102,25 +118,27 @@
           </packing>
         </child>
         <child>
-          <object class="GtkScrolledWindow" id="colorsetwin">
+          <object class="GtkScrolledWindow">
             <property name="visible">True</property>
             <property name="can-focus">True</property>
             <property name="hscrollbar-policy">never</property>
-            <property name="vscrollbar-policy">never</property>
+            <property name="vscrollbar-policy">always</property>
             <property name="shadow-type">in</property>
             <property name="overlay-scrolling">False</property>
+            <property name="height-request">180</property>
             <child>
-              <object class="GtkViewport">
+              <object class="GtkIconView" id="colorwindow_iv_colors">
                 <property name="visible">True</property>
-                <property name="can-focus">False</property>
-                <child>
-                  <object class="GtkDrawingArea" id="colorset">
-                    <property name="visible">True</property>
-                    <property name="can-focus">True</property>
-                    <property name="receives-default">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>
-                  </object>
-                </child>
+                <property name="can-focus">True</property>
+                <property name="model">colors_liststore</property>
+                <property name="pixbuf-column">0</property>
+                <property name="selection-mode">single</property>
+                <property name="item-orientation">horizontal</property>
+                <property name="columns">12</property>
+                <property name="row-spacing">1</property>
+                <property name="column-spacing">1</property>
+                <property name="item-padding">3</property>
+                <property name="activate-on-single-click">True</property>
               </object>
             </child>
           </object>
@@ -147,7 +165,7 @@
             <property name="can-focus">False</property>
             <property name="label" translatable="yes" 
context="colorwindow|label1">Recent</property>
             <property name="use-underline">True</property>
-            <property name="mnemonic-widget">recent_colorset</property>
+            <property 
name="mnemonic-widget">colorwindow_iv_recentcolors</property>
             <property name="xalign">0</property>
           </object>
           <packing>
@@ -157,11 +175,27 @@
           </packing>
         </child>
         <child>
-          <object class="GtkDrawingArea" id="recent_colorset">
+          <object class="GtkScrolledWindow">
             <property name="visible">True</property>
             <property name="can-focus">True</property>
-            <property name="receives-default">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="hscrollbar-policy">never</property>
+            <property name="vscrollbar-policy">never</property>
+            <property name="shadow-type">in</property>
+            <child>
+              <object class="GtkIconView" id="colorwindow_iv_recentcolors">
+                <property name="visible">True</property>
+                <property name="can-focus">True</property>
+                <property name="model">recent_colors_liststore</property>
+                <property name="pixbuf-column">0</property>
+                <property name="selection-mode">single</property>
+                <property name="item-orientation">horizontal</property>
+                <property name="columns">12</property>
+                <property name="row-spacing">1</property>
+                <property name="column-spacing">1</property>
+                <property name="item-padding">3</property>
+                <property name="activate-on-single-click">True</property>
+              </object>
+            </child>
           </object>
           <packing>
             <property name="expand">False</property>

Reply via email to