summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2011-05-23 13:58:53 +0100
committerCaolán McNamara <caolanm@redhat.com>2011-05-23 13:58:53 +0100
commitb620170fcb3d5b759a4c4d1342561f30dc4b33a2 (patch)
treec7293053ddd940d0c86ea6ca1dbd333b271c8045
parent2272c8ca6b38a92d32454bc5c5774e9c5d780001 (diff)
Resolves: fdo#36940 use natural string sorter as default svtools string sorterfeature/calc-multiline-input
-rw-r--r--svtools/source/contnr/svimpbox.cxx37
-rw-r--r--svtools/source/contnr/svtreebx.cxx5
-rw-r--r--svtools/source/inc/svimpbox.hxx12
3 files changed, 33 insertions, 21 deletions
diff --git a/svtools/source/contnr/svimpbox.cxx b/svtools/source/contnr/svimpbox.cxx
index a5a78edcad..ab543a6a43 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 b9c0d88c0b..e9648d2eb0 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 e0958f9d2b..01648d8d3b 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 );