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
#0  com::sun::star::i18n::casefolding::getValue (str=0x7fffffffaa9c, pos=0, len=1, aLocale=...,
    nMappingType=16 '\020') at /home/brad/git/libo/i18nutil/source/utility/casefolding.cxx:94
#1  0x00007fffe5a02b03 in com::sun::star::i18n::Transliteration_body::transliterateChar2Char (
    this=<optimized out>, inChar=79)
    at /home/brad/git/libo/i18npool/source/transliteration/transliteration_body.cxx:215
#2  0x00007fffe59c3cf3 in com::sun::star::i18n::cclass_Unicode::toTitle (this=0x1d0d240,
    Text="ORAN", nPos=<optimized out>, nCount=<optimized out>, rLocale=...)
    at /home/brad/git/libo/i18npool/source/characterclassification/cclass_unicode.cxx:110
#3  0x00007fffe59c7b6f in com::sun::star::i18n::CharacterClassificationImpl::toTitle (
    this=<optimized out>, Text="ORAN", nPos=0, nCount=<optimized out>, rLocale=<optimized out>)
    at /home/brad/git/libo/i18npool/source/characterclassification/characterclassificationImpl.cxx:74
#4  0x00007ffff4d5ff4b in CharClass::titlecase (this=<optimized out>, rStr="ORAN", nPos=0,
    nCount=4) at /home/brad/git/libo/unotools/source/i18n/charclass.cxx:284
#5  0x00007fffe1dc5c31 in titlecase (_rStr="ORAN", this=0x1d0b2a0)
    at /home/brad/git/libo/solver/unxlngx6.pro/inc/unotools/charclass.hxx:187
#6  QuickHelpData::FillStrArr (this=0x160fce0, rSh=..., rWord="ORAN")
    at /home/brad/git/libo/sw/source/ui/docvw/edtwin.cxx:5589
#7  0x00007fffe1dc7040 in SwEditWin::ShowAutoTextCorrectQuickHelp (this=<optimized out>,
    rWord="ORAN", pACfg=0x7fffe0e7c320, pACorr=0x15feab0, bFromIME=0 '\000')
    at /home/brad/git/libo/sw/source/ui/docvw/edtwin.cxx:5701
_______________________________________________
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice

Reply via email to