[Libreoffice-commits] .: svl/inc svl/source
Muthu Subramanian
sumuthu at kemper.freedesktop.org
Thu Dec 9 04:02:57 PST 2010
svl/inc/nfsymbol.hxx | 3 -
svl/inc/svl/zforlist.hxx | 4 +
svl/source/numbers/zforlist.cxx | 8 +++
svl/source/numbers/zformat.cxx | 90 +++++++++++++++++++---------------------
svl/source/numbers/zforscan.cxx | 45 +++++++++++---------
5 files changed, 81 insertions(+), 69 deletions(-)
New commits:
commit b0e90c6561dcf3697b680ea81b5733f073cbcf24
Author: Muthu Subramanian K <sumuthu at novell.com>
Date: Thu Dec 9 17:24:10 2010 +0530
New number formats (?/4, ?/100 and ?/[n]). n#655214
?/4 is for quarters representation
?/100 is for hunderds representation
?/[n] is for forcing the divisor to be 'n' e.g. ?/5
diff --git a/svl/inc/nfsymbol.hxx b/svl/inc/nfsymbol.hxx
index 675720b..f2b30c3 100644
--- a/svl/inc/nfsymbol.hxx
+++ b/svl/inc/nfsymbol.hxx
@@ -62,7 +62,8 @@ enum NfSymbolType
NF_SYMBOLTYPE_DATESEP = -18, // date separator
NF_SYMBOLTYPE_TIMESEP = -19, // time separator
NF_SYMBOLTYPE_TIME100SECSEP = -20, // time 100th seconds separator
- NF_SYMBOLTYPE_PERCENT = -21 // percent %
+ NF_SYMBOLTYPE_PERCENT = -21, // percent %
+ NF_SYMBOLTYPE_FRAC_FDIV = -22 // forced divisors
};
} // namespace svt
diff --git a/svl/inc/svl/zforlist.hxx b/svl/inc/svl/zforlist.hxx
index ed9abec..a51a0c9 100644
--- a/svl/inc/svl/zforlist.hxx
+++ b/svl/inc/svl/zforlist.hxx
@@ -126,7 +126,9 @@ enum NfIndexTableOffset
NF_FRACTION_START,
NF_FRACTION_1 = NF_FRACTION_START, // # ?/?
NF_FRACTION_2, // # ??/??
- NF_FRACTION_END = NF_FRACTION_2,
+ NF_FRACTION_3, // # ?/4
+ NF_FRACTION_4, // # ??/100
+ NF_FRACTION_END = NF_FRACTION_4,
NF_NUMERIC_END = NF_FRACTION_END,
diff --git a/svl/source/numbers/zforlist.cxx b/svl/source/numbers/zforlist.cxx
index ee7d917..a5af5a8 100644
--- a/svl/source/numbers/zforlist.cxx
+++ b/svl/source/numbers/zforlist.cxx
@@ -2586,6 +2586,14 @@ void SvNumberFormatter::ImpGenerateFormats( sal_uInt32 CLOffset, BOOL bLoadingSO
ImpInsertFormat( aSingleFormatCode,
CLOffset + SetIndexTable( NF_FRACTION_2, ZF_STANDARD_FRACTION+1 ));
+ aSingleFormatCode.Code = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "# ?/4" ) );
+ ImpInsertFormat( aSingleFormatCode,
+ CLOffset + SetIndexTable( NF_FRACTION_3, ZF_STANDARD_FRACTION+2 ));
+
+ aSingleFormatCode.Code = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "# ?\?/100" ) );
+ ImpInsertFormat( aSingleFormatCode,
+ CLOffset + SetIndexTable( NF_FRACTION_4, ZF_STANDARD_FRACTION+3 ));
+
// Week of year must be appended here because of nNewExtended
const String* pKeyword = pFormatScanner->GetKeywords();
aSingleFormatCode.Code = pKeyword[NF_KEY_WW];
diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx
index adda1ac..882c8a5 100644
--- a/svl/source/numbers/zformat.cxx
+++ b/svl/source/numbers/zformat.cxx
@@ -2,7 +2,7 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
+ *
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
@@ -186,7 +186,6 @@ void ImpSvNumberformatInfo::Load(SvStream& rStream, USHORT nAnz)
>> nCntPre >> nCntPost >> nCntExp;
}
-
//============================================================================
// static
@@ -242,7 +241,6 @@ BYTE SvNumberNatNum::MapDBNumToNatNum( BYTE nDBNum, LanguageType eLang, BOOL bDa
return nNatNum;
}
-
// static
BYTE SvNumberNatNum::MapNatNumToDBNum( BYTE nNatNum, LanguageType eLang, BOOL bDate )
{
@@ -399,7 +397,6 @@ void ImpSvNumFor::Load(SvStream& rStream, ImpSvNumberformatScan& rSc,
pColor = rSc.GetColor(sColorName);
}
-
BOOL ImpSvNumFor::HasNewCurrency() const
{
for ( USHORT j=0; j<nAnzStrings; j++ )
@@ -410,7 +407,6 @@ BOOL ImpSvNumFor::HasNewCurrency() const
return FALSE;
}
-
BOOL ImpSvNumFor::GetNewCurrencySymbol( String& rSymbol,
String& rExtension ) const
{
@@ -430,7 +426,6 @@ BOOL ImpSvNumFor::GetNewCurrencySymbol( String& rSymbol,
return FALSE;
}
-
void ImpSvNumFor::SaveNewCurrencyMap( SvStream& rStream ) const
{
USHORT j;
@@ -460,7 +455,6 @@ void ImpSvNumFor::SaveNewCurrencyMap( SvStream& rStream ) const
}
}
-
void ImpSvNumFor::LoadNewCurrencyMap( SvStream& rStream )
{
USHORT nCnt;
@@ -475,7 +469,6 @@ void ImpSvNumFor::LoadNewCurrencyMap( SvStream& rStream )
}
}
-
/***********************Funktionen SvNumberformat************************/
enum BracketFormatSymbolType
@@ -557,7 +550,6 @@ SvNumberformat::SvNumberformat( SvNumberformat& rFormat, ImpSvNumberformatScan&
ImpCopyNumberformat( rFormat );
}
-
BOOL lcl_SvNumberformat_IsBracketedPrefix( short nSymbolType )
{
if ( nSymbolType > 0 )
@@ -600,7 +592,6 @@ BOOL lcl_SvNumberformat_IsBracketedPrefix( short nSymbolType )
return FALSE;
}
-
SvNumberformat::SvNumberformat(String& rString,
ImpSvNumberformatScan* pSc,
ImpSvNumberInputScan* pISc,
@@ -1078,7 +1069,6 @@ enum ScanState
SsGetBracketed // any [...] not decided yet
};
-
// read a string until ']' and delete spaces in input
// static
xub_StrLen SvNumberformat::ImpGetNumber(String& rString,
@@ -1105,7 +1095,6 @@ xub_StrLen SvNumberformat::ImpGetNumber(String& rString,
return nPos - nStartPos;
}
-
// static
LanguageType SvNumberformat::ImpGetLanguageType( const String& rString,
xub_StrLen& nPos )
@@ -1138,7 +1127,6 @@ LanguageType SvNumberformat::ImpGetLanguageType( const String& rString,
LANGUAGE_DONTKNOW;
}
-
short SvNumberformat::ImpNextSymbol(String& rString,
xub_StrLen& nPos,
String& sSymbol)
@@ -1595,7 +1583,6 @@ void SvNumberformat::ConvertLanguage( SvNumberFormatter& rConverter,
}
}
-
// static
void SvNumberformat::LoadString( SvStream& rStream, String& rStr )
{
@@ -1626,7 +1613,6 @@ void SvNumberformat::LoadString( SvStream& rStream, String& rStr )
}
}
-
void SvNumberformat::Save( SvStream& rStream, ImpSvNumMultipleWriteHeader& rHdr ) const
{
String aFormatstring( sFormatstring );
@@ -1697,7 +1683,6 @@ void SvNumberformat::Save( SvStream& rStream, ImpSvNumMultipleWriteHeader& rHdr
rHdr.EndEntry();
}
-
BOOL SvNumberformat::HasNewCurrency() const
{
for ( USHORT j=0; j<4; j++ )
@@ -1708,7 +1693,6 @@ BOOL SvNumberformat::HasNewCurrency() const
return FALSE;
}
-
BOOL SvNumberformat::GetNewCurrencySymbol( String& rSymbol,
String& rExtension ) const
{
@@ -1722,7 +1706,6 @@ BOOL SvNumberformat::GetNewCurrencySymbol( String& rSymbol,
return FALSE;
}
-
// static
String SvNumberformat::StripNewCurrencyDelimiters( const String& rStr,
BOOL bQuoteSymbol )
@@ -1772,13 +1755,11 @@ String SvNumberformat::StripNewCurrencyDelimiters( const String& rStr,
return aTmp;
}
-
void SvNumberformat::Build50Formatstring( String& rStr ) const
{
rStr = StripNewCurrencyDelimiters( sFormatstring, TRUE );
}
-
void SvNumberformat::ImpGetOutputStandard(double& fNumber, String& OutString)
{
sal_uInt16 nStandardPrec = rScan.GetStandardPrec();
@@ -1823,8 +1804,8 @@ void SvNumberformat::ImpGetOutputStdToPrecision(double& rNumber, String& rOutStr
rtl_math_StringFormat_G, -3, '.', sal_True );
}
#endif
-
- // We decided to strip trailing zeros unconditionally, since binary
+
+ // We decided to strip trailing zeros unconditionally, since binary
// double-precision rounding error makes it impossible to determine e.g.
// whether 844.10000000000002273737 is what the user has typed, or the
// user has typed 844.1 but IEEE 754 represents it that way internally.
@@ -1996,6 +1977,33 @@ void lcl_GetOutputStringScientific(
fNumber, rtl_math_StringFormat_E, nPrec, rFormatter.GetNumDecimalSep().GetChar(0));
}
+sal_Int32 lcl_GetForcedDenominator(ImpSvNumberformatInfo &rInfo, USHORT nAnz)
+{
+ USHORT i;
+ rtl::OUString aDiv;
+ for( i = 0; i < nAnz; i++ )
+ {
+ if( rInfo.nTypeArray[i] == NF_SYMBOLTYPE_FRAC_FDIV )
+ aDiv += rInfo.sStrArray[i];
+ }
+ return aDiv.toInt32();
+}
+
+// TODO: More optimizations?
+void lcl_ForcedDenominator(ULONG &nFrac, ULONG &nDiv, ULONG nForcedDiv)
+{
+ double fFrac = (double)nFrac / (double)nDiv;
+ double fMultiplier = (double)nForcedDiv / (double)nDiv;
+ nFrac = (ULONG)( (double)nFrac * fMultiplier );
+
+ double fFracNew = (double)nFrac / (double)nForcedDiv;
+ double fFracNew1 = (double)(nFrac + 1) / (double)nForcedDiv;
+ double fDiff = fFrac - fFracNew;
+ if( fDiff > ( fFracNew1 - fFrac ) )
+ nFrac++;
+ nDiv = nForcedDiv;
+}
+
}
bool SvNumberformat::GetOutputString(double fNumber, sal_uInt16 nCharCount, String& rOutString) const
@@ -2085,7 +2093,7 @@ BOOL SvNumberformat::GetOutputString(double fNumber,
xub_StrLen nLen = OutString.Len();
if (!nLen)
return false;
-
+
// #i112250# With the 10-decimal limit, small numbers are formatted as "0".
// Switch to scientific in that case, too:
if (nLen > 11 || (OutString.EqualsAscii("0") && fNumber != 0.0))
@@ -2382,6 +2390,16 @@ BOOL SvNumberformat::GetOutputString(double fNumber,
}
}
+ if( sal_Int32 nForcedDiv = lcl_GetForcedDenominator(NumFor[nIx].Info(), nAnz) )
+ {
+ lcl_ForcedDenominator(nFrac, nDiv, nForcedDiv);
+ if( nFrac >= nDiv )
+ {
+ nFrac = nDiv = 0;
+ fNum = fNum + 1.0;
+ }
+ }
+
if (rInfo.nCntPre == 0) // unechter Bruch
{
double fNum1 = fNum * (double)nDiv + (double)nFrac;
@@ -2758,7 +2776,6 @@ BOOL SvNumberformat::ImpGetTimeOutput(double fNumber,
return bRes;
}
-
BOOL SvNumberformat::ImpIsOtherCalendar( const ImpSvNumFor& rNumFor ) const
{
if ( GetCal().getUniqueID() != Gregorian::get() )
@@ -2784,7 +2801,6 @@ BOOL SvNumberformat::ImpIsOtherCalendar( const ImpSvNumFor& rNumFor ) const
return FALSE;
}
-
void SvNumberformat::SwitchToOtherCalendar( String& rOrgCalendar,
double& fOrgDateTime ) const
{
@@ -2816,7 +2832,6 @@ void SvNumberformat::SwitchToOtherCalendar( String& rOrgCalendar,
}
}
-
void SvNumberformat::SwitchToGregorianCalendar( const String& rOrgCalendar,
double fOrgDateTime ) const
{
@@ -2829,7 +2844,6 @@ void SvNumberformat::SwitchToGregorianCalendar( const String& rOrgCalendar,
}
}
-
BOOL SvNumberformat::ImpFallBackToGregorianCalendar( String& rOrgCalendar, double& fOrgDateTime )
{
using namespace ::com::sun::star::i18n;
@@ -2856,7 +2870,6 @@ BOOL SvNumberformat::ImpFallBackToGregorianCalendar( String& rOrgCalendar, doubl
return FALSE;
}
-
BOOL SvNumberformat::ImpSwitchToSpecifiedCalendar( String& rOrgCalendar,
double& fOrgDateTime, const ImpSvNumFor& rNumFor ) const
{
@@ -2880,7 +2893,6 @@ BOOL SvNumberformat::ImpSwitchToSpecifiedCalendar( String& rOrgCalendar,
return FALSE;
}
-
// static
void SvNumberformat::ImpAppendEraG( String& OutString,
const CalendarWrapper& rCal, sal_Int16 nNatNum )
@@ -2905,7 +2917,6 @@ void SvNumberformat::ImpAppendEraG( String& OutString,
OutString += rCal.getDisplayString( CalendarDisplayCode::SHORT_ERA, nNatNum );
}
-
BOOL SvNumberformat::ImpGetDateOutput(double fNumber,
USHORT nIx,
String& OutString)
@@ -3863,6 +3874,8 @@ BOOL SvNumberformat::ImpNumberFill( String& sStr, // number string
sStr.Insert(sNum, k);
}
break;
+ case NF_SYMBOLTYPE_FRAC_FDIV: // Do Nothing
+ break;
default:
sStr.Insert(rInfo.sStrArray[j],k);
@@ -3974,7 +3987,6 @@ const String* SvNumberformat::GetNumForString( USHORT nNumFor, USHORT nPos,
return &NumFor[nNumFor].Info().sStrArray[nPos];
}
-
short SvNumberformat::GetNumForType( USHORT nNumFor, USHORT nPos,
BOOL bString /* = FALSE */ ) const
{
@@ -4016,7 +4028,6 @@ short SvNumberformat::GetNumForType( USHORT nNumFor, USHORT nPos,
return NumFor[nNumFor].Info().nTypeArray[nPos];
}
-
BOOL SvNumberformat::IsNegativeWithoutSign() const
{
if ( IsNegativeRealNegative() )
@@ -4028,7 +4039,6 @@ BOOL SvNumberformat::IsNegativeWithoutSign() const
return FALSE;
}
-
DateFormat SvNumberformat::GetDateOrder() const
{
if ( (eType & NUMBERFORMAT_DATE) == NUMBERFORMAT_DATE )
@@ -4065,7 +4075,6 @@ DateFormat SvNumberformat::GetDateOrder() const
return rLoc().getDateFormat();
}
-
sal_uInt32 SvNumberformat::GetExactDateOrder() const
{
sal_uInt32 nRet = 0;
@@ -4108,7 +4117,6 @@ sal_uInt32 SvNumberformat::GetExactDateOrder() const
return nRet;
}
-
void SvNumberformat::GetConditions( SvNumberformatLimitOps& rOper1, double& rVal1,
SvNumberformatLimitOps& rOper2, double& rVal2 ) const
{
@@ -4118,7 +4126,6 @@ void SvNumberformat::GetConditions( SvNumberformatLimitOps& rOper1, double& rVal
rVal2 = fLimit2;
}
-
Color* SvNumberformat::GetColor( USHORT nNumFor ) const
{
if ( nNumFor > 3 )
@@ -4127,7 +4134,6 @@ Color* SvNumberformat::GetColor( USHORT nNumFor ) const
return NumFor[nNumFor].GetColor();
}
-
void lcl_SvNumberformat_AddLimitStringImpl( String& rStr,
SvNumberformatLimitOps eOp, double fLimit, const String& rDecSep )
{
@@ -4164,7 +4170,6 @@ void lcl_SvNumberformat_AddLimitStringImpl( String& rStr,
}
}
-
String SvNumberformat::GetMappedFormatstring(
const NfKeywordTable& rKeywords, const LocaleDataWrapper& rLocWrp,
BOOL bDontQuote ) const
@@ -4326,7 +4331,6 @@ String SvNumberformat::GetMappedFormatstring(
return aStr;
}
-
String SvNumberformat::ImpGetNatNumString( const SvNumberNatNum& rNum,
sal_Int32 nVal, USHORT nMinDigits ) const
{
@@ -4362,7 +4366,6 @@ String SvNumberformat::ImpGetNatNumString( const SvNumberNatNum& rNum,
return aStr;
}
-
void SvNumberformat::ImpTransliterateImpl( String& rStr,
const SvNumberNatNum& rNum ) const
{
@@ -4372,7 +4375,6 @@ void SvNumberformat::ImpTransliterateImpl( String& rStr,
aLocale, rNum.GetNatNum() );
}
-
void SvNumberformat::GetNatNumXml(
com::sun::star::i18n::NativeNumberXmlAttributes& rAttr,
USHORT nNumFor ) const
@@ -4418,7 +4420,6 @@ BOOL SvNumberformat::HasStringNegativeSign( const String& rStr )
return FALSE;
}
-
// static
void SvNumberformat::SetComment( const String& rStr, String& rFormat,
String& rComment )
@@ -4450,7 +4451,6 @@ void SvNumberformat::SetComment( const String& rStr, String& rFormat,
}
}
-
// static
void SvNumberformat::EraseCommentBraces( String& rStr )
{
@@ -4471,7 +4471,6 @@ void SvNumberformat::EraseCommentBraces( String& rStr )
rStr.Erase( --nLen, 1 );
}
-
// static
void SvNumberformat::EraseComment( String& rStr )
{
@@ -4508,7 +4507,6 @@ void SvNumberformat::EraseComment( String& rStr )
rStr.Erase( nPos );
}
-
// static
BOOL SvNumberformat::IsInQuote( const String& rStr, xub_StrLen nPos,
sal_Unicode cQuote, sal_Unicode cEscIn, sal_Unicode cEscOut )
@@ -4542,7 +4540,6 @@ BOOL SvNumberformat::IsInQuote( const String& rStr, xub_StrLen nPos,
return bQuoted;
}
-
// static
xub_StrLen SvNumberformat::GetQuoteEnd( const String& rStr, xub_StrLen nPos,
sal_Unicode cQuote, sal_Unicode cEscIn, sal_Unicode cEscOut )
@@ -4568,7 +4565,6 @@ xub_StrLen SvNumberformat::GetQuoteEnd( const String& rStr, xub_StrLen nPos,
return nLen; // String Ende
}
-
USHORT SvNumberformat::ImpGetNumForStringElementCount( USHORT nNumFor ) const
{
USHORT nCnt = 0;
diff --git a/svl/source/numbers/zforscan.cxx b/svl/source/numbers/zforscan.cxx
index e0bb022..a456a64 100644
--- a/svl/source/numbers/zforscan.cxx
+++ b/svl/source/numbers/zforscan.cxx
@@ -2,7 +2,7 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
+ *
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
@@ -49,7 +49,7 @@ using namespace svt;
const sal_Unicode cNonBreakingSpace = 0xA0;
-namespace
+namespace
{
struct ImplEnglishColors
{
@@ -123,7 +123,6 @@ ImpSvNumberformatScan::~ImpSvNumberformatScan()
Reset();
}
-
void ImpSvNumberformatScan::ChangeIntl()
{
bKeywordsNeedInit = TRUE;
@@ -133,7 +132,6 @@ void ImpSvNumberformatScan::ChangeIntl()
sKeyword[NF_KEY_FALSE].Erase();
}
-
void ImpSvNumberformatScan::InitSpecialKeyword( NfKeywordIndex eIdx ) const
{
switch ( eIdx )
@@ -163,7 +161,6 @@ void ImpSvNumberformatScan::InitSpecialKeyword( NfKeywordIndex eIdx ) const
}
}
-
void ImpSvNumberformatScan::InitCompatCur() const
{
ImpSvNumberformatScan* pThis = (ImpSvNumberformatScan*)this;
@@ -174,7 +171,6 @@ void ImpSvNumberformatScan::InitCompatCur() const
bCompatCurNeedInit = FALSE;
}
-
void ImpSvNumberformatScan::InitKeywords() const
{
if ( !bKeywordsNeedInit )
@@ -183,7 +179,6 @@ void ImpSvNumberformatScan::InitKeywords() const
bKeywordsNeedInit = FALSE;
}
-
/** Extract the name of General, Standard, Whatever, ignoring leading modifiers
such as [NatNum1]. */
static String lcl_extractStandardGeneralName( const ::rtl::OUString & rCode )
@@ -227,7 +222,6 @@ static String lcl_extractStandardGeneralName( const ::rtl::OUString & rCode )
return aStr;
}
-
void ImpSvNumberformatScan::SetDependentKeywords()
{
using namespace ::com::sun::star;
@@ -455,7 +449,6 @@ void ImpSvNumberformatScan::SetDependentKeywords()
InitCompatCur();
}
-
void ImpSvNumberformatScan::ChangeNullDate(USHORT nDay, USHORT nMonth, USHORT nYear)
{
if ( pNullDate )
@@ -487,7 +480,7 @@ Color* ImpSvNumberformatScan::GetColor(String& sStr)
if ( j < NF_MAX_DEFAULT_COLORS )
i = j;
}
-
+
Color* pResult = NULL;
if (i >= NF_MAX_DEFAULT_COLORS)
{
@@ -535,7 +528,6 @@ Color* ImpSvNumberformatScan::GetColor(String& sStr)
return pResult;
}
-
short ImpSvNumberformatScan::GetKeyWord( const String& sSymbol, xub_StrLen nPos )
{
String sString = pFormatter->GetCharClass()->toUpper( sSymbol, nPos, sSymbol.Len() - nPos );
@@ -956,7 +948,6 @@ void ImpSvNumberformatScan::SkipStrings(USHORT& i, xub_StrLen& nPos)
}
}
-
USHORT ImpSvNumberformatScan::PreviousKeyword(USHORT i)
{
short res = 0;
@@ -1088,7 +1079,6 @@ void ImpSvNumberformatScan::Reset()
nNatNumModifier = 0;
}
-
BOOL ImpSvNumberformatScan::Is100SecZero( USHORT i, BOOL bHadDecSep )
{
USHORT nIndexPre = PreviousKeyword( i );
@@ -1098,7 +1088,6 @@ BOOL ImpSvNumberformatScan::Is100SecZero( USHORT i, BOOL bHadDecSep )
// SS"any"00 take "any" as a valid decimal separator
}
-
xub_StrLen ImpSvNumberformatScan::ScanType(const String&)
{
const LocaleDataWrapper* pLoc = pFormatter->GetLocaleData();
@@ -1407,7 +1396,6 @@ xub_StrLen ImpSvNumberformatScan::ScanType(const String&)
return 0; // Alles ok
}
-
bool ImpSvNumberformatScan::InsertSymbol( USHORT & nPos, svt::NfSymbolType eType, const String& rStr )
{
if (nAnzStrings >= NF_MAX_FORMAT_SYMBOLS || nPos > nAnzStrings)
@@ -1429,7 +1417,6 @@ bool ImpSvNumberformatScan::InsertSymbol( USHORT & nPos, svt::NfSymbolType eType
return true;
}
-
int ImpSvNumberformatScan::FinalScanGetCalendar( xub_StrLen& nPos, USHORT& i,
USHORT& rAnzResStrings )
{
@@ -1561,6 +1548,8 @@ xub_StrLen ImpSvNumberformatScan::FinalScan( String& rString, String& rComment )
sal_Unicode cThousandFill = ' ';
while (i < nAnzStrings)
{
+ // TODO: rechecking eScannedType is unnecessary.
+ // This switch-case is for eScannedType == NUMBERFORMAT_FRACTION anyway
if (eScannedType == NUMBERFORMAT_FRACTION && // special case
nTypeArray[i] == NF_SYMBOLTYPE_DEL && // # ### #/#
StringEqualsChar( sOldThousandSep, ' ' ) && // e.g. France or Sweden
@@ -1571,7 +1560,6 @@ xub_StrLen ImpSvNumberformatScan::FinalScan( String& rString, String& rComment )
nTypeArray[i] = NF_SYMBOLTYPE_STRING; // del->string
} // kein Taus.p.
-
if (nTypeArray[i] == NF_SYMBOLTYPE_BLANK ||
nTypeArray[i] == NF_SYMBOLTYPE_STAR ||
nTypeArray[i] == NF_KEY_CCC || // CCC
@@ -1622,6 +1610,26 @@ xub_StrLen ImpSvNumberformatScan::FinalScan( String& rString, String& rComment )
bThaiT = true;
sStrArray[i] = sKeyword[nTypeArray[i]];
}
+ else if (sStrArray[i].GetChar(0) >= '0' &&
+ sStrArray[i].GetChar(0) <= '9')
+ {
+ rtl::OUString sDiv;
+ USHORT j = i;
+ while(j < nAnzStrings)
+ sDiv += sStrArray[j++];
+ if (rtl::OUString::valueOf(sDiv.toInt32()) == sDiv)
+ {
+ /* Found a Divisor */
+ sal_Int32 nDiv = sDiv.toInt32();
+ while (i < j)
+ nTypeArray[i++] = NF_SYMBOLTYPE_FRAC_FDIV;
+ i = j - 1; // Stop the loop
+ if (nCntPost)
+ nCounter = nCntPost;
+ else if (nCntPre)
+ nCounter = nCntPre;
+ }
+ }
else
nTypeArray[i] = NF_SYMBOLTYPE_STRING;
nPos = nPos + sStrArray[i].Len();
@@ -2748,7 +2756,6 @@ xub_StrLen ImpSvNumberformatScan::FinalScan( String& rString, String& rComment )
return 0;
}
-
xub_StrLen ImpSvNumberformatScan::RemoveQuotes( String& rStr )
{
if ( rStr.Len() > 1 )
@@ -2770,7 +2777,6 @@ xub_StrLen ImpSvNumberformatScan::RemoveQuotes( String& rStr )
return 0;
}
-
xub_StrLen ImpSvNumberformatScan::ScanFormat( String& rString, String& rComment )
{
xub_StrLen res = Symbol_Division(rString); //lexikalische Analyse
@@ -2805,5 +2811,4 @@ void ImpSvNumberformatScan::CopyInfo(ImpSvNumberformatInfo* pInfo, USHORT nAnz)
pInfo->nCntExp = nCntExp;
}
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
More information about the Libreoffice-commits
mailing list