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 nsEditorSpellCheck_h___
7 : #define nsEditorSpellCheck_h___
8 :
9 :
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
17 :
18 : class nsIEditor;
19 : class nsISpellChecker;
20 : class nsITextServicesFilter;
21 :
22 : #define NS_EDITORSPELLCHECK_CID \
23 : { /* {75656ad9-bd13-4c5d-939a-ec6351eea0cc} */ \
24 : 0x75656ad9, 0xbd13, 0x4c5d, \
25 : { 0x93, 0x9a, 0xec, 0x63, 0x51, 0xee, 0xa0, 0xcc }\
26 : }
27 :
28 : class DictionaryFetcher;
29 :
30 : enum dictCompare {
31 : DICT_NORMAL_COMPARE,
32 : DICT_COMPARE_CASE_INSENSITIVE,
33 : DICT_COMPARE_DASHMATCH
34 : };
35 :
36 : class nsEditorSpellCheck final : public nsIEditorSpellCheck
37 : {
38 : friend class DictionaryFetcher;
39 :
40 : public:
41 : nsEditorSpellCheck();
42 :
43 : NS_DECL_CYCLE_COLLECTING_ISUPPORTS
44 0 : NS_DECL_CYCLE_COLLECTION_CLASS(nsEditorSpellCheck)
45 :
46 : /* Declare all methods in the nsIEditorSpellCheck interface */
47 : NS_DECL_NSIEDITORSPELLCHECK
48 :
49 : protected:
50 : virtual ~nsEditorSpellCheck();
51 :
52 : nsCOMPtr<nsISpellChecker> mSpellChecker;
53 :
54 : nsTArray<nsString> mSuggestedWordList;
55 : int32_t mSuggestedWordIndex;
56 :
57 : // these are the words in the current personal dictionary,
58 : // GetPersonalDictionary must be called to load them.
59 : nsTArray<nsString> mDictionaryList;
60 : int32_t mDictionaryIndex;
61 :
62 : nsresult DeleteSuggestedWordList();
63 :
64 : nsCOMPtr<nsITextServicesFilter> mTxtSrvFilter;
65 : nsCOMPtr<nsIEditor> mEditor;
66 :
67 : nsString mPreferredLang;
68 :
69 : uint32_t mDictionaryFetcherGroup;
70 :
71 : bool mUpdateDictionaryRunning;
72 :
73 : void BuildDictionaryList(const nsAString& aDictName,
74 : const nsTArray<nsString>& aDictList,
75 : enum dictCompare aCompareType,
76 : nsTArray<nsString>& aTryList);
77 :
78 : nsresult DictionaryFetched(DictionaryFetcher* aFetchState);
79 :
80 : void SetFallbackDictionary(DictionaryFetcher* aFetcher);
81 :
82 :
83 : public:
84 0 : void BeginUpdateDictionary() { mUpdateDictionaryRunning = true ;}
85 0 : void EndUpdateDictionary() { mUpdateDictionaryRunning = false ;}
86 : };
87 :
88 : #endif // nsEditorSpellCheck_h___
89 :
90 :
|