From 6a4e4fc74b8b66961fbfa86cde88ce72f84d1544 Mon Sep 17 00:00:00 2001 From: Rishabh Kumar Date: Wed, 6 Jul 2016 12:50:54 +0530 Subject: Add XGradientList to SvxPresetListBox Change-Id: I0b4af0eb465b997e8bea012b1f2e3cc07cce6ddb Reviewed-on: https://gerrit.libreoffice.org/26953 Reviewed-by: Katarina Behrens Tested-by: Katarina Behrens --- include/svx/SvxPresetListBox.hxx | 6 ++++++ svx/source/tbxctrls/SvxPresetListBox.cxx | 17 ++++++++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/include/svx/SvxPresetListBox.hxx b/include/svx/SvxPresetListBox.hxx index 228ad2d49eb3..38e8d2b14e9a 100644 --- a/include/svx/SvxPresetListBox.hxx +++ b/include/svx/SvxPresetListBox.hxx @@ -35,6 +35,10 @@ private: Link maDeleteHdl; DECL_LINK_TYPED( OnMenuItemSelected, Menu*, bool ); + + template< typename ListType, typename EntryType > + void FillPresetListBoxImpl(ListType& pList, sal_uInt32 nStartIndex = 1); + public: SvxPresetListBox(vcl::Window* pParent, WinBits nWinStyle = WB_ITEMBORDER); @@ -52,6 +56,8 @@ public: { maDeleteHdl = rLink; } + + void FillPresetListBox(XGradientList& pList, sal_uInt32 nStartIndex = 1); void FillPresetListBox(XHatchList& pList, sal_uInt32 nStartIndex = 1); void DrawLayout(); diff --git a/svx/source/tbxctrls/SvxPresetListBox.cxx b/svx/source/tbxctrls/SvxPresetListBox.cxx index c14ad1fa0bba..6a421cd6eac6 100644 --- a/svx/source/tbxctrls/SvxPresetListBox.cxx +++ b/svx/source/tbxctrls/SvxPresetListBox.cxx @@ -85,18 +85,29 @@ void SvxPresetListBox::DrawLayout() SetColCount(getColumnCount()); SetLineCount(5); } - -void SvxPresetListBox::FillPresetListBox(XHatchList& pList, sal_uInt32 nStartIndex) +template< typename ListType, typename EntryType > +void SvxPresetListBox::FillPresetListBoxImpl(ListType & pList, sal_uInt32 nStartIndex) { const Size aSize(100,60); BitmapEx aBitmap; for(long nIndex = 0; nIndex < pList.Count(); nIndex++, nStartIndex++) { aBitmap = pList.GetBitmapForPreview(nIndex, aSize); - InsertItem(nStartIndex, Image(aBitmap), pList.GetHatch( nIndex )->GetName()); + EntryType *pItem = static_cast( pList.Get( nIndex ) ); + InsertItem(nStartIndex, Image(aBitmap), pItem->GetName()); } } +void SvxPresetListBox::FillPresetListBox(XGradientList& pList, sal_uInt32 nStartIndex) +{ + FillPresetListBoxImpl< XGradientList, XGradientEntry>( pList, nStartIndex ); +} + +void SvxPresetListBox::FillPresetListBox(XHatchList& pList, sal_uInt32 nStartIndex) +{ + FillPresetListBoxImpl< XHatchList, XHatchEntry>( pList, nStartIndex ); +} + IMPL_LINK_TYPED(SvxPresetListBox, OnMenuItemSelected, Menu*, pMenu, bool) { if( pMenu == nullptr ) -- cgit