diff options
author | Rishabh Kumar <kris.kr296@gmail.com> | 2016-07-06 12:50:54 +0530 |
---|---|---|
committer | Katarina Behrens <Katarina.Behrens@cib.de> | 2016-07-06 14:22:07 +0000 |
commit | 6a4e4fc74b8b66961fbfa86cde88ce72f84d1544 (patch) | |
tree | 8bcf87a57480f47eedf5843fc14f2afa16e912b4 | |
parent | fc95bc132db20e7701088c76da6ec039031feadf (diff) |
Add XGradientList to SvxPresetListBox
Change-Id: I0b4af0eb465b997e8bea012b1f2e3cc07cce6ddb
Reviewed-on: https://gerrit.libreoffice.org/26953
Reviewed-by: Katarina Behrens <Katarina.Behrens@cib.de>
Tested-by: Katarina Behrens <Katarina.Behrens@cib.de>
-rw-r--r-- | include/svx/SvxPresetListBox.hxx | 6 | ||||
-rw-r--r-- | 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<SvxPresetListBox*,void> 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<EntryType*>( 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 ) |