~ubuntu-branches/ubuntu/precise/kompozer/precise

« back to all changes in this revision

Viewing changes to mozilla/intl/build/nsI18nModule.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Anthony Yarusso
  • Date: 2007-08-27 01:11:03 UTC
  • Revision ID: james.westby@ubuntu.com-20070827011103-2jgf4s6532gqu2ka
Tags: upstream-0.7.10
ImportĀ upstreamĀ versionĀ 0.7.10

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
 
2
/* ***** BEGIN LICENSE BLOCK *****
 
3
 * Version: NPL 1.1/GPL 2.0/LGPL 2.1
 
4
 *
 
5
 * The contents of this file are subject to the Netscape Public License
 
6
 * Version 1.1 (the "License"); you may not use this file except in
 
7
 * compliance with the License. You may obtain a copy of the License at
 
8
 * http://www.mozilla.org/NPL/
 
9
 *
 
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.
 
14
 *
 
15
 * The Original Code is mozilla.org code.
 
16
 *
 
17
 * The Initial Developer of the Original Code is 
 
18
 * Netscape Communications Corporation.
 
19
 * Portions created by the Initial Developer are Copyright (C) 1998
 
20
 * the Initial Developer. All Rights Reserved.
 
21
 *
 
22
 * Contributor(s):
 
23
 *
 
24
 *
 
25
 * Alternatively, the contents of this file may be used under the terms of
 
26
 * either the GNU General Public License Version 2 or later (the "GPL"), or
 
27
 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 
28
 * in which case the provisions of the GPL or the LGPL are applicable instead
 
29
 * of those above. If you wish to allow use of your version of this file only
 
30
 * under the terms of either the GPL or the LGPL, and not to allow others to
 
31
 * use your version of this file under the terms of the NPL, indicate your
 
32
 * decision by deleting the provisions above and replace them with the notice
 
33
 * and other provisions required by the GPL or the LGPL. If you do not delete
 
34
 * the provisions above, a recipient may use your version of this file under
 
35
 * the terms of any one of the NPL, the GPL or the LGPL.
 
36
 *
 
37
 * ***** END LICENSE BLOCK ***** */
 
38
 
 
39
#include "nsIGenericFactory.h"
 
40
#include "nsCOMPtr.h"
 
41
#include "nsICategoryManager.h"
 
42
#include "nsIServiceManager.h"
 
43
 
 
44
// chardet
 
45
#include "nsCharDetConstructors.h"
 
46
 
 
47
// lwbrk
 
48
#include "nsLWBrkConstructors.h"
 
49
#include "nsSemanticUnitScanner.h"
 
50
 
 
51
// unicharutil
 
52
#include "nsUcharUtilConstructors.h"
 
53
 
 
54
// string bundles (intl)
 
55
#include "nsStrBundleConstructors.h"
 
56
 
 
57
// locale
 
58
#include "nsLocaleConstructors.h"
 
59
 
 
60
 
 
61
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSemanticUnitScanner)
 
62
 
 
63
static NS_METHOD
 
64
AddCategoryEntry(const char* category,
 
65
                 const char* key,
 
66
                 const char* value)
 
67
{
 
68
  nsresult rv;
 
69
  nsCOMPtr<nsICategoryManager> 
 
70
    categoryManager(do_GetService("@mozilla.org/categorymanager;1", &rv));
 
71
  if (NS_FAILED(rv)) return rv;
 
72
  
 
73
  return categoryManager->AddCategoryEntry(category, key, value, 
 
74
                                           PR_TRUE, PR_TRUE,
 
75
                                           nsnull);
 
76
}
 
77
 
 
78
static NS_METHOD
 
79
DeleteCategoryEntry(const char* category,
 
80
                    const char* key)
 
81
{
 
82
  nsresult rv;
 
83
  nsCOMPtr<nsICategoryManager> 
 
84
    categoryManager(do_GetService("@mozilla.org/categorymanager;1", &rv));
 
85
  if (NS_FAILED(rv)) return rv;
 
86
  
 
87
  return categoryManager->DeleteCategoryEntry(category, key, PR_TRUE);
 
88
}
 
