diff options
author | Caolán McNamara <caolanm@redhat.com> | 2011-05-23 13:58:53 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2011-05-23 13:58:53 +0100 |
commit | b884958ff7102bcbef5623a1d443ae9e2bf06313 (patch) | |
tree | 07ed2c9331ae943b41158307e275565d60f5187e /svtools | |
parent | 795e0976bef1cfd9a3ffe0b339fa3ed5329205d5 (diff) |
Resolves: fdo#36940 use natural string sorter as default svtools string sorter
Diffstat (limited to 'svtools')
-rw-r--r-- | svtools/source/contnr/svimpbox.cxx | 37 | ||||
-rw-r--r-- | svtools/source/contnr/svtreebx.cxx | 5 | ||||
-rw-r--r-- | svtools/source/inc/svimpbox.hxx | 12 |
3 files changed, 33 insertions, 21 deletions
diff --git a/svtools/source/contnr/svimpbox.cxx b/svtools/source/contnr/svimpbox.cxx index f8550e0b5b3c..ac327a844444 100644 --- a/svtools/source/contnr/svimpbox.cxx +++ b/svtools/source/contnr/svimpbox.cxx @@ -44,6 +44,7 @@ #include <tools/wintypes.hxx> #include <svtools/svtools.hrc> #include <comphelper/processfactory.hxx> +#include <comphelper/string.hxx> #define NODE_BMP_TABDIST_NOTVALID -2000000 #define FIRST_ENTRY_TAB 1 @@ -64,7 +65,7 @@ SvImpLBox::SvImpLBox( SvTreeListBox* pLBView, SvLBoxTreeList* pLBTree, WinBits n aFctSet( this, &aSelEng, pLBView ), nExtendedWinBits( 0 ), bAreChildrenTransient( sal_True ), - pIntlWrapper( NULL ) // #102891# ----------------------- + m_pStringSorter(NULL) { osl_incrementInterlockedCount(&s_nImageRefCount); pView = pLBView; @@ -126,9 +127,7 @@ SvImpLBox::~SvImpLBox() aEditTimer.Stop(); StopUserEvent(); - // #102891# --------------------- - if( pIntlWrapper ) - delete pIntlWrapper; + delete m_pStringSorter; if ( osl_decrementInterlockedCount(&s_nImageRefCount) == 0 ) { DELETEZ(s_pDefCollapsed); @@ -136,23 +135,29 @@ SvImpLBox::~SvImpLBox() } } -// #102891# -------------------- -void SvImpLBox::UpdateIntlWrapper() +void SvImpLBox::UpdateStringSorter() { - const ::com::sun::star::lang::Locale & aNewLocale = Application::GetSettings().GetLocale(); - if( !pIntlWrapper ) - pIntlWrapper = new IntlWrapper( ::comphelper::getProcessServiceFactory(), aNewLocale ); - else + const ::com::sun::star::lang::Locale& rNewLocale = Application::GetSettings().GetLocale(); + + if( m_pStringSorter ) { - const ::com::sun::star::lang::Locale &aLocale = pIntlWrapper->getLocale(); - if( aLocale.Language != aNewLocale.Language || // different Locale from the older one - aLocale.Country != aNewLocale.Country || - aLocale.Variant != aNewLocale.Variant ) + // different Locale from the older one, drop it and force recreate + const ::com::sun::star::lang::Locale &aLocale = m_pStringSorter->getLocale(); + if( aLocale.Language != rNewLocale.Language || + aLocale.Country != rNewLocale.Country || + aLocale.Variant != rNewLocale.Variant ) { - delete pIntlWrapper; - pIntlWrapper = new IntlWrapper( ::comphelper::getProcessServiceFactory(), aNewLocale ); + delete m_pStringSorter; + m_pStringSorter = NULL; } } + + if( !m_pStringSorter ) + { + m_pStringSorter = new comphelper::string::NaturalStringSorter( + ::comphelper::getProcessComponentContext(), + rNewLocale); + } } // #97680# ---------------------- diff --git a/svtools/source/contnr/svtreebx.cxx b/svtools/source/contnr/svtreebx.cxx index 08174ca0cd96..d03b956bf571 100644 --- a/svtools/source/contnr/svtreebx.cxx +++ b/svtools/source/contnr/svtreebx.cxx @@ -37,6 +37,7 @@ class TabBar; #include <svtools/svlbitm.hxx> #include <svtools/svtreebx.hxx> #include <tools/diagnose_ex.h> +#include <comphelper/string.hxx> #include <svimpbox.hxx> #include <unotools/accessiblestatesethelper.hxx> #include <com/sun/star/accessibility/AccessibleStateType.hpp> @@ -2265,8 +2266,8 @@ IMPL_LINK( SvTreeListBox, DefaultCompare, SvSortData*, pData ) SvLBoxEntry* pRight = (SvLBoxEntry*)(pData->pRight ); String aLeft( ((SvLBoxString*)(pLeft->GetFirstItem(SV_ITEM_ID_LBOXSTRING)))->GetText()); String aRight( ((SvLBoxString*)(pRight->GetFirstItem(SV_ITEM_ID_LBOXSTRING)))->GetText()); - pImp->UpdateIntlWrapper(); - return pImp->pIntlWrapper->getCaseCollator()->compareString( aLeft, aRight ); + pImp->UpdateStringSorter(); + return pImp->m_pStringSorter->compare(aLeft, aRight); } void SvTreeListBox::ModelNotification( sal_uInt16 nActionId, SvListEntry* pEntry1, diff --git a/svtools/source/inc/svimpbox.hxx b/svtools/source/inc/svimpbox.hxx index 122416f8764d..c7603827f61e 100644 --- a/svtools/source/inc/svimpbox.hxx +++ b/svtools/source/inc/svimpbox.hxx @@ -47,6 +47,13 @@ class SvLBoxEntry; class SvLBoxItem; class SvLBoxTab; class TabBar; +namespace comphelper +{ + namespace string + { + class NaturalStringSorter; + } +} class ImpLBSelEng : public FunctionSet { @@ -163,7 +170,7 @@ private: Timer aEditTimer; // #102891# ------------------- - IntlWrapper * pIntlWrapper; + comphelper::string::NaturalStringSorter *m_pStringSorter; // #97680# -------------------- std::vector< short > aContextBmpWidthVector; @@ -239,8 +246,7 @@ private: static void implInitDefaultNodeImages(); - // #102891# ------------------- - void UpdateIntlWrapper(); + void UpdateStringSorter(); // #97680# -------------------- short UpdateContextBmpWidthVector( SvLBoxEntry* pEntry, short nWidth ); |