2001-09-25 22:53:13 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
1999-05-04 21:54:11 +00:00
|
|
|
|
|
|
|
#ifndef nsISpellChecker_h__
|
|
|
|
#define nsISpellChecker_h__
|
|
|
|
|
|
|
|
#include "nsISupports.h"
|
2009-01-18 20:14:14 +00:00
|
|
|
#include "nsTArray.h"
|
1999-05-04 21:54:11 +00:00
|
|
|
|
2000-09-13 23:57:52 +00:00
|
|
|
#define NS_SPELLCHECKER_CONTRACTID "@mozilla.org/spellchecker;1"
|
2000-05-05 14:58:43 +00:00
|
|
|
|
1999-05-04 21:54:11 +00:00
|
|
|
#define NS_ISPELLCHECKER_IID \
|
2011-09-13 18:58:54 +00:00
|
|
|
{ /* 27bff957-b486-40ae-9f5d-af0cdd211868 */ \
|
|
|
|
0x27bff957, 0xb486, 0x40ae, \
|
|
|
|
{ 0x9f, 0x5d, 0xaf, 0x0c, 0xdd, 0x21, 0x18, 0x68 } }
|
1999-05-04 21:54:11 +00:00
|
|
|
|
|
|
|
class nsITextServicesDocument;
|
|
|
|
class nsString;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A generic interface for a spelling checker.
|
|
|
|
*/
|
|
|
|
class nsISpellChecker : public nsISupports{
|
|
|
|
public:
|
|
|
|
|
2005-11-11 14:36:26 +00:00
|
|
|
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ISPELLCHECKER_IID)
|
1999-05-04 21:54:11 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Tells the spellchecker what document to check.
|
|
|
|
* @param aDoc is the document to check.
|
|
|
|
* @param aFromStartOfDoc If true, start check from beginning of document,
|
|
|
|
* if false, start check from current cursor position.
|
|
|
|
*/
|
2011-09-29 06:19:26 +00:00
|
|
|
NS_IMETHOD SetDocument(nsITextServicesDocument *aDoc, bool aFromStartofDoc) = 0;
|
1999-05-04 21:54:11 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Selects (hilites) the next misspelled word in the document.
|
|
|
|
* @param aWord will contain the misspelled word.
|
|
|
|
* @param aSuggestions is an array of nsStrings, that represent the
|
1999-05-12 21:56:11 +00:00
|
|
|
* suggested replacements for the misspelled word.
|
1999-05-04 21:54:11 +00:00
|
|
|
*/
|
2009-01-18 20:14:14 +00:00
|
|
|
NS_IMETHOD NextMisspelledWord(nsAString &aWord, nsTArray<nsString> *aSuggestions) = 0;
|
1999-05-04 21:54:11 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks if a word is misspelled. No document is required to use this method.
|
|
|
|
* @param aWord is the word to check.
|
|
|
|
* @param aIsMisspelled will be set to true if the word is misspelled.
|
|
|
|
* @param aSuggestions is an array of nsStrings which represent the
|
|
|
|
* suggested replacements for the misspelled word. The array will be empty
|
1999-05-12 21:56:11 +00:00
|
|
|
* if there aren't any suggestions.
|
1999-05-04 21:54:11 +00:00
|
|
|
*/
|
2011-09-29 06:19:26 +00:00
|
|
|
NS_IMETHOD CheckWord(const nsAString &aWord, bool *aIsMisspelled, nsTArray<nsString> *aSuggestions) = 0;
|
1999-05-04 21:54:11 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Replaces the old word with the specified new word.
|
|
|
|
* @param aOldWord is the word to be replaced.
|
|
|
|
* @param aNewWord is the word that is to replace old word.
|
|
|
|
* @param aAllOccurrences will replace all occurrences of old
|
|
|
|
* word, in the document, with new word when it is true. If
|
|
|
|
* false, it will replace the 1st occurrence only!
|
|
|
|
*/
|
2011-09-29 06:19:26 +00:00
|
|
|
NS_IMETHOD Replace(const nsAString &aOldWord, const nsAString &aNewWord, bool aAllOccurrences) = 0;
|
1999-05-04 21:54:11 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Ignores all occurrences of the specified word in the document.
|
|
|
|
* @param aWord is the word to ignore.
|
|
|
|
*/
|
2003-12-20 13:06:44 +00:00
|
|
|
NS_IMETHOD IgnoreAll(const nsAString &aWord) = 0;
|
1999-05-04 21:54:11 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Add a word to the user's personal dictionary.
|
|
|
|
* @param aWord is the word to add.
|
|
|
|
*/
|
2003-12-20 13:06:44 +00:00
|
|
|
NS_IMETHOD AddWordToPersonalDictionary(const nsAString &aWord) = 0;
|
1999-05-04 21:54:11 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove a word from the user's personal dictionary.
|
|
|
|
* @param aWord is the word to remove.
|
|
|
|
*/
|
2003-12-20 13:06:44 +00:00
|
|
|
NS_IMETHOD RemoveWordFromPersonalDictionary(const nsAString &aWord) = 0;
|
1999-05-04 21:54:11 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the list of words in the user's personal dictionary.
|
|
|
|
* @param aWordList is an array of nsStrings that represent the
|
1999-05-12 21:56:11 +00:00
|
|
|
* list of words in the user's personal dictionary.
|
1999-05-04 21:54:11 +00:00
|
|
|
*/
|
2009-01-18 20:14:14 +00:00
|
|
|
NS_IMETHOD GetPersonalDictionary(nsTArray<nsString> *aWordList) = 0;
|
2000-05-04 14:37:56 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the list of strings representing the dictionaries
|
|
|
|
* the spellchecker supports. It was suggested that the strings
|
|
|
|
* returned be in the RFC 1766 format. This format looks something
|
|
|
|
* like <ISO 639 language code>-<ISO 3166 country code>.
|
|
|
|
* For example: en-US
|
|
|
|
* @param aDictionaryList is an array of nsStrings that represent the
|
|
|
|
* dictionaries supported by the spellchecker.
|
|
|
|
*/
|
2009-01-18 20:14:14 +00:00
|
|
|
NS_IMETHOD GetDictionaryList(nsTArray<nsString> *aDictionaryList) = 0;
|
2000-05-04 14:37:56 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a string representing the current dictionary.
|
|
|
|
* @param aDictionary will contain the name of the dictionary.
|
|
|
|
* This name is the same string that is in the list returned
|
|
|
|
* by GetDictionaryList().
|
|
|
|
*/
|
2003-12-20 13:06:44 +00:00
|
|
|
NS_IMETHOD GetCurrentDictionary(nsAString &aDictionary) = 0;
|
2000-05-04 14:37:56 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Tells the spellchecker to use a specific dictionary.
|
|
|
|
* @param aDictionary a string that is in the list returned
|
2015-05-28 15:58:42 +00:00
|
|
|
* by GetDictionaryList() or an empty string. If aDictionary is
|
2011-08-12 19:12:45 +00:00
|
|
|
* empty string, spellchecker will be disabled.
|
2000-05-04 14:37:56 +00:00
|
|
|
*/
|
2003-12-20 13:06:44 +00:00
|
|
|
NS_IMETHOD SetCurrentDictionary(const nsAString &aDictionary) = 0;
|
1999-05-04 21:54:11 +00:00
|
|
|
};
|
|
|
|
|
2005-11-11 14:36:26 +00:00
|
|
|
NS_DEFINE_STATIC_IID_ACCESSOR(nsISpellChecker, NS_ISPELLCHECKER_IID)
|
|
|
|
|
1999-05-04 21:54:11 +00:00
|
|
|
#endif // nsISpellChecker_h__
|
|
|
|
|