summaryrefslogtreecommitdiff
path: root/xmlscript
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2013-07-12 12:29:45 +0200
committerEike Rathke <erack@redhat.com>2013-07-12 12:32:34 +0200
commit6c88ebe9aaf32b5c7c6e22270ee90091c019f567 (patch)
tree2f98c051a4379d835e92667bbd94f143350e85cf /xmlscript
parent76d36d5bba2712c1c98548e73ca9fb82e11b0cca (diff)
write bcp47 format-locale if necessary and read both
Change-Id: I82cfdd8652d1c86b701ccb0b913928c860a360d2
Diffstat (limited to 'xmlscript')
-rw-r--r--xmlscript/Library_xmlscript.mk1
-rw-r--r--xmlscript/source/xmldlg_imexp/xmldlg_export.cxx26
-rw-r--r--xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx12
3 files changed, 24 insertions, 15 deletions
diff --git a/xmlscript/Library_xmlscript.mk b/xmlscript/Library_xmlscript.mk
index fa680d17bb38..640b561612f1 100644
--- a/xmlscript/Library_xmlscript.mk
+++ b/xmlscript/Library_xmlscript.mk
@@ -21,6 +21,7 @@ $(eval $(call gb_Library_use_libraries,xmlscript,\
cppuhelper \
sal \
tl \
+ i18nlangtag \
$(gb_UWINAPI) \
))
diff --git a/xmlscript/source/xmldlg_imexp/xmldlg_export.cxx b/xmlscript/source/xmldlg_imexp/xmldlg_export.cxx
index 05c724aa2448..8f7c284754d5 100644
--- a/xmlscript/source/xmldlg_imexp/xmldlg_export.cxx
+++ b/xmlscript/source/xmldlg_imexp/xmldlg_export.cxx
@@ -58,6 +58,7 @@
#include <com/sun/star/document/GraphicObjectResolver.hpp>
#include <comphelper/processfactory.hxx>
+#include <i18nlangtag/languagetag.hxx>
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
@@ -485,19 +486,22 @@ void ElementDescriptor::addNumberFormatAttr(
addAttribute(XMLNS_DIALOGS_PREFIX ":format-code", sFormat );
// format-locale
- OUStringBuffer buf( 48 );
- buf.append( locale.Language );
- if (!locale.Country.isEmpty())
+ LanguageTag aLanguageTag( locale);
+ OUString aStr;
+ if (aLanguageTag.isIsoLocale())
{
- buf.append( (sal_Unicode)';' );
- buf.append( locale.Country );
- if (!locale.Variant.isEmpty())
- {
- buf.append( (sal_Unicode)';' );
- buf.append( locale.Variant );
- }
+ // Old style "lll;CC" for compatibility, I really don't know what may
+ // consume this.
+ if (aLanguageTag.getCountry().isEmpty())
+ aStr = aLanguageTag.getLanguage();
+ else
+ aStr = aLanguageTag.getLanguage() + ";" + aLanguageTag.getCountry();
+ }
+ else
+ {
+ aStr = aLanguageTag.getBcp47( false);
}
- addAttribute( XMLNS_DIALOGS_PREFIX ":format-locale", buf.makeStringAndClear() );
+ addAttribute( XMLNS_DIALOGS_PREFIX ":format-locale", aStr );
}
//__________________________________________________________________________________________________
Any ElementDescriptor::readProp( OUString const & rPropName )
diff --git a/xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx b/xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx
index bc8193a9ab04..d6902066d2b1 100644
--- a/xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx
+++ b/xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx
@@ -31,6 +31,7 @@
#include <com/sun/star/script/vba/XVBACompatibility.hpp>
#include <comphelper/processfactory.hxx>
+#include <i18nlangtag/languagetag.hxx>
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
@@ -539,21 +540,24 @@ void FormattedFieldElement::endElement()
if (!sLocale.isEmpty())
{
// split locale
+ // Don't know what may have written what we read here, so parse all
+ // old style including the trailing ";Variant" if present.
sal_Int32 semi0 = sLocale.indexOf( ';' );
- if (semi0 < 0) // no semi at all, just try language
+ if (semi0 < 0) // no semi at all, try new BCP47 or just language
{
- locale.Language = sLocale;
+ locale = LanguageTag( sLocale).getLocale( false);
}
else
{
sal_Int32 semi1 = sLocale.indexOf( ';', semi0 +1 );
if (semi1 > semi0) // language;country;variant
{
+ SAL_WARN( "xmlscript.xmldlg", "format-locale with variant that is ignored: " << sLocale);
locale.Language = sLocale.copy( 0, semi0 );
locale.Country = sLocale.copy( semi0 +1, semi1 - semi0 -1 );
- locale.Variant = sLocale.copy( semi1 +1 );
+ // Ignore Variant that no one knows what it would be.
}
- else // try language;country
+ else // language;country
{
locale.Language = sLocale.copy( 0, semi0 );
locale.Country = sLocale.copy( semi0 +1 );