[Libreoffice-commits] core.git: Branch 'libreoffice-6-1' - 2 commits - i18npool/source include/svl include/xmloff offapi/com offapi/UnoApi_offapi.mk svl/source xmloff/source

Eike Rathke erack at redhat.com
Mon Jun 11 20:59:47 UTC 2018


 i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx |    5 
 i18npool/source/nativenumber/nativenumbersupplier.cxx                 |    9 -
 include/svl/zformat.hxx                                               |    3 
 include/xmloff/xmltoken.hxx                                           |    3 
 offapi/UnoApi_offapi.mk                                               |    1 
 offapi/com/sun/star/i18n/NativeNumberXmlAttributes2.idl               |   59 ++++++++++
 offapi/com/sun/star/i18n/XNativeNumberSupplier2.idl                   |    2 
 svl/source/numbers/zformat.cxx                                        |   36 +++++-
 xmloff/source/core/xmltoken.cxx                                       |    3 
 xmloff/source/style/xmlnumfe.cxx                                      |   34 +++++
 xmloff/source/style/xmlnumfi.cxx                                      |   47 +++++--
 xmloff/source/token/tokens.txt                                        |    2 
 12 files changed, 171 insertions(+), 33 deletions(-)

New commits:
commit e2a39848fa11dfc082ca9142266cbfe8adb586f2
Author: Eike Rathke <erack at redhat.com>
Date:   Fri Jun 8 23:44:13 2018 +0200

    Derive NativeNumberXmlAttributes2 from NativeNumberXmlAttributes, tdf#115007 follow-up
    
    Also ensure that transliteration-spellout and
    (transliteration-format,transliteration-style) are mutually
    exclusive and transliteration-spellout is only written if ODF
    version is >1.2, namespace 'loext' for 1.2 with extensions and
    namespace 'number' in anticipation of ODF 1.3 (may need to be
    adapted).
    
    Change-Id: I371dee8883ecb0d4638510c92b4bf59acd09f636
    Reviewed-on: https://gerrit.libreoffice.org/55491
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Eike Rathke <erack at redhat.com>
    (cherry picked from commit 807d4382cb021d2ac3ea99d6757a7b368a32941d)
    Reviewed-on: https://gerrit.libreoffice.org/55626
    Tested-by: Eike Rathke <erack at redhat.com>
    Reviewed-by: László Németh <nemeth at numbertext.org>
    Tested-by: László Németh <nemeth at numbertext.org>

diff --git a/include/svl/zformat.hxx b/include/svl/zformat.hxx
index 59c3a293d5b3..6357be2cea9d 100644
--- a/include/svl/zformat.hxx
+++ b/include/svl/zformat.hxx
@@ -436,8 +436,7 @@ public:
 
     // rAttr.Number not empty if NatNum attributes are to be stored
     void GetNatNumXml(
-            css::i18n::NativeNumberXmlAttributes& rAttr,
-            css::i18n::NativeNumberXmlAttributes2& rAttr2,
+            css::i18n::NativeNumberXmlAttributes2& rAttr,
             sal_uInt16 nNumFor ) const;
 
     /** Switches to the first non-"gregorian" calendar, but only if the current
diff --git a/offapi/com/sun/star/i18n/NativeNumberXmlAttributes2.idl b/offapi/com/sun/star/i18n/NativeNumberXmlAttributes2.idl
index 34dbc9cc6e1d..d8c8fb225dd2 100644
--- a/offapi/com/sun/star/i18n/NativeNumberXmlAttributes2.idl
+++ b/offapi/com/sun/star/i18n/NativeNumberXmlAttributes2.idl
@@ -20,7 +20,7 @@
 #ifndef __com_sun_star_i18n_NativeNumberXmlAttributes_idl__
 #define __com_sun_star_i18n_NativeNumberXmlAttributes_idl__
 
-#include <com/sun/star/lang/Locale.idl>
+#include <com/sun/star/i18n/NativeNumberXmlAttributes.idl>
 
 
 module com { module sun { module star { module i18n {
@@ -39,16 +39,13 @@ module com { module sun { module star { module i18n {
 
     @internal
 
-    ATTENTION: This service is marked <em>internal</em> and does not
+    ATTENTION: This struct 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.
  */
 
