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
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"
41 #include "mozOSXSpell.h"
43 #include "mozHunspell.h"
45 #include "mozHunspellDirProvider.h"
49 #include "mozSpellChecker.h"
50 #include "mozInlineSpellChecker.h"
51 #include "nsTextServicesCID.h"
52 #include "mozPersonalDictionary.h"
53 #include "mozSpellI18NManager.h"
55 #define NS_SPELLCHECKER_CID \
56 { /* 8227f019-afc7-461e-b030-9f185d7a0e29 */ \
57 0x8227F019, 0xAFC7, 0x461e, \
58 { 0xB0, 0x30, 0x9F, 0x18, 0x5D, 0x7A, 0x0E, 0x29} }
60 #define MOZ_INLINESPELLCHECKER_CID \
61 { /* 9FE5D975-09BD-44aa-A01A-66402EA28657 */ \
62 0x9fe5d975, 0x9bd, 0x44aa, \
63 { 0xa0, 0x1a, 0x66, 0x40, 0x2e, 0xa2, 0x86, 0x57} }
65 ////////////////////////////////////////////////////////////////////////
66 // Define the constructor function for the objects
68 // NOTE: This creates an instance of objects by using the default constructor
72 NS_GENERIC_FACTORY_CONSTRUCTOR(mozOSXSpell
)
74 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(mozHunspell
, Init
)
76 NS_GENERIC_FACTORY_CONSTRUCTOR(mozHunspellDirProvider
)
80 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(mozSpellChecker
, Init
)
81 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(mozPersonalDictionary
, Init
)
82 NS_GENERIC_FACTORY_CONSTRUCTOR(mozSpellI18NManager
)
84 // This special constructor for the inline spell checker asks the inline
85 // spell checker if we can create spell checking objects at all (ie, if there
86 // are any dictionaries loaded) before trying to create one. The static
87 // CanEnableInlineSpellChecking caches the value so this will be faster (we
88 // have to run this code for every edit box we create, as well as for every
89 // right click in those edit boxes).
91 mozInlineSpellCheckerConstructor(nsISupports
*aOuter
, REFNSIID aIID
,
94 if (! mozInlineSpellChecker::CanEnableInlineSpellChecking())
95 return NS_ERROR_FAILURE
;
99 mozInlineSpellChecker
* inst
;
102 if (NULL
!= aOuter
) {
103 rv
= NS_ERROR_NO_AGGREGATION
;
107 NS_NEWXPCOM(inst
, mozInlineSpellChecker
);
109 rv
= NS_ERROR_OUT_OF_MEMORY
;
113 rv
= inst
->QueryInterface(aIID
, aResult
);
119 ////////////////////////////////////////////////////////////////////////
120 // Define a table of CIDs implemented by this module along with other
121 // information like the function to create an instance, contractid, and
124 static nsModuleComponentInfo components
[] = {
125 #ifdef MOZ_MACBROWSER
127 "OSX Spell check service",
129 MOZ_OSXSPELL_CONTRACTID
,
130 mozOSXSpellConstructor
136 MOZ_HUNSPELL_CONTRACTID
,
137 mozHunspellConstructor
141 "mozHunspellDirProvider",
142 HUNSPELLDIRPROVIDER_CID
,
143 mozHunspellDirProvider::kContractID
,
144 mozHunspellDirProviderConstructor
,
145 mozHunspellDirProvider::Register
,
146 mozHunspellDirProvider::Unregister
148 #endif // MOZ_XUL_APP
149 #endif // MOZ_MACBROWSER
153 NS_SPELLCHECKER_CONTRACTID
,
154 mozSpellCheckerConstructor
158 MOZ_PERSONALDICTIONARY_CID
,
159 MOZ_PERSONALDICTIONARY_CONTRACTID
,
160 mozPersonalDictionaryConstructor
164 MOZ_SPELLI18NMANAGER_CID
,
165 MOZ_SPELLI18NMANAGER_CONTRACTID
,
166 mozSpellI18NManagerConstructor
170 MOZ_INLINESPELLCHECKER_CID
,
171 MOZ_INLINESPELLCHECKER_CONTRACTID
,
172 mozInlineSpellCheckerConstructor
176 ////////////////////////////////////////////////////////////////////////
177 // Implement the NSGetModule() exported function for your module
178 // and the entire implementation of the module object.
180 NS_IMPL_NSGETMODULE(mozSpellCheckerModule
, components
)