diff options
author | Eike Rathke <erack@redhat.com> | 2018-06-08 23:44:13 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2018-06-11 22:59:32 +0200 |
commit | e2a39848fa11dfc082ca9142266cbfe8adb586f2 (patch) | |
tree | 6b0e8e8bdf713c3ece0aa766689b7b8f773471c7 /xmloff | |
parent | ecad621f6889e8af23baa4faee62d10f580ec074 (diff) |
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@libreoffice.org>
Reviewed-by: Eike Rathke <erack@redhat.com>
(cherry picked from commit 807d4382cb021d2ac3ea99d6757a7b368a32941d)
Reviewed-on: https://gerrit.libreoffice.org/55626
Tested-by: Eike Rathke <erack@redhat.com>
Reviewed-by: László Németh <nemeth@numbertext.org>
Tested-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'xmloff')
-rw-r--r-- | xmloff/source/style/xmlnumfe.cxx | 45 |
1 files changed, 29 insertions, 16 deletions
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 |