2001-09-26 00:40:45 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
1999-01-21 01:28:27 +00:00
|
|
|
|
2017-03-23 04:42:00 +00:00
|
|
|
#include "nsCollationFactory.h"
|
2018-09-06 05:31:54 +00:00
|
|
|
#include "nsCollation.h"
|
2013-09-27 16:45:04 +00:00
|
|
|
#include "nsServiceManagerUtils.h"
|
2017-02-07 20:52:03 +00:00
|
|
|
#include "mozilla/intl/LocaleService.h"
|
2014-05-08 09:32:00 +00:00
|
|
|
|
1999-02-04 01:40:58 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
1999-01-21 01:28:27 +00:00
|
|
|
|
2014-04-27 07:06:00 +00:00
|
|
|
NS_IMPL_ISUPPORTS(nsCollationFactory, nsICollationFactory)
|
1999-01-21 01:28:27 +00:00
|
|
|
|
2017-02-07 20:52:03 +00:00
|
|
|
nsresult nsCollationFactory::CreateCollation(nsICollation** instancePtr) {
|
|
|
|
nsAutoCString appLocale;
|
2017-03-13 15:31:43 +00:00
|
|
|
mozilla::intl::LocaleService::GetInstance()->GetAppLocaleAsLangTag(appLocale);
|
2017-02-07 20:52:03 +00:00
|
|
|
|
|
|
|
return CreateCollationForLocale(appLocale, instancePtr);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult nsCollationFactory::CreateCollationForLocale(
|
|
|
|
const nsACString& locale, nsICollation** instancePtr) {
|
1999-01-21 01:28:27 +00:00
|
|
|
// Create a collation interface instance.
|
|
|
|
//
|
2018-09-06 05:31:54 +00:00
|
|
|
nsCOMPtr<nsICollation> inst = new nsCollation();
|
1999-01-21 01:28:27 +00:00
|
|
|
|
|
|
|
inst->Initialize(locale);
|
2017-02-07 20:52:03 +00:00
|
|
|
|
2018-09-06 05:31:54 +00:00
|
|
|
inst.forget(instancePtr);
|
1999-01-21 01:28:27 +00:00
|
|
|
|
2018-09-06 05:31:54 +00:00
|
|
|
return NS_OK;
|
1999-01-21 01:28:27 +00:00
|
|
|
}
|