89
 
 
90
static NS_METHOD
 
91
nsMetaCharsetObserverRegistrationProc(nsIComponentManager *aCompMgr,
 
92
                                      nsIFile *aPath,
 
93
                                      const char *registryLocation,
 
94
                                      const char *componentType,
 
95
                                      const nsModuleComponentInfo *info)
 
96
{
 
97
  return AddCategoryEntry("parser-service-category", 
 
98
                          "Meta Charset Service",
 
99
                          NS_META_CHARSET_CONTRACTID);
 
100
}
 
101
 
 
102
static NS_METHOD
 
103
nsMetaCharsetObserverUnegistrationProc(nsIComponentManager *aCompMgr,
 
104
                                       nsIFile *aPath,
 
105
                                       const char *registryLocation,
 
106
                                       const nsModuleComponentInfo *info)
 
107
{
 
108
  return DeleteCategoryEntry("parser-service-category",
 
109
                             "Meta Charset Service");
 
110
}
 
111
 
 
112
static NS_METHOD
 
113
nsDetectionAdaptorRegistrationProc(nsIComponentManager *aCompMgr,
 
114
                                   nsIFile *aPath,
 
115
                                   const char *registryLocation,
 
116
                                   const char *componentType,
 
117
                                   const nsModuleComponentInfo *info)
 
118
{
 
119
  return AddCategoryEntry(NS_CHARSET_DETECTOR_CATEGORY, "off", "off");
 
120
}
 
121
 
 
122
static NS_METHOD
 
123
nsJAPSMDetectorRegistrationProc(nsIComponentManager *aCompMgr,
 
124
                                nsIFile *aPath,
 
125
                                const char *registryLocation,
 
126
                                const char *componentType,
 
127
                                const nsModuleComponentInfo *info)
 
128
{
 
129
  return AddCategoryEntry(NS_CHARSET_DETECTOR_CATEGORY,
 
130
                          "ja_parallel_state_machine",
 
131
                          info->mContractID);
 
132
}
 
133
 
 
134
static NS_METHOD
 
135
nsKOPSMDetectorRegistrationProc(nsIComponentManager *aCompMgr,
 
136
                                nsIFile *aPath,
 
137
                                const char *registryLocation,
 
138
                                const char *componentType,
 
139
                                const nsModuleComponentInfo *info)
 
140
{
 
141
  return AddCategoryEntry(NS_CHARSET_DETECTOR_CATEGORY,
 
142
                          "ko_parallel_state_machine",
 
143
                          info->mContractID);
 
144
}
 
145
 
 
146
static NS_METHOD
 
147
nsZHTWPSMDetectorRegistrationProc(nsIComponentManager *aCompMgr,
 
148
                                  nsIFile *aPath,
 
149
                                  const char *registryLocation,
 
150
                                  const char *componentType,
 
151
                                  const nsModuleComponentInfo *info)
 
152
{
 
153
  return AddCategoryEntry(NS_CHARSET_DETECTOR_CATEGORY,
 
154
                          "zhtw_parallel_state_machine",
 
155
                          info->mContractID);
 
156
}
 
157
 
 
158
static NS_METHOD
 
159
nsZHCNPSMDetectorRegistrationProc(nsIComponentManager *aCompMgr,
 
160
                                  nsIFile *aPath,
 
161
                                  const char *registryLocation,
 
162
                                  const char *componentType,
 
163
                                  const nsModuleComponentInfo *info)
 
164
{
 
165
  return AddCategoryEntry(NS_CHARSET_DETECTOR_CATEGORY,
 
166
                          "zhcn_parallel_state_machine",
 
167
                          info->mContractID);
 
168
}
 
169
 
 
170
static NS_METHOD
 
