cui/source/inc/cuitabarea.hxx     |   21 ++-
 cui/source/tabpages/tppattern.cxx |  237 ++++++++++++++++++++++++++++----------
 cui/uiconfig/ui/patterntabpage.ui |   30 +++-
 3 files changed, 210 insertions(+), 78 deletions(-)

New commits:
commit 683366242f3f2d91232c8e1d06edaeabf4a143e4
Author:     Parth Raiyani <[email protected]>
AuthorDate: Mon Aug 4 17:04:59 2025 +0530
Commit:     Caolán McNamara <[email protected]>
CommitDate: Tue Feb 24 15:59:10 2026 +0100

    Switch to IconView for pattern tab page for improved UI handling
    
    - Replaced ValueSet with IconView widget in pattern tab page
    - Updated patterntabpage UI to include GtkIconView and GtkTreeStore for 
pattern
    - Added support to select and preview default when no item is selected
    - Always keep selected item and selection preview in sync
    
    Change-Id: Id8f376482cc1f7147afa45188ce8524f56205f40
    Signed-off-by: Parth Raiyani <[email protected]>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/188239
    Reviewed-by: Szymon Kłos <[email protected]>
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200183
    Reviewed-by: Caolán McNamara <[email protected]>

diff --git a/cui/source/inc/cuitabarea.hxx b/cui/source/inc/cuitabarea.hxx
index 28522ff6e041..1dd9b52df2df 100644
--- a/cui/source/inc/cuitabarea.hxx
+++ b/cui/source/inc/cuitabarea.hxx
@@ -617,28 +617,39 @@ private:
 
     XFillAttrSetItem    m_aXFillAttr;
     SfxItemSet&         m_rXFSet;
+    OUString            sLastItemIdent;
+    Size                aIconSize;
 
     SvxXRectPreview m_aCtlPreview;
     std::unique_ptr<SvxPixelCtl> m_xCtlPixel;
     std::unique_ptr<ColorListBox> m_xLbColor;
     std::unique_ptr<ColorListBox> m_xLbBackgroundColor;
-    std::unique_ptr<SvxPresetListBox> m_xPatternLB;
+    std::unique_ptr<weld::IconView> m_xPatternLB;
     std::unique_ptr<weld::Button> m_xBtnAdd;
     std::unique_ptr<weld::Button> m_xBtnModify;
     std::unique_ptr<weld::CustomWeld> m_xCtlPixelWin;
     std::unique_ptr<weld::CustomWeld> m_xCtlPreview;
-    std::unique_ptr<weld::CustomWeld> m_xPatternLBWin;
     std::unique_ptr<SvxBitmapCtl> m_xBitmapCtl;
 
     DECL_LINK( ClickAddHdl_Impl, weld::Button&, void );
     DECL_LINK( ClickModifyHdl_Impl, weld::Button&, void );
-    DECL_LINK( ChangePatternHdl_Impl, ValueSet*, void );
+    DECL_LINK( ChangePatternHdl_Impl,  weld::IconView&, void );
     DECL_LINK( ChangeColorHdl_Impl, ColorListBox&, void );
-    DECL_LINK( ClickRenameHdl_Impl, SvxPresetListBox*, void );
-    DECL_LINK( ClickDeleteHdl_Impl, SvxPresetListBox*, void );
+    DECL_LINK(MousePressHdl, const MouseEvent&, bool);
+    DECL_LINK(MenuSelectAsyncHdl, void*, void);
+    DECL_LINK(OnPopupEnd, const OUString&, void);
+    DECL_LINK(QueryTooltipHdl, const weld::TreeIter&, OUString);
 
     sal_Int32 SearchPatternList(std::u16string_view rPatternName);
 
+    static VclPtr<VirtualDevice> GetVirtualDevice(Bitmap aBitmap);
+    void FillPresetListBox();
+    void ShowContextMenu(const Point& pPos);
+    void MenuSelect(const OUString& rIdent);
+    void HandleMenuSelect(std::u16string_view rIdent);
+    void ClickRenameHdl();
+    void ClickDeleteHdl();
+
 public:
     SvxPatternTabPage(weld::Container* pPage, weld::DialogController* 
pController, const SfxItemSet& rInAttrs);
     virtual ~SvxPatternTabPage() override;
