summaryrefslogtreecommitdiff
path: root/lingucomponent
diff options
context:
space:
mode:
authorSander Vesik <svesik@openoffice.org>2002-07-29 16:28:22 +0000
committerSander Vesik <svesik@openoffice.org>2002-07-29 16:28:22 +0000
commit779ea694af5eaf155ee24c8357e9b27a78046e6e (patch)
tree5efb6d05d70ecd3ec8102bb4088bc87c0adab543 /lingucomponent
parent4a3dd2fe99714c38fdf549dddbfb03530ceb3740 (diff)
Merge from OOO_STABLE_1
Diffstat (limited to 'lingucomponent')
-rw-r--r--lingucomponent/prj/build.lst13
-rw-r--r--lingucomponent/prj/d.lst10
-rw-r--r--lingucomponent/source/hyphenator/altlinuxhyph/hyphen/hyphenimp.cxx402
-rw-r--r--lingucomponent/source/hyphenator/altlinuxhyph/hyphen/hyphenimp.hxx18
-rw-r--r--lingucomponent/source/hyphenator/altlinuxhyph/hyphen/makefile.mk29
-rw-r--r--lingucomponent/source/spellcheck/spell/makefile.mk26
-rw-r--r--lingucomponent/source/spellcheck/spell/sspellimp.cxx115
7 files changed, 436 insertions, 177 deletions
diff --git a/lingucomponent/prj/build.lst b/lingucomponent/prj/build.lst
index f488926c0fe3..46a1851b5abd 100644
--- a/lingucomponent/prj/build.lst
+++ b/lingucomponent/prj/build.lst
@@ -1,9 +1,10 @@
lc lingucomponent : linguistic lingu NULL
lc lingucomponent usr1 - all lc_mkout NULL
-lc lingucomponent\source\thesaurus\parser nmake - all lc_parser NULL
-lc lingucomponent\source\thesaurus\libth nmake - all lc_libth NULL
-lc lingucomponent\source\spellcheck\myspell nmake - all lc_myspell NULL
+lc lingucomponent\source\utility nmake - all lc_util NULL
+lc lingucomponent\source\thesaurus\parser nmake - all lc_parser lc_util NULL
+lc lingucomponent\source\thesaurus\libth nmake - all lc_libth lc_util NULL
+lc lingucomponent\source\spellcheck\myspell nmake - all lc_myspell lc_util NULL
lc lingucomponent\source\spellcheck\spell nmake - all lc_libspell lc_myspell NULL
-lc lingucomponent\source\hyphenator\altlinuxhyph\libhnj nmake - all lc_libhnj NULL
-lc lingucomponent\source\hyphenator\altlinuxhyph\hyphen nmake - all lc_libhyphen lc_libhnj NULL
-lc lingucomponent\source\hyphenator\altlinuxhyph\hyphtabs nmake - all lc_hyphtabs NULL
+lc lingucomponent\source\hyphenator\altlinuxhyph\libhnj nmake - all lc_libhnj lc_util NULL
+lc lingucomponent\source\hyphenator\altlinuxhyph\hyphen nmake - all lc_libhyphen lc_libhnj NULL
+lc lingucomponent\source\hyphenator\altlinuxhyph\hyphtabs nmake - all lc_hyphtabs lc_util NULL
diff --git a/lingucomponent/prj/d.lst b/lingucomponent/prj/d.lst
index 6bb2f470c0e1..01015dace878 100644
--- a/lingucomponent/prj/d.lst
+++ b/lingucomponent/prj/d.lst
@@ -7,13 +7,13 @@
..\%__SRC%\bin\lth* %_DEST%\bin%_EXT%\lth*
..\%__SRC%\lib\ilth* %_DEST%\lib%_EXT%\ilth*
..\%__SRC%\lib\liblth.a %_DEST%\lib%_EXT%\liblth.a
-..\%__SRC%\lib\*.dylib %_DEST%\lib%_EXT%\*.dylib
+..\%__SRC%\lib\liblth*.dylib %_DEST%\lib%_EXT%\liblth*.dylib
..\%__SRC%\lib\liblth*.so %_DEST%\lib%_EXT%\liblth*.so
..\%__SRC%\bin\spell* %_DEST%\bin%_EXT%\spell*
..\%__SRC%\lib\ilspell* %_DEST%\lib%_EXT%\ilspell*
..\%__SRC%\lib\libspell.a %_DEST%\lib%_EXT%\libspell.a
-..\%__SRC%\lib\*.dylib %_DEST%\lib%_EXT%\*.dylib
+..\%__SRC%\lib\libspell*.dylib %_DEST%\lib%_EXT%\libspell*.dylib
..\%__SRC%\lib\libspell*.so %_DEST%\lib%_EXT%\libspell*.so
..\%__SRC%\bin\hyph* %_DEST%\bin%_EXT%\hyph*
@@ -22,3 +22,9 @@
..\%__SRC%\lib\*.dylib %_DEST%\lib%_EXT%\*.dylib
..\%__SRC%\lib\libhyphen*.so %_DEST%\lib%_EXT%\libhyphen*.so
+..\%__SRC%\bin\ulingu* %_DEST%\bin%_EXT%\ulingu*
+..\%__SRC%\lib\ilulingu* %_DEST%\lib%_EXT%\iulingu*
+..\%__SRC%\lib\libulingu.a %_DEST%\lib%_EXT%\libulingu.a
+..\%__SRC%\lib\*.dylib %_DEST%\lib%_EXT%\*.dylib
+..\%__SRC%\lib\libulingu*.so %_DEST%\lib%_EXT%\libulingu*.so
+
diff --git a/lingucomponent/source/hyphenator/altlinuxhyph/hyphen/hyphenimp.cxx b/lingucomponent/source/hyphenator/altlinuxhyph/hyphen/hyphenimp.cxx
index 5e912e7b962b..9946b97ef954 100644
--- a/lingucomponent/source/hyphenator/altlinuxhyph/hyphen/hyphenimp.cxx
+++ b/lingucomponent/source/hyphenator/altlinuxhyph/hyphen/hyphenimp.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: hyphenimp.cxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: nidd $ $Date: 2002-05-09 17:36:02 $
+ * last change: $Author: svesik $ $Date: 2002-07-29 17:28:00 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -113,6 +113,8 @@
#endif
#include <osl/file.hxx>
+#include "dictmgr.hxx"
+#include "csutil.hxx"
#include <stdio.h>
#include <iostream>
@@ -147,6 +149,7 @@ Hyphenator::Hyphenator() :
{
bDisposing = FALSE;
pPropHelper = NULL;
+ numdict = 0;
}
@@ -155,6 +158,11 @@ Hyphenator::~Hyphenator()
{
if (pPropHelper)
pPropHelper->RemoveAsPropListener();
+ if (numdict) {
+ delete[] aDicts;
+ aDicts = NULL;
+ numdict = 0;
+ }
}
@@ -181,23 +189,134 @@ Sequence< Locale > SAL_CALL Hyphenator::getLocales()
MutexGuard aGuard( GetLinguMutex() );
SvtPathOptions aPathOpt;
-
- if (!aSuppLocales.getLength())
+ if (!numdict)
{
- aSuppLocales.realloc( 4 );
- Locale *pLocale = aSuppLocales.getArray();
- pLocale[0] = Locale( A2OU("en"), A2OU("US"), OUString() );
- pLocale[1] = Locale( A2OU("ru"), A2OU("RU"), OUString() );
- pLocale[2] = Locale( A2OU("de"), A2OU("DE"), OUString() );
- pLocale[3] = Locale( A2OU("da"), A2OU("DK"), OUString() );
+ // this routine should return the locales supported by the installed
+ // hyph dictionaries. So here we need to parse both the user edited
+ // dictionary list and the shared dictionary list
+ // to see what dictionaries the admin/user has installed
+
+ int numusr; // number of user dictionary entries
+ int numshr; // number of shared dictionary entries
+ dictentry * spdict; // shared dict entry pointer
+ dictentry * updict; // user dict entry pointer
+
+ // invoke a dictionary manager to get the user dictionary list
+ OUString usrlst = aPathOpt.GetUserDictionaryPath() + A2OU("/dictionary.lst");
+ OUString ulst;
+ osl::FileBase::getSystemPathFromFileURL(usrlst,ulst);
+ OString uTmp(OU2ENC(ulst,osl_getThreadTextEncoding()));
+ DictMgr* udMgr = new DictMgr(uTmp.getStr(),"HYPH");
+ numusr = 0;
+ if (udMgr)
+ numusr = udMgr->get_list(&updict);
+
+ // invoke a second dictionary manager to get the shared dictionary list
+ OUString shrlst = aPathOpt.GetLinguisticPath() + A2OU("/ooo/dictionary.lst");
+ OUString slst;
+ osl::FileBase::getSystemPathFromFileURL(shrlst,slst);
+ OString sTmp(OU2ENC(slst,osl_getThreadTextEncoding()));
+ DictMgr* sdMgr = new DictMgr(sTmp.getStr(),"HYPH");
+ numshr = 0;
+ if (sdMgr)
+ numshr = sdMgr->get_list(&spdict);
+
+
+ // we really should merge these and remove duplicates but since
+ // users can name their dictionaries anything they want it would
+ // be impossible to know if a real duplication exists unless we
+ // add some unique key to each hyphenation dictionary
+ // we can worry about that when and if issuezilla's flood in
+ numdict = numusr + numshr;
+
+ if (numdict) {
+ aDicts = new HDInfo[numdict];
+ aSuppLocales.realloc(numdict);
+ Locale * pLocale = aSuppLocales.getArray();
+ int numlocs = 0;
+ int newloc;
+ int i,j;
+ int k = 0;
+
+ // first add the user dictionaries
+ // keeping track of unique locales only
+ for (i = 0; i < numusr; i++) {
+ Locale nLoc( A2OU(updict->lang), A2OU(updict->region), OUString() );
+
+ newloc = 1;
+ for (j = 0; j < numlocs; j++) {
+ if (nLoc == pLocale[j]) newloc = 0;
+ }
+ if (newloc) {
+ pLocale[numlocs] = nLoc;
+ numlocs++;
+ }
+ aDicts[k].aPtr = NULL;
+ aDicts[k].aLoc = nLoc;
+ aDicts[k].aEnc = 0;
+ aDicts[k].aName = A2OU(updict->filename);
+ k++;
+ updict++;
+ }
+
+ // now add the shared dictionaries
+ // keeping track of unique locales only
+ for (i = 0; i < numshr; i++) {
+ Locale nLoc( A2OU(spdict->lang), A2OU(spdict->region), OUString() );
+
+ newloc = 1;
+ for (j = 0; j < numlocs; j++) {
+ if (nLoc == pLocale[j]) newloc = 0;
+ }
+ if (newloc) {
+ pLocale[numlocs] = nLoc;
+ numlocs++;
+ }
+ aDicts[k].aPtr = NULL;
+ aDicts[k].aLoc = nLoc;
+ aDicts[k].aEnc = 0;
+ aDicts[k].aName = A2OU(spdict->filename);
+ k++;
+ spdict++;
+ }
+
+ // reallocate the size to just cover the unique locales
+ aSuppLocales.realloc(numlocs);
+
+ } else {
+ // no dictionary.lst files found, just default to hyph_en.dic
+ numdict = 1;
+ aSuppLocales.realloc(1);
+ Locale *pLocale = aSuppLocales.getArray();
+ Locale nLoc( A2OU("en"), A2OU("US"), OUString() );
+ pLocale[0] = nLoc;
+ aDicts = new HDInfo[1];
+ aDicts[0].aPtr = NULL;
+ aDicts[0].aLoc = nLoc;
+ aDicts[0].aEnc = 0;
+ aDicts[0].aName = A2OU("hyph_en");
+ }
+
+ /* de-allocation of memory is handled inside the DictMgr */
+ updict = NULL;
+ if (udMgr) {
+ delete udMgr;
+ udMgr = NULL;
+ }
+ spdict = NULL;
+ if (sdMgr) {
+ delete sdMgr;
+ sdMgr = NULL;
+ }
- }
+ }
return aSuppLocales;
}
+
sal_Bool SAL_CALL Hyphenator::hasLocale(const Locale& rLocale)
throw(RuntimeException)
{
@@ -220,15 +339,6 @@ sal_Bool SAL_CALL Hyphenator::hasLocale(const Locale& rLocale)
return bRes;
}
-rtl_TextEncoding L2TE( LanguageType nLang )
-{
- switch( nLang )
- {
- case 0x419 : return RTL_TEXTENCODING_KOI8_R; break; // RUSSIAN
-
- }
- return RTL_TEXTENCODING_MS_1252;
-}
Reference< XHyphenatedWord > SAL_CALL
Hyphenator::hyphenate( const ::rtl::OUString& aWord,
@@ -239,77 +349,103 @@ Hyphenator::hyphenate( const ::rtl::OUString& aWord,
com::sun::star::lang::IllegalArgumentException)
{
SvtPathOptions aPathOpt;
- CharClass chclass( rSMgr, aLocale );
int nHyphenationPos = -1;
int wordlen;
char *hyphens;
+ char *lcword;
+ int k = 0;
+
+
+ HyphenDict *dict = NULL;
+ rtl_TextEncoding aEnc = 0;
- HyphenDict *dict;
- OString encWord;
- OUString tohyphenate;
Reference< XHyphenatedWord > xRes;
- if ( ( dict = aOpenedDicts.Get ( LocaleToLanguage ( aLocale ) ) ) == NULL )
- {
- OUString DictFN = A2OU("hyph_") + aLocale.Language + A2OU(".dic");
- OUString userdictpath;
- OUString dictpath;
- osl::FileBase::getSystemPathFromFileURL(
+ k = -1;
+ for (int j = 0; j < numdict; j++)
+ if (aLocale == aDicts[j].aLoc) k = j;
+
+
+ // if we have a hyphenation dictionary matching this locale
+ if (k != -1) {
+
+ // if this dictinary has not been loaded yet do that
+ if (!aDicts[k].aPtr) {
+
+ OUString DictFN = aDicts[k].aName + A2OU(".dic");
+ OUString userdictpath;
+ OUString dictpath;
+
+ osl::FileBase::getSystemPathFromFileURL(
aPathOpt.GetUserDictionaryPath() + A2OU("/"),
userdictpath);
- osl::FileBase::getSystemPathFromFileURL(
- aPathOpt.GetDictionaryPath() + A2OU("/"),
+ osl::FileBase::getSystemPathFromFileURL(
+ aPathOpt.GetLinguisticPath() + A2OU("/ooo/"),
dictpath);
- if ( ( dict = hnj_hyphen_load ( OU2A(userdictpath + DictFN) ) ) == NULL )
- if ( ( dict = hnj_hyphen_load ( OU2A(dictpath + DictFN) ) ) == NULL )
- {
- fprintf(stderr, "Couldn't find file %s and %s\n", OU2A(userdictpath + DictFN), OU2A(userdictpath + DictFN ));
- return NULL;
- }
- aOpenedDicts.Insert( LocaleToLanguage ( aLocale ), dict );
- }
+ OString uTmp(OU2ENC(userdictpath + DictFN,osl_getThreadTextEncoding()));
+ OString sTmp(OU2ENC(dictpath + DictFN,osl_getThreadTextEncoding()));
rtl_TextEncoding DictionaryEnc = L2TE( LocaleToLanguage( aLocale ) );
-// chclass.toLower(aWord);
- encWord = OUStringToOString (aWord, DictionaryEnc);
+ if ( ( dict = hnj_hyphen_load ( uTmp.getStr() ) ) == NULL )
+ if ( ( dict = hnj_hyphen_load ( sTmp.getStr()) ) == NULL )
+ {
+ fprintf(stderr, "Couldn't find file %s and %s\n", OU2ENC(userdictpath + DictFN, osl_getThreadTextEncoding()), OU2ENC(userdictpath + DictFN, osl_getThreadTextEncoding() ));
+ return NULL;
+ }
+ aDicts[k].aPtr = dict;
+ aDicts[k].aEnc = rtl_getTextEncodingFromUnixCharset(dict->cset);
+ }
- wordlen = encWord.getLength();
+ // other wise hyphenate the word with that dictionary
+ dict = aDicts[k].aPtr;
+ aEnc = aDicts[k].aEnc;
- hyphens = new char[wordlen+5];
+ OString encWord(OU2ENC(aWord,aEnc));
- if (hnj_hyphen_hyphenate(dict, encWord.getStr(), wordlen, hyphens))
- {
- delete hyphens;
- return NULL;
- }
+ wordlen = encWord.getLength();
+ lcword = new char[wordlen+1];
+ hyphens = new char[wordlen+5];
+ enmkallsmall(lcword,encWord.getStr(),dict->cset);
- OUStringBuffer hyphenatedWord;
- INT32 Leading = GetPosInWordToCheck( aWord, nMaxLeading );
+ if (hnj_hyphen_hyphenate(dict, lcword, wordlen, hyphens))
+ {
+ //whoops something did not work
+ delete[] hyphens;
+ delete[] lcword;
+ return NULL;
+ }
- for (INT32 i = 0; i < encWord.getLength(); i++)
- {
- hyphenatedWord.append(aWord[i]);
- if ((hyphens[i]&1) && (i < Leading))
- {
- nHyphenationPos = i;
- hyphenatedWord.append(sal_Unicode('='));
- }
- }
+ OUStringBuffer hyphenatedWord;
+ INT32 Leading = GetPosInWordToCheck( aWord, nMaxLeading );
- if (nHyphenationPos == -1)
- xRes = NULL;
- else
- {
- xRes = new HyphenatedWord( aWord, LocaleToLanguage( aLocale ), nHyphenationPos,
+ for (INT32 i = 0; i < encWord.getLength(); i++)
+ {
+ hyphenatedWord.append(aWord[i]);
+ if ((hyphens[i]&1) && (i < Leading))
+ {
+ nHyphenationPos = i;
+ hyphenatedWord.append(sal_Unicode('='));
+ }
+ }
+
+ if (nHyphenationPos == -1)
+ xRes = NULL;
+ else
+ {
+ xRes = new HyphenatedWord( aWord, LocaleToLanguage( aLocale ), nHyphenationPos,
aWord, nHyphenationPos );
- }
+ }
+
+ delete[] hyphens;
+ delete[] lcword;
+ return xRes;
- delete hyphens;
- return xRes;
+ }
+ return NULL;
}
Reference < XHyphenatedWord > SAL_CALL
@@ -334,83 +470,111 @@ Reference< XPossibleHyphens > SAL_CALL
{
SvtPathOptions aPathOpt;
- CharClass chclass( rSMgr, aLocale );
+ // CharClass chclass( rSMgr, aLocale );
int nHyphenationPos = -1;
int wordlen;
char *hyphens;
+ char *lcword;
+ int k;
+
HyphenDict *dict;
- OString encWord;
- OUString tohyphenate;
+ rtl_TextEncoding aEnc;
+
Reference< XPossibleHyphens > xRes;
- if ( ( dict = aOpenedDicts.Get ( LocaleToLanguage ( aLocale ) ) ) == NULL )
- {
- OUString DictFN = A2OU("hyph_") + aLocale.Language + A2OU(".dic");
- OUString userdictpath;
- OUString dictpath;
- osl::FileBase::getSystemPathFromFileURL(
+ k = -1;
+ for (int j = 0; j < numdict; j++)
+ if (aLocale == aDicts[j].aLoc) k = j;
+
+ dict = NULL;
+ aEnc = 0;
+
+ // if we have a hyphenationd citionary matching this locale
+ if (k != -1) {
+
+ // if this dictioanry has not been loaded yet do that
+ if (!aDicts[k].aPtr) {
+
+ OUString DictFN = aDicts[k].aName + A2OU(".dic");
+ OUString userdictpath;
+ OUString dictpath;
+ osl::FileBase::getSystemPathFromFileURL(
aPathOpt.GetUserDictionaryPath() + A2OU("/"),
userdictpath);
- osl::FileBase::getSystemPathFromFileURL(
- aPathOpt.GetDictionaryPath() + A2OU("/"),
+ osl::FileBase::getSystemPathFromFileURL(
+ aPathOpt.GetLinguisticPath() + A2OU("/ooo/"),
dictpath);
+ OString uTmp(OU2ENC(userdictpath + DictFN,osl_getThreadTextEncoding()));
+ OString sTmp(OU2ENC(dictpath + DictFN,osl_getThreadTextEncoding()));
- if ( ( dict = hnj_hyphen_load ( OU2A(userdictpath + DictFN) ) ) == NULL )
- if ( ( dict = hnj_hyphen_load ( OU2A(dictpath + DictFN) ) ) == NULL )
- {
- fprintf(stderr, "Couldn't find file %s and %s\n", OU2A(userdictpath + DictFN), OU2A(userdictpath + DictFN ));
- return NULL;
+
+ if ( ( dict = hnj_hyphen_load ( uTmp.getStr() ) ) == NULL )
+ if ( ( dict = hnj_hyphen_load ( sTmp.getStr()) ) == NULL )
+ {
+ fprintf(stderr, "Couldn't find file %s and %s\n", OU2ENC(userdictpath + DictFN, osl_getThreadTextEncoding()), OU2ENC(userdictpath + DictFN, osl_getThreadTextEncoding() ));
+ return NULL;
+ }
+ aDicts[k].aPtr = dict;
+ aDicts[k].aEnc = rtl_getTextEncodingFromUnixCharset(dict->cset);
}
- aOpenedDicts.Insert( LocaleToLanguage ( aLocale ), dict );
- }
- rtl_TextEncoding DictionaryEnc = L2TE( LocaleToLanguage( aLocale ) );
+ // other wise hyphenate the word with that dictionary
+ dict = aDicts[k].aPtr;
+ aEnc = aDicts[k].aEnc;
- // chclass.toLower(aWord);
- encWord = OUStringToOString (aWord, DictionaryEnc);
- wordlen = encWord.getLength();
- hyphens = new char[wordlen+5];
+ OString encWord(OU2ENC(aWord, aEnc));
- if (hnj_hyphen_hyphenate(dict, encWord.getStr(), wordlen, hyphens))
- {
- delete hyphens;
- return NULL;
- }
+ wordlen = encWord.getLength();
+ lcword = new char[wordlen+1];
+ hyphens = new char[wordlen+5];
+ enmkallsmall(lcword,encWord.getStr(),dict->cset);
- INT16 nHyphCount = 0;
+ if (hnj_hyphen_hyphenate(dict, lcword, wordlen, hyphens))
+ {
+ delete[] hyphens;
+ delete[] lcword;
+ return NULL;
+ }
- for (INT16 i = 0; i < encWord.getLength(); i++)
- if (hyphens[i]&1)
- nHyphCount++;
+ INT16 nHyphCount = 0;
- Sequence< INT16 > aHyphPos(nHyphCount);
- INT16 *pPos = aHyphPos.getArray();
- OUStringBuffer hyphenatedWordBuffer;
- OUString hyphenatedWord;
- nHyphCount = 0;
+ for (INT16 i = 0; i < encWord.getLength(); i++)
+ if (hyphens[i]&1)
+ nHyphCount++;
- for (i = 0; i < encWord.getLength(); i++)
- {
- hyphenatedWordBuffer.append(aWord[i]);
- if (hyphens[i]&1)
- {
- pPos[nHyphCount] = i;
- hyphenatedWordBuffer.append(sal_Unicode('='));
- nHyphCount++;
- }
- }
+ Sequence< INT16 > aHyphPos(nHyphCount);
+ INT16 *pPos = aHyphPos.getArray();
+ OUStringBuffer hyphenatedWordBuffer;
+ OUString hyphenatedWord;
+ nHyphCount = 0;
- hyphenatedWord = hyphenatedWordBuffer.makeStringAndClear();
+ for (i = 0; i < encWord.getLength(); i++)
+ {
+ hyphenatedWordBuffer.append(aWord[i]);
+ if (hyphens[i]&1)
+ {
+ pPos[nHyphCount] = i;
+ hyphenatedWordBuffer.append(sal_Unicode('='));
+ nHyphCount++;
+ }
+ }
- xRes = new PossibleHyphens( aWord, LocaleToLanguage( aLocale ),
+ hyphenatedWord = hyphenatedWordBuffer.makeStringAndClear();
+
+ xRes = new PossibleHyphens( aWord, LocaleToLanguage( aLocale ),
hyphenatedWord, aHyphPos );
- delete hyphens;
- return xRes;
+ delete[] hyphens;
+ delete[] lcword;
+ return xRes;
+ }
+
+ return NULL;
+
}
diff --git a/lingucomponent/source/hyphenator/altlinuxhyph/hyphen/hyphenimp.hxx b/lingucomponent/source/hyphenator/altlinuxhyph/hyphen/hyphenimp.hxx
index 2edbd43e7f28..3c7d744437fa 100644
--- a/lingucomponent/source/hyphenator/altlinuxhyph/hyphen/hyphenimp.hxx
+++ b/lingucomponent/source/hyphenator/altlinuxhyph/hyphen/hyphenimp.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: hyphenimp.hxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: nidd $ $Date: 2001-12-25 08:24:12 $
+ * last change: $Author: svesik $ $Date: 2002-07-29 17:28:01 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -105,10 +105,19 @@ using namespace ::com::sun::star::linguistic2;
#define OU2ISO_1(rtlOUString) ::rtl::OString((rtlOUString).getStr(), (rtlOUString).getLength(), RTL_TEXTENCODING_ISO_8859_1).getStr()
+#define OU2ENC(rtlOUString, rtlEncoding) ::rtl::OString((rtlOUString).getStr(), (rtlOUString).getLength(), rtlEncoding).getStr()
+
///////////////////////////////////////////////////////////////////////////
-DECLARE_TABLE(HyphDictList, HyphenDict * );
+struct HDInfo {
+ HyphenDict * aPtr;
+ OUString aName;
+ Locale aLoc;
+ rtl_TextEncoding aEnc;
+};
+
+
class Hyphenator :
public cppu::WeakImplHelper6
@@ -122,7 +131,8 @@ class Hyphenator :
>
{
Sequence< Locale > aSuppLocales;
- HyphDictList aOpenedDicts;
+ HDInfo * aDicts;
+ sal_Int32 numdict;
::cppu::OInterfaceContainerHelper aEvtListeners;
Reference< XPropertyChangeListener > xPropHelper;
diff --git a/lingucomponent/source/hyphenator/altlinuxhyph/hyphen/makefile.mk b/lingucomponent/source/hyphenator/altlinuxhyph/hyphen/makefile.mk
index 336cafd0cb3c..39f277c189d3 100644
--- a/lingucomponent/source/hyphenator/altlinuxhyph/hyphen/makefile.mk
+++ b/lingucomponent/source/hyphenator/altlinuxhyph/hyphen/makefile.mk
@@ -2,9 +2,9 @@
#
# $RCSfile: makefile.mk,v $
#
-# $Revision: 1.3 $
+# $Revision: 1.4 $
#
-# last change: $Author: nidd $ $Date: 2002-05-09 17:36:02 $
+# last change: $Author: svesik $ $Date: 2002-07-29 17:28:01 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
@@ -68,11 +68,22 @@ ENABLE_EXCEPTIONS=TRUE
USE_DEFFILE=TRUE
.IF "$(GUI)"=="UNX"
-HNJLIB="-lhnj"
+HNJLIB=-lhnj
.ELSE
-HNJLIB="libhnj.lib"
+HNJLIB=libhnj.lib
.ENDIF
+.IF "$(ULINGULIB)"==""
+.IF "$(GUI)"=="UNX"
+ULINGULIB=-lulingu$(UPD)$(DLLPOSTFIX)
+.ENDIF # unx
+.IF "$(GUI)"=="WNT"
+ULINGULIB=$(LIBPRE) ulingu.lib
+.ENDIF # wnt
+.ENDIF
+
+
+
#----- Settings ---------------------------------------------------------
.INCLUDE : settings.mk
@@ -109,9 +120,9 @@ UNOTYPES=\
com.sun.star.linguistic2.XSupportedLocales\
com.sun.star.linguistic2.XThesaurus
-CXXFLAGS += -I../libhnj
-CFLAGSCXX += -I../libhnj
-CFLAGSCC += -I../libhnj
+CXXFLAGS += -I..$/libhnj -I..$/..$/..$/utility
+CFLAGSCXX += -I..$/libhnj -I..$/..$/..$/utility
+CFLAGSCC += -I..$/libhnj -I..$/..$/..$/utility
.IF "$(header)" == ""
@@ -141,7 +152,9 @@ SHL1STDLIBS= \
$(UCBHELPERLIB) \
$(UNOTOOLSLIB) \
$(LNGLIB) \
- $(HNJLIB)
+ $(HNJLIB) \
+ $(ULINGULIB)
+
# build DLL
SHL1LIBS= $(SLB)$/$(TARGET).lib
diff --git a/lingucomponent/source/spellcheck/spell/makefile.mk b/lingucomponent/source/spellcheck/spell/makefile.mk
index 19bd8f60763a..84d88176ffe1 100644
--- a/lingucomponent/source/spellcheck/spell/makefile.mk
+++ b/lingucomponent/source/spellcheck/spell/makefile.mk
@@ -2,9 +2,9 @@
#
# $RCSfile: makefile.mk,v $
#
-# $Revision: 1.3 $
+# $Revision: 1.4 $
#
-# last change: $Author: khendricks $ $Date: 2001-09-11 12:56:28 $
+# last change: $Author: svesik $ $Date: 2002-07-29 17:28:22 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
@@ -75,6 +75,19 @@ MYSPELLLIB=-lmyspell
MYSPELLLIB=libmyspell.lib
.ENDIF # wnt
.ENDIF
+
+.IF "$(ULINGULIB)"==""
+.IF "$(GUI)"=="UNX"
+ULINGULIB=-lulingu$(UPD)$(DLLPOSTFIX)
+.ENDIF # unx
+.IF "$(GUI)"=="WNT"
+ULINGULIB=$(LIBPRE) ulingu.lib
+.ENDIF # wnt
+.ENDIF
+
+
+
+
#----- Settings ---------------------------------------------------------
.INCLUDE : settings.mk
@@ -112,9 +125,9 @@ UNOTYPES=\
com.sun.star.linguistic2.XThesaurus
-CXXFLAGS += -I../myspell
-CFLAGSCXX += -I../myspell
-CFLAGSCC += -I../myspell
+CXXFLAGS += -I..$/myspell -I..$/..$/utility
+CFLAGSCXX += -I..$/myspell -I..$/..$/utility
+CFLAGSCC += -I..$/myspell -I..$/..$/utility
.IF "$(header)" == ""
@@ -144,7 +157,8 @@ SHL1STDLIBS= \
$(UCBHELPERLIB) \
$(UNOTOOLSLIB) \
$(LNGLIB) \
- $(MYSPELLLIB)
+ $(MYSPELLLIB) \
+ $(ULINGULIB)
# build DLL
diff --git a/lingucomponent/source/spellcheck/spell/sspellimp.cxx b/lingucomponent/source/spellcheck/spell/sspellimp.cxx
index cc3488b47bd7..482f18d2a1a5 100644
--- a/lingucomponent/source/spellcheck/spell/sspellimp.cxx
+++ b/lingucomponent/source/spellcheck/spell/sspellimp.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: sspellimp.cxx,v $
*
- * $Revision: 1.6 $
+ * $Revision: 1.7 $
*
- * last change: $Author: khendricks $ $Date: 2002-01-07 15:46:15 $
+ * last change: $Author: svesik $ $Date: 2002-07-29 17:28:22 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -171,24 +171,45 @@ Sequence< Locale > SAL_CALL SpellChecker::getLocales()
{
MutexGuard aGuard( GetLinguMutex() );
- /* this routine should return the locales supported by the installed */
- /* dictionaries. So here we need to parse the user edited dictionary list */
- /* to see what dictionaries the user has installed */
+ // this routine should return the locales supported by the installed
+ // dictionaries. So here we need to parse both the user edited
+ // dictionary list and the shared dictionary list
+ // to see what dictionaries the admin/user has installed
+ int numusr; // number of user dictionary entries
+ int numshr; // number of shared dictionary entries
+ dictentry * spdict; // shared dict entry pointer
+ dictentry * updict; // user dict entry pointer
+ SvtPathOptions aPathOpt;
if (!numdict) {
- SvtPathOptions aPathOpt;
- OUString diclst = aPathOpt.GetUserDictionaryPath() + A2OU("/dictionary.lst");
- OUString dlst;
- osl::FileBase::getSystemPathFromFileURL(diclst,dlst);
-
- /* invoke the dictionary manager to parse and return the dictionary list */
- OString aTmp(OU2A(dlst));
- DictMgr* dMgr = new DictMgr(aTmp.getStr());
- dictentry * pdict;
- if (dMgr)
- numdict = dMgr->get_list(&pdict);
+ // invoke a dictionary manager to get the user dictionary list
+ OUString usrlst = aPathOpt.GetUserDictionaryPath() + A2OU("/dictionary.lst");
+ OUString ulst;
+ osl::FileBase::getSystemPathFromFileURL(usrlst,ulst);
+ OString uTmp(OU2ENC(ulst, osl_getThreadTextEncoding()));
+ DictMgr* udMgr = new DictMgr(uTmp.getStr(),"DICT");
+ numusr = 0;
+ if (udMgr)
+ numusr = udMgr->get_list(&updict);
+
+
+ // invoke a second dictionary manager to get the shared dictionary list
+ OUString shrlst = aPathOpt.GetLinguisticPath() + A2OU("/ooo/dictionary.lst");
+ OUString slst;
+ osl::FileBase::getSystemPathFromFileURL(shrlst,slst);
+ OString sTmp(OU2ENC(slst, osl_getThreadTextEncoding()));
+ DictMgr* sdMgr = new DictMgr(sTmp.getStr(),"DICT");
+ numshr = 0;
+ if (sdMgr)
+ numshr = sdMgr->get_list(&spdict);
+
+ // we really should merge these and remove duplicates but since
+ // users can name their dictionaries anything they want it would
+ // be impossible to know if a real duplication exists unless we
+ // add some unique key to each myspell dictionary
+ numdict = numshr + numusr;
if (numdict) {
aDicts = new MySpell* [numdict];
@@ -199,26 +220,51 @@ Sequence< Locale > SAL_CALL SpellChecker::getLocales()
Locale * pLocale = aSuppLocales.getArray();
int numlocs = 0;
int newloc;
- for (int i = 0; i < numdict; i++) {
- Locale nLoc( A2OU(pdict->lang), A2OU(pdict->region), OUString() );
+ int i,j;
+ int k = 0;
+
+ //first add the user dictionaries
+ for (i = 0; i < numusr; i++) {
+ Locale nLoc( A2OU(updict->lang), A2OU(updict->region), OUString() );
newloc = 1;
- for (int j = 0; j < numlocs; j++) {
+ for (j = 0; j < numlocs; j++) {
if (nLoc == pLocale[j]) newloc = 0;
}
if (newloc) {
pLocale[numlocs] = nLoc;
numlocs++;
}
- aDLocs[i] = nLoc;
- aDicts[i] = NULL;
- aDEncs[i] = 0;
- aDNames[i] = aPathOpt.GetUserDictionaryPath() + A2OU("/") + A2OU(pdict->filename);
- pdict++;
+ aDLocs[k] = nLoc;
+ aDicts[k] = NULL;
+ aDEncs[k] = 0;
+ aDNames[k] = aPathOpt.GetUserDictionaryPath() + A2OU("/") + A2OU(updict->filename);
+ k++;
+ updict++;
}
+
+ // now add the shared dictionaries
+ for (i = 0; i < numshr; i++) {
+ Locale nLoc( A2OU(spdict->lang), A2OU(spdict->region), OUString() );
+ newloc = 1;
+ for (j = 0; j < numlocs; j++) {
+ if (nLoc == pLocale[j]) newloc = 0;
+ }
+ if (newloc) {
+ pLocale[numlocs] = nLoc;
+ numlocs++;
+ }
+ aDLocs[k] = nLoc;
+ aDicts[k] = NULL;
+ aDEncs[k] = 0;
+ aDNames[k] = aPathOpt.GetLinguisticPath() + A2OU("/ooo/") + A2OU(spdict->filename);
+ k++;
+ spdict++;
+ }
+
aSuppLocales.realloc(numlocs);
} else {
- /* no dictionary.lst so just use default en_US dictionary */
+ /* no dictionary.lst so just use default en_US dictionary at shared location */
numdict = 1;
aDicts = new MySpell*[1];
aDEncs = new rtl_TextEncoding[1];
@@ -230,14 +276,19 @@ Sequence< Locale > SAL_CALL SpellChecker::getLocales()
pLocale[0] = nLoc;
aDLocs[0] = nLoc;
aDicts[0] = NULL;
- aDNames[0] = aPathOpt.GetUserDictionaryPath() + A2OU("/") + A2OU("en_US");
+ aDNames[0] = aPathOpt.GetLinguisticPath() + A2OU("/ooo/") + A2OU("en_US");
}
/* de-allocation of memory is handled inside the DictMgr */
- pdict = NULL;
- if (dMgr) {
- delete dMgr;
- dMgr = NULL;
+ updict = NULL;
+ if (udMgr) {
+ delete udMgr;
+ udMgr = NULL;
+ }
+ spdict = NULL;
+ if (sdMgr) {
+ delete sdMgr;
+ sdMgr = NULL;
}
}
@@ -298,8 +349,8 @@ INT16 SpellChecker::GetSpellFailure( const OUString &rWord, const Locale &rLocal
OUString aff;
osl::FileBase::getSystemPathFromFileURL(dicpath,dict);
osl::FileBase::getSystemPathFromFileURL(affpath,aff);
- OString aTmpaff(OU2A(aff));
- OString aTmpdict(OU2A(dict));
+ OString aTmpaff(OU2ENC(aff,osl_getThreadTextEncoding()));
+ OString aTmpdict(OU2ENC(dict,osl_getThreadTextEncoding()));
aDicts[i] = new MySpell(aTmpaff.getStr(),aTmpdict.getStr());
aDEncs[i] = 0;
if (aDicts[i]) {