| 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 }; | 97 }; |
| 98 | 98 |
| 99 static FX_LPCWSTR fullmonths[] = | 99 static FX_LPCWSTR fullmonths[] = |
| 100 { | 100 { |
| 101 L"January", L"February", L"March", L"April", L"May", L"June", L"July", L
"August", L"September", L"October", L"November", L"December" | 101 L"January", L"February", L"March", L"April", L"May", L"June", L"July", L
"August", L"September", L"October", L"November", L"December" |
| 102 }; | 102 }; |
| 103 | 103 |
| 104 FX_BOOL CJS_PublicMethods::IsNumber(FX_LPCWSTR string) | 104 FX_BOOL CJS_PublicMethods::IsNumber(FX_LPCWSTR string) |
| 105 { | 105 { |
| 106 CFX_WideString sTrim = StrTrim(string); | 106 CFX_WideString sTrim = StrTrim(string); |
| 107 » FX_LPCWSTR pTrim = sTrim; | 107 » FX_LPCWSTR pTrim = sTrim.c_str(); |
| 108 FX_LPCWSTR p = pTrim; | 108 FX_LPCWSTR p = pTrim; |
| 109 | 109 |
| 110 | 110 |
| 111 FX_BOOL bDot = FALSE; | 111 FX_BOOL bDot = FALSE; |
| 112 FX_BOOL bKXJS = FALSE; | 112 FX_BOOL bKXJS = FALSE; |
| 113 | 113 |
| 114 wchar_t c; | 114 wchar_t c; |
| 115 while ((c = *p)) | 115 while ((c = *p)) |
| 116 { | 116 { |
| 117 if (c == '.' || c == ',') | 117 if (c == '.' || c == ',') |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 { | 224 { |
| 225 FX_LPCWSTR p = pStr; | 225 FX_LPCWSTR p = pStr; |
| 226 while (*p) p++; | 226 while (*p) p++; |
| 227 while (p > pStr && *(p - 1) == L' ') p--; | 227 while (p > pStr && *(p - 1) == L' ') p--; |
| 228 | 228 |
| 229 return CFX_WideString(pStr, p - pStr); | 229 return CFX_WideString(pStr, p - pStr); |
| 230 } | 230 } |
| 231 | 231 |
| 232 CFX_WideString CJS_PublicMethods::StrTrim(FX_LPCWSTR pStr) | 232 CFX_WideString CJS_PublicMethods::StrTrim(FX_LPCWSTR pStr) |
| 233 { | 233 { |
| 234 » return StrRTrim(StrLTrim(pStr)); | 234 » return StrRTrim(StrLTrim(pStr).c_str()); |
| 235 } | 235 } |
| 236 | 236 |
| 237 CFX_ByteString CJS_PublicMethods::StrLTrim(FX_LPCSTR pStr) | 237 CFX_ByteString CJS_PublicMethods::StrLTrim(FX_LPCSTR pStr) |
| 238 { | 238 { |
| 239 while (*pStr && *pStr == ' ') pStr++; | 239 while (*pStr && *pStr == ' ') pStr++; |
| 240 | 240 |
| 241 return pStr; | 241 return pStr; |
| 242 } | 242 } |
| 243 | 243 |
| 244 CFX_ByteString CJS_PublicMethods::StrRTrim(FX_LPCSTR pStr) | 244 CFX_ByteString CJS_PublicMethods::StrRTrim(FX_LPCSTR pStr) |
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 584 bWrongFormat = FALSE; | 584 bWrongFormat = FALSE; |
| 585 } | 585 } |
| 586 else | 586 else |
| 587 { | 587 { |
| 588 bWrongFormat = TRUE; | 588 bWrongFormat = TRUE; |
| 589 return dt; | 589 return dt; |
| 590 } | 590 } |
| 591 | 591 |
| 592 CFX_WideString swTemp; | 592 CFX_WideString swTemp; |
| 593 swTemp.Format(L"%d/%d/%d %d:%d:%d",nMonth,nDay,nYear,nHour,nMin,nSec); | 593 swTemp.Format(L"%d/%d/%d %d:%d:%d",nMonth,nDay,nYear,nHour,nMin,nSec); |
| 594 » return JS_DateParse(swTemp); | 594 » return JS_DateParse(swTemp.c_str()); |
| 595 } | 595 } |
| 596 | 596 |
| 597 double CJS_PublicMethods::MakeRegularDate(const CFX_WideString & value, const CF
X_WideString & format, FX_BOOL& bWrongFormat) | 597 double CJS_PublicMethods::MakeRegularDate(const CFX_WideString & value, const CF
X_WideString & format, FX_BOOL& bWrongFormat) |
| 598 { | 598 { |
| 599 double dt = JS_GetDateTime(); | 599 double dt = JS_GetDateTime(); |
| 600 | 600 |
| 601 if (format.IsEmpty() || value.IsEmpty()) | 601 if (format.IsEmpty() || value.IsEmpty()) |
| 602 return dt; | 602 return dt; |
| 603 | 603 |
| 604 int nYear = JS_GetYearFromTime(dt); | 604 int nYear = JS_GetYearFromTime(dt); |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 789 FX_BOOL
bFind = FALSE; | 789 FX_BOOL
bFind = FALSE; |
| 790 | 790 |
| 791 CFX_Wide
String sMonth = ParseStringString(value, j, nSkip); | 791 CFX_Wide
String sMonth = ParseStringString(value, j, nSkip); |
| 792 sMonth.M
akeLower(); | 792 sMonth.M
akeLower(); |
| 793 | 793 |
| 794 for (int
m = 0; m < 12; m++) | 794 for (int
m = 0; m < 12; m++) |
| 795 { | 795 { |
| 796
CFX_WideString sFullMonths = fullmonths[m]; | 796
CFX_WideString sFullMonths = fullmonths[m]; |
| 797
sFullMonths.MakeLower(); | 797
sFullMonths.MakeLower(); |
| 798 | 798 |
| 799 » » » » » » » » » »
if (sFullMonths.Find(sMonth, 0) != -1) | 799 » » » » » » » » » »
if (sFullMonths.Find(sMonth.c_str(), 0) != -1) |
| 800
{ | 800
{ |
| 801
nMonth = m + 1; | 801
nMonth = m + 1; |
| 802
i += 4; | 802
i += 4; |
| 803
j += nSkip; | 803
j += nSkip; |
| 804
bFind = TRUE; | 804
bFind = TRUE; |
| 805
break; | 805
break; |
| 806
} | 806
} |
| 807 } | 807 } |
| 808 | 808 |
| 809 if (!bFi
nd) | 809 if (!bFi
nd) |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 881 if (bWrongFormat) | 881 if (bWrongFormat) |
| 882 { | 882 { |
| 883 dRet = ParseNormalDate(value, bWrongFormat); | 883 dRet = ParseNormalDate(value, bWrongFormat); |
| 884 } | 884 } |
| 885 else | 885 else |
| 886 { | 886 { |
| 887 dRet = JS_MakeDate(JS_MakeDay(nYear,nMonth - 1,nDay),JS_MakeTime
(nHour, nMin, nSec, 0)); | 887 dRet = JS_MakeDate(JS_MakeDay(nYear,nMonth - 1,nDay),JS_MakeTime
(nHour, nMin, nSec, 0)); |
| 888 | 888 |
| 889 if (JS_PortIsNan(dRet)) | 889 if (JS_PortIsNan(dRet)) |
| 890 { | 890 { |
| 891 » » » dRet = JS_DateParse(value); | 891 » » » dRet = JS_DateParse(value.c_str()); |
| 892 } | 892 } |
| 893 } | 893 } |
| 894 | 894 |
| 895 if (JS_PortIsNan(dRet)) | 895 if (JS_PortIsNan(dRet)) |
| 896 { | 896 { |
| 897 dRet = ParseNormalDate(value, bWrongFormat); | 897 dRet = ParseNormalDate(value, bWrongFormat); |
| 898 } | 898 } |
| 899 | 899 |
| 900 return dRet; | 900 return dRet; |
| 901 | 901 |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1068 return FALSE; | 1068 return FALSE; |
| 1069 CFX_WideString& Value = pEvent->Value(); | 1069 CFX_WideString& Value = pEvent->Value(); |
| 1070 CFX_ByteString strValue = StrTrim(CFX_ByteString::FromUnicode(Value)); | 1070 CFX_ByteString strValue = StrTrim(CFX_ByteString::FromUnicode(Value)); |
| 1071 | 1071 |
| 1072 if (strValue.IsEmpty()) return TRUE; | 1072 if (strValue.IsEmpty()) return TRUE; |
| 1073 | 1073 |
| 1074 int iDec = params[0].ToInt(); | 1074 int iDec = params[0].ToInt(); |
| 1075 int iSepStyle = params[1].ToInt(); | 1075 int iSepStyle = params[1].ToInt(); |
| 1076 int iNegStyle = params[2].ToInt(); | 1076 int iNegStyle = params[2].ToInt(); |
| 1077 // params[3] is iCurrStyle, it's not used. | 1077 // params[3] is iCurrStyle, it's not used. |
| 1078 » std::wstring wstrCurrency(params[4].ToCFXWideString()); | 1078 » std::wstring wstrCurrency(params[4].ToCFXWideString().c_str()); |
| 1079 FX_BOOL bCurrencyPrepend = params[5].ToBool(); | 1079 FX_BOOL bCurrencyPrepend = params[5].ToBool(); |
| 1080 | 1080 |
| 1081 if (iDec < 0) iDec = -iDec; | 1081 if (iDec < 0) iDec = -iDec; |
| 1082 | 1082 |
| 1083 if (iSepStyle < 0 || iSepStyle > 3) | 1083 if (iSepStyle < 0 || iSepStyle > 3) |
| 1084 iSepStyle = 0; | 1084 iSepStyle = 0; |
| 1085 | 1085 |
| 1086 if (iNegStyle < 0 || iNegStyle > 3) | 1086 if (iNegStyle < 0 || iNegStyle > 3) |
| 1087 iNegStyle = 0; | 1087 iNegStyle = 0; |
| 1088 | 1088 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1162 { | 1162 { |
| 1163 strValue.Insert(iDecPositive, cSeperator); | 1163 strValue.Insert(iDecPositive, cSeperator); |
| 1164 iMax++; | 1164 iMax++; |
| 1165 } | 1165 } |
| 1166 } | 1166 } |
| 1167 | 1167 |
| 1168 ////////////////////////////////////////////////////////////////////// | 1168 ////////////////////////////////////////////////////////////////////// |
| 1169 //for processing currency string | 1169 //for processing currency string |
| 1170 | 1170 |
| 1171 Value = CFX_WideString::FromLocal(strValue); | 1171 Value = CFX_WideString::FromLocal(strValue); |
| 1172 » | 1172 » std::wstring strValue2 = Value.c_str(); |
| 1173 » std::wstring strValue2(Value); | |
| 1174 | 1173 |
| 1175 if (bCurrencyPrepend) | 1174 if (bCurrencyPrepend) |
| 1176 strValue2 = wstrCurrency + strValue2; | 1175 strValue2 = wstrCurrency + strValue2; |
| 1177 else | 1176 else |
| 1178 strValue2 = strValue2 + wstrCurrency; | 1177 strValue2 = strValue2 + wstrCurrency; |
| 1179 | 1178 |
| 1180 | 1179 |
| 1181 | 1180 |
| 1182 ////////////////////////////////////////////////////////////////////////
/ | 1181 ////////////////////////////////////////////////////////////////////////
/ |
| 1183 //for processing negative style | 1182 //for processing negative style |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1274 iSepStyle = 0; | 1273 iSepStyle = 0; |
| 1275 if(!pEvent->m_pValue) | 1274 if(!pEvent->m_pValue) |
| 1276 return FALSE; | 1275 return FALSE; |
| 1277 CFX_WideString & val = pEvent->Value(); | 1276 CFX_WideString & val = pEvent->Value(); |
| 1278 CFX_WideString & w_strChange = pEvent->Change(); | 1277 CFX_WideString & w_strChange = pEvent->Change(); |
| 1279 CFX_WideString w_strValue = val; | 1278 CFX_WideString w_strValue = val; |
| 1280 | 1279 |
| 1281 if (pEvent->WillCommit()) | 1280 if (pEvent->WillCommit()) |
| 1282 { | 1281 { |
| 1283 CFX_WideString wstrChange = w_strChange; | 1282 CFX_WideString wstrChange = w_strChange; |
| 1284 » » CFX_WideString wstrValue = StrLTrim(w_strValue); | 1283 » » CFX_WideString wstrValue = StrLTrim(w_strValue.c_str()); |
| 1285 if (wstrValue.IsEmpty()) | 1284 if (wstrValue.IsEmpty()) |
| 1286 return TRUE; | 1285 return TRUE; |
| 1287 | 1286 |
| 1288 CFX_WideString swTemp = wstrValue; | 1287 CFX_WideString swTemp = wstrValue; |
| 1289 swTemp.Replace(L",", L"."); | 1288 swTemp.Replace(L",", L"."); |
| 1290 » » if (!IsNumber(swTemp)) //!(IsNumber(wstrChange) && | 1289 » » if (!IsNumber(swTemp.c_str())) |
| 1291 { | 1290 { |
| 1292 pEvent->Rc() = FALSE; | 1291 pEvent->Rc() = FALSE; |
| 1293 sError = JSGetStringFromID(pContext, IDS_STRING_JSAFNUMB
ER_KEYSTROKE); | 1292 sError = JSGetStringFromID(pContext, IDS_STRING_JSAFNUMB
ER_KEYSTROKE); |
| 1294 » » » Alert(pContext, sError); | 1293 » » » Alert(pContext, sError.c_str()); |
| 1295 return TRUE; | 1294 return TRUE; |
| 1296 } | 1295 } |
| 1297 return TRUE; // it happens after the last keystroke and before v
alidating, | 1296 return TRUE; // it happens after the last keystroke and before v
alidating, |
| 1298 } | 1297 } |
| 1299 » | 1298 |
| 1300 » std::wstring w_strValue2 (w_strValue); | 1299 » std::wstring w_strValue2 = w_strValue.c_str(); |
| 1301 » std::wstring w_strChange2(w_strChange); | 1300 » std::wstring w_strChange2 = w_strChange.c_str(); |
| 1302 » | |
| 1303 std::wstring w_strSelected; | 1301 std::wstring w_strSelected; |
| 1304 if(-1 != pEvent->SelStart()) | 1302 if(-1 != pEvent->SelStart()) |
| 1305 w_strSelected = w_strValue2.substr(pEvent->SelStart(),(pEvent->S
elEnd() - pEvent->SelStart())); | 1303 w_strSelected = w_strValue2.substr(pEvent->SelStart(),(pEvent->S
elEnd() - pEvent->SelStart())); |
| 1306 FX_BOOL bHasSign = (w_strValue2.find('-') != -1) && (w_strSelected.find(
'-') == -1); | 1304 FX_BOOL bHasSign = (w_strValue2.find('-') != -1) && (w_strSelected.find(
'-') == -1); |
| 1307 if (bHasSign) | 1305 if (bHasSign) |
| 1308 { | 1306 { |
| 1309 //can't insert "change" in front to sign postion. | 1307 //can't insert "change" in front to sign postion. |
| 1310 if (pEvent->SelStart() == 0) | 1308 if (pEvent->SelStart() == 0) |
| 1311 { | 1309 { |
| 1312 FX_BOOL &bRc = pEvent->Rc(); | 1310 FX_BOOL &bRc = pEvent->Rc(); |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1537 dDate = MakeInterDate(strValue); | 1535 dDate = MakeInterDate(strValue); |
| 1538 } | 1536 } |
| 1539 else | 1537 else |
| 1540 { | 1538 { |
| 1541 dDate = MakeRegularDate(strValue,sFormat,bWrongFormat); | 1539 dDate = MakeRegularDate(strValue,sFormat,bWrongFormat); |
| 1542 } | 1540 } |
| 1543 | 1541 |
| 1544 if (JS_PortIsNan(dDate)) | 1542 if (JS_PortIsNan(dDate)) |
| 1545 { | 1543 { |
| 1546 CFX_WideString swMsg; | 1544 CFX_WideString swMsg; |
| 1547 » » swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSPARSEDATE)
, sFormat.c_str()); | 1545 » » swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSPARSEDATE)
.c_str(), sFormat.c_str()); |
| 1548 » » Alert(pContext, swMsg); | 1546 » » Alert(pContext, swMsg.c_str()); |
| 1549 return FALSE; | 1547 return FALSE; |
| 1550 } | 1548 } |
| 1551 | 1549 |
| 1552 val = MakeFormatDate(dDate,sFormat); | 1550 val = MakeFormatDate(dDate,sFormat); |
| 1553 return TRUE; | 1551 return TRUE; |
| 1554 } | 1552 } |
| 1555 | 1553 |
| 1556 double CJS_PublicMethods::MakeInterDate(CFX_WideString strValue) | 1554 double CJS_PublicMethods::MakeInterDate(CFX_WideString strValue) |
| 1557 { | 1555 { |
| 1558 int nHour; | 1556 int nHour; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1590 if(sTemp.Compare(L"Apr") == 0) nMonth = 4; | 1588 if(sTemp.Compare(L"Apr") == 0) nMonth = 4; |
| 1591 if(sTemp.Compare(L"May") == 0) nMonth = 5; | 1589 if(sTemp.Compare(L"May") == 0) nMonth = 5; |
| 1592 if(sTemp.Compare(L"Jun") == 0) nMonth = 6; | 1590 if(sTemp.Compare(L"Jun") == 0) nMonth = 6; |
| 1593 if(sTemp.Compare(L"Jul") == 0) nMonth = 7; | 1591 if(sTemp.Compare(L"Jul") == 0) nMonth = 7; |
| 1594 if(sTemp.Compare(L"Aug") == 0) nMonth = 8; | 1592 if(sTemp.Compare(L"Aug") == 0) nMonth = 8; |
| 1595 if(sTemp.Compare(L"Sep") == 0) nMonth = 9; | 1593 if(sTemp.Compare(L"Sep") == 0) nMonth = 9; |
| 1596 if(sTemp.Compare(L"Oct") == 0) nMonth = 10; | 1594 if(sTemp.Compare(L"Oct") == 0) nMonth = 10; |
| 1597 if(sTemp.Compare(L"Nov") == 0) nMonth = 11; | 1595 if(sTemp.Compare(L"Nov") == 0) nMonth = 11; |
| 1598 if(sTemp.Compare(L"Dec") == 0) nMonth = 12; | 1596 if(sTemp.Compare(L"Dec") == 0) nMonth = 12; |
| 1599 | 1597 |
| 1600 » nDay = (int)ParseStringToNumber(wsArray[2]); | 1598 » nDay = (int)ParseStringToNumber(wsArray[2].c_str()); |
| 1601 » nHour = (int)ParseStringToNumber(wsArray[3]); | 1599 » nHour = (int)ParseStringToNumber(wsArray[3].c_str()); |
| 1602 » nMin = (int)ParseStringToNumber(wsArray[4]); | 1600 » nMin = (int)ParseStringToNumber(wsArray[4].c_str()); |
| 1603 » nSec = (int)ParseStringToNumber(wsArray[5]); | 1601 » nSec = (int)ParseStringToNumber(wsArray[5].c_str()); |
| 1604 » nYear = (int)ParseStringToNumber(wsArray[7]); | 1602 » nYear = (int)ParseStringToNumber(wsArray[7].c_str()); |
| 1605 | 1603 |
| 1606 double dRet = JS_MakeDate(JS_MakeDay(nYear,nMonth - 1,nDay),JS_MakeTime(
nHour, nMin, nSec, 0)); | 1604 double dRet = JS_MakeDate(JS_MakeDay(nYear,nMonth - 1,nDay),JS_MakeTime(
nHour, nMin, nSec, 0)); |
| 1607 | 1605 |
| 1608 if (JS_PortIsNan(dRet)) | 1606 if (JS_PortIsNan(dRet)) |
| 1609 { | 1607 { |
| 1610 » » dRet = JS_DateParse(strValue); | 1608 » » dRet = JS_DateParse(strValue.c_str()); |
| 1611 } | 1609 } |
| 1612 | 1610 |
| 1613 return dRet; | 1611 return dRet; |
| 1614 } | 1612 } |
| 1615 | 1613 |
| 1616 //AFDate_KeystrokeEx(cFormat) | 1614 //AFDate_KeystrokeEx(cFormat) |
| 1617 FX_BOOL CJS_PublicMethods::AFDate_KeystrokeEx(IFXJS_Context* cc, const CJS_Param
eters& params, CJS_Value& vRet, CFX_WideString& sError) | 1615 FX_BOOL CJS_PublicMethods::AFDate_KeystrokeEx(IFXJS_Context* cc, const CJS_Param
eters& params, CJS_Value& vRet, CFX_WideString& sError) |
| 1618 { | 1616 { |
| 1619 CJS_Context* pContext = (CJS_Context *)cc; | 1617 CJS_Context* pContext = (CJS_Context *)cc; |
| 1620 ASSERT(pContext != NULL); | 1618 ASSERT(pContext != NULL); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1634 CFX_WideString strValue = pEvent->Value(); | 1632 CFX_WideString strValue = pEvent->Value(); |
| 1635 if (strValue.IsEmpty()) | 1633 if (strValue.IsEmpty()) |
| 1636 return TRUE; | 1634 return TRUE; |
| 1637 | 1635 |
| 1638 CFX_WideString sFormat = params[0].ToCFXWideString(); | 1636 CFX_WideString sFormat = params[0].ToCFXWideString(); |
| 1639 FX_BOOL bWrongFormat = FALSE; | 1637 FX_BOOL bWrongFormat = FALSE; |
| 1640 double dRet = MakeRegularDate(strValue,sFormat,bWrongFormat); | 1638 double dRet = MakeRegularDate(strValue,sFormat,bWrongFormat); |
| 1641 if (bWrongFormat || JS_PortIsNan(dRet)) | 1639 if (bWrongFormat || JS_PortIsNan(dRet)) |
| 1642 { | 1640 { |
| 1643 CFX_WideString swMsg; | 1641 CFX_WideString swMsg; |
| 1644 » » » swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSPA
RSEDATE), sFormat.c_str()); | 1642 » » » swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSPA
RSEDATE).c_str(), sFormat.c_str()); |
| 1645 » » » Alert(pContext, swMsg); | 1643 » » » Alert(pContext, swMsg.c_str()); |
| 1646 pEvent->Rc() = FALSE; | 1644 pEvent->Rc() = FALSE; |
| 1647 return TRUE; | 1645 return TRUE; |
| 1648 } | 1646 } |
| 1649 } | 1647 } |
| 1650 return TRUE; | 1648 return TRUE; |
| 1651 } | 1649 } |
| 1652 | 1650 |
| 1653 FX_BOOL CJS_PublicMethods::AFDate_Format(IFXJS_Context* cc, const CJS_Parameters
& params, CJS_Value& vRet, CFX_WideString& sError) | 1651 FX_BOOL CJS_PublicMethods::AFDate_Format(IFXJS_Context* cc, const CJS_Parameters
& params, CJS_Value& vRet, CFX_WideString& sError) |
| 1654 { | 1652 { |
| 1655 v8::Isolate* isolate = ::GetIsolate(cc); | 1653 v8::Isolate* isolate = ::GetIsolate(cc); |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1844 } | 1842 } |
| 1845 | 1843 |
| 1846 if(!pEvent->m_pValue) | 1844 if(!pEvent->m_pValue) |
| 1847 return FALSE; | 1845 return FALSE; |
| 1848 CFX_WideString& valEvent = pEvent->Value(); | 1846 CFX_WideString& valEvent = pEvent->Value(); |
| 1849 | 1847 |
| 1850 CFX_WideString wstrMask = params[0].ToCFXWideString(); | 1848 CFX_WideString wstrMask = params[0].ToCFXWideString(); |
| 1851 if (wstrMask.IsEmpty()) | 1849 if (wstrMask.IsEmpty()) |
| 1852 return TRUE; | 1850 return TRUE; |
| 1853 | 1851 |
| 1854 » std::wstring wstrValue(valEvent); | 1852 » std::wstring wstrValue = valEvent.c_str(); |
| 1855 | 1853 |
| 1856 if (pEvent->WillCommit()) | 1854 if (pEvent->WillCommit()) |
| 1857 { | 1855 { |
| 1858 if (wstrValue.empty()) | 1856 if (wstrValue.empty()) |
| 1859 return TRUE; | 1857 return TRUE; |
| 1860 int iIndexMask = 0; | 1858 int iIndexMask = 0; |
| 1861 for (std::wstring::iterator it = wstrValue.begin(); it != wstrVa
lue.end(); it++) | 1859 for (std::wstring::iterator it = wstrValue.begin(); it != wstrVa
lue.end(); it++) |
| 1862 { | 1860 { |
| 1863 wchar_t w_Value = *it; | 1861 wchar_t w_Value = *it; |
| 1864 if (!maskSatisfied(w_Value,wstrMask[iIndexMask])) | 1862 if (!maskSatisfied(w_Value,wstrMask[iIndexMask])) |
| 1865 break; | 1863 break; |
| 1866 iIndexMask++; | 1864 iIndexMask++; |
| 1867 } | 1865 } |
| 1868 | 1866 |
| 1869 if (iIndexMask != wstrMask.GetLength() || (iIndexMask != wstrVal
ue.size() && wstrMask.GetLength() != 0)) | 1867 if (iIndexMask != wstrMask.GetLength() || (iIndexMask != wstrVal
ue.size() && wstrMask.GetLength() != 0)) |
| 1870 { | 1868 { |
| 1871 » » » Alert(pContext, JSGetStringFromID(pContext, IDS_STRING_J
SAFNUMBER_KEYSTROKE)); | 1869 » » » Alert(pContext, JSGetStringFromID(pContext, IDS_STRING_J
SAFNUMBER_KEYSTROKE).c_str()); |
| 1872 pEvent->Rc() = FALSE; | 1870 pEvent->Rc() = FALSE; |
| 1873 } | 1871 } |
| 1874 return TRUE; | 1872 return TRUE; |
| 1875 } | 1873 } |
| 1876 | 1874 |
| 1877 CFX_WideString &wideChange = pEvent->Change(); | 1875 CFX_WideString &wideChange = pEvent->Change(); |
| 1878 » std::wstring wChange(wideChange); | 1876 » std::wstring wChange = wideChange.c_str(); |
| 1879 if (wChange.empty()) | 1877 if (wChange.empty()) |
| 1880 return TRUE; | 1878 return TRUE; |
| 1881 | 1879 |
| 1882 int iIndexMask = pEvent->SelStart(); | 1880 int iIndexMask = pEvent->SelStart(); |
| 1883 | 1881 |
| 1884 if (wstrValue.length() - (pEvent->SelEnd()-pEvent->SelStart()) + wChange
.length() > (FX_DWORD)wstrMask.GetLength()) | 1882 if (wstrValue.length() - (pEvent->SelEnd()-pEvent->SelStart()) + wChange
.length() > (FX_DWORD)wstrMask.GetLength()) |
| 1885 { | 1883 { |
| 1886 » » Alert(pContext, JSGetStringFromID(pContext, IDS_STRING_JSPARAM_T
OOLONG)); | 1884 » » Alert(pContext, JSGetStringFromID(pContext, IDS_STRING_JSPARAM_T
OOLONG).c_str()); |
| 1887 pEvent->Rc() = FALSE; | 1885 pEvent->Rc() = FALSE; |
| 1888 return TRUE; | 1886 return TRUE; |
| 1889 } | 1887 } |
| 1890 | 1888 |
| 1891 if (iIndexMask >= wstrMask.GetLength() && (!wChange.empty())) | 1889 if (iIndexMask >= wstrMask.GetLength() && (!wChange.empty())) |
| 1892 { | 1890 { |
| 1893 » » Alert(pContext, JSGetStringFromID(pContext, IDS_STRING_JSPARAM_T
OOLONG)); | 1891 » » Alert(pContext, JSGetStringFromID(pContext, IDS_STRING_JSPARAM_T
OOLONG).c_str()); |
| 1894 pEvent->Rc() = FALSE; | 1892 pEvent->Rc() = FALSE; |
| 1895 return TRUE; | 1893 return TRUE; |
| 1896 } | 1894 } |
| 1897 | 1895 |
| 1898 for (std::wstring::iterator it = wChange.begin(); it != wChange.end(); i
t++) | 1896 for (std::wstring::iterator it = wChange.begin(); it != wChange.end(); i
t++) |
| 1899 { | 1897 { |
| 1900 if (iIndexMask >= wstrMask.GetLength()) | 1898 if (iIndexMask >= wstrMask.GetLength()) |
| 1901 { | 1899 { |
| 1902 » » » Alert(pContext, JSGetStringFromID(pContext, IDS_STRING_J
SPARAM_TOOLONG)); | 1900 » » » Alert(pContext, JSGetStringFromID(pContext, IDS_STRING_J
SPARAM_TOOLONG).c_str()); |
| 1903 pEvent->Rc() = FALSE; | 1901 pEvent->Rc() = FALSE; |
| 1904 return TRUE; | 1902 return TRUE; |
| 1905 } | 1903 } |
| 1906 wchar_t w_Mask = wstrMask[iIndexMask]; | 1904 wchar_t w_Mask = wstrMask[iIndexMask]; |
| 1907 if (!isReservedMaskChar(w_Mask)) | 1905 if (!isReservedMaskChar(w_Mask)) |
| 1908 { | 1906 { |
| 1909 *it = w_Mask; | 1907 *it = w_Mask; |
| 1910 } | 1908 } |
| 1911 wchar_t w_Change = *it; | 1909 wchar_t w_Change = *it; |
| 1912 if (!maskSatisfied(w_Change,w_Mask)) | 1910 if (!maskSatisfied(w_Change,w_Mask)) |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1939 } | 1937 } |
| 1940 | 1938 |
| 1941 std::string cFormat; | 1939 std::string cFormat; |
| 1942 int iIndex = params[0].ToInt(); | 1940 int iIndex = params[0].ToInt(); |
| 1943 | 1941 |
| 1944 if(!pEvent->m_pValue) | 1942 if(!pEvent->m_pValue) |
| 1945 return FALSE; | 1943 return FALSE; |
| 1946 //CJS_Value val = pEvent->Value(); | 1944 //CJS_Value val = pEvent->Value(); |
| 1947 CFX_WideString& val = pEvent->Value(); | 1945 CFX_WideString& val = pEvent->Value(); |
| 1948 std::string strSrc = CFX_ByteString::FromUnicode(val).c_str(); | 1946 std::string strSrc = CFX_ByteString::FromUnicode(val).c_str(); |
| 1949 » std::wstring wstrChange(pEvent->Change()); | 1947 » std::wstring wstrChange = pEvent->Change().c_str(); |
| 1950 » | 1948 |
| 1951 switch (iIndex) | 1949 switch (iIndex) |
| 1952 { | 1950 { |
| 1953 case 0: | 1951 case 0: |
| 1954 cFormat = "99999"; | 1952 cFormat = "99999"; |
| 1955 break; | 1953 break; |
| 1956 case 1: | 1954 case 1: |
| 1957 //cFormat = "99999-9999"; | 1955 //cFormat = "99999-9999"; |
| 1958 cFormat = "999999999"; | 1956 cFormat = "999999999"; |
| 1959 break; | 1957 break; |
| 1960 case 2: | 1958 case 2: |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1994 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); | 1992 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); |
| 1995 return FALSE; | 1993 return FALSE; |
| 1996 } | 1994 } |
| 1997 | 1995 |
| 1998 CFX_WideString swValue; | 1996 CFX_WideString swValue; |
| 1999 if (pEventHandler->m_pValue != NULL) | 1997 if (pEventHandler->m_pValue != NULL) |
| 2000 swValue = pEventHandler->Value(); | 1998 swValue = pEventHandler->Value(); |
| 2001 | 1999 |
| 2002 if (pEventHandler->WillCommit()) | 2000 if (pEventHandler->WillCommit()) |
| 2003 { | 2001 { |
| 2004 » » vRet = swValue; | 2002 » » vRet = swValue.c_str(); |
| 2005 return TRUE; | 2003 return TRUE; |
| 2006 } | 2004 } |
| 2007 | 2005 |
| 2008 CFX_WideString prefix,postfix; | 2006 CFX_WideString prefix,postfix; |
| 2009 | 2007 |
| 2010 if (pEventHandler->SelStart() >= 0) | 2008 if (pEventHandler->SelStart() >= 0) |
| 2011 prefix = swValue.Mid(0,pEventHandler->SelStart()); | 2009 prefix = swValue.Mid(0,pEventHandler->SelStart()); |
| 2012 else | 2010 else |
| 2013 prefix = L""; | 2011 prefix = L""; |
| 2014 | 2012 |
| 2015 | 2013 |
| 2016 if (pEventHandler->SelEnd() >= 0 && pEventHandler->SelEnd() <= swValue.G
etLength()) | 2014 if (pEventHandler->SelEnd() >= 0 && pEventHandler->SelEnd() <= swValue.G
etLength()) |
| 2017 postfix = swValue.Mid(pEventHandler->SelEnd(), swValue.GetLength
() - pEventHandler->SelEnd()); | 2015 postfix = swValue.Mid(pEventHandler->SelEnd(), swValue.GetLength
() - pEventHandler->SelEnd()); |
| 2018 else postfix = L""; | 2016 else postfix = L""; |
| 2019 | 2017 |
| 2020 » vRet = prefix + pEventHandler->Change() + postfix; | 2018 » vRet = (prefix + pEventHandler->Change() + postfix).c_str(); |
| 2021 | 2019 |
| 2022 return TRUE; | 2020 return TRUE; |
| 2023 } | 2021 } |
| 2024 | 2022 |
| 2025 FX_BOOL CJS_PublicMethods::AFParseDateEx(IFXJS_Context* cc, const CJS_Parameters
& params, CJS_Value& vRet, CFX_WideString& sError) | 2023 FX_BOOL CJS_PublicMethods::AFParseDateEx(IFXJS_Context* cc, const CJS_Parameters
& params, CJS_Value& vRet, CFX_WideString& sError) |
| 2026 { | 2024 { |
| 2027 CJS_Context* pContext = (CJS_Context *)cc; | 2025 CJS_Context* pContext = (CJS_Context *)cc; |
| 2028 ASSERT(pContext != NULL); | 2026 ASSERT(pContext != NULL); |
| 2029 | 2027 |
| 2030 if (params.size() != 2) | 2028 if (params.size() != 2) |
| 2031 { | 2029 { |
| 2032 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); | 2030 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); |
| 2033 return FALSE; | 2031 return FALSE; |
| 2034 } | 2032 } |
| 2035 | 2033 |
| 2036 CFX_WideString sValue = params[0].ToCFXWideString(); | 2034 CFX_WideString sValue = params[0].ToCFXWideString(); |
| 2037 CFX_WideString sFormat = params[1].ToCFXWideString(); | 2035 CFX_WideString sFormat = params[1].ToCFXWideString(); |
| 2038 | 2036 |
| 2039 FX_BOOL bWrongFormat = FALSE; | 2037 FX_BOOL bWrongFormat = FALSE; |
| 2040 double dDate = MakeRegularDate(sValue,sFormat,bWrongFormat); | 2038 double dDate = MakeRegularDate(sValue,sFormat,bWrongFormat); |
| 2041 | 2039 |
| 2042 if (JS_PortIsNan(dDate)) | 2040 if (JS_PortIsNan(dDate)) |
| 2043 { | 2041 { |
| 2044 CFX_WideString swMsg; | 2042 CFX_WideString swMsg; |
| 2045 » » swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSPARSEDATE)
, sFormat.c_str()); | 2043 » » swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSPARSEDATE)
.c_str(), sFormat.c_str()); |
| 2046 » » Alert((CJS_Context *)cc, swMsg); | 2044 » » Alert((CJS_Context *)cc, swMsg.c_str()); |
| 2047 return FALSE; | 2045 return FALSE; |
| 2048 } | 2046 } |
| 2049 | 2047 |
| 2050 vRet = dDate; | 2048 vRet = dDate; |
| 2051 return TRUE; | 2049 return TRUE; |
| 2052 } | 2050 } |
| 2053 | 2051 |
| 2054 FX_BOOL CJS_PublicMethods::AFSimple(IFXJS_Context* cc, const CJS_Parameters& par
ams, CJS_Value& vRet, CFX_WideString& sError) | 2052 FX_BOOL CJS_PublicMethods::AFSimple(IFXJS_Context* cc, const CJS_Parameters& par
ams, CJS_Value& vRet, CFX_WideString& sError) |
| 2055 { | 2053 { |
| 2056 if (params.size() != 3) | 2054 if (params.size() != 3) |
| 2057 { | 2055 { |
| 2058 CJS_Context* pContext = (CJS_Context *)cc; | 2056 CJS_Context* pContext = (CJS_Context *)cc; |
| 2059 ASSERT(pContext != NULL); | 2057 ASSERT(pContext != NULL); |
| 2060 | 2058 |
| 2061 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); | 2059 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); |
| 2062 return FALSE; | 2060 return FALSE; |
| 2063 } | 2061 } |
| 2064 | 2062 |
| 2065 » vRet = (double)AF_Simple(params[0].ToCFXWideString(), params[1].ToDouble
(), params[2].ToDouble()); | 2063 » vRet = (double)AF_Simple(params[0].ToCFXWideString().c_str(), params[1].
ToDouble(), params[2].ToDouble()); |
| 2066 return TRUE; | 2064 return TRUE; |
| 2067 } | 2065 } |
| 2068 | 2066 |
| 2069 FX_BOOL CJS_PublicMethods::AFMakeNumber(IFXJS_Context* cc, const CJS_Parameters&
params, CJS_Value& vRet, CFX_WideString& sError) | 2067 FX_BOOL CJS_PublicMethods::AFMakeNumber(IFXJS_Context* cc, const CJS_Parameters&
params, CJS_Value& vRet, CFX_WideString& sError) |
| 2070 { | 2068 { |
| 2071 if (params.size() != 1) | 2069 if (params.size() != 1) |
| 2072 { | 2070 { |
| 2073 CJS_Context* pContext = (CJS_Context *)cc; | 2071 CJS_Context* pContext = (CJS_Context *)cc; |
| 2074 ASSERT(pContext != NULL); | 2072 ASSERT(pContext != NULL); |
| 2075 | 2073 |
| 2076 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); | 2074 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); |
| 2077 return FALSE; | 2075 return FALSE; |
| 2078 } | 2076 } |
| 2079 » vRet = ParseStringToNumber(params[0].ToCFXWideString()); | 2077 » vRet = ParseStringToNumber(params[0].ToCFXWideString().c_str()); |
| 2080 return TRUE; | 2078 return TRUE; |
| 2081 } | 2079 } |
| 2082 | 2080 |
| 2083 FX_BOOL CJS_PublicMethods::AFSimple_Calculate(IFXJS_Context* cc, const CJS_Param
eters& params, CJS_Value& vRet, CFX_WideString& sError) | 2081 FX_BOOL CJS_PublicMethods::AFSimple_Calculate(IFXJS_Context* cc, const CJS_Param
eters& params, CJS_Value& vRet, CFX_WideString& sError) |
| 2084 { | 2082 { |
| 2085 v8::Isolate* isolate = ::GetIsolate(cc); | 2083 v8::Isolate* isolate = ::GetIsolate(cc); |
| 2086 | 2084 |
| 2087 CJS_Context* pContext = (CJS_Context *)cc; | 2085 CJS_Context* pContext = (CJS_Context *)cc; |
| 2088 ASSERT(pContext != NULL); | 2086 ASSERT(pContext != NULL); |
| 2089 | 2087 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 2105 ASSERT(pReaderDoc != NULL); | 2103 ASSERT(pReaderDoc != NULL); |
| 2106 | 2104 |
| 2107 CPDFSDK_InterForm* pReaderInterForm = pReaderDoc->GetInterForm(); | 2105 CPDFSDK_InterForm* pReaderInterForm = pReaderDoc->GetInterForm(); |
| 2108 ASSERT(pReaderInterForm != NULL); | 2106 ASSERT(pReaderInterForm != NULL); |
| 2109 | 2107 |
| 2110 CPDF_InterForm* pInterForm = pReaderInterForm->GetInterForm(); | 2108 CPDF_InterForm* pInterForm = pReaderInterForm->GetInterForm(); |
| 2111 ASSERT(pInterForm != NULL); | 2109 ASSERT(pInterForm != NULL); |
| 2112 | 2110 |
| 2113 double dValue; | 2111 double dValue; |
| 2114 CFX_WideString sFunction = params[0].ToCFXWideString(); | 2112 CFX_WideString sFunction = params[0].ToCFXWideString(); |
| 2115 » if (wcscmp(sFunction, L"PRD") == 0) | 2113 » if (wcscmp(sFunction.c_str(), L"PRD") == 0) |
| 2116 dValue = 1.0; | 2114 dValue = 1.0; |
| 2117 else | 2115 else |
| 2118 dValue = 0.0; | 2116 dValue = 0.0; |
| 2119 | 2117 |
| 2120 CJS_Array FieldNameArray = AF_MakeArrayFromList(isolate,params1); | 2118 CJS_Array FieldNameArray = AF_MakeArrayFromList(isolate,params1); |
| 2121 | 2119 |
| 2122 int nFieldsCount = 0; | 2120 int nFieldsCount = 0; |
| 2123 | 2121 |
| 2124 for (int i=0,isz=FieldNameArray.GetLength(); i<isz; i++) | 2122 for (int i=0,isz=FieldNameArray.GetLength(); i<isz; i++) |
| 2125 { | 2123 { |
| 2126 CJS_Value jsValue(isolate); | 2124 CJS_Value jsValue(isolate); |
| 2127 FieldNameArray.GetElement(i,jsValue); | 2125 FieldNameArray.GetElement(i,jsValue); |
| 2128 CFX_WideString wsFieldName = jsValue.ToCFXWideString(); | 2126 CFX_WideString wsFieldName = jsValue.ToCFXWideString(); |
| 2129 | 2127 |
| 2130 for (int j=0,jsz=pInterForm->CountFields(wsFieldName); j<jsz; j++) | 2128 for (int j=0,jsz=pInterForm->CountFields(wsFieldName); j<jsz; j++) |
| 2131 { | 2129 { |
| 2132 if (CPDF_FormField* pFormField = pInterForm->GetField(j,
wsFieldName)) | 2130 if (CPDF_FormField* pFormField = pInterForm->GetField(j,
wsFieldName)) |
| 2133 { | 2131 { |
| 2134 double dTemp = 0.0; | 2132 double dTemp = 0.0; |
| 2135 | 2133 |
| 2136 switch (pFormField->GetFieldType()) | 2134 switch (pFormField->GetFieldType()) |
| 2137 { | 2135 { |
| 2138 case FIELDTYPE_TEXTFIELD: | 2136 case FIELDTYPE_TEXTFIELD: |
| 2139 case FIELDTYPE_COMBOBOX: | 2137 case FIELDTYPE_COMBOBOX: |
| 2140 { | 2138 { |
| 2141 » » » » » » dTemp = ParseStringToNumber(pFor
mField->GetValue()); | 2139 » » » » » » dTemp = ParseStringToNumber(pFor
mField->GetValue().c_str()); |
| 2142 break; | 2140 break; |
| 2143 } | 2141 } |
| 2144 case FIELDTYPE_PUSHBUTTON: | 2142 case FIELDTYPE_PUSHBUTTON: |
| 2145 { | 2143 { |
| 2146 dTemp = 0.0; | 2144 dTemp = 0.0; |
| 2147 break; | 2145 break; |
| 2148 } | 2146 } |
| 2149 case FIELDTYPE_CHECKBOX: | 2147 case FIELDTYPE_CHECKBOX: |
| 2150 case FIELDTYPE_RADIOBUTTON: | 2148 case FIELDTYPE_RADIOBUTTON: |
| 2151 { | 2149 { |
| 2152 dTemp = 0.0; | 2150 dTemp = 0.0; |
| 2153 for (int c=0,csz=pFormField->Cou
ntControls(); c<csz; c++) | 2151 for (int c=0,csz=pFormField->Cou
ntControls(); c<csz; c++) |
| 2154 { | 2152 { |
| 2155 if (CPDF_FormControl* pF
ormCtrl = pFormField->GetControl(c)) | 2153 if (CPDF_FormControl* pF
ormCtrl = pFormField->GetControl(c)) |
| 2156 { | 2154 { |
| 2157 if (pFormCtrl->I
sChecked()) | 2155 if (pFormCtrl->I
sChecked()) |
| 2158 { | 2156 { |
| 2159 » » » » » » » » » dTemp +=
ParseStringToNumber(pFormCtrl->GetExportValue()); | 2157 » » » » » » » » » dTemp +=
ParseStringToNumber(pFormCtrl->GetExportValue().c_str()); |
| 2160 break; | 2158 break; |
| 2161 } | 2159 } |
| 2162 else | 2160 else |
| 2163 continue
; | 2161 continue
; |
| 2164 } | 2162 } |
| 2165 } | 2163 } |
| 2166 break; | 2164 break; |
| 2167 } | 2165 } |
| 2168 case FIELDTYPE_LISTBOX: | 2166 case FIELDTYPE_LISTBOX: |
| 2169 { | 2167 { |
| 2170 dTemp = 0.0; | 2168 dTemp = 0.0; |
| 2171 if (pFormField->CountSelectedIte
ms() > 1) | 2169 if (pFormField->CountSelectedIte
ms() > 1) |
| 2172 break; | 2170 break; |
| 2173 else | 2171 else |
| 2174 { | 2172 { |
| 2175 » » » » » » » dTemp = ParseStringToNum
ber(pFormField->GetValue()); | 2173 » » » » » » » dTemp = ParseStringToNum
ber(pFormField->GetValue().c_str()); |
| 2176 break; | 2174 break; |
| 2177 } | 2175 } |
| 2178 } | 2176 } |
| 2179 default: | 2177 default: |
| 2180 break; | 2178 break; |
| 2181 } | 2179 } |
| 2182 | 2180 |
| 2183 » » » » if (i == 0 && j == 0 && (wcscmp(sFunction,L"MIN"
) == 0 || wcscmp(sFunction, L"MAX") == 0)) | 2181 » » » » if (i == 0 && j == 0 && (wcscmp(sFunction.c_str(
), L"MIN") == 0 || wcscmp(sFunction.c_str(), L"MAX") == 0)) |
| 2184 dValue = dTemp; | 2182 dValue = dTemp; |
| 2185 | 2183 |
| 2186 » » » » dValue = AF_Simple(sFunction, dValue, dTemp); | 2184 » » » » dValue = AF_Simple(sFunction.c_str(), dValue, dT
emp); |
| 2187 | 2185 |
| 2188 nFieldsCount++; | 2186 nFieldsCount++; |
| 2189 } | 2187 } |
| 2190 } | 2188 } |
| 2191 } | 2189 } |
| 2192 | 2190 |
| 2193 » if (wcscmp(sFunction, L"AVG") == 0 && nFieldsCount > 0) | 2191 » if (wcscmp(sFunction.c_str(), L"AVG") == 0 && nFieldsCount > 0) |
| 2194 dValue /= nFieldsCount; | 2192 dValue /= nFieldsCount; |
| 2195 | 2193 |
| 2196 dValue = (double)floor(dValue * FXSYS_pow((double)10,(double)6) + 0.49)
/ FXSYS_pow((double)10,(double)6); | 2194 dValue = (double)floor(dValue * FXSYS_pow((double)10,(double)6) + 0.49)
/ FXSYS_pow((double)10,(double)6); |
| 2197 CJS_Value jsValue(isolate,dValue); | 2195 CJS_Value jsValue(isolate,dValue); |
| 2198 if((CJS_EventHandler*)pContext->GetEventHandler()->m_pValue) | 2196 if((CJS_EventHandler*)pContext->GetEventHandler()->m_pValue) |
| 2199 ((CJS_EventHandler*)pContext->GetEventHandler())->Value() = jsVa
lue.ToCFXWideString(); | 2197 ((CJS_EventHandler*)pContext->GetEventHandler())->Value() = jsVa
lue.ToCFXWideString(); |
| 2200 | 2198 |
| 2201 return TRUE; | 2199 return TRUE; |
| 2202 } | 2200 } |
| 2203 | 2201 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 2224 double dEentValue = atof(CFX_ByteString::FromUnicode(pEvent->Value())); | 2222 double dEentValue = atof(CFX_ByteString::FromUnicode(pEvent->Value())); |
| 2225 FX_BOOL bGreaterThan = params[0].ToBool(); | 2223 FX_BOOL bGreaterThan = params[0].ToBool(); |
| 2226 double dGreaterThan = params[1].ToDouble(); | 2224 double dGreaterThan = params[1].ToDouble(); |
| 2227 FX_BOOL bLessThan = params[2].ToBool(); | 2225 FX_BOOL bLessThan = params[2].ToBool(); |
| 2228 double dLessThan = params[3].ToDouble(); | 2226 double dLessThan = params[3].ToDouble(); |
| 2229 CFX_WideString swMsg; | 2227 CFX_WideString swMsg; |
| 2230 | 2228 |
| 2231 if (bGreaterThan && bLessThan) | 2229 if (bGreaterThan && bLessThan) |
| 2232 { | 2230 { |
| 2233 if (dEentValue < dGreaterThan || dEentValue > dLessThan) | 2231 if (dEentValue < dGreaterThan || dEentValue > dLessThan) |
| 2234 » » » swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSRA
NGE1), | 2232 » » » swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSRA
NGE1).c_str(), |
| 2235 params[1].ToCFXWideString().c_s
tr(), | 2233 params[1].ToCFXWideString().c_s
tr(), |
| 2236 params[3].ToCFXWideString().c_s
tr()); | 2234 params[3].ToCFXWideString().c_s
tr()); |
| 2237 } | 2235 } |
| 2238 else if (bGreaterThan) | 2236 else if (bGreaterThan) |
| 2239 { | 2237 { |
| 2240 if (dEentValue < dGreaterThan) | 2238 if (dEentValue < dGreaterThan) |
| 2241 » » » swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSRA
NGE2), | 2239 » » » swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSRA
NGE2).c_str(), |
| 2242 params[1].ToCFXWideString().c_s
tr()); | 2240 params[1].ToCFXWideString().c_s
tr()); |
| 2243 } | 2241 } |
| 2244 else if (bLessThan) | 2242 else if (bLessThan) |
| 2245 { | 2243 { |
| 2246 if (dEentValue > dLessThan) | 2244 if (dEentValue > dLessThan) |
| 2247 » » » swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSRA
NGE3), | 2245 » » » swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSRA
NGE3).c_str(), |
| 2248 params[3].ToCFXWideString().c_s
tr()); | 2246 params[3].ToCFXWideString().c_s
tr()); |
| 2249 } | 2247 } |
| 2250 | 2248 |
| 2251 if (!swMsg.IsEmpty()) | 2249 if (!swMsg.IsEmpty()) |
| 2252 { | 2250 { |
| 2253 » » Alert(pContext, swMsg); | 2251 » » Alert(pContext, swMsg.c_str()); |
| 2254 pEvent->Rc() = FALSE; | 2252 pEvent->Rc() = FALSE; |
| 2255 } | 2253 } |
| 2256 return TRUE; | 2254 return TRUE; |
| 2257 } | 2255 } |
| 2258 | 2256 |
| 2259 FX_BOOL CJS_PublicMethods::AFExtractNums(IFXJS_Context* cc, const CJS_Parameters
& params, CJS_Value& vRet, CFX_WideString& sError) | 2257 FX_BOOL CJS_PublicMethods::AFExtractNums(IFXJS_Context* cc, const CJS_Parameters
& params, CJS_Value& vRet, CFX_WideString& sError) |
| 2260 { | 2258 { |
| 2261 v8::Isolate* isolate = ::GetIsolate(cc); | 2259 v8::Isolate* isolate = ::GetIsolate(cc); |
| 2262 CJS_Context* pContext = (CJS_Context*)cc; | 2260 CJS_Context* pContext = (CJS_Context*)cc; |
| 2263 ASSERT(pContext != NULL); | 2261 ASSERT(pContext != NULL); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2300 nums.SetElement(nIndex,CJS_Value(isolate,sPart.c_str())); | 2298 nums.SetElement(nIndex,CJS_Value(isolate,sPart.c_str())); |
| 2301 } | 2299 } |
| 2302 | 2300 |
| 2303 if (nums.GetLength() > 0) | 2301 if (nums.GetLength() > 0) |
| 2304 vRet = nums; | 2302 vRet = nums; |
| 2305 else | 2303 else |
| 2306 vRet.SetNull(); | 2304 vRet.SetNull(); |
| 2307 | 2305 |
| 2308 return TRUE; | 2306 return TRUE; |
| 2309 } | 2307 } |
| OLD | NEW |