i18npool/inc/nativenumbersupplier.hxx                                 |   17 +-
 i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx |   19 +-
 i18npool/source/nativenumber/nativenumbersupplier.cxx                 |   44 
+++---
 i18npool/util/i18npool.component                                      |    1 
 include/svl/zformat.hxx                                               |    6 
 include/unotools/nativenumberwrapper.hxx                              |   12 +
 offapi/UnoApi_offapi.mk                                               |    2 
 offapi/com/sun/star/i18n/NativeNumberMode.idl                         |   13 -
 offapi/com/sun/star/i18n/NativeNumberSupplier2.idl                    |   45 
++++++
 offapi/com/sun/star/i18n/XNativeNumberSupplier2.idl                   |   69 
++++++++++
 svl/qa/unit/svl.cxx                                                   |    4 
 svl/source/numbers/zformat.cxx                                        |   35 
++++-
 unotools/source/i18n/nativenumberwrapper.cxx                          |   28 
+++-
 13 files changed, 237 insertions(+), 58 deletions(-)

New commits:
commit 90d233b0311a208967a3e264820e00395bf057fb
Author: Mike Kaganski <mike.kagan...@collabora.com>
Date:   Sun May 13 03:09:43 2018 +0300

    tdf#115007: Use [NatNum12 params...] syntax
    
    This allows using all the libnumbertext library functions.
    
    [NatNum12] gives cardinal number names (one, two, three, ...)
    [NatNum12 ordinal] gives ordinal number names (first, second, third, ...)
    [NatNum12 ordinal-number] gives ordinal indicators (1st, 2nd, 3rd, ...)
    [NatNum12 money USD][$-409] gives formal English (US) money text
    ... etc (see numbertext.org for syntax).
    
    Change-Id: I16dbb44d8d4bdb82a1b950de6d438c8311b554ff
    Reviewed-on: https://gerrit.libreoffice.org/54366
    Tested-by: Jenkins <c...@libreoffice.org>
    Reviewed-by: László Németh <nem...@numbertext.org>

diff --git a/i18npool/inc/nativenumbersupplier.hxx 
b/i18npool/inc/nativenumbersupplier.hxx
index e248a1812004..d17c39fe7490 100644
--- a/i18npool/inc/nativenumbersupplier.hxx
+++ b/i18npool/inc/nativenumbersupplier.hxx
@@ -19,7 +19,7 @@
 #ifndef INCLUDED_I18NPOOL_INC_NATIVENUMBERSUPPLIER_HXX
 #define INCLUDED_I18NPOOL_INC_NATIVENUMBERSUPPLIER_HXX
 
-#include <com/sun/star/i18n/XNativeNumberSupplier.hpp>
+#include <com/sun/star/i18n/XNativeNumberSupplier2.hpp>
 #include <com/sun/star/i18n/NativeNumberMode.hpp>
 #include <com/sun/star/i18n/NativeNumberXmlAttributes.hpp>
 #include <cppuhelper/implbase.hxx>