-struct NativeNumberXmlAttributes2
+struct NativeNumberXmlAttributes2 : com::sun::star::i18n::NativeNumberXmlAttributes
 {
-    /// The locale of the native number representation
-    ::com::sun::star::lang::Locale  Locale;
-
     /** The format of the number string, for example, "cardinal",
         "ordinal" or "ordinal-number". */
     string  Spellout;
diff --git a/offapi/com/sun/star/i18n/XNativeNumberSupplier2.idl b/offapi/com/sun/star/i18n/XNativeNumberSupplier2.idl
index 08c0d37ce663..17a1df082c9f 100644
--- a/offapi/com/sun/star/i18n/XNativeNumberSupplier2.idl
+++ b/offapi/com/sun/star/i18n/XNativeNumberSupplier2.idl
@@ -33,7 +33,7 @@ module com { module sun { module star { module i18n {
 
     @internal
 
-    ATTENTION: This service is marked <em>internal</em> and does not
+    ATTENTION: This interface 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.
  */
diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx
index 02ac08c7dfc5..e24ef037f7ba 100644
--- a/svl/source/numbers/zformat.cxx
+++ b/svl/source/numbers/zformat.cxx
@@ -5392,8 +5392,7 @@ void SvNumberformat::impTransliterateImpl(OUStringBuffer& rStr,
     rStr.append(sTemp);
 }
 
-void SvNumberformat::GetNatNumXml( css::i18n::NativeNumberXmlAttributes& rAttr,
-                                   css::i18n::NativeNumberXmlAttributes2& rAttr2,
+void SvNumberformat::GetNatNumXml( css::i18n::NativeNumberXmlAttributes2& rAttr,
                                    sal_uInt16 nNumFor ) const
 {
     if ( nNumFor <= 3 )
@@ -5404,23 +5403,37 @@ void SvNumberformat::GetNatNumXml( css::i18n::NativeNumberXmlAttributes& rAttr,
             css::lang::Locale aLocale(
                     LanguageTag( rNum.GetLang() ).getLocale() );
 
+            /* TODO: a new XNativeNumberSupplier2::convertToXmlAttributes()
+             * should rather return NativeNumberXmlAttributes2 and places
+             * adapted, and whether to fill Spellout or something different
+             * should be internal there. */
+            css::i18n::NativeNumberXmlAttributes aTmp(
+                    GetFormatter().GetNatNum()->convertToXmlAttributes(
+                        aLocale, rNum.GetNatNum()));
+            rAttr.Locale = aTmp.Locale;
+            rAttr.Format = aTmp.Format;
+            rAttr.Style = aTmp.Style;
             if ( NatNumTakesParameters(rNum.GetNatNum()) )
             {
                 // NatNum12 spell out numbers, dates and money amounts
-                rAttr2 = css::i18n::NativeNumberXmlAttributes2(aLocale, rNum.GetParams());
-            } else {
-                rAttr = GetFormatter().GetNatNum()->convertToXmlAttributes(
-                    aLocale, rNum.GetNatNum() );
+                rAttr.Spellout = rNum.GetParams();
+                // Mutually exclusive.
+                rAttr.Format.clear();
+                rAttr.Style.clear();
+            }
+            else
+            {
+                rAttr.Spellout.clear();
             }
         }
         else
         {
-            rAttr = css::i18n::NativeNumberXmlAttributes();
+            rAttr = css::i18n::NativeNumberXmlAttributes2();
         }
     }
     else
     {
-        rAttr = css::i18n::NativeNumberXmlAttributes();
+        rAttr = css::i18n::NativeNumberXmlAttributes2();
     }
 }
 
diff --git a/xmloff/source/style/xmlnumfe.cxx b/xmloff/source/style/xmlnumfe.cxx
index 56a5d168cb64..7001328ab196 100644
--- a/xmloff/source/style/xmlnumfe.cxx
+++ b/xmloff/source/style/xmlnumfe.cxx
@@ -32,7 +32,6 @@
 #include <tools/color.hxx>
 #include <sax/tools/converter.hxx>
 
-#include <com/sun/star/i18n/NativeNumberXmlAttributes.hpp>
 #include <com/sun/star/i18n/NativeNumberXmlAttributes2.hpp>
 
 #include <xmloff/xmlnumfe.hxx>
@@ -1191,11 +1190,12 @@ void SvXMLNumFmtExport::ExportPart_Impl( const SvNumberformat& rFormat, sal_uInt
     }
 
     // Native number transliteration
-    css::i18n::NativeNumberXmlAttributes aAttr;
-    css::i18n::NativeNumberXmlAttributes2 aAttr2;
-    rFormat.GetNatNumXml( aAttr, aAttr2, nPart );
+    css::i18n::NativeNumberXmlAttributes2 aAttr;
+    rFormat.GetNatNumXml( aAttr, nPart );
     if ( !aAttr.Format.isEmpty() )
     {
+        assert(aAttr.Spellout.isEmpty());   // mutually exclusive
+
         /* FIXME-BCP47: ODF defines no transliteration-script or
          * transliteration-rfc-language-tag */
         LanguageTag aLanguageTag( aAttr.Locale);
@@ -1211,19 +1211,32 @@ void SvXMLNumFmtExport::ExportPart_Impl( const SvNumberformat& rFormat, sal_uInt
                               aAttr.Style );
     }
 
-    if ( !aAttr2.Spellout.isEmpty() )
+    if ( !aAttr.Spellout.isEmpty() )
     {
-        /* FIXME-BCP47: ODF defines no transliteration-script or
-         * transliteration-rfc-language-tag */
-        LanguageTag aLanguageTag( aAttr2.Locale);
-        OUString aLanguage, aScript, aCountry;
-        aLanguageTag.getIsoLanguageScriptCountry( aLanguage, aScript, aCountry);
-        rExport.AddAttribute( XML_NAMESPACE_LO_EXT, XML_TRANSLITERATION_SPELLOUT,
-                              aAttr2.Spellout );
-        rExport.AddAttribute( XML_NAMESPACE_NUMBER, XML_TRANSLITERATION_LANGUAGE,
-                              aLanguage );
-        rExport.AddAttribute( XML_NAMESPACE_NUMBER, XML_TRANSLITERATION_COUNTRY,
-                              aCountry );
+        const bool bWriteSpellout = aAttr.Format.isEmpty();
+        assert(bWriteSpellout);     // mutually exclusive
+
+        // Export only for 1.2 with extensions or 1.3 and later.
+        SvtSaveOptions::ODFSaneDefaultVersion eVersion = rExport.getSaneDefaultVersion();
+        // Also ensure that duplicated transliteration-language and
+        // transliteration-country attributes never escape into the wild with
+        // releases.
+        if (eVersion > SvtSaveOptions::ODFSVER_012 && bWriteSpellout)
+        {
+            /* FIXME-BCP47: ODF defines no transliteration-script or
+             * transliteration-rfc-language-tag */
+            LanguageTag aLanguageTag( aAttr.Locale);
+            OUString aLanguage, aScript, aCountry;
+            aLanguageTag.getIsoLanguageScriptCountry( aLanguage, aScript, aCountry);
+            // For 1.2+ use loext namespace, for 1.3 use number namespace.
+            rExport.AddAttribute( ((eVersion < SvtSaveOptions::ODFSVER_013) ?
+                        XML_NAMESPACE_LO_EXT : XML_NAMESPACE_NUMBER),
+                    XML_TRANSLITERATION_SPELLOUT, aAttr.Spellout );
+            rExport.AddAttribute( XML_NAMESPACE_NUMBER, XML_TRANSLITERATION_LANGUAGE,
+                                  aLanguage );
+            rExport.AddAttribute( XML_NAMESPACE_NUMBER, XML_TRANSLITERATION_COUNTRY,
+                                  aCountry );
+        }
     }
 
     // The element
commit ecad621f6889e8af23baa4faee62d10f580ec074
Author: László Németh <nemeth at numbertext.org>
Date:   Wed May 30 17:28:17 2018 +0200

    tdf#115007: add import/export to NatNum12 (spell out numbers,
    
    dates and money amounts, supporting all the
    XNumberText/libnumbertext formatting codes, for example
    "ordinal", "ordinal-number", "ordinal-feminine", etc., and
    ISO 4217 currency codes, also their possible combinations.
    NatNum12 formatting codes are stored by using the newly
    introduced (yet, loext:)transliteration-spellout attribute.
    
    creator-initials also added to token list
    
    Change-Id: I20f93c9d16778f142067a56d53b336d0acbe2d92
    Reviewed-on: https://gerrit.libreoffice.org/54673
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: László Németh <nemeth at numbertext.org>
    (cherry picked from commit 32f1c56d8ff5e6f87dbcf086fd3743d6d36182bc)
    Reviewed-on: https://gerrit.libreoffice.org/55625
    Reviewed-by: Eike Rathke <erack at redhat.com>
    Tested-by: László Németh <nemeth at numbertext.org>

diff --git a/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx b/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx
index 45a222ce9efd..d363407c19fe 100644
--- a/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx
+++ b/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx
@@ -642,12 +642,13 @@ DefaultNumberingProvider::makeNumberingString( const Sequence<beans::PropertyVal
                locale = aLocale;
                bCapitalize = true;
                break;
-          case TEXT_CARDINAL: // cardinal number names (one, two, three, ...)
+          case TEXT_CARDINAL: // cardinal number names (One, Two, Three, ...)
                natNum = NativeNumberMode::NATNUM12;
+               sNatNumParams = "cardinal";
                locale = aLocale;
                bCapitalize = true;
                break;
-          case TEXT_ORDINAL: // ordinal number names (first, second, third, ...)
+          case TEXT_ORDINAL: // ordinal number names (First, Second, Third, ...)
                natNum = NativeNumberMode::NATNUM12;
                sNatNumParams = "ordinal";
                locale = aLocale;
diff --git a/i18npool/source/nativenumber/nativenumbersupplier.cxx b/i18npool/source/nativenumber/nativenumbersupplier.cxx
index 0de111165adc..a18d8c7c798a 100644
--- a/i18npool/source/nativenumber/nativenumbersupplier.cxx
+++ b/i18npool/source/nativenumber/nativenumbersupplier.cxx
@@ -598,9 +598,10 @@ OUString getNumberText(const Locale& rLocale, const OUString& rNumberString,
 
     static auto xNumberText
         = css::linguistic2::NumberText::create(comphelper::getProcessComponentContext());
-    OUString numbertext_prefix = sNumberTextParams;
-    if (!numbertext_prefix.isEmpty())
-        numbertext_prefix += " ";
+    OUString numbertext_prefix;
+    // default "cardinal" gets empty prefix
+    if (sNumberTextParams != "cardinal")
+        numbertext_prefix = sNumberTextParams + " ";
     // 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.
@@ -777,7 +778,7 @@ sal_Bool SAL_CALL NativeNumberSupplierService::isValidNatNum( const Locale& rLoc
     switch (nNativeNumberMode) {
         case NativeNumberMode::NATNUM0:     // Ascii
         case NativeNumberMode::NATNUM3:     // Char, FullWidth
-        case NativeNumberMode::NATNUM12:    // Spell number
+        case NativeNumberMode::NATNUM12:    // spell out numbers, dates and money amounts
             return true;
         case NativeNumberMode::NATNUM1:     // Char, Lower
             return (langnum >= 0);
diff --git a/include/svl/zformat.hxx b/include/svl/zformat.hxx
index 92a8080e3383..59c3a293d5b3 100644
--- a/include/svl/zformat.hxx
+++ b/include/svl/zformat.hxx
@@ -24,6 +24,7 @@
 #include <svl/zforlist.hxx>
 #include <svl/nfkeytab.hxx>
 #include <vector>
+#include <com/sun/star/i18n/NativeNumberXmlAttributes2.hpp>
 
 namespace utl {
     class DigitGroupingIterator;
@@ -436,6 +437,7 @@ public:
     // rAttr.Number not empty if NatNum attributes are to be stored
     void GetNatNumXml(
             css::i18n::NativeNumberXmlAttributes& rAttr,
+            css::i18n::NativeNumberXmlAttributes2& rAttr2,
             sal_uInt16 nNumFor ) const;
 
     /** Switches to the first non-"gregorian" calendar, but only if the current
diff --git a/include/xmloff/xmltoken.hxx b/include/xmloff/xmltoken.hxx
index 6ab3cdd217f5..5a1cd6157887 100644
--- a/include/xmloff/xmltoken.hxx
+++ b/include/xmloff/xmltoken.hxx
@@ -3316,6 +3316,9 @@ namespace xmloff { namespace token {
 
         XML_CREATOR_INITIALS,
 
+        // tdf#115007
+        XML_TRANSLITERATION_SPELLOUT,
+
         XML_TOKEN_END
     };
 
diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk
index bd8932463c12..93a76c5908a2 100644
--- a/offapi/UnoApi_offapi.mk
+++ b/offapi/UnoApi_offapi.mk
@@ -2753,6 +2753,7 @@ $(eval $(call gb_UnoApi_add_idlfiles,offapi,com/sun/star/i18n,\
 	MultipleCharsOutputException \
 	NativeNumberMode \
 	NativeNumberXmlAttributes \
+	NativeNumberXmlAttributes2 \
 	NumberFormatCode \
 	NumberFormatIndex \
 	ParseResult \
diff --git a/offapi/com/sun/star/i18n/NativeNumberXmlAttributes2.idl b/offapi/com/sun/star/i18n/NativeNumberXmlAttributes2.idl
new file mode 100644
index 000000000000..34dbc9cc6e1d
--- /dev/null
+++ b/offapi/com/sun/star/i18n/NativeNumberXmlAttributes2.idl
@@ -0,0 +1,62 @@
+/* -*- 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_NativeNumberXmlAttributes_idl__
+#define __com_sun_star_i18n_NativeNumberXmlAttributes_idl__
+
+#include <com/sun/star/lang/Locale.idl>
+
+
+module com { module sun { module star { module i18n {
+
+
+/**
+    Attributes describing a native number mode for a specific locale,
+    stored in XML file format.
+
+    <p> Used later with
+    XNativeNumberSupplier2::convertToXmlAttributes() and
+    XNativeNumberSupplier2::convertFromXmlAttributes()
+    </p>
+
+    @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.
+ */
+
+struct NativeNumberXmlAttributes2
+{
+    /// The locale of the native number representation
+    ::com::sun::star::lang::Locale  Locale;
+
+    /** The format of the number string, for example, "cardinal",
+        "ordinal" or "ordinal-number". */
+    string  Spellout;
+
+};
+
+}; }; }; };
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx
index c9bcf82a88c6..02ac08c7dfc5 100644
--- a/svl/source/numbers/zformat.cxx
+++ b/svl/source/numbers/zformat.cxx
@@ -952,8 +952,11 @@ SvNumberformat::SvNumberformat(OUString& rString,
                         }
                         sStr = "NatNum" + OUString::number(nNum);
                         NumFor[nIndex].SetNatNumNum( nNum, false );
-                        if (!sParams.isEmpty())
+                        // NatNum12 supports arguments
+                        if (nNum == 12)
                         {
+                            if (sParams.isEmpty())
+                                sParams = "cardinal"; // default NatNum12 format is "cardinal"
                             NumFor[nIndex].SetNatNumParams(sParams);
                             sStr += " " + sParams;
                         }
@@ -5390,6 +5393,7 @@ void SvNumberformat::impTransliterateImpl(OUStringBuffer& rStr,
 }
 
 void SvNumberformat::GetNatNumXml( css::i18n::NativeNumberXmlAttributes& rAttr,
+                                   css::i18n::NativeNumberXmlAttributes2& rAttr2,
                                    sal_uInt16 nNumFor ) const
 {
     if ( nNumFor <= 3 )
@@ -5399,8 +5403,15 @@ void SvNumberformat::GetNatNumXml( css::i18n::NativeNumberXmlAttributes& rAttr,
         {
             css::lang::Locale aLocale(
                     LanguageTag( rNum.GetLang() ).getLocale() );
-            rAttr = GetFormatter().GetNatNum()->convertToXmlAttributes(
+
+            if ( NatNumTakesParameters(rNum.GetNatNum()) )
+            {
+                // NatNum12 spell out numbers, dates and money amounts
+                rAttr2 = css::i18n::NativeNumberXmlAttributes2(aLocale, rNum.GetParams());
+            } else {
+                rAttr = GetFormatter().GetNatNum()->convertToXmlAttributes(
                     aLocale, rNum.GetNatNum() );
+            }
         }
         else
         {
diff --git a/xmloff/source/core/xmltoken.cxx b/xmloff/source/core/xmltoken.cxx
index 019c0bb19308..d9e221bf34b2 100644
--- a/xmloff/source/core/xmltoken.cxx
+++ b/xmloff/source/core/xmltoken.cxx
@@ -3308,6 +3308,9 @@ namespace xmloff { namespace token {
         TOKEN( "newline",                         XML_NEWLINE ),
         TOKEN( "creator-initials",                XML_CREATOR_INITIALS ),
 
+        // tdf#115007 spell out numbers, dates, money amounts and cross references
+        TOKEN( "transliteration-spellout",         XML_TRANSLITERATION_SPELLOUT ),
+
 #if OSL_DEBUG_LEVEL > 0
         { 0, nullptr, nullptr,                       XML_TOKEN_END }
 #else
diff --git a/xmloff/source/style/xmlnumfe.cxx b/xmloff/source/style/xmlnumfe.cxx
index 99366b9800fc..56a5d168cb64 100644
--- a/xmloff/source/style/xmlnumfe.cxx
+++ b/xmloff/source/style/xmlnumfe.cxx
@@ -33,6 +33,7 @@
 #include <sax/tools/converter.hxx>
 
 #include <com/sun/star/i18n/NativeNumberXmlAttributes.hpp>
+#include <com/sun/star/i18n/NativeNumberXmlAttributes2.hpp>
 
 #include <xmloff/xmlnumfe.hxx>
 #include <xmloff/xmlnmspe.hxx>
@@ -1191,7 +1192,8 @@ void SvXMLNumFmtExport::ExportPart_Impl( const SvNumberformat& rFormat, sal_uInt
 
     // Native number transliteration
     css::i18n::NativeNumberXmlAttributes aAttr;
-    rFormat.GetNatNumXml( aAttr, nPart );
+    css::i18n::NativeNumberXmlAttributes2 aAttr2;
+    rFormat.GetNatNumXml( aAttr, aAttr2, nPart );
     if ( !aAttr.Format.isEmpty() )
     {
         /* FIXME-BCP47: ODF defines no transliteration-script or
@@ -1209,6 +1211,21 @@ void SvXMLNumFmtExport::ExportPart_Impl( const SvNumberformat& rFormat, sal_uInt
                               aAttr.Style );
     }
 
+    if ( !aAttr2.Spellout.isEmpty() )
+    {
+        /* FIXME-BCP47: ODF defines no transliteration-script or
+         * transliteration-rfc-language-tag */
+        LanguageTag aLanguageTag( aAttr2.Locale);
+        OUString aLanguage, aScript, aCountry;
+        aLanguageTag.getIsoLanguageScriptCountry( aLanguage, aScript, aCountry);
+        rExport.AddAttribute( XML_NAMESPACE_LO_EXT, XML_TRANSLITERATION_SPELLOUT,
+                              aAttr2.Spellout );
+        rExport.AddAttribute( XML_NAMESPACE_NUMBER, XML_TRANSLITERATION_LANGUAGE,
+                              aLanguage );
+        rExport.AddAttribute( XML_NAMESPACE_NUMBER, XML_TRANSLITERATION_COUNTRY,
+                              aCountry );
+    }
+
     // The element
     SvXMLElementExport aElem( rExport, XML_NAMESPACE_NUMBER, eType,
                               true, true );
diff --git a/xmloff/source/style/xmlnumfi.cxx b/xmloff/source/style/xmlnumfi.cxx
index 037d38c2d15a..63cb90af60a8 100644
--- a/xmloff/source/style/xmlnumfi.cxx
+++ b/xmloff/source/style/xmlnumfi.cxx
@@ -246,7 +246,8 @@ enum SvXMLStyleAttrTokens
     XML_TOK_STYLE_ATTR_TRANSL_FORMAT,
     XML_TOK_STYLE_ATTR_TRANSL_LANGUAGE,
     XML_TOK_STYLE_ATTR_TRANSL_COUNTRY,
-    XML_TOK_STYLE_ATTR_TRANSL_STYLE
+    XML_TOK_STYLE_ATTR_TRANSL_STYLE,
+    XML_TOK_STYLE_ATTR_TRANSL_SPELLOUT
 };
 
 enum SvXMLStyleElemAttrTokens
@@ -524,6 +525,8 @@ const SvXMLTokenMap& SvXMLNumImpData::GetStyleAttrTokenMap()
             // not defined in ODF { XML_NAMESPACE_NUMBER, XML_TRANSLITERATION_SCRIPT,     XML_TOK_STYLE_ATTR_TRANSL_SCRIPT    },
             { XML_NAMESPACE_NUMBER, XML_TRANSLITERATION_COUNTRY,    XML_TOK_STYLE_ATTR_TRANSL_COUNTRY   },
             { XML_NAMESPACE_NUMBER, XML_TRANSLITERATION_STYLE,      XML_TOK_STYLE_ATTR_TRANSL_STYLE     },
+            { XML_NAMESPACE_LO_EXT, XML_TRANSLITERATION_SPELLOUT,    XML_TOK_STYLE_ATTR_TRANSL_SPELLOUT   },
+            { XML_NAMESPACE_NUMBER, XML_TRANSLITERATION_SPELLOUT,    XML_TOK_STYLE_ATTR_TRANSL_SPELLOUT   },
             XML_TOKEN_MAP_END
         };
 
@@ -1395,6 +1398,7 @@ SvXMLNumFormatContext::SvXMLNumFormatContext( SvXMLImport& rImport,
 {
     LanguageTagODF aLanguageTagODF;
     css::i18n::NativeNumberXmlAttributes aNatNumAttr;
+    OUString aSpellout;
     bool bAttrBool(false);
 
     sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
@@ -1446,6 +1450,9 @@ SvXMLNumFormatContext::SvXMLNumFormatContext( SvXMLImport& rImport,
             case XML_TOK_STYLE_ATTR_TRANSL_FORMAT:
                 aNatNumAttr.Format = sValue;
                 break;
+            case XML_TOK_STYLE_ATTR_TRANSL_SPELLOUT:
+                aSpellout = sValue;
+                break;
             case XML_TOK_STYLE_ATTR_TRANSL_LANGUAGE:
                 aNatNumAttr.Locale.Language = sValue;
                 break;
@@ -1465,30 +1472,36 @@ SvXMLNumFormatContext::SvXMLNumFormatContext( SvXMLImport& rImport,
             nFormatLang = LANGUAGE_SYSTEM;          //! error handling for unknown locales?
     }
 
-    if ( !aNatNumAttr.Format.isEmpty() )
+    if ( !aNatNumAttr.Format.isEmpty() || !aSpellout.isEmpty() )
     {
-        SvNumberFormatter* pFormatter = pData->GetNumberFormatter();
-        if ( pFormatter )
-        {
-            LanguageTag aLanguageTag( OUString(), aNatNumAttr.Locale.Language,
+        LanguageTag aLanguageTag( OUString(), aNatNumAttr.Locale.Language,
                     OUString(), aNatNumAttr.Locale.Country);
-            aNatNumAttr.Locale = aLanguageTag.getLocale( false);
+        aNatNumAttr.Locale = aLanguageTag.getLocale( false);
+
+        // NatNum12 spell out formula (cardinal, ordinal, ordinal-feminine etc.)
+        if ( !aSpellout.isEmpty() )
+        {
+            aFormatCode.append( "[NatNum12 " );
+            aFormatCode.append( aSpellout );
+        } else {
+            SvNumberFormatter* pFormatter = pData->GetNumberFormatter();
+            if ( !pFormatter ) return;
 
             sal_Int32 nNatNum = pFormatter->GetNatNum()->convertFromXmlAttributes( aNatNumAttr );
             aFormatCode.append( "[NatNum" );
             aFormatCode.append( nNatNum );
+        }
 
-            LanguageType eLang = aLanguageTag.getLanguageType( false);
-            if ( eLang == LANGUAGE_DONTKNOW )
-                eLang = LANGUAGE_SYSTEM;            //! error handling for unknown locales?
-            if ( eLang != nFormatLang && eLang != LANGUAGE_SYSTEM )
-            {
-                aFormatCode.append( "][$-" );
-                // language code in upper hex:
-                aFormatCode.append(OUString::number(static_cast<sal_uInt16>(eLang), 16).toAsciiUpperCase());
-            }
-            aFormatCode.append( ']' );
+        LanguageType eLang = aLanguageTag.getLanguageType( false );
+        if ( eLang == LANGUAGE_DONTKNOW )
+            eLang = LANGUAGE_SYSTEM;            //! error handling for unknown locales?
+        if ( eLang != nFormatLang && eLang != LANGUAGE_SYSTEM )
+        {
+            aFormatCode.append( "][$-" );
+            // language code in upper hex:
+            aFormatCode.append(OUString::number(static_cast<sal_uInt16>(eLang), 16).toAsciiUpperCase());
         }
+        aFormatCode.append( ']' );
     }
 }
 
diff --git a/xmloff/source/token/tokens.txt b/xmloff/source/token/tokens.txt
index 04275393f2bc..095b21a8c46f 100644
--- a/xmloff/source/token/tokens.txt
+++ b/xmloff/source/token/tokens.txt
@@ -3079,4 +3079,6 @@ zeros-denominator-digits
 integer-fraction-delimiter
 reference-language
 newline
+creator-initials
+transliteration-spellout
 TOKEN_END_DUMMY


More information about the Libreoffice-commits mailing list