summaryrefslogtreecommitdiff
path: root/lingucomponent/source/lingutil
diff options
context:
space:
mode:
authorRĂ¼diger Timm <rt@openoffice.org>2008-06-13 13:02:52 +0000
committerRĂ¼diger Timm <rt@openoffice.org>2008-06-13 13:02:52 +0000
commit4d320c0988552ded4827e6ee2fc0781f34bb5bf0 (patch)
tree2e8042050d6550b592574c2ff3bab316c199841a /lingucomponent/source/lingutil
parent2b09ca34ddba956a4a2abe997266bbfc8f32dd3f (diff)
INTEGRATION: CWS hunspellexternal (1.3.4); FILE MERGED
2008/04/23 19:04:43 rene 1.3.4.2: #i87882# system dictionary paths 2008/04/22 13:39:40 cmc 1.3.4.1: #i87881# remove unused set and fix migration
Diffstat (limited to 'lingucomponent/source/lingutil')
-rw-r--r--lingucomponent/source/lingutil/lingutil.cxx78
1 files changed, 70 insertions, 8 deletions
diff --git a/lingucomponent/source/lingutil/lingutil.cxx b/lingucomponent/source/lingutil/lingutil.cxx
index 6aae8edf6280..826e9bde2c80 100644
--- a/lingucomponent/source/lingutil/lingutil.cxx
+++ b/lingucomponent/source/lingutil/lingutil.cxx
@@ -7,7 +7,7 @@
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: lingutil.cxx,v $
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
* This file is part of OpenOffice.org.
*
@@ -45,9 +45,7 @@
#include <osl/thread.h>
-#ifndef _OSL_FILE_H_
#include <osl/file.hxx>
-#endif
#include <tools/debug.hxx>
#include <tools/urlobj.hxx>
#include <i18npool/mslangid.hxx>
@@ -123,6 +121,11 @@ std::vector< SvtLinguConfigDictionaryEntry > GetOldStyleDics( const char *pDicTy
rtl::OUString aFormatName;
String aDicExtension;
+#ifdef SYSTEM_DICTS
+ rtl::OUString aSystemDir;
+ rtl::OUString aSystemPrefix;
+ rtl::OUString aSystemSuffix;
+#endif
bool bSpell = false;
bool bHyph = false;
bool bThes = false;
@@ -130,18 +133,32 @@ std::vector< SvtLinguConfigDictionaryEntry > GetOldStyleDics( const char *pDicTy
{
aFormatName = A2OU("DICT_SPELL");
aDicExtension = String::CreateFromAscii( ".dic" );
+#ifdef SYSTEM_DICTS
+ aSystemDir = A2OU( DICT_SYSTEM_DIR );
+ aSystemSuffix = aDicExtension;
+#endif
bSpell = true;
}
else if (strcmp( pDicType, "HYPH" ) == 0)
{
aFormatName = A2OU("DICT_HYPH");
aDicExtension = String::CreateFromAscii( ".dic" );
+#ifdef SYSTEM_DICTS
+ aSystemDir = A2OU( HYPH_SYSTEM_DIR );
+ aSystemPrefix = A2OU( "hyph_" );
+ aSystemSuffix = aDicExtension;
+#endif
bHyph = true;
}
else if (strcmp( pDicType, "THES" ) == 0)
{
aFormatName = A2OU("DICT_THES");
aDicExtension = String::CreateFromAscii( ".dat" );
+#ifdef SYSTEM_DICTS
+ aSystemDir = A2OU( THES_SYSTEM_DIR );
+ aSystemPrefix = A2OU( "th_" );
+ aSystemSuffix = A2OU( "_v2.dat" );
+#endif
bThes = true;
}
@@ -150,7 +167,10 @@ std::vector< SvtLinguConfigDictionaryEntry > GetOldStyleDics( const char *pDicTy
return aRes;
dictentry * pDict = NULL; // shared dict entry pointer
- std::set< dictentry *, lt_dictentry > aAvailableDics;
+
+ // set of languages to remember the language where it is already
+ // decided to make use of the dictionary.
+ std::set< LanguageType > aDicLangInUse;
const sal_Int16 USER_LAYER = 0;
for (int k = 0; k < 2; ++k)
@@ -171,10 +191,6 @@ std::vector< SvtLinguConfigDictionaryEntry > GetOldStyleDics( const char *pDicTy
DictMgr aDictMgr( aSysPathToFile.getStr(), pDicType );
int nDicts = aDictMgr.get_list( &pDict );
- // set of languages to remember the language where it is already
- // decided to make use of the dictionary.
- std::set< LanguageType > aDicLangInUse;
-
// Test for existence of the actual dictionary files
// and remember the ones we like to use...
for (int i = 0; i < nDicts; ++i)
@@ -225,6 +241,52 @@ std::vector< SvtLinguConfigDictionaryEntry > GetOldStyleDics( const char *pDicTy
}
}
+#ifdef SYSTEM_DICTS
+ osl::Directory aSystemDicts(aSystemDir);
+ if (aSystemDicts.open() == osl::FileBase::E_None)
+ {
+ osl::DirectoryItem aItem;
+ osl::FileStatus aFileStatus(FileStatusMask_FileURL);
+ while (aSystemDicts.getNextItem(aItem) == osl::FileBase::E_None)
+ {
+ aItem.getFileStatus(aFileStatus);
+ rtl::OUString sPath = aFileStatus.getFileURL();
+ if (sPath.lastIndexOf(aSystemSuffix) == sPath.getLength()-aSystemSuffix.getLength())
+ {
+ sal_Int32 nStartIndex = sPath.lastIndexOf(sal_Unicode('/')) + 1;
+ if (!sPath.match(aSystemPrefix, nStartIndex))
+ continue;
+ sal_Int32 nIndex = nStartIndex + aSystemPrefix.getLength();
+ rtl::OUString sLang = sPath.getToken( 0, '_', nIndex );
+ rtl::OUString sRegion = sPath.copy( nIndex, sPath.getLength() - nIndex - aSystemSuffix.getLength());
+ if (!sLang.getLength() || !sRegion.getLength())
+ continue;
+
+ // Thus we first get the language of the dictionary
+ LanguageType nLang = MsLangId::convertIsoNamesToLanguage(
+ sLang, sRegion );
+
+ if (aDicLangInUse.count( nLang ) == 0)
+ {
+ // remember the new language in use
+ aDicLangInUse.insert( nLang );
+
+ // add the dictionary to the resulting vector
+ SvtLinguConfigDictionaryEntry aDicEntry;
+ aDicEntry.aLocations.realloc(1);
+ aDicEntry.aLocaleNames.realloc(1);
+ rtl::OUString aLocaleName( MsLangId::convertLanguageToIsoString( nLang ) );
+ aDicEntry.aLocations[0] = sPath;
+ aDicEntry.aFormatName = aFormatName;
+ aDicEntry.aLocaleNames[0] = aLocaleName;
+ aRes.push_back( aDicEntry );
+ }
+ }
+ }
+ }
+
+#endif
+
return aRes;
}