[Libreoffice-commits] .: 2 commits - comphelper/inc svtools/source

Caolán McNamara caolan at kemper.freedesktop.org
Mon May 23 06:03:18 PDT 2011


 comphelper/inc/comphelper/string.hxx |    1 
 svtools/source/contnr/svimpbox.cxx   |   37 +++++++++++++++++++----------------
 svtools/source/contnr/svtreebx.cxx   |    5 ++--
 svtools/source/inc/svimpbox.hxx      |   12 ++++++++---
 4 files changed, 34 insertions(+), 21 deletions(-)

New commits:
commit b620170fcb3d5b759a4c4d1342561f30dc4b33a2
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Mon May 23 13:58:53 2011 +0100

    Resolves: fdo#36940 use natural string sorter as default svtools string sorter

diff --git a/svtools/source/contnr/svimpbox.cxx b/svtools/source/contnr/svimpbox.cxx
index a5a78ed..ab543a6 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 b9c0d88..e9648d2 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 e0958f9..01648d8 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 );
commit 2272c8ca6b38a92d32454bc5c5774e9c5d780001
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Mon May 23 13:26:19 2011 +0100

    add getLocale to NaturalStringSorter

diff --git a/comphelper/inc/comphelper/string.hxx b/comphelper/inc/comphelper/string.hxx
index 5a14d85..5cc704d 100644
--- a/comphelper/inc/comphelper/string.hxx
+++ b/comphelper/inc/comphelper/string.hxx
@@ -190,6 +190,7 @@ public:
     {
         return compareNatural(rLHS, rRHS, m_xCollator, m_xBI, m_aLocale);
     }
+    const ::com::sun::star::lang::Locale& getLocale() const { return m_aLocale; }
 };
 
 } }


More information about the Libreoffice-commits mailing list