diff --git a/cui/source/tabpages/tppattern.cxx 
b/cui/source/tabpages/tppattern.cxx
index 6df99cb90e80..e845fedeb927 100644
--- a/cui/source/tabpages/tppattern.cxx
+++ b/cui/source/tabpages/tppattern.cxx
@@ -39,6 +39,7 @@
 #include <svx/svxdlg.hxx>
 #include <dialmgr.hxx>
 #include <sal/log.hxx>
+#include <comphelper/lok.hxx>
 
 using namespace com::sun::star;
 
@@ -79,21 +80,20 @@ SvxPatternTabPage::SvxPatternTabPage(weld::Container* 
pPage, weld::DialogControl
     , m_pnColorListState(nullptr)
     , m_aXFillAttr(rInAttrs.GetPool())
     , m_rXFSet(m_aXFillAttr.GetItemSet())
+    , aIconSize(60, 64)
     , m_xCtlPixel(new SvxPixelCtl(this))
     , m_xLbColor(new 
ColorListBox(m_xBuilder->weld_menu_button(u"LB_COLOR"_ustr),
                 [this]{ return GetDialogController()->getDialog(); }))
     , m_xLbBackgroundColor(new 
ColorListBox(m_xBuilder->weld_menu_button(u"LB_BACKGROUND_COLOR"_ustr),
                 [this]{ return GetDialogController()->getDialog(); }))
-    , m_xPatternLB(new 
SvxPresetListBox(m_xBuilder->weld_scrolled_window(u"patternpresetlistwin"_ustr, 
true)))
+    , m_xPatternLB(m_xBuilder->weld_icon_view(u"patternpresetlist"_ustr))
     , m_xBtnAdd(m_xBuilder->weld_button(u"BTN_ADD"_ustr))
     , m_xBtnModify(m_xBuilder->weld_button(u"BTN_MODIFY"_ustr))
     , m_xCtlPixelWin(new weld::CustomWeld(*m_xBuilder, u"CTL_PIXEL"_ustr, 
*m_xCtlPixel))
     , m_xCtlPreview(new weld::CustomWeld(*m_xBuilder, u"CTL_PREVIEW"_ustr, 
m_aCtlPreview))
-    , m_xPatternLBWin(new weld::CustomWeld(*m_xBuilder, 
u"patternpresetlist"_ustr, *m_xPatternLB))
 {
     // size of the bitmap display
     Size aSize = 
getDrawPreviewOptimalSize(m_aCtlPreview.GetDrawingArea()->get_ref_device());
-    m_xPatternLB->set_size_request(aSize.Width(), aSize.Height());
     m_xCtlPreview->set_size_request(aSize.Width(), aSize.Height());
 
     m_xBitmapCtl.reset(new SvxBitmapCtl);
@@ -108,18 +108,16 @@ SvxPatternTabPage::SvxPatternTabPage(weld::Container* 
pPage, weld::DialogControl
     m_xBtnAdd->connect_clicked( LINK( this, SvxPatternTabPage, 
ClickAddHdl_Impl ) );
     m_xBtnModify->connect_clicked( LINK( this, SvxPatternTabPage, 
ClickModifyHdl_Impl ) );
 
-    m_xPatternLB->SetSelectHdl( LINK( this, SvxPatternTabPage, 
ChangePatternHdl_Impl ) );
-    m_xPatternLB->SetRenameHdl( LINK( this, SvxPatternTabPage, 
ClickRenameHdl_Impl ) );
-    m_xPatternLB->SetDeleteHdl( LINK( this, SvxPatternTabPage, 
ClickDeleteHdl_Impl ) );
+    m_xPatternLB->connect_selection_changed(LINK(this, SvxPatternTabPage, 
ChangePatternHdl_Impl));
+    m_xPatternLB->connect_mouse_press(LINK(this, SvxPatternTabPage, 
MousePressHdl));
+    m_xPatternLB->connect_query_tooltip(LINK(this, SvxPatternTabPage, 
QueryTooltipHdl));
     m_xLbColor->SetSelectHdl( LINK( this, SvxPatternTabPage, 
ChangeColorHdl_Impl ) );
     m_xLbBackgroundColor->SetSelectHdl( LINK( this, SvxPatternTabPage, 
ChangeColorHdl_Impl ) );
 
-    m_xPatternLB->SetStyle(WB_FLATVALUESET | WB_NO_DIRECTSELECT | WB_TABSTOP);
 }
 
 SvxPatternTabPage::~SvxPatternTabPage()
 {
-    m_xPatternLBWin.reset();
     m_xCtlPreview.reset();
     m_xCtlPixelWin.reset();
     m_xPatternLB.reset();
@@ -141,7 +139,36 @@ SvxPatternTabPage::~SvxPatternTabPage()
 
 void SvxPatternTabPage::Construct()
 {
-    m_xPatternLB->FillPresetListBox( *m_pPatternList );
+    FillPresetListBox();
+}
+
+void SvxPatternTabPage::FillPresetListBox()
+{
+    m_xPatternLB->clear();
+
+    m_xPatternLB->freeze();
+    for (tools::Long nId = 0; nId < m_pPatternList->Count(); nId++)
+    {
+        const OUString aString(m_pPatternList->GetBitmap(nId)->GetName());
+
+        OUString sId = OUString::number(nId);
+        Bitmap aBitmap = m_pPatternList->GetBitmapForPreview(nId, aIconSize);
+        VclPtr<VirtualDevice> aVDev = GetVirtualDevice(aBitmap);
+        Bitmap aBmp = aVDev->GetBitmap(Point(), aVDev->GetOutputSizePixel());
+
+        if (!m_xPatternLB->get_id(nId).isEmpty())
+        {
+            m_xPatternLB->set_image(nId, *aVDev);
+            m_xPatternLB->set_id(nId, sId);
+            m_xPatternLB->set_text(nId, aString);
+        }
+        else
+        {
+            m_xPatternLB->insert(-1, &aString, &sId, &aBmp, nullptr);
+        }
+    }
+
+    m_xPatternLB->thaw();
 }
 
 void SvxPatternTabPage::ActivatePage( const SfxItemSet& rSet )
@@ -181,12 +208,14 @@ void SvxPatternTabPage::ActivatePage( const SfxItemSet& 
rSet )
         sal_Int32 nPos = SearchPatternList( aItem.GetName() );
         if ( nPos != -1)
         {
-            sal_uInt16 nId = m_xPatternLB->GetItemId( static_cast<size_t>( 
nPos ) );
-            m_xPatternLB->SelectItem( nId );
+            m_xPatternLB->select( nPos );
         }
     }
     else
-        m_xPatternLB->SelectItem( m_xPatternLB->GetItemId( 
static_cast<size_t>( 0 ) ) );
+        m_xPatternLB->select( 0 );
+
+    // colors could have been deleted
+    ChangePatternHdl_Impl(*m_xPatternLB);
 }
 
 
@@ -202,11 +231,13 @@ DeactivateRC SvxPatternTabPage::DeactivatePage( 
SfxItemSet* _pSet)
 bool SvxPatternTabPage::FillItemSet( SfxItemSet* _rOutAttrs )
 {
     _rOutAttrs->Put(XFillStyleItem(drawing::FillStyle_BITMAP));
-    size_t nPos = m_xPatternLB->IsNoSelection() ? VALUESET_ITEM_NOTFOUND : 
m_xPatternLB->GetSelectItemPos();
-    if(VALUESET_ITEM_NOTFOUND != nPos)
+    OUString sId = m_xPatternLB->get_selected_id();
+    sal_Int32 nPos = !sId.isEmpty() ? sId.toInt32() : -1;
+
+    if(nPos != -1)
     {
         const XBitmapEntry* pXBitmapEntry = m_pPatternList->GetBitmap( 
static_cast<sal_uInt16>(nPos) );
-        const OUString aString( m_xPatternLB->GetItemText( 
m_xPatternLB->GetSelectedItemId() ) );
+        const OUString aString( m_pPatternList->GetBitmap(nPos)->GetName() );
 
         _rOutAttrs->Put(XFillBitmapItem(aString, 
pXBitmapEntry->GetGraphicObject()));
     }
@@ -236,7 +267,7 @@ void SvxPatternTabPage::Reset( const SfxItemSet*  )
         m_aCtlPreview.Invalidate();
     }
 
-    ChangePatternHdl_Impl(m_xPatternLB.get());
+    ChangePatternHdl_Impl(*m_xPatternLB);
 
     // determine button state
     if( m_pPatternList.is() && m_pPatternList->Count() )
@@ -256,12 +287,13 @@ std::unique_ptr<SfxTabPage> SvxPatternTabPage::Create( 
weld::Container* pPage, w
     return std::make_unique<SvxPatternTabPage>(pPage, pController, *rSet);
 }
 
-IMPL_LINK_NOARG(SvxPatternTabPage, ChangePatternHdl_Impl, ValueSet*, void)
+IMPL_LINK_NOARG(SvxPatternTabPage, ChangePatternHdl_Impl, weld::IconView&, 
void)
 {
     std::unique_ptr<GraphicObject> pGraphicObject;
-    size_t nPos = m_xPatternLB->GetSelectItemPos();
+    OUString sId = m_xPatternLB->get_selected_id();
+    sal_Int32 nPos = !sId.isEmpty() ? sId.toInt32() : -1;
 
-    if(VALUESET_ITEM_NOTFOUND != nPos)
+    if(nPos != -1)
     {
         pGraphicObject.reset(new GraphicObject(m_pPatternList->GetBitmap( 
static_cast<sal_uInt16>(nPos) )->GetGraphicObject()));
     }
@@ -278,14 +310,10 @@ IMPL_LINK_NOARG(SvxPatternTabPage, ChangePatternHdl_Impl, 
ValueSet*, void)
             }
         }
 
