Source code

Revision control

Other Tools

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