Back to index

lightning-sunbird  0.9+nobinonly
mozSpellCheckerFactory.cpp
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is Mozilla Spellchecker Component.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * David Einstein.
00019  * Portions created by the Initial Developer are Copyright (C) 2001
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s): David Einstein <Deinst@world.std.com>
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either the GNU General Public License Version 2 or later (the "GPL"), or
00026  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 
00038 
00039 #include "nsIGenericFactory.h"
00040 
00041 #include "mozSpellChecker.h"
00042 #include "mozInlineSpellChecker.h"
00043 #include "nsTextServicesCID.h"
00044 #include "mozPersonalDictionary.h"
00045 #include "mozSpellI18NManager.h"
00046 
00047 #define NS_SPELLCHECKER_CID         \
00048 { /* 8227f019-afc7-461e-b030-9f185d7a0e29 */    \
00049 0x8227F019, 0xAFC7, 0x461e,                     \
00050 { 0xB0, 0x30, 0x9F, 0x18, 0x5D, 0x7A, 0x0E, 0x29} }
00051 
00052 #define MOZ_INLINESPELLCHECKER_CID         \
00053 { /* 9FE5D975-09BD-44aa-A01A-66402EA28657 */    \
00054 0x9fe5d975, 0x9bd, 0x44aa,                      \
00055 { 0xa0, 0x1a, 0x66, 0x40, 0x2e, 0xa2, 0x86, 0x57} }
00056 
00058 // Define the contructor function for the objects
00059 //
00060 // NOTE: This creates an instance of objects by using the default constructor
00061 //
00062 
00063 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(mozSpellChecker, Init)
00064 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(mozPersonalDictionary, Init)
00065 NS_GENERIC_FACTORY_CONSTRUCTOR(mozSpellI18NManager)
00066 
00067 // This special constructor for the inline spell checker asks the inline
00068 // spell checker if we can create spell checking objects at all (ie, if there
00069 // are any dictionaries loaded) before trying to create one. The static
00070 // CanEnableInlineSpellChecking caches the value so this will be faster (we
00071 // have to run this code for every edit box we create, as well as for every
00072 // right click in those edit boxes).
00073 static NS_IMETHODIMP
00074 mozInlineSpellCheckerConstructor(nsISupports *aOuter, REFNSIID aIID,
00075                                  void **aResult)
00076 {
00077   if (! mozInlineSpellChecker::CanEnableInlineSpellChecking())
00078     return NS_ERROR_FAILURE;
00079 
00080   nsresult rv;
00081 
00082   mozInlineSpellChecker* inst;
00083 
00084   *aResult = NULL;
00085   if (NULL != aOuter) {
00086     rv = NS_ERROR_NO_AGGREGATION;
00087     return rv;
00088   }
00089 
00090   NS_NEWXPCOM(inst, mozInlineSpellChecker);
00091   if (NULL == inst) {
00092     rv = NS_ERROR_OUT_OF_MEMORY;
00093     return rv;
00094   }
00095   NS_ADDREF(inst);
00096   rv = inst->QueryInterface(aIID, aResult);
00097   NS_RELEASE(inst);
00098 
00099   return rv;
00100 }
00101 
00103 // Define a table of CIDs implemented by this module along with other
00104 // information like the function to create an instance, contractid, and
00105 // class name.
00106 //
00107 static nsModuleComponentInfo components[] = {
00108   { NULL, NS_SPELLCHECKER_CID, NS_SPELLCHECKER_CONTRACTID, mozSpellCheckerConstructor },
00109   { NULL, MOZ_PERSONALDICTIONARY_CID, MOZ_PERSONALDICTIONARY_CONTRACTID, mozPersonalDictionaryConstructor },
00110   { NULL, MOZ_SPELLI18NMANAGER_CID, MOZ_SPELLI18NMANAGER_CONTRACTID, mozSpellI18NManagerConstructor },
00111   { NULL, MOZ_INLINESPELLCHECKER_CID, MOZ_INLINESPELLCHECKER_CONTRACTID, mozInlineSpellCheckerConstructor }
00112 };
00113 
00115 // Implement the NSGetModule() exported function for your module
00116 // and the entire implementation of the module object.
00117 //
00118 NS_IMPL_NSGETMODULE(mozSpellCheckerModule, components)