Line data Source code
1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* This Source Code Form is subject to the terms of the Mozilla Public
3 : * License, v. 2.0. If a copy of the MPL was not distributed with this
4 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 :
6 : #include "nsCollationFactory.h"
7 : #include "nsCollationCID.h"
8 : #include "nsServiceManagerUtils.h"
9 : #include "mozilla/intl/LocaleService.h"
10 :
11 : ////////////////////////////////////////////////////////////////////////////////
12 :
13 : NS_DEFINE_CID(kCollationCID, NS_COLLATION_CID);
14 :
15 0 : NS_IMPL_ISUPPORTS(nsCollationFactory, nsICollationFactory)
16 :
17 0 : nsresult nsCollationFactory::CreateCollation(nsICollation** instancePtr)
18 : {
19 0 : nsAutoCString appLocale;
20 0 : mozilla::intl::LocaleService::GetInstance()->GetAppLocaleAsLangTag(appLocale);
21 :
22 0 : return CreateCollationForLocale(appLocale, instancePtr);
23 : }
24 :
25 : nsresult
26 0 : nsCollationFactory::CreateCollationForLocale(const nsACString& locale, nsICollation** instancePtr)
27 : {
28 : // Create a collation interface instance.
29 : //
30 : nsICollation *inst;
31 : nsresult res;
32 :
33 0 : res = CallCreateInstance(kCollationCID, &inst);
34 0 : if (NS_FAILED(res)) {
35 0 : return res;
36 : }
37 :
38 0 : inst->Initialize(locale);
39 :
40 0 : *instancePtr = inst;
41 :
42 0 : return res;
43 : }
|