Don't delete valid [$.*] components of number formats

... such as [RED], [NatNumX] etc.
This commit is contained in:
Katarina Machalkova 2011-07-28 14:50:24 +02:00
parent bcf50ad172
commit 0da07b6075

View file

@ -636,6 +636,7 @@ SvNumberformat::SvNumberformat(String& rString,
sal_Bool bCancel = sal_False; sal_Bool bCancel = sal_False;
sal_Bool bCondition = sal_False; sal_Bool bCondition = sal_False;
sal_Bool bHasValidBracketPrefix = sal_False;
short eSymbolType; short eSymbolType;
xub_StrLen nPos = 0; xub_StrLen nPos = 0;
xub_StrLen nPosOld; xub_StrLen nPosOld;
@ -727,6 +728,8 @@ SvNumberformat::SvNumberformat(String& rString,
bCancel = sal_True; // break for bCancel = sal_True; // break for
nCheckPos = nPosOld; nCheckPos = nPosOld;
} }
else
bHasValidBracketPrefix = sal_True;
} }
} }
break; break;
@ -763,6 +766,7 @@ SvNumberformat::SvNumberformat(String& rString,
sal_uInt8 nNum = sal::static_int_cast< sal_uInt8 >(0 - (eSymbolType - BRACKET_SYMBOLTYPE_NATNUM0)); sal_uInt8 nNum = sal::static_int_cast< sal_uInt8 >(0 - (eSymbolType - BRACKET_SYMBOLTYPE_NATNUM0));
sStr += String::CreateFromInt32( nNum ); sStr += String::CreateFromInt32( nNum );
NumFor[nIndex].SetNatNumNum( nNum, sal_False ); NumFor[nIndex].SetNatNumNum( nNum, sal_False );
bHasValidBracketPrefix = sal_True;
} }
} }
break; break;
@ -788,6 +792,7 @@ SvNumberformat::SvNumberformat(String& rString,
sal_uInt8 nNum = sal::static_int_cast< sal_uInt8 >(1 - (eSymbolType - BRACKET_SYMBOLTYPE_DBNUM1)); sal_uInt8 nNum = sal::static_int_cast< sal_uInt8 >(1 - (eSymbolType - BRACKET_SYMBOLTYPE_DBNUM1));
sStr += static_cast< sal_Unicode >('0' + nNum); sStr += static_cast< sal_Unicode >('0' + nNum);
NumFor[nIndex].SetNatNumNum( nNum, sal_True ); NumFor[nIndex].SetNatNumNum( nNum, sal_True );
bHasValidBracketPrefix = sal_True;
} }
} }
break; break;
@ -812,6 +817,7 @@ SvNumberformat::SvNumberformat(String& rString,
sStr.AssignAscii( RTL_CONSTASCII_STRINGPARAM("$-") ); sStr.AssignAscii( RTL_CONSTASCII_STRINGPARAM("$-") );
sStr = sStr + maLocale.generateCode(); sStr = sStr + maLocale.generateCode();
NumFor[nIndex].SetNatNumLang(maLocale.meLanguage); NumFor[nIndex].SetNatNumLang(maLocale.meLanguage);
bHasValidBracketPrefix = sal_True;
} }
} }
} }
@ -820,7 +826,7 @@ SvNumberformat::SvNumberformat(String& rString,
if ( !bCancel ) if ( !bCancel )
{ {
rString.Erase(nPosOld,nPos-nPosOld); rString.Erase(nPosOld,nPos-nPosOld);
if (maLocale.meLanguage != 0) if ( bHasValidBracketPrefix )
{ {
rString.Insert(sStr,nPosOld); rString.Insert(sStr,nPosOld);
nPos = nPosOld + sStr.Len(); nPos = nPosOld + sStr.Len();