Line data Source code
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 "nsIMemoryReporter.h"
70 : #include "nsIObserver.h"
71 : #include "mozilla/Encoding.h"
72 : #include "nsInterfaceHashtable.h"
73 : #include "nsWeakReference.h"
74 : #include "nsCycleCollectionParticipant.h"
75 : #include "mozHunspellAllocator.h"
76 :
77 : #define MOZ_HUNSPELL_CONTRACTID "@mozilla.org/spellchecker/engine;1"
78 : #define MOZ_HUNSPELL_CID \
79 : /* 56c778e4-1bee-45f3-a689-886692a97fe7 */ \
80 : { 0x56c778e4, 0x1bee, 0x45f3, \
81 : { 0xa6, 0x89, 0x88, 0x66, 0x92, 0xa9, 0x7f, 0xe7 } }
82 :
83 : class mozHunspell final : public mozISpellCheckingEngine,
84 : public nsIObserver,
85 : public nsSupportsWeakReference,
86 : public nsIMemoryReporter
87 : {
88 : public:
89 : NS_DECL_CYCLE_COLLECTING_ISUPPORTS
90 : NS_DECL_MOZISPELLCHECKINGENGINE
91 : NS_DECL_NSIOBSERVER
92 28 : NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(mozHunspell, mozISpellCheckingEngine)
93 :
94 : mozHunspell();
95 :
96 : nsresult Init();
97 :
98 : void LoadDictionaryList(bool aNotifyChildProcesses);
99 :
100 : // helper method for converting a word to the charset of the dictionary
101 : nsresult ConvertCharset(const char16_t* aStr, std::string* aDst);
102 :
103 : NS_DECL_NSIMEMORYREPORTER
104 :
105 : protected:
106 : virtual ~mozHunspell();
107 :
108 : nsCOMPtr<mozIPersonalDictionary> mPersonalDictionary;
109 : mozilla::UniquePtr<mozilla::Encoder> mEncoder;
110 : mozilla::UniquePtr<mozilla::Decoder> mDecoder;
111 :
112 : // Hashtable matches dictionary name to .aff file
113 : nsInterfaceHashtable<nsStringHashKey, nsIFile> mDictionaries;
114 : nsString mDictionary;
115 : nsString mLanguage;
116 : nsCString mAffixFileName;
117 :
118 : // dynamic dirs used to search for dictionaries
119 : nsCOMArray<nsIFile> mDynamicDirectories;
120 :
121 : Hunspell *mHunspell;
122 : };
123 :
124 : #endif
|