Kaydet (Commit) e7d73b42 authored tarafından Eike Rathke's avatar Eike Rathke

use proper offset for additional locale data formats, fdo#64947 related

Old number formats had predefined formats from 0..49, locale data could
define additional formats from index 50 on. Internal (fractional)
formats were added to the number formatter, shifting the number of
predefined entries NF_INDEX_TABLE_ENTRIES by two that was also used as
an offset to determine whether a format needed to be added additionally.

As a consequece, formats defined with index values 50 and 51 in locale
data were ignored and not available in the dialog.

Introduced a new enum constant NF_INDEX_TABLE_LOCALE_DATA_DEFAULTS to
use as the old offset value for not having to change all locale data
definitions everytime an internally generated format is added.

Change-Id: I94bdaabf360f7b9c253b1e3f5b73087f0c45fb44
üst 296834c2
...@@ -176,10 +176,12 @@ enum NfIndexTableOffset ...@@ -176,10 +176,12 @@ enum NfIndexTableOffset
NF_BOOLEAN, // BOOLEAN NF_BOOLEAN, // BOOLEAN
NF_TEXT, // @ NF_TEXT, // @
NF_INDEX_TABLE_LOCALE_DATA_DEFAULTS, // old number of predefined entries, locale data additions start after this
// From here on are values of new built-in formats that are not in the // From here on are values of new built-in formats that are not in the
// original NumberFormatIndex.idl // original NumberFormatIndex.idl
NF_FRACTION_3, // # ?/4 NF_FRACTION_3 = NF_INDEX_TABLE_LOCALE_DATA_DEFAULTS, // # ?/4
NF_FRACTION_4, // # ?/100 NF_FRACTION_4, // # ?/100
NF_INDEX_TABLE_ENTRIES NF_INDEX_TABLE_ENTRIES
......
...@@ -1825,7 +1825,7 @@ SvNumberformat* SvNumberFormatter::ImpInsertFormat( const ::com::sun::star::i18n ...@@ -1825,7 +1825,7 @@ SvNumberformat* SvNumberFormatter::ImpInsertFormat( const ::com::sun::star::i18n
sal_Int16 nOrgIndex ) sal_Int16 nOrgIndex )
{ {
String aCodeStr( rCode.Code ); String aCodeStr( rCode.Code );
if ( rCode.Index < NF_INDEX_TABLE_ENTRIES && if ( rCode.Index < NF_INDEX_TABLE_LOCALE_DATA_DEFAULTS &&
rCode.Usage == ::com::sun::star::i18n::KNumberFormatUsage::CURRENCY && rCode.Usage == ::com::sun::star::i18n::KNumberFormatUsage::CURRENCY &&
rCode.Index != NF_CURRENCY_1000DEC2_CCC ) rCode.Index != NF_CURRENCY_1000DEC2_CCC )
{ // strip surrounding [$...] on automatic currency { // strip surrounding [$...] on automatic currency
...@@ -1865,7 +1865,7 @@ SvNumberformat* SvNumberFormatter::ImpInsertFormat( const ::com::sun::star::i18n ...@@ -1865,7 +1865,7 @@ SvNumberformat* SvNumberFormatter::ImpInsertFormat( const ::com::sun::star::i18n
delete pFormat; delete pFormat;
return NULL; return NULL;
} }
if ( rCode.Index >= NF_INDEX_TABLE_ENTRIES ) if ( rCode.Index >= NF_INDEX_TABLE_LOCALE_DATA_DEFAULTS )
{ {
sal_uInt32 nCLOffset = nPos - (nPos % SV_COUNTRY_LANGUAGE_OFFSET); sal_uInt32 nCLOffset = nPos - (nPos % SV_COUNTRY_LANGUAGE_OFFSET);
sal_uInt32 nKey = ImpIsEntry( aCodeStr, nCLOffset, ActLnge ); sal_uInt32 nKey = ImpIsEntry( aCodeStr, nCLOffset, ActLnge );
...@@ -2714,7 +2714,7 @@ void SvNumberFormatter::ImpGenerateAdditionalFormats( sal_uInt32 CLOffset, ...@@ -2714,7 +2714,7 @@ void SvNumberFormatter::ImpGenerateAdditionalFormats( sal_uInt32 CLOffset,
SAL_WARN( "svl.numbers", "ImpGenerateAdditionalFormats: too many formats" ); SAL_WARN( "svl.numbers", "ImpGenerateAdditionalFormats: too many formats" );
break; // for break; // for
} }
if ( pFormatArr[j].Index < NF_INDEX_TABLE_ENTRIES && if ( pFormatArr[j].Index < NF_INDEX_TABLE_LOCALE_DATA_DEFAULTS &&
pFormatArr[j].Index != NF_CURRENCY_1000DEC2_CCC ) pFormatArr[j].Index != NF_CURRENCY_1000DEC2_CCC )
{ // Insert only if not already inserted, but internal index must be { // Insert only if not already inserted, but internal index must be
// above so ImpInsertFormat can distinguish it. // above so ImpInsertFormat can distinguish it.
...@@ -2750,7 +2750,7 @@ void SvNumberFormatter::ImpGenerateAdditionalFormats( sal_uInt32 CLOffset, ...@@ -2750,7 +2750,7 @@ void SvNumberFormatter::ImpGenerateAdditionalFormats( sal_uInt32 CLOffset,
SAL_WARN( "svl.numbers", "ImpGenerateAdditionalFormats: too many formats" ); SAL_WARN( "svl.numbers", "ImpGenerateAdditionalFormats: too many formats" );
break; // for break; // for
} }
if ( pFormatArr[j].Index >= NF_INDEX_TABLE_ENTRIES ) if ( pFormatArr[j].Index >= NF_INDEX_TABLE_LOCALE_DATA_DEFAULTS )
if ( ImpInsertNewStandardFormat( pFormatArr[j], nPos+1, if ( ImpInsertNewStandardFormat( pFormatArr[j], nPos+1,
SV_NUMBERFORMATTER_VERSION_ADDITIONAL_I18N_FORMATS, SV_NUMBERFORMATTER_VERSION_ADDITIONAL_I18N_FORMATS,
bAfterChangingSystemCL ) ) bAfterChangingSystemCL ) )
......
...@@ -1612,7 +1612,7 @@ sal_Int32 SvXMLNumFormatContext::CreateAndInsert(SvNumberFormatter* pFormatter) ...@@ -1612,7 +1612,7 @@ sal_Int32 SvXMLNumFormatContext::CreateAndInsert(SvNumberFormatter* pFormatter)
NfIndexTableOffset eFormat = (NfIndexTableOffset) SvXMLNumFmtDefaults::GetDefaultDateFormat( NfIndexTableOffset eFormat = (NfIndexTableOffset) SvXMLNumFmtDefaults::GetDefaultDateFormat(
eDateDOW, eDateDay, eDateMonth, eDateYear, eDateDOW, eDateDay, eDateMonth, eDateYear,
eDateHours, eDateMins, eDateSecs, bFromSystem ); eDateHours, eDateMins, eDateSecs, bFromSystem );
if ( eFormat < NF_INDEX_TABLE_ENTRIES ) if ( eFormat < NF_INDEX_TABLE_LOCALE_DATA_DEFAULTS )
{ {
// #109651# if a date format has the automatic-order attribute and // #109651# if a date format has the automatic-order attribute and
// contains exactly the elements of one of the default date formats, // contains exactly the elements of one of the default date formats,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment