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 "../../include/javascript/JavaScript.h" | 7 #include "../../include/javascript/JavaScript.h" |
8 #include "../../include/javascript/IJavaScript.h" | 8 #include "../../include/javascript/IJavaScript.h" |
9 #include "../../include/javascript/JS_Define.h" | 9 #include "../../include/javascript/JS_Define.h" |
10 #include "../../include/javascript/JS_Object.h" | 10 #include "../../include/javascript/JS_Object.h" |
(...skipping 1048 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1059 | 1059 |
1060 | 1060 |
1061 ////////////////////////////////////////////////////// | 1061 ////////////////////////////////////////////////////// |
1062 //for processing decimal places | 1062 //for processing decimal places |
1063 strValue.Replace(",", "."); | 1063 strValue.Replace(",", "."); |
1064 double dValue = atof(strValue); | 1064 double dValue = atof(strValue); |
1065 if (iDec > 0) | 1065 if (iDec > 0) |
1066 dValue += DOUBLE_CORRECT; | 1066 dValue += DOUBLE_CORRECT; |
1067 | 1067 |
1068 int iDec2; | 1068 int iDec2; |
1069 FX_BOOL bNegative = FALSE; | 1069 int iNegative = 0; |
1070 | 1070 |
1071 strValue = fcvt(dValue,iDec,&iDec2,&bNegative); | 1071 strValue = fcvt(dValue, iDec, &iDec2, &iNegative); |
1072 if (strValue.IsEmpty()) | 1072 if (strValue.IsEmpty()) |
1073 { | 1073 { |
1074 dValue = 0; | 1074 dValue = 0; |
1075 strValue = fcvt(dValue,iDec,&iDec2,&bNegative); | 1075 strValue = fcvt(dValue, iDec, &iDec2, &iNegative); |
1076 if (strValue.IsEmpty()) | 1076 if (strValue.IsEmpty()) |
1077 { | 1077 { |
1078 strValue = "0"; | 1078 strValue = "0"; |
1079 iDec2 = 1; | 1079 iDec2 = 1; |
1080 } | 1080 } |
1081 | 1081 |
1082 } | 1082 } |
1083 | 1083 |
1084 if (iDec2 < 0) | 1084 if (iDec2 < 0) |
1085 { | 1085 { |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1143 | 1143 |
1144 if (bCurrencyPrepend) | 1144 if (bCurrencyPrepend) |
1145 strValue2 = wstrCurrency + strValue2; | 1145 strValue2 = wstrCurrency + strValue2; |
1146 else | 1146 else |
1147 strValue2 = strValue2 + wstrCurrency; | 1147 strValue2 = strValue2 + wstrCurrency; |
1148 | 1148 |
1149 | 1149 |
1150 | 1150 |
1151 ///////////////////////////////////////////////////////////////////////// | 1151 ///////////////////////////////////////////////////////////////////////// |
1152 //for processing negative style | 1152 //for processing negative style |
1153 if (bNegative) | 1153 if (iNegative) |
1154 { | 1154 { |
1155 if (iNegStyle == 0) | 1155 if (iNegStyle == 0) |
1156 { | 1156 { |
1157 strValue2.insert(0,L"-"); | 1157 strValue2.insert(0,L"-"); |
1158 } | 1158 } |
1159 if (iNegStyle == 2 || iNegStyle == 3) | 1159 if (iNegStyle == 2 || iNegStyle == 3) |
1160 { | 1160 { |
1161 strValue2.insert(0,L"("); | 1161 strValue2.insert(0,L"("); |
1162 strValue2.insert(strValue2.length(),L")"); | 1162 strValue2.insert(strValue2.length(),L")"); |
1163 } | 1163 } |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1386 iSepStyle = 0; | 1386 iSepStyle = 0; |
1387 | 1387 |
1388 ////////////////////////////////////////////////////// | 1388 ////////////////////////////////////////////////////// |
1389 //for processing decimal places | 1389 //for processing decimal places |
1390 double dValue = atof(strValue); | 1390 double dValue = atof(strValue); |
1391 dValue *= 100; | 1391 dValue *= 100; |
1392 if (iDec > 0) | 1392 if (iDec > 0) |
1393 dValue += DOUBLE_CORRECT;//УÕý | 1393 dValue += DOUBLE_CORRECT;//УÕý |
1394 | 1394 |
1395 int iDec2; | 1395 int iDec2; |
1396 FX_BOOL bNegative = FALSE; | 1396 int iNegative = 0; |
1397 strValue = fcvt(dValue,iDec,&iDec2,&bNegative); | 1397 strValue = fcvt(dValue, iDec, &iDec2, &iNegative); |
1398 if (strValue.IsEmpty()) | 1398 if (strValue.IsEmpty()) |
1399 { | 1399 { |
1400 dValue = 0; | 1400 dValue = 0; |
1401 strValue = fcvt(dValue,iDec,&iDec2,&bNegative); | 1401 strValue = fcvt(dValue, iDec, &iDec2, &iNegative); |
1402 } | 1402 } |
1403 | 1403 |
1404 if (iDec2 < 0) | 1404 if (iDec2 < 0) |
1405 { | 1405 { |
1406 for (int iNum = 0; iNum < abs(iDec2); iNum++) | 1406 for (int iNum = 0; iNum < abs(iDec2); iNum++) |
1407 { | 1407 { |
1408 strValue = "0" + strValue; | 1408 strValue = "0" + strValue; |
1409 } | 1409 } |
1410 iDec2 = 0; | 1410 iDec2 = 0; |
1411 | 1411 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1449 iDecPositive = iDec2; | 1449 iDecPositive = iDec2; |
1450 | 1450 |
1451 for (iDecPositive = iDec2 -3; iDecPositive > 0; iDecPositive -= 3) | 1451 for (iDecPositive = iDec2 -3; iDecPositive > 0; iDecPositive -= 3) |
1452 { | 1452 { |
1453 strValue.Insert(iDecPositive,cSeperator); | 1453 strValue.Insert(iDecPositive,cSeperator); |
1454 iMax++; | 1454 iMax++; |
1455 } | 1455 } |
1456 } | 1456 } |
1457 //////////////////////////////////////////////////////////////////// | 1457 //////////////////////////////////////////////////////////////////// |
1458 //negative mark | 1458 //negative mark |
1459 if(bNegative) | 1459 if (iNegative) |
1460 strValue = "-" + strValue; | 1460 strValue = "-" + strValue; |
1461 strValue += "%"; | 1461 strValue += "%"; |
1462 Value = CFX_WideString::FromLocal(strValue); | 1462 Value = CFX_WideString::FromLocal(strValue); |
1463 #endif | 1463 #endif |
1464 return TRUE; | 1464 return TRUE; |
1465 } | 1465 } |
1466 //AFPercent_Keystroke(nDec, sepStyle) | 1466 //AFPercent_Keystroke(nDec, sepStyle) |
1467 FX_BOOL CJS_PublicMethods::AFPercent_Keystroke(IFXJS_Context* cc, const CJS_Para
meters& params, CJS_Value& vRet, CFX_WideString& sError) | 1467 FX_BOOL CJS_PublicMethods::AFPercent_Keystroke(IFXJS_Context* cc, const CJS_Para
meters& params, CJS_Value& vRet, CFX_WideString& sError) |
1468 { | 1468 { |
1469 return AFNumber_Keystroke(cc,params,vRet,sError); | 1469 return AFNumber_Keystroke(cc,params,vRet,sError); |
(...skipping 794 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2264 nums.SetElement(nIndex,CJS_Value(isolate,sPart.c_str())); | 2264 nums.SetElement(nIndex,CJS_Value(isolate,sPart.c_str())); |
2265 } | 2265 } |
2266 | 2266 |
2267 if (nums.GetLength() > 0) | 2267 if (nums.GetLength() > 0) |
2268 vRet = nums; | 2268 vRet = nums; |
2269 else | 2269 else |
2270 vRet.SetNull(); | 2270 vRet.SetNull(); |
2271 | 2271 |
2272 return TRUE; | 2272 return TRUE; |
2273 } | 2273 } |
OLD | NEW |