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: #include "nsISupports.idl" michael@0: michael@0: interface nsIEditor; michael@0: interface nsITextServicesFilter; michael@0: interface nsIEditorSpellCheckCallback; michael@0: michael@0: [scriptable, uuid(dd32ef3b-a7d8-43d1-9617-5f2dddbe29eb)] michael@0: interface nsIEditorSpellCheck : nsISupports michael@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: * If the current dictionary is no longer available, then pick another one. michael@0: */ michael@0: void checkCurrentDictionary(); michael@0: michael@0: /** michael@0: * Returns true if we can enable spellchecking. If there are no available michael@0: * dictionaries, this will return false. michael@0: */ michael@0: boolean canSpellCheck(); michael@0: michael@0: /** michael@0: * Turns on the spell checker for the given editor. enableSelectionChecking michael@0: * set means that we only want to check the current selection in the editor, michael@0: * (this controls the behavior of GetNextMisspelledWord). For spellchecking michael@0: * clients with no modal UI (such as inline spellcheckers), this flag doesn't michael@0: * matter. Initialization is asynchronous and is not complete until the given michael@0: * callback is called. michael@0: */ michael@0: void InitSpellChecker(in nsIEditor editor, in boolean enableSelectionChecking, michael@0: [optional] in nsIEditorSpellCheckCallback callback); michael@0: michael@0: /** michael@0: * When interactively spell checking the document, this will return the michael@0: * value of the next word that is misspelled. This also computes the michael@0: * suggestions which you can get by calling GetSuggestedWord. michael@0: * michael@0: * @see nsISpellChecker::GetNextMisspelledWord michael@0: */ michael@0: wstring GetNextMisspelledWord(); michael@0: michael@0: /** michael@0: * Used to get suggestions for the last word that was checked and found to michael@0: * be misspelled. The first call will give you the first (best) suggestion. michael@0: * Subsequent calls will iterate through all the suggestions, allowing you michael@0: * to build a list. When there are no more suggestions, an empty string michael@0: * (not a null pointer) will be returned. michael@0: * michael@0: * @see nsISpellChecker::GetSuggestedWord michael@0: */ michael@0: wstring GetSuggestedWord(); michael@0: michael@0: /** michael@0: * Check a given word. In spite of the name, this function checks the word michael@0: * you give it, returning true if the word is misspelled. If the word is michael@0: * misspelled, it will compute the suggestions which you can get from michael@0: * GetSuggestedWord(). michael@0: * michael@0: * @see nsISpellChecker::CheckCurrentWord michael@0: */ michael@0: boolean CheckCurrentWord(in wstring suggestedWord); michael@0: michael@0: /** michael@0: * Use when modally checking the document to replace a word. michael@0: * michael@0: * @see nsISpellChecker::CheckCurrentWord michael@0: */ michael@0: void ReplaceWord(in wstring misspelledWord, in wstring replaceWord, in boolean allOccurrences); michael@0: michael@0: /** michael@0: * @see nsISpellChecker::IgnoreAll michael@0: */ michael@0: void IgnoreWordAllOccurrences(in wstring word); michael@0: michael@0: /** michael@0: * Fills an internal list of words added to the personal dictionary. These michael@0: * words can be retrieved using GetPersonalDictionaryWord() michael@0: * michael@0: * @see nsISpellChecker::GetPersonalDictionary michael@0: * @see GetPersonalDictionaryWord michael@0: */ michael@0: void GetPersonalDictionary(); michael@0: michael@0: /** michael@0: * Used after you call GetPersonalDictionary() to iterate through all the michael@0: * words added to the personal dictionary. Will return the empty string when michael@0: * there are no more words. michael@0: */ michael@0: wstring GetPersonalDictionaryWord(); michael@0: michael@0: /** michael@0: * Adds a word to the current personal dictionary. michael@0: * michael@0: * @see nsISpellChecker::AddWordToDictionary michael@0: */ michael@0: void AddWordToDictionary(in wstring word); michael@0: michael@0: /** michael@0: * Removes a word from the current personal dictionary. michael@0: * michael@0: * @see nsISpellChecker::RemoveWordFromPersonalDictionary michael@0: */ michael@0: void RemoveWordFromDictionary(in wstring word); michael@0: michael@0: /** michael@0: * Retrieves a list of the currently available dictionaries. The strings will michael@0: * typically be language IDs, like "en-US". michael@0: * michael@0: * @see mozISpellCheckingEngine::GetDictionaryList michael@0: */ michael@0: void GetDictionaryList([array, size_is(count)] out wstring dictionaryList, out uint32_t count); michael@0: michael@0: /** michael@0: * @see nsISpellChecker::GetCurrentDictionary michael@0: */ michael@0: AString GetCurrentDictionary(); michael@0: michael@0: /** michael@0: * @see nsISpellChecker::SetCurrentDictionary michael@0: */ michael@0: void SetCurrentDictionary(in AString dictionary); michael@0: michael@0: /** michael@0: * Call this to free up the spell checking object. It will also save the michael@0: * current selected language as the default for future use. michael@0: * michael@0: * If you have called CanSpellCheck but not InitSpellChecker, you can still michael@0: * call this function to clear the cached spell check object, and no michael@0: * preference saving will happen. michael@0: */ michael@0: void UninitSpellChecker(); michael@0: michael@0: /** michael@0: * Used to filter the content (for example, to skip blockquotes in email from michael@0: * spellchecking. Call this before calling InitSpellChecker; calling it michael@0: * after initialization will have no effect. michael@0: * michael@0: * @see nsITextServicesDocument::setFilter michael@0: */ michael@0: void setFilter(in nsITextServicesFilter filter); michael@0: michael@0: /** michael@0: * Like CheckCurrentWord, checks the word you give it, returning true if it's michael@0: * misspelled. This is faster than CheckCurrentWord because it does not michael@0: * compute any suggestions. michael@0: * michael@0: * Watch out: this does not clear any suggestions left over from previous michael@0: * calls to CheckCurrentWord, so there may be suggestions, but they will be michael@0: * invalid. michael@0: */ michael@0: boolean CheckCurrentWordNoSuggest(in wstring suggestedWord); michael@0: michael@0: /** michael@0: * Update the dictionary in use to be sure it corresponds to what the editor michael@0: * needs. The update is asynchronous and is not complete until the given michael@0: * callback is called. michael@0: */ michael@0: void UpdateCurrentDictionary([optional] in nsIEditorSpellCheckCallback callback); michael@0: michael@0: }; michael@0: michael@0: [scriptable, function, uuid(5f0a4bab-8538-4074-89d3-2f0e866a1c0b)] michael@0: interface nsIEditorSpellCheckCallback : nsISupports michael@0: { michael@0: void editorSpellCheckDone(); michael@0: };