Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(178)

Side by Side Diff: fpdfsdk/src/javascript/Field.cpp

Issue 1582013002: Cleanup CJS_PublicMethods::ParseNumber (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Update bug_361_expected.txt Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | fpdfsdk/src/javascript/PublicMethods.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "Field.h" 7 #include "Field.h"
8 8
9 #include "Document.h" 9 #include "Document.h"
10 #include "Icon.h" 10 #include "Icon.h"
(...skipping 2723 matching lines...) Expand 10 before | Expand all | Expand 10 after
2734 2734
2735 CPDF_FormField* pFormField = FieldArray[0]; 2735 CPDF_FormField* pFormField = FieldArray[0];
2736 switch (pFormField->GetFieldType()) { 2736 switch (pFormField->GetFieldType()) {
2737 case FIELDTYPE_PUSHBUTTON: 2737 case FIELDTYPE_PUSHBUTTON:
2738 return FALSE; 2738 return FALSE;
2739 case FIELDTYPE_COMBOBOX: 2739 case FIELDTYPE_COMBOBOX:
2740 case FIELDTYPE_TEXTFIELD: { 2740 case FIELDTYPE_TEXTFIELD: {
2741 CFX_WideString swValue = pFormField->GetValue(); 2741 CFX_WideString swValue = pFormField->GetValue();
2742 2742
2743 double dRet; 2743 double dRet;
2744 FX_BOOL bDot; 2744 if (CJS_PublicMethods::ConvertStringToNumber(swValue.c_str(), dRet)) {
2745 if (CJS_PublicMethods::ConvertStringToNumber(swValue.c_str(), dRet, 2745 vp << dRet;
2746 bDot)) {
2747 if (bDot)
2748 vp << dRet;
2749 else
2750 vp << dRet;
2751 } else { 2746 } else {
2752 vp << swValue; 2747 vp << swValue;
2753 } 2748 }
2754 } break; 2749 } break;
2755 case FIELDTYPE_LISTBOX: { 2750 case FIELDTYPE_LISTBOX: {
2756 if (pFormField->CountSelectedItems() > 1) { 2751 if (pFormField->CountSelectedItems() > 1) {
2757 CJS_Array ValueArray(pRuntime); 2752 CJS_Array ValueArray(pRuntime);
2758 CJS_Value ElementValue(pRuntime); 2753 CJS_Value ElementValue(pRuntime);
2759 int iIndex; 2754 int iIndex;
2760 for (int i = 0, sz = pFormField->CountSelectedItems(); i < sz; i++) { 2755 for (int i = 0, sz = pFormField->CountSelectedItems(); i < sz; i++) {
2761 iIndex = pFormField->GetSelectedIndex(i); 2756 iIndex = pFormField->GetSelectedIndex(i);
2762 ElementValue = pFormField->GetOptionValue(iIndex).c_str(); 2757 ElementValue = pFormField->GetOptionValue(iIndex).c_str();
2763 if (FXSYS_wcslen(ElementValue.ToCFXWideString().c_str()) == 0) 2758 if (FXSYS_wcslen(ElementValue.ToCFXWideString().c_str()) == 0)
2764 ElementValue = pFormField->GetOptionLabel(iIndex).c_str(); 2759 ElementValue = pFormField->GetOptionLabel(iIndex).c_str();
2765 ValueArray.SetElement(i, ElementValue); 2760 ValueArray.SetElement(i, ElementValue);
2766 } 2761 }
2767 vp << ValueArray; 2762 vp << ValueArray;
2768 } else { 2763 } else {
2769 CFX_WideString swValue = pFormField->GetValue(); 2764 CFX_WideString swValue = pFormField->GetValue();
2770 2765
2771 double dRet; 2766 double dRet;
2772 FX_BOOL bDot; 2767 if (CJS_PublicMethods::ConvertStringToNumber(swValue.c_str(), dRet)) {
2773 if (CJS_PublicMethods::ConvertStringToNumber(swValue.c_str(), dRet, 2768 vp << dRet;
2774 bDot)) {
2775 if (bDot)
2776 vp << dRet;
2777 else
2778 vp << dRet;
2779 } else { 2769 } else {
2780 vp << swValue; 2770 vp << swValue;
2781 } 2771 }
2782 } 2772 }
2783 } break; 2773 } break;
2784 case FIELDTYPE_CHECKBOX: 2774 case FIELDTYPE_CHECKBOX:
2785 case FIELDTYPE_RADIOBUTTON: { 2775 case FIELDTYPE_RADIOBUTTON: {
2786 FX_BOOL bFind = FALSE; 2776 FX_BOOL bFind = FALSE;
2787 for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) { 2777 for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) {
2788 if (!pFormField->GetControl(i)->IsChecked()) 2778 if (!pFormField->GetControl(i)->IsChecked())
2789 continue; 2779 continue;
2790 2780
2791 CFX_WideString swValue = pFormField->GetControl(i)->GetExportValue(); 2781 CFX_WideString swValue = pFormField->GetControl(i)->GetExportValue();
2792 double dRet; 2782 double dRet;
2793 FX_BOOL bDotDummy; 2783 if (CJS_PublicMethods::ConvertStringToNumber(swValue.c_str(), dRet)) {
2794 if (CJS_PublicMethods::ConvertStringToNumber(swValue.c_str(), dRet,
2795 bDotDummy)) {
2796 vp << dRet; 2784 vp << dRet;
2797 } else { 2785 } else {
2798 vp << swValue; 2786 vp << swValue;
2799 } 2787 }
2800 2788
2801 bFind = TRUE; 2789 bFind = TRUE;
2802 break; 2790 break;
2803 } 2791 }
2804 if (!bFind) 2792 if (!bFind)
2805 vp << L"Off"; 2793 vp << L"Off";
(...skipping 814 matching lines...) Expand 10 before | Expand all | Expand 10 after
3620 } 3608 }
3621 } 3609 }
3622 3610
3623 void Field::AddField(CPDFSDK_Document* pDocument, 3611 void Field::AddField(CPDFSDK_Document* pDocument,
3624 int nPageIndex, 3612 int nPageIndex,
3625 int nFieldType, 3613 int nFieldType,
3626 const CFX_WideString& sName, 3614 const CFX_WideString& sName,
3627 const CPDF_Rect& rcCoords) { 3615 const CPDF_Rect& rcCoords) {
3628 // Not supported. 3616 // Not supported.
3629 } 3617 }
OLDNEW
« no previous file with comments | « no previous file | fpdfsdk/src/javascript/PublicMethods.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698