summaryrefslogtreecommitdiff
path: root/svl
diff options
context:
space:
mode:
authorLaurent Balland-Poirier <laurent.balland-poirier@laposte.net>2016-05-04 23:47:09 +0200
committerEike Rathke <erack@redhat.com>2016-05-09 14:07:14 +0000
commit8f8fa5674d3853ed8ca6762b512e6b63c53f1039 (patch)
treee7b0aa155d19450cb1b4436f57540d97c72b264a /svl
parentc47f6d35ee101531452b3035aa5042709d8a44e6 (diff)
tdf#88657 calculate denominator length
Get length of denominator which could be different from numerator length Change-Id: I9f5c10917185eb029d52efbc0f20be5f81c74d10 Reviewed-on: https://gerrit.libreoffice.org/24712 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'svl')
-rw-r--r--svl/source/numbers/zformat.cxx23
1 files changed, 15 insertions, 8 deletions
diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx
index f3d0e6c2e98c..61da0969f23a 100644
--- a/svl/source/numbers/zformat.cxx
+++ b/svl/source/numbers/zformat.cxx
@@ -2004,18 +2004,25 @@ void lcl_GetOutputStringScientific(double fNumber, sal_uInt16 nCharCount,
nPrec, rFormatter.GetNumDecimalSep()[0], true );
}
-sal_Int32 lcl_GetForcedDenominator(const ImpSvNumberformatInfo &rInfo, sal_uInt16 nAnz)
+
+OUString lcl_GetDenominatorString(const ImpSvNumberformatInfo &rInfo, sal_uInt16 nAnz)
{
sal_uInt16 i;
- OUString aDiv;
+ OUStringBuffer aDenominatorString;
for( i = 0; i < nAnz; i++ )
{
- if( rInfo.nTypeArray[i] == NF_SYMBOLTYPE_FRAC_FDIV )
+ if( rInfo.nTypeArray[i] == NF_SYMBOLTYPE_FRAC )
{
- aDiv += rInfo.sStrArray[i];
+ for( i++; i < nAnz; i++ )
+ {
+ if( rInfo.nTypeArray[i] == NF_SYMBOLTYPE_FRAC_FDIV || rInfo.nTypeArray[i] == NF_SYMBOLTYPE_DIGIT )
+ aDenominatorString.append( rInfo.sStrArray[i] );
+ else
+ i = nAnz;
+ }
}
}
- return aDiv.toInt32();
+ return aDenominatorString.makeStringAndClear();
}
// TODO: More optimizations?
@@ -2037,11 +2044,11 @@ void lcl_ForcedDenominator(sal_uLong &nFrac, sal_uLong &nDiv, sal_uLong nForcedD
}
-sal_Int32 SvNumberformat::GetForcedDenominatorForType( sal_uInt16 nNumFor ) const
+OUString SvNumberformat::GetDenominatorString( sal_uInt16 nNumFor ) const
{
const ImpSvNumberformatInfo& rInfo = NumFor[nNumFor].Info();
sal_uInt16 nAnz = NumFor[nNumFor].GetCount();
- return lcl_GetForcedDenominator( rInfo, nAnz );
+ return lcl_GetDenominatorString( rInfo, nAnz );
}
bool SvNumberformat::GetOutputString(double fNumber, sal_uInt16 nCharCount, OUString& rOutString) const
@@ -2613,7 +2620,7 @@ bool SvNumberformat::ImpGetFractionOutput(double fNumber,
}
}
- if( sal_Int32 nForcedDiv = lcl_GetForcedDenominator(NumFor[nIx].Info(), nAnz) )
+ if( sal_Int32 nForcedDiv = lcl_GetDenominatorString(NumFor[nIx].Info(), nAnz).toInt32() )
{
lcl_ForcedDenominator(nFrac, nDiv, nForcedDiv);
if( nFrac >= nDiv )