Line data Source code
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 : #include "RemoteSpellCheckEngineChild.h"
21 :
22 : namespace mozilla {
23 : class RemoteSpellcheckEngineChild;
24 : } // namespace mozilla
25 :
26 : class mozSpellChecker : public nsISpellChecker
27 : {
28 : public:
29 : NS_DECL_CYCLE_COLLECTING_ISUPPORTS
30 10 : NS_DECL_CYCLE_COLLECTION_CLASS(mozSpellChecker)
31 :
32 : mozSpellChecker();
33 :
34 : nsresult Init();
35 :
36 : // nsISpellChecker
37 : NS_IMETHOD SetDocument(nsITextServicesDocument *aDoc, bool aFromStartofDoc) override;
38 : NS_IMETHOD NextMisspelledWord(nsAString &aWord, nsTArray<nsString> *aSuggestions) override;
39 : NS_IMETHOD CheckWord(const nsAString &aWord, bool *aIsMisspelled, nsTArray<nsString> *aSuggestions) override;
40 : NS_IMETHOD Replace(const nsAString &aOldWord, const nsAString &aNewWord, bool aAllOccurrences) override;
41 : NS_IMETHOD IgnoreAll(const nsAString &aWord) override;
42 :
43 : NS_IMETHOD AddWordToPersonalDictionary(const nsAString &aWord) override;
44 : NS_IMETHOD RemoveWordFromPersonalDictionary(const nsAString &aWord) override;
45 : NS_IMETHOD GetPersonalDictionary(nsTArray<nsString> *aWordList) override;
46 :
47 : NS_IMETHOD GetDictionaryList(nsTArray<nsString> *aDictionaryList) override;
48 : NS_IMETHOD GetCurrentDictionary(nsAString &aDictionary) override;
49 : NS_IMETHOD SetCurrentDictionary(const nsAString &aDictionary) override;
50 : NS_IMETHOD_(RefPtr<mozilla::GenericPromise>)
51 : SetCurrentDictionaryFromList(const nsTArray<nsString>& aList) override;
52 :
53 0 : void DeleteRemoteEngine() {
54 0 : mEngine = nullptr;
55 0 : }
56 :
57 : protected:
58 : virtual ~mozSpellChecker();
59 :
60 : nsCOMPtr<mozISpellI18NUtil> mConverter;
61 : nsCOMPtr<nsITextServicesDocument> mTsDoc;
62 : nsCOMPtr<mozIPersonalDictionary> mPersonalDictionary;
63 :
64 : nsCOMPtr<mozISpellCheckingEngine> mSpellCheckingEngine;
65 : bool mFromStart;
66 :
67 : nsString mCurrentDictionary;
68 :
69 : nsresult SetupDoc(int32_t *outBlockOffset);
70 :
71 : nsresult GetCurrentBlockIndex(nsITextServicesDocument *aDoc, int32_t *outBlockIndex);
72 :
73 : nsresult GetEngineList(nsCOMArray<mozISpellCheckingEngine> *aDictionaryList);
74 :
75 : mozilla::RemoteSpellcheckEngineChild *mEngine;
76 :
77 : friend class mozilla::RemoteSpellcheckEngineChild;
78 : };
79 : #endif // mozSpellChecker_h__
|