|
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/. */ |
|
5 |
|
6 #ifndef mozSpellChecker_h__ |
|
7 #define mozSpellChecker_h__ |
|
8 |
|
9 #include "nsCOMPtr.h" |
|
10 #include "nsCOMArray.h" |
|
11 #include "nsISpellChecker.h" |
|
12 #include "nsString.h" |
|
13 #include "nsITextServicesDocument.h" |
|
14 #include "mozIPersonalDictionary.h" |
|
15 #include "mozISpellCheckingEngine.h" |
|
16 #include "nsClassHashtable.h" |
|
17 #include "nsTArray.h" |
|
18 #include "mozISpellI18NUtil.h" |
|
19 #include "nsCycleCollectionParticipant.h" |
|
20 |
|
21 class mozSpellChecker : public nsISpellChecker |
|
22 { |
|
23 public: |
|
24 NS_DECL_CYCLE_COLLECTING_ISUPPORTS |
|
25 NS_DECL_CYCLE_COLLECTION_CLASS(mozSpellChecker) |
|
26 |
|
27 mozSpellChecker(); |
|
28 virtual ~mozSpellChecker(); |
|
29 |
|
30 nsresult Init(); |
|
31 |
|
32 // nsISpellChecker |
|
33 NS_IMETHOD SetDocument(nsITextServicesDocument *aDoc, bool aFromStartofDoc); |
|
34 NS_IMETHOD NextMisspelledWord(nsAString &aWord, nsTArray<nsString> *aSuggestions); |
|
35 NS_IMETHOD CheckWord(const nsAString &aWord, bool *aIsMisspelled, nsTArray<nsString> *aSuggestions); |
|
36 NS_IMETHOD Replace(const nsAString &aOldWord, const nsAString &aNewWord, bool aAllOccurrences); |
|
37 NS_IMETHOD IgnoreAll(const nsAString &aWord); |
|
38 |
|
39 NS_IMETHOD AddWordToPersonalDictionary(const nsAString &aWord); |
|
40 NS_IMETHOD RemoveWordFromPersonalDictionary(const nsAString &aWord); |
|
41 NS_IMETHOD GetPersonalDictionary(nsTArray<nsString> *aWordList); |
|
42 |
|
43 NS_IMETHOD GetDictionaryList(nsTArray<nsString> *aDictionaryList); |
|
44 NS_IMETHOD GetCurrentDictionary(nsAString &aDictionary); |
|
45 NS_IMETHOD SetCurrentDictionary(const nsAString &aDictionary); |
|
46 NS_IMETHOD CheckCurrentDictionary(); |
|
47 |
|
48 protected: |
|
49 nsCOMPtr<mozISpellI18NUtil> mConverter; |
|
50 nsCOMPtr<nsITextServicesDocument> mTsDoc; |
|
51 nsCOMPtr<mozIPersonalDictionary> mPersonalDictionary; |
|
52 |
|
53 nsCOMPtr<mozISpellCheckingEngine> mSpellCheckingEngine; |
|
54 bool mFromStart; |
|
55 |
|
56 nsresult SetupDoc(int32_t *outBlockOffset); |
|
57 |
|
58 nsresult GetCurrentBlockIndex(nsITextServicesDocument *aDoc, int32_t *outBlockIndex); |
|
59 |
|
60 nsresult GetEngineList(nsCOMArray<mozISpellCheckingEngine> *aDictionaryList); |
|
61 }; |
|
62 #endif // mozSpellChecker_h__ |