replacing OUString::valueOf(static_cast<sal_Int32>) ??

Jan Holesovsky kendy at suse.cz
Fri Jan 11 04:02:17 PST 2013


Hi Noel,

Noel Grandin píše v Pá 11. 01. 2013 v 08:46 +0200:

> > - There's no need for valueOfChar(). There is already OUString ctor from
> > sal_Unicode, so the valueOf() overload for it is just making an obvious thing
> > complicated. Code using it can be converted to use the ctor instead.
> I've already dealt with why we can't use the constructor.
>     git grep "String::valueOf.*Unicode"
> says we do in fact appear to need such a method.

I've had a look at this git grep, and most of them could be written an
easier way thanks to the Lubos' OUString magic; like:

- aPropName += OUString::valueOf( (sal_Unicode) '/' );
+ aPropName += "/";

The only more tricky one is

- aRepresentation += OUString::valueOf( (sal_Unicode)(char)( ( nPageNumber - 1 ) % 26 + 'A' ) );
+ aRepresentation += OUString( (sal_Unicode)(char)( ( nPageNumber - 1 ) % 26 + 'A' ) );

Or did you mean something different?

> > - It's a question if we really need 'OUString::valueOfBool( foo )' instead of
> > simply 'foo ? OUString( "true" ) : OUString( "false" )' (such a pity the
> > string literals handling doesn't allow "foo ? "true" : "false"' ). I wonder
> > how many places in the code really need to convert a boolean to the hardcoded
> > english string representation.
> I have no idea how to count call sites automatically.
> But at least 10 places need to use a cast to access the method, so there 
> is definitely code using it.

I've counted exactly 5 - seeing the trouble we have un-publishing
something that we have published, I'd really prefer not to introduce a
method in our core API that would satisfy only 5 callers ;-)

Either way, thanks for looking into this!

All the best,
Kendy



More information about the LibreOffice mailing list