[Libreoffice] [PATCH] nuke obsolete use of String

Caolán McNamara caolanm at redhat.com
Sun Dec 12 13:05:38 PST 2010


On Sun, 2010-12-12 at 20:59 +0900, Takeshi Abe wrote:
> Hi,
> 
> While trying Easy Hack 3.8 [1], I found obsolete use of String in
> desktop/source/app/cmdlineargs.cxx .

This is good stuff, I didn't push this yet though. There's one little
easily-fixed snag I think, e.g.

- else if ( aArgStr.CompareToAscii( "-psn", 4 ) == COMPARE_EQUAL )
+ else if
( aArg.equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("-psn")))

CompareToAscii is case sensitive, while equalsIgnoreAsciiCaseAsciiL is
case insensitive, so that would change the logic slightly. On the other
hand we don't seem to care about the case for the other command line
options so maybe that's a good thing.

However there's another catch. 

OUString::equalsIgnoreAsciiCaseAsciiL takes the length as an
optimization, both entire strings have to match, so it's like strcmp.
While the old-school String::CompareToAscii only compare the String
against the argument up to the passed-in-length, like strncmp

So, that one should be (I think, I get a little confused when I mix my
strings, double check me) matchAsciiL to be exactly the same as before.

C.

p.s. I think we should have a wiki page to list the old String methods
and the new OUString equivalents side-by-side with snags listed. (Some
of the String methods are sort of OUStringBuffer equivalents, and some
are hard to do with OUStrings, and might have workarounds in
comphelper). Maybe you, or someone else, could start a page in the wiki
and just start with the methods used in this example



More information about the LibreOffice mailing list