Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(122)

Side by Side Diff: fpdfsdk/src/javascript/PublicMethods.cpp

Issue 1437863005: Merge to XFA: Replace CJS_Parameters with std::vector<CJS_Value>. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « fpdfsdk/src/javascript/PublicMethods.h ('k') | fpdfsdk/src/javascript/app.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "PublicMethods.h" 7 #include "PublicMethods.h"
8 8
9 #include "../../include/fsdk_mgr.h" // For CPDFDoc_Environment. 9 #include "../../include/fsdk_mgr.h" // For CPDFDoc_Environment.
10 #include "../../include/javascript/IJavaScript.h" 10 #include "../../include/javascript/IJavaScript.h"
(...skipping 885 matching lines...) Expand 10 before | Expand all | Expand 10 after
896 } 896 }
897 897
898 return sRet; 898 return sRet;
899 } 899 }
900 900
901 /* -------------------------------------------------------------------------- */ 901 /* -------------------------------------------------------------------------- */
902 902
903 // function AFNumber_Format(nDec, sepStyle, negStyle, currStyle, strCurrency, 903 // function AFNumber_Format(nDec, sepStyle, negStyle, currStyle, strCurrency,
904 // bCurrencyPrepend) 904 // bCurrencyPrepend)
905 FX_BOOL CJS_PublicMethods::AFNumber_Format(IJS_Context* cc, 905 FX_BOOL CJS_PublicMethods::AFNumber_Format(IJS_Context* cc,
906 const CJS_Parameters& params, 906 const std::vector<CJS_Value>& params,
907 CJS_Value& vRet, 907 CJS_Value& vRet,
908 CFX_WideString& sError) { 908 CFX_WideString& sError) {
909 #if _FX_OS_ != _FX_ANDROID_ 909 #if _FX_OS_ != _FX_ANDROID_
910 CJS_Context* pContext = (CJS_Context*)cc; 910 CJS_Context* pContext = (CJS_Context*)cc;
911 if (params.size() != 6) { 911 if (params.size() != 6) {
912 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); 912 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
913 return FALSE; 913 return FALSE;
914 } 914 }
915 915
916 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); 916 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
1074 } 1074 }
1075 } 1075 }
1076 } 1076 }
1077 Value = strValue2.c_str(); 1077 Value = strValue2.c_str();
1078 #endif 1078 #endif
1079 return TRUE; 1079 return TRUE;
1080 } 1080 }
1081 1081
1082 // function AFNumber_Keystroke(nDec, sepStyle, negStyle, currStyle, strCurrency, 1082 // function AFNumber_Keystroke(nDec, sepStyle, negStyle, currStyle, strCurrency,
1083 // bCurrencyPrepend) 1083 // bCurrencyPrepend)
1084 FX_BOOL CJS_PublicMethods::AFNumber_Keystroke(IJS_Context* cc, 1084 FX_BOOL CJS_PublicMethods::AFNumber_Keystroke(
1085 const CJS_Parameters& params, 1085 IJS_Context* cc,
1086 CJS_Value& vRet, 1086 const std::vector<CJS_Value>& params,
1087 CFX_WideString& sError) { 1087 CJS_Value& vRet,
1088 CFX_WideString& sError) {
1088 CJS_Context* pContext = (CJS_Context*)cc; 1089 CJS_Context* pContext = (CJS_Context*)cc;
1089 ASSERT(pContext != NULL); 1090 ASSERT(pContext != NULL);
1090 CJS_EventHandler* pEvent = pContext->GetEventHandler(); 1091 CJS_EventHandler* pEvent = pContext->GetEventHandler();
1091 ASSERT(pEvent != NULL); 1092 ASSERT(pEvent != NULL);
1092 1093
1093 if (params.size() < 2) 1094 if (params.size() < 2)
1094 return FALSE; 1095 return FALSE;
1095 int iSepStyle = params[1].ToInt(); 1096 int iSepStyle = params[1].ToInt();
1096 1097
1097 if (iSepStyle < 0 || iSepStyle > 3) 1098 if (iSepStyle < 0 || iSepStyle > 3)
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
1193 std::wstring w_postfix; 1194 std::wstring w_postfix;
1194 if (pEvent->SelEnd() < (int)w_strValue2.length()) 1195 if (pEvent->SelEnd() < (int)w_strValue2.length())
1195 w_postfix = w_strValue2.substr(pEvent->SelEnd()); 1196 w_postfix = w_strValue2.substr(pEvent->SelEnd());
1196 w_strValue2 = w_prefix + w_strChange2 + w_postfix; 1197 w_strValue2 = w_prefix + w_strChange2 + w_postfix;
1197 w_strValue = w_strValue2.c_str(); 1198 w_strValue = w_strValue2.c_str();
1198 val = w_strValue; 1199 val = w_strValue;
1199 return TRUE; 1200 return TRUE;
1200 } 1201 }
1201 1202
1202 // function AFPercent_Format(nDec, sepStyle) 1203 // function AFPercent_Format(nDec, sepStyle)
1203 FX_BOOL CJS_PublicMethods::AFPercent_Format(IJS_Context* cc, 1204 FX_BOOL CJS_PublicMethods::AFPercent_Format(
1204 const CJS_Parameters& params, 1205 IJS_Context* cc,
1205 CJS_Value& vRet, 1206 const std::vector<CJS_Value>& params,
1206 CFX_WideString& sError) { 1207 CJS_Value& vRet,
1208 CFX_WideString& sError) {
1207 #if _FX_OS_ != _FX_ANDROID_ 1209 #if _FX_OS_ != _FX_ANDROID_
1208 CJS_Context* pContext = (CJS_Context*)cc; 1210 CJS_Context* pContext = (CJS_Context*)cc;
1209 ASSERT(pContext != NULL); 1211 ASSERT(pContext != NULL);
1210 CJS_EventHandler* pEvent = pContext->GetEventHandler(); 1212 CJS_EventHandler* pEvent = pContext->GetEventHandler();
1211 ASSERT(pEvent != NULL); 1213 ASSERT(pEvent != NULL);
1212 1214
1213 if (params.size() != 2) { 1215 if (params.size() != 2) {
1214 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); 1216 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
1215 return FALSE; 1217 return FALSE;
1216 } 1218 }
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
1287 //////////////////////////////////////////////////////////////////// 1289 ////////////////////////////////////////////////////////////////////
1288 // negative mark 1290 // negative mark
1289 if (iNegative) 1291 if (iNegative)
1290 strValue = "-" + strValue; 1292 strValue = "-" + strValue;
1291 strValue += "%"; 1293 strValue += "%";
1292 Value = CFX_WideString::FromLocal(strValue); 1294 Value = CFX_WideString::FromLocal(strValue);
1293 #endif 1295 #endif
1294 return TRUE; 1296 return TRUE;
1295 } 1297 }
1296 // AFPercent_Keystroke(nDec, sepStyle) 1298 // AFPercent_Keystroke(nDec, sepStyle)
1297 FX_BOOL CJS_PublicMethods::AFPercent_Keystroke(IJS_Context* cc, 1299 FX_BOOL CJS_PublicMethods::AFPercent_Keystroke(
1298 const CJS_Parameters& params, 1300 IJS_Context* cc,
1299 CJS_Value& vRet, 1301 const std::vector<CJS_Value>& params,
1300 CFX_WideString& sError) { 1302 CJS_Value& vRet,
1303 CFX_WideString& sError) {
1301 return AFNumber_Keystroke(cc, params, vRet, sError); 1304 return AFNumber_Keystroke(cc, params, vRet, sError);
1302 } 1305 }
1303 1306
1304 // function AFDate_FormatEx(cFormat) 1307 // function AFDate_FormatEx(cFormat)
1305 FX_BOOL CJS_PublicMethods::AFDate_FormatEx(IJS_Context* cc, 1308 FX_BOOL CJS_PublicMethods::AFDate_FormatEx(IJS_Context* cc,
1306 const CJS_Parameters& params, 1309 const std::vector<CJS_Value>& params,
1307 CJS_Value& vRet, 1310 CJS_Value& vRet,
1308 CFX_WideString& sError) { 1311 CFX_WideString& sError) {
1309 CJS_Context* pContext = (CJS_Context*)cc; 1312 CJS_Context* pContext = (CJS_Context*)cc;
1310 ASSERT(pContext != NULL); 1313 ASSERT(pContext != NULL);
1311 CJS_EventHandler* pEvent = pContext->GetEventHandler(); 1314 CJS_EventHandler* pEvent = pContext->GetEventHandler();
1312 ASSERT(pEvent != NULL); 1315 ASSERT(pEvent != NULL);
1313 1316
1314 if (params.size() != 1) { 1317 if (params.size() != 1) {
1315 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); 1318 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
1316 return FALSE; 1319 return FALSE;
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
1411 JS_MakeTime(nHour, nMin, nSec, 0)); 1414 JS_MakeTime(nHour, nMin, nSec, 0));
1412 1415
1413 if (JS_PortIsNan(dRet)) { 1416 if (JS_PortIsNan(dRet)) {
1414 dRet = JS_DateParse(strValue.c_str()); 1417 dRet = JS_DateParse(strValue.c_str());
1415 } 1418 }
1416 1419
1417 return dRet; 1420 return dRet;
1418 } 1421 }
1419 1422
1420 // AFDate_KeystrokeEx(cFormat) 1423 // AFDate_KeystrokeEx(cFormat)
1421 FX_BOOL CJS_PublicMethods::AFDate_KeystrokeEx(IJS_Context* cc, 1424 FX_BOOL CJS_PublicMethods::AFDate_KeystrokeEx(
1422 const CJS_Parameters& params, 1425 IJS_Context* cc,
1423 CJS_Value& vRet, 1426 const std::vector<CJS_Value>& params,
1424 CFX_WideString& sError) { 1427 CJS_Value& vRet,
1428 CFX_WideString& sError) {
1425 CJS_Context* pContext = (CJS_Context*)cc; 1429 CJS_Context* pContext = (CJS_Context*)cc;
1426 ASSERT(pContext != NULL); 1430 ASSERT(pContext != NULL);
1427 CJS_EventHandler* pEvent = pContext->GetEventHandler(); 1431 CJS_EventHandler* pEvent = pContext->GetEventHandler();
1428 ASSERT(pEvent != NULL); 1432 ASSERT(pEvent != NULL);
1429 1433
1430 if (params.size() != 1) { 1434 if (params.size() != 1) {
1431 sError = L"AFDate_KeystrokeEx's parameters' size r not correct"; 1435 sError = L"AFDate_KeystrokeEx's parameters' size r not correct";
1432 return FALSE; 1436 return FALSE;
1433 } 1437 }
1434 1438
(...skipping 13 matching lines...) Expand all
1448 sFormat.c_str()); 1452 sFormat.c_str());
1449 Alert(pContext, swMsg.c_str()); 1453 Alert(pContext, swMsg.c_str());
1450 pEvent->Rc() = FALSE; 1454 pEvent->Rc() = FALSE;
1451 return TRUE; 1455 return TRUE;
1452 } 1456 }
1453 } 1457 }
1454 return TRUE; 1458 return TRUE;
1455 } 1459 }
1456 1460
1457 FX_BOOL CJS_PublicMethods::AFDate_Format(IJS_Context* cc, 1461 FX_BOOL CJS_PublicMethods::AFDate_Format(IJS_Context* cc,
1458 const CJS_Parameters& params, 1462 const std::vector<CJS_Value>& params,
1459 CJS_Value& vRet, 1463 CJS_Value& vRet,
1460 CFX_WideString& sError) { 1464 CFX_WideString& sError) {
1461 CJS_Context* pContext = (CJS_Context*)cc; 1465 CJS_Context* pContext = (CJS_Context*)cc;
1462 if (params.size() != 1) { 1466 if (params.size() != 1) {
1463 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); 1467 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
1464 return FALSE; 1468 return FALSE;
1465 } 1469 }
1466 1470
1467 int iIndex = params[0].ToInt(); 1471 int iIndex = params[0].ToInt();
1468 const FX_WCHAR* cFormats[] = {L"m/d", 1472 const FX_WCHAR* cFormats[] = {L"m/d",
1469 L"m/d/yy", 1473 L"m/d/yy",
1470 L"mm/dd/yy", 1474 L"mm/dd/yy",
1471 L"mm/yy", 1475 L"mm/yy",
1472 L"d-mmm", 1476 L"d-mmm",
1473 L"d-mmm-yy", 1477 L"d-mmm-yy",
1474 L"dd-mmm-yy", 1478 L"dd-mmm-yy",
1475 L"yy-mm-dd", 1479 L"yy-mm-dd",
1476 L"mmm-yy", 1480 L"mmm-yy",
1477 L"mmmm-yy", 1481 L"mmmm-yy",
1478 L"mmm d, yyyy", 1482 L"mmm d, yyyy",
1479 L"mmmm d, yyyy", 1483 L"mmmm d, yyyy",
1480 L"m/d/yy h:MM tt", 1484 L"m/d/yy h:MM tt",
1481 L"m/d/yy HH:MM"}; 1485 L"m/d/yy HH:MM"};
1482 1486
1483 if (iIndex < 0 || (static_cast<size_t>(iIndex) >= FX_ArraySize(cFormats))) 1487 if (iIndex < 0 || (static_cast<size_t>(iIndex) >= FX_ArraySize(cFormats)))
1484 iIndex = 0; 1488 iIndex = 0;
1485 1489
1486 CJS_Parameters newParams; 1490 std::vector<CJS_Value> newParams;
1487 newParams.push_back( 1491 newParams.push_back(
1488 CJS_Value(CJS_Runtime::FromContext(cc), cFormats[iIndex])); 1492 CJS_Value(CJS_Runtime::FromContext(cc), cFormats[iIndex]));
1489 return AFDate_FormatEx(cc, newParams, vRet, sError); 1493 return AFDate_FormatEx(cc, newParams, vRet, sError);
1490 } 1494 }
1491 1495
1492 // AFDate_KeystrokeEx(cFormat) 1496 // AFDate_KeystrokeEx(cFormat)
1493 FX_BOOL CJS_PublicMethods::AFDate_Keystroke(IJS_Context* cc, 1497 FX_BOOL CJS_PublicMethods::AFDate_Keystroke(
1494 const CJS_Parameters& params, 1498 IJS_Context* cc,
1495 CJS_Value& vRet, 1499 const std::vector<CJS_Value>& params,
1496 CFX_WideString& sError) { 1500 CJS_Value& vRet,
1501 CFX_WideString& sError) {
1497 CJS_Context* pContext = (CJS_Context*)cc; 1502 CJS_Context* pContext = (CJS_Context*)cc;
1498 if (params.size() != 1) { 1503 if (params.size() != 1) {
1499 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); 1504 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
1500 return FALSE; 1505 return FALSE;
1501 } 1506 }
1502 1507
1503 int iIndex = params[0].ToInt(); 1508 int iIndex = params[0].ToInt();
1504 const FX_WCHAR* cFormats[] = {L"m/d", 1509 const FX_WCHAR* cFormats[] = {L"m/d",
1505 L"m/d/yy", 1510 L"m/d/yy",
1506 L"mm/dd/yy", 1511 L"mm/dd/yy",
1507 L"mm/yy", 1512 L"mm/yy",
1508 L"d-mmm", 1513 L"d-mmm",
1509 L"d-mmm-yy", 1514 L"d-mmm-yy",
1510 L"dd-mmm-yy", 1515 L"dd-mmm-yy",
1511 L"yy-mm-dd", 1516 L"yy-mm-dd",
1512 L"mmm-yy", 1517 L"mmm-yy",
1513 L"mmmm-yy", 1518 L"mmmm-yy",
1514 L"mmm d, yyyy", 1519 L"mmm d, yyyy",
1515 L"mmmm d, yyyy", 1520 L"mmmm d, yyyy",
1516 L"m/d/yy h:MM tt", 1521 L"m/d/yy h:MM tt",
1517 L"m/d/yy HH:MM"}; 1522 L"m/d/yy HH:MM"};
1518 1523
1519 if (iIndex < 0 || (static_cast<size_t>(iIndex) >= FX_ArraySize(cFormats))) 1524 if (iIndex < 0 || (static_cast<size_t>(iIndex) >= FX_ArraySize(cFormats)))
1520 iIndex = 0; 1525 iIndex = 0;
1521 1526
1522 CJS_Parameters newParams; 1527 std::vector<CJS_Value> newParams;
1523 newParams.push_back( 1528 newParams.push_back(
1524 CJS_Value(CJS_Runtime::FromContext(cc), cFormats[iIndex])); 1529 CJS_Value(CJS_Runtime::FromContext(cc), cFormats[iIndex]));
1525 return AFDate_KeystrokeEx(cc, newParams, vRet, sError); 1530 return AFDate_KeystrokeEx(cc, newParams, vRet, sError);
1526 } 1531 }
1527 1532
1528 // function AFTime_Format(ptf) 1533 // function AFTime_Format(ptf)
1529 FX_BOOL CJS_PublicMethods::AFTime_Format(IJS_Context* cc, 1534 FX_BOOL CJS_PublicMethods::AFTime_Format(IJS_Context* cc,
1530 const CJS_Parameters& params, 1535 const std::vector<CJS_Value>& params,
1531 CJS_Value& vRet, 1536 CJS_Value& vRet,
1532 CFX_WideString& sError) { 1537 CFX_WideString& sError) {
1533 CJS_Context* pContext = (CJS_Context*)cc; 1538 CJS_Context* pContext = (CJS_Context*)cc;
1534 if (params.size() != 1) { 1539 if (params.size() != 1) {
1535 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); 1540 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
1536 return FALSE; 1541 return FALSE;
1537 } 1542 }
1538 1543
1539 int iIndex = params[0].ToInt(); 1544 int iIndex = params[0].ToInt();
1540 const FX_WCHAR* cFormats[] = {L"HH:MM", L"h:MM tt", L"HH:MM:ss", 1545 const FX_WCHAR* cFormats[] = {L"HH:MM", L"h:MM tt", L"HH:MM:ss",
1541 L"h:MM:ss tt"}; 1546 L"h:MM:ss tt"};
1542 1547
1543 if (iIndex < 0 || (static_cast<size_t>(iIndex) >= FX_ArraySize(cFormats))) 1548 if (iIndex < 0 || (static_cast<size_t>(iIndex) >= FX_ArraySize(cFormats)))
1544 iIndex = 0; 1549 iIndex = 0;
1545 1550
1546 CJS_Parameters newParams; 1551 std::vector<CJS_Value> newParams;
1547 newParams.push_back( 1552 newParams.push_back(
1548 CJS_Value(CJS_Runtime::FromContext(cc), cFormats[iIndex])); 1553 CJS_Value(CJS_Runtime::FromContext(cc), cFormats[iIndex]));
1549 return AFDate_FormatEx(cc, newParams, vRet, sError); 1554 return AFDate_FormatEx(cc, newParams, vRet, sError);
1550 } 1555 }
1551 1556
1552 FX_BOOL CJS_PublicMethods::AFTime_Keystroke(IJS_Context* cc, 1557 FX_BOOL CJS_PublicMethods::AFTime_Keystroke(
1553 const CJS_Parameters& params, 1558 IJS_Context* cc,
1554 CJS_Value& vRet, 1559 const std::vector<CJS_Value>& params,
1555 CFX_WideString& sError) { 1560 CJS_Value& vRet,
1561 CFX_WideString& sError) {
1556 CJS_Context* pContext = (CJS_Context*)cc; 1562 CJS_Context* pContext = (CJS_Context*)cc;
1557 if (params.size() != 1) { 1563 if (params.size() != 1) {
1558 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); 1564 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
1559 return FALSE; 1565 return FALSE;
1560 } 1566 }
1561 1567
1562 int iIndex = params[0].ToInt(); 1568 int iIndex = params[0].ToInt();
1563 const FX_WCHAR* cFormats[] = {L"HH:MM", L"h:MM tt", L"HH:MM:ss", 1569 const FX_WCHAR* cFormats[] = {L"HH:MM", L"h:MM tt", L"HH:MM:ss",
1564 L"h:MM:ss tt"}; 1570 L"h:MM:ss tt"};
1565 1571
1566 if (iIndex < 0 || (static_cast<size_t>(iIndex) >= FX_ArraySize(cFormats))) 1572 if (iIndex < 0 || (static_cast<size_t>(iIndex) >= FX_ArraySize(cFormats)))
1567 iIndex = 0; 1573 iIndex = 0;
1568 1574
1569 CJS_Parameters newParams; 1575 std::vector<CJS_Value> newParams;
1570 newParams.push_back( 1576 newParams.push_back(
1571 CJS_Value(CJS_Runtime::FromContext(cc), cFormats[iIndex])); 1577 CJS_Value(CJS_Runtime::FromContext(cc), cFormats[iIndex]));
1572 return AFDate_KeystrokeEx(cc, newParams, vRet, sError); 1578 return AFDate_KeystrokeEx(cc, newParams, vRet, sError);
1573 } 1579 }
1574 1580
1575 FX_BOOL CJS_PublicMethods::AFTime_FormatEx(IJS_Context* cc, 1581 FX_BOOL CJS_PublicMethods::AFTime_FormatEx(IJS_Context* cc,
1576 const CJS_Parameters& params, 1582 const std::vector<CJS_Value>& params,
1577 CJS_Value& vRet, 1583 CJS_Value& vRet,
1578 CFX_WideString& sError) { 1584 CFX_WideString& sError) {
1579 return AFDate_FormatEx(cc, params, vRet, sError); 1585 return AFDate_FormatEx(cc, params, vRet, sError);
1580 } 1586 }
1581 1587
1582 FX_BOOL CJS_PublicMethods::AFTime_KeystrokeEx(IJS_Context* cc, 1588 FX_BOOL CJS_PublicMethods::AFTime_KeystrokeEx(
1583 const CJS_Parameters& params, 1589 IJS_Context* cc,
1584 CJS_Value& vRet, 1590 const std::vector<CJS_Value>& params,
1585 CFX_WideString& sError) { 1591 CJS_Value& vRet,
1592 CFX_WideString& sError) {
1586 return AFDate_KeystrokeEx(cc, params, vRet, sError); 1593 return AFDate_KeystrokeEx(cc, params, vRet, sError);
1587 } 1594 }
1588 1595
1589 // function AFSpecial_Format(psf) 1596 // function AFSpecial_Format(psf)
1590 FX_BOOL CJS_PublicMethods::AFSpecial_Format(IJS_Context* cc, 1597 FX_BOOL CJS_PublicMethods::AFSpecial_Format(
1591 const CJS_Parameters& params, 1598 IJS_Context* cc,
1592 CJS_Value& vRet, 1599 const std::vector<CJS_Value>& params,
1593 CFX_WideString& sError) { 1600 CJS_Value& vRet,
1601 CFX_WideString& sError) {
1594 CJS_Context* pContext = (CJS_Context*)cc; 1602 CJS_Context* pContext = (CJS_Context*)cc;
1595 ASSERT(pContext != NULL); 1603 ASSERT(pContext != NULL);
1596 1604
1597 if (params.size() != 1) { 1605 if (params.size() != 1) {
1598 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); 1606 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
1599 return FALSE; 1607 return FALSE;
1600 } 1608 }
1601 1609
1602 std::string cFormat; 1610 std::string cFormat;
1603 int iIndex = params[0].ToInt(); 1611 int iIndex = params[0].ToInt();
(...skipping 27 matching lines...) Expand all
1631 break; 1639 break;
1632 } 1640 }
1633 1641
1634 std::string strDes; 1642 std::string strDes;
1635 util::printx(cFormat, strSrc, strDes); 1643 util::printx(cFormat, strSrc, strDes);
1636 Value = CFX_WideString::FromLocal(strDes.c_str()); 1644 Value = CFX_WideString::FromLocal(strDes.c_str());
1637 return TRUE; 1645 return TRUE;
1638 } 1646 }
1639 1647
1640 // function AFSpecial_KeystrokeEx(mask) 1648 // function AFSpecial_KeystrokeEx(mask)
1641 FX_BOOL CJS_PublicMethods::AFSpecial_KeystrokeEx(IJS_Context* cc, 1649 FX_BOOL CJS_PublicMethods::AFSpecial_KeystrokeEx(
1642 const CJS_Parameters& params, 1650 IJS_Context* cc,
1643 CJS_Value& vRet, 1651 const std::vector<CJS_Value>& params,
1644 CFX_WideString& sError) { 1652 CJS_Value& vRet,
1653 CFX_WideString& sError) {
1645 CJS_Context* pContext = (CJS_Context*)cc; 1654 CJS_Context* pContext = (CJS_Context*)cc;
1646 ASSERT(pContext != NULL); 1655 ASSERT(pContext != NULL);
1647 CJS_EventHandler* pEvent = pContext->GetEventHandler(); 1656 CJS_EventHandler* pEvent = pContext->GetEventHandler();
1648 1657
1649 ASSERT(pEvent != NULL); 1658 ASSERT(pEvent != NULL);
1650 1659
1651 if (params.size() < 1) { 1660 if (params.size() < 1) {
1652 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); 1661 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
1653 return FALSE; 1662 return FALSE;
1654 } 1663 }
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1724 return TRUE; 1733 return TRUE;
1725 } 1734 }
1726 iIndexMask++; 1735 iIndexMask++;
1727 } 1736 }
1728 1737
1729 wideChange = wChange.c_str(); 1738 wideChange = wChange.c_str();
1730 return TRUE; 1739 return TRUE;
1731 } 1740 }
1732 1741
1733 // function AFSpecial_Keystroke(psf) 1742 // function AFSpecial_Keystroke(psf)
1734 FX_BOOL CJS_PublicMethods::AFSpecial_Keystroke(IJS_Context* cc, 1743 FX_BOOL CJS_PublicMethods::AFSpecial_Keystroke(
1735 const CJS_Parameters& params, 1744 IJS_Context* cc,
1736 CJS_Value& vRet, 1745 const std::vector<CJS_Value>& params,
1737 CFX_WideString& sError) { 1746 CJS_Value& vRet,
1747 CFX_WideString& sError) {
1738 CJS_Context* pContext = (CJS_Context*)cc; 1748 CJS_Context* pContext = (CJS_Context*)cc;
1739 if (params.size() != 1) { 1749 if (params.size() != 1) {
1740 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); 1750 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
1741 return FALSE; 1751 return FALSE;
1742 } 1752 }
1743 1753
1744 CJS_EventHandler* pEvent = pContext->GetEventHandler(); 1754 CJS_EventHandler* pEvent = pContext->GetEventHandler();
1745 if (!pEvent->m_pValue) 1755 if (!pEvent->m_pValue)
1746 return FALSE; 1756 return FALSE;
1747 1757
(...skipping 21 matching lines...) Expand all
1769 // cFormat = "999-9999"; 1779 // cFormat = "999-9999";
1770 cFormat = "9999999"; 1780 cFormat = "9999999";
1771 break; 1781 break;
1772 } 1782 }
1773 case 3: 1783 case 3:
1774 // cFormat = "999-99-9999"; 1784 // cFormat = "999-99-9999";
1775 cFormat = "999999999"; 1785 cFormat = "999999999";
1776 break; 1786 break;
1777 } 1787 }
1778 1788
1779 CJS_Parameters params2; 1789 std::vector<CJS_Value> params2;
1780 params2.push_back(CJS_Value(CJS_Runtime::FromContext(cc), cFormat.c_str())); 1790 params2.push_back(CJS_Value(CJS_Runtime::FromContext(cc), cFormat.c_str()));
1781 return AFSpecial_KeystrokeEx(cc, params2, vRet, sError); 1791 return AFSpecial_KeystrokeEx(cc, params2, vRet, sError);
1782 } 1792 }
1783 1793
1784 FX_BOOL CJS_PublicMethods::AFMergeChange(IJS_Context* cc, 1794 FX_BOOL CJS_PublicMethods::AFMergeChange(IJS_Context* cc,
1785 const CJS_Parameters& params, 1795 const std::vector<CJS_Value>& params,
1786 CJS_Value& vRet, 1796 CJS_Value& vRet,
1787 CFX_WideString& sError) { 1797 CFX_WideString& sError) {
1788 CJS_Context* pContext = (CJS_Context*)cc; 1798 CJS_Context* pContext = (CJS_Context*)cc;
1789 ASSERT(pContext != NULL); 1799 ASSERT(pContext != NULL);
1790 CJS_EventHandler* pEventHandler = pContext->GetEventHandler(); 1800 CJS_EventHandler* pEventHandler = pContext->GetEventHandler();
1791 ASSERT(pEventHandler != NULL); 1801 ASSERT(pEventHandler != NULL);
1792 1802
1793 if (params.size() != 1) { 1803 if (params.size() != 1) {
1794 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); 1804 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
1795 return FALSE; 1805 return FALSE;
(...skipping 21 matching lines...) Expand all
1817 swValue.GetLength() - pEventHandler->SelEnd()); 1827 swValue.GetLength() - pEventHandler->SelEnd());
1818 else 1828 else
1819 postfix = L""; 1829 postfix = L"";
1820 1830
1821 vRet = (prefix + pEventHandler->Change() + postfix).c_str(); 1831 vRet = (prefix + pEventHandler->Change() + postfix).c_str();
1822 1832
1823 return TRUE; 1833 return TRUE;
1824 } 1834 }
1825 1835
1826 FX_BOOL CJS_PublicMethods::AFParseDateEx(IJS_Context* cc, 1836 FX_BOOL CJS_PublicMethods::AFParseDateEx(IJS_Context* cc,
1827 const CJS_Parameters& params, 1837 const std::vector<CJS_Value>& params,
1828 CJS_Value& vRet, 1838 CJS_Value& vRet,
1829 CFX_WideString& sError) { 1839 CFX_WideString& sError) {
1830 CJS_Context* pContext = (CJS_Context*)cc; 1840 CJS_Context* pContext = (CJS_Context*)cc;
1831 ASSERT(pContext != NULL); 1841 ASSERT(pContext != NULL);
1832 1842
1833 if (params.size() != 2) { 1843 if (params.size() != 2) {
1834 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); 1844 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
1835 return FALSE; 1845 return FALSE;
1836 } 1846 }
1837 1847
1838 CFX_WideString sValue = params[0].ToCFXWideString(); 1848 CFX_WideString sValue = params[0].ToCFXWideString();
1839 CFX_WideString sFormat = params[1].ToCFXWideString(); 1849 CFX_WideString sFormat = params[1].ToCFXWideString();
1840 1850
1841 FX_BOOL bWrongFormat = FALSE; 1851 FX_BOOL bWrongFormat = FALSE;
1842 double dDate = MakeRegularDate(sValue, sFormat, bWrongFormat); 1852 double dDate = MakeRegularDate(sValue, sFormat, bWrongFormat);
1843 1853
1844 if (JS_PortIsNan(dDate)) { 1854 if (JS_PortIsNan(dDate)) {
1845 CFX_WideString swMsg; 1855 CFX_WideString swMsg;
1846 swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSPARSEDATE).c_str(), 1856 swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSPARSEDATE).c_str(),
1847 sFormat.c_str()); 1857 sFormat.c_str());
1848 Alert((CJS_Context*)cc, swMsg.c_str()); 1858 Alert((CJS_Context*)cc, swMsg.c_str());
1849 return FALSE; 1859 return FALSE;
1850 } 1860 }
1851 1861
1852 vRet = dDate; 1862 vRet = dDate;
1853 return TRUE; 1863 return TRUE;
1854 } 1864 }
1855 1865
1856 FX_BOOL CJS_PublicMethods::AFSimple(IJS_Context* cc, 1866 FX_BOOL CJS_PublicMethods::AFSimple(IJS_Context* cc,
1857 const CJS_Parameters& params, 1867 const std::vector<CJS_Value>& params,
1858 CJS_Value& vRet, 1868 CJS_Value& vRet,
1859 CFX_WideString& sError) { 1869 CFX_WideString& sError) {
1860 if (params.size() != 3) { 1870 if (params.size() != 3) {
1861 CJS_Context* pContext = (CJS_Context*)cc; 1871 CJS_Context* pContext = (CJS_Context*)cc;
1862 ASSERT(pContext != NULL); 1872 ASSERT(pContext != NULL);
1863 1873
1864 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); 1874 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
1865 return FALSE; 1875 return FALSE;
1866 } 1876 }
1867 1877
1868 vRet = (double)AF_Simple(params[0].ToCFXWideString().c_str(), 1878 vRet = (double)AF_Simple(params[0].ToCFXWideString().c_str(),
1869 params[1].ToDouble(), params[2].ToDouble()); 1879 params[1].ToDouble(), params[2].ToDouble());
1870 return TRUE; 1880 return TRUE;
1871 } 1881 }
1872 1882
1873 FX_BOOL CJS_PublicMethods::AFMakeNumber(IJS_Context* cc, 1883 FX_BOOL CJS_PublicMethods::AFMakeNumber(IJS_Context* cc,
1874 const CJS_Parameters& params, 1884 const std::vector<CJS_Value>& params,
1875 CJS_Value& vRet, 1885 CJS_Value& vRet,
1876 CFX_WideString& sError) { 1886 CFX_WideString& sError) {
1877 if (params.size() != 1) { 1887 if (params.size() != 1) {
1878 CJS_Context* pContext = (CJS_Context*)cc; 1888 CJS_Context* pContext = (CJS_Context*)cc;
1879 ASSERT(pContext != NULL); 1889 ASSERT(pContext != NULL);
1880 1890
1881 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); 1891 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
1882 return FALSE; 1892 return FALSE;
1883 } 1893 }
1884 vRet = ParseStringToNumber(params[0].ToCFXWideString().c_str()); 1894 vRet = ParseStringToNumber(params[0].ToCFXWideString().c_str());
1885 return TRUE; 1895 return TRUE;
1886 } 1896 }
1887 1897
1888 FX_BOOL CJS_PublicMethods::AFSimple_Calculate(IJS_Context* cc, 1898 FX_BOOL CJS_PublicMethods::AFSimple_Calculate(
1889 const CJS_Parameters& params, 1899 IJS_Context* cc,
1890 CJS_Value& vRet, 1900 const std::vector<CJS_Value>& params,
1891 CFX_WideString& sError) { 1901 CJS_Value& vRet,
1902 CFX_WideString& sError) {
1892 CJS_Context* pContext = (CJS_Context*)cc; 1903 CJS_Context* pContext = (CJS_Context*)cc;
1893 if (params.size() != 2) { 1904 if (params.size() != 2) {
1894 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); 1905 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
1895 return FALSE; 1906 return FALSE;
1896 } 1907 }
1897 1908
1898 CJS_Value params1 = params[1]; 1909 CJS_Value params1 = params[1];
1899 if (!params1.IsArrayObject() && params1.GetType() != CJS_Value::VT_string) { 1910 if (!params1.IsArrayObject() && params1.GetType() != CJS_Value::VT_string) {
1900 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); 1911 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
1901 return FALSE; 1912 return FALSE;
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
1978 CJS_Value jsValue(pRuntime, dValue); 1989 CJS_Value jsValue(pRuntime, dValue);
1979 if (pContext->GetEventHandler()->m_pValue) 1990 if (pContext->GetEventHandler()->m_pValue)
1980 pContext->GetEventHandler()->Value() = jsValue.ToCFXWideString(); 1991 pContext->GetEventHandler()->Value() = jsValue.ToCFXWideString();
1981 1992
1982 return TRUE; 1993 return TRUE;
1983 } 1994 }
1984 1995
1985 /* This function validates the current event to ensure that its value is 1996 /* This function validates the current event to ensure that its value is
1986 ** within the specified range. */ 1997 ** within the specified range. */
1987 1998
1988 FX_BOOL CJS_PublicMethods::AFRange_Validate(IJS_Context* cc, 1999 FX_BOOL CJS_PublicMethods::AFRange_Validate(
1989 const CJS_Parameters& params, 2000 IJS_Context* cc,
1990 CJS_Value& vRet, 2001 const std::vector<CJS_Value>& params,
1991 CFX_WideString& sError) { 2002 CJS_Value& vRet,
2003 CFX_WideString& sError) {
1992 CJS_Context* pContext = (CJS_Context*)cc; 2004 CJS_Context* pContext = (CJS_Context*)cc;
1993 ASSERT(pContext != NULL); 2005 ASSERT(pContext != NULL);
1994 CJS_EventHandler* pEvent = pContext->GetEventHandler(); 2006 CJS_EventHandler* pEvent = pContext->GetEventHandler();
1995 ASSERT(pEvent != NULL); 2007 ASSERT(pEvent != NULL);
1996 2008
1997 if (params.size() != 4) { 2009 if (params.size() != 4) {
1998 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); 2010 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
1999 return FALSE; 2011 return FALSE;
2000 } 2012 }
2001 2013
(...skipping 24 matching lines...) Expand all
2026 } 2038 }
2027 2039
2028 if (!swMsg.IsEmpty()) { 2040 if (!swMsg.IsEmpty()) {
2029 Alert(pContext, swMsg.c_str()); 2041 Alert(pContext, swMsg.c_str());
2030 pEvent->Rc() = FALSE; 2042 pEvent->Rc() = FALSE;
2031 } 2043 }
2032 return TRUE; 2044 return TRUE;
2033 } 2045 }
2034 2046
2035 FX_BOOL CJS_PublicMethods::AFExtractNums(IJS_Context* cc, 2047 FX_BOOL CJS_PublicMethods::AFExtractNums(IJS_Context* cc,
2036 const CJS_Parameters& params, 2048 const std::vector<CJS_Value>& params,
2037 CJS_Value& vRet, 2049 CJS_Value& vRet,
2038 CFX_WideString& sError) { 2050 CFX_WideString& sError) {
2039 CJS_Context* pContext = (CJS_Context*)cc; 2051 CJS_Context* pContext = (CJS_Context*)cc;
2040 if (params.size() != 1) { 2052 if (params.size() != 1) {
2041 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); 2053 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
2042 return FALSE; 2054 return FALSE;
2043 } 2055 }
2044 2056
2045 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); 2057 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
2046 CJS_Array nums(pRuntime); 2058 CJS_Array nums(pRuntime);
(...skipping 22 matching lines...) Expand all
2069 nums.SetElement(nIndex, CJS_Value(pRuntime, sPart.c_str())); 2081 nums.SetElement(nIndex, CJS_Value(pRuntime, sPart.c_str()));
2070 } 2082 }
2071 2083
2072 if (nums.GetLength() > 0) 2084 if (nums.GetLength() > 0)
2073 vRet = nums; 2085 vRet = nums;
2074 else 2086 else
2075 vRet.SetNull(); 2087 vRet.SetNull();
2076 2088
2077 return TRUE; 2089 return TRUE;
2078 } 2090 }
OLDNEW
« no previous file with comments | « fpdfsdk/src/javascript/PublicMethods.h ('k') | fpdfsdk/src/javascript/app.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698