|
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 #include "nsISupports.idl" |
|
7 |
|
8 interface nsIEditor; |
|
9 interface nsITextServicesFilter; |
|
10 interface nsIEditorSpellCheckCallback; |
|
11 |
|
12 [scriptable, uuid(dd32ef3b-a7d8-43d1-9617-5f2dddbe29eb)] |
|
13 interface nsIEditorSpellCheck : nsISupports |
|
14 { |
|
15 |
|
16 /** |
|
17 * Call this on any change in installed dictionaries to ensure that the spell |
|
18 * checker is not using a current dictionary which is no longer available. |
|
19 * If the current dictionary is no longer available, then pick another one. |
|
20 */ |
|
21 void checkCurrentDictionary(); |
|
22 |
|
23 /** |
|
24 * Returns true if we can enable spellchecking. If there are no available |
|
25 * dictionaries, this will return false. |
|
26 */ |
|
27 boolean canSpellCheck(); |
|
28 |
|
29 /** |
|
30 * Turns on the spell checker for the given editor. enableSelectionChecking |
|
31 * set means that we only want to check the current selection in the editor, |
|
32 * (this controls the behavior of GetNextMisspelledWord). For spellchecking |
|
33 * clients with no modal UI (such as inline spellcheckers), this flag doesn't |
|
34 * matter. Initialization is asynchronous and is not complete until the given |
|
35 * callback is called. |
|
36 */ |
|
37 void InitSpellChecker(in nsIEditor editor, in boolean enableSelectionChecking, |
|
38 [optional] in nsIEditorSpellCheckCallback callback); |
|
39 |
|
40 /** |
|
41 * When interactively spell checking the document, this will return the |
|
42 * value of the next word that is misspelled. This also computes the |
|
43 * suggestions which you can get by calling GetSuggestedWord. |
|
44 * |
|
45 * @see nsISpellChecker::GetNextMisspelledWord |
|
46 */ |
|
47 wstring GetNextMisspelledWord(); |
|
48 |
|
49 /** |
|
50 * Used to get suggestions for the last word that was checked and found to |
|
51 * be misspelled. The first call will give you the first (best) suggestion. |
|
52 * Subsequent calls will iterate through all the suggestions, allowing you |
|
53 * to build a list. When there are no more suggestions, an empty string |
|
54 * (not a null pointer) will be returned. |
|
55 * |
|
56 * @see nsISpellChecker::GetSuggestedWord |
|
57 */ |
|
58 wstring GetSuggestedWord(); |
|
59 |
|
60 /** |
|
61 * Check a given word. In spite of the name, this function checks the word |
|
62 * you give it, returning true if the word is misspelled. If the word is |
|
63 * misspelled, it will compute the suggestions which you can get from |
|
64 * GetSuggestedWord(). |
|
65 * |
|
66 * @see nsISpellChecker::CheckCurrentWord |
|
67 */ |
|
68 boolean CheckCurrentWord(in wstring suggestedWord); |
|
69 |
|
70 /** |
|
71 * Use when modally checking the document to replace a word. |
|
72 * |
|
73 * @see nsISpellChecker::CheckCurrentWord |
|
74 */ |
|
75 void ReplaceWord(in wstring misspelledWord, in wstring replaceWord, in boolean allOccurrences); |
|
76 |
|
77 /** |
|
78 * @see nsISpellChecker::IgnoreAll |
|
79 */ |
|
80 void IgnoreWordAllOccurrences(in wstring word); |
|
81 |
|
82 /** |
|
83 * Fills an internal list of words added to the personal dictionary. These |
|
84 * words can be retrieved using GetPersonalDictionaryWord() |
|
85 * |
|
86 * @see nsISpellChecker::GetPersonalDictionary |
|
87 * @see GetPersonalDictionaryWord |
|
88 */ |
|
89 void GetPersonalDictionary(); |
|
90 |
|
91 /** |
|
92 * Used after you call GetPersonalDictionary() to iterate through all the |
|
93 * words added to the personal dictionary. Will return the empty string when |
|
94 * there are no more words. |
|
95 */ |
|
96 wstring GetPersonalDictionaryWord(); |
|
97 |
|
98 /** |
|
99 * Adds a word to the current personal dictionary. |
|
100 * |
|
101 * @see nsISpellChecker::AddWordToDictionary |
|
102 */ |
|
103 void AddWordToDictionary(in wstring word); |
|
104 |
|
105 /** |
|
106 * Removes a word from the current personal dictionary. |
|
107 * |
|
108 * @see nsISpellChecker::RemoveWordFromPersonalDictionary |
|
109 */ |
|
110 void RemoveWordFromDictionary(in wstring word); |
|
111 |
|
112 /** |
|
113 * Retrieves a list of the currently available dictionaries. The strings will |
|
114 * typically be language IDs, like "en-US". |
|
115 * |
|
116 * @see mozISpellCheckingEngine::GetDictionaryList |
|
117 */ |
|
118 void GetDictionaryList([array, size_is(count)] out wstring dictionaryList, out uint32_t count); |
|
119 |
|
120 /** |
|
121 * @see nsISpellChecker::GetCurrentDictionary |
|
122 */ |
|
123 AString GetCurrentDictionary(); |
|
124 |
|
125 /** |
|
126 * @see nsISpellChecker::SetCurrentDictionary |
|
127 */ |
|
128 void SetCurrentDictionary(in AString dictionary); |
|
129 |
|
130 /** |
|
131 * Call this to free up the spell checking object. It will also save the |
|
132 * current selected language as the default for future use. |
|
133 * |
|
134 * If you have called CanSpellCheck but not InitSpellChecker, you can still |
|
135 * call this function to clear the cached spell check object, and no |
|
136 * preference saving will happen. |
|
137 */ |
|
138 void UninitSpellChecker(); |
|
139 |
|
140 /** |
|
141 * Used to filter the content (for example, to skip blockquotes in email from |
|
142 * spellchecking. Call this before calling InitSpellChecker; calling it |
|
143 * after initialization will have no effect. |
|
144 * |
|
145 * @see nsITextServicesDocument::setFilter |
|
146 */ |
|
147 void setFilter(in nsITextServicesFilter filter); |
|
148 |
|
149 /** |
|
150 * Like CheckCurrentWord, checks the word you give it, returning true if it's |
|
151 * misspelled. This is faster than CheckCurrentWord because it does not |
|
152 * compute any suggestions. |
|
153 * |
|
154 * Watch out: this does not clear any suggestions left over from previous |
|
155 * calls to CheckCurrentWord, so there may be suggestions, but they will be |
|
156 * invalid. |
|
157 */ |
|
158 boolean CheckCurrentWordNoSuggest(in wstring suggestedWord); |
|
159 |
|
160 /** |
|
161 * Update the dictionary in use to be sure it corresponds to what the editor |
|
162 * needs. The update is asynchronous and is not complete until the given |
|
163 * callback is called. |
|
164 */ |
|
165 void UpdateCurrentDictionary([optional] in nsIEditorSpellCheckCallback callback); |
|
166 |
|
167 }; |
|
168 |
|
169 [scriptable, function, uuid(5f0a4bab-8538-4074-89d3-2f0e866a1c0b)] |
|
170 interface nsIEditorSpellCheckCallback : nsISupports |
|
171 { |
|
172 void editorSpellCheckDone(); |
|
173 }; |