171
nsZHPSMDetectorRegistrationProc(nsIComponentManager *aCompMgr,
 
172
                                nsIFile *aPath,
 
173
                                const char *registryLocation,
 
174
                                const char *componentType,
 
175
                                const nsModuleComponentInfo *info)
 
176
{
 
177
  return AddCategoryEntry(NS_CHARSET_DETECTOR_CATEGORY,
 
178
                          "zh_parallel_state_machine",
 
179
                          info->mContractID);
 
180
}
 
181
 
 
182
static NS_METHOD
 
183
nsCJKPSMDetectorRegistrationProc(nsIComponentManager *aCompMgr,
 
184
                                 nsIFile *aPath,
 
185
                                 const char *registryLocation,
 
186
                                 const char *componentType,
 
187
                                 const nsModuleComponentInfo *info)
 
188
{
 
189
  return AddCategoryEntry(NS_CHARSET_DETECTOR_CATEGORY,
 
190
                          "cjk_parallel_state_machine",
 
191
                          info->mContractID);
 
192
}
 
193
 
 
194
static NS_METHOD
 
195
nsRUProbDetectorRegistrationProc(nsIComponentManager *aCompMgr,
 
196
                                 nsIFile *aPath,
 
197
                                 const char *registryLocation,
 
198
                                 const char *componentType,
 
199
                                 const nsModuleComponentInfo *info)
 
200
{
 
201
  return AddCategoryEntry(NS_CHARSET_DETECTOR_CATEGORY,
 
202
                          "ruprob",
 
203
                          info->mContractID);
 
204
}
 
205
 
 
206
static NS_METHOD
 
207
nsUKProbDetectorRegistrationProc(nsIComponentManager *aCompMgr,
 
208
                                 nsIFile *aPath,
 
209
                                 const char *registryLocation,
 
210
                                 const char *componentType,
 
211
                                 const nsModuleComponentInfo *info)
 
212
{
 
213
  return AddCategoryEntry(NS_CHARSET_DETECTOR_CATEGORY,
 
214
                          "ukprob",
 
215
                          info->mContractID);
 
216
}
 
217
 
 
218
 
 
219
static nsModuleComponentInfo components[] =
 
