1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/extensions/spellcheck/hunspell/src/mozHunspell.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,131 @@ 1.4 +/******* BEGIN LICENSE BLOCK ******* 1.5 + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 1.6 + * 1.7 + * The contents of this file are subject to the Mozilla Public License Version 1.8 + * 1.1 (the "License"); you may not use this file except in compliance with 1.9 + * the License. You may obtain a copy of the License at 1.10 + * http://www.mozilla.org/MPL/ 1.11 + * 1.12 + * Software distributed under the License is distributed on an "AS IS" basis, 1.13 + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 1.14 + * for the specific language governing rights and limitations under the 1.15 + * License. 1.16 + * 1.17 + * The Initial Developers of the Original Code are Kevin Hendricks (MySpell) 1.18 + * and László Németh (Hunspell). Portions created by the Initial Developers 1.19 + * are Copyright (C) 2002-2005 the Initial Developers. All Rights Reserved. 1.20 + * 1.21 + * Contributor(s): Kevin Hendricks (kevin.hendricks@sympatico.ca) 1.22 + * David Einstein (deinst@world.std.com) 1.23 + * Michiel van Leeuwen (mvl@exedo.nl) 1.24 + * Caolan McNamara (cmc@openoffice.org) 1.25 + * László Németh (nemethl@gyorsposta.hu) 1.26 + * Davide Prina 1.27 + * Giuseppe Modugno 1.28 + * Gianluca Turconi 1.29 + * Simon Brouwer 1.30 + * Noll Janos 1.31 + * Biro Arpad 1.32 + * Goldman Eleonora 1.33 + * Sarlos Tamas 1.34 + * Bencsath Boldizsar 1.35 + * Halacsy Peter 1.36 + * Dvornik Laszlo 1.37 + * Gefferth Andras 1.38 + * Nagy Viktor 1.39 + * Varga Daniel 1.40 + * Chris Halls 1.41 + * Rene Engelhard 1.42 + * Bram Moolenaar 1.43 + * Dafydd Jones 1.44 + * Harri Pitkanen 1.45 + * Andras Timar 1.46 + * Tor Lillqvist 1.47 + * Jesper Kristensen (mail@jesperkristensen.dk) 1.48 + * 1.49 + * Alternatively, the contents of this file may be used under the terms of 1.50 + * either the GNU General Public License Version 2 or later (the "GPL"), or 1.51 + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 1.52 + * in which case the provisions of the GPL or the LGPL are applicable instead 1.53 + * of those above. If you wish to allow use of your version of this file only 1.54 + * under the terms of either the GPL or the LGPL, and not to allow others to 1.55 + * use your version of this file under the terms of the MPL, indicate your 1.56 + * decision by deleting the provisions above and replace them with the notice 1.57 + * and other provisions required by the GPL or the LGPL. If you do not delete 1.58 + * the provisions above, a recipient may use your version of this file under 1.59 + * the terms of any one of the MPL, the GPL or the LGPL. 1.60 + * 1.61 + ******* END LICENSE BLOCK *******/ 1.62 + 1.63 +#ifndef mozHunspell_h__ 1.64 +#define mozHunspell_h__ 1.65 + 1.66 +#include <hunspell.hxx> 1.67 +#include "mozISpellCheckingEngine.h" 1.68 +#include "mozIPersonalDictionary.h" 1.69 +#include "nsString.h" 1.70 +#include "nsCOMPtr.h" 1.71 +#include "nsCOMArray.h" 1.72 +#include "nsIMemoryReporter.h" 1.73 +#include "nsIObserver.h" 1.74 +#include "nsIUnicodeEncoder.h" 1.75 +#include "nsIUnicodeDecoder.h" 1.76 +#include "nsInterfaceHashtable.h" 1.77 +#include "nsWeakReference.h" 1.78 +#include "nsCycleCollectionParticipant.h" 1.79 +#include "mozHunspellAllocator.h" 1.80 + 1.81 +#define MOZ_HUNSPELL_CONTRACTID "@mozilla.org/spellchecker/engine;1" 1.82 +#define MOZ_HUNSPELL_CID \ 1.83 +/* 56c778e4-1bee-45f3-a689-886692a97fe7 */ \ 1.84 +{ 0x56c778e4, 0x1bee, 0x45f3, \ 1.85 + { 0xa6, 0x89, 0x88, 0x66, 0x92, 0xa9, 0x7f, 0xe7 } } 1.86 + 1.87 +class mozHunspell : public mozISpellCheckingEngine, 1.88 + public nsIObserver, 1.89 + public nsSupportsWeakReference, 1.90 + public nsIMemoryReporter 1.91 +{ 1.92 +public: 1.93 + NS_DECL_CYCLE_COLLECTING_ISUPPORTS 1.94 + NS_DECL_MOZISPELLCHECKINGENGINE 1.95 + NS_DECL_NSIOBSERVER 1.96 + NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(mozHunspell, mozISpellCheckingEngine) 1.97 + 1.98 + mozHunspell(); 1.99 + virtual ~mozHunspell(); 1.100 + 1.101 + nsresult Init(); 1.102 + 1.103 + void LoadDictionaryList(); 1.104 + 1.105 + // helper method for converting a word to the charset of the dictionary 1.106 + nsresult ConvertCharset(const char16_t* aStr, char ** aDst); 1.107 + 1.108 + NS_IMETHOD CollectReports(nsIHandleReportCallback* aHandleReport, 1.109 + nsISupports* aData) 1.110 + { 1.111 + return MOZ_COLLECT_REPORT( 1.112 + "explicit/spell-check", KIND_HEAP, UNITS_BYTES, HunspellAllocator::MemoryAllocated(), 1.113 + "Memory used by the spell-checking engine."); 1.114 + } 1.115 + 1.116 +protected: 1.117 + 1.118 + nsCOMPtr<mozIPersonalDictionary> mPersonalDictionary; 1.119 + nsCOMPtr<nsIUnicodeEncoder> mEncoder; 1.120 + nsCOMPtr<nsIUnicodeDecoder> mDecoder; 1.121 + 1.122 + // Hashtable matches dictionary name to .aff file 1.123 + nsInterfaceHashtable<nsStringHashKey, nsIFile> mDictionaries; 1.124 + nsString mDictionary; 1.125 + nsString mLanguage; 1.126 + nsCString mAffixFileName; 1.127 + 1.128 + // dynamic dirs used to search for dictionaries 1.129 + nsCOMArray<nsIFile> mDynamicDirectories; 1.130 + 1.131 + Hunspell *mHunspell; 1.132 +}; 1.133 + 1.134 +#endif