1 : /******* BEGIN LICENSE BLOCK *******
2 : * Version: MPL 1.1/GPL 2.0/LGPL 2.1
3 : *
4 : * The contents of this file are subject to the Mozilla Public License Version
5 : * 1.1 (the "License"); you may not use this file except in compliance with
6 : * the License. You may obtain a copy of the License at
7 : * http://www.mozilla.org/MPL/
8 : *
9 : * Software distributed under the License is distributed on an "AS IS" basis,
10 : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 : * for the specific language governing rights and limitations under the
12 : * License.
13 : *
14 : * The Initial Developers of the Original Code are Kevin Hendricks (MySpell)
15 : * and László Németh (Hunspell). Portions created by the Initial Developers
16 : * are Copyright (C) 2002-2005 the Initial Developers. All Rights Reserved.
17 : *
18 : * Contributor(s): Kevin Hendricks (kevin.hendricks@sympatico.ca)
19 : * David Einstein (deinst@world.std.com)
20 : * Michiel van Leeuwen (mvl@exedo.nl)
21 : * Caolan McNamara (cmc@openoffice.org)
22 : * László Németh (nemethl@gyorsposta.hu)
23 : * Davide Prina
24 : * Giuseppe Modugno
25 : * Gianluca Turconi
26 : * Simon Brouwer
27 : * Noll Janos
28 : * Biro Arpad
29 : * Goldman Eleonora
30 : * Sarlos Tamas
31 : * Bencsath Boldizsar
32 : * Halacsy Peter
33 : * Dvornik Laszlo
34 : * Gefferth Andras
35 : * Nagy Viktor
36 : * Varga Daniel
37 : * Chris Halls
38 : * Rene Engelhard
39 : * Bram Moolenaar
40 : * Dafydd Jones
41 : * Harri Pitkanen
42 : * Andras Timar
43 : * Tor Lillqvist
44 : * Jesper Kristensen (mail@jesperkristensen.dk)
45 : *
46 : * Alternatively, the contents of this file may be used under the terms of
47 : * either the GNU General Public License Version 2 or later (the "GPL"), or
48 : * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
49 : * in which case the provisions of the GPL or the LGPL are applicable instead
50 : * of those above. If you wish to allow use of your version of this file only
51 : * under the terms of either the GPL or the LGPL, and not to allow others to
52 : * use your version of this file under the terms of the MPL, indicate your
53 : * decision by deleting the provisions above and replace them with the notice
54 : * and other provisions required by the GPL or the LGPL. If you do not delete
55 : * the provisions above, a recipient may use your version of this file under
56 : * the terms of any one of the MPL, the GPL or the LGPL.
57 : *
58 : ******* END LICENSE BLOCK *******/
59 :
60 : #ifndef mozHunspell_h__
61 : #define mozHunspell_h__
62 :
63 : #include <hunspell.hxx>
64 : #include "mozISpellCheckingEngine.h"
65 : #include "mozIPersonalDictionary.h"
66 : #include "nsString.h"
67 : #include "nsCOMPtr.h"
68 : #include "nsCOMArray.h"
69 : #include "nsIObserver.h"
70 : #include "nsIUnicodeEncoder.h"
71 : #include "nsIUnicodeDecoder.h"
72 : #include "nsInterfaceHashtable.h"
73 : #include "nsWeakReference.h"
74 : #include "nsCycleCollectionParticipant.h"
75 :
76 : #define MOZ_HUNSPELL_CONTRACTID "@mozilla.org/spellchecker/engine;1"
77 : #define MOZ_HUNSPELL_CID \
78 : /* 56c778e4-1bee-45f3-a689-886692a97fe7 */ \
79 : { 0x56c778e4, 0x1bee, 0x45f3, \
80 : { 0xa6, 0x89, 0x88, 0x66, 0x92, 0xa9, 0x7f, 0xe7 } }
81 :
82 : class nsIMemoryReporter;
83 :
84 : class mozHunspell : public mozISpellCheckingEngine,
85 : public nsIObserver,
86 : public nsSupportsWeakReference
87 : {
88 : public:
89 0 : NS_DECL_CYCLE_COLLECTING_ISUPPORTS
90 : NS_DECL_MOZISPELLCHECKINGENGINE
91 : NS_DECL_NSIOBSERVER
92 1486 : NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(mozHunspell, mozISpellCheckingEngine)
93 :
94 1 : mozHunspell() : mHunspell(nsnull), mHunspellReporter(nsnull) { }
95 : virtual ~mozHunspell();
96 :
97 : nsresult Init();
98 :
99 : void LoadDictionaryList();
100 :
101 : // helper method for converting a word to the charset of the dictionary
102 : nsresult ConvertCharset(const PRUnichar* aStr, char ** aDst);
103 :
104 : protected:
105 :
106 : nsCOMPtr<mozIPersonalDictionary> mPersonalDictionary;
107 : nsCOMPtr<nsIUnicodeEncoder> mEncoder;
108 : nsCOMPtr<nsIUnicodeDecoder> mDecoder;
109 :
110 : // Hashtable matches dictionary name to .aff file
111 : nsInterfaceHashtable<nsStringHashKey, nsIFile> mDictionaries;
112 : nsString mDictionary;
113 : nsString mLanguage;
114 : nsCString mAffixFileName;
115 :
116 : // dynamic dirs used to search for dictionaries
117 : nsCOMArray<nsIFile> mDynamicDirectories;
118 :
119 : Hunspell *mHunspell;
120 :
121 : nsIMemoryReporter* mHunspellReporter;
122 : };
123 :
124 : #endif
|