tdf#150582 linguistic: fix always rejected words with U+2019 apostrophe
During spell checking, words added to the user dictionaries still weren't recognized by Calc, Impress and Draw because of the unnecessary conversion their typographic apostrophes to ASCII apostrophes. Note: Writer has no such problem because of its (obsolete) apostrophe conversion for the user dictionary. First skip the obsolete apostrophe conversion in isValid(), but keep it as a fallback for Writer users. Change-Id: I09870a35d7a91017281ba4b228d338336e7bd9c1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168858 Tested-by: Jenkins Reviewed-by: László Németh <nemeth@numbertext.org>
This commit is contained in:
parent
e78bb77c3c
commit
8de1941fe6
2 changed files with 27 additions and 7 deletions
|
@ -199,10 +199,19 @@ sal_Bool SAL_CALL
|
|||
const css::uno::Sequence< ::css::beans::PropertyValue >& rProperties )
|
||||
{
|
||||
MutexGuard aGuard( GetLinguMutex() );
|
||||
return isValid_Impl( rWord, LinguLocaleToLanguage( rLocale ), rProperties );
|
||||
// for historical reasons, the word can be only with ASCII apostrophe in the dictionaries,
|
||||
// so as a fallback, convert typographical apostrophes to avoid annoying users, if they
|
||||
// have old (user) dictionaries only with the obsolete ASCII apostrophe.
|
||||
bool bConvert = false;
|
||||
bool bRet = isValid_Impl( rWord, LinguLocaleToLanguage( rLocale ), rProperties, bConvert );
|
||||
if (!bRet && bConvert)
|
||||
{
|
||||
// fallback: convert the apostrophes
|
||||
bRet = isValid_Impl( rWord, LinguLocaleToLanguage( rLocale ), rProperties, bConvert );
|
||||
}
|
||||
return bRet;
|
||||
}
|
||||
|
||||
|
||||
Reference< XSpellAlternatives > SAL_CALL
|
||||
SpellCheckerDispatcher::spell( const OUString& rWord, const Locale& rLocale,
|
||||
const css::uno::Sequence< ::css::beans::PropertyValue >& rProperties )
|
||||
|
@ -249,7 +258,8 @@ static Reference< XDictionaryEntry > lcl_GetRulingDictionaryEntry(
|
|||
bool SpellCheckerDispatcher::isValid_Impl(
|
||||
const OUString& rWord,
|
||||
LanguageType nLanguage,
|
||||
const PropertyValues& rProperties)
|
||||
const PropertyValues& rProperties,
|
||||
bool& rConvertApostrophe)
|
||||
{
|
||||
MutexGuard aGuard( GetLinguMutex() );
|
||||
|
||||
|
@ -267,11 +277,21 @@ bool SpellCheckerDispatcher::isValid_Impl(
|
|||
OUString aChkWord( rWord );
|
||||
Locale aLocale( LanguageTag::convertToLocale( nLanguage ) );
|
||||
|
||||
// replace typographical apostroph by ascii apostroph
|
||||
// replace typographical apostrophe by ASCII apostrophe only as a fallback
|
||||
// for old user dictionaries before the time of the default typographical apostrophe
|
||||
// (Note: otherwise also no problem with non-Unicode Hunspell dictionaries, because
|
||||
// the character conversion converts also the typographical apostrophe to the ASCII one)
|
||||
OUString aSingleQuote( GetLocaleDataWrapper( nLanguage ).getQuotationMarkEnd() );
|
||||
DBG_ASSERT( 1 == aSingleQuote.getLength(), "unexpected length of quotation mark" );
|
||||
if (!aSingleQuote.isEmpty())
|
||||
aChkWord = aChkWord.replace( aSingleQuote[0], '\'' );
|
||||
if (!aSingleQuote.isEmpty() && aChkWord.indexOf(aSingleQuote[0]) > -1)
|
||||
{
|
||||
// tdf#150582 first check with the original typographical apostrophe,
|
||||
// and convert it only on the second try
|
||||
if (rConvertApostrophe)
|
||||
aChkWord = aChkWord.replace( aSingleQuote[0], '\'' );
|
||||
else
|
||||
rConvertApostrophe = true;
|
||||
}
|
||||
|
||||
RemoveHyphens( aChkWord );
|
||||
if (IsIgnoreControlChars( rProperties, GetPropSet() ))
|
||||
|
|
|
@ -69,7 +69,7 @@ class SpellCheckerDispatcher :
|
|||
/// @throws css::uno::RuntimeException
|
||||
/// @throws css::lang::IllegalArgumentException
|
||||
bool isValid_Impl(const OUString& aWord, LanguageType nLanguage,
|
||||
const css::beans::PropertyValues& aProperties);
|
||||
const css::beans::PropertyValues& aProperties, bool& rConvertApostrophe);
|
||||
|
||||
/// @throws css::uno::RuntimeException
|
||||
/// @throws css::lang::IllegalArgumentException
|
||||
|
|
Loading…
Reference in a new issue