OLD | NEW |
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 Loading... |
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 if (CJS_PublicMethods::ConvertStringToNumber(swValue.c_str(), dRet)) { | 2744 FX_BOOL bDot; |
2745 vp << dRet; | 2745 if (CJS_PublicMethods::ConvertStringToNumber(swValue.c_str(), dRet, |
| 2746 bDot)) { |
| 2747 if (bDot) |
| 2748 vp << dRet; |
| 2749 else |
| 2750 vp << dRet; |
2746 } else { | 2751 } else { |
2747 vp << swValue; | 2752 vp << swValue; |
2748 } | 2753 } |
2749 } break; | 2754 } break; |
2750 case FIELDTYPE_LISTBOX: { | 2755 case FIELDTYPE_LISTBOX: { |
2751 if (pFormField->CountSelectedItems() > 1) { | 2756 if (pFormField->CountSelectedItems() > 1) { |
2752 CJS_Array ValueArray(pRuntime); | 2757 CJS_Array ValueArray(pRuntime); |
2753 CJS_Value ElementValue(pRuntime); | 2758 CJS_Value ElementValue(pRuntime); |
2754 int iIndex; | 2759 int iIndex; |
2755 for (int i = 0, sz = pFormField->CountSelectedItems(); i < sz; i++) { | 2760 for (int i = 0, sz = pFormField->CountSelectedItems(); i < sz; i++) { |
2756 iIndex = pFormField->GetSelectedIndex(i); | 2761 iIndex = pFormField->GetSelectedIndex(i); |
2757 ElementValue = pFormField->GetOptionValue(iIndex).c_str(); | 2762 ElementValue = pFormField->GetOptionValue(iIndex).c_str(); |
2758 if (FXSYS_wcslen(ElementValue.ToCFXWideString().c_str()) == 0) | 2763 if (FXSYS_wcslen(ElementValue.ToCFXWideString().c_str()) == 0) |
2759 ElementValue = pFormField->GetOptionLabel(iIndex).c_str(); | 2764 ElementValue = pFormField->GetOptionLabel(iIndex).c_str(); |
2760 ValueArray.SetElement(i, ElementValue); | 2765 ValueArray.SetElement(i, ElementValue); |
2761 } | 2766 } |
2762 vp << ValueArray; | 2767 vp << ValueArray; |
2763 } else { | 2768 } else { |
2764 CFX_WideString swValue = pFormField->GetValue(); | 2769 CFX_WideString swValue = pFormField->GetValue(); |
2765 | 2770 |
2766 double dRet; | 2771 double dRet; |
2767 if (CJS_PublicMethods::ConvertStringToNumber(swValue.c_str(), dRet)) { | 2772 FX_BOOL bDot; |
2768 vp << dRet; | 2773 if (CJS_PublicMethods::ConvertStringToNumber(swValue.c_str(), dRet, |
| 2774 bDot)) { |
| 2775 if (bDot) |
| 2776 vp << dRet; |
| 2777 else |
| 2778 vp << dRet; |
2769 } else { | 2779 } else { |
2770 vp << swValue; | 2780 vp << swValue; |
2771 } | 2781 } |
2772 } | 2782 } |
2773 } break; | 2783 } break; |
2774 case FIELDTYPE_CHECKBOX: | 2784 case FIELDTYPE_CHECKBOX: |
2775 case FIELDTYPE_RADIOBUTTON: { | 2785 case FIELDTYPE_RADIOBUTTON: { |
2776 FX_BOOL bFind = FALSE; | 2786 FX_BOOL bFind = FALSE; |
2777 for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) { | 2787 for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) { |
2778 if (!pFormField->GetControl(i)->IsChecked()) | 2788 if (!pFormField->GetControl(i)->IsChecked()) |
2779 continue; | 2789 continue; |
2780 | 2790 |
2781 CFX_WideString swValue = pFormField->GetControl(i)->GetExportValue(); | 2791 CFX_WideString swValue = pFormField->GetControl(i)->GetExportValue(); |
2782 double dRet; | 2792 double dRet; |
2783 if (CJS_PublicMethods::ConvertStringToNumber(swValue.c_str(), dRet)) { | 2793 FX_BOOL bDotDummy; |
| 2794 if (CJS_PublicMethods::ConvertStringToNumber(swValue.c_str(), dRet, |
| 2795 bDotDummy)) { |
2784 vp << dRet; | 2796 vp << dRet; |
2785 } else { | 2797 } else { |
2786 vp << swValue; | 2798 vp << swValue; |
2787 } | 2799 } |
2788 | 2800 |
2789 bFind = TRUE; | 2801 bFind = TRUE; |
2790 break; | 2802 break; |
2791 } | 2803 } |
2792 if (!bFind) | 2804 if (!bFind) |
2793 vp << L"Off"; | 2805 vp << L"Off"; |
(...skipping 814 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3608 } | 3620 } |
3609 } | 3621 } |
3610 | 3622 |
3611 void Field::AddField(CPDFSDK_Document* pDocument, | 3623 void Field::AddField(CPDFSDK_Document* pDocument, |
3612 int nPageIndex, | 3624 int nPageIndex, |
3613 int nFieldType, | 3625 int nFieldType, |
3614 const CFX_WideString& sName, | 3626 const CFX_WideString& sName, |
3615 const CPDF_Rect& rcCoords) { | 3627 const CPDF_Rect& rcCoords) { |
3616 // Not supported. | 3628 // Not supported. |
3617 } | 3629 } |
OLD | NEW |