@@ -32,7 +32,7 @@ namespace i18npool {
 //      ----------------------------------------------------
 class NativeNumberSupplierService : public cppu::WeakImplHelper
 <
-        css::i18n::XNativeNumberSupplier,
+        css::i18n::XNativeNumberSupplier2,
         css::lang::XServiceInfo
 >
 {
@@ -52,6 +52,11 @@ public:
         virtual sal_Int16 SAL_CALL convertFromXmlAttributes(
                 const css::i18n::NativeNumberXmlAttributes& aAttr ) override;
 
+        // XNativeNumberSupplier2
+        virtual OUString SAL_CALL getNativeNumberStringParams(
+            const OUString& rNumberString, const css::lang::Locale& rLocale,
+            sal_Int16 nNativeNumberMode, const OUString& rNativeNumberParams) 
override;
+
         //XServiceInfo
         virtual OUString SAL_CALL getImplementationName() override;
         virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) 
override;
@@ -59,9 +64,11 @@ public:
 
         // following methods are not for XNativeNumberSupplier, they are for 
calling from transliterations
         /// @throws css::uno::RuntimeException
-        OUString getNativeNumberString( const OUString& aNumberString,
-                const css::lang::Locale& aLocale, sal_Int16 nNativeNumberMode,
-                css::uno::Sequence< sal_Int32 >& offset  );
+        OUString getNativeNumberString(const OUString& rNumberString,
+                                       const css::lang::Locale& rLocale,
+                                       sal_Int16 nNativeNumberMode,
+                                       css::uno::Sequence<sal_Int32>& offset,
+                                       const OUString& rNativeNumberParams = 
OUString());
         /// @throws css::uno::RuntimeException
         sal_Unicode getNativeNumberChar( const sal_Unicode inChar,
                 const css::lang::Locale& aLocale, sal_Int16 nNativeNumberMode 
) ;
diff --git 
a/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx 
b/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx
index af4e27d0f69f..45a222ce9efd 100644
--- a/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx
+++ b/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx
@@ -585,6 +585,7 @@ DefaultNumberingProvider::makeNumberingString( const 
Sequence<beans::PropertyVal
      const sal_Unicode *table = nullptr;     // initialize to avoid compiler 
warning
      bool bRecycleSymbol = false;
      bool bCapitalize = false;
+     OUString sNatNumParams;
      Locale locale;
 
      OUString  prefix;
@@ -635,18 +636,20 @@ DefaultNumberingProvider::makeNumberingString( const 
Sequence<beans::PropertyVal
           case CHARS_LOWER_LETTER:
                lcl_formatChars( lowerLetter, 26, number-1, result );
                break;
-          case TEXT_NUMBER:
-               natNum = NativeNumberMode::NATNUM14; // ordinal indicators 
(1st, 2nd, 3rd, ...)
+          case TEXT_NUMBER: // ordinal indicators (1st, 2nd, 3rd, ...)
+               natNum = NativeNumberMode::NATNUM12;
+               sNatNumParams = "ordinal-number";
                locale = aLocale;
                bCapitalize = true;
                break;
-          case TEXT_CARDINAL:
-               natNum = NativeNumberMode::NATNUM12; // cardinal number names 
(one, two, three, ...)
+          case TEXT_CARDINAL: // cardinal number names (one, two, three, ...)
+               natNum = NativeNumberMode::NATNUM12;
                locale = aLocale;
                bCapitalize = true;
                break;
-          case TEXT_ORDINAL:
-               natNum = NativeNumberMode::NATNUM13; // ordinal number names 
(first, second, third, ...)
+          case TEXT_ORDINAL: // ordinal number names (first, second, third, 
...)
+               natNum = NativeNumberMode::NATNUM12;
+               sNatNumParams = "ordinal";
                locale = aLocale;
                bCapitalize = true;
                break;
@@ -909,8 +912,8 @@ DefaultNumberingProvider::makeNumberingString( const 
Sequence<beans::PropertyVal
 
         if (natNum) {
             rtl::Reference<NativeNumberSupplierService> xNatNum(new 
NativeNumberSupplierService);
-            OUString aNum
-                = xNatNum->getNativeNumberString(OUString::number(number), 
locale, natNum);
+            OUString aNum = 
xNatNum->getNativeNumberStringParams(OUString::number(number), locale,
+                                                                 natNum, 
sNatNumParams);
             if (bCapitalize)
             {
                 if (!xCharClass.is())
diff --git a/i18npool/source/nativenumber/nativenumbersupplier.cxx 
b/i18npool/source/nativenumber/nativenumbersupplier.cxx
index b25007969e38..025cd0d897eb 100644
--- a/i18npool/source/nativenumber/nativenumbersupplier.cxx
+++ b/i18npool/source/nativenumber/nativenumbersupplier.cxx
@@ -556,17 +556,15 @@ Separators getLocaleSeparators(const Locale& rLocale, 
const OUString& rLocStr)
     return it->second;
 }
 
-OUString getNumberText(const Locale& aLocale, sal_Int16 numType, const 
OUString& rNumberString)
+OUString getNumberText(const Locale& rLocale, const OUString& rNumberString,
+                       const OUString& sNumberTextParams)
 {
-    assert(numType == NativeNumberMode::NATNUM12 || numType == 
NativeNumberMode::NATNUM13
-           || numType == NativeNumberMode::NATNUM14);
-
     sal_Int32 i, count = 0;
     const sal_Int32 len = rNumberString.getLength();
     const sal_Unicode* src = rNumberString.getStr();
 
-    OUString aLoc = LanguageTag::convertToBcp47(aLocale);
-    Separators aSeparators = getLocaleSeparators(aLocale, aLoc);
+    OUString aLoc = LanguageTag::convertToBcp47(rLocale);
+    Separators aSeparators = getLocaleSeparators(rLocale, aLoc);
 
     OUStringBuffer sBuf(len);
     for (i = 0; i < len; i++)
@@ -599,11 +597,9 @@ OUString getNumberText(const Locale& aLocale, sal_Int16 
numType, const OUString&
 
     static auto xNumberText
         = 
css::linguistic2::NumberText::create(comphelper::getProcessComponentContext());
-    OUString numbertext_prefix;
-    if (numType == NativeNumberMode::NATNUM14)
-        numbertext_prefix = "ordinal-number ";
-    else if (numType == NativeNumberMode::NATNUM13)
-        numbertext_prefix = "ordinal ";
+    OUString numbertext_prefix = sNumberTextParams;
+    if (!numbertext_prefix.isEmpty())
+        numbertext_prefix += " ";
     // Several hundreds of headings could result typing lags because
     // of the continuous update of the multiple number names during typing.
     // We fix this by buffering the result of the conversion.
@@ -612,7 +608,7 @@ OUString getNumberText(const Locale& aLocale, sal_Int16 
numType, const OUString&
     auto& rItem = rItems[numbertext_prefix + aLoc];
     if (rItem.isEmpty())
     {
-        rItem = xNumberText->getNumberText(numbertext_prefix + aNumberStr, 
aLocale);
+        rItem = xNumberText->getNumberText(numbertext_prefix + aNumberStr, 
rLocale);
         // use number at missing number to text conversion
         if (rItem.isEmpty())
             rItem = aNumberStr;
@@ -625,15 +621,15 @@ OUString getNumberText(const Locale& aLocale, sal_Int16 
numType, const OUString&
 }
 
 OUString NativeNumberSupplierService::getNativeNumberString(const OUString& 
aNumberString, const Locale& rLocale,
-                sal_Int16 nNativeNumberMode, Sequence< sal_Int32 >& offset)
+                                                            sal_Int16 
nNativeNumberMode,
+                                                            
Sequence<sal_Int32>& offset,
+                                                            const OUString& 
rNativeNumberParams)
 {
     if (!isValidNatNum(rLocale, nNativeNumberMode))
         return aNumberString;
 
-    if (nNativeNumberMode == NativeNumberMode::NATNUM12
-        || nNativeNumberMode == NativeNumberMode::NATNUM13
-        || nNativeNumberMode == NativeNumberMode::NATNUM14)
-        return getNumberText(rLocale, nNativeNumberMode, aNumberString);
+    if (nNativeNumberMode == NativeNumberMode::NATNUM12)
+        return getNumberText(rLocale, aNumberString, rNativeNumberParams);
 
     sal_Int16 langnum = getLanguageNumber(rLocale);
     if (langnum == -1)
@@ -721,6 +717,14 @@ OUString SAL_CALL 
NativeNumberSupplierService::getNativeNumberString(const OUStr
     return getNativeNumberString(aNumberString, rLocale, nNativeNumberMode, 
offset);
 }
 
+OUString SAL_CALL NativeNumberSupplierService::getNativeNumberStringParams(
+    const OUString& rNumberString, const css::lang::Locale& rLocale, sal_Int16 
nNativeNumberMode,
+    const OUString& rNativeNumberParams)
+{
+    Sequence<sal_Int32> offset;
+    return getNativeNumberString(rNumberString, rLocale, nNativeNumberMode, 
offset, rNativeNumberParams);
+}
+
 sal_Unicode NativeNumberSupplierService::getNativeNumberChar( const 
sal_Unicode inChar, const Locale& rLocale, sal_Int16 nNativeNumberMode )
 {
     if (nNativeNumberMode == NativeNumberMode::NATNUM0) { // Ascii
@@ -772,9 +776,7 @@ sal_Bool SAL_CALL 
NativeNumberSupplierService::isValidNatNum( const Locale& rLoc
     switch (nNativeNumberMode) {
         case NativeNumberMode::NATNUM0:     // Ascii
         case NativeNumberMode::NATNUM3:     // Char, FullWidth
-        case NativeNumberMode::NATNUM12:    // Cardinal number names (one, 
two, three, ...)
-        case NativeNumberMode::NATNUM13:    // Ordinal number names (first, 
second, third, ...)
-        case NativeNumberMode::NATNUM14:    // Ordinal indicators (1st, 2nd, 
3rd, ...)
+        case NativeNumberMode::NATNUM12:    // Spell number
             return true;
         case NativeNumberMode::NATNUM1:     // Char, Lower
             return (langnum >= 0);
@@ -1157,7 +1159,7 @@ NativeNumberSupplierService::supportsService(const 
OUString& rServiceName)
 Sequence< OUString > SAL_CALL
 NativeNumberSupplierService::getSupportedServiceNames()
 {
-    Sequence< OUString > aRet {implementationName};
+    Sequence< OUString > aRet {implementationName, 
"com.sun.star.i18n.NativeNumberSupplier2"};
     return aRet;
 }
 
diff --git a/i18npool/util/i18npool.component b/i18npool/util/i18npool.component
index 3598ffa8b781..d4e7ea7b0a35 100644
--- a/i18npool/util/i18npool.component
+++ b/i18npool/util/i18npool.component
@@ -133,6 +133,7 @@
   <implementation name="com.sun.star.i18n.NativeNumberSupplier"
       constructor="com_sun_star_i18n_NativeNumberSupplier_get_implementation">
     <service name="com.sun.star.i18n.NativeNumberSupplier"/>
+    <service name="com.sun.star.i18n.NativeNumberSupplier2"/>
   </implementation>
   <implementation name="com.sun.star.i18n.NumberFormatCodeMapper"
       
constructor="com_sun_star_i18n_NumberFormatCodeMapper_get_implementation">
diff --git a/include/svl/zformat.hxx b/include/svl/zformat.hxx
index 33b5bf8b2062..92a8080e3383 100644
--- a/include/svl/zformat.hxx
+++ b/include/svl/zformat.hxx
@@ -64,7 +64,8 @@ struct ImpSvNumberformatInfo            // Struct for 
FormatInfo
 // eLang specifies the Locale to use.
 class SvNumberNatNum
 {
-    LanguageType    eLang;
+    OUString sParams;               // For [NatNum12 ordinal-number]-like 
syntax
+    LanguageType eLang;
     sal_uInt8            nNum;
     bool            bDBNum  :1;     // DBNum, to be converted to NatNum
     bool            bDate   :1;     // Used in date? (needed for DBNum/NatNum 
mapping)
@@ -90,6 +91,8 @@ public:
                         }
     bool            IsSet() const       { return bSet; }
     void            SetDate( bool bDateP )   { bDate = bDateP; }
+    void            SetParams(const OUString& s) { sParams = s; }
+    OUString        GetParams() const { return sParams; }
 };
 
 class CharClass;
@@ -125,6 +128,7 @@ public:
     void SetNatNumNum( sal_uInt8 nNum, bool bDBNum ) { aNatNum.SetNum( nNum, 
bDBNum ); }
     void SetNatNumLang( LanguageType eLang ) { aNatNum.SetLang( eLang ); }
     void SetNatNumDate( bool bDate ) { aNatNum.SetDate( bDate ); }
+    void SetNatNumParams(const OUString& sParams) { 
aNatNum.SetParams(sParams); }
     const SvNumberNatNum& GetNatNum() const { return aNatNum; }
 
 private:
diff --git a/include/unotools/nativenumberwrapper.hxx 
b/include/unotools/nativenumberwrapper.hxx
index 064a438a85ef..be699f216d8b 100644
--- a/include/unotools/nativenumberwrapper.hxx
+++ b/include/unotools/nativenumberwrapper.hxx
@@ -21,7 +21,7 @@
 #define INCLUDED_UNOTOOLS_NATIVENUMBERWRAPPER_HXX
 
 #include <unotools/unotoolsdllapi.h>
-#include <com/sun/star/i18n/XNativeNumberSupplier.hpp>
+#include <com/sun/star/i18n/XNativeNumberSupplier2.hpp>
 
 namespace com { namespace sun { namespace star {
     namespace uno {
@@ -31,7 +31,7 @@ namespace com { namespace sun { namespace star {
 
 class UNOTOOLS_DLLPUBLIC NativeNumberWrapper
 {
-    css::uno::Reference< css::i18n::XNativeNumberSupplier >   xNNS;
+    css::uno::Reference< css::i18n::XNativeNumberSupplier2 >   xNNS;
                                 NativeNumberWrapper( const 
NativeNumberWrapper& ) = delete;
             NativeNumberWrapper&    operator=( const NativeNumberWrapper& ) = 
delete;
 
@@ -47,7 +47,13 @@ public:
     OUString getNativeNumberString(
                         const OUString& rNumberString,
                         const css::lang::Locale& rLocale,
-                        sal_Int16 nNativeNumberMode ) const;
+                        sal_Int16 nNativeNumberMode) const;
+
+    OUString getNativeNumberStringParams(
+                        const OUString& rNumberString,
+                        const css::lang::Locale& rLocale,
+                        sal_Int16 nNativeNumberMode,
+                        const OUString& rNativeNumberParams) const;
 
     css::i18n::NativeNumberXmlAttributes convertToXmlAttributes(
                         const css::lang::Locale& rLocale,
diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk
index e25fc4495805..bd8932463c12 100644
--- a/offapi/UnoApi_offapi.mk
+++ b/offapi/UnoApi_offapi.mk
@@ -232,6 +232,7 @@ $(eval $(call 
gb_UnoApi_add_idlfiles_nohdl,offapi,com/sun/star/i18n,\
        LocaleData \
        LocaleData2 \
        NativeNumberSupplier \
+       NativeNumberSupplier2 \
        NumberFormatMapper \
        OrdinalSuffix \
        TextConversion \
@@ -2788,6 +2789,7 @@ $(eval $(call 
gb_UnoApi_add_idlfiles,offapi,com/sun/star/i18n,\
        XLocaleData4 \
        XLocaleData5 \
        XNativeNumberSupplier \
+       XNativeNumberSupplier2 \
        XNumberFormatCode \
        XOrdinalSuffix \
        XScriptTypeDetector \
diff --git a/offapi/com/sun/star/i18n/NativeNumberMode.idl 
b/offapi/com/sun/star/i18n/NativeNumberMode.idl
index f19980b96edc..8fbf058f3e12 100644
--- a/offapi/com/sun/star/i18n/NativeNumberMode.idl
+++ b/offapi/com/sun/star/i18n/NativeNumberMode.idl
@@ -146,17 +146,12 @@ published constants NativeNumberMode
       */
     const short NATNUM11    = 11;
 
-    /** Transliteration to cardinal number names (one, two, three, ...)
+    /** Transliteration to cardinal number names (one, two, three, ...),
+        ordinal number names (first, second, third, ...),
+        ordinal indicators (1st, 2nd, 3rd, ...), etc.
+        Uses NatNum params string
      */
     const short NATNUM12 = 12;
-
-    /** Transliteration to ordinal number names (first, second, third, ...)
-     */
-    const short NATNUM13 = 13;
-
-    /** Transliteration to ordinal indicators (1st, 2nd, 3rd, ...)
-     */
-    const short NATNUM14 = 14;
 };
 
 }; }; }; };
diff --git a/offapi/com/sun/star/i18n/NativeNumberSupplier2.idl 
b/offapi/com/sun/star/i18n/NativeNumberSupplier2.idl
new file mode 100644
index 000000000000..721c1642afda
--- /dev/null
+++ b/offapi/com/sun/star/i18n/NativeNumberSupplier2.idl
@@ -0,0 +1,45 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef __com_sun_star_i18n_NativeNumberSupplier2_idl__
+#define __com_sun_star_i18n_NativeNumberSupplier2_idl__
+
+#include <com/sun/star/i18n/XNativeNumberSupplier2.idl>
+
+
+module com { module sun { module star { module i18n {
+
+
+/** Supplier for transliteration of numerals (native number strings).
+
+    @since LibreOffice 6.1
+
+    @internal
+
+    ATTENTION: This service is marked <em>internal</em> and does not
+    have the <em>published</em> flag, which means it is subject to
+    change without notice and should not be used outside the LibreOffice core.
+*/
+service NativeNumberSupplier2 : com::sun::star::i18n::XNativeNumberSupplier2;
+
+}; }; }; };
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/offapi/com/sun/star/i18n/XNativeNumberSupplier2.idl 
b/offapi/com/sun/star/i18n/XNativeNumberSupplier2.idl
new file mode 100644
index 000000000000..08c0d37ce663
--- /dev/null
+++ b/offapi/com/sun/star/i18n/XNativeNumberSupplier2.idl
@@ -0,0 +1,69 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef __com_sun_star_i18n_XNativeNumberSupplier2_idl__
+#define __com_sun_star_i18n_XNativeNumberSupplier2_idl__
+
+#include <com/sun/star/i18n/XNativeNumberSupplier.idl>
+
+
+module com { module sun { module star { module i18n {
+
+
+/** Methods to convert between strings of ASCII Arabic digits and native
+    numeral strings, using NatNum params.
+
+    @since LibreOffice 6.1
+
+    @internal
+
+    ATTENTION: This service is marked <em>internal</em> and does not
+    have the <em>published</em> flag, which means it is subject to
+    change without notice and should not be used outside the LibreOffice core.
+ */
+
+interface XNativeNumberSupplier2 : 
::com::sun::star::i18n::XNativeNumberSupplier
+{
+    /** Returns native number string for given number string, using NatNum 
params.
+
+        @param NumberString
+            The input string.
+
+        @param NativeNumberMode
+            One of NativeNumberMode values.
+
+        @param Locale
+            The locale.
+
+        @param NativeNumberParams
+            The NatNum params (like "ordinal-digits" in [NatNum12 
ordinal-digits]).
+     */
+    string getNativeNumberStringParams(
+                    [in] string NumberString,
+                    [in] ::com::sun::star::lang::Locale Locale,
+                    [in] short NativeNumberMode,
+                    [in] string NativeNumberParameters );
+
+};
+
+}; }; }; };
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svl/qa/unit/svl.cxx b/svl/qa/unit/svl.cxx
index 6dea21f05883..45bff9ef2ca1 100644
--- a/svl/qa/unit/svl.cxx
+++ b/svl/qa/unit/svl.cxx
@@ -1388,10 +1388,10 @@ void Test::testUserDefinedNumberFormats()
         sCode = "[NatNum12]0.00";
         sExpected = "one hundred twenty-three point four five";
         checkPreviewString(aFormatter, sCode, 123.45, eLang, sExpected);
-        sCode = "[NatNum13]0";
+        sCode = "[NatNum12 ordinal]0";
         sExpected = "one hundred twenty-third";
         checkPreviewString(aFormatter, sCode, 123, eLang, sExpected);
-        sCode = "[NatNum14]0";
+        sCode = "[NatNum12 ordinal-number]0";
         sExpected = "123rd";
         checkPreviewString(aFormatter, sCode, 123, eLang, sExpected);
 #endif
diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx
index 07c9bf2b70cd..eb2f6c7aece2 100644
--- a/svl/source/numbers/zformat.cxx
+++ b/svl/source/numbers/zformat.cxx
@@ -33,6 +33,7 @@
 #include <com/sun/star/i18n/CalendarDisplayIndex.hpp>
 #include <com/sun/star/i18n/CalendarDisplayCode.hpp>
 #include <com/sun/star/i18n/AmPmValue.hpp>
+#include <com/sun/star/i18n/NativeNumberMode.hpp>
 
 #include <svl/zformat.hxx>
 #include "zforscan.hxx"
@@ -751,6 +752,13 @@ OUString SvNumberformat::ImpObtainCalendarAndNumerals( 
OUStringBuffer& rString,
     return sCalendar;
 }
 
+namespace
+{
+bool NatNumTakesParameters(sal_Int16 nNum)
+{
+    return (nNum == css::i18n::NativeNumberMode::NATNUM12);
+}
+}
 
 SvNumberformat::SvNumberformat(OUString& rString,
                                ImpSvNumberformatScan* pSc,
@@ -928,11 +936,27 @@ SvNumberformat::SvNumberformat(OUString& rString,
                     }
                     else
                     {
-                        sStr = "NatNum";
+                        OUString sParams;
+                        sal_Int32 nSpacePos = sStr.indexOf(' ');
+                        if (nSpacePos >= 0)
+                        {
+                            sParams = sStr.copy(nSpacePos+1).trim();
+                        }
                         //! eSymbolType is negative
                         sal_uInt8 nNum = static_cast<sal_uInt8>(0 - 
(eSymbolType - BRACKET_SYMBOLTYPE_NATNUM0));
-                        sStr += OUString::number( nNum );
+                        if (!sParams.isEmpty() && !NatNumTakesParameters(nNum))
+                        {
+                            bCancel = true; // break for
+                            nCheckPos = nPosOld;
+                            break;
+                        }
+                        sStr = "NatNum" + OUString::number(nNum);
                         NumFor[nIndex].SetNatNumNum( nNum, false );
+                        if (!sParams.isEmpty())
+                        {
+                            NumFor[nIndex].SetNatNumParams(sParams);
+                            sStr += " " + sParams;
+                        }
                     }
                     break;
                 case BRACKET_SYMBOLTYPE_DBNUM1 :
@@ -5350,8 +5374,8 @@ OUString SvNumberformat::impTransliterateImpl(const 
OUString& rStr,
                                               const SvNumberNatNum& rNum ) 
const
 {
     css::lang::Locale aLocale( LanguageTag( rNum.GetLang() ).getLocale() );
-    return GetFormatter().GetNatNum()->getNativeNumberString( rStr,
-                                                              aLocale, 
rNum.GetNatNum() );
+    return GetFormatter().GetNatNum()->getNativeNumberStringParams(rStr, 
aLocale, rNum.GetNatNum(),
+                                                                   
rNum.GetParams());
 }
 
 void SvNumberformat::impTransliterateImpl(OUStringBuffer& rStr,
@@ -5360,7 +5384,8 @@ void SvNumberformat::impTransliterateImpl(OUStringBuffer& 
rStr,
     css::lang::Locale aLocale( LanguageTag( rNum.GetLang() ).getLocale() );
 
     OUString sTemp(rStr.makeStringAndClear());
-    sTemp = GetFormatter().GetNatNum()->getNativeNumberString( sTemp, aLocale, 
rNum.GetNatNum() );
+    sTemp = GetFormatter().GetNatNum()->getNativeNumberStringParams(
+        sTemp, aLocale, rNum.GetNatNum(), rNum.GetParams());
     rStr.append(sTemp);
 }
 
diff --git a/unotools/source/i18n/nativenumberwrapper.cxx 
b/unotools/source/i18n/nativenumberwrapper.cxx
index 102e765d4275..26fcbd7fa32f 100644
--- a/unotools/source/i18n/nativenumberwrapper.cxx
+++ b/unotools/source/i18n/nativenumberwrapper.cxx
@@ -21,7 +21,7 @@
 
 #include <sal/log.hxx>
 #include <unotools/nativenumberwrapper.hxx>
-#include <com/sun/star/i18n/NativeNumberSupplier.hpp>
+#include <com/sun/star/i18n/NativeNumberSupplier2.hpp>
 
 using namespace ::com::sun::star;
 
@@ -29,7 +29,7 @@ NativeNumberWrapper::NativeNumberWrapper(
             const uno::Reference< uno::XComponentContext > & rxContext
             )
 {
-    xNNS = i18n::NativeNumberSupplier::create(rxContext);
+    xNNS = i18n::NativeNumberSupplier2::create(rxContext);
 }
 
 NativeNumberWrapper::~NativeNumberWrapper()
@@ -40,12 +40,12 @@ OUString
 NativeNumberWrapper::getNativeNumberString(
                     const OUString& rNumberString,
                     const css::lang::Locale& rLocale,
-                    sal_Int16 nNativeNumberMode ) const
+                    sal_Int16 nNativeNumberMode) const
 {
     try
     {
         if ( xNNS.is() )
-            return xNNS->getNativeNumberString( rNumberString, rLocale, 
nNativeNumberMode );
+            return xNNS->getNativeNumberString(rNumberString, rLocale, 
nNativeNumberMode);
     }
     catch ( const uno::Exception& )
     {
@@ -54,6 +54,26 @@ NativeNumberWrapper::getNativeNumberString(
     return OUString();
 }
 
+OUString
+NativeNumberWrapper::getNativeNumberStringParams(
+                    const OUString& rNumberString,
+                    const css::lang::Locale& rLocale,
+                    sal_Int16 nNativeNumberMode,
+                    const OUString& rNativeNumberParams) const
+{
+    try
+    {
+        if ( xNNS.is() )
+            return xNNS->getNativeNumberStringParams(rNumberString, rLocale, 
nNativeNumberMode,
+                                                     rNativeNumberParams);
+    }
+    catch ( const uno::Exception& )
+    {
+        SAL_WARN( "unotools.i18n", "getNativeNumberStringParams: Exception 
caught!" );
+    }
+    return OUString();
+}
+
 i18n::NativeNumberXmlAttributes
 NativeNumberWrapper::convertToXmlAttributes(
                     const css::lang::Locale& rLocale,
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to