nsIEditorSpellCheck.idl 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #include "nsISupports.idl"
  6. interface nsIEditor;
  7. interface nsITextServicesFilter;
  8. interface nsIEditorSpellCheckCallback;
  9. [scriptable, uuid(a171c25f-e4a8-4d08-adef-b797e6377bdc)]
  10. interface nsIEditorSpellCheck : nsISupports
  11. {
  12. /**
  13. * Returns true if we can enable spellchecking. If there are no available
  14. * dictionaries, this will return false.
  15. */
  16. boolean canSpellCheck();
  17. /**
  18. * Turns on the spell checker for the given editor. enableSelectionChecking
  19. * set means that we only want to check the current selection in the editor,
  20. * (this controls the behavior of GetNextMisspelledWord). For spellchecking
  21. * clients with no modal UI (such as inline spellcheckers), this flag doesn't
  22. * matter. Initialization is asynchronous and is not complete until the given
  23. * callback is called.
  24. */
  25. void InitSpellChecker(in nsIEditor editor, in boolean enableSelectionChecking,
  26. [optional] in nsIEditorSpellCheckCallback callback);
  27. /**
  28. * When interactively spell checking the document, this will return the
  29. * value of the next word that is misspelled. This also computes the
  30. * suggestions which you can get by calling GetSuggestedWord.
  31. *
  32. * @see nsISpellChecker::GetNextMisspelledWord
  33. */
  34. wstring GetNextMisspelledWord();
  35. /**
  36. * Used to get suggestions for the last word that was checked and found to
  37. * be misspelled. The first call will give you the first (best) suggestion.
  38. * Subsequent calls will iterate through all the suggestions, allowing you
  39. * to build a list. When there are no more suggestions, an empty string
  40. * (not a null pointer) will be returned.
  41. *
  42. * @see nsISpellChecker::GetSuggestedWord
  43. */
  44. wstring GetSuggestedWord();
  45. /**
  46. * Check a given word. In spite of the name, this function checks the word
  47. * you give it, returning true if the word is misspelled. If the word is
  48. * misspelled, it will compute the suggestions which you can get from
  49. * GetSuggestedWord().
  50. *
  51. * @see nsISpellChecker::CheckCurrentWord
  52. */
  53. boolean CheckCurrentWord(in wstring suggestedWord);
  54. /**
  55. * Use when modally checking the document to replace a word.
  56. *
  57. * @see nsISpellChecker::CheckCurrentWord
  58. */
  59. void ReplaceWord(in wstring misspelledWord, in wstring replaceWord, in boolean allOccurrences);
  60. /**
  61. * @see nsISpellChecker::IgnoreAll
  62. */
  63. void IgnoreWordAllOccurrences(in wstring word);
  64. /**
  65. * Fills an internal list of words added to the personal dictionary. These
  66. * words can be retrieved using GetPersonalDictionaryWord()
  67. *
  68. * @see nsISpellChecker::GetPersonalDictionary
  69. * @see GetPersonalDictionaryWord
  70. */
  71. void GetPersonalDictionary();
  72. /**
  73. * Used after you call GetPersonalDictionary() to iterate through all the
  74. * words added to the personal dictionary. Will return the empty string when
  75. * there are no more words.
  76. */
  77. wstring GetPersonalDictionaryWord();
  78. /**
  79. * Adds a word to the current personal dictionary.
  80. *
  81. * @see nsISpellChecker::AddWordToDictionary
  82. */
  83. void AddWordToDictionary(in wstring word);
  84. /**
  85. * Removes a word from the current personal dictionary.
  86. *
  87. * @see nsISpellChecker::RemoveWordFromPersonalDictionary
  88. */
  89. void RemoveWordFromDictionary(in wstring word);
  90. /**
  91. * Retrieves a list of the currently available dictionaries. The strings will
  92. * typically be language IDs, like "en-US".
  93. *
  94. * @see mozISpellCheckingEngine::GetDictionaryList
  95. */
  96. void GetDictionaryList([array, size_is(count)] out wstring dictionaryList, out uint32_t count);
  97. /**
  98. * @see nsISpellChecker::GetCurrentDictionary
  99. */
  100. AString GetCurrentDictionary();
  101. /**
  102. * @see nsISpellChecker::SetCurrentDictionary
  103. */
  104. void SetCurrentDictionary(in AString dictionary);
  105. /**
  106. * Call this to free up the spell checking object. It will also save the
  107. * current selected language as the default for future use.
  108. *
  109. * If you have called CanSpellCheck but not InitSpellChecker, you can still
  110. * call this function to clear the cached spell check object, and no
  111. * preference saving will happen.
  112. */
  113. void UninitSpellChecker();
  114. /**
  115. * Used to filter the content (for example, to skip blockquotes in email from
  116. * spellchecking. Call this before calling InitSpellChecker; calling it
  117. * after initialization will have no effect.
  118. *
  119. * @see nsITextServicesDocument::setFilter
  120. */
  121. void setFilter(in nsITextServicesFilter filter);
  122. /**
  123. * Like CheckCurrentWord, checks the word you give it, returning true if it's
  124. * misspelled. This is faster than CheckCurrentWord because it does not
  125. * compute any suggestions.
  126. *
  127. * Watch out: this does not clear any suggestions left over from previous
  128. * calls to CheckCurrentWord, so there may be suggestions, but they will be
  129. * invalid.
  130. */
  131. boolean CheckCurrentWordNoSuggest(in wstring suggestedWord);
  132. /**
  133. * Update the dictionary in use to be sure it corresponds to what the editor
  134. * needs. The update is asynchronous and is not complete until the given
  135. * callback is called.
  136. */
  137. void UpdateCurrentDictionary([optional] in nsIEditorSpellCheckCallback callback);
  138. };
  139. [scriptable, function, uuid(5f0a4bab-8538-4074-89d3-2f0e866a1c0b)]
  140. interface nsIEditorSpellCheckCallback : nsISupports
  141. {
  142. void editorSpellCheckDone();
  143. };