Hi Prashant, 2013/2/17 Prashant Pandey <prashant3.yi...@gmail.com>
> Hi, > >> >> I need some guidance as am stuck at a place. >> How should I replace 'erase' using guidelines given under >> https://wiki.documentfoundation.org/Development/String_Classes. >> If I try to fit 'replaceAt' in place of 'erase' in the line bolded below: >> >> * aRealStyle.Erase(aRealStyle.Search(aSep) + aSep.Len());* >> >> it will give me error (if I do : >> *aRealStyle.replaceAt(aRealStyle.indexOf(aSep) >> + aSep.getLength());*) >> >> Reason: >> >> replaceAt defined as: rtl::OUString rtl::OUString::replaceAt(sal_Int32, >> sal_Int32, const rtl::OUString&) const >> (candidate expects 3 arguments, 1 provided) >> error: no matching function for call to >> ‘rtl::OUString::replaceAt(sal_Int32) >> >> My question is, what should I pass inside the replaceAt() >> parameters/arguments? >> > I would suggest you write this: * sal_int32 idx = **aRealStyle.indexOf(aSep) + aSep.getLength();* * **aRealStyle = aRealStyle.replaceAt(idx, **aRealStyle.getLength() - **aRealStyle, "");* Because: - If nIndex is set then can use replaceAt with an arg of an empty string (from the wiki page) - The second argument is the count, and here we replace until the end of the string - Since OUString is immutable, you must assign back the resulting OUString if you do not want to lose it Cheers, Jean-Noël
_______________________________________________ LibreOffice mailing list LibreOffice@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice