Kaydet (Commit) 311be7d7 authored tarafından Eike Rathke's avatar Eike Rathke

Related: tdf#108795 never use an unresolved LANGUAGE_SYSTEM in SvxAutoCorrect

Substitute with the current work locale, using MsLangId::getSystemLanguage()
instead was also wrong.

Change-Id: I55db3bc1f76329320afc1f366d7426a8c2f66fb2
Reviewed-on: https://gerrit.libreoffice.org/41476Reviewed-by: 's avatarEike Rathke <erack@redhat.com>
Tested-by: 's avatarJenkins <ci@libreoffice.org>
üst 06d14411
......@@ -203,6 +203,16 @@ static const LanguageTag& GetAppLang()
{
return Application::GetSettings().GetLanguageTag();
}
/// Never use an unresolved LANGUAGE_SYSTEM.
static LanguageType GetDocLanguage( const SvxAutoCorrDoc& rDoc, sal_Int32 nPos )
{
LanguageType eLang = rDoc.GetLanguage( nPos );
if (eLang == LANGUAGE_SYSTEM)
eLang = GetAppLang().getLanguageType(); // the current work locale
return eLang;
}
static LocaleDataWrapper& GetLocaleDataWrapper( LanguageType nLang )
{
static LocaleDataWrapper aLclDtWrp( GetAppLang() );
......@@ -1165,7 +1175,7 @@ void SvxAutoCorrect::InsertQuote( SvxAutoCorrDoc& rDoc, sal_Int32 nInsPos,
sal_Unicode cInsChar, bool bSttQuote,
bool bIns )
{
LanguageType eLang = rDoc.GetLanguage( nInsPos );
const LanguageType eLang = GetDocLanguage( rDoc, nInsPos );
sal_Unicode cRet = GetQuote( cInsChar, bSttQuote, eLang );
OUString sChg( cInsChar );
......@@ -1178,8 +1188,6 @@ void SvxAutoCorrect::InsertQuote( SvxAutoCorrDoc& rDoc, sal_Int32 nInsPos,
if( '\"' == cInsChar )
{
if( LANGUAGE_SYSTEM == eLang )
eLang = GetAppLang().getLanguageType();
if( eLang.anyOf(
LANGUAGE_FRENCH,
LANGUAGE_FRENCH_BELGIAN,
......@@ -1205,15 +1213,13 @@ void SvxAutoCorrect::InsertQuote( SvxAutoCorrDoc& rDoc, sal_Int32 nInsPos,
OUString SvxAutoCorrect::GetQuote( SvxAutoCorrDoc const & rDoc, sal_Int32 nInsPos,
sal_Unicode cInsChar, bool bSttQuote )
{
LanguageType eLang = rDoc.GetLanguage( nInsPos );
const LanguageType eLang = GetDocLanguage( rDoc, nInsPos );
sal_Unicode cRet = GetQuote( cInsChar, bSttQuote, eLang );
OUString sRet = OUString(cRet);
if( '\"' == cInsChar )
{
if( LANGUAGE_SYSTEM == eLang )
eLang = GetAppLang().getLanguageType();
if( eLang.anyOf(
LANGUAGE_FRENCH,
LANGUAGE_FRENCH_BELGIAN,
......@@ -1274,7 +1280,7 @@ void SvxAutoCorrect::DoAutoCorrect( SvxAutoCorrDoc& rDoc, const OUString& rTxt,
if ( IsAutoCorrFlag( AddNonBrkSpace ) )
{
if ( NeedsHardspaceAutocorr( cChar ) &&
FnAddNonBrkSpace( rDoc, rTxt, nInsPos, rDoc.GetLanguage( nInsPos ), io_bNbspRunNext ) )
FnAddNonBrkSpace( rDoc, rTxt, nInsPos, GetDocLanguage( rDoc, nInsPos ), io_bNbspRunNext ) )
{
;
}
......@@ -1331,9 +1337,7 @@ void SvxAutoCorrect::DoAutoCorrect( SvxAutoCorrDoc& rDoc, const OUString& rTxt,
if( !nPos && !IsWordDelim( rTxt[ 0 ]))
--nCapLttrPos; // begin of paragraph and no blank
LanguageType eLang = rDoc.GetLanguage( nCapLttrPos );
if( LANGUAGE_SYSTEM == eLang )
eLang = MsLangId::getSystemLanguage();
const LanguageType eLang = GetDocLanguage( rDoc, nCapLttrPos );
CharClass& rCC = GetCharClass( eLang );
// no symbol characters
......@@ -1544,9 +1548,7 @@ bool SvxAutoCorrect::GetPrevAutoCorrWord( SvxAutoCorrDoc const & rDoc,
if( 3 > nEnde - nCapLttrPos )
return false;
LanguageType eLang = rDoc.GetLanguage( nCapLttrPos );
if( LANGUAGE_SYSTEM == eLang )
eLang = MsLangId::getSystemLanguage();
const LanguageType eLang = GetDocLanguage( rDoc, nCapLttrPos );
SvxAutoCorrect* pThis = const_cast<SvxAutoCorrect*>(this);
CharClass& rCC = pThis->GetCharClass( eLang );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment