From 3885b5d4b00ebb31adabc36c507abd642c03d0d4 Mon Sep 17 00:00:00 2001 From: Eike Rathke Date: Sat, 17 May 2014 04:05:20 +0200 Subject: resolved fdo#41166 match month and day name word instead of substring Follow-up, check for ASCII first to avoid calls to i18n, and check the type flags instead of calls to CharClass methods that give unexpected results with their masks. Change-Id: I10e685998299dceb2dbcf1d87ae1de09680b8a99 --- svl/source/numbers/zforfind.cxx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'svl/source') diff --git a/svl/source/numbers/zforfind.cxx b/svl/source/numbers/zforfind.cxx index 0cf62fd68dd7..0e10138661cb 100644 --- a/svl/source/numbers/zforfind.cxx +++ b/svl/source/numbers/zforfind.cxx @@ -458,18 +458,23 @@ bool ImpSvNumberInputScan::StringContainsWord( const OUString& rWhat, * how many languages do not separate the day and month names in some * form? */ + // Check simple ASCII first before invoking i18n or anything else. + if (rtl::isAsciiAlphanumeric( rString[nPos] )) + return false; // Alpha or numeric is not word gap. + sal_Int32 nIndex = nPos; - sal_uInt32 c = rString.iterateCodePoints( &nIndex); + const sal_uInt32 c = rString.iterateCodePoints( &nIndex); if (nPos+1 < nIndex) return true; // Surrogate, assume these to be new words. (void)c; const sal_Int32 nType = pFormatter->GetCharClass()->getCharacterType( rString, nPos); + using namespace ::com::sun::star::i18n; - if (CharClass::isAlphaNumericType( nType)) + if ((nType & (KCharacterType::UPPER | KCharacterType::LOWER | KCharacterType::DIGIT)) != 0) return false; // Alpha or numeric is not word gap. - if (CharClass::isLetterType( nType)) + if ((nType & (KCharacterType::LETTER)) != 0) return true; // Letter other than alpha is new word. (Is it?) return true; // Catch all remaining as gap until we know better. -- cgit