1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/editor/idl/nsIEditorSpellCheck.idl Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,173 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#include "nsISupports.idl" 1.10 + 1.11 +interface nsIEditor; 1.12 +interface nsITextServicesFilter; 1.13 +interface nsIEditorSpellCheckCallback; 1.14 + 1.15 +[scriptable, uuid(dd32ef3b-a7d8-43d1-9617-5f2dddbe29eb)] 1.16 +interface nsIEditorSpellCheck : nsISupports 1.17 +{ 1.18 + 1.19 + /** 1.20 + * Call this on any change in installed dictionaries to ensure that the spell 1.21 + * checker is not using a current dictionary which is no longer available. 1.22 + * If the current dictionary is no longer available, then pick another one. 1.23 + */ 1.24 + void checkCurrentDictionary(); 1.25 + 1.26 + /** 1.27 + * Returns true if we can enable spellchecking. If there are no available 1.28 + * dictionaries, this will return false. 1.29 + */ 1.30 + boolean canSpellCheck(); 1.31 + 1.32 + /** 1.33 + * Turns on the spell checker for the given editor. enableSelectionChecking 1.34 + * set means that we only want to check the current selection in the editor, 1.35 + * (this controls the behavior of GetNextMisspelledWord). For spellchecking 1.36 + * clients with no modal UI (such as inline spellcheckers), this flag doesn't 1.37 + * matter. Initialization is asynchronous and is not complete until the given 1.38 + * callback is called. 1.39 + */ 1.40 + void InitSpellChecker(in nsIEditor editor, in boolean enableSelectionChecking, 1.41 + [optional] in nsIEditorSpellCheckCallback callback); 1.42 + 1.43 + /** 1.44 + * When interactively spell checking the document, this will return the 1.45 + * value of the next word that is misspelled. This also computes the 1.46 + * suggestions which you can get by calling GetSuggestedWord. 1.47 + * 1.48 + * @see nsISpellChecker::GetNextMisspelledWord 1.49 + */ 1.50 + wstring GetNextMisspelledWord(); 1.51 + 1.52 + /** 1.53 + * Used to get suggestions for the last word that was checked and found to 1.54 + * be misspelled. The first call will give you the first (best) suggestion. 1.55 + * Subsequent calls will iterate through all the suggestions, allowing you 1.56 + * to build a list. When there are no more suggestions, an empty string 1.57 + * (not a null pointer) will be returned. 1.58 + * 1.59 + * @see nsISpellChecker::GetSuggestedWord 1.60 + */ 1.61 + wstring GetSuggestedWord(); 1.62 + 1.63 + /** 1.64 + * Check a given word. In spite of the name, this function checks the word 1.65 + * you give it, returning true if the word is misspelled. If the word is 1.66 + * misspelled, it will compute the suggestions which you can get from 1.67 + * GetSuggestedWord(). 1.68 + * 1.69 + * @see nsISpellChecker::CheckCurrentWord 1.70 + */ 1.71 + boolean CheckCurrentWord(in wstring suggestedWord); 1.72 + 1.73 + /** 1.74 + * Use when modally checking the document to replace a word. 1.75 + * 1.76 + * @see nsISpellChecker::CheckCurrentWord 1.77 + */ 1.78 + void ReplaceWord(in wstring misspelledWord, in wstring replaceWord, in boolean allOccurrences); 1.79 + 1.80 + /** 1.81 + * @see nsISpellChecker::IgnoreAll 1.82 + */ 1.83 + void IgnoreWordAllOccurrences(in wstring word); 1.84 + 1.85 + /** 1.86 + * Fills an internal list of words added to the personal dictionary. These 1.87 + * words can be retrieved using GetPersonalDictionaryWord() 1.88 + * 1.89 + * @see nsISpellChecker::GetPersonalDictionary 1.90 + * @see GetPersonalDictionaryWord 1.91 + */ 1.92 + void GetPersonalDictionary(); 1.93 + 1.94 + /** 1.95 + * Used after you call GetPersonalDictionary() to iterate through all the 1.96 + * words added to the personal dictionary. Will return the empty string when 1.97 + * there are no more words. 1.98 + */ 1.99 + wstring GetPersonalDictionaryWord(); 1.100 + 1.101 + /** 1.102 + * Adds a word to the current personal dictionary. 1.103 + * 1.104 + * @see nsISpellChecker::AddWordToDictionary 1.105 + */ 1.106 + void AddWordToDictionary(in wstring word); 1.107 + 1.108 + /** 1.109 + * Removes a word from the current personal dictionary. 1.110 + * 1.111 + * @see nsISpellChecker::RemoveWordFromPersonalDictionary 1.112 + */ 1.113 + void RemoveWordFromDictionary(in wstring word); 1.114 + 1.115 + /** 1.116 + * Retrieves a list of the currently available dictionaries. The strings will 1.117 + * typically be language IDs, like "en-US". 1.118 + * 1.119 + * @see mozISpellCheckingEngine::GetDictionaryList 1.120 + */ 1.121 + void GetDictionaryList([array, size_is(count)] out wstring dictionaryList, out uint32_t count); 1.122 + 1.123 + /** 1.124 + * @see nsISpellChecker::GetCurrentDictionary 1.125 + */ 1.126 + AString GetCurrentDictionary(); 1.127 + 1.128 + /** 1.129 + * @see nsISpellChecker::SetCurrentDictionary 1.130 + */ 1.131 + void SetCurrentDictionary(in AString dictionary); 1.132 + 1.133 + /** 1.134 + * Call this to free up the spell checking object. It will also save the 1.135 + * current selected language as the default for future use. 1.136 + * 1.137 + * If you have called CanSpellCheck but not InitSpellChecker, you can still 1.138 + * call this function to clear the cached spell check object, and no 1.139 + * preference saving will happen. 1.140 + */ 1.141 + void UninitSpellChecker(); 1.142 + 1.143 + /** 1.144 + * Used to filter the content (for example, to skip blockquotes in email from 1.145 + * spellchecking. Call this before calling InitSpellChecker; calling it 1.146 + * after initialization will have no effect. 1.147 + * 1.148 + * @see nsITextServicesDocument::setFilter 1.149 + */ 1.150 + void setFilter(in nsITextServicesFilter filter); 1.151 + 1.152 + /** 1.153 + * Like CheckCurrentWord, checks the word you give it, returning true if it's 1.154 + * misspelled. This is faster than CheckCurrentWord because it does not 1.155 + * compute any suggestions. 1.156 + * 1.157 + * Watch out: this does not clear any suggestions left over from previous 1.158 + * calls to CheckCurrentWord, so there may be suggestions, but they will be 1.159 + * invalid. 1.160 + */ 1.161 + boolean CheckCurrentWordNoSuggest(in wstring suggestedWord); 1.162 + 1.163 + /** 1.164 + * Update the dictionary in use to be sure it corresponds to what the editor 1.165 + * needs. The update is asynchronous and is not complete until the given 1.166 + * callback is called. 1.167 + */ 1.168 + void UpdateCurrentDictionary([optional] in nsIEditorSpellCheckCallback callback); 1.169 + 1.170 +}; 1.171 + 1.172 +[scriptable, function, uuid(5f0a4bab-8538-4074-89d3-2f0e866a1c0b)] 1.173 +interface nsIEditorSpellCheckCallback : nsISupports 1.174 +{ 1.175 + void editorSpellCheckDone(); 1.176 +};