summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Balland-Poirier <laurent.balland-poirier@laposte.net>2015-03-20 08:22:22 +0100
committerEike Rathke <erack@redhat.com>2015-03-23 11:40:12 +0000
commit2b838285e206912374f464bd1ab8dc8a561f59f5 (patch)
treeed8b7ce7fb53c83377f3a8e0fe9f0c391704d42a
parent09f399d13d65b9aafa3108cb006b55b92d4bbbca (diff)
tdf#90133 Scientific format: allow variable decimal
This commit treats variable decimal in the same way for scientfic format as for number format Change-Id: Ibc3f88150e2a8e353d35415da78998ec8c201e8b Reviewed-on: https://gerrit.libreoffice.org/14918 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.hxx6
-rw-r--r--svl/source/numbers/zformat.cxx36
2 files changed, 30 insertions, 12 deletions
diff --git a/include/svl/zformat.hxx b/include/svl/zformat.hxx
index e6d4bf908561..08415f9d10fd 100644
--- a/include/svl/zformat.hxx
+++ b/include/svl/zformat.hxx
@@ -592,6 +592,12 @@ private:
sal_Int32 & nDigitCount,
utl::DigitGroupingIterator & );
+ SVL_DLLPRIVATE bool ImpDecimalFill( OUStringBuffer& sStr,
+ double& rNumber,
+ sal_uInt16 j,
+ sal_uInt16 nIx,
+ bool bInteger );
+
SVL_DLLPRIVATE bool ImpGetFractionOutput(double fNumber,
sal_uInt16 nIx,
OUStringBuffer& OutString);
diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx
index 41a99e8a8d0c..9b22cacf26be 100644
--- a/svl/source/numbers/zformat.cxx
+++ b/svl/source/numbers/zformat.cxx
@@ -2375,10 +2375,9 @@ bool SvNumberformat::ImpGetScientificOutput(double fNumber,
}
else
{
- k = sStr.getLength(); // After last figure
- bRes |= ImpNumberFillWithThousands(sStr, fNumber, k, j, nIx,
- rInfo.nCntPre + rInfo.nCntPost);
+ bRes |= ImpDecimalFill(sStr, fNumber, j, nIx, false);
}
+
if (bSign)
{
sStr.insert(0, '-');
@@ -3868,7 +3867,6 @@ bool SvNumberformat::ImpGetNumberOutput(double fNumber,
}
}
sal_uInt16 i, j;
- sal_Int32 k;
bool bInteger = false;
if ( rInfo.nThousand != FLAG_STANDARD_IN_FORMAT )
{
@@ -3940,9 +3938,27 @@ bool SvNumberformat::ImpGetNumberOutput(double fNumber,
} // End of != FLAG_STANDARD_IN_FORMAT
// Edit backwards:
- k = sStr.getLength(); // After last figure
j = NumFor[nIx].GetCount()-1; // Last symbol
// Decimal places:
+ bRes |= ImpDecimalFill( sStr, fNumber, j, nIx, bInteger );
+ if (bSign)
+ {
+ sStr.insert(0, '-');
+ }
+ impTransliterate(sStr, NumFor[nIx].GetNatNum());
+ return bRes;
+}
+
+bool SvNumberformat::ImpDecimalFill( OUStringBuffer& sStr, // number string
+ double& rNumber, // number
+ sal_uInt16 j, // symbol index within format code
+ sal_uInt16 nIx, // subformat index
+ bool bInteger) // is integer
+{
+ bool bRes = false;
+ const ImpSvNumberformatInfo& rInfo = NumFor[nIx].Info();
+ sal_Int32 k = sStr.getLength(); // After last figure
+ // Decimal places:
if (rInfo.nCntPost > 0)
{
bool bTrailing = true; // Trailing zeros?
@@ -4020,7 +4036,7 @@ bool SvNumberformat::ImpGetNumberOutput(double fNumber,
case NF_KEY_GENERAL: // Standard in the String
{
OUStringBuffer sNum;
- ImpGetOutputStandard(fNumber, sNum);
+ ImpGetOutputStandard(rNumber, sNum);
sNum.stripStart('-');
sStr.insert(k, sNum.makeStringAndClear());
break;
@@ -4032,7 +4048,7 @@ bool SvNumberformat::ImpGetNumberOutput(double fNumber,
} // of while
} // of decimal places
- bRes |= ImpNumberFillWithThousands(sStr, fNumber, k, j, nIx, // Fill with . if needed
+ bRes |= ImpNumberFillWithThousands(sStr, rNumber, k, j, nIx, // Fill with . if needed
rInfo.nCntPre);
if ( rInfo.nCntPost > 0 )
{
@@ -4043,11 +4059,7 @@ bool SvNumberformat::ImpGetNumberOutput(double fNumber,
sStr.truncate( sStr.getLength() - nLen ); // no decimals => strip DecSep
}
}
- if (bSign)
- {
- sStr.insert(0, '-');
- }
- impTransliterate(sStr, NumFor[nIx].GetNatNum());
+
return bRes;
}