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 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 Loading... |
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 } |
OLD | NEW |