write bcp47 format-locale if necessary and read both
Change-Id: I82cfdd8652d1c86b701ccb0b913928c860a360d2
This commit is contained in:
@@ -21,6 +21,7 @@ $(eval $(call gb_Library_use_libraries,xmlscript,\
|
|||||||
cppuhelper \
|
cppuhelper \
|
||||||
sal \
|
sal \
|
||||||
tl \
|
tl \
|
||||||
|
i18nlangtag \
|
||||||
$(gb_UWINAPI) \
|
$(gb_UWINAPI) \
|
||||||
))
|
))
|
||||||
|
|
||||||
|
@@ -58,6 +58,7 @@
|
|||||||
#include <com/sun/star/document/GraphicObjectResolver.hpp>
|
#include <com/sun/star/document/GraphicObjectResolver.hpp>
|
||||||
|
|
||||||
#include <comphelper/processfactory.hxx>
|
#include <comphelper/processfactory.hxx>
|
||||||
|
#include <i18nlangtag/languagetag.hxx>
|
||||||
|
|
||||||
using namespace ::com::sun::star;
|
using namespace ::com::sun::star;
|
||||||
using namespace ::com::sun::star::uno;
|
using namespace ::com::sun::star::uno;
|
||||||
@@ -485,19 +486,22 @@ void ElementDescriptor::addNumberFormatAttr(
|
|||||||
addAttribute(XMLNS_DIALOGS_PREFIX ":format-code", sFormat );
|
addAttribute(XMLNS_DIALOGS_PREFIX ":format-code", sFormat );
|
||||||
|
|
||||||
// format-locale
|
// format-locale
|
||||||
OUStringBuffer buf( 48 );
|
LanguageTag aLanguageTag( locale);
|
||||||
buf.append( locale.Language );
|
OUString aStr;
|
||||||
if (!locale.Country.isEmpty())
|
if (aLanguageTag.isIsoLocale())
|
||||||
{
|
{
|
||||||
buf.append( (sal_Unicode)';' );
|
// Old style "lll;CC" for compatibility, I really don't know what may
|
||||||
buf.append( locale.Country );
|
// consume this.
|
||||||
if (!locale.Variant.isEmpty())
|
if (aLanguageTag.getCountry().isEmpty())
|
||||||
{
|
aStr = aLanguageTag.getLanguage();
|
||||||
buf.append( (sal_Unicode)';' );
|
else
|
||||||
buf.append( locale.Variant );
|
aStr = aLanguageTag.getLanguage() + ";" + aLanguageTag.getCountry();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
addAttribute( XMLNS_DIALOGS_PREFIX ":format-locale", buf.makeStringAndClear() );
|
else
|
||||||
|
{
|
||||||
|
aStr = aLanguageTag.getBcp47( false);
|
||||||
|
}
|
||||||
|
addAttribute( XMLNS_DIALOGS_PREFIX ":format-locale", aStr );
|
||||||
}
|
}
|
||||||
//__________________________________________________________________________________________________
|
//__________________________________________________________________________________________________
|
||||||
Any ElementDescriptor::readProp( OUString const & rPropName )
|
Any ElementDescriptor::readProp( OUString const & rPropName )
|
||||||
|
@@ -31,6 +31,7 @@
|
|||||||
#include <com/sun/star/script/vba/XVBACompatibility.hpp>
|
#include <com/sun/star/script/vba/XVBACompatibility.hpp>
|
||||||
|
|
||||||
#include <comphelper/processfactory.hxx>
|
#include <comphelper/processfactory.hxx>
|
||||||
|
#include <i18nlangtag/languagetag.hxx>
|
||||||
|
|
||||||
using namespace ::com::sun::star;
|
using namespace ::com::sun::star;
|
||||||
using namespace ::com::sun::star::uno;
|
using namespace ::com::sun::star::uno;
|
||||||
@@ -539,21 +540,24 @@ void FormattedFieldElement::endElement()
|
|||||||
if (!sLocale.isEmpty())
|
if (!sLocale.isEmpty())
|
||||||
{
|
{
|
||||||
// split locale
|
// 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( ';' );
|
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
|
else
|
||||||
{
|
{
|
||||||
sal_Int32 semi1 = sLocale.indexOf( ';', semi0 +1 );
|
sal_Int32 semi1 = sLocale.indexOf( ';', semi0 +1 );
|
||||||
if (semi1 > semi0) // language;country;variant
|
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.Language = sLocale.copy( 0, semi0 );
|
||||||
locale.Country = sLocale.copy( semi0 +1, semi1 - semi0 -1 );
|
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.Language = sLocale.copy( 0, semi0 );
|
||||||
locale.Country = sLocale.copy( semi0 +1 );
|
locale.Country = sLocale.copy( semi0 +1 );
|
||||||
|
Reference in New Issue
Block a user