diff options
Diffstat (limited to 'vcl/source/control/ilstbox.cxx')
-rw-r--r-- | vcl/source/control/ilstbox.cxx | 87 |
1 files changed, 50 insertions, 37 deletions
diff --git a/vcl/source/control/ilstbox.cxx b/vcl/source/control/ilstbox.cxx index 016facae8e2c..a6cd7b980620 100644 --- a/vcl/source/control/ilstbox.cxx +++ b/vcl/source/control/ilstbox.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -47,6 +48,10 @@ #include <com/sun/star/accessibility/XAccessible.hpp> #include <com/sun/star/accessibility/AccessibleRole.hpp> +#include <rtl/instance.hxx> +#include <comphelper/string.hxx> +#include <comphelper/processfactory.hxx> + #define MULTILINE_ENTRY_DRAW_FLAGS ( TEXT_DRAW_WORDBREAK | TEXT_DRAW_MULTILINE | TEXT_DRAW_VCENTER ) using namespace ::com::sun::star; @@ -145,17 +150,29 @@ void ImplEntryList::SelectEntry( sal_uInt16 nPos, sal_Bool bSelect ) } } -// ----------------------------------------------------------------------- - -uno::Reference< i18n::XCollator > ImplGetCollator (lang::Locale &rLocale) +namespace { - static uno::Reference< i18n::XCollator > xCollator; - if ( !xCollator.is() ) - xCollator = vcl::unohelper::CreateCollator(); - if( xCollator.is() ) - xCollator->loadDefaultCollator (rLocale, 0); + struct theSorter + : public rtl::StaticWithInit< comphelper::string::NaturalStringSorter, theSorter > + { + comphelper::string::NaturalStringSorter operator () () + { + return comphelper::string::NaturalStringSorter( + ::comphelper::getProcessComponentContext(), + Application::GetSettings().GetLocale()); + } + }; +} - return xCollator; +namespace vcl +{ + namespace unohelper + { + const comphelper::string::NaturalStringSorter& getNaturalStringSorterForAppLocale() + { + return theSorter::get(); + } + } } sal_uInt16 ImplEntryList::InsertEntry( sal_uInt16 nPos, ImplEntryType* pNewEntry, sal_Bool bSort ) @@ -169,8 +186,7 @@ sal_uInt16 ImplEntryList::InsertEntry( sal_uInt16 nPos, ImplEntryType* pNewEntry } else { - lang::Locale aLocale = Application::GetSettings().GetLocale(); - uno::Reference< i18n::XCollator > xCollator = ImplGetCollator(aLocale); + const comphelper::string::NaturalStringSorter &rSorter = theSorter::get(); const XubString& rStr = pNewEntry->maStr; sal_uLong nLow, nHigh, nMid; @@ -183,9 +199,7 @@ sal_uInt16 ImplEntryList::InsertEntry( sal_uInt16 nPos, ImplEntryType* pNewEntry { // XXX even though XCollator::compareString returns a sal_Int32 the only // defined values are {-1, 0, 1} which is compatible with StringCompare - StringCompare eComp = xCollator.is() ? - (StringCompare)xCollator->compareString (rStr, pTemp->maStr) - : COMPARE_EQUAL; + StringCompare eComp = (StringCompare)rSorter.compare(rStr, pTemp->maStr); // Schnelles Einfuegen bei sortierten Daten if ( eComp != COMPARE_LESS ) @@ -197,7 +211,7 @@ sal_uInt16 ImplEntryList::InsertEntry( sal_uInt16 nPos, ImplEntryType* pNewEntry nLow = mnMRUCount; pTemp = (ImplEntryType*)GetEntry( (sal_uInt16)nLow ); - eComp = (StringCompare)xCollator->compareString (rStr, pTemp->maStr); + eComp = (StringCompare)rSorter.compare(rStr, pTemp->maStr); if ( eComp != COMPARE_GREATER ) { Insert( pNewEntry, (sal_uLong)0 ); @@ -211,7 +225,7 @@ sal_uInt16 ImplEntryList::InsertEntry( sal_uInt16 nPos, ImplEntryType* pNewEntry nMid = (nLow + nHigh) / 2; pTemp = (ImplEntryType*)GetObject( nMid ); - eComp = (StringCompare)xCollator->compareString (rStr, pTemp->maStr); + eComp = (StringCompare)rSorter.compare(rStr, pTemp->maStr); if ( eComp == COMPARE_LESS ) nHigh = nMid-1; @@ -234,8 +248,8 @@ sal_uInt16 ImplEntryList::InsertEntry( sal_uInt16 nPos, ImplEntryType* pNewEntry } catch (uno::RuntimeException& ) { - // XXX this is arguable, if the exception occured because pNewEntry is - // garbage you wouldn't insert it. If the exception occured because the + // XXX this is arguable, if the exception occurred because pNewEntry is + // garbage you wouldn't insert it. If the exception occurred because the // Collator implementation is garbage then give the user a chance to see // his stuff Insert( pNewEntry, (sal_uLong)0 ); @@ -2747,25 +2761,17 @@ ImplWin::ImplWin( Window* pParent, WinBits nWinStyle ) : // ----------------------------------------------------------------------- -sal_Bool ImplWin::SetModeImage( const Image& rImage, BmpColorMode eMode ) +sal_Bool ImplWin::SetModeImage( const Image& rImage ) { - if( eMode == BMP_COLOR_NORMAL ) - SetImage( rImage ); - else if( eMode == BMP_COLOR_HIGHCONTRAST ) - maImageHC = rImage; - else - return sal_False; + SetImage( rImage ); return sal_True; } // ----------------------------------------------------------------------- -const Image& ImplWin::GetModeImage( BmpColorMode eMode ) const +const Image& ImplWin::GetModeImage( ) const { - if( eMode == BMP_COLOR_HIGHCONTRAST ) - return maImageHC; - else - return maImage; + return maImage; } // ----------------------------------------------------------------------- @@ -2782,7 +2788,6 @@ void ImplWin::MouseButtonDown( const MouseEvent& ) { if( IsEnabled() ) { -// Control::MouseButtonDown( rMEvt ); MBDown(); } } @@ -2944,12 +2949,6 @@ void ImplWin::DrawEntry( sal_Bool bDrawImage, sal_Bool bDrawText, sal_Bool bDraw // check for HC mode Image *pImage = &maImage; - if( !!maImageHC ) - { - if( GetSettings().GetStyleSettings().GetHighContrastMode() ) - pImage = &maImageHC; - } - if ( !IsZoom() ) { DrawImage( aPtImg, *pImage, nStyle ); @@ -3183,6 +3182,11 @@ Size ImplListBoxFloatingWindow::CalcFloatSize() long nSBWidth = GetSettings().GetStyleSettings().GetScrollBarSize(); aFloatSz.Width() += nSBWidth; } + + long nDesktopWidth = GetDesktopRectPixel().getWidth(); + if (aFloatSz.Width() > nDesktopWidth) + // Don't exceed the desktop width. + aFloatSz.Width() = nDesktopWidth; } if ( aFloatSz.Height() > nMaxHeight ) @@ -3209,6 +3213,13 @@ Size ImplListBoxFloatingWindow::CalcFloatSize() aFloatSz.Height() = nInnerHeight + nTop + nBottom; } + if (aFloatSz.Width() < aSz.Width()) + { + // The max width of list box entries exceeds the window width. + // Account for the scroll bar height. + long nSBWidth = GetSettings().GetStyleSettings().GetScrollBarSize(); + aFloatSz.Height() += nSBWidth; + } return aFloatSz; } @@ -3262,3 +3273,5 @@ void ImplListBoxFloatingWindow::StartFloat( sal_Bool bStartTracking ) mpImplLB->GetMainWindow()->ImplClearLayoutData(); } } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |