Date: prev next · Thread: first prev next last
2013 Archives by date, by thread · List index


Hi,

I have submitted a patch for review:

    https://gerrit.libreoffice.org/3665

To pull it, you can do:

    git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/65/3665/1

introduced libi18nlangtagicu

Change-Id: Ie80e989d55d465e127ccc20290d654acf222e5bb
---
M Library_merged.mk
M Repository.mk
M RepositoryModule_host.mk
A i18nlangtag/Library_i18nlangtagicu.mk
M i18nlangtag/Module_i18nlangtag.mk
A i18nlangtag/source/languagetag/languagetagicu.cxx
M include/i18nlangtag/languagetag.hxx
A include/i18nlangtag/languagetagicu.hxx
8 files changed, 117 insertions(+), 0 deletions(-)



diff --git a/Library_merged.mk b/Library_merged.mk
index 2d5ef60..4603bda 100644
--- a/Library_merged.mk
+++ b/Library_merged.mk
@@ -33,6 +33,7 @@
        cppu \
        cppuhelper \
        i18nlangtag \
+       i18nlangtagicu \
        $(if $(filter TRUE,$(SOLAR_JAVA)), \
                jvmaccess \
                jvmfwk) \
diff --git a/Repository.mk b/Repository.mk
index 0ccc03d..2094721a 100644
--- a/Repository.mk
+++ b/Repository.mk
@@ -469,6 +469,7 @@
        deployment \
        fileacc \
        i18nlangtag \
+       i18nlangtagicu \
        i18nutil \
        mcnttype \
        package2 \
diff --git a/RepositoryModule_host.mk b/RepositoryModule_host.mk
index 1b939f1..e504cdc 100644
--- a/RepositoryModule_host.mk
+++ b/RepositoryModule_host.mk
@@ -80,6 +80,7 @@
        hwpfilter \
        $(call gb_Helper_optional,HYPHEN,hyphen) \
        i18nlangtag \
+       i18nlangtagicu \
        i18npool \
        i18nutil \
        $(call gb_Helper_optional,ICU,icu) \
diff --git a/i18nlangtag/Library_i18nlangtagicu.mk b/i18nlangtag/Library_i18nlangtagicu.mk
new file mode 100644
index 0000000..d1def1b
--- /dev/null
+++ b/i18nlangtag/Library_i18nlangtagicu.mk
@@ -0,0 +1,32 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# 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/.
+
+$(eval $(call gb_Library_Library,i18nlangtagicu))
+
+$(eval $(call gb_Library_use_sdk_api,i18nlangtagicu))
+
+$(eval $(call gb_Library_add_defs,i18nlangtagicu,\
+       -DI18NLANGTAG_DLLIMPLEMENTATION \
+))
+
+$(eval $(call gb_Library_use_libraries,i18nlangtagicu,\
+       sal \
+       i18nlangtag \
+       $(gb_UWINAPI) \
+))
+
+$(eval $(call gb_Library_use_externals,i18nlangtagicu,\
+       icu_headers \
+       icuuc \
+))
+
+$(eval $(call gb_Library_add_exception_objects,i18nlangtagicu,\
+       i18nlangtag/source/languagetag/languagetagicu \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/i18nlangtag/Module_i18nlangtag.mk b/i18nlangtag/Module_i18nlangtag.mk
index edd2e1d..22b8a7f 100644
--- a/i18nlangtag/Module_i18nlangtag.mk
+++ b/i18nlangtag/Module_i18nlangtag.mk
@@ -10,6 +10,7 @@
 
 $(eval $(call gb_Module_add_targets,i18nlangtag,\
        Library_i18nlangtag \
+       Library_i18nlangtagicu \
 ))
 
 $(eval $(call gb_Module_add_check_targets,i18nlangtag,\
diff --git a/i18nlangtag/source/languagetag/languagetagicu.cxx 
b/i18nlangtag/source/languagetag/languagetagicu.cxx
new file mode 100644
index 0000000..6f426d6
--- /dev/null
+++ b/i18nlangtag/source/languagetag/languagetagicu.cxx
@@ -0,0 +1,36 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * 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/.
+ */
+
+#include "i18nlangtag/languagetagicu.hxx"
+#include "i18nlangtag/languagetag.hxx"
+
+
+// static
+icu::Locale LanguageTagIcu::getIcuLocale( const LanguageTag & rLanguageTag )
+{
+    if (rLanguageTag.isIsoLocale())
+    {
+        // The simple case.
+        const com::sun::star::lang::Locale& rLocale = rLanguageTag.getLocale();
+        if (rLocale.Country.isEmpty())
+            return icu::Locale( OUStringToOString( rLocale.Language, 
RTL_TEXTENCODING_ASCII_US).getStr());
+        return icu::Locale(
+                OUStringToOString( rLocale.Language, RTL_TEXTENCODING_ASCII_US).getStr(),
+                OUStringToOString( rLocale.Country, RTL_TEXTENCODING_ASCII_US).getStr());
+    }
+
+    /* TODO: could we optimize this for the isIsoODF() case where only a script
+     * is added? */
+
+    // Let ICU decide how it wants a BCP47 string stuffed into its Locale.
+    return icu::Locale::createFromName(
+            OUStringToOString( rLanguageTag.getBcp47(), RTL_TEXTENCODING_ASCII_US).getStr());
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/i18nlangtag/languagetag.hxx b/include/i18nlangtag/languagetag.hxx
index e5ba011..15ca4ec 100644
--- a/include/i18nlangtag/languagetag.hxx
+++ b/include/i18nlangtag/languagetag.hxx
@@ -393,6 +393,7 @@
                                        OUString& rLanguage,
                                        OUString& rScript,
                                        OUString& rCountry );
+
 };
 
 #endif  // INCLUDED_I18NLANGTAG_LANGUAGETAG_HXX
diff --git a/include/i18nlangtag/languagetagicu.hxx b/include/i18nlangtag/languagetagicu.hxx
new file mode 100644
index 0000000..20e5349
--- /dev/null
+++ b/include/i18nlangtag/languagetagicu.hxx
@@ -0,0 +1,44 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * 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/.
+ */
+
+#ifndef INCLUDED_I18NLANGTAG_LANGUAGETAGICU_HXX
+#define INCLUDED_I18NLANGTAG_LANGUAGETAGICU_HXX
+
+#include <sal/config.h>
+#include <i18nlangtag/i18nlangtagdllapi.h>
+#include <unicode/locid.h>
+
+class LanguageTag;
+
+
+/** Interface LanguageTag to ICU's icu::Locale
+
+    Separated from LanguageTag into its own library to not pollute the entire
+    code base with ICU header file inclusion and linkage, only the few code
+    actually using this needs to link against ICU libraries, which it did
+    anyway.
+*/
+class I18NLANGTAG_DLLPUBLIC LanguageTagIcu
+{
+public:
+
+    /** Obtain language tag as ICU icu::Locale.
+
+        If the language tag is a "pure" ISO locale (see
+        LanguageTag::getLocale()) that is directly constructed, otherwise it is
+        converted using the available ICU mechanisms.
+
+        Always resolves an empty tag to the system locale.
+     */
+    static  icu::Locale     getIcuLocale( const LanguageTag & rLanguageTag );
+};
+
+#endif  // INCLUDED_I18NLANGTAG_LANGUAGETAGICU_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

-- 
To view, visit https://gerrit.libreoffice.org/3665
To unsubscribe, visit https://gerrit.libreoffice.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie80e989d55d465e127ccc20290d654acf222e5bb
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: master
Gerrit-Owner: Eike Rathke <erack@redhat.com>


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.