|
75 | 75 | #include "mozilla/Services.h" |
76 | 76 | #include <stdlib.h> |
77 | 77 | #include "nsIMemoryReporter.h" |
| 78 | +#include "nsIPrefService.h" |
| 79 | +#include "nsIPrefBranch.h" |
78 | 80 |
|
79 | 81 | static NS_DEFINE_CID(kCharsetConverterManagerCID, NS_ICHARSETCONVERTERMANAGER_CID); |
80 | 82 | static NS_DEFINE_CID(kUnicharUtilCID, NS_UNICHARUTIL_CID); |
@@ -372,11 +374,26 @@ mozHunspell::LoadDictionaryList() |
372 | 374 | if (!dirSvc) |
373 | 375 | return; |
374 | 376 |
|
375 | | - // find built in dictionaries |
| 377 | + // find built in dictionaries, or dictionaries specified in |
| 378 | + // spellchecker.dictionary_path in prefs |
376 | 379 | nsCOMPtr<nsIFile> dictDir; |
377 | | - rv = dirSvc->Get(DICTIONARY_SEARCH_DIRECTORY, |
378 | | - NS_GET_IID(nsIFile), getter_AddRefs(dictDir)); |
379 | | - if (NS_SUCCEEDED(rv)) { |
| 380 | + |
| 381 | + // check preferences first |
| 382 | + nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID)); |
| 383 | + if (prefs) { |
| 384 | + nsCString extDictPath; |
| 385 | + rv = prefs->GetCharPref("spellchecker.dictionary_path", getter_Copies(extDictPath)); |
| 386 | + if (NS_SUCCEEDED(rv)) { |
| 387 | + // set the spellchecker.dictionary_path |
| 388 | + rv = NS_NewNativeLocalFile(extDictPath, true, getter_AddRefs(dictDir)); |
| 389 | + } |
| 390 | + } |
| 391 | + if (!dictDir) { |
| 392 | + // spellcheck.dictionary_path not found, set internal path |
| 393 | + rv = dirSvc->Get(DICTIONARY_SEARCH_DIRECTORY, |
| 394 | + NS_GET_IID(nsIFile), getter_AddRefs(dictDir)); |
| 395 | + } |
| 396 | + if (dictDir) { |
380 | 397 | LoadDictionariesFromDir(dictDir); |
381 | 398 | } |
382 | 399 | else { |
|
0 commit comments