220
{
 
221
    // chardet
 
222
 { "Meta Charset", NS_META_CHARSET_CID, 
 
223
    NS_META_CHARSET_CONTRACTID, nsMetaCharsetObserverConstructor, 
 
224
    nsMetaCharsetObserverRegistrationProc, nsMetaCharsetObserverUnegistrationProc,
 
225
    NULL},
 
226
 { "Document Charset Info", NS_DOCUMENTCHARSETINFO_CID, 
 
227
    NS_DOCUMENTCHARSETINFO_CONTRACTID, nsDocumentCharsetInfoConstructor, 
 
228
    NULL, NULL},
 
229
 { "XML Encoding", NS_XML_ENCODING_CID, 
 
230
    NS_XML_ENCODING_CONTRACTID, nsXMLEncodingObserverConstructor, 
 
231
    NULL, NULL},
 
232
 { "Charset Detection Adaptor", NS_CHARSET_DETECTION_ADAPTOR_CID, 
 
233
    NS_CHARSET_DETECTION_ADAPTOR_CONTRACTID, nsDetectionAdaptorConstructor, 
 
234
    nsDetectionAdaptorRegistrationProc, NULL},
 
235
 { "PSM based Japanese Charset Detector", NS_JA_PSMDETECTOR_CID, 
 
236
    NS_CHARSET_DETECTOR_CONTRACTID_BASE "ja_parallel_state_machine", nsJAPSMDetectorConstructor, 
 
237
    nsJAPSMDetectorRegistrationProc, NULL},
 
238
 { "PSM based Japanese String Charset Detector", NS_JA_STRING_PSMDETECTOR_CID, 
 
239
    NS_STRCDETECTOR_CONTRACTID_BASE "ja_parallel_state_machine", nsJAStringPSMDetectorConstructor, 
 
240
    NULL, NULL},
 
241
 { "PSM based Korean Charset Detector", NS_KO_PSMDETECTOR_CID, 
 
242
    NS_CHARSET_DETECTOR_CONTRACTID_BASE "ko_parallel_state_machine", nsKOPSMDetectorConstructor, 
 
243
    nsKOPSMDetectorRegistrationProc, NULL},
 
244
 { "PSM based Korean String Charset Detector", NS_KO_STRING_PSMDETECTOR_CID, 
 
245
    NS_STRCDETECTOR_CONTRACTID_BASE "ko_parallel_state_machine", nsKOStringPSMDetectorConstructor, 
 
246
    NULL, NULL},
 
247
 { "PSM based Traditional Chinese Charset Detector", NS_ZHTW_PSMDETECTOR_CID, 
 
248
    NS_CHARSET_DETECTOR_CONTRACTID_BASE "zhtw_parallel_state_machine", nsZHTWPSMDetectorConstructor, 
 
249
    nsZHTWPSMDetectorRegistrationProc, NULL},
 
250
 { "PSM based Traditional Chinese String Charset Detector", NS_ZHTW_STRING_PSMDETECTOR_CID, 
 
251
    NS_STRCDETECTOR_CONTRACTID_BASE "zhtw_parallel_state_machine", nsZHTWStringPSMDetectorConstructor, 
 
252
    NULL, NULL},
 
253
 { "PSM based Simplified Chinese Charset Detector", NS_ZHCN_PSMDETECTOR_CID, 
 
254
    NS_CHARSET_DETECTOR_CONTRACTID_BASE "zhcn_parallel_state_machine", nsZHCNPSMDetectorConstructor, 
 
255
    nsZHCNPSMDetectorRegistrationProc, NULL},
 
256
 { "PSM based Simplified Chinese String Charset Detector", NS_ZHCN_STRING_PSMDETECTOR_CID, 
 
257
    NS_STRCDETECTOR_CONTRACTID_BASE "zhcn_parallel_state_machine", nsZHCNStringPSMDetectorConstructor, 
 
258
    NULL, NULL},
 
259
 { "PSM based Chinese Charset Detector", NS_ZH_PSMDETECTOR_CID, 
 
260
    NS_CHARSET_DETECTOR_CONTRACTID_BASE "zh_parallel_state_machine", nsZHPSMDetectorConstructor, 
 
261
    nsZHPSMDetectorRegistrationProc, NULL},
 
262
 { "PSM based Chinese String Charset Detector", NS_ZH_STRING_PSMDETECTOR_CID, 
 
263
    NS_STRCDETECTOR_CONTRACTID_BASE "zh_parallel_state_machine", nsZHStringPSMDetectorConstructor, 
 
264
    NULL, NULL},
 
265
 { "PSM based CJK Charset Detector", NS_CJK_PSMDETECTOR_CID, 
 
266
    NS_CHARSET_DETECTOR_CONTRACTID_BASE "cjk_parallel_state_machine", nsCJKPSMDetectorConstructor, 
 
267
    nsCJKPSMDetectorRegistrationProc, NULL},
 
268
 { "PSM based CJK String Charset Detector", NS_CJK_STRING_PSMDETECTOR_CID, 
 
269
    NS_STRCDETECTOR_CONTRACTID_BASE "cjk_parallel_state_machine", nsCJKStringPSMDetectorConstructor, 
 
270
    NULL, NULL},
 
271
 { "Probability based Russian Charset Detector", NS_RU_PROBDETECTOR_CID, 
 
272
    NS_CHARSET_DETECTOR_CONTRACTID_BASE "ruprob", nsRUProbDetectorConstructor, 
 
273
    nsRUProbDetectorRegistrationProc, NULL},
 
274
 { "Probability based Ukrainian Charset Detector", NS_UK_PROBDETECTOR_CID, 
 
275
    NS_CHARSET_DETECTOR_CONTRACTID_BASE "ukprob", nsUKProbDetectorConstructor, 
 
276
    nsUKProbDetectorRegistrationProc, NULL},
 
277
 { "Probability based Russian String Charset Detector", NS_RU_STRING_PROBDETECTOR_CID, 
 
278
    NS_STRCDETECTOR_CONTRACTID_BASE "ruprob", nsRUStringProbDetectorConstructor, 
 
279
    NULL, NULL},
 
280
 { "Probability based Ukrainian String Charset Detector", NS_UK_STRING_PROBDETECTOR_CID, 
 
281
    NS_STRCDETECTOR_CONTRACTID_BASE "ukprob", nsUKStringProbDetectorConstructor, 
 
282
   NULL, NULL},
 
283
#ifdef INCLUDE_DBGDETECTOR
 
284
 { "Debugging Detector 1st block", NS_1STBLKDBG_DETECTOR_CID, 
 
285
    NS_CHARSET_DETECTOR_CONTRACTID_BASE "1stblkdbg", ns1stBlkDbgDetectorConstructor, 
 
286
    NULL, NULL},
 
287
 { "Debugging Detector 2nd block", NS_2NDBLKDBG_DETECTOR_CID, 
 
288
    NS_CHARSET_DETECTOR_CONTRACTID_BASE "2ndblkdbg", ns2ndBlkDbgDetectorConstructor, 
 
289
    NULL, NULL},
 
290
 { "Debugging Detector Last block", NS_LASTBLKDBG_DETECTOR_CID, 
 
291
    NS_CHARSET_DETECTOR_CONTRACTID_BASE "lastblkdbg", nsLastBlkDbgDetectorConstructor, 
 
292
    NULL, NULL},
 
293
#endif /* INCLUDE_DBGDETECTOR */
 
294
 // lwbrk
 
295
  { "Line and Word Breaker", NS_LWBRK_CID,
 
296
    NS_LWBRK_CONTRACTID, nsLWBreakerFImpConstructor},
 
297
  { "Semantic Unit Scanner", NS_SEMANTICUNITSCANNER_CID,
 
298
    NS_SEMANTICUNITSCANNER_CONTRACTID, nsSemanticUnitScannerConstructor},
 
299
 
 
300
 // unicharutil
 
301
  { "Unichar Utility", NS_UNICHARUTIL_CID, 
 
302
      NS_UNICHARUTIL_CONTRACTID, nsCaseConversionImp2Constructor},
 
303
  { "Unicode To Entity Converter", NS_ENTITYCONVERTER_CID, 
 
304
      NS_ENTITYCONVERTER_CONTRACTID, nsEntityConverterConstructor },
 
305
  { "Unicode To Charset Converter", NS_SAVEASCHARSET_CID, 
 
306
      NS_SAVEASCHARSET_CONTRACTID, nsSaveAsCharsetConstructor},
 
307
  { "Japanese Hankaku To Zenkaku", NS_HANKAKUTOZENKAKU_CID, 
 
308
      NS_HANKAKUTOZENKAKU_CONTRACTID, CreateNewHankakuToZenkaku},
 
309
  { "Unicode Normlization", NS_UNICODE_NORMALIZER_CID, 
 
310
      NS_UNICODE_NORMALIZER_CONTRACTID,  nsUnicodeNormalizerConstructor},
 
311
 
 
312
 
 
313
 // strres
 
314
  { "String Bundle", NS_STRINGBUNDLESERVICE_CID, NS_STRINGBUNDLE_CONTRACTID,
 
315
    nsStringBundleServiceConstructor},
 
316
  { "String Textfile Overrides", NS_STRINGBUNDLETEXTOVERRIDE_CID,
 
317
    NS_STRINGBUNDLETEXTOVERRIDE_CONTRACTID,
 
318
    nsStringBundleTextOverrideConstructor },
 
319
 
 
320
 // locale
 
321
  { "nsLocaleService component",
 
322
    NS_LOCALESERVICE_CID,
 
323
    NS_LOCALESERVICE_CONTRACTID,
 
324
    CreateLocaleService },
 
325
  { "Collation factory",
 
326
    NS_COLLATIONFACTORY_CID,
 
327
    NS_COLLATIONFACTORY_CONTRACTID,
 
328
    nsCollationFactoryConstructor },
 
329
  { "Scriptable Date Format",
 
330
    NS_SCRIPTABLEDATEFORMAT_CID,
 
331
    NS_SCRIPTABLEDATEFORMAT_CONTRACTID,
 
332
    NS_NewScriptableDateFormat },
 
333
  { "Language Atom Service",
 
334
    NS_LANGUAGEATOMSERVICE_CID,
 
335
    NS_LANGUAGEATOMSERVICE_CONTRACTID,
 
336
    nsLanguageAtomServiceConstructor },
 
337
  { "Font Package Service",
 
338
    NS_FONTPACKAGESERVICE_CID,
 
339
    NS_FONTPACKAGESERVICE_CONTRACTID,
 
340
    nsFontPackageServiceConstructor },
 
341
 
 
342
#ifdef XP_WIN 
 
343
  { "Platform locale",
 
344
    NS_WIN32LOCALE_CID,
 
345
    NS_WIN32LOCALE_CONTRACTID,
 
346
    nsIWin32LocaleImplConstructor },
 
347
  { "Collation",
 
348
    NS_COLLATION_CID,
 
349
    NS_COLLATION_CONTRACTID,
 
350
    nsCollationWinConstructor },
 
351
  { "Date/Time formatter",
 
352
    NS_DATETIMEFORMAT_CID,
 
353
    NULL,
 
354
    nsDateTimeFormatWinConstructor },
 
355
#endif
 
356
 
 
357
#ifdef USE_UNIX_LOCALE
 
358
  { "Platform locale",
 
359
    NS_POSIXLOCALE_CID,
 
360
    NS_POSIXLOCALE_CONTRACTID,
 
361
    nsPosixLocaleConstructor },
 
362
 
 
363
  { "Collation",
 
364
    NS_COLLATION_CID,
 
365
    NS_COLLATION_CONTRACTID,
 
366
    nsCollationUnixConstructor },
 
367
 
 
368
  { "Date/Time formatter",
 
369
    NS_DATETIMEFORMAT_CID,
 
370
    NULL,
 
371
    nsDateTimeFormatUnixConstructor },
 
372
#endif
 
373
 
 
374
#ifdef USE_MAC_LOCALE
 
375
  { "Mac locale",
 
376
    NS_MACLOCALE_CID,
 
377
    NS_MACLOCALE_CONTRACTID,
 
378
    nsMacLocaleConstructor },
 
379
  { "Collation",
 
380
    NS_COLLATION_CID,
 
381
    NS_COLLATION_CONTRACTID,
 
382
#ifdef USE_UCCOLLATIONKEY
 
383
    nsCollationMacUCConstructor },
 
384
#else
 
385
    nsCollationMacConstructor },
 
386
#endif
 
387
  { "Date/Time formatter",
 
388
    NS_DATETIMEFORMAT_CID,
 
389
    NULL,
 
390
    nsDateTimeFormatMacConstructor },
 
391
#endif
 
392
 
 
393
#ifdef XP_OS2
 
394
  { "OS/2 locale",
 
395
    NS_OS2LOCALE_CID,
 
396
    NS_OS2LOCALE_CONTRACTID,
 
397
    nsOS2LocaleConstructor },
 
398
  { "Collation",
 
399
    NS_COLLATION_CID,
 
400
    NS_COLLATION_CONTRACTID,
 
401
    nsCollationOS2Constructor },
 
402
  { "Date/Time formatter",
 
403
    NS_DATETIMEFORMAT_CID,
 
404
    NULL,
 
405
    nsDateTimeFormatOS2Constructor },
 
406
#endif
 
407
      
 
408
};
 
409
 
 
410
 
 
411
NS_IMPL_NSGETMODULE(nsI18nModule, components)