| 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 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 423 } | 423 } |
| 424 | 424 |
| 425 CJS_Array CJS_PublicMethods::AF_MakeArrayFromList(v8::Isolate* isolate, CJS_Valu
e val) | 425 CJS_Array CJS_PublicMethods::AF_MakeArrayFromList(v8::Isolate* isolate, CJS_Valu
e val) |
| 426 { | 426 { |
| 427 CJS_Array StrArray(isolate); | 427 CJS_Array StrArray(isolate); |
| 428 if(val.IsArrayObject()) | 428 if(val.IsArrayObject()) |
| 429 { | 429 { |
| 430 val.ConvertToArray(StrArray); | 430 val.ConvertToArray(StrArray); |
| 431 return StrArray; | 431 return StrArray; |
| 432 } | 432 } |
| 433 » CFX_WideString wsStr = val.operator CFX_WideString(); | 433 » CFX_WideString wsStr = val.ToCFXWideString(); |
| 434 CFX_ByteString t = CFX_ByteString::FromUnicode(wsStr); | 434 CFX_ByteString t = CFX_ByteString::FromUnicode(wsStr); |
| 435 const char * p = (const char *)t; | 435 const char * p = (const char *)t; |
| 436 | 436 |
| 437 | 437 |
| 438 int ch = ',' ; | 438 int ch = ',' ; |
| 439 int nIndex = 0; | 439 int nIndex = 0; |
| 440 | 440 |
| 441 while (*p) | 441 while (*p) |
| 442 { | 442 { |
| 443 const char * pTemp = strchr(p, ch); | 443 const char * pTemp = strchr(p, ch); |
| (...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1064 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); | 1064 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); |
| 1065 return FALSE; | 1065 return FALSE; |
| 1066 } | 1066 } |
| 1067 if(!pEvent->m_pValue) | 1067 if(!pEvent->m_pValue) |
| 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]; | 1074 » int iDec = params[0].ToInt(); |
| 1075 » int iSepStyle = params[1]; | 1075 » int iSepStyle = params[1].ToInt(); |
| 1076 » int iNegStyle = params[2]; | 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].operator CFX_WideString()); | 1078 » std::wstring wstrCurrency(params[4].ToCFXWideString()); |
| 1079 » FX_BOOL bCurrencyPrepend = params[5]; | 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 |
| 1089 | 1089 |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1261 //function AFNumber_Keystroke(nDec, sepStyle, negStyle, currStyle, strCurrency,
bCurrencyPrepend) | 1261 //function AFNumber_Keystroke(nDec, sepStyle, negStyle, currStyle, strCurrency,
bCurrencyPrepend) |
| 1262 FX_BOOL CJS_PublicMethods::AFNumber_Keystroke(IFXJS_Context* cc, const CJS_Param
eters& params, CJS_Value& vRet, CFX_WideString& sError) | 1262 FX_BOOL CJS_PublicMethods::AFNumber_Keystroke(IFXJS_Context* cc, const CJS_Param
eters& params, CJS_Value& vRet, CFX_WideString& sError) |
| 1263 { | 1263 { |
| 1264 CJS_Context* pContext = (CJS_Context *)cc; | 1264 CJS_Context* pContext = (CJS_Context *)cc; |
| 1265 ASSERT(pContext != NULL); | 1265 ASSERT(pContext != NULL); |
| 1266 CJS_EventHandler* pEvent = pContext->GetEventHandler(); | 1266 CJS_EventHandler* pEvent = pContext->GetEventHandler(); |
| 1267 ASSERT(pEvent != NULL); | 1267 ASSERT(pEvent != NULL); |
| 1268 | 1268 |
| 1269 if(params.size() < 2) | 1269 if(params.size() < 2) |
| 1270 return FALSE; | 1270 return FALSE; |
| 1271 » int iSepStyle = params[1]; | 1271 » int iSepStyle = params[1].ToInt(); |
| 1272 | 1272 |
| 1273 if (iSepStyle < 0 || iSepStyle > 3) | 1273 if (iSepStyle < 0 || iSepStyle > 3) |
| 1274 iSepStyle = 0; | 1274 iSepStyle = 0; |
| 1275 if(!pEvent->m_pValue) | 1275 if(!pEvent->m_pValue) |
| 1276 return FALSE; | 1276 return FALSE; |
| 1277 CFX_WideString & val = pEvent->Value(); | 1277 CFX_WideString & val = pEvent->Value(); |
| 1278 CFX_WideString & w_strChange = pEvent->Change(); | 1278 CFX_WideString & w_strChange = pEvent->Change(); |
| 1279 CFX_WideString w_strValue = val; | 1279 CFX_WideString w_strValue = val; |
| 1280 | 1280 |
| 1281 if (pEvent->WillCommit()) | 1281 if (pEvent->WillCommit()) |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1399 CJS_EventHandler* pEvent = pContext->GetEventHandler(); | 1399 CJS_EventHandler* pEvent = pContext->GetEventHandler(); |
| 1400 ASSERT(pEvent != NULL); | 1400 ASSERT(pEvent != NULL); |
| 1401 | 1401 |
| 1402 if (params.size() != 2) | 1402 if (params.size() != 2) |
| 1403 { | 1403 { |
| 1404 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); | 1404 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); |
| 1405 return FALSE; | 1405 return FALSE; |
| 1406 } | 1406 } |
| 1407 if(!pEvent->m_pValue) | 1407 if(!pEvent->m_pValue) |
| 1408 return FALSE; | 1408 return FALSE; |
| 1409 |
| 1409 CFX_WideString& Value = pEvent->Value(); | 1410 CFX_WideString& Value = pEvent->Value(); |
| 1410 | |
| 1411 // HWND hMainFrame = NULL; | |
| 1412 // | |
| 1413 // CPDFSDK_FormFillApp *pApp = pContext->GetReaderApp(); | |
| 1414 // ASSERT(pApp); | |
| 1415 // hMainFrame = pApp->GetMainFrameWnd(); | |
| 1416 | |
| 1417 CFX_ByteString strValue = StrTrim(CFX_ByteString::FromUnicode(Value)); | 1411 CFX_ByteString strValue = StrTrim(CFX_ByteString::FromUnicode(Value)); |
| 1418 | |
| 1419 if (strValue.IsEmpty()) | 1412 if (strValue.IsEmpty()) |
| 1420 return TRUE; | 1413 return TRUE; |
| 1421 » | 1414 |
| 1422 » int iDec = params[0]; | 1415 » int iDec = params[0].ToInt(); |
| 1423 » int iSepStyle = params[1]; | |
| 1424 » | |
| 1425 » //ASSERT(iDec > 0); | |
| 1426 if (iDec < 0) | 1416 if (iDec < 0) |
| 1427 iDec = -iDec; | 1417 iDec = -iDec; |
| 1428 » | 1418 |
| 1419 » int iSepStyle = params[1].ToInt(); |
| 1429 if (iSepStyle < 0 || iSepStyle > 3) | 1420 if (iSepStyle < 0 || iSepStyle > 3) |
| 1430 iSepStyle = 0; | 1421 iSepStyle = 0; |
| 1431 » | 1422 |
| 1432 » | |
| 1433 ////////////////////////////////////////////////////// | 1423 ////////////////////////////////////////////////////// |
| 1434 //for processing decimal places | 1424 //for processing decimal places |
| 1435 double dValue = atof(strValue); | 1425 double dValue = atof(strValue); |
| 1436 dValue *= 100; | 1426 dValue *= 100; |
| 1437 if (iDec > 0) | 1427 if (iDec > 0) |
| 1438 dValue += DOUBLE_CORRECT;//УÕý | 1428 dValue += DOUBLE_CORRECT;//УÕý |
| 1439 | 1429 |
| 1440 int iDec2; | 1430 int iDec2; |
| 1441 FX_BOOL bNagative = FALSE; | 1431 FX_BOOL bNagative = FALSE; |
| 1442 strValue = fcvt(dValue,iDec,&iDec2,&bNagative); | 1432 strValue = fcvt(dValue,iDec,&iDec2,&bNagative); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1520 { | 1510 { |
| 1521 CJS_Context* pContext = (CJS_Context *)cc; | 1511 CJS_Context* pContext = (CJS_Context *)cc; |
| 1522 ASSERT(pContext != NULL); | 1512 ASSERT(pContext != NULL); |
| 1523 CJS_EventHandler* pEvent = pContext->GetEventHandler(); | 1513 CJS_EventHandler* pEvent = pContext->GetEventHandler(); |
| 1524 ASSERT(pEvent != NULL); | 1514 ASSERT(pEvent != NULL); |
| 1525 | 1515 |
| 1526 if (params.size() != 1) | 1516 if (params.size() != 1) |
| 1527 { | 1517 { |
| 1528 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); | 1518 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); |
| 1529 return FALSE; | 1519 return FALSE; |
| 1530 » }» | 1520 » } |
| 1531 if(!pEvent->m_pValue) | 1521 if(!pEvent->m_pValue) |
| 1532 return FALSE; | 1522 return FALSE; |
| 1523 |
| 1533 CFX_WideString& val = pEvent->Value(); | 1524 CFX_WideString& val = pEvent->Value(); |
| 1534 » | 1525 » CFX_WideString strValue = val; |
| 1535 » CFX_WideString strValue = val;» | 1526 » if (strValue.IsEmpty()) |
| 1536 » if (strValue.IsEmpty()) return TRUE;» » | 1527 » » return TRUE; |
| 1537 | 1528 |
| 1538 » CFX_WideString sFormat = params[0].operator CFX_WideString(); | 1529 » CFX_WideString sFormat = params[0].ToCFXWideString(); |
| 1539 | |
| 1540 FX_BOOL bWrongFormat = FALSE; | 1530 FX_BOOL bWrongFormat = FALSE; |
| 1541 double dDate = 0.0f; | 1531 double dDate = 0.0f; |
| 1542 | 1532 |
| 1543 if(strValue.Find(L"GMT") != -1) | 1533 if(strValue.Find(L"GMT") != -1) |
| 1544 { | 1534 { |
| 1545 //for GMT format time | 1535 //for GMT format time |
| 1546 //such as "Tue Aug 11 14:24:16 GMT+08002009" | 1536 //such as "Tue Aug 11 14:24:16 GMT+08002009" |
| 1547 dDate = MakeInterDate(strValue); | 1537 dDate = MakeInterDate(strValue); |
| 1548 } | 1538 } |
| 1549 else | 1539 else |
| 1550 { | 1540 { |
| 1551 dDate = MakeRegularDate(strValue,sFormat,bWrongFormat); | 1541 dDate = MakeRegularDate(strValue,sFormat,bWrongFormat); |
| 1552 } | 1542 } |
| 1553 | 1543 |
| 1554 if (JS_PortIsNan(dDate)) | 1544 if (JS_PortIsNan(dDate)) |
| 1555 { | 1545 { |
| 1556 CFX_WideString swMsg; | 1546 CFX_WideString swMsg; |
| 1557 swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSPARSEDATE)
, sFormat.c_str()); | 1547 swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSPARSEDATE)
, sFormat.c_str()); |
| 1558 Alert(pContext, swMsg); | 1548 Alert(pContext, swMsg); |
| 1559 return FALSE; | 1549 return FALSE; |
| 1560 } | 1550 } |
| 1561 » | 1551 |
| 1562 val = MakeFormatDate(dDate,sFormat); | 1552 val = MakeFormatDate(dDate,sFormat); |
| 1563 | |
| 1564 return TRUE; | 1553 return TRUE; |
| 1565 } | 1554 } |
| 1566 | 1555 |
| 1567 double CJS_PublicMethods::MakeInterDate(CFX_WideString strValue) | 1556 double CJS_PublicMethods::MakeInterDate(CFX_WideString strValue) |
| 1568 { | 1557 { |
| 1569 int nHour; | 1558 int nHour; |
| 1570 int nMin; | 1559 int nMin; |
| 1571 int nSec; | 1560 int nSec; |
| 1572 int nYear; | 1561 int nYear; |
| 1573 int nMonth; | 1562 int nMonth; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1629 { | 1618 { |
| 1630 CJS_Context* pContext = (CJS_Context *)cc; | 1619 CJS_Context* pContext = (CJS_Context *)cc; |
| 1631 ASSERT(pContext != NULL); | 1620 ASSERT(pContext != NULL); |
| 1632 CJS_EventHandler* pEvent = pContext->GetEventHandler(); | 1621 CJS_EventHandler* pEvent = pContext->GetEventHandler(); |
| 1633 ASSERT(pEvent != NULL); | 1622 ASSERT(pEvent != NULL); |
| 1634 | 1623 |
| 1635 if (params.size() != 1) | 1624 if (params.size() != 1) |
| 1636 { | 1625 { |
| 1637 sError = L"AFDate_KeystrokeEx's parameters' size r not correct"; | 1626 sError = L"AFDate_KeystrokeEx's parameters' size r not correct"; |
| 1638 return FALSE; | 1627 return FALSE; |
| 1639 » }» | 1628 » } |
| 1640 » | 1629 |
| 1641 if (pEvent->WillCommit()) | 1630 if (pEvent->WillCommit()) |
| 1642 { | 1631 { |
| 1643 if(!pEvent->m_pValue) | 1632 if(!pEvent->m_pValue) |
| 1644 return FALSE; | 1633 return FALSE; |
| 1645 CFX_WideString strValue = pEvent->Value(); | 1634 CFX_WideString strValue = pEvent->Value(); |
| 1646 » » if (strValue.IsEmpty()) return TRUE; | 1635 » » if (strValue.IsEmpty()) |
| 1636 » » » return TRUE; |
| 1647 | 1637 |
| 1648 » » CFX_WideString sFormat = params[0].operator CFX_WideString(); | 1638 » » CFX_WideString sFormat = params[0].ToCFXWideString(); |
| 1649 | |
| 1650 FX_BOOL bWrongFormat = FALSE; | 1639 FX_BOOL bWrongFormat = FALSE; |
| 1651 double dRet = MakeRegularDate(strValue,sFormat,bWrongFormat); | 1640 double dRet = MakeRegularDate(strValue,sFormat,bWrongFormat); |
| 1652 if (bWrongFormat || JS_PortIsNan(dRet)) | 1641 if (bWrongFormat || JS_PortIsNan(dRet)) |
| 1653 { | 1642 { |
| 1654 CFX_WideString swMsg; | 1643 CFX_WideString swMsg; |
| 1655 swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSPA
RSEDATE), sFormat.c_str()); | 1644 swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSPA
RSEDATE), sFormat.c_str()); |
| 1656 Alert(pContext, swMsg); | 1645 Alert(pContext, swMsg); |
| 1657 pEvent->Rc() = FALSE; | 1646 pEvent->Rc() = FALSE; |
| 1658 return TRUE; | 1647 return TRUE; |
| 1659 } | 1648 } |
| 1660 } | 1649 } |
| 1661 return TRUE; | 1650 return TRUE; |
| 1662 } | 1651 } |
| 1663 | 1652 |
| 1664 FX_BOOL CJS_PublicMethods::AFDate_Format(IFXJS_Context* cc, const CJS_Parameters
& params, CJS_Value& vRet, CFX_WideString& sError) | 1653 FX_BOOL CJS_PublicMethods::AFDate_Format(IFXJS_Context* cc, const CJS_Parameters
& params, CJS_Value& vRet, CFX_WideString& sError) |
| 1665 { | 1654 { |
| 1666 v8::Isolate* isolate = ::GetIsolate(cc); | 1655 v8::Isolate* isolate = ::GetIsolate(cc); |
| 1667 | 1656 |
| 1668 if (params.size() != 1) | 1657 if (params.size() != 1) |
| 1669 { | 1658 { |
| 1670 CJS_Context* pContext = (CJS_Context*)cc; | 1659 CJS_Context* pContext = (CJS_Context*)cc; |
| 1671 ASSERT(pContext != NULL); | 1660 ASSERT(pContext != NULL); |
| 1672 | 1661 |
| 1673 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); | 1662 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); |
| 1674 return FALSE; | 1663 return FALSE; |
| 1675 } | 1664 } |
| 1676 | 1665 |
| 1677 » int iIndex = params[0]; | 1666 » int iIndex = params[0].ToInt(); |
| 1678 FX_LPCWSTR cFormats[] = {L"m/d", L"m/d/yy", L"mm/dd/yy", L"mm/yy", L"d-
mmm", L"d-mmm-yy", L"dd-mmm-yy", | 1667 FX_LPCWSTR cFormats[] = {L"m/d", L"m/d/yy", L"mm/dd/yy", L"mm/yy", L"d-
mmm", L"d-mmm-yy", L"dd-mmm-yy", |
| 1679 L"yy-mm-dd", L"mmm-yy", L"mmmm-yy", L"mmm d, yyyy", L"mmmm d, yy
yy", | 1668 L"yy-mm-dd", L"mmm-yy", L"mmmm-yy", L"mmm d, yyyy", L"mmmm d, yy
yy", |
| 1680 L"m/d/yy h:MM tt", L"m/d/yy HH:MM" }; | 1669 L"m/d/yy h:MM tt", L"m/d/yy HH:MM" }; |
| 1681 | 1670 |
| 1682 ASSERT(iIndex < FX_ArraySize(cFormats)); | 1671 ASSERT(iIndex < FX_ArraySize(cFormats)); |
| 1683 | 1672 |
| 1684 if (iIndex < 0) | 1673 if (iIndex < 0) |
| 1685 iIndex = 0; | 1674 iIndex = 0; |
| 1686 if (iIndex >= FX_ArraySize(cFormats)) | 1675 if (iIndex >= FX_ArraySize(cFormats)) |
| 1687 iIndex = 0; | 1676 iIndex = 0; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1698 | 1687 |
| 1699 if (params.size() != 1) | 1688 if (params.size() != 1) |
| 1700 { | 1689 { |
| 1701 CJS_Context* pContext = (CJS_Context*)cc; | 1690 CJS_Context* pContext = (CJS_Context*)cc; |
| 1702 ASSERT(pContext != NULL); | 1691 ASSERT(pContext != NULL); |
| 1703 | 1692 |
| 1704 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); | 1693 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); |
| 1705 return FALSE; | 1694 return FALSE; |
| 1706 } | 1695 } |
| 1707 | 1696 |
| 1708 » int iIndex = params[0]; | 1697 » int iIndex = params[0].ToInt(); |
| 1709 FX_LPCWSTR cFormats[] = {L"m/d", L"m/d/yy", L"mm/dd/yy", L"mm/yy", L"d-
mmm", L"d-mmm-yy", L"dd-mmm-yy", | 1698 FX_LPCWSTR cFormats[] = {L"m/d", L"m/d/yy", L"mm/dd/yy", L"mm/yy", L"d-
mmm", L"d-mmm-yy", L"dd-mmm-yy", |
| 1710 L"yy-mm-dd", L"mmm-yy", L"mmmm-yy", L"mmm d, yyyy", L"mmmm d, yy
yy", | 1699 L"yy-mm-dd", L"mmm-yy", L"mmmm-yy", L"mmm d, yyyy", L"mmmm d, yy
yy", |
| 1711 L"m/d/yy h:MM tt", L"m/d/yy HH:MM" }; | 1700 L"m/d/yy h:MM tt", L"m/d/yy HH:MM" }; |
| 1712 | 1701 |
| 1713 ASSERT(iIndex<FX_ArraySize(cFormats)); | 1702 ASSERT(iIndex<FX_ArraySize(cFormats)); |
| 1714 | 1703 |
| 1715 if (iIndex < 0) | 1704 if (iIndex < 0) |
| 1716 iIndex = 0; | 1705 iIndex = 0; |
| 1717 if (iIndex >= FX_ArraySize(cFormats)) | 1706 if (iIndex >= FX_ArraySize(cFormats)) |
| 1718 iIndex = 0; | 1707 iIndex = 0; |
| 1719 CJS_Parameters newParams; | 1708 CJS_Parameters newParams; |
| 1720 CJS_Value val(isolate,cFormats[iIndex]); | 1709 CJS_Value val(isolate,cFormats[iIndex]); |
| 1721 newParams.push_back(val); | 1710 newParams.push_back(val); |
| 1722 return AFDate_KeystrokeEx(cc,newParams,vRet,sError); | 1711 return AFDate_KeystrokeEx(cc,newParams,vRet,sError); |
| 1723 } | 1712 } |
| 1724 | 1713 |
| 1725 //function AFTime_Format(ptf) | 1714 //function AFTime_Format(ptf) |
| 1726 FX_BOOL CJS_PublicMethods::AFTime_Format(IFXJS_Context* cc, const CJS_Parameters
& params, CJS_Value& vRet, CFX_WideString& sError) | 1715 FX_BOOL CJS_PublicMethods::AFTime_Format(IFXJS_Context* cc, const CJS_Parameters
& params, CJS_Value& vRet, CFX_WideString& sError) |
| 1727 { | 1716 { |
| 1728 v8::Isolate* isolate = ::GetIsolate(cc); | 1717 v8::Isolate* isolate = ::GetIsolate(cc); |
| 1729 | 1718 |
| 1730 if (params.size() != 1) | 1719 if (params.size() != 1) |
| 1731 { | 1720 { |
| 1732 CJS_Context* pContext = (CJS_Context*)cc; | 1721 CJS_Context* pContext = (CJS_Context*)cc; |
| 1733 ASSERT(pContext != NULL); | 1722 ASSERT(pContext != NULL); |
| 1734 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); | 1723 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); |
| 1735 return FALSE; | 1724 return FALSE; |
| 1736 } | 1725 } |
| 1737 | 1726 |
| 1738 » int iIndex = params[0]; | 1727 » int iIndex = params[0].ToInt(); |
| 1739 FX_LPCWSTR cFormats[] = {L"HH:MM", L"h:MM tt", L"HH:MM:ss", L"h:MM:ss tt
"}; | 1728 FX_LPCWSTR cFormats[] = {L"HH:MM", L"h:MM tt", L"HH:MM:ss", L"h:MM:ss tt
"}; |
| 1740 | 1729 |
| 1741 ASSERT(iIndex<FX_ArraySize(cFormats)); | 1730 ASSERT(iIndex<FX_ArraySize(cFormats)); |
| 1742 | 1731 |
| 1743 if (iIndex < 0) | 1732 if (iIndex < 0) |
| 1744 iIndex = 0; | 1733 iIndex = 0; |
| 1745 if (iIndex >= FX_ArraySize(cFormats)) | 1734 if (iIndex >= FX_ArraySize(cFormats)) |
| 1746 iIndex = 0; | 1735 iIndex = 0; |
| 1747 CJS_Parameters newParams; | 1736 CJS_Parameters newParams; |
| 1748 CJS_Value val(isolate,cFormats[iIndex]); | 1737 CJS_Value val(isolate,cFormats[iIndex]); |
| 1749 newParams.push_back(val); | 1738 newParams.push_back(val); |
| 1750 return AFDate_FormatEx(cc,newParams,vRet,sError); | 1739 return AFDate_FormatEx(cc,newParams,vRet,sError); |
| 1751 } | 1740 } |
| 1752 | 1741 |
| 1753 FX_BOOL CJS_PublicMethods::AFTime_Keystroke(IFXJS_Context* cc, const CJS_Paramet
ers& params, CJS_Value& vRet, CFX_WideString& sError) | 1742 FX_BOOL CJS_PublicMethods::AFTime_Keystroke(IFXJS_Context* cc, const CJS_Paramet
ers& params, CJS_Value& vRet, CFX_WideString& sError) |
| 1754 { | 1743 { |
| 1755 v8::Isolate* isolate = ::GetIsolate(cc); | 1744 v8::Isolate* isolate = ::GetIsolate(cc); |
| 1756 if (params.size() != 1) | 1745 if (params.size() != 1) |
| 1757 { | 1746 { |
| 1758 CJS_Context* pContext = (CJS_Context*)cc; | 1747 CJS_Context* pContext = (CJS_Context*)cc; |
| 1759 ASSERT(pContext != NULL); | 1748 ASSERT(pContext != NULL); |
| 1760 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); | 1749 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); |
| 1761 return FALSE; | 1750 return FALSE; |
| 1762 } | 1751 } |
| 1763 | 1752 |
| 1764 » int iIndex = params[0]; | 1753 » int iIndex = params[0].ToInt(); |
| 1765 FX_LPCWSTR cFormats[] = {L"HH:MM", L"h:MM tt", L"HH:MM:ss", L"h:MM:ss tt
"}; | 1754 FX_LPCWSTR cFormats[] = {L"HH:MM", L"h:MM tt", L"HH:MM:ss", L"h:MM:ss tt
"}; |
| 1766 | 1755 |
| 1767 ASSERT(iIndex<FX_ArraySize(cFormats)); | 1756 ASSERT(iIndex<FX_ArraySize(cFormats)); |
| 1768 | 1757 |
| 1769 if (iIndex < 0) | 1758 if (iIndex < 0) |
| 1770 iIndex = 0; | 1759 iIndex = 0; |
| 1771 if (iIndex >= FX_ArraySize(cFormats)) | 1760 if (iIndex >= FX_ArraySize(cFormats)) |
| 1772 iIndex = 0; | 1761 iIndex = 0; |
| 1773 CJS_Parameters newParams; | 1762 CJS_Parameters newParams; |
| 1774 CJS_Value val(isolate,cFormats[iIndex]); | 1763 CJS_Value val(isolate,cFormats[iIndex]); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1792 CJS_Context* pContext = (CJS_Context *)cc; | 1781 CJS_Context* pContext = (CJS_Context *)cc; |
| 1793 ASSERT(pContext != NULL); | 1782 ASSERT(pContext != NULL); |
| 1794 | 1783 |
| 1795 if (params.size() != 1) | 1784 if (params.size() != 1) |
| 1796 { | 1785 { |
| 1797 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); | 1786 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); |
| 1798 return FALSE; | 1787 return FALSE; |
| 1799 } | 1788 } |
| 1800 | 1789 |
| 1801 std::string cFormat; | 1790 std::string cFormat; |
| 1802 » int iIndex = params[0]; | 1791 » int iIndex = params[0].ToInt(); |
| 1803 | 1792 |
| 1804 CJS_EventHandler* pEvent = pContext->GetEventHandler(); | 1793 CJS_EventHandler* pEvent = pContext->GetEventHandler(); |
| 1805 ASSERT(pEvent != NULL); | 1794 ASSERT(pEvent != NULL); |
| 1806 | 1795 |
| 1807 if(!pEvent->m_pValue) | 1796 if(!pEvent->m_pValue) |
| 1808 return FALSE; | 1797 return FALSE; |
| 1809 CFX_WideString& Value = pEvent->Value(); | 1798 CFX_WideString& Value = pEvent->Value(); |
| 1810 std::string strSrc = CFX_ByteString::FromUnicode(Value).c_str(); | 1799 std::string strSrc = CFX_ByteString::FromUnicode(Value).c_str(); |
| 1811 | 1800 |
| 1812 switch (iIndex) | 1801 switch (iIndex) |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1851 if (params.size() < 1) | 1840 if (params.size() < 1) |
| 1852 { | 1841 { |
| 1853 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); | 1842 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); |
| 1854 return FALSE; | 1843 return FALSE; |
| 1855 } | 1844 } |
| 1856 | 1845 |
| 1857 if(!pEvent->m_pValue) | 1846 if(!pEvent->m_pValue) |
| 1858 return FALSE; | 1847 return FALSE; |
| 1859 CFX_WideString& valEvent = pEvent->Value(); | 1848 CFX_WideString& valEvent = pEvent->Value(); |
| 1860 | 1849 |
| 1861 » CFX_WideString wstrMask = params[0].operator CFX_WideString(); | 1850 » CFX_WideString wstrMask = params[0].ToCFXWideString(); |
| 1862 » if (wstrMask.IsEmpty()) return TRUE; | 1851 » if (wstrMask.IsEmpty()) |
| 1863 » | 1852 » » return TRUE; |
| 1853 |
| 1864 std::wstring wstrValue(valEvent); | 1854 std::wstring wstrValue(valEvent); |
| 1865 » | 1855 |
| 1866 if (pEvent->WillCommit()) | 1856 if (pEvent->WillCommit()) |
| 1867 { | 1857 { |
| 1868 if (wstrValue.empty()) | 1858 if (wstrValue.empty()) |
| 1869 return TRUE; | 1859 return TRUE; |
| 1870 int iIndexMask = 0; | 1860 int iIndexMask = 0; |
| 1871 for (std::wstring::iterator it = wstrValue.begin(); it != wstrVa
lue.end(); it++) | 1861 for (std::wstring::iterator it = wstrValue.begin(); it != wstrVa
lue.end(); it++) |
| 1872 { | 1862 { |
| 1873 wchar_t w_Value = *it; | 1863 wchar_t w_Value = *it; |
| 1874 if (!maskSatisfied(w_Value,wstrMask[iIndexMask])) | 1864 » » » if (!maskSatisfied(w_Value,wstrMask[iIndexMask])) |
| 1875 break; | 1865 break; |
| 1876 iIndexMask++; | 1866 iIndexMask++; |
| 1877 } | 1867 } |
| 1878 | 1868 |
| 1879 if (iIndexMask != wstrMask.GetLength() || (iIndexMask != wstrVal
ue.size() && wstrMask.GetLength() != 0)) | 1869 if (iIndexMask != wstrMask.GetLength() || (iIndexMask != wstrVal
ue.size() && wstrMask.GetLength() != 0)) |
| 1880 { | 1870 { |
| 1881 Alert(pContext, JSGetStringFromID(pContext, IDS_STRING_J
SAFNUMBER_KEYSTROKE)); | 1871 Alert(pContext, JSGetStringFromID(pContext, IDS_STRING_J
SAFNUMBER_KEYSTROKE)); |
| 1882 pEvent->Rc() = FALSE; | 1872 pEvent->Rc() = FALSE; |
| 1883 } | 1873 } |
| 1884 return TRUE; | 1874 return TRUE; |
| 1885 } | 1875 } |
| 1886 | 1876 |
| 1887 | |
| 1888 CFX_WideString &wideChange = pEvent->Change(); | 1877 CFX_WideString &wideChange = pEvent->Change(); |
| 1889 std::wstring wChange(wideChange); | 1878 std::wstring wChange(wideChange); |
| 1890 | |
| 1891 if (wChange.empty()) | 1879 if (wChange.empty()) |
| 1892 return TRUE; | 1880 return TRUE; |
| 1893 int iIndexMask = pEvent->SelStart(); | 1881 |
| 1894 » //iIndexMask++; | 1882 » int iIndexMask = pEvent->SelStart(); |
| 1895 » | 1883 |
| 1896 » | |
| 1897 if (wstrValue.length() - (pEvent->SelEnd()-pEvent->SelStart()) + wChange
.length() > (FX_DWORD)wstrMask.GetLength()) | 1884 if (wstrValue.length() - (pEvent->SelEnd()-pEvent->SelStart()) + wChange
.length() > (FX_DWORD)wstrMask.GetLength()) |
| 1898 { | 1885 { |
| 1899 Alert(pContext, JSGetStringFromID(pContext, IDS_STRING_JSPARAM_T
OOLONG)); | 1886 Alert(pContext, JSGetStringFromID(pContext, IDS_STRING_JSPARAM_T
OOLONG)); |
| 1900 pEvent->Rc() = FALSE; | 1887 pEvent->Rc() = FALSE; |
| 1901 return TRUE; | 1888 return TRUE; |
| 1902 } | 1889 } |
| 1903 » | 1890 |
| 1904 » | |
| 1905 if (iIndexMask >= wstrMask.GetLength() && (!wChange.empty())) | 1891 if (iIndexMask >= wstrMask.GetLength() && (!wChange.empty())) |
| 1906 { | 1892 { |
| 1907 Alert(pContext, JSGetStringFromID(pContext, IDS_STRING_JSPARAM_T
OOLONG)); | 1893 Alert(pContext, JSGetStringFromID(pContext, IDS_STRING_JSPARAM_T
OOLONG)); |
| 1908 pEvent->Rc() = FALSE; | 1894 pEvent->Rc() = FALSE; |
| 1909 return TRUE; | 1895 return TRUE; |
| 1910 } | 1896 } |
| 1911 » | 1897 |
| 1912 for (std::wstring::iterator it = wChange.begin(); it != wChange.end(); i
t++) | 1898 for (std::wstring::iterator it = wChange.begin(); it != wChange.end(); i
t++) |
| 1913 { | 1899 { |
| 1914 if (iIndexMask >= wstrMask.GetLength()) | 1900 if (iIndexMask >= wstrMask.GetLength()) |
| 1915 { | 1901 { |
| 1916 Alert(pContext, JSGetStringFromID(pContext, IDS_STRING_J
SPARAM_TOOLONG)); | 1902 Alert(pContext, JSGetStringFromID(pContext, IDS_STRING_J
SPARAM_TOOLONG)); |
| 1917 pEvent->Rc() = FALSE; | 1903 pEvent->Rc() = FALSE; |
| 1918 return TRUE; | 1904 return TRUE; |
| 1919 } | 1905 } |
| 1920 wchar_t w_Mask = wstrMask[iIndexMask]; | 1906 wchar_t w_Mask = wstrMask[iIndexMask]; |
| 1921 if (!isReservedMaskChar(w_Mask)) | 1907 if (!isReservedMaskChar(w_Mask)) |
| 1922 { | 1908 { |
| 1923 //wChange.insert(it,w_Mask); | |
| 1924 *it = w_Mask; | 1909 *it = w_Mask; |
| 1925 } | 1910 } |
| 1926 wchar_t w_Change = *it; | 1911 wchar_t w_Change = *it; |
| 1927 » » | 1912 » » if (!maskSatisfied(w_Change,w_Mask)) |
| 1928 if (!maskSatisfied(w_Change,w_Mask)) | |
| 1929 { | 1913 { |
| 1930 pEvent->Rc() = FALSE; | 1914 pEvent->Rc() = FALSE; |
| 1931 return TRUE; | 1915 return TRUE; |
| 1932 } | 1916 } |
| 1933 iIndexMask++; | 1917 iIndexMask++; |
| 1934 } | 1918 } |
| 1935 » | 1919 |
| 1936 » wideChange = wChange.c_str();» | 1920 » wideChange = wChange.c_str(); |
| 1937 » | |
| 1938 return TRUE; | 1921 return TRUE; |
| 1939 } | 1922 } |
| 1940 | 1923 |
| 1941 | 1924 |
| 1942 //function AFSpecial_Keystroke(psf) | 1925 //function AFSpecial_Keystroke(psf) |
| 1943 FX_BOOL CJS_PublicMethods::AFSpecial_Keystroke(IFXJS_Context* cc, const CJS_Para
meters& params, CJS_Value& vRet, CFX_WideString& sError) | 1926 FX_BOOL CJS_PublicMethods::AFSpecial_Keystroke(IFXJS_Context* cc, const CJS_Para
meters& params, CJS_Value& vRet, CFX_WideString& sError) |
| 1944 { | 1927 { |
| 1945 v8::Isolate* isolate = ::GetIsolate(cc); | 1928 v8::Isolate* isolate = ::GetIsolate(cc); |
| 1946 | 1929 |
| 1947 CJS_Context* pContext = (CJS_Context *)cc; | 1930 CJS_Context* pContext = (CJS_Context *)cc; |
| 1948 ASSERT(pContext != NULL); | 1931 ASSERT(pContext != NULL); |
| 1949 CJS_EventHandler* pEvent = pContext->GetEventHandler(); | 1932 CJS_EventHandler* pEvent = pContext->GetEventHandler(); |
| 1950 ASSERT(pEvent != NULL); | 1933 ASSERT(pEvent != NULL); |
| 1951 | 1934 |
| 1952 if (params.size() != 1) | 1935 if (params.size() != 1) |
| 1953 { | 1936 { |
| 1954 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); | 1937 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); |
| 1955 return FALSE; | 1938 return FALSE; |
| 1956 } | 1939 } |
| 1957 | 1940 |
| 1958 std::string cFormat; | 1941 std::string cFormat; |
| 1959 » int iIndex = (int)params[0];» | 1942 » int iIndex = params[0].ToInt(); |
| 1960 | 1943 |
| 1961 if(!pEvent->m_pValue) | 1944 if(!pEvent->m_pValue) |
| 1962 return FALSE; | 1945 return FALSE; |
| 1963 //CJS_Value val = pEvent->Value(); | 1946 //CJS_Value val = pEvent->Value(); |
| 1964 CFX_WideString& val = pEvent->Value(); | 1947 CFX_WideString& val = pEvent->Value(); |
| 1965 std::string strSrc = CFX_ByteString::FromUnicode(val).c_str(); | 1948 std::string strSrc = CFX_ByteString::FromUnicode(val).c_str(); |
| 1966 std::wstring wstrChange(pEvent->Change()); | 1949 std::wstring wstrChange(pEvent->Change()); |
| 1967 | 1950 |
| 1968 switch (iIndex) | 1951 switch (iIndex) |
| 1969 { | 1952 { |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2043 { | 2026 { |
| 2044 CJS_Context* pContext = (CJS_Context *)cc; | 2027 CJS_Context* pContext = (CJS_Context *)cc; |
| 2045 ASSERT(pContext != NULL); | 2028 ASSERT(pContext != NULL); |
| 2046 | 2029 |
| 2047 if (params.size() != 2) | 2030 if (params.size() != 2) |
| 2048 { | 2031 { |
| 2049 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); | 2032 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); |
| 2050 return FALSE; | 2033 return FALSE; |
| 2051 } | 2034 } |
| 2052 | 2035 |
| 2053 » CFX_WideString sValue = params[0].operator CFX_WideString(); | 2036 » CFX_WideString sValue = params[0].ToCFXWideString(); |
| 2054 » CFX_WideString sFormat = params[1].operator CFX_WideString(); | 2037 » CFX_WideString sFormat = params[1].ToCFXWideString(); |
| 2055 | 2038 |
| 2056 FX_BOOL bWrongFormat = FALSE; | 2039 FX_BOOL bWrongFormat = FALSE; |
| 2057 double dDate = MakeRegularDate(sValue,sFormat,bWrongFormat); | 2040 double dDate = MakeRegularDate(sValue,sFormat,bWrongFormat); |
| 2058 | 2041 |
| 2059 if (JS_PortIsNan(dDate)) | 2042 if (JS_PortIsNan(dDate)) |
| 2060 { | 2043 { |
| 2061 CFX_WideString swMsg; | 2044 CFX_WideString swMsg; |
| 2062 swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSPARSEDATE)
, sFormat.c_str()); | 2045 swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSPARSEDATE)
, sFormat.c_str()); |
| 2063 Alert((CJS_Context *)cc, swMsg); | 2046 Alert((CJS_Context *)cc, swMsg); |
| 2064 return FALSE; | 2047 return FALSE; |
| 2065 } | 2048 } |
| 2066 » | 2049 |
| 2067 vRet = dDate; | 2050 vRet = dDate; |
| 2068 | |
| 2069 return TRUE; | 2051 return TRUE; |
| 2070 } | 2052 } |
| 2071 | 2053 |
| 2072 FX_BOOL CJS_PublicMethods::AFSimple(IFXJS_Context* cc, const CJS_Parameters& par
ams, CJS_Value& vRet, CFX_WideString& sError) | 2054 FX_BOOL CJS_PublicMethods::AFSimple(IFXJS_Context* cc, const CJS_Parameters& par
ams, CJS_Value& vRet, CFX_WideString& sError) |
| 2073 { | 2055 { |
| 2074 if (params.size() != 3) | 2056 if (params.size() != 3) |
| 2075 { | 2057 { |
| 2076 CJS_Context* pContext = (CJS_Context *)cc; | 2058 CJS_Context* pContext = (CJS_Context *)cc; |
| 2077 ASSERT(pContext != NULL); | 2059 ASSERT(pContext != NULL); |
| 2078 | 2060 |
| 2079 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); | 2061 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); |
| 2080 return FALSE; | 2062 return FALSE; |
| 2081 } | 2063 } |
| 2082 | 2064 |
| 2083 » vRet = (double)AF_Simple(params[0].operator CFX_WideString(), (double)pa
rams[1], (double)params[2]); | 2065 » vRet = (double)AF_Simple(params[0].ToCFXWideString(), params[1].ToDouble
(), params[2].ToDouble()); |
| 2084 return TRUE; | 2066 return TRUE; |
| 2085 } | 2067 } |
| 2086 | 2068 |
| 2087 FX_BOOL CJS_PublicMethods::AFMakeNumber(IFXJS_Context* cc, const CJS_Parameters&
params, CJS_Value& vRet, CFX_WideString& sError) | 2069 FX_BOOL CJS_PublicMethods::AFMakeNumber(IFXJS_Context* cc, const CJS_Parameters&
params, CJS_Value& vRet, CFX_WideString& sError) |
| 2088 { | 2070 { |
| 2089 if (params.size() != 1) | 2071 if (params.size() != 1) |
| 2090 { | 2072 { |
| 2091 CJS_Context* pContext = (CJS_Context *)cc; | 2073 CJS_Context* pContext = (CJS_Context *)cc; |
| 2092 ASSERT(pContext != NULL); | 2074 ASSERT(pContext != NULL); |
| 2093 | 2075 |
| 2094 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); | 2076 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); |
| 2095 return FALSE; | 2077 return FALSE; |
| 2096 } | 2078 } |
| 2097 vRet = ParseStringToNumber(params[0].operator CFX_WideString()); | 2079 » vRet = ParseStringToNumber(params[0].ToCFXWideString()); |
| 2098 return TRUE; | 2080 return TRUE; |
| 2099 } | 2081 } |
| 2100 | 2082 |
| 2101 FX_BOOL CJS_PublicMethods::AFSimple_Calculate(IFXJS_Context* cc, const CJS_Param
eters& params, CJS_Value& vRet, CFX_WideString& sError) | 2083 FX_BOOL CJS_PublicMethods::AFSimple_Calculate(IFXJS_Context* cc, const CJS_Param
eters& params, CJS_Value& vRet, CFX_WideString& sError) |
| 2102 { | 2084 { |
| 2103 v8::Isolate* isolate = ::GetIsolate(cc); | 2085 v8::Isolate* isolate = ::GetIsolate(cc); |
| 2104 | 2086 |
| 2105 CJS_Context* pContext = (CJS_Context *)cc; | 2087 CJS_Context* pContext = (CJS_Context *)cc; |
| 2106 ASSERT(pContext != NULL); | 2088 ASSERT(pContext != NULL); |
| 2107 | 2089 |
| 2108 if (params.size() != 2) | 2090 if (params.size() != 2) |
| 2109 { | 2091 { |
| 2110 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); | 2092 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); |
| 2111 return FALSE; | 2093 return FALSE; |
| 2112 } | 2094 } |
| 2113 | 2095 |
| 2114 CJS_Value params1 = params[1]; | 2096 CJS_Value params1 = params[1]; |
| 2115 | 2097 |
| 2116 if (!params1.IsArrayObject() && params1.GetType() != VT_string) | 2098 if (!params1.IsArrayObject() && params1.GetType() != VT_string) |
| 2117 { | 2099 { |
| 2118 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); | 2100 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); |
| 2119 return FALSE; | 2101 return FALSE; |
| 2120 } | 2102 } |
| 2121 » | 2103 |
| 2122 CPDFSDK_Document* pReaderDoc = pContext->GetReaderDocument(); | 2104 CPDFSDK_Document* pReaderDoc = pContext->GetReaderDocument(); |
| 2123 ASSERT(pReaderDoc != NULL); | 2105 ASSERT(pReaderDoc != NULL); |
| 2124 | 2106 |
| 2125 CPDFSDK_InterForm* pReaderInterForm = pReaderDoc->GetInterForm(); | 2107 CPDFSDK_InterForm* pReaderInterForm = pReaderDoc->GetInterForm(); |
| 2126 ASSERT(pReaderInterForm != NULL); | 2108 ASSERT(pReaderInterForm != NULL); |
| 2127 | 2109 |
| 2128 CPDF_InterForm* pInterForm = pReaderInterForm->GetInterForm(); | 2110 CPDF_InterForm* pInterForm = pReaderInterForm->GetInterForm(); |
| 2129 ASSERT(pInterForm != NULL); | 2111 ASSERT(pInterForm != NULL); |
| 2130 | 2112 |
| 2131 double dValue; | 2113 double dValue; |
| 2132 » CFX_WideString sFunction = params[0].operator CFX_WideString(); | 2114 » CFX_WideString sFunction = params[0].ToCFXWideString(); |
| 2133 if (wcscmp(sFunction, L"PRD") == 0) | 2115 if (wcscmp(sFunction, L"PRD") == 0) |
| 2134 dValue = 1.0; | 2116 dValue = 1.0; |
| 2135 else | 2117 else |
| 2136 dValue = 0.0; | 2118 dValue = 0.0; |
| 2137 | 2119 |
| 2138 CJS_Array FieldNameArray = AF_MakeArrayFromList(isolate,params1); | 2120 CJS_Array FieldNameArray = AF_MakeArrayFromList(isolate,params1); |
| 2139 | 2121 |
| 2140 int nFieldsCount = 0; | 2122 int nFieldsCount = 0; |
| 2141 | 2123 |
| 2142 for (int i=0,isz=FieldNameArray.GetLength(); i<isz; i++) | 2124 for (int i=0,isz=FieldNameArray.GetLength(); i<isz; i++) |
| 2143 { | 2125 { |
| 2144 CJS_Value jsValue(isolate); | 2126 CJS_Value jsValue(isolate); |
| 2145 FieldNameArray.GetElement(i,jsValue); | 2127 FieldNameArray.GetElement(i,jsValue); |
| 2146 CFX_WideString wsFieldName = jsValue.operator CFX_WideString(); | 2128 » » CFX_WideString wsFieldName = jsValue.ToCFXWideString(); |
| 2147 | 2129 |
| 2148 for (int j=0,jsz=pInterForm->CountFields(wsFieldName); j<jsz; j++) | 2130 for (int j=0,jsz=pInterForm->CountFields(wsFieldName); j<jsz; j++) |
| 2149 { | 2131 { |
| 2150 if (CPDF_FormField* pFormField = pInterForm->GetField(j,
wsFieldName)) | 2132 if (CPDF_FormField* pFormField = pInterForm->GetField(j,
wsFieldName)) |
| 2151 { | 2133 { |
| 2152 double dTemp = 0.0; | 2134 double dTemp = 0.0; |
| 2153 | 2135 |
| 2154 switch (pFormField->GetFieldType()) | 2136 switch (pFormField->GetFieldType()) |
| 2155 { | 2137 { |
| 2156 case FIELDTYPE_TEXTFIELD: | 2138 case FIELDTYPE_TEXTFIELD: |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2207 } | 2189 } |
| 2208 } | 2190 } |
| 2209 } | 2191 } |
| 2210 | 2192 |
| 2211 if (wcscmp(sFunction, L"AVG") == 0 && nFieldsCount > 0) | 2193 if (wcscmp(sFunction, L"AVG") == 0 && nFieldsCount > 0) |
| 2212 dValue /= nFieldsCount; | 2194 dValue /= nFieldsCount; |
| 2213 | 2195 |
| 2214 dValue = (double)floor(dValue * FXSYS_pow((double)10,(double)6) + 0.49)
/ FXSYS_pow((double)10,(double)6); | 2196 dValue = (double)floor(dValue * FXSYS_pow((double)10,(double)6) + 0.49)
/ FXSYS_pow((double)10,(double)6); |
| 2215 CJS_Value jsValue(isolate,dValue); | 2197 CJS_Value jsValue(isolate,dValue); |
| 2216 if((CJS_EventHandler*)pContext->GetEventHandler()->m_pValue) | 2198 if((CJS_EventHandler*)pContext->GetEventHandler()->m_pValue) |
| 2217 » » ((CJS_EventHandler*)pContext->GetEventHandler())->Value() = jsVa
lue; | 2199 » » ((CJS_EventHandler*)pContext->GetEventHandler())->Value() = jsVa
lue.ToCFXWideString(); |
| 2218 | 2200 |
| 2219 return TRUE; | 2201 return TRUE; |
| 2220 } | 2202 } |
| 2221 | 2203 |
| 2222 /* This function validates the current event to ensure that its value is | 2204 /* This function validates the current event to ensure that its value is |
| 2223 ** within the specified range. */ | 2205 ** within the specified range. */ |
| 2224 | 2206 |
| 2225 FX_BOOL CJS_PublicMethods::AFRange_Validate(IFXJS_Context* cc, const CJS_Paramet
ers& params, CJS_Value& vRet, CFX_WideString& sError) | 2207 FX_BOOL CJS_PublicMethods::AFRange_Validate(IFXJS_Context* cc, const CJS_Paramet
ers& params, CJS_Value& vRet, CFX_WideString& sError) |
| 2226 { | 2208 { |
| 2227 CJS_Context* pContext = (CJS_Context *)cc; | 2209 CJS_Context* pContext = (CJS_Context *)cc; |
| 2228 ASSERT(pContext != NULL); | 2210 ASSERT(pContext != NULL); |
| 2229 CJS_EventHandler* pEvent = pContext->GetEventHandler(); | 2211 CJS_EventHandler* pEvent = pContext->GetEventHandler(); |
| 2230 ASSERT(pEvent != NULL); | 2212 ASSERT(pEvent != NULL); |
| 2231 | 2213 |
| 2232 if (params.size() != 4) | 2214 if (params.size() != 4) |
| 2233 { | 2215 { |
| 2234 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); | 2216 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); |
| 2235 return FALSE; | 2217 return FALSE; |
| 2236 } | 2218 } |
| 2237 | 2219 |
| 2238 if(!pEvent->m_pValue) | 2220 if(!pEvent->m_pValue) |
| 2239 return FALSE; | 2221 return FALSE; |
| 2240 if (pEvent->Value().IsEmpty() ) | 2222 if (pEvent->Value().IsEmpty() ) |
| 2241 return TRUE; | 2223 return TRUE; |
| 2242 double dEentValue = atof(CFX_ByteString::FromUnicode(pEvent->Value())); | 2224 double dEentValue = atof(CFX_ByteString::FromUnicode(pEvent->Value())); |
| 2243 » FX_BOOL bGreaterThan, bLessThan; | 2225 » FX_BOOL bGreaterThan = params[0].ToBool(); |
| 2244 » double dGreaterThan, dLessThan; | 2226 » double dGreaterThan = params[1].ToDouble(); |
| 2245 bGreaterThan = (FX_BOOL)params[0]; | 2227 » FX_BOOL bLessThan = params[2].ToBool(); |
| 2228 » double dLessThan = params[3].ToDouble(); |
| 2246 CFX_WideString swMsg; | 2229 CFX_WideString swMsg; |
| 2247 dGreaterThan = (double)params[1]; | |
| 2248 bLessThan = (FX_BOOL)params[2]; | |
| 2249 dLessThan = (double)params[3]; | |
| 2250 | 2230 |
| 2251 if (bGreaterThan && bLessThan) | 2231 if (bGreaterThan && bLessThan) |
| 2252 { | 2232 { |
| 2253 if (dEentValue < dGreaterThan || dEentValue > dLessThan) | 2233 if (dEentValue < dGreaterThan || dEentValue > dLessThan) |
| 2254 » » » swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSRA
NGE1),(FX_LPCWSTR)params[1].operator CFX_WideString(), (FX_LPCWSTR)params[3].ope
rator CFX_WideString()); | 2234 » » » swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSRA
NGE1), |
| 2235 » » » » » » params[1].ToCFXWideString().c_s
tr(), |
| 2236 » » » » » » params[3].ToCFXWideString().c_s
tr()); |
| 2255 } | 2237 } |
| 2256 else if (bGreaterThan) | 2238 else if (bGreaterThan) |
| 2257 { | 2239 { |
| 2258 if (dEentValue < dGreaterThan) | 2240 if (dEentValue < dGreaterThan) |
| 2259 » » » swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSRA
NGE2), (FX_LPCWSTR)params[1].operator CFX_WideString()); | 2241 » » » swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSRA
NGE2), |
| 2242 » » » » » » params[1].ToCFXWideString().c_s
tr()); |
| 2260 } | 2243 } |
| 2261 else if (bLessThan) | 2244 else if (bLessThan) |
| 2262 { | 2245 { |
| 2263 if (dEentValue > dLessThan) | 2246 if (dEentValue > dLessThan) |
| 2264 » » » swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSRA
NGE3), (FX_LPCWSTR)params[3].operator CFX_WideString()); | 2247 » » » swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSRA
NGE3), |
| 2248 » » » » » » params[3].ToCFXWideString().c_s
tr()); |
| 2265 } | 2249 } |
| 2266 | 2250 |
| 2267 if (!swMsg.IsEmpty()) | 2251 if (!swMsg.IsEmpty()) |
| 2268 { | 2252 { |
| 2269 Alert(pContext, swMsg); | 2253 Alert(pContext, swMsg); |
| 2270 pEvent->Rc() = FALSE; | 2254 pEvent->Rc() = FALSE; |
| 2271 } | 2255 } |
| 2272 return TRUE; | 2256 return TRUE; |
| 2273 } | 2257 } |
| 2274 | 2258 |
| 2275 FX_BOOL CJS_PublicMethods::AFExtractNums(IFXJS_Context* cc, const CJS_Parameters
& params, CJS_Value& vRet, CFX_WideString& sError) | 2259 FX_BOOL CJS_PublicMethods::AFExtractNums(IFXJS_Context* cc, const CJS_Parameters
& params, CJS_Value& vRet, CFX_WideString& sError) |
| 2276 { | 2260 { |
| 2277 v8::Isolate* isolate = ::GetIsolate(cc); | 2261 v8::Isolate* isolate = ::GetIsolate(cc); |
| 2278 CJS_Context* pContext = (CJS_Context*)cc; | 2262 CJS_Context* pContext = (CJS_Context*)cc; |
| 2279 ASSERT(pContext != NULL); | 2263 ASSERT(pContext != NULL); |
| 2280 | 2264 |
| 2281 if (params.size() != 1) | 2265 if (params.size() != 1) |
| 2282 { | 2266 { |
| 2283 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); | 2267 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); |
| 2284 return FALSE; | 2268 return FALSE; |
| 2285 } | 2269 } |
| 2286 | 2270 |
| 2287 CJS_Array nums(isolate); | 2271 CJS_Array nums(isolate); |
| 2288 | 2272 |
| 2289 » CFX_WideString str = params[0].operator CFX_WideString(); | 2273 » CFX_WideString str = params[0].ToCFXWideString(); |
| 2290 CFX_WideString sPart; | 2274 CFX_WideString sPart; |
| 2291 | 2275 |
| 2292 if (str.GetAt(0) == L'.' || str.GetAt(0) == L',') | 2276 if (str.GetAt(0) == L'.' || str.GetAt(0) == L',') |
| 2293 str = L"0" + str; | 2277 str = L"0" + str; |
| 2294 | 2278 |
| 2295 int nIndex = 0; | 2279 int nIndex = 0; |
| 2296 for (int i=0, sz=str.GetLength(); i<sz; i++) | 2280 for (int i=0, sz=str.GetLength(); i<sz; i++) |
| 2297 { | 2281 { |
| 2298 FX_WCHAR wc = str.GetAt(i); | 2282 FX_WCHAR wc = str.GetAt(i); |
| 2299 if (IsDigit((wchar_t)wc)) | 2283 if (IsDigit((wchar_t)wc)) |
| (...skipping 16 matching lines...) Expand all Loading... |
| 2316 nums.SetElement(nIndex,CJS_Value(isolate,sPart.c_str())); | 2300 nums.SetElement(nIndex,CJS_Value(isolate,sPart.c_str())); |
| 2317 } | 2301 } |
| 2318 | 2302 |
| 2319 if (nums.GetLength() > 0) | 2303 if (nums.GetLength() > 0) |
| 2320 vRet = nums; | 2304 vRet = nums; |
| 2321 else | 2305 else |
| 2322 vRet.SetNull(); | 2306 vRet.SetNull(); |
| 2323 | 2307 |
| 2324 return TRUE; | 2308 return TRUE; |
| 2325 } | 2309 } |
| OLD | NEW |