1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* ***** BEGIN LICENSE BLOCK *****
3 : * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 : *
5 : * The contents of this file are subject to the Mozilla Public License Version
6 : * 1.1 (the "License"); you may not use this file except in compliance with
7 : * the License. You may obtain a copy of the License at
8 : * http://www.mozilla.org/MPL/
9 : *
10 : * Software distributed under the License is distributed on an "AS IS" basis,
11 : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 : * for the specific language governing rights and limitations under the
13 : * License.
14 : *
15 : * The Original Code is mozilla.org code.
16 : *
17 : * The Initial Developer of the Original Code is
18 : * Netscape Communications Corporation.
19 : * Portions created by the Initial Developer are Copyright (C) 1998
20 : * the Initial Developer. All Rights Reserved.
21 : *
22 : * Contributor(s):
23 : *
24 : * Alternatively, the contents of this file may be used under the terms of
25 : * either of the GNU General Public License Version 2 or later (the "GPL"),
26 : * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 : * in which case the provisions of the GPL or the LGPL are applicable instead
28 : * of those above. If you wish to allow use of your version of this file only
29 : * under the terms of either the GPL or the LGPL, and not to allow others to
30 : * use your version of this file under the terms of the MPL, indicate your
31 : * decision by deleting the provisions above and replace them with the notice
32 : * and other provisions required by the GPL or the LGPL. If you do not delete
33 : * the provisions above, a recipient may use your version of this file under
34 : * the terms of any one of the MPL, the GPL or the LGPL.
35 : *
36 : * ***** END LICENSE BLOCK ***** */
37 :
38 : #ifndef nsISpellChecker_h__
39 : #define nsISpellChecker_h__
40 :
41 : #include "nsISupports.h"
42 : #include "nsTArray.h"
43 :
44 : #define NS_SPELLCHECKER_CONTRACTID "@mozilla.org/spellchecker;1"
45 :
46 : #define NS_ISPELLCHECKER_IID \
47 : { /* 27bff957-b486-40ae-9f5d-af0cdd211868 */ \
48 : 0x27bff957, 0xb486, 0x40ae, \
49 : { 0x9f, 0x5d, 0xaf, 0x0c, 0xdd, 0x21, 0x18, 0x68 } }
50 :
51 : class nsITextServicesDocument;
52 : class nsString;
53 :
54 : /**
55 : * A generic interface for a spelling checker.
56 : */
57 0 : class nsISpellChecker : public nsISupports{
58 : public:
59 :
60 : NS_DECLARE_STATIC_IID_ACCESSOR(NS_ISPELLCHECKER_IID)
61 :
62 : /**
63 : * Tells the spellchecker what document to check.
64 : * @param aDoc is the document to check.
65 : * @param aFromStartOfDoc If true, start check from beginning of document,
66 : * if false, start check from current cursor position.
67 : */
68 : NS_IMETHOD SetDocument(nsITextServicesDocument *aDoc, bool aFromStartofDoc) = 0;
69 :
70 : /**
71 : * Selects (hilites) the next misspelled word in the document.
72 : * @param aWord will contain the misspelled word.
73 : * @param aSuggestions is an array of nsStrings, that represent the
74 : * suggested replacements for the misspelled word.
75 : */
76 : NS_IMETHOD NextMisspelledWord(nsAString &aWord, nsTArray<nsString> *aSuggestions) = 0;
77 :
78 : /**
79 : * Checks if a word is misspelled. No document is required to use this method.
80 : * @param aWord is the word to check.
81 : * @param aIsMisspelled will be set to true if the word is misspelled.
82 : * @param aSuggestions is an array of nsStrings which represent the
83 : * suggested replacements for the misspelled word. The array will be empty
84 : * if there aren't any suggestions.
85 : */
86 : NS_IMETHOD CheckWord(const nsAString &aWord, bool *aIsMisspelled, nsTArray<nsString> *aSuggestions) = 0;
87 :
88 : /**
89 : * Replaces the old word with the specified new word.
90 : * @param aOldWord is the word to be replaced.
91 : * @param aNewWord is the word that is to replace old word.
92 : * @param aAllOccurrences will replace all occurrences of old
93 : * word, in the document, with new word when it is true. If
94 : * false, it will replace the 1st occurrence only!
95 : */
96 : NS_IMETHOD Replace(const nsAString &aOldWord, const nsAString &aNewWord, bool aAllOccurrences) = 0;
97 :
98 : /**
99 : * Ignores all occurrences of the specified word in the document.
100 : * @param aWord is the word to ignore.
101 : */
102 : NS_IMETHOD IgnoreAll(const nsAString &aWord) = 0;
103 :
104 : /**
105 : * Add a word to the user's personal dictionary.
106 : * @param aWord is the word to add.
107 : */
108 : NS_IMETHOD AddWordToPersonalDictionary(const nsAString &aWord) = 0;
109 :
110 : /**
111 : * Remove a word from the user's personal dictionary.
112 : * @param aWord is the word to remove.
113 : */
114 : NS_IMETHOD RemoveWordFromPersonalDictionary(const nsAString &aWord) = 0;
115 :
116 : /**
117 : * Returns the list of words in the user's personal dictionary.
118 : * @param aWordList is an array of nsStrings that represent the
119 : * list of words in the user's personal dictionary.
120 : */
121 : NS_IMETHOD GetPersonalDictionary(nsTArray<nsString> *aWordList) = 0;
122 :
123 : /**
124 : * Returns the list of strings representing the dictionaries
125 : * the spellchecker supports. It was suggested that the strings
126 : * returned be in the RFC 1766 format. This format looks something
127 : * like <ISO 639 language code>-<ISO 3166 country code>.
128 : * For example: en-US
129 : * @param aDictionaryList is an array of nsStrings that represent the
130 : * dictionaries supported by the spellchecker.
131 : */
132 : NS_IMETHOD GetDictionaryList(nsTArray<nsString> *aDictionaryList) = 0;
133 :
134 : /**
135 : * Returns a string representing the current dictionary.
136 : * @param aDictionary will contain the name of the dictionary.
137 : * This name is the same string that is in the list returned
138 : * by GetDictionaryList().
139 : */
140 : NS_IMETHOD GetCurrentDictionary(nsAString &aDictionary) = 0;
141 :
142 : /**
143 : * Tells the spellchecker to use a specific dictionary.
144 : * @param aDictionary a string that is in the list returned
145 : * by GetDictionaryList() or an empty string. If aDictionary is
146 : * empty string, spellchecker will be disabled.
147 : */
148 : NS_IMETHOD SetCurrentDictionary(const nsAString &aDictionary) = 0;
149 :
150 : /**
151 : * Call this on any change in installed dictionaries to ensure that the spell
152 : * checker is not using a current dictionary which is no longer available.
153 : */
154 : NS_IMETHOD CheckCurrentDictionary() = 0;
155 : };
156 :
157 : NS_DEFINE_STATIC_IID_ACCESSOR(nsISpellChecker, NS_ISPELLCHECKER_IID)
158 :
159 : #endif // nsISpellChecker_h__
160 :
|