[PUSHED] Re: [PATCH 2/2] Smarter auto-complete capitalization (#i22961#) and i18n handling

Brad Sowden code at sowden.org
Wed Jun 6 02:53:55 PDT 2012


Hi Caolán,

>>> * Sidenote - Initially I tried using CharClass::titlecase() but
>>> discovered this doesn't actually work.
>
> What did you try and what went wrong ?
>
>>> There appears to be an issue with
>>> class cclass_Unicode where "trans" is only ever set to
>>> "Transliteration_casemapping" and there is no mechanism to set it to
>>> "Transliteration_titlecase".
>
> I believe that the casemapping thing there knows about upper, lower and
> title case and uses setMappingType to MappingTypeToTitle to toggle which
> one to return
>
> e.g. I added this test
> http://cgit.freedesktop.org/libreoffice/core/commit/?id=eb9b8ebca49291797e655b50f64af2c2fa03434c
> to confirm to myself that its working like I think its supposed to.

When I called CharClass::titlecase() I expected "ORAN" to be changed to 
"Oran" but from memory the returned string was still "ORAN". Attached is 
the back trace I took at the time.

Looking again in cclass_Unicode::toTitle()

http://opengrok.libreoffice.org/xref/core/i18npool/source/characterclassification/cclass_unicode.cxx#92

I see only the first character in each word is Title cased and the rest 
are left untouched. Oh!

105     for (sal_Int32 i = nPos; i < nCount + nPos; i++, out++) {
106         if (i >= bdy.endPos)
107             bdy = brk.nextWord(Text, bdy.endPos, rLocale,
108                         WordType::ANYWORD_IGNOREWHITESPACES);
109         *out = (i == bdy.startPos) ?
110             trans->transliterateChar2Char(Text[i]) : Text[i];
111     }

I just checked and your test case passes when sTest = "Some text" but if 
I change it to sTest = "Some tExt" it fails (assuming "Some Text" is the 
right result).

The following function appears to do what I originally wanted (i.e. 
Title case the first character and Lower case subsequent characters) but 
using opengrok I can't find anywhere that actually instantiates this class.

rtl::OUString SAL_CALL Transliteration_titlecase::transliterate()

http://opengrok.libreoffice.org/xref/core/i18npool/source/transliteration/transliteration_body.cxx#329

Anyway, I think the solution I used in my patch is better as I actually 
wanted Sentence case rather than Title case for the overall string.

Cheers,
Brad
-------------- next part --------------
A non-text attachment was scrubbed...
Name: backtrace.log
Type: text/x-log
Size: 1621 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/libreoffice/attachments/20120606/31fd64a7/attachment.bin>


More information about the LibreOffice mailing list