LCOV - code coverage report
Current view: top level - editor/txtsvc - nsISpellChecker.h (source / functions) Hit Total Coverage
Test: output.info Lines: 1 1 100.0 %
Date: 2017-07-14 16:53:18 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.13