-        if(!pGraphicObject)
+        if(!pGraphicObject && m_xPatternLB->n_children() > 0)
         {
-            sal_uInt16 nPosition = m_xPatternLB->GetItemId( 0 );
-            m_xPatternLB->SelectItem( nPosition );
-            if( nPosition != 0 )
-            {
-                pGraphicObject.reset(new 
GraphicObject(m_pPatternList->GetBitmap(0)->GetGraphicObject()));
-            }
+            m_xPatternLB->select(0);
+            pGraphicObject.reset(new 
GraphicObject(m_pPatternList->GetBitmap(0)->GetGraphicObject()));
         }
     }
 
@@ -394,15 +422,20 @@ IMPL_LINK_NOARG(SvxPatternTabPage, ClickAddHdl_Impl, 
weld::Button&, void)
         if( pEntry )
         {
             m_pPatternList->Insert(std::move(pEntry), nCount);
-            sal_Int32 nId = m_xPatternLB->GetItemId( nCount - 1 );
-            Bitmap aBitmap = m_pPatternList->GetBitmapForPreview( nCount, 
m_xPatternLB->GetIconSize() );
-            m_xPatternLB->InsertItem( nId + 1, Image(aBitmap), aName );
-            m_xPatternLB->SelectItem( nId + 1 );
-            m_xPatternLB->Resize();
+
+            OUString sId = nCount > 0 ? m_xPatternLB->get_id( nCount - 1 ) : 
OUString();
+            sal_Int32 nId = !sId.isEmpty() ? sId.toInt32() : -1;
+            Bitmap aBitmapEx = m_pPatternList->GetBitmapForPreview( nCount, 
aIconSize );
+            VclPtr<VirtualDevice> pVDev = GetVirtualDevice(aBitmapEx);
+            Bitmap aBmp = pVDev->GetBitmap(Point(), 
pVDev->GetOutputSizePixel());
+
+            m_xPatternLB->insert( nId + 1, &aName, &sId, &aBmp, nullptr);
+            FillPresetListBox();
+            m_xPatternLB->select( nId + 1 );
 
             m_nPatternListState |= ChangeType::MODIFIED;
 
-            ChangePatternHdl_Impl(m_xPatternLB.get());
+            ChangePatternHdl_Impl(*m_xPatternLB);
         }
     }
 
