Kaydet (Commit) cd2c3e72 authored tarafından Chr. Rossmanith's avatar Chr. Rossmanith Kaydeden (comit) Fridrich Strba

Replaced XubString with OUString in vcl(combobox)

Change-Id: Ibe80e9837f1c8275d625e942eb75ecc8de897bf5
Reviewed-on: https://gerrit.libreoffice.org/2574Reviewed-by: 's avatarFridrich Strba <fridrich@documentfoundation.org>
Tested-by: 's avatarFridrich Strba <fridrich@documentfoundation.org>
üst 0ed4da1a
...@@ -120,28 +120,28 @@ public: ...@@ -120,28 +120,28 @@ public:
sal_uInt16 GetDropDownLineCount() const; sal_uInt16 GetDropDownLineCount() const;
void EnableAutoSize( sal_Bool bAuto ); void EnableAutoSize( sal_Bool bAuto );
sal_Bool IsAutoSizeEnabled() const { return mbDDAutoSize; } sal_Bool IsAutoSizeEnabled() const { return mbDDAutoSize; }
void EnableDDAutoWidth( sal_Bool b ); void EnableDDAutoWidth( sal_Bool b );
virtual void SetText( const OUString& rStr ); virtual void SetText( const OUString& rStr );
virtual void SetText( const OUString& rStr, const Selection& rNewSelection ); virtual void SetText( const OUString& rStr, const Selection& rNewSelection );
sal_uInt16 InsertEntry( const XubString& rStr, sal_uInt16 nPos = COMBOBOX_APPEND ); sal_uInt16 InsertEntry( const OUString& 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, const Image& rImage, sal_uInt16 nPos = COMBOBOX_APPEND );
void RemoveEntry( const XubString& rStr ); void RemoveEntry( const OUString& rStr );
void RemoveEntry( sal_uInt16 nPos ); void RemoveEntry( sal_uInt16 nPos );
void Clear(); void Clear();
sal_uInt16 GetEntryPos( const XubString& rStr ) const; sal_uInt16 GetEntryPos( const OUString& rStr ) const;
Image GetEntryImage( sal_uInt16 nPos ) const; Image GetEntryImage( sal_uInt16 nPos ) const;
XubString GetEntry( sal_uInt16 nPos ) const; OUString GetEntry( sal_uInt16 nPos ) const;
sal_uInt16 GetEntryCount() const; sal_uInt16 GetEntryCount() const;
sal_Bool IsTravelSelect() const; sal_Bool IsTravelSelect() const;
sal_Bool IsInDropDown() const; sal_Bool IsInDropDown() const;
void ToggleDropDown(); void ToggleDropDown();
long CalcWindowSizePixel( sal_uInt16 nLines ) const; long CalcWindowSizePixel( sal_uInt16 nLines ) const;
...@@ -155,10 +155,10 @@ public: ...@@ -155,10 +155,10 @@ public:
void SetSeparatorPos( sal_uInt16 n = LISTBOX_ENTRY_NOTFOUND ); void SetSeparatorPos( sal_uInt16 n = LISTBOX_ENTRY_NOTFOUND );
void EnableAutocomplete( sal_Bool bEnable, sal_Bool bMatchCase = sal_False ); void EnableAutocomplete( sal_Bool bEnable, sal_Bool bMatchCase = sal_False );
sal_Bool IsAutocompleteEnabled() const; sal_Bool IsAutocompleteEnabled() const;
void EnableMultiSelection( sal_Bool bMulti ); void EnableMultiSelection( sal_Bool bMulti );
sal_Bool IsMultiSelectionEnabled() const; sal_Bool IsMultiSelectionEnabled() const;
void SetMultiSelectionSeparator( sal_Unicode cSep ) { mcMultiSep = cSep; } void SetMultiSelectionSeparator( sal_Unicode cSep ) { mcMultiSep = cSep; }
sal_Unicode GetMultiSelectionSeparator() const { return mcMultiSep; } sal_Unicode GetMultiSelectionSeparator() const { return mcMultiSep; }
...@@ -174,8 +174,8 @@ public: ...@@ -174,8 +174,8 @@ public:
Size CalcSize( sal_uInt16 nColumns, sal_uInt16 nLines ) const; Size CalcSize( sal_uInt16 nColumns, sal_uInt16 nLines ) const;
void GetMaxVisColumnsAndLines( sal_uInt16& rnCols, sal_uInt16& rnLines ) const; void GetMaxVisColumnsAndLines( sal_uInt16& rnCols, sal_uInt16& rnLines ) const;
void SetMRUEntries( const XubString& rEntries, sal_Unicode cSep = ';' ); void SetMRUEntries( const OUString& rEntries, sal_Unicode cSep = ';' );
XubString GetMRUEntries( sal_Unicode cSep = ';' ) const; OUString GetMRUEntries( sal_Unicode cSep = ';' ) const;
void SetMaxMRUCount( sal_uInt16 n ); void SetMaxMRUCount( sal_uInt16 n );
sal_uInt16 GetMaxMRUCount() const; sal_uInt16 GetMaxMRUCount() const;
......
...@@ -34,11 +34,11 @@ ...@@ -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, ' '); aToken = comphelper::string::strip(aToken, ' ');
sal_uInt16 nPos = pEntryList->FindEntry( aToken ); sal_uInt16 nPos = pEntryList->FindEntry( aToken );
if ( nPos != LISTBOX_ENTRY_NOTFOUND ) if ( nPos != LISTBOX_ENTRY_NOTFOUND )
...@@ -324,8 +324,8 @@ IMPL_LINK( ComboBox, ImplAutocompleteHdl, Edit*, pEdit ) ...@@ -324,8 +324,8 @@ IMPL_LINK( ComboBox, ImplAutocompleteHdl, Edit*, pEdit )
if ( aSel.Len() || if ( aSel.Len() ||
((eAction != AUTOCOMPLETE_TABFORWARD) && (eAction != AUTOCOMPLETE_TABBACKWARD)) ) ((eAction != AUTOCOMPLETE_TABFORWARD) && (eAction != AUTOCOMPLETE_TABBACKWARD)) )
{ {
XubString aFullText = pEdit->GetText(); OUString aFullText = pEdit->GetText();
XubString aStartText = aFullText.Copy( 0, (xub_StrLen)aSel.Max() ); OUString aStartText = aFullText.copy( 0, (sal_Int32)aSel.Max() );
sal_uInt16 nStart = mpImplLB->GetCurrentPos(); sal_uInt16 nStart = mpImplLB->GetCurrentPos();
if ( nStart == LISTBOX_ENTRY_NOTFOUND ) if ( nStart == LISTBOX_ENTRY_NOTFOUND )
...@@ -359,8 +359,8 @@ IMPL_LINK( ComboBox, ImplAutocompleteHdl, Edit*, pEdit ) ...@@ -359,8 +359,8 @@ IMPL_LINK( ComboBox, ImplAutocompleteHdl, Edit*, pEdit )
if ( nPos != LISTBOX_ENTRY_NOTFOUND ) if ( nPos != LISTBOX_ENTRY_NOTFOUND )
{ {
XubString aText = mpImplLB->GetEntryList()->GetEntryText( nPos ); OUString aText = mpImplLB->GetEntryList()->GetEntryText( nPos );
Selection aSelection( aText.Len(), aStartText.Len() ); Selection aSelection( aText.getLength(), aStartText.getLength() );
pEdit->SetText( aText, aSelection ); pEdit->SetText( aText, aSelection );
} }
} }
...@@ -376,29 +376,31 @@ IMPL_LINK_NOARG(ComboBox, ImplSelectHdl) ...@@ -376,29 +376,31 @@ IMPL_LINK_NOARG(ComboBox, ImplSelectHdl)
sal_Bool bCallSelect = sal_False; sal_Bool bCallSelect = sal_False;
if ( mpImplLB->IsSelectionChanged() || bPopup ) if ( mpImplLB->IsSelectionChanged() || bPopup )
{ {
XubString aText; OUString aText;
if ( IsMultiSelectionEnabled() ) if ( IsMultiSelectionEnabled() )
{ {
aText = mpSubEdit->GetText(); aText = mpSubEdit->GetText();
// remove all entries to which there is an entry, but which is not selected // remove all entries to which there is an entry, but which is not selected
xub_StrLen nIndex = 0; sal_Int32 nIndex = 0;
while ( nIndex != STRING_NOTFOUND ) while ( nIndex >= 0 )
{ {
xub_StrLen nPrevIndex = nIndex; sal_Int32 nPrevIndex = nIndex;
XubString aToken = aText.GetToken( 0, mcMultiSep, nIndex ); OUString aToken = aText.getToken( 0, mcMultiSep, nIndex );
xub_StrLen nTokenLen = aToken.Len(); sal_Int32 nTokenLen = aToken.getLength();
aToken = comphelper::string::strip(aToken, ' '); aToken = comphelper::string::strip(aToken, ' ');
sal_uInt16 nP = mpImplLB->GetEntryList()->FindEntry( aToken ); sal_uInt16 nP = mpImplLB->GetEntryList()->FindEntry( aToken );
if ( (nP != LISTBOX_ENTRY_NOTFOUND) && (!mpImplLB->GetEntryList()->IsEntryPosSelected( nP )) ) 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); 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--; nIndex--;
++nSepCount;
} }
aText.replaceAt( nPrevIndex, nSepCount, "" );
} }
aText = comphelper::string::strip(aText, ' '); aText = comphelper::string::strip(aText, ' ');
} }
...@@ -412,16 +414,15 @@ IMPL_LINK_NOARG(ComboBox, ImplSelectHdl) ...@@ -412,16 +414,15 @@ IMPL_LINK_NOARG(ComboBox, ImplSelectHdl)
sal_uInt16 nP = mpImplLB->GetEntryList()->GetSelectEntryPos( n ); sal_uInt16 nP = mpImplLB->GetEntryList()->GetSelectEntryPos( n );
if ( !aSelInText.count( nP ) ) if ( !aSelInText.count( nP ) )
{ {
if ( aText.Len() && (aText.GetChar( aText.Len()-1 ) != mcMultiSep) ) if ( !aText.isEmpty() && (aText[ aText.getLength()-1 ] != mcMultiSep) )
aText += mcMultiSep; aText += OUString(mcMultiSep);
if ( aText.Len() ) if ( !aText.isEmpty() )
aText += ' '; // slightly loosen aText += " "; // slightly loosen
aText += mpImplLB->GetEntryList()->GetEntryText( nP ); aText += mpImplLB->GetEntryList()->GetEntryText( nP );
aText += mcMultiSep; aText += OUString(mcMultiSep);
} }
} }
if ( aText.Len() && (aText.GetChar( aText.Len()-1 ) == mcMultiSep) ) aText = comphelper::string::stripEnd( aText, mcMultiSep );
aText.Erase( aText.Len()-1, 1 );
} }
else else
{ {
...@@ -430,9 +431,9 @@ IMPL_LINK_NOARG(ComboBox, ImplSelectHdl) ...@@ -430,9 +431,9 @@ IMPL_LINK_NOARG(ComboBox, ImplSelectHdl)
mpSubEdit->SetText( aText ); mpSubEdit->SetText( aText );
Selection aNewSelection( 0, aText.Len() ); Selection aNewSelection( 0, aText.getLength() );
if ( IsMultiSelectionEnabled() ) if ( IsMultiSelectionEnabled() )
aNewSelection.Min() = aText.Len(); aNewSelection.Min() = aText.getLength();
mpSubEdit->SetSelection( aNewSelection ); mpSubEdit->SetSelection( aNewSelection );
bCallSelect = sal_True; bCallSelect = sal_True;
...@@ -907,7 +908,7 @@ void ComboBox::ImplUpdateFloatSelection() ...@@ -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 ); sal_uInt16 nRealPos = mpImplLB->InsertEntry( nPos + mpImplLB->GetEntryList()->GetMRUCount(), rStr );
nRealPos = sal::static_int_cast<sal_uInt16>(nRealPos - mpImplLB->GetEntryList()->GetMRUCount()); 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 ) ...@@ -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 ); sal_uInt16 nRealPos = mpImplLB->InsertEntry( nPos + mpImplLB->GetEntryList()->GetMRUCount(), rStr, rImage );
nRealPos = sal::static_int_cast<sal_uInt16>(nRealPos - mpImplLB->GetEntryList()->GetMRUCount()); 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 ...@@ -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 ) ); RemoveEntry( GetEntryPos( rStr ) );
} }
...@@ -958,7 +959,7 @@ Image ComboBox::GetEntryImage( sal_uInt16 nPos ) const ...@@ -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 ); sal_uInt16 nPos = mpImplLB->GetEntryList()->FindEntry( rStr );
if ( nPos != LISTBOX_ENTRY_NOTFOUND ) if ( nPos != LISTBOX_ENTRY_NOTFOUND )
...@@ -968,7 +969,7 @@ sal_uInt16 ComboBox::GetEntryPos( const XubString& rStr ) const ...@@ -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() ); return mpImplLB->GetEntryList()->GetEntryText( nPos + mpImplLB->GetEntryList()->GetMRUCount() );
} }
...@@ -1319,14 +1320,14 @@ void ComboBox::SetSeparatorPos( sal_uInt16 n ) ...@@ -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 ); mpImplLB->SetMRUEntries( rEntries, cSep );
} }
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
XubString ComboBox::GetMRUEntries( sal_Unicode cSep ) const OUString ComboBox::GetMRUEntries( sal_Unicode cSep ) const
{ {
return mpImplLB->GetMRUEntries( cSep ); return mpImplLB->GetMRUEntries( cSep );
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment