1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef mozilla_EditorSpellCheck_h
7 #define mozilla_EditorSpellCheck_h
9 #include "mozilla/mozSpellChecker.h" // for mozilla::CheckWordPromise
10 #include "nsCOMPtr.h" // for nsCOMPtr
11 #include "nsCycleCollectionParticipant.h"
12 #include "nsIEditorSpellCheck.h" // for NS_DECL_NSIEDITORSPELLCHECK, etc
13 #include "nsISupportsImpl.h"
14 #include "nsString.h" // for nsString
15 #include "nsTArray.h" // for nsTArray
16 #include "nscore.h" // for nsresult
18 class mozSpellChecker
;
23 class DictionaryFetcher
;
28 DICT_COMPARE_CASE_INSENSITIVE
,
29 DICT_COMPARE_DASHMATCH
32 class EditorSpellCheck final
: public nsIEditorSpellCheck
{
33 friend class DictionaryFetcher
;
38 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
39 NS_DECL_CYCLE_COLLECTION_CLASS(EditorSpellCheck
)
41 /* Declare all methods in the nsIEditorSpellCheck interface */
42 NS_DECL_NSIEDITORSPELLCHECK
44 mozSpellChecker
* GetSpellChecker();
47 * Like CheckCurrentWord, checks the word you give it, returning true via
48 * promise if it's misspelled.
49 * This is faster than CheckCurrentWord because it does not compute
52 * Watch out: this does not clear any suggestions left over from previous
53 * calls to CheckCurrentWord, so there may be suggestions, but they will be
56 RefPtr
<mozilla::CheckWordPromise
> CheckCurrentWordsNoSuggest(
57 const nsTArray
<nsString
>& aSuggestedWords
);
60 virtual ~EditorSpellCheck();
62 RefPtr
<mozSpellChecker
> mSpellChecker
;
63 RefPtr
<EditorBase
> mEditor
;
65 nsTArray
<nsString
> mSuggestedWordList
;
67 // these are the words in the current personal dictionary,
68 // GetPersonalDictionary must be called to load them.
69 nsTArray
<nsString
> mDictionaryList
;
71 nsTArray
<nsCString
> mPreferredLangs
;
73 uint32_t mTxtSrvFilterType
;
74 int32_t mSuggestedWordIndex
;
75 int32_t mDictionaryIndex
;
76 uint32_t mDictionaryFetcherGroup
;
78 bool mUpdateDictionaryRunning
;
80 nsresult
DeleteSuggestedWordList();
82 bool BuildDictionaryList(const nsACString
& aDictName
,
83 const nsTArray
<nsCString
>& aDictList
,
84 enum dictCompare aCompareType
,
85 nsTArray
<nsCString
>& aOutList
);
87 nsresult
DictionaryFetched(DictionaryFetcher
* aFetchState
);
89 void SetDictionarySucceeded(DictionaryFetcher
* aFetcher
);
90 void SetFallbackDictionary(DictionaryFetcher
* aFetcher
);
93 void BeginUpdateDictionary() { mUpdateDictionaryRunning
= true; }
94 void EndUpdateDictionary() { mUpdateDictionaryRunning
= false; }
97 } // namespace mozilla
99 #endif // mozilla_EditorSpellCheck_h