diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-10-04 15:31:35 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-10-05 09:05:32 +0200 |
commit | 83c00b33594a59157ed483eb11c3c5022c978939 (patch) | |
tree | 88cdb6525b70722ac572c61ec550aee69ef1a32f /svx/source | |
parent | b93ae66b210f98c193263c4c1cd26d896bbf8e83 (diff) |
loplugin:mergerclass merge FillAttrLB with SvxFillAttrBox
Change-Id: I5dfa7689eb219548bde7ce181a0a453c84b0f066
Reviewed-on: https://gerrit.libreoffice.org/43136
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svx/source')
-rw-r--r-- | svx/source/dialog/dlgctrl.cxx | 143 | ||||
-rw-r--r-- | svx/source/tbxctrls/itemwin.cxx | 145 |
2 files changed, 141 insertions, 147 deletions
diff --git a/svx/source/dialog/dlgctrl.cxx b/svx/source/dialog/dlgctrl.cxx index e031b940a0b8..3a109baa72d1 100644 --- a/svx/source/dialog/dlgctrl.cxx +++ b/svx/source/dialog/dlgctrl.cxx @@ -1044,27 +1044,6 @@ extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL makeHatchingLB(VclPtr<vcl::Window> // Fills the listbox (provisional) with strings -void FillAttrLB::Fill( const XHatchListRef &pList ) -{ - long nCount = pList->Count(); - ListBox::SetUpdateMode( false ); - - for( long i = 0; i < nCount; i++ ) - { - const XHatchEntry* pEntry = pList->GetHatch(i); - const Bitmap aBitmap = pList->GetUiBitmap( i ); - if( !aBitmap.IsEmpty() ) - ListBox::InsertEntry(pEntry->GetName(), Image(aBitmap)); - else - InsertEntry( pEntry->GetName() ); - } - - AdaptDropDownLineCountToMaximum(); - ListBox::SetUpdateMode( true ); -} - -// Fills the listbox (provisional) with strings - GradientLB::GradientLB( vcl::Window* pParent, WinBits aWB) : ListBox( pParent, aWB ) { @@ -1082,27 +1061,6 @@ extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL makeGradientLB(VclPtr<vcl::Window> rRet = pListBox; } -// Fills the listbox (provisional) with strings - -void FillAttrLB::Fill( const XGradientListRef &pList ) -{ - long nCount = pList->Count(); - ListBox::SetUpdateMode( false ); - - for( long i = 0; i < nCount; i++ ) - { - const XGradientEntry* pEntry = pList->GetGradient(i); - const Bitmap aBitmap = pList->GetUiBitmap( i ); - if( !aBitmap.IsEmpty() ) - ListBox::InsertEntry(pEntry->GetName(), Image(aBitmap)); - else - InsertEntry( pEntry->GetName() ); - } - - AdaptDropDownLineCountToMaximum(); - ListBox::SetUpdateMode( true ); -} - // BitmapLB Constructor BitmapLB::BitmapLB( vcl::Window* pParent, WinBits aWB) @@ -1122,107 +1080,6 @@ extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL makeBitmapLB(VclPtr<vcl::Window> & rRet = pListBox; } -namespace -{ - void formatBitmapExToSize(BitmapEx& rBitmapEx, const Size& rSize) - { - if(!rBitmapEx.IsEmpty() && rSize.Width() > 0 && rSize.Height() > 0) - { - ScopedVclPtrInstance< VirtualDevice > pVirtualDevice; - pVirtualDevice->SetOutputSizePixel(rSize); - - if(rBitmapEx.IsTransparent()) - { - const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); - - if(rStyleSettings.GetPreviewUsesCheckeredBackground()) - { - const Point aNull(0, 0); - static const sal_uInt32 nLen(8); - static const Color aW(COL_WHITE); - static const Color aG(0xef, 0xef, 0xef); - - pVirtualDevice->DrawCheckered(aNull, rSize, nLen, aW, aG); - } - else - { - pVirtualDevice->SetBackground(rStyleSettings.GetFieldColor()); - pVirtualDevice->Erase(); - } - } - - if(rBitmapEx.GetSizePixel().Width() >= rSize.Width() && rBitmapEx.GetSizePixel().Height() >= rSize.Height()) - { - rBitmapEx.Scale(rSize); - pVirtualDevice->DrawBitmapEx(Point(0, 0), rBitmapEx); - } - else - { - const Size aBitmapSize(rBitmapEx.GetSizePixel()); - - for(long y(0); y < rSize.Height(); y += aBitmapSize.Height()) - { - for(long x(0); x < rSize.Width(); x += aBitmapSize.Width()) - { - pVirtualDevice->DrawBitmapEx( - Point(x, y), - rBitmapEx); - } - } - } - - rBitmapEx = pVirtualDevice->GetBitmap(Point(0, 0), rSize); - } - } -} // end of anonymous namespace - -FillAttrLB::FillAttrLB(vcl::Window* pParent, WinBits aWB) - : ListBox(pParent, aWB) -{ -} - -void FillAttrLB::Fill( const XBitmapListRef &pList ) -{ - const long nCount(pList->Count()); - const XBitmapEntry* pEntry; - const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); - const Size aSize(rStyleSettings.GetListBoxPreviewDefaultPixelSize()); - - ListBox::SetUpdateMode(false); - - for(long i(0); i < nCount; i++) - { - pEntry = pList->GetBitmap( i ); - maBitmapEx = pEntry->GetGraphicObject().GetGraphic().GetBitmapEx(); - formatBitmapExToSize(maBitmapEx, aSize); - ListBox::InsertEntry(pEntry->GetName(), Image(maBitmapEx)); - } - - AdaptDropDownLineCountToMaximum(); - ListBox::SetUpdateMode(true); -} - -void FillAttrLB::Fill( const XPatternListRef &pList ) -{ - const long nCount(pList->Count()); - const XBitmapEntry* pEntry; - const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); - const Size aSize(rStyleSettings.GetListBoxPreviewDefaultPixelSize()); - - ListBox::SetUpdateMode(false); - - for(long i(0); i < nCount; i++) - { - pEntry = pList->GetBitmap( i ); - maBitmapEx = pEntry->GetGraphicObject().GetGraphic().GetBitmapEx(); - formatBitmapExToSize(maBitmapEx, aSize); - ListBox::InsertEntry(pEntry->GetName(), Image(maBitmapEx)); - } - - AdaptDropDownLineCountToMaximum(); - ListBox::SetUpdateMode(true); -} - void FillTypeLB::Fill() { SetUpdateMode( false ); diff --git a/svx/source/tbxctrls/itemwin.cxx b/svx/source/tbxctrls/itemwin.cxx index b76fbebc7b73..01a189ec6ba5 100644 --- a/svx/source/tbxctrls/itemwin.cxx +++ b/svx/source/tbxctrls/itemwin.cxx @@ -49,7 +49,6 @@ using namespace ::com::sun::star; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::frame; -using namespace ::com::sun::star::util; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::beans; @@ -461,7 +460,7 @@ void SvxFillTypeBox::ReleaseFocus_Impl() } SvxFillAttrBox::SvxFillAttrBox( vcl::Window* pParent ) : - FillAttrLB( pParent, WB_BORDER | WB_DROPDOWN | WB_AUTOHSCROLL | WB_TABSTOP ), + ListBox(pParent, WB_BORDER | WB_DROPDOWN | WB_AUTOHSCROLL | WB_TABSTOP), nCurPos( 0 ) { SetPosPixel( Point( 90, 0 ) ); @@ -478,13 +477,13 @@ bool SvxFillAttrBox::PreNotify( NotifyEvent& rNEvt ) if ( MouseNotifyEvent::MOUSEBUTTONDOWN == nType || MouseNotifyEvent::GETFOCUS == nType ) nCurPos = GetSelectedEntryPos(); - return FillAttrLB::PreNotify( rNEvt ); + return ListBox::PreNotify( rNEvt ); } bool SvxFillAttrBox::EventNotify( NotifyEvent& rNEvt ) { - bool bHandled = FillAttrLB::EventNotify( rNEvt ); + bool bHandled = ListBox::EventNotify( rNEvt ); if ( rNEvt.GetType() == MouseNotifyEvent::KEYINPUT ) { @@ -521,4 +520,142 @@ void SvxFillAttrBox::ReleaseFocus_Impl() } } +// Fills the listbox (provisional) with strings + +void SvxFillAttrBox::Fill( const XHatchListRef &pList ) +{ + long nCount = pList->Count(); + ListBox::SetUpdateMode( false ); + + for( long i = 0; i < nCount; i++ ) + { + const XHatchEntry* pEntry = pList->GetHatch(i); + const Bitmap aBitmap = pList->GetUiBitmap( i ); + if( !aBitmap.IsEmpty() ) + ListBox::InsertEntry(pEntry->GetName(), Image(aBitmap)); + else + InsertEntry( pEntry->GetName() ); + } + + AdaptDropDownLineCountToMaximum(); + ListBox::SetUpdateMode( true ); +} + +// Fills the listbox (provisional) with strings + +void SvxFillAttrBox::Fill( const XGradientListRef &pList ) +{ + long nCount = pList->Count(); + ListBox::SetUpdateMode( false ); + + for( long i = 0; i < nCount; i++ ) + { + const XGradientEntry* pEntry = pList->GetGradient(i); + const Bitmap aBitmap = pList->GetUiBitmap( i ); + if( !aBitmap.IsEmpty() ) + ListBox::InsertEntry(pEntry->GetName(), Image(aBitmap)); + else + InsertEntry( pEntry->GetName() ); + } + + AdaptDropDownLineCountToMaximum(); + ListBox::SetUpdateMode( true ); +} + +namespace +{ + void formatBitmapExToSize(BitmapEx& rBitmapEx, const Size& rSize) + { + if(!rBitmapEx.IsEmpty() && rSize.Width() > 0 && rSize.Height() > 0) + { + ScopedVclPtrInstance< VirtualDevice > pVirtualDevice; + pVirtualDevice->SetOutputSizePixel(rSize); + + if(rBitmapEx.IsTransparent()) + { + const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); + + if(rStyleSettings.GetPreviewUsesCheckeredBackground()) + { + const Point aNull(0, 0); + static const sal_uInt32 nLen(8); + static const Color aW(COL_WHITE); + static const Color aG(0xef, 0xef, 0xef); + + pVirtualDevice->DrawCheckered(aNull, rSize, nLen, aW, aG); + } + else + { + pVirtualDevice->SetBackground(rStyleSettings.GetFieldColor()); + pVirtualDevice->Erase(); + } + } + + if(rBitmapEx.GetSizePixel().Width() >= rSize.Width() && rBitmapEx.GetSizePixel().Height() >= rSize.Height()) + { + rBitmapEx.Scale(rSize); + pVirtualDevice->DrawBitmapEx(Point(0, 0), rBitmapEx); + } + else + { + const Size aBitmapSize(rBitmapEx.GetSizePixel()); + + for(long y(0); y < rSize.Height(); y += aBitmapSize.Height()) + { + for(long x(0); x < rSize.Width(); x += aBitmapSize.Width()) + { + pVirtualDevice->DrawBitmapEx( + Point(x, y), + rBitmapEx); + } + } + } + + rBitmapEx = pVirtualDevice->GetBitmap(Point(0, 0), rSize); + } + } +} // end of anonymous namespace + +void SvxFillAttrBox::Fill( const XBitmapListRef &pList ) +{ + const long nCount(pList->Count()); + const XBitmapEntry* pEntry; + const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); + const Size aSize(rStyleSettings.GetListBoxPreviewDefaultPixelSize()); + + ListBox::SetUpdateMode(false); + + for(long i(0); i < nCount; i++) + { + pEntry = pList->GetBitmap( i ); + maBitmapEx = pEntry->GetGraphicObject().GetGraphic().GetBitmapEx(); + formatBitmapExToSize(maBitmapEx, aSize); + ListBox::InsertEntry(pEntry->GetName(), Image(maBitmapEx)); + } + + AdaptDropDownLineCountToMaximum(); + ListBox::SetUpdateMode(true); +} + +void SvxFillAttrBox::Fill( const XPatternListRef &pList ) +{ + const long nCount(pList->Count()); + const XBitmapEntry* pEntry; + const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); + const Size aSize(rStyleSettings.GetListBoxPreviewDefaultPixelSize()); + + ListBox::SetUpdateMode(false); + + for(long i(0); i < nCount; i++) + { + pEntry = pList->GetBitmap( i ); + maBitmapEx = pEntry->GetGraphicObject().GetGraphic().GetBitmapEx(); + formatBitmapExToSize(maBitmapEx, aSize); + ListBox::InsertEntry(pEntry->GetName(), Image(maBitmapEx)); + } + + AdaptDropDownLineCountToMaximum(); + ListBox::SetUpdateMode(true); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |