summaryrefslogtreecommitdiff
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
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>
-rw-r--r--include/svl/zformat.hxx2
-rw-r--r--svl/source/numbers/zformat.cxx23
-rw-r--r--xmloff/source/style/xmlnumfe.cxx6
3 files changed, 20 insertions, 11 deletions
diff --git a/include/svl/zformat.hxx b/include/svl/zformat.hxx
index 41179583c0c7..916a0d3004c8 100644
--- a/include/svl/zformat.hxx
+++ b/include/svl/zformat.hxx
@@ -249,7 +249,7 @@ public:
// nPos == 0xFFFF => last substring
short GetNumForType( sal_uInt16 nNumFor, sal_uInt16 nPos ) const;
- sal_Int32 GetForcedDenominatorForType( sal_uInt16 nNumFor ) const;
+ OUString GetDenominatorString( sal_uInt16 nNumFor ) const;
/** If the count of string elements (substrings, ignoring [modifiers] and
so on) in a subformat code nNumFor (0..3) is equal to the given number.
Used by ImpSvNumberInputScan::IsNumberFormatMain() to detect a matched
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 )
diff --git a/xmloff/source/style/xmlnumfe.cxx b/xmloff/source/style/xmlnumfe.cxx
index 9494439bd69b..218321e91f58 100644
--- a/xmloff/source/style/xmlnumfe.cxx
+++ b/xmloff/source/style/xmlnumfe.cxx
@@ -1470,8 +1470,10 @@ void SvXMLNumFmtExport::ExportPart_Impl( const SvNumberformat& rFormat, sal_uInt
// min-integer-digits attribute must be written.
nInteger = -1;
}
- sal_Int32 nDenominator = rFormat.GetForcedDenominatorForType( nPart );
- WriteFractionElement_Impl( nInteger, bThousand, nPrecision, nPrecision, nDenominator );
+ OUString aDenominatorString = rFormat.GetDenominatorString( nPart );
+ sal_Int32 nDenominator = aDenominatorString.toInt32();
+ sal_Int32 nDenominatorLength = aDenominatorString.getLength();
+ WriteFractionElement_Impl( nInteger, bThousand, nPrecision, nDenominatorLength, nDenominator );
bAnyContent = true;
}
break;