Bug 470455 - test_database_sync_embed_visits.js leaks, r=sdwilsh
[wine-gecko.git] / extensions / spellcheck / src / mozSpellCheckerFactory.cpp
blobf261253e81f16e823c0266bce84e3b7e0aa0acfb
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
15 * The Original Code is Mozilla Spellchecker Component.
17 * The Initial Developer of the Original Code is David Einstein.
18 * Portions created by the Initial Developer are Copyright (C) 2001
19 * the Initial Developer. All Rights Reserved.
21 * Contributor(s): David Einstein <Deinst@world.std.com>
23 * Alternatively, the contents of this file may be used under the terms of
24 * either the GNU General Public License Version 2 or later (the "GPL"), or
25 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
26 * in which case the provisions of the GPL or the LGPL are applicable instead
27 * of those above. If you wish to allow use of your version of this file only
28 * under the terms of either the GPL or the LGPL, and not to allow others to
29 * use your version of this file under the terms of the MPL, indicate your
30 * decision by deleting the provisions above and replace them with the notice
31 * and other provisions required by the GPL or the LGPL. If you do not delete
32 * the provisions above, a recipient may use your version of this file under
33 * the terms of any one of the MPL, the GPL or the LGPL.
35 * ***** END LICENSE BLOCK ***** */
38 #include "nsIGenericFactory.h"
40 #ifdef MOZ_MACBROWSER
41 #include "mozOSXSpell.h"
42 #else
43 #include "mozHunspell.h"
44 #include "mozHunspellDirProvider.h"
45 #endif
47 #include "mozSpellChecker.h"
48 #include "mozInlineSpellChecker.h"
49 #include "nsTextServicesCID.h"
50 #include "mozPersonalDictionary.h"
51 #include "mozSpellI18NManager.h"
53 #define NS_SPELLCHECKER_CID \
54 { /* 8227f019-afc7-461e-b030-9f185d7a0e29 */ \
55 0x8227F019, 0xAFC7, 0x461e, \
56 { 0xB0, 0x30, 0x9F, 0x18, 0x5D, 0x7A, 0x0E, 0x29} }
58 #define MOZ_INLINESPELLCHECKER_CID \
59 { /* 9FE5D975-09BD-44aa-A01A-66402EA28657 */ \
60 0x9fe5d975, 0x9bd, 0x44aa, \
61 { 0xa0, 0x1a, 0x66, 0x40, 0x2e, 0xa2, 0x86, 0x57} }
63 ////////////////////////////////////////////////////////////////////////
64 // Define the constructor function for the objects
66 // NOTE: This creates an instance of objects by using the default constructor
69 #ifdef MOZ_MACBROWSER
70 NS_GENERIC_FACTORY_CONSTRUCTOR(mozOSXSpell)
71 #else
72 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(mozHunspell, Init)
73 NS_GENERIC_FACTORY_CONSTRUCTOR(mozHunspellDirProvider)
74 #endif
76 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(mozSpellChecker, Init)
77 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(mozPersonalDictionary, Init)
78 NS_GENERIC_FACTORY_CONSTRUCTOR(mozSpellI18NManager)
80 // This special constructor for the inline spell checker asks the inline
81 // spell checker if we can create spell checking objects at all (ie, if there
82 // are any dictionaries loaded) before trying to create one. The static
83 // CanEnableInlineSpellChecking caches the value so this will be faster (we
84 // have to run this code for every edit box we create, as well as for every
85 // right click in those edit boxes).
86 static NS_IMETHODIMP
87 mozInlineSpellCheckerConstructor(nsISupports *aOuter, REFNSIID aIID,
88 void **aResult)
90 if (! mozInlineSpellChecker::CanEnableInlineSpellChecking())
91 return NS_ERROR_FAILURE;
93 nsresult rv;
95 mozInlineSpellChecker* inst;
97 *aResult = NULL;
98 if (NULL != aOuter) {
99 rv = NS_ERROR_NO_AGGREGATION;
100 return rv;
103 NS_NEWXPCOM(inst, mozInlineSpellChecker);
104 if (NULL == inst) {
105 rv = NS_ERROR_OUT_OF_MEMORY;
106 return rv;
108 NS_ADDREF(inst);
109 rv = inst->QueryInterface(aIID, aResult);
110 NS_RELEASE(inst);
112 return rv;
115 ////////////////////////////////////////////////////////////////////////
116 // Define a table of CIDs implemented by this module along with other
117 // information like the function to create an instance, contractid, and
118 // class name.
120 static nsModuleComponentInfo components[] = {
121 #ifdef MOZ_MACBROWSER
123 "OSX Spell check service",
124 MOZ_OSXSPELL_CID,
125 MOZ_OSXSPELL_CONTRACTID,
126 mozOSXSpellConstructor
128 #else
130 "mozHunspell",
131 MOZ_HUNSPELL_CID,
132 MOZ_HUNSPELL_CONTRACTID,
133 mozHunspellConstructor
136 "mozHunspellDirProvider",
137 HUNSPELLDIRPROVIDER_CID,
138 mozHunspellDirProvider::kContractID,
139 mozHunspellDirProviderConstructor,
140 mozHunspellDirProvider::Register,
141 mozHunspellDirProvider::Unregister
143 #endif // MOZ_MACBROWSER
145 NULL,
146 NS_SPELLCHECKER_CID,
147 NS_SPELLCHECKER_CONTRACTID,
148 mozSpellCheckerConstructor
151 NULL,
152 MOZ_PERSONALDICTIONARY_CID,
153 MOZ_PERSONALDICTIONARY_CONTRACTID,
154 mozPersonalDictionaryConstructor
157 NULL,
158 MOZ_SPELLI18NMANAGER_CID,
159 MOZ_SPELLI18NMANAGER_CONTRACTID,
160 mozSpellI18NManagerConstructor
163 NULL,
164 MOZ_INLINESPELLCHECKER_CID,
165 MOZ_INLINESPELLCHECKER_CONTRACTID,
166 mozInlineSpellCheckerConstructor
170 ////////////////////////////////////////////////////////////////////////
171 // Implement the NSGetModule() exported function for your module
172 // and the entire implementation of the module object.
174 NS_IMPL_NSGETMODULE(mozSpellCheckerModule, components)