Date: prev next · Thread: first prev next last
2013 Archives by date, by thread · List index


Hello,

I have been looking at the following code, but struggle a bit to understand
how this loop is working in IMPL_LINK_NOARG(ComboBox, ImplSelectHdl) :
            xub_StrLen nIndex = 0;
            while ( nIndex != STRING_NOTFOUND )
            {
                xub_StrLen  nPrevIndex = nIndex;
                XubString   aToken = aText.GetToken( 0, mcMultiSep, nIndex
);
                xub_StrLen  nTokenLen = aToken.Len();
                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 );
                    nIndex = sal::static_int_cast<xub_StrLen>(nIndex -
nTokenLen);
                    if ( (nPrevIndex < aText.Len()) && (aText.GetChar(
nPrevIndex ) == mcMultiSep) )
                    {
                        aText.Erase( nPrevIndex, 1 );
                        nIndex--;
                    }
                }
                aText = comphelper::string::strip(aText, ' ');
            }

My problem lies with how the nIndex variable gets updated, I don't see how
it can reach STRING_NOTFOUND any other way than by luck. I must be missing
something.
Does anybody have a better read than me here?

BTW I am trying to convert this code to use OUString, so any suggestion in
this direction is more than welcome :)

Cheers,
Jean--Noël

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.