extensions/spellcheck/src/mozSpellChecker.h
author Mike Hommey <mh+mozilla@glandium.org>
Sat, 04 Aug 2012 08:48:56 +0200
changeset 104533 2ef51674316aadfe26a46877b16794f758bf4b6d
parent 96742 f4157e8c410708d76703f19e4dfb61859bfe32d8
child 106112 a16372ce30b5f6b747246b01fcd215a4bf3b6342
child 109823 80e4ab0d24bc64ceaa7693ab5def36faffde7a40
permissions -rw-r--r--
Bug 774032 bonus - Use @DEPTH@ and @relativesrcdir@ in Makefile.in. r=ted

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#ifndef mozSpellChecker_h__
#define mozSpellChecker_h__

#include "nsCOMPtr.h"
#include "nsCOMArray.h"
#include "nsISpellChecker.h"
#include "nsString.h"
#include "nsITextServicesDocument.h"
#include "mozIPersonalDictionary.h"
#include "mozISpellCheckingEngine.h"
#include "nsClassHashtable.h"
#include "nsVoidArray.h"
#include "nsTArray.h"
#include "mozISpellI18NUtil.h"
#include "nsCycleCollectionParticipant.h"

class mozSpellChecker : public nsISpellChecker
{
public:
  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
  NS_DECL_CYCLE_COLLECTION_CLASS(mozSpellChecker)

  mozSpellChecker();
  virtual ~mozSpellChecker();

  nsresult Init();

  // nsISpellChecker
  NS_IMETHOD SetDocument(nsITextServicesDocument *aDoc, bool aFromStartofDoc);
  NS_IMETHOD NextMisspelledWord(nsAString &aWord, nsTArray<nsString> *aSuggestions);
  NS_IMETHOD CheckWord(const nsAString &aWord, bool *aIsMisspelled, nsTArray<nsString> *aSuggestions);
  NS_IMETHOD Replace(const nsAString &aOldWord, const nsAString &aNewWord, bool aAllOccurrences);
  NS_IMETHOD IgnoreAll(const nsAString &aWord);

  NS_IMETHOD AddWordToPersonalDictionary(const nsAString &aWord);
  NS_IMETHOD RemoveWordFromPersonalDictionary(const nsAString &aWord);
  NS_IMETHOD GetPersonalDictionary(nsTArray<nsString> *aWordList);

  NS_IMETHOD GetDictionaryList(nsTArray<nsString> *aDictionaryList);
  NS_IMETHOD GetCurrentDictionary(nsAString &aDictionary);
  NS_IMETHOD SetCurrentDictionary(const nsAString &aDictionary);
  NS_IMETHOD CheckCurrentDictionary();

protected:
  nsCOMPtr<mozISpellI18NUtil> mConverter;
  nsCOMPtr<nsITextServicesDocument> mTsDoc;
  nsCOMPtr<mozIPersonalDictionary> mPersonalDictionary;

  nsCOMPtr<mozISpellCheckingEngine>  mSpellCheckingEngine;
  bool mFromStart;

  nsresult SetupDoc(PRInt32 *outBlockOffset);

  nsresult GetCurrentBlockIndex(nsITextServicesDocument *aDoc, PRInt32 *outBlockIndex);

  nsresult GetEngineList(nsCOMArray<mozISpellCheckingEngine> *aDictionaryList);
};
#endif // mozSpellChecker_h__