michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef nsISpellChecker_h__ michael@0: #define nsISpellChecker_h__ michael@0: michael@0: #include "nsISupports.h" michael@0: #include "nsTArray.h" michael@0: michael@0: #define NS_SPELLCHECKER_CONTRACTID "@mozilla.org/spellchecker;1" michael@0: michael@0: #define NS_ISPELLCHECKER_IID \ michael@0: { /* 27bff957-b486-40ae-9f5d-af0cdd211868 */ \ michael@0: 0x27bff957, 0xb486, 0x40ae, \ michael@0: { 0x9f, 0x5d, 0xaf, 0x0c, 0xdd, 0x21, 0x18, 0x68 } } michael@0: michael@0: class nsITextServicesDocument; michael@0: class nsString; michael@0: michael@0: /** michael@0: * A generic interface for a spelling checker. michael@0: */ michael@0: class nsISpellChecker : public nsISupports{ michael@0: public: michael@0: michael@0: NS_DECLARE_STATIC_IID_ACCESSOR(NS_ISPELLCHECKER_IID) michael@0: michael@0: /** michael@0: * Tells the spellchecker what document to check. michael@0: * @param aDoc is the document to check. michael@0: * @param aFromStartOfDoc If true, start check from beginning of document, michael@0: * if false, start check from current cursor position. michael@0: */ michael@0: NS_IMETHOD SetDocument(nsITextServicesDocument *aDoc, bool aFromStartofDoc) = 0; michael@0: michael@0: /** michael@0: * Selects (hilites) the next misspelled word in the document. michael@0: * @param aWord will contain the misspelled word. michael@0: * @param aSuggestions is an array of nsStrings, that represent the michael@0: * suggested replacements for the misspelled word. michael@0: */ michael@0: NS_IMETHOD NextMisspelledWord(nsAString &aWord, nsTArray *aSuggestions) = 0; michael@0: michael@0: /** michael@0: * Checks if a word is misspelled. No document is required to use this method. michael@0: * @param aWord is the word to check. michael@0: * @param aIsMisspelled will be set to true if the word is misspelled. michael@0: * @param aSuggestions is an array of nsStrings which represent the michael@0: * suggested replacements for the misspelled word. The array will be empty michael@0: * if there aren't any suggestions. michael@0: */ michael@0: NS_IMETHOD CheckWord(const nsAString &aWord, bool *aIsMisspelled, nsTArray *aSuggestions) = 0; michael@0: michael@0: /** michael@0: * Replaces the old word with the specified new word. michael@0: * @param aOldWord is the word to be replaced. michael@0: * @param aNewWord is the word that is to replace old word. michael@0: * @param aAllOccurrences will replace all occurrences of old michael@0: * word, in the document, with new word when it is true. If michael@0: * false, it will replace the 1st occurrence only! michael@0: */ michael@0: NS_IMETHOD Replace(const nsAString &aOldWord, const nsAString &aNewWord, bool aAllOccurrences) = 0; michael@0: michael@0: /** michael@0: * Ignores all occurrences of the specified word in the document. michael@0: * @param aWord is the word to ignore. michael@0: */ michael@0: NS_IMETHOD IgnoreAll(const nsAString &aWord) = 0; michael@0: michael@0: /** michael@0: * Add a word to the user's personal dictionary. michael@0: * @param aWord is the word to add. michael@0: */ michael@0: NS_IMETHOD AddWordToPersonalDictionary(const nsAString &aWord) = 0; michael@0: michael@0: /** michael@0: * Remove a word from the user's personal dictionary. michael@0: * @param aWord is the word to remove. michael@0: */ michael@0: NS_IMETHOD RemoveWordFromPersonalDictionary(const nsAString &aWord) = 0; michael@0: michael@0: /** michael@0: * Returns the list of words in the user's personal dictionary. michael@0: * @param aWordList is an array of nsStrings that represent the michael@0: * list of words in the user's personal dictionary. michael@0: */ michael@0: NS_IMETHOD GetPersonalDictionary(nsTArray *aWordList) = 0; michael@0: michael@0: /** michael@0: * Returns the list of strings representing the dictionaries michael@0: * the spellchecker supports. It was suggested that the strings michael@0: * returned be in the RFC 1766 format. This format looks something michael@0: * like -. michael@0: * For example: en-US michael@0: * @param aDictionaryList is an array of nsStrings that represent the michael@0: * dictionaries supported by the spellchecker. michael@0: */ michael@0: NS_IMETHOD GetDictionaryList(nsTArray *aDictionaryList) = 0; michael@0: michael@0: /** michael@0: * Returns a string representing the current dictionary. michael@0: * @param aDictionary will contain the name of the dictionary. michael@0: * This name is the same string that is in the list returned michael@0: * by GetDictionaryList(). michael@0: */ michael@0: NS_IMETHOD GetCurrentDictionary(nsAString &aDictionary) = 0; michael@0: michael@0: /** michael@0: * Tells the spellchecker to use a specific dictionary. michael@0: * @param aDictionary a string that is in the list returned michael@0: * by GetDictionaryList() or an empty string. If aDictionary is michael@0: * empty string, spellchecker will be disabled. michael@0: */ michael@0: NS_IMETHOD SetCurrentDictionary(const nsAString &aDictionary) = 0; michael@0: michael@0: /** michael@0: * Call this on any change in installed dictionaries to ensure that the spell michael@0: * checker is not using a current dictionary which is no longer available. michael@0: */ michael@0: NS_IMETHOD CheckCurrentDictionary() = 0; michael@0: }; michael@0: michael@0: NS_DEFINE_STATIC_IID_ACCESSOR(nsISpellChecker, NS_ISPELLCHECKER_IID) michael@0: michael@0: #endif // nsISpellChecker_h__ michael@0: