Bug 1888590 - Mark some subtests on trusted-types-event-handlers.html as failing...
[gecko.git] / extensions / spellcheck / hunspell / glue / mozHunspell.h
blob89a38d9e4928dd188f919d474ed714450d3f4d8b
1 /******* BEGIN LICENSE BLOCK *******
2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
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/
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.
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.
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)
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.
58 ******* END LICENSE BLOCK *******/
60 #ifndef mozHunspell_h__
61 #define mozHunspell_h__
63 #include "RLBoxHunspell.h"
64 #include "mozISpellCheckingEngine.h"
65 #include "mozIPersonalDictionary.h"
66 #include "nsString.h"
67 #include "nsCOMPtr.h"
68 #include "nsCOMArray.h"
69 #include "nsHashKeys.h"
70 #include "nsIMemoryReporter.h"
71 #include "nsIObserver.h"
72 #include "nsIURI.h"
73 #include "mozilla/Encoding.h"
74 #include "mozilla/UniquePtr.h"
75 #include "nsInterfaceHashtable.h"
76 #include "nsWeakReference.h"
77 #include "nsTHashMap.h"
78 #include "nsCycleCollectionParticipant.h"
79 #include "mozHunspellAllocator.h"
81 #define MOZ_HUNSPELL_CONTRACTID "@mozilla.org/spellchecker/engine;1"
82 #define MOZ_HUNSPELL_CID \
83 /* 56c778e4-1bee-45f3-a689-886692a97fe7 */ \
84 { \
85 0x56c778e4, 0x1bee, 0x45f3, { \
86 0xa6, 0x89, 0x88, 0x66, 0x92, 0xa9, 0x7f, 0xe7 \
87 } \
90 class mozHunspell final : public mozISpellCheckingEngine,
91 public nsIObserver,
92 public nsSupportsWeakReference,
93 public nsIMemoryReporter {
94 public:
95 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
96 NS_DECL_MOZISPELLCHECKINGENGINE
97 NS_DECL_NSIOBSERVER
98 NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(mozHunspell, mozISpellCheckingEngine)
100 mozHunspell();
102 nsresult Init();
104 void LoadDictionaryList(bool aNotifyChildProcesses);
106 NS_DECL_NSIMEMORYREPORTER
108 protected:
109 virtual ~mozHunspell();
111 void DictionariesChanged(bool aNotifyChildProcesses);
113 nsCOMPtr<mozIPersonalDictionary> mPersonalDictionary;
115 // Hashtable matches dictionary name to .aff file
116 nsInterfaceHashtable<nsStringHashKey, nsIURI> mDictionaries;
118 // dynamic dirs used to search for dictionaries
119 nsCOMArray<nsIFile> mDynamicDirectories;
120 nsInterfaceHashtable<nsStringHashKey, nsIURI> mDynamicDictionaries;
122 struct DictionaryData {
123 // keep track of whether the dictionary is currently in use or not
124 bool mEnabled = true;
126 // keep track of whether we've failed loading this dictionary before.
127 // if set, we don't try loading it again.
128 bool mLoadFailed = false;
130 mozilla::UniquePtr<mozilla::Encoder> mEncoder;
131 mozilla::UniquePtr<mozilla::Decoder> mDecoder;
132 mozilla::UniquePtr<RLBoxHunspell> mHunspell;
133 nsCString mAffixFileName;
135 // helper method for converting a word to the charset of the dictionary
136 nsresult ConvertCharset(const nsAString& aStr, std::string& aDst);
138 // helper method to the load the dictionary if it is not already loaded
139 nsresult LoadIfNecessary();
142 nsTHashMap<nsCStringHashKey, DictionaryData> mHunspells;
145 #endif