@@ -415,10 +448,10 @@ IMPL_LINK_NOARG(SvxPatternTabPage, ClickAddHdl_Impl, 
weld::Button&, void)
 
 IMPL_LINK_NOARG(SvxPatternTabPage, ClickModifyHdl_Impl, weld::Button&, void)
 {
-    sal_uInt16 nId = m_xPatternLB->GetSelectedItemId();
-    size_t nPos = m_xPatternLB->GetSelectItemPos();
+    OUString sId = m_xPatternLB->get_selected_id();
+    sal_Int32 nPos = !sId.isEmpty() ? sId.toInt32() : -1;
 
-    if ( nPos == VALUESET_ITEM_NOTFOUND )
+    if ( nPos == -1 )
         return;
 
     OUString aName( m_pPatternList->GetBitmap( static_cast<sal_uInt16>(nPos) 
)->GetName() );
@@ -426,21 +459,103 @@ IMPL_LINK_NOARG(SvxPatternTabPage, ClickModifyHdl_Impl, 
weld::Button&, void)
     // #i123497# Need to replace the existing entry with a new one (old 
returned needs to be deleted)
     
m_pPatternList->Replace(std::make_unique<XBitmapEntry>(Graphic(m_xBitmapCtl->GetBitmap()),
 aName), nPos);
 
