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 "fpdfsdk/javascript/PublicMethods.h" | 7 #include "fpdfsdk/javascript/PublicMethods.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <string> | 10 #include <string> |
(...skipping 1201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1212 nMonth = 8; | 1212 nMonth = 8; |
1213 else if (sTemp.Compare(L"Sep") == 0) | 1213 else if (sTemp.Compare(L"Sep") == 0) |
1214 nMonth = 9; | 1214 nMonth = 9; |
1215 else if (sTemp.Compare(L"Oct") == 0) | 1215 else if (sTemp.Compare(L"Oct") == 0) |
1216 nMonth = 10; | 1216 nMonth = 10; |
1217 else if (sTemp.Compare(L"Nov") == 0) | 1217 else if (sTemp.Compare(L"Nov") == 0) |
1218 nMonth = 11; | 1218 nMonth = 11; |
1219 else if (sTemp.Compare(L"Dec") == 0) | 1219 else if (sTemp.Compare(L"Dec") == 0) |
1220 nMonth = 12; | 1220 nMonth = 12; |
1221 | 1221 |
1222 int nDay = FX_atof(wsArray[2]); | 1222 int nDay = FX_atof(wsArray[2].AsWideStringC()); |
1223 int nHour = FX_atof(wsArray[3]); | 1223 int nHour = FX_atof(wsArray[3].AsWideStringC()); |
1224 int nMin = FX_atof(wsArray[4]); | 1224 int nMin = FX_atof(wsArray[4].AsWideStringC()); |
1225 int nSec = FX_atof(wsArray[5]); | 1225 int nSec = FX_atof(wsArray[5].AsWideStringC()); |
1226 int nYear = FX_atof(wsArray[7]); | 1226 int nYear = FX_atof(wsArray[7].AsWideStringC()); |
1227 double dRet = JS_MakeDate(JS_MakeDay(nYear, nMonth - 1, nDay), | 1227 double dRet = JS_MakeDate(JS_MakeDay(nYear, nMonth - 1, nDay), |
1228 JS_MakeTime(nHour, nMin, nSec, 0)); | 1228 JS_MakeTime(nHour, nMin, nSec, 0)); |
1229 if (JS_PortIsNan(dRet)) | 1229 if (JS_PortIsNan(dRet)) |
1230 dRet = JS_DateParse(strValue.c_str()); | 1230 dRet = JS_DateParse(strValue.c_str()); |
1231 | 1231 |
1232 return dRet; | 1232 return dRet; |
1233 } | 1233 } |
1234 | 1234 |
1235 // AFDate_KeystrokeEx(cFormat) | 1235 // AFDate_KeystrokeEx(cFormat) |
1236 FX_BOOL CJS_PublicMethods::AFDate_KeystrokeEx( | 1236 FX_BOOL CJS_PublicMethods::AFDate_KeystrokeEx( |
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1719 | 1719 |
1720 for (int j = 0, jsz = pInterForm->CountFields(wsFieldName); j < jsz; j++) { | 1720 for (int j = 0, jsz = pInterForm->CountFields(wsFieldName); j < jsz; j++) { |
1721 if (CPDF_FormField* pFormField = pInterForm->GetField(j, wsFieldName)) { | 1721 if (CPDF_FormField* pFormField = pInterForm->GetField(j, wsFieldName)) { |
1722 double dTemp = 0.0; | 1722 double dTemp = 0.0; |
1723 switch (pFormField->GetFieldType()) { | 1723 switch (pFormField->GetFieldType()) { |
1724 case FIELDTYPE_TEXTFIELD: | 1724 case FIELDTYPE_TEXTFIELD: |
1725 case FIELDTYPE_COMBOBOX: { | 1725 case FIELDTYPE_COMBOBOX: { |
1726 CFX_WideString trimmed = pFormField->GetValue(); | 1726 CFX_WideString trimmed = pFormField->GetValue(); |
1727 trimmed.TrimRight(); | 1727 trimmed.TrimRight(); |
1728 trimmed.TrimLeft(); | 1728 trimmed.TrimLeft(); |
1729 dTemp = FX_atof(trimmed); | 1729 dTemp = FX_atof(trimmed.AsWideStringC()); |
1730 } break; | 1730 } break; |
1731 case FIELDTYPE_PUSHBUTTON: { | 1731 case FIELDTYPE_PUSHBUTTON: { |
1732 dTemp = 0.0; | 1732 dTemp = 0.0; |
1733 } break; | 1733 } break; |
1734 case FIELDTYPE_CHECKBOX: | 1734 case FIELDTYPE_CHECKBOX: |
1735 case FIELDTYPE_RADIOBUTTON: { | 1735 case FIELDTYPE_RADIOBUTTON: { |
1736 dTemp = 0.0; | 1736 dTemp = 0.0; |
1737 for (int c = 0, csz = pFormField->CountControls(); c < csz; c++) { | 1737 for (int c = 0, csz = pFormField->CountControls(); c < csz; c++) { |
1738 if (CPDF_FormControl* pFormCtrl = pFormField->GetControl(c)) { | 1738 if (CPDF_FormControl* pFormCtrl = pFormField->GetControl(c)) { |
1739 if (pFormCtrl->IsChecked()) { | 1739 if (pFormCtrl->IsChecked()) { |
1740 CFX_WideString trimmed = pFormCtrl->GetExportValue(); | 1740 CFX_WideString trimmed = pFormCtrl->GetExportValue(); |
1741 trimmed.TrimRight(); | 1741 trimmed.TrimRight(); |
1742 trimmed.TrimLeft(); | 1742 trimmed.TrimLeft(); |
1743 dTemp = FX_atof(trimmed); | 1743 dTemp = FX_atof(trimmed.AsWideStringC()); |
1744 break; | 1744 break; |
1745 } | 1745 } |
1746 } | 1746 } |
1747 } | 1747 } |
1748 } break; | 1748 } break; |
1749 case FIELDTYPE_LISTBOX: { | 1749 case FIELDTYPE_LISTBOX: { |
1750 if (pFormField->CountSelectedItems() <= 1) { | 1750 if (pFormField->CountSelectedItems() <= 1) { |
1751 CFX_WideString trimmed = pFormField->GetValue(); | 1751 CFX_WideString trimmed = pFormField->GetValue(); |
1752 trimmed.TrimRight(); | 1752 trimmed.TrimRight(); |
1753 trimmed.TrimLeft(); | 1753 trimmed.TrimLeft(); |
1754 dTemp = FX_atof(trimmed); | 1754 dTemp = FX_atof(trimmed.AsWideStringC()); |
1755 } | 1755 } |
1756 } break; | 1756 } break; |
1757 default: | 1757 default: |
1758 break; | 1758 break; |
1759 } | 1759 } |
1760 | 1760 |
1761 if (i == 0 && j == 0 && (wcscmp(sFunction.c_str(), L"MIN") == 0 || | 1761 if (i == 0 && j == 0 && (wcscmp(sFunction.c_str(), L"MIN") == 0 || |
1762 wcscmp(sFunction.c_str(), L"MAX") == 0)) | 1762 wcscmp(sFunction.c_str(), L"MAX") == 0)) |
1763 dValue = dTemp; | 1763 dValue = dTemp; |
1764 | 1764 |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1867 nums.SetElement(nIndex, CJS_Value(pRuntime, sPart.c_str())); | 1867 nums.SetElement(nIndex, CJS_Value(pRuntime, sPart.c_str())); |
1868 } | 1868 } |
1869 | 1869 |
1870 if (nums.GetLength() > 0) | 1870 if (nums.GetLength() > 0) |
1871 vRet = nums; | 1871 vRet = nums; |
1872 else | 1872 else |
1873 vRet.SetNull(); | 1873 vRet.SetNull(); |
1874 | 1874 |
1875 return TRUE; | 1875 return TRUE; |
1876 } | 1876 } |
OLD | NEW |