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 819 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
830 else | 830 else |
831 cSeperator = '.'; | 831 cSeperator = '.'; |
832 | 832 |
833 for (int iDecPositive = iDec2 - 3; iDecPositive > 0; iDecPositive -= 3) { | 833 for (int iDecPositive = iDec2 - 3; iDecPositive > 0; iDecPositive -= 3) { |
834 strValue.Insert(iDecPositive, cSeperator); | 834 strValue.Insert(iDecPositive, cSeperator); |
835 iMax++; | 835 iMax++; |
836 } | 836 } |
837 } | 837 } |
838 | 838 |
839 // for processing currency string | 839 // for processing currency string |
840 Value = CFX_WideString::FromLocal(strValue.AsByteStringC()); | 840 Value = CFX_WideString::FromLocal(strValue.AsStringC()); |
841 std::wstring strValue2 = Value.c_str(); | 841 std::wstring strValue2 = Value.c_str(); |
842 | 842 |
843 if (bCurrencyPrepend) | 843 if (bCurrencyPrepend) |
844 strValue2 = wstrCurrency + strValue2; | 844 strValue2 = wstrCurrency + strValue2; |
845 else | 845 else |
846 strValue2 = strValue2 + wstrCurrency; | 846 strValue2 = strValue2 + wstrCurrency; |
847 | 847 |
848 // for processing negative style | 848 // for processing negative style |
849 if (iNegative) { | 849 if (iNegative) { |
850 if (iNegStyle == 0) { | 850 if (iNegStyle == 0) { |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1113 for (int iDecPositive = iDec2 - 3; iDecPositive > 0; iDecPositive -= 3) { | 1113 for (int iDecPositive = iDec2 - 3; iDecPositive > 0; iDecPositive -= 3) { |
1114 strValue.Insert(iDecPositive, cSeperator); | 1114 strValue.Insert(iDecPositive, cSeperator); |
1115 iMax++; | 1115 iMax++; |
1116 } | 1116 } |
1117 } | 1117 } |
1118 | 1118 |
1119 // negative mark | 1119 // negative mark |
1120 if (iNegative) | 1120 if (iNegative) |
1121 strValue = "-" + strValue; | 1121 strValue = "-" + strValue; |
1122 strValue += "%"; | 1122 strValue += "%"; |
1123 Value = CFX_WideString::FromLocal(strValue.AsByteStringC()); | 1123 Value = CFX_WideString::FromLocal(strValue.AsStringC()); |
1124 #endif | 1124 #endif |
1125 return TRUE; | 1125 return TRUE; |
1126 } | 1126 } |
1127 // AFPercent_Keystroke(nDec, sepStyle) | 1127 // AFPercent_Keystroke(nDec, sepStyle) |
1128 FX_BOOL CJS_PublicMethods::AFPercent_Keystroke( | 1128 FX_BOOL CJS_PublicMethods::AFPercent_Keystroke( |
1129 IJS_Context* cc, | 1129 IJS_Context* cc, |
1130 const std::vector<CJS_Value>& params, | 1130 const std::vector<CJS_Value>& params, |
1131 CJS_Value& vRet, | 1131 CJS_Value& vRet, |
1132 CFX_WideString& sError) { | 1132 CFX_WideString& sError) { |
1133 return AFNumber_Keystroke(cc, params, vRet, sError); | 1133 return AFNumber_Keystroke(cc, params, vRet, sError); |
(...skipping 78 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].AsWideStringC()); | 1222 int nDay = FX_atof(wsArray[2].AsStringC()); |
1223 int nHour = FX_atof(wsArray[3].AsWideStringC()); | 1223 int nHour = FX_atof(wsArray[3].AsStringC()); |
1224 int nMin = FX_atof(wsArray[4].AsWideStringC()); | 1224 int nMin = FX_atof(wsArray[4].AsStringC()); |
1225 int nSec = FX_atof(wsArray[5].AsWideStringC()); | 1225 int nSec = FX_atof(wsArray[5].AsStringC()); |
1226 int nYear = FX_atof(wsArray[7].AsWideStringC()); | 1226 int nYear = FX_atof(wsArray[7].AsStringC()); |
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.AsWideStringC()); | 1729 dTemp = FX_atof(trimmed.AsStringC()); |
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.AsWideStringC()); | 1743 dTemp = FX_atof(trimmed.AsStringC()); |
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.AsWideStringC()); | 1754 dTemp = FX_atof(trimmed.AsStringC()); |
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 |