[Libreoffice-commits] core.git: editeng/qa editeng/source include/editeng sw/source
Eike Rathke
erack at redhat.com
Sat Sep 21 06:30:56 PDT 2013
editeng/qa/unit/core-test.cxx | 3
editeng/source/editeng/edtspell.cxx | 5 -
editeng/source/misc/svxacorr.cxx | 158 +++++++++++++++++++++---------------
include/editeng/svxacorr.hxx | 12 +-
sw/source/core/edit/acorrect.cxx | 5 -
5 files changed, 107 insertions(+), 76 deletions(-)
New commits:
commit a641bbff59cdd55cfc9757e6a43e732a3c8867be
Author: Eike Rathke <erack at redhat.com>
Date: Sat Sep 21 15:20:49 2013 +0200
map autocorrection files with LanguageTag key
... as several tags (i.e. renamed) may map to the same LangID.
Change-Id: I8202b18ea0dc8034522017be59bb104b3d06c0f4
diff --git a/editeng/qa/unit/core-test.cxx b/editeng/qa/unit/core-test.cxx
index 57c62c3..d0437f4 100644
--- a/editeng/qa/unit/core-test.cxx
+++ b/editeng/qa/unit/core-test.cxx
@@ -281,8 +281,9 @@ private:
if (m_rText.isEmpty())
return false;
+ LanguageTag aLanguageTag( m_eLang);
const SvxAutocorrWord* pFnd = rACorrect.SearchWordsInList(
- m_rText, rSttPos, nEndPos, *this, m_eLang);
+ m_rText, rSttPos, nEndPos, *this, aLanguageTag);
if (pFnd && pFnd->IsTextOnly())
{
m_rText = m_rText.replaceAt(rSttPos, nEndPos, pFnd->GetLong());
diff --git a/editeng/source/editeng/edtspell.cxx b/editeng/source/editeng/edtspell.cxx
index 6787981..f9eb356 100644
--- a/editeng/source/editeng/edtspell.cxx
+++ b/editeng/source/editeng/edtspell.cxx
@@ -741,8 +741,9 @@ bool EdtAutoCorrDoc::ChgAutoCorrWord( sal_Int32& rSttPos,
if( aShort.isEmpty() )
return bRet;
- LanguageType eLang = mpEditEngine->GetLanguage( EditPaM( pCurNode, rSttPos+1 ) );
- const SvxAutocorrWord* pFnd = rACorrect.SearchWordsInList(pCurNode->GetString(), rSttPos, nEndPos, *this, eLang);
+ LanguageTag aLanguageTag( mpEditEngine->GetLanguage( EditPaM( pCurNode, rSttPos+1 ) ));
+ const SvxAutocorrWord* pFnd = rACorrect.SearchWordsInList(
+ pCurNode->GetString(), rSttPos, nEndPos, *this, aLanguageTag);
if( pFnd && pFnd->IsTextOnly() )
{
// then replace
diff --git a/editeng/source/misc/svxacorr.cxx b/editeng/source/misc/svxacorr.cxx
index 14d3de7..1c65aea 100644
--- a/editeng/source/misc/svxacorr.cxx
+++ b/editeng/source/misc/svxacorr.cxx
@@ -223,7 +223,7 @@ static CollatorWrapper& GetCollatorWrapper()
return aCollWrp;
}
-static void lcl_ClearTable(boost::ptr_map<LanguageType, SvxAutoCorrectLanguageLists>& rLangTable)
+static void lcl_ClearTable(boost::ptr_map<LanguageTag, SvxAutoCorrectLanguageLists>& rLangTable)
{
rLangTable.clear();
}
@@ -282,7 +282,7 @@ SvxAutoCorrect::SvxAutoCorrect( const OUString& rShareAutocorrFile,
const OUString& rUserAutocorrFile )
: sShareAutoCorrFile( rShareAutocorrFile ),
sUserAutoCorrFile( rUserAutocorrFile ),
- pLangTable( new boost::ptr_map<LanguageType, SvxAutoCorrectLanguageLists> ),
+ pLangTable( new boost::ptr_map<LanguageTag, SvxAutoCorrectLanguageLists> ),
pCharClass( 0 ), bRunNext( false ),
cStartDQuote( 0 ), cEndDQuote( 0 ), cStartSQuote( 0 ), cEndSQuote( 0 )
{
@@ -298,7 +298,7 @@ SvxAutoCorrect::SvxAutoCorrect( const SvxAutoCorrect& rCpy )
aSwFlags( rCpy.aSwFlags ),
- pLangTable( new boost::ptr_map<LanguageType, SvxAutoCorrectLanguageLists> ),
+ pLangTable( new boost::ptr_map<LanguageTag, SvxAutoCorrectLanguageLists> ),
pCharClass( 0 ), bRunNext( false ),
nFlags( rCpy.nFlags & ~(ChgWordLstLoad|CplSttLstLoad|WrdSttLstLoad)),
@@ -319,7 +319,7 @@ SvxAutoCorrect::~SvxAutoCorrect()
void SvxAutoCorrect::_GetCharClass( LanguageType eLang )
{
delete pCharClass;
- pCharClass = new CharClass( LanguageTag( eLang ));
+ pCharClass = new CharClass( LanguageTag( eLang));
eCharClassLang = eLang;
}
@@ -1441,14 +1441,15 @@ SvxAutoCorrect::DoAutoCorrect( SvxAutoCorrDoc& rDoc, const OUString& rTxt,
SvxAutoCorrectLanguageLists& SvxAutoCorrect::_GetLanguageList(
LanguageType eLang )
{
- if(pLangTable->find(eLang) == pLangTable->end())
- CreateLanguageFile(eLang, sal_True);
- return *(pLangTable->find(eLang)->second);
+ LanguageTag aLanguageTag( eLang);
+ if(pLangTable->find(aLanguageTag) == pLangTable->end())
+ CreateLanguageFile(aLanguageTag, sal_True);
+ return *(pLangTable->find(aLanguageTag)->second);
}
void SvxAutoCorrect::SaveCplSttExceptList( LanguageType eLang )
{
- boost::ptr_map<LanguageType, SvxAutoCorrectLanguageLists>::iterator nTmpVal = pLangTable->find(eLang);
+ boost::ptr_map<LanguageTag, SvxAutoCorrectLanguageLists>::iterator nTmpVal = pLangTable->find(LanguageTag(eLang));
if(nTmpVal != pLangTable->end() && nTmpVal->second)
nTmpVal->second->SaveCplSttExceptList();
#ifdef DBG_UTIL
@@ -1461,7 +1462,7 @@ void SvxAutoCorrect::SaveCplSttExceptList( LanguageType eLang )
void SvxAutoCorrect::SaveWrdSttExceptList(LanguageType eLang)
{
- boost::ptr_map<LanguageType, SvxAutoCorrectLanguageLists>::iterator nTmpVal = pLangTable->find(eLang);
+ boost::ptr_map<LanguageTag, SvxAutoCorrectLanguageLists>::iterator nTmpVal = pLangTable->find(LanguageTag(eLang));
if(nTmpVal != pLangTable->end() && nTmpVal->second)
nTmpVal->second->SaveWrdSttExceptList();
#ifdef DBG_UTIL
@@ -1478,16 +1479,17 @@ sal_Bool SvxAutoCorrect::AddCplSttException( const String& rNew,
{
SvxAutoCorrectLanguageLists* pLists = 0;
// either the right language is present or it will be this in the general list
- boost::ptr_map<LanguageType, SvxAutoCorrectLanguageLists>::iterator nTmpVal = pLangTable->find(eLang);
+ boost::ptr_map<LanguageTag, SvxAutoCorrectLanguageLists>::iterator nTmpVal = pLangTable->find(LanguageTag(eLang));
if(nTmpVal != pLangTable->end())
pLists = nTmpVal->second;
else
{
- nTmpVal = pLangTable->find(LANGUAGE_UNDETERMINED);
+ LanguageTag aLangTagUndetermined( LANGUAGE_UNDETERMINED);
+ nTmpVal = pLangTable->find(aLangTagUndetermined);
if(nTmpVal != pLangTable->end())
pLists = nTmpVal->second;
- else if(CreateLanguageFile(LANGUAGE_UNDETERMINED, sal_True))
- pLists = pLangTable->find(LANGUAGE_UNDETERMINED)->second;
+ else if(CreateLanguageFile(aLangTagUndetermined, sal_True))
+ pLists = pLangTable->find(aLangTagUndetermined)->second;
}
OSL_ENSURE(pLists, "No auto correction data");
return pLists->AddToCplSttExceptList(rNew);
@@ -1499,16 +1501,17 @@ sal_Bool SvxAutoCorrect::AddWrtSttException( const String& rNew,
{
SvxAutoCorrectLanguageLists* pLists = 0;
//either the right language is present or it is set in the general list
- boost::ptr_map<LanguageType, SvxAutoCorrectLanguageLists>::iterator nTmpVal = pLangTable->find(eLang);
+ boost::ptr_map<LanguageTag, SvxAutoCorrectLanguageLists>::iterator nTmpVal = pLangTable->find(LanguageTag(eLang));
if(nTmpVal != pLangTable->end())
pLists = nTmpVal->second;
else
{
- nTmpVal = pLangTable->find(LANGUAGE_UNDETERMINED);
+ LanguageTag aLangTagUndetermined( LANGUAGE_UNDETERMINED);
+ nTmpVal = pLangTable->find(aLangTagUndetermined);
if(nTmpVal != pLangTable->end())
pLists = nTmpVal->second;
- else if(CreateLanguageFile(LANGUAGE_UNDETERMINED, sal_True))
- pLists = pLangTable->find(LANGUAGE_UNDETERMINED)->second;
+ else if(CreateLanguageFile(aLangTagUndetermined, sal_True))
+ pLists = pLangTable->find(aLangTagUndetermined)->second;
}
OSL_ENSURE(pLists, "No auto correction file!");
return pLists->AddToWrdSttExceptList(rNew);
@@ -1559,18 +1562,18 @@ sal_Bool SvxAutoCorrect::GetPrevAutoCorrWord( SvxAutoCorrDoc& rDoc,
return sal_True;
}
-sal_Bool SvxAutoCorrect::CreateLanguageFile( LanguageType eLang, sal_Bool bNewFile )
+sal_Bool SvxAutoCorrect::CreateLanguageFile( const LanguageTag& rLanguageTag, sal_Bool bNewFile )
{
- OSL_ENSURE(pLangTable->find(eLang) == pLangTable->end(), "Language already exists ");
+ OSL_ENSURE(pLangTable->find(rLanguageTag) == pLangTable->end(), "Language already exists ");
- OUString sUserDirFile( GetAutoCorrFileName( eLang, sal_True, sal_False ));
+ OUString sUserDirFile( GetAutoCorrFileName( rLanguageTag, sal_True, sal_False ));
OUString sShareDirFile( sUserDirFile );
SvxAutoCorrectLanguageListsPtr pLists = 0;
Time nMinTime( 0, 2 ), nAktTime( Time::SYSTEM ), nLastCheckTime( Time::EMPTY );
- std::map<LanguageType, long>::iterator nFndPos = aLastFileTable.find(eLang);
+ std::map<LanguageTag, long>::iterator nFndPos = aLastFileTable.find(rLanguageTag);
if(nFndPos != aLastFileTable.end() &&
(nLastCheckTime.SetTime(nFndPos->second), nLastCheckTime < nAktTime) &&
nAktTime - nLastCheckTime < nMinTime)
@@ -1581,23 +1584,25 @@ sal_Bool SvxAutoCorrect::CreateLanguageFile( LanguageType eLang, sal_Bool bNewFi
{
sShareDirFile = sUserDirFile;
pLists = new SvxAutoCorrectLanguageLists( *this, sShareDirFile, sUserDirFile );
- pLangTable->insert(eLang, pLists);
+ LanguageTag aTmp(rLanguageTag); // this insert() needs a non-const reference
+ pLangTable->insert(aTmp, pLists);
aLastFileTable.erase(nFndPos);
}
}
else if( ( FStatHelper::IsDocument( sUserDirFile ) ||
FStatHelper::IsDocument( sShareDirFile =
- GetAutoCorrFileName( eLang, sal_False, sal_False ) ) ) ||
+ GetAutoCorrFileName( rLanguageTag, sal_False, sal_False ) ) ) ||
( sShareDirFile = sUserDirFile, bNewFile ))
{
pLists = new SvxAutoCorrectLanguageLists( *this, sShareDirFile, sUserDirFile );
- pLangTable->insert(eLang, pLists);
+ LanguageTag aTmp(rLanguageTag); // this insert() needs a non-const reference
+ pLangTable->insert(aTmp, pLists);
if (nFndPos != aLastFileTable.end())
aLastFileTable.erase(nFndPos);
}
else if( !bNewFile )
{
- aLastFileTable[eLang] = nAktTime.GetTime();
+ aLastFileTable[rLanguageTag] = nAktTime.GetTime();
}
return pLists != 0;
}
@@ -1605,11 +1610,12 @@ sal_Bool SvxAutoCorrect::CreateLanguageFile( LanguageType eLang, sal_Bool bNewFi
sal_Bool SvxAutoCorrect::PutText( const OUString& rShort, const OUString& rLong,
LanguageType eLang )
{
- boost::ptr_map<LanguageType, SvxAutoCorrectLanguageLists>::iterator nTmpVal = pLangTable->find(eLang);
+ LanguageTag aLanguageTag( eLang);
+ boost::ptr_map<LanguageTag, SvxAutoCorrectLanguageLists>::iterator nTmpVal = pLangTable->find(aLanguageTag);
if(nTmpVal != pLangTable->end())
return nTmpVal->second->PutText(rShort, rLong);
- if(CreateLanguageFile(eLang))
- return pLangTable->find(eLang)->second->PutText(rShort, rLong);
+ if(CreateLanguageFile(aLanguageTag))
+ return pLangTable->find(aLanguageTag)->second->PutText(rShort, rLong);
return sal_False;
}
@@ -1617,14 +1623,15 @@ sal_Bool SvxAutoCorrect::MakeCombinedChanges( std::vector<SvxAutocorrWord>& aNew
std::vector<SvxAutocorrWord>& aDeleteEntries,
LanguageType eLang )
{
- boost::ptr_map<LanguageType, SvxAutoCorrectLanguageLists>::iterator nTmpVal = pLangTable->find(eLang);
+ LanguageTag aLanguageTag( eLang);
+ boost::ptr_map<LanguageTag, SvxAutoCorrectLanguageLists>::iterator nTmpVal = pLangTable->find(aLanguageTag);
if(nTmpVal != pLangTable->end())
{
return nTmpVal->second->MakeCombinedChanges( aNewEntries, aDeleteEntries );
}
- else if(CreateLanguageFile( eLang ))
+ else if(CreateLanguageFile( aLanguageTag ))
{
- return pLangTable->find( eLang )->second->MakeCombinedChanges( aNewEntries, aDeleteEntries );
+ return pLangTable->find( aLanguageTag )->second->MakeCombinedChanges( aNewEntries, aDeleteEntries );
}
return sal_False;
@@ -1694,63 +1701,70 @@ static const SvxAutocorrWord* lcl_SearchWordsInList(
// the search for the words in the substitution table
const SvxAutocorrWord* SvxAutoCorrect::SearchWordsInList(
const OUString& rTxt, sal_Int32& rStt, sal_Int32 nEndPos,
- SvxAutoCorrDoc&, LanguageType& rLang )
+ SvxAutoCorrDoc&, LanguageTag& rLang )
{
- LanguageType eLang = rLang;
const SvxAutocorrWord* pRet = 0;
- if( LANGUAGE_SYSTEM == eLang )
- eLang = MsLangId::getSystemLanguage();
+ LanguageTag aLanguageTag( rLang);
+ if( aLanguageTag.isSystemLocale() )
+ aLanguageTag.reset( MsLangId::getSystemLanguage());
+
+ /* TODO-BCP47: this is so ugly, should all maybe be a proper fallback
+ * list instead? */
// First search for eLang, then US-English -> English
// and last in LANGUAGE_UNDETERMINED
- if(pLangTable->find(eLang) != pLangTable->end() || CreateLanguageFile(eLang, sal_False))
+ if(pLangTable->find(aLanguageTag) != pLangTable->end() || CreateLanguageFile(aLanguageTag, sal_False))
{
//the language is available - so bring it on
- SvxAutoCorrectLanguageLists* pList = pLangTable->find(eLang)->second;
+ SvxAutoCorrectLanguageLists* pList = pLangTable->find(aLanguageTag)->second;
pRet = lcl_SearchWordsInList( pList, rTxt, rStt, nEndPos );
if( pRet )
{
- rLang = eLang;
+ rLang = aLanguageTag;
return pRet;
}
}
// If it still could not be found here, then keep on searching
+ LanguageType eLang = aLanguageTag.getLanguageType();
LanguageType nTmpKey1 = eLang & 0x7ff, // the main language in many cases DE
nTmpKey2 = eLang & 0x3ff; // otherwise for example EN
- if(nTmpKey1 != eLang && (pLangTable->find(nTmpKey1) != pLangTable->end() || CreateLanguageFile(nTmpKey1, sal_False)))
+ if(nTmpKey1 != eLang && (pLangTable->find(aLanguageTag.reset(nTmpKey1)) != pLangTable->end() ||
+ CreateLanguageFile(aLanguageTag, sal_False)))
{
//the language is available - so bring it on
- SvxAutoCorrectLanguageLists* pList = pLangTable->find(nTmpKey1)->second;
+ SvxAutoCorrectLanguageLists* pList = pLangTable->find(aLanguageTag)->second;
pRet = lcl_SearchWordsInList( pList, rTxt, rStt, nEndPos );
if( pRet )
{
- rLang = nTmpKey1;
+ rLang = aLanguageTag;
return pRet;
}
}
- if(nTmpKey2 != eLang && (pLangTable->find(nTmpKey2) != pLangTable->end() || CreateLanguageFile(nTmpKey2, sal_False)))
+ if(nTmpKey2 != eLang && (pLangTable->find(aLanguageTag.reset(nTmpKey2)) != pLangTable->end() ||
+ CreateLanguageFile(aLanguageTag, sal_False)))
{
//the language is available - so bring it on
- SvxAutoCorrectLanguageLists* pList = pLangTable->find(nTmpKey2)->second;
+ SvxAutoCorrectLanguageLists* pList = pLangTable->find(aLanguageTag)->second;
pRet = lcl_SearchWordsInList( pList, rTxt, rStt, nEndPos );
if( pRet )
{
- rLang = nTmpKey2;
+ rLang = aLanguageTag;
return pRet;
}
}
- if(pLangTable->find(LANGUAGE_UNDETERMINED) != pLangTable->end() || CreateLanguageFile(LANGUAGE_UNDETERMINED, sal_False))
+ if(pLangTable->find(aLanguageTag.reset(LANGUAGE_UNDETERMINED)) != pLangTable->end() ||
+ CreateLanguageFile(aLanguageTag, sal_False))
{
//the language is available - so bring it on
- SvxAutoCorrectLanguageLists* pList = pLangTable->find(LANGUAGE_UNDETERMINED)->second;
+ SvxAutoCorrectLanguageLists* pList = pLangTable->find(aLanguageTag)->second;
pRet = lcl_SearchWordsInList( pList, rTxt, rStt, nEndPos );
if( pRet )
{
- rLang = LANGUAGE_UNDETERMINED;
+ rLang = aLanguageTag;
return pRet;
}
}
@@ -1760,42 +1774,49 @@ const SvxAutocorrWord* SvxAutoCorrect::SearchWordsInList(
sal_Bool SvxAutoCorrect::FindInWrdSttExceptList( LanguageType eLang,
const OUString& sWord )
{
+ LanguageTag aLanguageTag( eLang);
+
+ /* TODO-BCP47: again horrible uglyness */
+
// First search for eLang, then US-English -> English
// and last in LANGUAGE_UNDETERMINED
LanguageType nTmpKey1 = eLang & 0x7ff, // the main language in many cases DE
nTmpKey2 = eLang & 0x3ff; // otherwise for example EN
OUString sTemp(sWord);
- if(pLangTable->find(eLang) != pLangTable->end() || CreateLanguageFile(eLang, sal_False))
+ if(pLangTable->find(aLanguageTag) != pLangTable->end() || CreateLanguageFile(aLanguageTag, sal_False))
{
//the language is available - so bring it on
- SvxAutoCorrectLanguageLists* pList = pLangTable->find(eLang)->second;
+ SvxAutoCorrectLanguageLists* pList = pLangTable->find(aLanguageTag)->second;
OUString _sTemp(sWord);
if(pList->GetWrdSttExceptList()->find(_sTemp) != pList->GetWrdSttExceptList()->end() )
return sal_True;
}
// If it still could not be found here, then keep on searching
- if(nTmpKey1 != eLang && (pLangTable->find(nTmpKey1) != pLangTable->end() || CreateLanguageFile(nTmpKey1, sal_False)))
+ if(nTmpKey1 != eLang && (pLangTable->find(aLanguageTag.reset(nTmpKey1)) != pLangTable->end() ||
+ CreateLanguageFile(aLanguageTag, sal_False)))
{
//the language is available - so bring it on
- SvxAutoCorrectLanguageLists* pList = pLangTable->find(nTmpKey1)->second;
+ SvxAutoCorrectLanguageLists* pList = pLangTable->find(aLanguageTag)->second;
if(pList->GetWrdSttExceptList()->find(sTemp) != pList->GetWrdSttExceptList()->end() )
return sal_True;
}
- if(nTmpKey2 != eLang && (pLangTable->find(nTmpKey2) != pLangTable->end() || CreateLanguageFile(nTmpKey2, sal_False)))
+ if(nTmpKey2 != eLang && (pLangTable->find(aLanguageTag.reset(nTmpKey2)) != pLangTable->end() ||
+ CreateLanguageFile(aLanguageTag, sal_False)))
{
//the language is available - so bring it on
- SvxAutoCorrectLanguageLists* pList = pLangTable->find(nTmpKey2)->second;
+ SvxAutoCorrectLanguageLists* pList = pLangTable->find(aLanguageTag)->second;
if(pList->GetWrdSttExceptList()->find(sTemp) != pList->GetWrdSttExceptList()->end() )
return sal_True;
}
- if(pLangTable->find(LANGUAGE_UNDETERMINED) != pLangTable->end() || CreateLanguageFile(LANGUAGE_UNDETERMINED, sal_False))
+ if(pLangTable->find(aLanguageTag.reset(LANGUAGE_UNDETERMINED)) != pLangTable->end() ||
+ CreateLanguageFile(aLanguageTag, sal_False))
{
//the language is available - so bring it on
- SvxAutoCorrectLanguageLists* pList = pLangTable->find(LANGUAGE_UNDETERMINED)->second;
+ SvxAutoCorrectLanguageLists* pList = pLangTable->find(aLanguageTag)->second;
if(pList->GetWrdSttExceptList()->find(sTemp) != pList->GetWrdSttExceptList()->end() )
return sal_True;
}
@@ -1839,50 +1860,57 @@ static sal_Bool lcl_FindAbbreviation(const SvStringsISortDtor* pList, const OUSt
sal_Bool SvxAutoCorrect::FindInCplSttExceptList(LanguageType eLang,
const OUString& sWord, sal_Bool bAbbreviation)
{
+ LanguageTag aLanguageTag( eLang);
+
+ /* TODO-BCP47: did I mention terrible horrible uglyness? */
+
// First search for eLang, then US-English -> English
// and last in LANGUAGE_UNDETERMINED
LanguageType nTmpKey1 = eLang & 0x7ff, // the main language in many cases DE
nTmpKey2 = eLang & 0x3ff; // otherwise for example EN
OUString sTemp( sWord );
- if(pLangTable->find(eLang) != pLangTable->end() || CreateLanguageFile(eLang, sal_False))
+ if(pLangTable->find(aLanguageTag) != pLangTable->end() || CreateLanguageFile(aLanguageTag, sal_False))
{
//the language is available - so bring it on
- const SvStringsISortDtor* pList = pLangTable->find(eLang)->second->GetCplSttExceptList();
+ const SvStringsISortDtor* pList = pLangTable->find(aLanguageTag)->second->GetCplSttExceptList();
if(bAbbreviation ? lcl_FindAbbreviation(pList, sWord) : pList->find(sTemp) != pList->end() )
return sal_True;
}
// If it still could not be found here, then keep on searching
- if(nTmpKey1 != eLang && (pLangTable->find(nTmpKey1) != pLangTable->end() || CreateLanguageFile(nTmpKey1, sal_False)))
+ if(nTmpKey1 != eLang && (pLangTable->find(aLanguageTag.reset(nTmpKey1)) != pLangTable->end() ||
+ CreateLanguageFile(aLanguageTag, sal_False)))
{
- const SvStringsISortDtor* pList = pLangTable->find(nTmpKey1)->second->GetCplSttExceptList();
+ const SvStringsISortDtor* pList = pLangTable->find(aLanguageTag)->second->GetCplSttExceptList();
if(bAbbreviation ? lcl_FindAbbreviation(pList, sWord) : pList->find(sTemp) != pList->end() )
return sal_True;
}
- if(nTmpKey2 != eLang && (pLangTable->find(nTmpKey2) != pLangTable->end() || CreateLanguageFile(nTmpKey2, sal_False)))
+ if(nTmpKey2 != eLang && (pLangTable->find(aLanguageTag.reset(nTmpKey2)) != pLangTable->end() ||
+ CreateLanguageFile(aLanguageTag, sal_False)))
{
//the language is available - so bring it on
- const SvStringsISortDtor* pList = pLangTable->find(nTmpKey2)->second->GetCplSttExceptList();
+ const SvStringsISortDtor* pList = pLangTable->find(aLanguageTag)->second->GetCplSttExceptList();
if(bAbbreviation ? lcl_FindAbbreviation(pList, sWord) : pList->find(sTemp) != pList->end() )
return sal_True;
}
- if(pLangTable->find(LANGUAGE_UNDETERMINED) != pLangTable->end() || CreateLanguageFile(LANGUAGE_UNDETERMINED, sal_False))
+ if(pLangTable->find(aLanguageTag.reset(LANGUAGE_UNDETERMINED)) != pLangTable->end() ||
+ CreateLanguageFile(aLanguageTag, sal_False))
{
//the language is available - so bring it on
- const SvStringsISortDtor* pList = pLangTable->find(LANGUAGE_UNDETERMINED)->second->GetCplSttExceptList();
+ const SvStringsISortDtor* pList = pLangTable->find(aLanguageTag)->second->GetCplSttExceptList();
if(bAbbreviation ? lcl_FindAbbreviation(pList, sWord) : pList->find(sTemp) != pList->end() )
return sal_True;
}
return sal_False;
}
-OUString SvxAutoCorrect::GetAutoCorrFileName( LanguageType eLang,
+OUString SvxAutoCorrect::GetAutoCorrFileName( const LanguageTag& rLanguageTag,
sal_Bool bNewFile, sal_Bool bTst ) const
{
- OUString sRet, sExt( LanguageTag::convertToBcp47( eLang ) );
+ OUString sRet, sExt( rLanguageTag.getBcp47() );
sExt = "_" + sExt + ".dat";
if( bNewFile )
diff --git a/include/editeng/svxacorr.hxx b/include/editeng/svxacorr.hxx
index cc08b5f3..a3378f1 100644
--- a/include/editeng/svxacorr.hxx
+++ b/include/editeng/svxacorr.hxx
@@ -24,7 +24,7 @@
#include <o3tl/sorted_vector.hxx>
#include <tools/rtti.hxx>
-#include <i18nlangtag/lang.h>
+#include <i18nlangtag/languagetag.hxx>
#include <tools/time.hxx>
#include <tools/date.hxx>
#include <tools/string.hxx>
@@ -244,8 +244,8 @@ class EDITENG_DLLPUBLIC SvxAutoCorrect
SvxSwAutoFmtFlags aSwFlags; // StarWriter AutoFormat Flags
// all languages in a table
- boost::ptr_map<LanguageType, SvxAutoCorrectLanguageLists>* pLangTable;
- std::map<LanguageType, long> aLastFileTable;
+ boost::ptr_map<LanguageTag, SvxAutoCorrectLanguageLists>* pLangTable;
+ std::map<LanguageTag, long> aLastFileTable;
CharClass* pCharClass;
bool bRunNext;
@@ -269,7 +269,7 @@ protected:
const OUString& rFileName, const OUString& rShort, SfxObjectShell&, OUString& );
// required language in the table add if possible only when the file exists
- sal_Bool CreateLanguageFile(LanguageType eLang, sal_Bool bNewFile = sal_True);
+ sal_Bool CreateLanguageFile(const LanguageTag& rLanguageTag, sal_Bool bNewFile = sal_True);
// - Return the replacement text (only for SWG format, all others can be
// taken from the word list!)
// rShort is the stream name - encrypted!
@@ -309,7 +309,7 @@ public:
const SvxAutocorrWord* SearchWordsInList( const OUString& rTxt,
sal_Int32& rStt, sal_Int32 nEndPos,
SvxAutoCorrDoc& rDoc,
- LanguageType& rLang );
+ LanguageTag& rLang );
// Query/Set the Character for the Quote substitution
sal_Unicode GetStartSingleQuote() const { return cStartSQuote; }
@@ -329,7 +329,7 @@ public:
// Query/Set the name of the AutoCorrect file
// the default is "autocorr.dat"
- OUString GetAutoCorrFileName( LanguageType eLang = LANGUAGE_SYSTEM,
+ OUString GetAutoCorrFileName( const LanguageTag& rLanguageTag /* = LANGUAGE_SYSTEM */ ,
sal_Bool bNewFile = sal_False,
sal_Bool bTstUserExist = sal_False ) const;
diff --git a/sw/source/core/edit/acorrect.cxx b/sw/source/core/edit/acorrect.cxx
index 4599e75..8d9fb7c 100644
--- a/sw/source/core/edit/acorrect.cxx
+++ b/sw/source/core/edit/acorrect.cxx
@@ -312,13 +312,14 @@ bool SwAutoCorrDoc::ChgAutoCorrWord( sal_Int32& rSttPos, sal_Int32 nEndPos,
LanguageType eLang = GetLanguage(nEndPos, sal_False);
if(LANGUAGE_SYSTEM == eLang)
eLang = GetAppLanguage();
+ LanguageTag aLanguageTag( eLang);
//JP 22.04.99: Bug 63883 - Special treatment for dots.
bool bLastCharIsPoint = nEndPos < pTxtNd->GetTxt().getLength() &&
('.' == pTxtNd->GetTxt()[nEndPos]);
const SvxAutocorrWord* pFnd = rACorrect.SearchWordsInList(
- pTxtNd->GetTxt(), rSttPos, nEndPos, *this, eLang );
+ pTxtNd->GetTxt(), rSttPos, nEndPos, *this, aLanguageTag );
SwDoc* pDoc = rEditSh.GetDoc();
if( pFnd )
{
@@ -338,7 +339,7 @@ bool SwAutoCorrDoc::ChgAutoCorrWord( sal_Int32& rSttPos, sal_Int32 nEndPos,
}
else
{
- SwTextBlocks aTBlks( rACorrect.GetAutoCorrFileName( eLang, sal_False, sal_True ));
+ SwTextBlocks aTBlks( rACorrect.GetAutoCorrFileName( aLanguageTag, sal_False, sal_True ));
sal_uInt16 nPos = aTBlks.GetIndex( pFnd->GetShort() );
if( USHRT_MAX != nPos && aTBlks.BeginGetDoc( nPos ) )
{
More information about the Libreoffice-commits
mailing list