-    Bitmap aBitmap = m_pPatternList->GetBitmapForPreview( 
static_cast<sal_uInt16>( nPos ), m_xPatternLB->GetIconSize() );
-    m_xPatternLB->RemoveItem(nId);
-    m_xPatternLB->InsertItem( nId, Image(aBitmap), aName, 
static_cast<sal_uInt16>(nPos) );
-    m_xPatternLB->SelectItem( nId );
+    Bitmap aBitmapEx = m_pPatternList->GetBitmapForPreview( 
static_cast<sal_uInt16>(nPos), aIconSize );
+    VclPtr<VirtualDevice> pVDev = GetVirtualDevice(aBitmapEx);
+    Bitmap aBmp = pVDev->GetBitmap(Point(), pVDev->GetOutputSizePixel());
+
+    m_xPatternLB->remove( nPos );
+    m_xPatternLB->insert( nPos, &aName, &sId, &aBmp, nullptr);
+    FillPresetListBox();
+    m_xPatternLB->select( nPos );
 
     m_nPatternListState |= ChangeType::MODIFIED;
 }
 
+VclPtr<VirtualDevice> SvxPatternTabPage::GetVirtualDevice(Bitmap aBitmap)
+{
+    VclPtr<VirtualDevice> pVDev = VclPtr<VirtualDevice>::Create();
+    const Point aNull(0, 0);
+    if (pVDev->GetDPIScaleFactor() > 1)
+        aBitmap.Scale(pVDev->GetDPIScaleFactor(), pVDev->GetDPIScaleFactor());
+    const Size aSize(aBitmap.GetSizePixel());
+    pVDev->SetOutputSizePixel(aSize);
+    pVDev->DrawBitmap(aNull, aBitmap);
+
+    return pVDev;
+}
 
