diff options
author | Andras Timar <andras.timar@collabora.com> | 2013-12-09 20:22:26 +0100 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2013-12-09 20:22:26 +0100 |
commit | cb56ab9bca5e917d86a7dc24eb144353c405f07c (patch) | |
tree | ea20c551f372f5a3ebe044c079bf36fec3f729ea /lingucomponent | |
parent | f464bb21c8e8483200feb159cfdf9e5bc29aa27f (diff) |
fdo#56443 allow different name for .dic and .aff files
For example, de_CH_frami.dic and de_AT_frami.dic use de_DE_frami.aff.
Change-Id: I1d3770ad871b4714f7e595e1cd13f5fd7f224a1f
Diffstat (limited to 'lingucomponent')
-rw-r--r-- | lingucomponent/source/spellcheck/spell/sspellimp.cxx | 42 | ||||
-rw-r--r-- | lingucomponent/source/spellcheck/spell/sspellimp.hxx | 3 |
2 files changed, 26 insertions, 19 deletions
diff --git a/lingucomponent/source/spellcheck/spell/sspellimp.cxx b/lingucomponent/source/spellcheck/spell/sspellimp.cxx index e3a79df0fe66..bce00cc0dc5f 100644 --- a/lingucomponent/source/spellcheck/spell/sspellimp.cxx +++ b/lingucomponent/source/spellcheck/spell/sspellimp.cxx @@ -66,7 +66,8 @@ SpellChecker::SpellChecker() : aDicts(NULL), aDEncs(NULL), aDLocs(NULL), - aDNames(NULL), + aDAffNames(NULL), + aDDicNames(NULL), numdict(0), aEvtListeners(GetLinguMutex()), pPropHelper(NULL), @@ -86,7 +87,8 @@ SpellChecker::~SpellChecker() } delete[] aDEncs; delete[] aDLocs; - delete[] aDNames; + delete[] aDAffNames; + delete[] aDDicNames; if (pPropHelper) { pPropHelper->RemoveAsPropListener(); @@ -183,7 +185,8 @@ Sequence< Locale > SAL_CALL SpellChecker::getLocales() aDicts = new Hunspell* [numdict]; aDEncs = new rtl_TextEncoding [numdict]; aDLocs = new Locale [numdict]; - aDNames = new OUString [numdict]; + aDAffNames = new OUString [numdict]; + aDDicNames = new OUString [numdict]; k = 0; for (aDictIt = aDics.begin(); aDictIt != aDics.end(); ++aDictIt) { @@ -201,13 +204,16 @@ Sequence< Locale > SAL_CALL SpellChecker::getLocales() aDicts[k] = NULL; aDEncs[k] = RTL_TEXTENCODING_DONTKNOW; aDLocs[k] = LanguageTag::convertToLocale( aLocaleNames[i] ); - // also both files have to be in the same directory and the - // file names must only differ in the extension (.aff/.dic). - // Thus we use the first location only and strip the extension part. - OUString aLocation = aDictIt->aLocations[0]; - sal_Int32 nPos = aLocation.lastIndexOf( '.' ); - aLocation = aLocation.copy( 0, nPos ); - aDNames[k] = aLocation; + if ((aDictIt->aLocations[0]).endsWith(".aff")) + { + aDAffNames[k] = aDictIt->aLocations[0]; + aDDicNames[k] = aDictIt->aLocations[1]; + } + else + { + aDAffNames[k] = aDictIt->aLocations[1]; + aDDicNames[k] = aDictIt->aLocations[0]; + } ++k; } @@ -225,8 +231,10 @@ Sequence< Locale > SAL_CALL SpellChecker::getLocales() aDEncs = NULL; delete[] aDLocs; aDLocs = NULL; - delete[] aDNames; - aDNames = NULL; + delete[] aDAffNames; + delete[] aDDicNames; + aDAffNames = NULL; + aDDicNames = NULL; aSuppLocales.realloc(0); } } @@ -303,18 +311,16 @@ sal_Int16 SpellChecker::GetSpellFailure( const OUString &rWord, const Locale &rL { if (!aDicts[i]) { - OUString dicpath = aDNames[i] + ".dic"; - OUString affpath = aDNames[i] + ".aff"; OUString dict; OUString aff; - osl::FileBase::getSystemPathFromFileURL(dicpath,dict); - osl::FileBase::getSystemPathFromFileURL(affpath,aff); + osl::FileBase::getSystemPathFromFileURL(aDDicNames[i],dict); + osl::FileBase::getSystemPathFromFileURL(aDAffNames[i],aff); OString aTmpaff(OU2ENC(aff,osl_getThreadTextEncoding())); OString aTmpdict(OU2ENC(dict,osl_getThreadTextEncoding())); #if defined(WNT) - // workaround for Windows specifc problem that the - // path length in calls to 'fopen' is limted to somewhat + // workaround for Windows specific problem that the + // path length in calls to 'fopen' is limited to somewhat // about 120+ characters which will usually be exceed when // using dictionaries as extensions. aTmpaff = Win_GetShortPathName( aff ); diff --git a/lingucomponent/source/spellcheck/spell/sspellimp.hxx b/lingucomponent/source/spellcheck/spell/sspellimp.hxx index 89ac20e8936d..47c1c31ad148 100644 --- a/lingucomponent/source/spellcheck/spell/sspellimp.hxx +++ b/lingucomponent/source/spellcheck/spell/sspellimp.hxx @@ -63,7 +63,8 @@ class SpellChecker : Hunspell ** aDicts; rtl_TextEncoding * aDEncs; Locale * aDLocs; - OUString * aDNames; + OUString * aDAffNames; + OUString * aDDicNames; sal_Int32 numdict; ::cppu::OInterfaceContainerHelper aEvtListeners; |