Hi Prashant,<br><br><div class="gmail_quote">2013/2/17 Prashant Pandey <span dir="ltr"><<a href="mailto:prashant3.yishu@gmail.com" target="_blank">prashant3.yishu@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5">Hi,<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>I need some guidance as am stuck at a place. <br>
How should I replace 'erase' using guidelines given under <a href="https://wiki.documentfoundation.org/Development/String_Classes" target="_blank">https://wiki.documentfoundation.org/Development/String_Classes</a>.<br>
If I try to fit 'replaceAt' in place of 'erase' in the line bolded below:<br><br><b> aRealStyle.Erase(aRealStyle.Search(aSep) + aSep.Len());</b><br><br>it will give me error (if I do : <b>aRealStyle.replaceAt(aRealStyle.indexOf(aSep) + aSep.getLength());</b>)<br>
<br>Reason: <br><br>replaceAt defined as: rtl::OUString rtl::OUString::replaceAt(sal_Int32, sal_Int32, const rtl::OUString&) const<br>(candidate expects 3 arguments, 1 provided)<br>error: no matching function for call to ‘rtl::OUString::replaceAt(sal_Int32)<br>
<br>My question is, what should I pass inside the replaceAt() parameters/arguments?<br></blockquote></div></div></div></blockquote></div><br>I would suggest you write this:<br><b> sal_int32 idx = </b><b>aRealStyle.indexOf(aSep) + aSep.getLength();</b><br>
<b> </b><b><b>aRealStyle = </b>aRealStyle.replaceAt(idx, </b><b><b>aRealStyle</b>.getLength() - </b><b><b>aRealStyle, ""</b>);</b><br>
<br>Because:<br><ul><li>If nIndex is set then can use replaceAt with an arg of an empty string (from the wiki page)<br></li><li>The second argument is the count, and here we replace until the end of the string</li><li>Since OUString is immutable, you must assign back the resulting OUString if you do not want to lose it</li>
</ul><p>Cheers,<br></p><p>Jean-Noël<br></p>