/work/obj-fuzz/dist/include/mozilla/mozSpellChecker.h
Line | Count | Source (jump to first uncovered line) |
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 "mozIPersonalDictionary.h" |
14 | | #include "mozISpellCheckingEngine.h" |
15 | | #include "nsClassHashtable.h" |
16 | | #include "nsTArray.h" |
17 | | #include "nsCycleCollectionParticipant.h" |
18 | | |
19 | | class mozEnglishWordUtils; |
20 | | |
21 | | namespace mozilla { |
22 | | class RemoteSpellcheckEngineChild; |
23 | | } // namespace mozilla |
24 | | |
25 | | class mozSpellChecker final : public nsISpellChecker |
26 | | { |
27 | | public: |
28 | | NS_DECL_CYCLE_COLLECTING_ISUPPORTS |
29 | | NS_DECL_CYCLE_COLLECTION_CLASS(mozSpellChecker) |
30 | | |
31 | | static already_AddRefed<mozSpellChecker> |
32 | | Create() |
33 | 0 | { |
34 | 0 | RefPtr<mozSpellChecker> spellChecker = new mozSpellChecker(); |
35 | 0 | nsresult rv = spellChecker->Init(); |
36 | 0 | NS_ENSURE_SUCCESS(rv, nullptr); |
37 | 0 | return spellChecker.forget(); |
38 | 0 | } |
39 | | |
40 | | // nsISpellChecker |
41 | | NS_IMETHOD SetDocument(mozilla::TextServicesDocument* aTextServicesDocument, |
42 | | bool aFromStartofDoc) override; |
43 | | NS_IMETHOD NextMisspelledWord(nsAString &aWord, nsTArray<nsString> *aSuggestions) override; |
44 | | NS_IMETHOD CheckWord(const nsAString &aWord, bool *aIsMisspelled, nsTArray<nsString> *aSuggestions) override; |
45 | | NS_IMETHOD Replace(const nsAString &aOldWord, const nsAString &aNewWord, bool aAllOccurrences) override; |
46 | | NS_IMETHOD IgnoreAll(const nsAString &aWord) override; |
47 | | |
48 | | NS_IMETHOD AddWordToPersonalDictionary(const nsAString &aWord) override; |
49 | | NS_IMETHOD RemoveWordFromPersonalDictionary(const nsAString &aWord) override; |
50 | | NS_IMETHOD GetPersonalDictionary(nsTArray<nsString> *aWordList) override; |
51 | | |
52 | | NS_IMETHOD GetDictionaryList(nsTArray<nsString> *aDictionaryList) override; |
53 | | NS_IMETHOD GetCurrentDictionary(nsAString &aDictionary) override; |
54 | | NS_IMETHOD SetCurrentDictionary(const nsAString &aDictionary) override; |
55 | | NS_IMETHOD_(RefPtr<mozilla::GenericPromise>) |
56 | | SetCurrentDictionaryFromList(const nsTArray<nsString>& aList) override; |
57 | | |
58 | 0 | void DeleteRemoteEngine() { |
59 | 0 | mEngine = nullptr; |
60 | 0 | } |
61 | | |
62 | | mozilla::TextServicesDocument* GetTextServicesDocument(); |
63 | | |
64 | | protected: |
65 | | mozSpellChecker(); |
66 | | virtual ~mozSpellChecker(); |
67 | | |
68 | | nsresult Init(); |
69 | | |
70 | | RefPtr<mozEnglishWordUtils> mConverter; |
71 | | RefPtr<mozilla::TextServicesDocument> mTextServicesDocument; |
72 | | nsCOMPtr<mozIPersonalDictionary> mPersonalDictionary; |
73 | | |
74 | | nsCOMPtr<mozISpellCheckingEngine> mSpellCheckingEngine; |
75 | | bool mFromStart; |
76 | | |
77 | | nsString mCurrentDictionary; |
78 | | |
79 | | nsresult SetupDoc(int32_t *outBlockOffset); |
80 | | |
81 | | nsresult GetCurrentBlockIndex( |
82 | | mozilla::TextServicesDocument* aTextServicesDocument, |
83 | | int32_t* aOutBlockIndex); |
84 | | |
85 | | nsresult GetEngineList(nsCOMArray<mozISpellCheckingEngine> *aDictionaryList); |
86 | | |
87 | | mozilla::RemoteSpellcheckEngineChild *mEngine; |
88 | | |
89 | | friend class mozilla::RemoteSpellcheckEngineChild; |
90 | | }; |
91 | | #endif // mozSpellChecker_h__ |