summaryrefslogtreecommitdiff
path: root/fpdfsdk/src/javascript/Field.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2016-01-20 11:48:29 -0800
committerTom Sepez <tsepez@chromium.org>2016-01-20 11:48:29 -0800
commit4246b0015732d7611ad6838b76b85161fab3795e (patch)
tree97591bdfa54a443abd025943788af65a9a82291f /fpdfsdk/src/javascript/Field.cpp
parentc4fd5c183142aef5ae93b918b65a0bf01d2a0a1e (diff)
downloadpdfium-4246b0015732d7611ad6838b76b85161fab3795e.tar.xz
Merge to XFA: Bugs in CJS_PublicMethods::ParseNumber().
Original Review URL: https://codereview.chromium.org/1586203006 . (cherry picked from commit f13d510cf267c27f4c123494de67670ec201cedc) BUG=pdfium:361 R=ochang@chromium.org TBR=ochang@chromium.org Review URL: https://codereview.chromium.org/1603173004 .
Diffstat (limited to 'fpdfsdk/src/javascript/Field.cpp')
-rw-r--r--fpdfsdk/src/javascript/Field.cpp50
1 files changed, 8 insertions, 42 deletions
diff --git a/fpdfsdk/src/javascript/Field.cpp b/fpdfsdk/src/javascript/Field.cpp
index 7baefd111c..1b55515069 100644
--- a/fpdfsdk/src/javascript/Field.cpp
+++ b/fpdfsdk/src/javascript/Field.cpp
@@ -2737,19 +2737,7 @@ FX_BOOL Field::value(IJS_Context* cc,
return FALSE;
case FIELDTYPE_COMBOBOX:
case FIELDTYPE_TEXTFIELD: {
- CFX_WideString swValue = pFormField->GetValue();
-
- double dRet;
- FX_BOOL bDot;
- if (CJS_PublicMethods::ConvertStringToNumber(swValue.c_str(), dRet,
- bDot)) {
- if (bDot)
- vp << dRet;
- else
- vp << dRet;
- } else {
- vp << swValue;
- }
+ vp << pFormField->GetValue();
} break;
case FIELDTYPE_LISTBOX: {
if (pFormField->CountSelectedItems() > 1) {
@@ -2765,40 +2753,18 @@ FX_BOOL Field::value(IJS_Context* cc,
}
vp << ValueArray;
} else {
- CFX_WideString swValue = pFormField->GetValue();
-
- double dRet;
- FX_BOOL bDot;
- if (CJS_PublicMethods::ConvertStringToNumber(swValue.c_str(), dRet,
- bDot)) {
- if (bDot)
- vp << dRet;
- else
- vp << dRet;
- } else {
- vp << swValue;
- }
+ vp << pFormField->GetValue();
}
} break;
case FIELDTYPE_CHECKBOX:
case FIELDTYPE_RADIOBUTTON: {
- FX_BOOL bFind = FALSE;
+ bool bFind = false;
for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) {
- if (!pFormField->GetControl(i)->IsChecked())
- continue;
-
- CFX_WideString swValue = pFormField->GetControl(i)->GetExportValue();
- double dRet;
- FX_BOOL bDotDummy;
- if (CJS_PublicMethods::ConvertStringToNumber(swValue.c_str(), dRet,
- bDotDummy)) {
- vp << dRet;
- } else {
- vp << swValue;
+ if (pFormField->GetControl(i)->IsChecked()) {
+ vp << pFormField->GetControl(i)->GetExportValue();
+ bFind = true;
+ break;
}
-
- bFind = TRUE;
- break;
}
if (!bFind)
vp << L"Off";
@@ -2808,7 +2774,7 @@ FX_BOOL Field::value(IJS_Context* cc,
break;
}
}
-
+ vp.MaybeCoerceToNumber();
return TRUE;
}