i18npool/source/localedata/LocaleNode.cxx | 44 +++++++++++++++++++++++++++--- i18npool/source/localedata/LocaleNode.hxx | 3 ++ i18npool/source/localedata/data/ga_IE.xml | 4 +- i18npool/source/localedata/data/my_MM.xml | 7 ++++ i18npool/source/localedata/data/wa_BE.xml | 2 - 5 files changed, 53 insertions(+), 7 deletions(-)
New commits: commit 4e34d8fd5b64a18dd17faf4ed4d603648bab8311 Author: Eike Rathke <er...@redhat.com> Date: Fri Nov 25 19:37:35 2011 +0100 added check if locale data's usedInCompatibleFormatCodes currency is really used there and fixed the cases discovered by the check ... diff --git a/i18npool/source/localedata/LocaleNode.cxx b/i18npool/source/localedata/LocaleNode.cxx index 8d7d1a3..88c26b5 100644 --- a/i18npool/source/localedata/LocaleNode.cxx +++ b/i18npool/source/localedata/LocaleNode.cxx @@ -337,6 +337,12 @@ void LocaleNode::incErrorStr( const char* pStr, const ::rtl::OUString& rVal ) co fprintf( stderr, prepareErrorFormat( pStr, ": %s"), OSTR( rVal)); } +void LocaleNode::incErrorStrStr( const char* pStr, const ::rtl::OUString& rVal1, const ::rtl::OUString& rVal2 ) const +{ + ++nError; + fprintf( stderr, prepareErrorFormat( pStr, ": %s %s"), OSTR( rVal1), OSTR( rVal2)); +} + void LCInfoNode::generateCode (const OFileWriter &of) const { @@ -590,13 +596,17 @@ void LCCTYPENode::generateCode (const OFileWriter &of) const } +static OUString sTheCompatibleCurrency; + sal_Int16 LCFormatNode::mnSection = 0; sal_Int16 LCFormatNode::mnFormats = 0; void LCFormatNode::generateCode (const OFileWriter &of) const { OUString str; - if (mnSection >= 2) + if (mnSection == 0) + sTheCompatibleCurrency = OUString(); + else if (mnSection >= 2) incError("more than 2 LC_FORMAT sections"); OUString strFrom( getAttr().getValueByName("replaceFrom")); of.writeParameter("replaceFrom", strFrom, mnSection); @@ -607,6 +617,13 @@ void LCFormatNode::generateCode (const OFileWriter &of) const if (str.endsWithIgnoreAsciiCaseAsciiL( "-FFFF]", 6)) incErrorStr("replaceTo=\"%s\" needs FFFF to be adapted to the real LangID value.", str); of.writeParameter("replaceTo", str, mnSection); + // Remember the currency symbol if present. + if (str.indexOfAsciiL( "[$", 2) == 0) + { + sal_Int32 nHyphen = str.indexOf( '-'); + if (nHyphen >= 3) + sTheCompatibleCurrency = str.copy( 2, nHyphen - 2); + } ::rtl::OUString useLocale = getAttr().getValueByName("ref"); if (useLocale.getLength() > 0) { switch (mnSection) @@ -710,14 +727,27 @@ void LCFormatNode::generateCode (const OFileWriter &of) const } } break; - // Currency formats should be something like [C]###0;-[C]###0 - // and not parenthesized [C]###0;([C]###0) if not en_US. + case cssi::NumberFormatIndex::CURRENCY_1000DEC2 : + // Remember the currency symbol if present. + { + sal_Int32 nStart; + if (sTheCompatibleCurrency.isEmpty() && + ((nStart = n->getValue().indexOfAsciiL( "[$", 2)) >= 0)) + { + OUString aCode( n->getValue()); + sal_Int32 nHyphen = aCode.indexOf( '-', nStart); + if (nHyphen >= nStart + 3) + sTheCompatibleCurrency = aCode.copy( nStart + 2, nHyphen - nStart - 2); + } + } + // fallthru case cssi::NumberFormatIndex::CURRENCY_1000INT : case cssi::NumberFormatIndex::CURRENCY_1000INT_RED : - case cssi::NumberFormatIndex::CURRENCY_1000DEC2 : case cssi::NumberFormatIndex::CURRENCY_1000DEC2_RED : case cssi::NumberFormatIndex::CURRENCY_1000DEC2_CCC : case cssi::NumberFormatIndex::CURRENCY_1000DEC2_DASHED : + // Currency formats should be something like [C]###0;-[C]###0 + // and not parenthesized [C]###0;([C]###0) if not en_US. if (strcmp( of.getLocale(), "en_US") != 0) { OUString aCode( n->getValue()); @@ -1549,6 +1579,12 @@ void LCCurrencyNode :: generateCode (const OFileWriter &of) const incError( "CurrencyID is not ISO 4217"); str = currencyNode -> findNode ("CurrencySymbol") -> getValue(); of.writeParameter("currencySymbol", str, nbOfCurrencies); + // Check if this currency really is the one used in number format + // codes. In case of ref=... mechanisms it may be that TheCurrency + // couldn't had been determined from the current locale (i.e. is + // empty), silently assume the referred locale has things right. + if (bCompatible && !sTheCompatibleCurrency.isEmpty() && sTheCompatibleCurrency != str) + incErrorStrStr( "CurrencySymbol \"%s\" flagged as usedInCompatibleFormatCodes doesn't match \"%s\" determined from format codes.", str, sTheCompatibleCurrency); str = currencyNode -> findNode ("BankSymbol") -> getValue(); of.writeParameter("bankSymbol", str, nbOfCurrencies); // BankSymbol currently must be ISO 4217. May change later if diff --git a/i18npool/source/localedata/LocaleNode.hxx b/i18npool/source/localedata/LocaleNode.hxx index fb35063..c79726c 100644 --- a/i18npool/source/localedata/LocaleNode.hxx +++ b/i18npool/source/localedata/LocaleNode.hxx @@ -152,6 +152,9 @@ public: void incErrorInt( const char* pStr, int nVal ) const; // ++nError with output to stderr, pStr should contain "%s", otherwise appended void incErrorStr( const char* pStr, const ::rtl::OUString& rVal ) const; + // ++nError with output to stderr, pStr should contain "%s %s", otherwise + // appended + void incErrorStrStr( const char* pStr, const ::rtl::OUString& rVal1, const ::rtl::OUString& rVal2 ) const; // used by incError...(), returns a pointer to a static buffer, // pDefaultConversion is appended if pFormat doesn't contain a % // specification and should be something like ": %d" or ": %s" or similar. diff --git a/i18npool/source/localedata/data/ga_IE.xml b/i18npool/source/localedata/data/ga_IE.xml index 89ab1e0..f397241 100644 --- a/i18npool/source/localedata/data/ga_IE.xml +++ b/i18npool/source/localedata/data/ga_IE.xml @@ -149,14 +149,14 @@ <CurrencyName>Euro</CurrencyName> <DecimalPlaces>2</DecimalPlaces> </Currency> - <Currency default="false" usedInCompatibleFormatCodes="true"> + <Currency default="false" usedInCompatibleFormatCodes="false"> <CurrencyID>IEP</CurrencyID> <CurrencySymbol>IR£</CurrencySymbol> <BankSymbol>IEP</BankSymbol> <CurrencyName>Punt Ãireannach</CurrencyName> <DecimalPlaces>2</DecimalPlaces> </Currency> - <Currency default="false" usedInCompatibleFormatCodes="false"> + <Currency default="false" usedInCompatibleFormatCodes="true"> <CurrencyID>GBP</CurrencyID> <CurrencySymbol>£</CurrencySymbol> <BankSymbol>GBP</BankSymbol> diff --git a/i18npool/source/localedata/data/my_MM.xml b/i18npool/source/localedata/data/my_MM.xml index 6c12c89..17c50fa 100644 --- a/i18npool/source/localedata/data/my_MM.xml +++ b/i18npool/source/localedata/data/my_MM.xml @@ -387,6 +387,13 @@ <LC_CURRENCY> <Currency default="true" usedInCompatibleFormatCodes="true"> <CurrencyID>MMK</CurrencyID> + <CurrencySymbol>áá»ááº</CurrencySymbol> + <BankSymbol>MMK</BankSymbol> + <CurrencyName>Kyat</CurrencyName> + <DecimalPlaces>2</DecimalPlaces> + </Currency> + <Currency default="false" usedInCompatibleFormatCodes="false" legacyOnly="true"> + <CurrencyID>MMK</CurrencyID> <CurrencySymbol>K</CurrencySymbol> <BankSymbol>MMK</BankSymbol> <CurrencyName>Kyat</CurrencyName> diff --git a/i18npool/source/localedata/data/wa_BE.xml b/i18npool/source/localedata/data/wa_BE.xml index aa99482..eb3bf51 100644 --- a/i18npool/source/localedata/data/wa_BE.xml +++ b/i18npool/source/localedata/data/wa_BE.xml @@ -34,7 +34,7 @@ <TimePM>PM</TimePM> <MeasurementSystem>metric</MeasurementSystem> </LC_CTYPE> - <LC_FORMAT replaceFrom="[CURRENCY]" replaceTo="[$â¬-633]"> + <LC_FORMAT replaceFrom="[CURRENCY]" replaceTo="[$FB-633]"> <FormatElement msgid="FixedFormatskey1" default="true" type="medium" usage="FIXED_NUMBER" formatindex="0"> <FormatCode>Standard</FormatCode> </FormatElement>
_______________________________________________ Libreoffice-commits mailing list Libreoffice-commits@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits