[Libreoffice-commits] core.git: vcl/inc vcl/source

Chr. Rossmanith ChrRossmanith at gmx.de
Thu Mar 7 04:36:59 PST 2013


 vcl/inc/vcl/combobox.hxx        |   26 ++++++++--------
 vcl/source/control/combobox.cxx |   65 ++++++++++++++++++++--------------------
 2 files changed, 46 insertions(+), 45 deletions(-)

New commits:
commit cd2c3e72a73fd4b91f913d8e19693d4deb35b0c4
Author: Chr. Rossmanith <ChrRossmanith at gmx.de>
Date:   Wed Mar 6 22:03:42 2013 +0100

    Replaced XubString with OUString in vcl(combobox)
    
    Change-Id: Ibe80e9837f1c8275d625e942eb75ecc8de897bf5
    Reviewed-on: https://gerrit.libreoffice.org/2574
    Reviewed-by: Fridrich Strba <fridrich at documentfoundation.org>
    Tested-by: Fridrich Strba <fridrich at documentfoundation.org>

diff --git a/vcl/inc/vcl/combobox.hxx b/vcl/inc/vcl/combobox.hxx
index 9758281..22ee570 100644
--- a/vcl/inc/vcl/combobox.hxx
+++ b/vcl/inc/vcl/combobox.hxx
@@ -120,28 +120,28 @@ public:
     sal_uInt16      GetDropDownLineCount() const;
 
     void            EnableAutoSize( sal_Bool bAuto );
-    sal_Bool            IsAutoSizeEnabled() const               { return mbDDAutoSize; }
+    sal_Bool        IsAutoSizeEnabled() const               { return mbDDAutoSize; }
 
     void            EnableDDAutoWidth( sal_Bool b );
 
     virtual void    SetText( const OUString& rStr );
     virtual void    SetText( const OUString& rStr, const Selection& rNewSelection );
 
-    sal_uInt16          InsertEntry( const XubString& rStr, sal_uInt16 nPos = COMBOBOX_APPEND );
-    sal_uInt16          InsertEntry( const XubString& rStr, const Image& rImage, sal_uInt16 nPos = COMBOBOX_APPEND );
+    sal_uInt16      InsertEntry( const OUString& rStr, sal_uInt16 nPos = COMBOBOX_APPEND );
+    sal_uInt16      InsertEntry( const OUString& rStr, const Image& rImage, sal_uInt16 nPos = COMBOBOX_APPEND );
 
-    void            RemoveEntry( const XubString& rStr );
+    void            RemoveEntry( const OUString& rStr );
     void            RemoveEntry( sal_uInt16 nPos );
 
     void            Clear();
 
-    sal_uInt16          GetEntryPos( const XubString& rStr ) const;
+    sal_uInt16      GetEntryPos( const OUString& rStr ) const;
     Image           GetEntryImage( sal_uInt16 nPos ) const;
-    XubString       GetEntry( sal_uInt16 nPos ) const;
-    sal_uInt16          GetEntryCount() const;
+    OUString        GetEntry( sal_uInt16 nPos ) const;
+    sal_uInt16      GetEntryCount() const;
 
-    sal_Bool            IsTravelSelect() const;
-    sal_Bool            IsInDropDown() const;
+    sal_Bool        IsTravelSelect() const;
+    sal_Bool        IsInDropDown() const;
     void            ToggleDropDown();
 
     long            CalcWindowSizePixel( sal_uInt16 nLines ) const;
@@ -155,10 +155,10 @@ public:
     void            SetSeparatorPos( sal_uInt16 n = LISTBOX_ENTRY_NOTFOUND );
 
     void            EnableAutocomplete( sal_Bool bEnable, sal_Bool bMatchCase = sal_False );
-    sal_Bool            IsAutocompleteEnabled() const;
+    sal_Bool        IsAutocompleteEnabled() const;
 
     void            EnableMultiSelection( sal_Bool bMulti );
-    sal_Bool            IsMultiSelectionEnabled() const;
+    sal_Bool        IsMultiSelectionEnabled() const;
     void            SetMultiSelectionSeparator( sal_Unicode cSep ) { mcMultiSep = cSep; }
     sal_Unicode     GetMultiSelectionSeparator() const { return mcMultiSep; }
 
@@ -174,8 +174,8 @@ public:
     Size            CalcSize( sal_uInt16 nColumns, sal_uInt16 nLines ) const;
     void            GetMaxVisColumnsAndLines( sal_uInt16& rnCols, sal_uInt16& rnLines ) const;
 
-    void            SetMRUEntries( const XubString& rEntries, sal_Unicode cSep = ';' );
-    XubString       GetMRUEntries( sal_Unicode cSep = ';' ) const;
+    void            SetMRUEntries( const OUString& rEntries, sal_Unicode cSep = ';' );
+    OUString        GetMRUEntries( sal_Unicode cSep = ';' ) const;
     void            SetMaxMRUCount( sal_uInt16 n );
     sal_uInt16          GetMaxMRUCount() const;
 
