diff options
author | Julien Nabet <serval2412@yahoo.fr> | 2014-06-18 21:08:03 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-07-05 13:46:14 +0000 |
commit | a5f36fd02ad88af4bab74a074e676cf239e15d14 (patch) | |
tree | 9863c4ba78b4d45b97c1919fffd58e00d8fb00a1 | |
parent | 1cacd685bf7c3230d3cdff964503adaedd025418 (diff) |
Resolves fdo#79276 Add fallback system for autocorrection of French variants
1) Replace the creation of acor_fr-FR.dat by acor_fr.dat since there's no specific for variants of fr
2) Add a fallback system to use it
Cherry-picked from 82f291d2f7630938ce6ca740f904cab07d1ff90d
Reviewed-on: https://gerrit.libreoffice.org/9825
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Change-Id: Ia3e11fff0f266839dc148077b50c1b2f798d1c50
Reviewed-on: https://gerrit.libreoffice.org/10063
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Miklos Vajna <vmiklos@collabora.co.uk>
-rw-r--r-- | editeng/source/misc/svxacorr.cxx | 24 | ||||
-rw-r--r-- | extras/CustomTarget_autocorr.mk | 2 | ||||
-rw-r--r-- | extras/Package_autocorr.mk | 2 | ||||
-rw-r--r-- | include/editeng/svxacorr.hxx | 3 | ||||
-rw-r--r-- | sw/source/core/edit/acorrect.cxx | 2 |
5 files changed, 23 insertions, 10 deletions
diff --git a/editeng/source/misc/svxacorr.cxx b/editeng/source/misc/svxacorr.cxx index c9d283466a5f..8b1a3eef33fa 100644 --- a/editeng/source/misc/svxacorr.cxx +++ b/editeng/source/misc/svxacorr.cxx @@ -1544,7 +1544,7 @@ bool SvxAutoCorrect::CreateLanguageFile( const LanguageTag& rLanguageTag, bool b { OSL_ENSURE(pLangTable->find(rLanguageTag) == pLangTable->end(), "Language already exists "); - OUString sUserDirFile( GetAutoCorrFileName( rLanguageTag, true, false )); + OUString sUserDirFile( GetAutoCorrFileName( rLanguageTag, true, false, false )); OUString sShareDirFile( sUserDirFile ); SvxAutoCorrectLanguageListsPtr pLists = 0; @@ -1567,10 +1567,15 @@ bool SvxAutoCorrect::CreateLanguageFile( const LanguageTag& rLanguageTag, bool b aLastFileTable.erase(nFndPos); } } - else if( ( FStatHelper::IsDocument( sUserDirFile ) || - FStatHelper::IsDocument( sShareDirFile = - GetAutoCorrFileName( rLanguageTag, false, false ) ) ) || - ( sShareDirFile = sUserDirFile, bNewFile )) + else if( + ( FStatHelper::IsDocument( sUserDirFile ) || + FStatHelper::IsDocument( sShareDirFile = + GetAutoCorrFileName( rLanguageTag, false, false, false ) ) || + FStatHelper::IsDocument( sShareDirFile = + GetAutoCorrFileName( rLanguageTag, false, false, true) ) + ) || + ( sShareDirFile = sUserDirFile, bNewFile ) + ) { pLists = new SvxAutoCorrectLanguageLists( *this, sShareDirFile, sUserDirFile ); LanguageTag aTmp(rLanguageTag); // this insert() needs a non-const reference @@ -1886,9 +1891,16 @@ bool SvxAutoCorrect::FindInCplSttExceptList(LanguageType eLang, } OUString SvxAutoCorrect::GetAutoCorrFileName( const LanguageTag& rLanguageTag, - bool bNewFile, bool bTst ) const + bool bNewFile, bool bTst, bool bUnlocalized ) const { OUString sRet, sExt( rLanguageTag.getBcp47() ); + if (bUnlocalized) + { + // we don't want variant, so we'll take "fr" instead of "fr-CA" for example + ::std::vector< OUString > vecFallBackStrings = rLanguageTag.getFallbackStrings(false); + if (!vecFallBackStrings.empty()) + sExt = vecFallBackStrings[0]; + } sExt = "_" + sExt + ".dat"; if( bNewFile ) diff --git a/extras/CustomTarget_autocorr.mk b/extras/CustomTarget_autocorr.mk index 66d32f6a8a65..ddafa020f7f4 100644 --- a/extras/CustomTarget_autocorr.mk +++ b/extras/CustomTarget_autocorr.mk @@ -23,7 +23,7 @@ extras_AUTOCORR_LANGS := \ es:es-ES \ fa:fa-IR \ fi:fi-FI \ - fr:fr-FR \ + fr:fr \ ga-IE:ga-IE \ hr:hr-HR \ hu:hu-HU \ diff --git a/extras/Package_autocorr.mk b/extras/Package_autocorr.mk index e42e3d1215d3..8c71a60d1aa3 100644 --- a/extras/Package_autocorr.mk +++ b/extras/Package_autocorr.mk @@ -23,7 +23,7 @@ $(eval $(call gb_Package_add_files,extras_autocorr,$(LIBO_SHARE_FOLDER)/autocorr acor_es-ES.dat \ acor_fa-IR.dat \ acor_fi-FI.dat \ - acor_fr-FR.dat \ + acor_fr.dat \ acor_ga-IE.dat \ acor_hr-HR.dat \ acor_hu-HU.dat \ diff --git a/include/editeng/svxacorr.hxx b/include/editeng/svxacorr.hxx index d4529a51623e..f2d066558cbf 100644 --- a/include/editeng/svxacorr.hxx +++ b/include/editeng/svxacorr.hxx @@ -329,7 +329,8 @@ public: // the default is "autocorr.dat" OUString GetAutoCorrFileName( const LanguageTag& rLanguageTag /* = LANGUAGE_SYSTEM */ , bool bNewFile = false, - bool bTstUserExist = false ) const; + bool bTstUserExist = false, + bool bUnlocalized = false ) const; // Query/Set the current settings of AutoCorrect long GetFlags() const { return nFlags; } diff --git a/sw/source/core/edit/acorrect.cxx b/sw/source/core/edit/acorrect.cxx index 20ee723f6eb9..f15169f4e8b3 100644 --- a/sw/source/core/edit/acorrect.cxx +++ b/sw/source/core/edit/acorrect.cxx @@ -340,7 +340,7 @@ bool SwAutoCorrDoc::ChgAutoCorrWord( sal_Int32& rSttPos, sal_Int32 nEndPos, } else { - SwTextBlocks aTBlks( rACorrect.GetAutoCorrFileName( aLanguageTag, false, true )); + SwTextBlocks aTBlks( rACorrect.GetAutoCorrFileName( aLanguageTag, false, true, false )); sal_uInt16 nPos = aTBlks.GetIndex( pFnd->GetShort() ); if( USHRT_MAX != nPos && aTBlks.BeginGetDoc( nPos ) ) { |