michael@0: /******* BEGIN LICENSE BLOCK ******* michael@0: * Version: MPL 1.1/GPL 2.0/LGPL 2.1 michael@0: * michael@0: * The contents of this file are subject to the Mozilla Public License Version michael@0: * 1.1 (the "License"); you may not use this file except in compliance with michael@0: * the License. You may obtain a copy of the License at michael@0: * http://www.mozilla.org/MPL/ michael@0: * michael@0: * Software distributed under the License is distributed on an "AS IS" basis, michael@0: * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License michael@0: * for the specific language governing rights and limitations under the michael@0: * License. michael@0: * michael@0: * The Initial Developers of the Original Code are Kevin Hendricks (MySpell) michael@0: * and László Németh (Hunspell). Portions created by the Initial Developers michael@0: * are Copyright (C) 2002-2005 the Initial Developers. All Rights Reserved. michael@0: * michael@0: * Contributor(s): Kevin Hendricks (kevin.hendricks@sympatico.ca) michael@0: * David Einstein (deinst@world.std.com) michael@0: * Michiel van Leeuwen (mvl@exedo.nl) michael@0: * Caolan McNamara (cmc@openoffice.org) michael@0: * László Németh (nemethl@gyorsposta.hu) michael@0: * Davide Prina michael@0: * Giuseppe Modugno michael@0: * Gianluca Turconi michael@0: * Simon Brouwer michael@0: * Noll Janos michael@0: * Biro Arpad michael@0: * Goldman Eleonora michael@0: * Sarlos Tamas michael@0: * Bencsath Boldizsar michael@0: * Halacsy Peter michael@0: * Dvornik Laszlo michael@0: * Gefferth Andras michael@0: * Nagy Viktor michael@0: * Varga Daniel michael@0: * Chris Halls michael@0: * Rene Engelhard michael@0: * Bram Moolenaar michael@0: * Dafydd Jones michael@0: * Harri Pitkanen michael@0: * Andras Timar michael@0: * Tor Lillqvist michael@0: * Jesper Kristensen (mail@jesperkristensen.dk) michael@0: * michael@0: * Alternatively, the contents of this file may be used under the terms of michael@0: * either the GNU General Public License Version 2 or later (the "GPL"), or michael@0: * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), michael@0: * in which case the provisions of the GPL or the LGPL are applicable instead michael@0: * of those above. If you wish to allow use of your version of this file only michael@0: * under the terms of either the GPL or the LGPL, and not to allow others to michael@0: * use your version of this file under the terms of the MPL, indicate your michael@0: * decision by deleting the provisions above and replace them with the notice michael@0: * and other provisions required by the GPL or the LGPL. If you do not delete michael@0: * the provisions above, a recipient may use your version of this file under michael@0: * the terms of any one of the MPL, the GPL or the LGPL. michael@0: * michael@0: ******* END LICENSE BLOCK *******/ michael@0: michael@0: #ifndef mozHunspell_h__ michael@0: #define mozHunspell_h__ michael@0: michael@0: #include michael@0: #include "mozISpellCheckingEngine.h" michael@0: #include "mozIPersonalDictionary.h" michael@0: #include "nsString.h" michael@0: #include "nsCOMPtr.h" michael@0: #include "nsCOMArray.h" michael@0: #include "nsIMemoryReporter.h" michael@0: #include "nsIObserver.h" michael@0: #include "nsIUnicodeEncoder.h" michael@0: #include "nsIUnicodeDecoder.h" michael@0: #include "nsInterfaceHashtable.h" michael@0: #include "nsWeakReference.h" michael@0: #include "nsCycleCollectionParticipant.h" michael@0: #include "mozHunspellAllocator.h" michael@0: michael@0: #define MOZ_HUNSPELL_CONTRACTID "@mozilla.org/spellchecker/engine;1" michael@0: #define MOZ_HUNSPELL_CID \ michael@0: /* 56c778e4-1bee-45f3-a689-886692a97fe7 */ \ michael@0: { 0x56c778e4, 0x1bee, 0x45f3, \ michael@0: { 0xa6, 0x89, 0x88, 0x66, 0x92, 0xa9, 0x7f, 0xe7 } } michael@0: michael@0: class mozHunspell : public mozISpellCheckingEngine, michael@0: public nsIObserver, michael@0: public nsSupportsWeakReference, michael@0: public nsIMemoryReporter michael@0: { michael@0: public: michael@0: NS_DECL_CYCLE_COLLECTING_ISUPPORTS michael@0: NS_DECL_MOZISPELLCHECKINGENGINE michael@0: NS_DECL_NSIOBSERVER michael@0: NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(mozHunspell, mozISpellCheckingEngine) michael@0: michael@0: mozHunspell(); michael@0: virtual ~mozHunspell(); michael@0: michael@0: nsresult Init(); michael@0: michael@0: void LoadDictionaryList(); michael@0: michael@0: // helper method for converting a word to the charset of the dictionary michael@0: nsresult ConvertCharset(const char16_t* aStr, char ** aDst); michael@0: michael@0: NS_IMETHOD CollectReports(nsIHandleReportCallback* aHandleReport, michael@0: nsISupports* aData) michael@0: { michael@0: return MOZ_COLLECT_REPORT( michael@0: "explicit/spell-check", KIND_HEAP, UNITS_BYTES, HunspellAllocator::MemoryAllocated(), michael@0: "Memory used by the spell-checking engine."); michael@0: } michael@0: michael@0: protected: michael@0: michael@0: nsCOMPtr mPersonalDictionary; michael@0: nsCOMPtr mEncoder; michael@0: nsCOMPtr mDecoder; michael@0: michael@0: // Hashtable matches dictionary name to .aff file michael@0: nsInterfaceHashtable mDictionaries; michael@0: nsString mDictionary; michael@0: nsString mLanguage; michael@0: nsCString mAffixFileName; michael@0: michael@0: // dynamic dirs used to search for dictionaries michael@0: nsCOMArray mDynamicDirectories; michael@0: michael@0: Hunspell *mHunspell; michael@0: }; michael@0: michael@0: #endif