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
This commit is contained in:
Andras Timar 2013-12-09 20:22:26 +01:00
parent f464bb21c8
commit cb56ab9bca
2 changed files with 26 additions and 19 deletions

View File

@ -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 );

View File

@ -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;