extensions/spellcheck/hunspell/src/mozHunspell.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     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 *******/
    60 #ifndef mozHunspell_h__
    61 #define mozHunspell_h__
    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 "nsIUnicodeEncoder.h"
    72 #include "nsIUnicodeDecoder.h"
    73 #include "nsInterfaceHashtable.h"
    74 #include "nsWeakReference.h"
    75 #include "nsCycleCollectionParticipant.h"
    76 #include "mozHunspellAllocator.h"
    78 #define MOZ_HUNSPELL_CONTRACTID "@mozilla.org/spellchecker/engine;1"
    79 #define MOZ_HUNSPELL_CID         \
    80 /* 56c778e4-1bee-45f3-a689-886692a97fe7 */   \
    81 { 0x56c778e4, 0x1bee, 0x45f3, \
    82   { 0xa6, 0x89, 0x88, 0x66, 0x92, 0xa9, 0x7f, 0xe7 } }
    84 class mozHunspell : public mozISpellCheckingEngine,
    85                     public nsIObserver,
    86                     public nsSupportsWeakReference,
    87                     public nsIMemoryReporter
    88 {
    89 public:
    90   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
    91   NS_DECL_MOZISPELLCHECKINGENGINE
    92   NS_DECL_NSIOBSERVER
    93   NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(mozHunspell, mozISpellCheckingEngine)
    95   mozHunspell();
    96   virtual ~mozHunspell();
    98   nsresult Init();
   100   void LoadDictionaryList();
   102   // helper method for converting a word to the charset of the dictionary
   103   nsresult ConvertCharset(const char16_t* aStr, char ** aDst);
   105   NS_IMETHOD CollectReports(nsIHandleReportCallback* aHandleReport,
   106                             nsISupports* aData)
   107   {
   108     return MOZ_COLLECT_REPORT(
   109       "explicit/spell-check", KIND_HEAP, UNITS_BYTES, HunspellAllocator::MemoryAllocated(),
   110       "Memory used by the spell-checking engine.");
   111   }
   113 protected:
   115   nsCOMPtr<mozIPersonalDictionary> mPersonalDictionary;
   116   nsCOMPtr<nsIUnicodeEncoder>      mEncoder;
   117   nsCOMPtr<nsIUnicodeDecoder>      mDecoder;
   119   // Hashtable matches dictionary name to .aff file
   120   nsInterfaceHashtable<nsStringHashKey, nsIFile> mDictionaries;
   121   nsString  mDictionary;
   122   nsString  mLanguage;
   123   nsCString mAffixFileName;
   125   // dynamic dirs used to search for dictionaries
   126   nsCOMArray<nsIFile> mDynamicDirectories;
   128   Hunspell  *mHunspell;
   129 };
   131 #endif

mercurial