[PATCH] Replaced XubString with OUString in vcl(combobox)
Christina Roßmanith (via_Code_Review)
gerrit at gerrit.libreoffice.org
Wed Mar 6 13:05:35 PST 2013
Hi,
I have submitted a patch for review:
https://gerrit.libreoffice.org/2574
To pull it, you can do:
git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/74/2574/1
Replaced XubString with OUString in vcl(combobox)
Change-Id: Ibe80e9837f1c8275d625e942eb75ecc8de897bf5
---
M vcl/inc/vcl/combobox.hxx
M vcl/source/control/combobox.cxx
2 files changed, 47 insertions(+), 46 deletions(-)
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 @@
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 @@
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 @@
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 8356a52..d021af6 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 @@
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 @@
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,34 +376,36 @@
sal_Bool bCallSelect = sal_False;
if ( mpImplLB->IsSelectionChanged() || bPopup )
{
- XubString aText;
+ OUString aText;
if ( IsMultiSelectionEnabled() )
{
aText = mpSubEdit->GetText();
// Alle Eintraege entfernen, zu denen es einen Entry gibt, der aber nicht selektiert ist.
- 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, ' ');
}
- // Fehlende Eintraege anhaengen...
+ // append missing entries
::std::set< sal_uInt16 > aSelInText;
lcl_GetSelectedEntries( aSelInText, aText, mcMultiSep, mpImplLB->GetEntryList() );
sal_uInt16 nSelectedEntries = mpImplLB->GetEntryList()->GetSelectEntryCount();
@@ -412,16 +414,15 @@
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 += ' '; // etwas auflockern
+ if ( !aText.isEmpty() && (aText[ aText.getLength()-1 ] != mcMultiSep) )
+ aText += OUString(mcMultiSep);
+ if ( !aText.isEmpty() )
+ aText += " "; // etwas auflockern
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 @@
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;
@@ -906,7 +907,7 @@
// -----------------------------------------------------------------------
-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());
@@ -916,7 +917,7 @@
// -----------------------------------------------------------------------
-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());
@@ -926,7 +927,7 @@
// -----------------------------------------------------------------------
-void ComboBox::RemoveEntry( const XubString& rStr )
+void ComboBox::RemoveEntry( const OUString& rStr )
{
RemoveEntry( GetEntryPos( rStr ) );
}
@@ -957,7 +958,7 @@
// -----------------------------------------------------------------------
-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 )
@@ -967,7 +968,7 @@
// -----------------------------------------------------------------------
-XubString ComboBox::GetEntry( sal_uInt16 nPos ) const
+OUString ComboBox::GetEntry( sal_uInt16 nPos ) const
{
return mpImplLB->GetEntryList()->GetEntryText( nPos + mpImplLB->GetEntryList()->GetMRUCount() );
}
@@ -1318,14 +1319,14 @@
// -----------------------------------------------------------------------
-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 );
}
--
To view, visit https://gerrit.libreoffice.org/2574
To unsubscribe, visit https://gerrit.libreoffice.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibe80e9837f1c8275d625e942eb75ecc8de897bf5
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: master
Gerrit-Owner: Christina Roßmanith <ChrRossmanith at web.de>
More information about the LibreOffice
mailing list