Index: source/i18n/quantityformatter.cpp |
diff --git a/source/i18n/quantityformatter.cpp b/source/i18n/quantityformatter.cpp |
index bef509a718691f08cbd628bb98ba4fb313f8fdbf..ed80b38b500d1465db2ec2388bbba08ad9ee1fb6 100644 |
--- a/source/i18n/quantityformatter.cpp |
+++ b/source/i18n/quantityformatter.cpp |
@@ -1,6 +1,6 @@ |
/* |
****************************************************************************** |
-* Copyright (C) 2014, International Business Machines |
+* Copyright (C) 2014-2015, International Business Machines |
* Corporation and others. All Rights Reserved. |
****************************************************************************** |
* quantityformatter.cpp |
@@ -11,11 +11,11 @@ |
#include "unicode/unistr.h" |
#include "unicode/decimfmt.h" |
#include "cstring.h" |
-#include "plurrule_impl.h" |
#include "unicode/plurrule.h" |
#include "charstr.h" |
#include "unicode/fmtable.h" |
#include "unicode/fieldpos.h" |
+#include "visibledigits.h" |
#if !UCONFIG_NO_FORMATTING |
@@ -136,13 +136,14 @@ UnicodeString &QuantityFormatter::format( |
return appendTo; |
} |
UnicodeString count; |
+ VisibleDigitsWithExponent digits; |
const DecimalFormat *decFmt = dynamic_cast<const DecimalFormat *>(&fmt); |
if (decFmt != NULL) { |
- FixedDecimal fd = decFmt->getFixedDecimal(quantity, status); |
+ decFmt->initVisibleDigitsWithExponent(quantity, digits, status); |
if (U_FAILURE(status)) { |
return appendTo; |
} |
- count = rules.select(fd); |
+ count = rules.select(digits); |
} else { |
if (quantity.getType() == Formattable::kDouble) { |
count = rules.select(quantity.getDouble()); |
@@ -167,10 +168,20 @@ UnicodeString &QuantityFormatter::format( |
} |
UnicodeString formattedNumber; |
FieldPosition fpos(pos.getField()); |
- fmt.format(quantity, formattedNumber, fpos, status); |
+ if (decFmt != NULL) { |
+ decFmt->format(digits, formattedNumber, fpos, status); |
+ } else { |
+ fmt.format(quantity, formattedNumber, fpos, status); |
+ } |
const UnicodeString *params[1] = {&formattedNumber}; |
int32_t offsets[1]; |
- pattern->format(params, UPRV_LENGTHOF(params), appendTo, offsets, UPRV_LENGTHOF(offsets), status); |
+ pattern->formatAndAppend( |
+ params, |
+ UPRV_LENGTHOF(params), |
+ appendTo, |
+ offsets, |
+ UPRV_LENGTHOF(offsets), |
+ status); |
if (offsets[0] != -1) { |
if (fpos.getBeginIndex() != 0 || fpos.getEndIndex() != 0) { |
pos.setBeginIndex(fpos.getBeginIndex() + offsets[0]); |