-IMPL_LINK_NOARG(SvxPatternTabPage, ClickRenameHdl_Impl, SvxPresetListBox*, 
void)
+IMPL_LINK(SvxPatternTabPage, QueryTooltipHdl, const weld::TreeIter&, rIter, 
OUString)
 {
-    const sal_uInt16 nId = m_xPatternLB->GetContextMenuItemId();
-    const size_t nPos = m_xPatternLB->GetItemPos(nId);
+    OUString sId = m_xPatternLB->get_id(rIter);
+    sal_Int32 nId = !sId.isEmpty() ? sId.toInt32() : -1;
 
-    if ( nPos == VALUESET_ITEM_NOTFOUND )
+    if (nId >= 0)
+    {
+        return m_pPatternList->GetBitmap(nId)->GetName();
+    }
+    return OUString();
+}
+
+IMPL_LINK(SvxPatternTabPage, MousePressHdl, const MouseEvent&, rMEvt, bool)
+{
+    if (!rMEvt.IsRight())
+        return false;
+
+    // Disable context menu for LibreOfficeKit mode
+    if (comphelper::LibreOfficeKit::isActive())
+        return false;
+
+    const Point& pPos = rMEvt.GetPosPixel();
+    for (int i = 0; i < m_xPatternLB->n_children(); i++)
+    {
+        const ::tools::Rectangle aRect = m_xPatternLB->get_rect(i);
+        if (aRect.Contains(pPos))
+        {
+            ShowContextMenu(pPos);
+            break;
+        }
+    }
+    return false;
+}
+
+void SvxPatternTabPage::ShowContextMenu(const Point& pPos)
+{
+    ::tools::Rectangle aRect(pPos, Size(1, 1));
+    std::unique_ptr<weld::Builder> xBuilder(
+        Application::CreateBuilder(m_xPatternLB.get(), 
u"svx/ui/presetmenu.ui"_ustr));
+    std::unique_ptr<weld::Menu> xMenu(xBuilder->weld_menu(u"menu"_ustr));
+
+    xMenu->connect_activate(LINK(this, SvxPatternTabPage, OnPopupEnd));
+    xMenu->popup_at_rect(m_xPatternLB.get(), aRect);
+}
+
+IMPL_LINK(SvxPatternTabPage, OnPopupEnd, const OUString&, sCommand, void)
+{
+    sLastItemIdent = sCommand;
+    if (sLastItemIdent.isEmpty())
+        return;
+
+    Application::PostUserEvent(LINK(this, SvxPatternTabPage, 
MenuSelectAsyncHdl));
+}
+
+IMPL_LINK_NOARG(SvxPatternTabPage, MenuSelectAsyncHdl, void*, void)
+{
+    if (sLastItemIdent == u"rename")
+    {
+        ClickRenameHdl();
+    }
+    else if (sLastItemIdent == u"delete")
+    {
+        ClickDeleteHdl();
+    }
+}
+
+void SvxPatternTabPage::ClickRenameHdl()
+{
+    const OUString sId = m_xPatternLB->get_selected_id();
+    const sal_Int32 nPos = !sId.isEmpty() ? sId.toInt32() : -1;
+
+    if ( nPos == -1 )
         return;
 
     OUString aDesc(CuiResId(RID_CUISTR_DESC_NEW_PATTERN));
@@ -455,7 +570,7 @@ IMPL_LINK_NOARG(SvxPatternTabPage, ClickRenameHdl_Impl, 
SvxPresetListBox*, void)
     {
         aName = pDlg->GetName();
         sal_Int32 nPatternPos = SearchPatternList(aName);
-        bool bValidPatternName = (nPatternPos == static_cast<sal_Int32>(nPos) 
) || (nPatternPos == -1);
+        bool bValidPatternName = (nPatternPos == nPos ) || (nPatternPos == -1);
 
         if( bValidPatternName )
         {
@@ -463,7 +578,7 @@ IMPL_LINK_NOARG(SvxPatternTabPage, ClickRenameHdl_Impl, 
SvxPresetListBox*, void)
 
             m_pPatternList->GetBitmap(nPos)->SetName(aName);
 
-            m_xPatternLB->SetItemText( nId, aName );
+            m_xPatternLB->set_text( nPos, aName );
 
             m_nPatternListState |= ChangeType::MODIFIED;
         }
@@ -476,29 +591,30 @@ IMPL_LINK_NOARG(SvxPatternTabPage, ClickRenameHdl_Impl, 
SvxPresetListBox*, void)
     }
 }
 
