diff options
author | Eike Rathke <erack@redhat.com> | 2017-08-23 17:52:02 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2017-08-24 00:30:55 +0200 |
commit | 311be7d70146e4963e4dfd1f39d6c71d45d241ca (patch) | |
tree | 32a25021c3b4647c2dfab2d382351116ee7dacb2 | |
parent | 06d14411a447cd798d1f0678a3c5e06f5278a1cb (diff) |
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/41476
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Jenkins <ci@libreoffice.org>
-rw-r--r-- | editeng/source/misc/svxacorr.cxx | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/editeng/source/misc/svxacorr.cxx b/editeng/source/misc/svxacorr.cxx index 51571e1af1ca..a430c4835446 100644 --- a/editeng/source/misc/svxacorr.cxx +++ b/editeng/source/misc/svxacorr.cxx @@ -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 ); |