Handle tinkering with '-N => (N)' number format -- bnc#659993
This commit is contained in:
parent
96dc8d285d
commit
6437196eea
3 changed files with 51 additions and 6 deletions
|
@ -334,6 +334,10 @@ public:
|
|||
// Whether the negative format is without a sign or not
|
||||
BOOL IsNegativeWithoutSign() const;
|
||||
|
||||
BOOL IsNegativeInBracket() const;
|
||||
|
||||
BOOL HasPositiveBracketPlaceholder() const;
|
||||
|
||||
// Whether a new SYMBOLTYPE_CURRENCY is contained in the format
|
||||
BOOL HasNewCurrency() const;
|
||||
|
||||
|
|
|
@ -2744,6 +2744,10 @@ void SvNumberFormatter::GenerateFormat(String& sString,
|
|||
utl::DigitGroupingIterator aGrouping( xLocaleData->getDigitGrouping());
|
||||
const xub_StrLen nDigitsInFirstGroup = static_cast<xub_StrLen>(aGrouping.get());
|
||||
const String& rThSep = GetNumThousandSep();
|
||||
|
||||
SvNumberformat* pFormat = (SvNumberformat*) aFTable.Get(nIndex);
|
||||
BOOL insertBrackets = pFormat->IsNegativeInBracket();
|
||||
|
||||
if (nAnzLeading == 0)
|
||||
{
|
||||
if (!bThousand)
|
||||
|
@ -2836,15 +2840,35 @@ void SvNumberFormatter::GenerateFormat(String& sString,
|
|||
sString += ';';
|
||||
sString += sNegStr;
|
||||
}
|
||||
if (IsRed && eType != NUMBERFORMAT_CURRENCY)
|
||||
if ( (IsRed || insertBrackets ) && eType != NUMBERFORMAT_CURRENCY)
|
||||
{
|
||||
String sTmpStr = sString;
|
||||
|
||||
if ( pFormat->HasPositiveBracketPlaceholder() )
|
||||
{
|
||||
sTmpStr += '_';
|
||||
sTmpStr += ')';
|
||||
}
|
||||
sTmpStr += ';';
|
||||
sTmpStr += '[';
|
||||
sTmpStr += pFormatScanner->GetRedString();
|
||||
sTmpStr += ']';
|
||||
sTmpStr += '-';
|
||||
sTmpStr +=sString;
|
||||
|
||||
if (IsRed)
|
||||
{
|
||||
sTmpStr += '[';
|
||||
sTmpStr += pFormatScanner->GetRedString();
|
||||
sTmpStr += ']';
|
||||
}
|
||||
|
||||
if (insertBrackets)
|
||||
{
|
||||
sTmpStr += '(';
|
||||
sTmpStr += sString;
|
||||
sTmpStr += ')';
|
||||
}
|
||||
else
|
||||
{
|
||||
sTmpStr += '-';
|
||||
sTmpStr +=sString;
|
||||
}
|
||||
sString = sTmpStr;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4114,6 +4114,23 @@ BOOL SvNumberformat::IsNegativeWithoutSign() const
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL SvNumberformat::IsNegativeInBracket() const
|
||||
{
|
||||
USHORT nAnz = NumFor[1].GetCount();
|
||||
if (!nAnz)
|
||||
return FALSE;
|
||||
|
||||
String *tmpStr = NumFor[1].Info().sStrArray;
|
||||
return (tmpStr[0] == '(' && tmpStr[nAnz-1] == ')' );
|
||||
}
|
||||
|
||||
BOOL SvNumberformat::HasPositiveBracketPlaceholder() const
|
||||
{
|
||||
USHORT nAnz = NumFor[0].GetCount();
|
||||
String *tmpStr = NumFor[0].Info().sStrArray;
|
||||
return (tmpStr[nAnz-1].EqualsAscii( "_)" ));
|
||||
}
|
||||
|
||||
DateFormat SvNumberformat::GetDateOrder() const
|
||||
{
|
||||
if ( (eType & NUMBERFORMAT_DATE) == NUMBERFORMAT_DATE )
|
||||
|
|
Loading…
Reference in a new issue