/editor/txtsvc/public/nsISpellChecker.h

http://github.com/zpao/v8monkey · C Header · 160 lines · 29 code · 22 blank · 109 comment · 0 complexity · 1168d6319f511e90aca0433d09b90eec MD5 · raw file

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