[Libreoffice-commits] core.git: include/svl svl/source xmloff/source
Laurent Balland-Poirier
laurent.balland-poirier at laposte.net
Mon May 9 14:07:41 UTC 2016
include/svl/zformat.hxx | 2 +-
svl/source/numbers/zformat.cxx | 23 +++++++++++++++--------
xmloff/source/style/xmlnumfe.cxx | 6 ++++--
3 files changed, 20 insertions(+), 11 deletions(-)
New commits:
commit 8f8fa5674d3853ed8ca6762b512e6b63c53f1039
Author: Laurent Balland-Poirier <laurent.balland-poirier at laposte.net>
Date: Wed May 4 23:47:09 2016 +0200
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 at libreoffice.org>
Reviewed-by: Eike Rathke <erack at redhat.com>
Tested-by: Eike Rathke <erack at redhat.com>
diff --git a/include/svl/zformat.hxx b/include/svl/zformat.hxx
index 4117958..916a0d3 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 f3d0e6c..61da096 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 9494439..218321e 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;
More information about the Libreoffice-commits
mailing list