Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit c6fc8fa

Browse files
committed
Bug 429023 - Use preference 'spellchecker.dictionary_path' to override loading internal dictionaries; r=ehsan,glandium
1 parent 4b1e050 commit c6fc8fa

1 file changed

Lines changed: 21 additions & 4 deletions

File tree

extensions/spellcheck/hunspell/src/mozHunspell.cpp

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@
7575
#include "mozilla/Services.h"
7676
#include <stdlib.h>
7777
#include "nsIMemoryReporter.h"
78+
#include "nsIPrefService.h"
79+
#include "nsIPrefBranch.h"
7880

7981
static NS_DEFINE_CID(kCharsetConverterManagerCID, NS_ICHARSETCONVERTERMANAGER_CID);
8082
static NS_DEFINE_CID(kUnicharUtilCID, NS_UNICHARUTIL_CID);
@@ -372,11 +374,26 @@ mozHunspell::LoadDictionaryList()
372374
if (!dirSvc)
373375
return;
374376

375-
// find built in dictionaries
377+
// find built in dictionaries, or dictionaries specified in
378+
// spellchecker.dictionary_path in prefs
376379
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) {
380397
LoadDictionariesFromDir(dictDir);
381398
}
382399
else {

0 commit comments

Comments
 (0)