diff --git a/vcl/source/control/combobox.cxx b/vcl/source/control/combobox.cxx
index 13e3f2e..867e649 100644
--- a/vcl/source/control/combobox.cxx
+++ b/vcl/source/control/combobox.cxx
@@ -34,11 +34,11 @@
 
 // =======================================================================
 
-static void lcl_GetSelectedEntries( ::std::set< sal_uInt16 >& rSelectedPos, const XubString& rText, sal_Unicode cTokenSep, const ImplEntryList* pEntryList )
+static void lcl_GetSelectedEntries( ::std::set< sal_uInt16 >& rSelectedPos, const OUString& rText, sal_Unicode cTokenSep, const ImplEntryList* pEntryList )
 {
-    for (xub_StrLen n = comphelper::string::getTokenCount(rText, cTokenSep); n;)
+    for (sal_Int32 n = comphelper::string::getTokenCount(rText, cTokenSep); n;)
     {
-        XubString aToken = rText.GetToken( --n, cTokenSep );
+        OUString aToken = rText.getToken( --n, cTokenSep );
         aToken = comphelper::string::strip(aToken, ' ');
         sal_uInt16 nPos = pEntryList->FindEntry( aToken );
         if ( nPos != LISTBOX_ENTRY_NOTFOUND )
@@ -324,8 +324,8 @@ IMPL_LINK( ComboBox, ImplAutocompleteHdl, Edit*, pEdit )
     if ( aSel.Len() ||
          ((eAction != AUTOCOMPLETE_TABFORWARD) && (eAction != AUTOCOMPLETE_TABBACKWARD)) )
     {
-        XubString   aFullText = pEdit->GetText();
-        XubString   aStartText = aFullText.Copy( 0, (xub_StrLen)aSel.Max() );
+        OUString    aFullText = pEdit->GetText();
+        OUString    aStartText = aFullText.copy( 0, (sal_Int32)aSel.Max() );
         sal_uInt16      nStart = mpImplLB->GetCurrentPos();
 
         if ( nStart == LISTBOX_ENTRY_NOTFOUND )
@@ -359,8 +359,8 @@ IMPL_LINK( ComboBox, ImplAutocompleteHdl, Edit*, pEdit )
 
         if ( nPos != LISTBOX_ENTRY_NOTFOUND )
         {
-            XubString aText = mpImplLB->GetEntryList()->GetEntryText( nPos );
-            Selection aSelection( aText.Len(), aStartText.Len() );
+            OUString aText = mpImplLB->GetEntryList()->GetEntryText( nPos );
+            Selection aSelection( aText.getLength(), aStartText.getLength() );
             pEdit->SetText( aText, aSelection );
         }
     }
@@ -376,29 +376,31 @@ IMPL_LINK_NOARG(ComboBox, ImplSelectHdl)
     sal_Bool bCallSelect = sal_False;
     if ( mpImplLB->IsSelectionChanged() || bPopup )
     {
-        XubString aText;
+        OUString aText;
         if ( IsMultiSelectionEnabled() )
         {
             aText = mpSubEdit->GetText();
 
             // remove all entries to which there is an entry, but which is not selected
-            xub_StrLen nIndex = 0;
-            while ( nIndex != STRING_NOTFOUND )
+            sal_Int32 nIndex = 0;
+            while ( nIndex >= 0 )
             {
-                xub_StrLen  nPrevIndex = nIndex;
-                XubString   aToken = aText.GetToken( 0, mcMultiSep, nIndex );
-                xub_StrLen  nTokenLen = aToken.Len();
+                sal_Int32  nPrevIndex = nIndex;
+                OUString   aToken = aText.getToken( 0, mcMultiSep, nIndex );
+                sal_Int32  nTokenLen = aToken.getLength();
                 aToken = comphelper::string::strip(aToken, ' ');
                 sal_uInt16      nP = mpImplLB->GetEntryList()->FindEntry( aToken );
                 if ( (nP != LISTBOX_ENTRY_NOTFOUND) && (!mpImplLB->GetEntryList()->IsEntryPosSelected( nP )) )
                 {
-                    aText.Erase( nPrevIndex, nTokenLen );
+                    aText = aText.replaceAt( nPrevIndex, nTokenLen, "" );
                     nIndex = sal::static_int_cast<xub_StrLen>(nIndex - nTokenLen);
-                    if ( (nPrevIndex < aText.Len()) && (aText.GetChar( nPrevIndex ) == mcMultiSep) )
+                    sal_Int32 nSepCount=0;
+                    if ( (nPrevIndex+nSepCount < aText.getLength()) && (aText[nPrevIndex+nSepCount] == mcMultiSep) )
                     {
-                        aText.Erase( nPrevIndex, 1 );
                         nIndex--;
+                        ++nSepCount;
                     }
+                    aText.replaceAt( nPrevIndex, nSepCount, "" );
                 }
                 aText = comphelper::string::strip(aText, ' ');
             }
@@ -412,16 +414,15 @@ IMPL_LINK_NOARG(ComboBox, ImplSelectHdl)
                 sal_uInt16 nP = mpImplLB->GetEntryList()->GetSelectEntryPos( n );
                 if ( !aSelInText.count( nP ) )
                 {
-                    if ( aText.Len() && (aText.GetChar( aText.Len()-1 ) != mcMultiSep) )
-                        aText += mcMultiSep;
-                    if ( aText.Len() )
-                        aText += ' ';   // slightly loosen
+                    if ( !aText.isEmpty() && (aText[ aText.getLength()-1 ] != mcMultiSep) )
+                        aText += OUString(mcMultiSep);
+                    if ( !aText.isEmpty() )
+                        aText += " ";   // slightly loosen
                     aText += mpImplLB->GetEntryList()->GetEntryText( nP );
-                    aText += mcMultiSep;
+                    aText += OUString(mcMultiSep);
                 }
             }
-            if ( aText.Len() && (aText.GetChar( aText.Len()-1 ) == mcMultiSep) )
-                aText.Erase( aText.Len()-1, 1 );
+            aText = comphelper::string::stripEnd( aText, mcMultiSep );
         }
         else
         {
@@ -430,9 +431,9 @@ IMPL_LINK_NOARG(ComboBox, ImplSelectHdl)
 
         mpSubEdit->SetText( aText );
 
-        Selection aNewSelection( 0, aText.Len() );
+        Selection aNewSelection( 0, aText.getLength() );
         if ( IsMultiSelectionEnabled() )
-            aNewSelection.Min() = aText.Len();
+            aNewSelection.Min() = aText.getLength();
         mpSubEdit->SetSelection( aNewSelection );
 
         bCallSelect = sal_True;
@@ -907,7 +908,7 @@ void ComboBox::ImplUpdateFloatSelection()
 
 // -----------------------------------------------------------------------
 
-sal_uInt16 ComboBox::InsertEntry( const XubString& rStr, sal_uInt16 nPos )
+sal_uInt16 ComboBox::InsertEntry( const OUString& rStr, sal_uInt16 nPos )
 {
     sal_uInt16 nRealPos = mpImplLB->InsertEntry( nPos + mpImplLB->GetEntryList()->GetMRUCount(), rStr );
     nRealPos = sal::static_int_cast<sal_uInt16>(nRealPos - mpImplLB->GetEntryList()->GetMRUCount());
@@ -917,7 +918,7 @@ sal_uInt16 ComboBox::InsertEntry( const XubString& rStr, sal_uInt16 nPos )
 
 // -----------------------------------------------------------------------
 
-sal_uInt16 ComboBox::InsertEntry( const XubString& rStr, const Image& rImage, sal_uInt16 nPos )
+sal_uInt16 ComboBox::InsertEntry( const OUString& rStr, const Image& rImage, sal_uInt16 nPos )
 {
     sal_uInt16 nRealPos = mpImplLB->InsertEntry( nPos + mpImplLB->GetEntryList()->GetMRUCount(), rStr, rImage );
     nRealPos = sal::static_int_cast<sal_uInt16>(nRealPos - mpImplLB->GetEntryList()->GetMRUCount());
@@ -927,7 +928,7 @@ sal_uInt16 ComboBox::InsertEntry( const XubString& rStr, const Image& rImage, sa
 
 // -----------------------------------------------------------------------
 
-void ComboBox::RemoveEntry( const XubString& rStr )
+void ComboBox::RemoveEntry( const OUString& rStr )
 {
     RemoveEntry( GetEntryPos( rStr ) );
 }
@@ -958,7 +959,7 @@ Image ComboBox::GetEntryImage( sal_uInt16 nPos ) const
 
 // -----------------------------------------------------------------------
 
-sal_uInt16 ComboBox::GetEntryPos( const XubString& rStr ) const
+sal_uInt16 ComboBox::GetEntryPos( const OUString& rStr ) const
 {
     sal_uInt16 nPos = mpImplLB->GetEntryList()->FindEntry( rStr );
     if ( nPos != LISTBOX_ENTRY_NOTFOUND )
@@ -968,7 +969,7 @@ sal_uInt16 ComboBox::GetEntryPos( const XubString& rStr ) const
 
 // -----------------------------------------------------------------------
 
-XubString ComboBox::GetEntry( sal_uInt16 nPos ) const
+OUString ComboBox::GetEntry( sal_uInt16 nPos ) const
 {
     return mpImplLB->GetEntryList()->GetEntryText( nPos + mpImplLB->GetEntryList()->GetMRUCount() );
 }
@@ -1319,14 +1320,14 @@ void ComboBox::SetSeparatorPos( sal_uInt16 n )
 
 // -----------------------------------------------------------------------
 
-void ComboBox::SetMRUEntries( const XubString& rEntries, sal_Unicode cSep )
+void ComboBox::SetMRUEntries( const OUString& rEntries, sal_Unicode cSep )
 {
     mpImplLB->SetMRUEntries( rEntries, cSep );
 }
 
 // -----------------------------------------------------------------------
 
-XubString ComboBox::GetMRUEntries( sal_Unicode cSep ) const
+OUString ComboBox::GetMRUEntries( sal_Unicode cSep ) const
 {
     return mpImplLB->GetMRUEntries( cSep );
 }


More information about the Libreoffice-commits mailing list