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/. */
6 #ifndef nsISpellChecker_h__
7 #define nsISpellChecker_h__
9 #include "nsISupports.h"
12 #define NS_SPELLCHECKER_CONTRACTID "@mozilla.org/spellchecker;1"
14 #define NS_ISPELLCHECKER_IID \
15 { /* 27bff957-b486-40ae-9f5d-af0cdd211868 */ \
16 0x27bff957, 0xb486, 0x40ae, \
17 { 0x9f, 0x5d, 0xaf, 0x0c, 0xdd, 0x21, 0x18, 0x68 } }
19 class nsITextServicesDocument
;
23 * A generic interface for a spelling checker.
25 class nsISpellChecker
: public nsISupports
{
28 NS_DECLARE_STATIC_IID_ACCESSOR(NS_ISPELLCHECKER_IID
)
31 * Tells the spellchecker what document to check.
32 * @param aDoc is the document to check.
33 * @param aFromStartOfDoc If true, start check from beginning of document,
34 * if false, start check from current cursor position.
36 NS_IMETHOD
SetDocument(nsITextServicesDocument
*aDoc
, bool aFromStartofDoc
) = 0;
39 * Selects (hilites) the next misspelled word in the document.
40 * @param aWord will contain the misspelled word.
41 * @param aSuggestions is an array of nsStrings, that represent the
42 * suggested replacements for the misspelled word.
44 NS_IMETHOD
NextMisspelledWord(nsAString
&aWord
, nsTArray
<nsString
> *aSuggestions
) = 0;
47 * Checks if a word is misspelled. No document is required to use this method.
48 * @param aWord is the word to check.
49 * @param aIsMisspelled will be set to true if the word is misspelled.
50 * @param aSuggestions is an array of nsStrings which represent the
51 * suggested replacements for the misspelled word. The array will be empty
52 * if there aren't any suggestions.
54 NS_IMETHOD
CheckWord(const nsAString
&aWord
, bool *aIsMisspelled
, nsTArray
<nsString
> *aSuggestions
) = 0;
57 * Replaces the old word with the specified new word.
58 * @param aOldWord is the word to be replaced.
59 * @param aNewWord is the word that is to replace old word.
60 * @param aAllOccurrences will replace all occurrences of old
61 * word, in the document, with new word when it is true. If
62 * false, it will replace the 1st occurrence only!
64 NS_IMETHOD
Replace(const nsAString
&aOldWord
, const nsAString
&aNewWord
, bool aAllOccurrences
) = 0;
67 * Ignores all occurrences of the specified word in the document.
68 * @param aWord is the word to ignore.
70 NS_IMETHOD
IgnoreAll(const nsAString
&aWord
) = 0;
73 * Add a word to the user's personal dictionary.
74 * @param aWord is the word to add.
76 NS_IMETHOD
AddWordToPersonalDictionary(const nsAString
&aWord
) = 0;
79 * Remove a word from the user's personal dictionary.
80 * @param aWord is the word to remove.
82 NS_IMETHOD
RemoveWordFromPersonalDictionary(const nsAString
&aWord
) = 0;
85 * Returns the list of words in the user's personal dictionary.
86 * @param aWordList is an array of nsStrings that represent the
87 * list of words in the user's personal dictionary.
89 NS_IMETHOD
GetPersonalDictionary(nsTArray
<nsString
> *aWordList
) = 0;
92 * Returns the list of strings representing the dictionaries
93 * the spellchecker supports. It was suggested that the strings
94 * returned be in the RFC 1766 format. This format looks something
95 * like <ISO 639 language code>-<ISO 3166 country code>.
97 * @param aDictionaryList is an array of nsStrings that represent the
98 * dictionaries supported by the spellchecker.
100 NS_IMETHOD
GetDictionaryList(nsTArray
<nsString
> *aDictionaryList
) = 0;
103 * Returns a string representing the current dictionary.
104 * @param aDictionary will contain the name of the dictionary.
105 * This name is the same string that is in the list returned
106 * by GetDictionaryList().
108 NS_IMETHOD
GetCurrentDictionary(nsAString
&aDictionary
) = 0;
111 * Tells the spellchecker to use a specific dictionary.
112 * @param aDictionary a string that is in the list returned
113 * by GetDictionaryList() or an empty string. If aDictionary is
114 * empty string, spellchecker will be disabled.
116 NS_IMETHOD
SetCurrentDictionary(const nsAString
&aDictionary
) = 0;
119 * Call this on any change in installed dictionaries to ensure that the spell
120 * checker is not using a current dictionary which is no longer available.
122 NS_IMETHOD
CheckCurrentDictionary() = 0;
125 NS_DEFINE_STATIC_IID_ACCESSOR(nsISpellChecker
, NS_ISPELLCHECKER_IID
)
127 #endif // nsISpellChecker_h__