editor/txtsvc/public/nsISpellChecker.h

Wed, 31 Dec 2014 07:16:47 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:16:47 +0100
branch
TOR_BUG_9701
changeset 3
141e0f1194b1
permissions
-rw-r--r--

Revert simplistic fix pending revisit of Mozilla integration attempt.

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 #ifndef nsISpellChecker_h__
michael@0 7 #define nsISpellChecker_h__
michael@0 8
michael@0 9 #include "nsISupports.h"
michael@0 10 #include "nsTArray.h"
michael@0 11
michael@0 12 #define NS_SPELLCHECKER_CONTRACTID "@mozilla.org/spellchecker;1"
michael@0 13
michael@0 14 #define NS_ISPELLCHECKER_IID \
michael@0 15 { /* 27bff957-b486-40ae-9f5d-af0cdd211868 */ \
michael@0 16 0x27bff957, 0xb486, 0x40ae, \
michael@0 17 { 0x9f, 0x5d, 0xaf, 0x0c, 0xdd, 0x21, 0x18, 0x68 } }
michael@0 18
michael@0 19 class nsITextServicesDocument;
michael@0 20 class nsString;
michael@0 21
michael@0 22 /**
michael@0 23 * A generic interface for a spelling checker.
michael@0 24 */
michael@0 25 class nsISpellChecker : public nsISupports{
michael@0 26 public:
michael@0 27
michael@0 28 NS_DECLARE_STATIC_IID_ACCESSOR(NS_ISPELLCHECKER_IID)
michael@0 29
michael@0 30 /**
michael@0 31 * Tells the spellchecker what document to check.
michael@0 32 * @param aDoc is the document to check.
michael@0 33 * @param aFromStartOfDoc If true, start check from beginning of document,
michael@0 34 * if false, start check from current cursor position.
michael@0 35 */
michael@0 36 NS_IMETHOD SetDocument(nsITextServicesDocument *aDoc, bool aFromStartofDoc) = 0;
michael@0 37
michael@0 38 /**
michael@0 39 * Selects (hilites) the next misspelled word in the document.
michael@0 40 * @param aWord will contain the misspelled word.
michael@0 41 * @param aSuggestions is an array of nsStrings, that represent the
michael@0 42 * suggested replacements for the misspelled word.
michael@0 43 */
michael@0 44 NS_IMETHOD NextMisspelledWord(nsAString &aWord, nsTArray<nsString> *aSuggestions) = 0;
michael@0 45
michael@0 46 /**
michael@0 47 * Checks if a word is misspelled. No document is required to use this method.
michael@0 48 * @param aWord is the word to check.
michael@0 49 * @param aIsMisspelled will be set to true if the word is misspelled.
michael@0 50 * @param aSuggestions is an array of nsStrings which represent the
michael@0 51 * suggested replacements for the misspelled word. The array will be empty
michael@0 52 * if there aren't any suggestions.
michael@0 53 */
michael@0 54 NS_IMETHOD CheckWord(const nsAString &aWord, bool *aIsMisspelled, nsTArray<nsString> *aSuggestions) = 0;
michael@0 55
michael@0 56 /**
michael@0 57 * Replaces the old word with the specified new word.
michael@0 58 * @param aOldWord is the word to be replaced.
michael@0 59 * @param aNewWord is the word that is to replace old word.
michael@0 60 * @param aAllOccurrences will replace all occurrences of old
michael@0 61 * word, in the document, with new word when it is true. If
michael@0 62 * false, it will replace the 1st occurrence only!
michael@0 63 */
michael@0 64 NS_IMETHOD Replace(const nsAString &aOldWord, const nsAString &aNewWord, bool aAllOccurrences) = 0;
michael@0 65
michael@0 66 /**
michael@0 67 * Ignores all occurrences of the specified word in the document.
michael@0 68 * @param aWord is the word to ignore.
michael@0 69 */
michael@0 70 NS_IMETHOD IgnoreAll(const nsAString &aWord) = 0;
michael@0 71
michael@0 72 /**
michael@0 73 * Add a word to the user's personal dictionary.
michael@0 74 * @param aWord is the word to add.
michael@0 75 */
michael@0 76 NS_IMETHOD AddWordToPersonalDictionary(const nsAString &aWord) = 0;
michael@0 77
michael@0 78 /**
michael@0 79 * Remove a word from the user's personal dictionary.
michael@0 80 * @param aWord is the word to remove.
michael@0 81 */
michael@0 82 NS_IMETHOD RemoveWordFromPersonalDictionary(const nsAString &aWord) = 0;
michael@0 83
michael@0 84 /**
michael@0 85 * Returns the list of words in the user's personal dictionary.
michael@0 86 * @param aWordList is an array of nsStrings that represent the
michael@0 87 * list of words in the user's personal dictionary.
michael@0 88 */
michael@0 89 NS_IMETHOD GetPersonalDictionary(nsTArray<nsString> *aWordList) = 0;
michael@0 90
michael@0 91 /**
michael@0 92 * Returns the list of strings representing the dictionaries
michael@0 93 * the spellchecker supports. It was suggested that the strings
michael@0 94 * returned be in the RFC 1766 format. This format looks something
michael@0 95 * like <ISO 639 language code>-<ISO 3166 country code>.
michael@0 96 * For example: en-US
michael@0 97 * @param aDictionaryList is an array of nsStrings that represent the
michael@0 98 * dictionaries supported by the spellchecker.
michael@0 99 */
michael@0 100 NS_IMETHOD GetDictionaryList(nsTArray<nsString> *aDictionaryList) = 0;
michael@0 101
michael@0 102 /**
michael@0 103 * Returns a string representing the current dictionary.
michael@0 104 * @param aDictionary will contain the name of the dictionary.
michael@0 105 * This name is the same string that is in the list returned
michael@0 106 * by GetDictionaryList().
michael@0 107 */
michael@0 108 NS_IMETHOD GetCurrentDictionary(nsAString &aDictionary) = 0;
michael@0 109
michael@0 110 /**
michael@0 111 * Tells the spellchecker to use a specific dictionary.
michael@0 112 * @param aDictionary a string that is in the list returned
michael@0 113 * by GetDictionaryList() or an empty string. If aDictionary is
michael@0 114 * empty string, spellchecker will be disabled.
michael@0 115 */
michael@0 116 NS_IMETHOD SetCurrentDictionary(const nsAString &aDictionary) = 0;
michael@0 117
michael@0 118 /**
michael@0 119 * Call this on any change in installed dictionaries to ensure that the spell
michael@0 120 * checker is not using a current dictionary which is no longer available.
michael@0 121 */
michael@0 122 NS_IMETHOD CheckCurrentDictionary() = 0;
michael@0 123 };
michael@0 124
michael@0 125 NS_DEFINE_STATIC_IID_ACCESSOR(nsISpellChecker, NS_ISPELLCHECKER_IID)
michael@0 126
michael@0 127 #endif // nsISpellChecker_h__
michael@0 128

mercurial