-IMPL_LINK_NOARG(SvxPatternTabPage, ClickDeleteHdl_Impl, SvxPresetListBox*, 
void)
+void SvxPatternTabPage::ClickDeleteHdl()
 {
-    const sal_uInt16 nId = m_xPatternLB->GetContextMenuItemId();
-    const size_t nPos = m_xPatternLB->GetItemPos(nId);
+    const OUString sId = m_xPatternLB->get_selected_id();
+    const sal_Int32 nPos = !sId.isEmpty() ? sId.toInt32() : -1;
 
-    if( nPos != VALUESET_ITEM_NOTFOUND )
+    if( nPos != -1 )
     {
         std::unique_ptr<weld::Builder> 
xBuilder(Application::CreateBuilder(GetFrameWeld(), 
u"cui/ui/querydeletebitmapdialog.ui"_ustr));
         std::unique_ptr<weld::MessageDialog> 
xQueryBox(xBuilder->weld_message_dialog(u"AskDelBitmapDialog"_ustr));
         if (xQueryBox->run() == RET_YES)
         {
-            const bool bDeletingSelectedItem(nId == 
m_xPatternLB->GetSelectedItemId());
             m_pPatternList->Remove(nPos);
-            m_xPatternLB->RemoveItem( nId );
-            if (bDeletingSelectedItem)
-            {
-                
m_xPatternLB->SelectItem(m_xPatternLB->GetItemId(/*Position=*/0));
-                m_aCtlPreview.Invalidate();
-                m_xCtlPixel->Invalidate();
-            }
-            m_xPatternLB->Resize();
+            m_xPatternLB->remove( nPos );
+
+            FillPresetListBox();
 
-            ChangePatternHdl_Impl(m_xPatternLB.get());
+            sal_Int32 nNextId = nPos;
+            if (nPos >= m_xPatternLB->n_children())
+                nNextId = m_xPatternLB->n_children() - 1;
+
+            if(m_xPatternLB->n_children() > 0)
+                m_xPatternLB->select(nNextId);
+
+            ChangePatternHdl_Impl(*m_xPatternLB);
 
             m_nPatternListState |= ChangeType::MODIFIED;
         }
@@ -513,7 +629,6 @@ IMPL_LINK_NOARG(SvxPatternTabPage, ClickDeleteHdl_Impl, 
SvxPresetListBox*, void)
 IMPL_LINK_NOARG(SvxPatternTabPage, ChangeColorHdl_Impl, ColorListBox&, void)
 {
     ChangeColor_Impl();
-    m_xPatternLB->SetNoSelection();
 }
 
 void SvxPatternTabPage::ChangeColor_Impl()
@@ -542,8 +657,6 @@ void SvxPatternTabPage::PointChanged(weld::DrawingArea* 
pDrawingArea, RectPoint)
         m_aCtlPreview.SetAttributes( m_aXFillAttr.GetItemSet() );
         m_aCtlPreview.Invalidate();
     }
-
-    m_xPatternLB->SetNoSelection();
 }
 
 sal_Int32 SvxPatternTabPage::SearchPatternList(std::u16string_view 
rPatternName)
diff --git a/cui/uiconfig/ui/patterntabpage.ui 
b/cui/uiconfig/ui/patterntabpage.ui
index f3e25e5a0f23..d315103cd1e3 100644
--- a/cui/uiconfig/ui/patterntabpage.ui
+++ b/cui/uiconfig/ui/patterntabpage.ui
@@ -2,6 +2,14 @@
 <!-- Generated with glade 3.36.0 -->
 <interface domain="cui">
   <requires lib="gtk+" version="3.24"/>
+  <object class="GtkTreeStore" id="liststore1">
+    <columns>
+      <!-- column-name pixbuf -->
+      <column type="GdkPixbuf"/>
+      <!-- column-name id -->
+      <column type="gchararray"/>
+    </columns>
+  </object>
   <object class="GtkBox" id="PatternTabPage">
     <property name="visible">True</property>
     <property name="can_focus">False</property>
@@ -29,20 +37,20 @@
                 <property name="can_focus">True</property>
                 <property name="vexpand">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>
                 <child>
-                  <object class="GtkViewport">
+                  <object class="GtkIconView" id="patternpresetlist">
                     <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <child>
-                      <object class="GtkDrawingArea" id="patternpresetlist">
-                        <property name="visible">True</property>
-                        <property name="can_focus">True</property>
-                        <property name="events">GDK_BUTTON_MOTION_MASK | 
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_STRUCTURE_MASK</property>
-                        <property name="vexpand">True</property>
-                      </object>
-                    </child>
+                    <property name="item-padding">2</property>
+                    <property name="can-focus">True</property>
+                    <property name="hexpand">False</property>
+                    <property name="vexpand">True</property>
+                    <property name="model">liststore1</property>
+                    <property name="pixbuf-column">0</property>
+                    <property name="margin">6</property>
+                    <property name="columns">3</property>
+                    <property name="activate-on-single-click">True</property>
                   </object>
                 </child>
               </object>

Reply via email to