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

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

Issue 1437713003: Replace CJS_Parameters with std::vector<CJS_Value>. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@todo
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 893 matching lines...) Expand 10 before | Expand all | Expand 10 after
904 } 904 }
905 905
906 return sRet; 906 return sRet;
907 } 907 }
908 908
909 /* -------------------------------------------------------------------------- */ 909 /* -------------------------------------------------------------------------- */
910 910
911 // function AFNumber_Format(nDec, sepStyle, negStyle, currStyle, strCurrency, 911 // function AFNumber_Format(nDec, sepStyle, negStyle, currStyle, strCurrency,
912 // bCurrencyPrepend) 912 // bCurrencyPrepend)
913 FX_BOOL CJS_PublicMethods::AFNumber_Format(IJS_Context* cc, 913 FX_BOOL CJS_PublicMethods::AFNumber_Format(IJS_Context* cc,
914 const CJS_Parameters& params, 914 const std::vector<CJS_Value>& params,
915 CJS_Value& vRet, 915 CJS_Value& vRet,
916 CFX_WideString& sError) { 916 CFX_WideString& sError) {
917 #if _FX_OS_ != _FX_ANDROID_ 917 #if _FX_OS_ != _FX_ANDROID_
918 CJS_Context* pContext = (CJS_Context*)cc; 918 CJS_Context* pContext = (CJS_Context*)cc;
919 if (params.size() != 6) { 919 if (params.size() != 6) {
920 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); 920 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
921 return FALSE; 921 return FALSE;
922 } 922 }
923 923
924 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); 924 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
1082 } 1082 }
1083 } 1083 }
1084 } 1084 }
1085 Value = strValue2.c_str(); 1085 Value = strValue2.c_str();
1086 #endif 1086 #endif
1087 return TRUE; 1087 return TRUE;
1088 } 1088 }
1089 1089
1090 // function AFNumber_Keystroke(nDec, sepStyle, negStyle, currStyle, strCurrency, 1090 // function AFNumber_Keystroke(nDec, sepStyle, negStyle, currStyle, strCurrency,
1091 // bCurrencyPrepend) 1091 // bCurrencyPrepend)
1092 FX_BOOL CJS_PublicMethods::AFNumber_Keystroke(IJS_Context* cc, 1092 FX_BOOL CJS_PublicMethods::AFNumber_Keystroke(
1093 const CJS_Parameters& params, 1093 IJS_Context* cc,
1094 CJS_Value& vRet, 1094 const std::vector<CJS_Value>& params,
1095 CFX_WideString& sError) { 1095 CJS_Value& vRet,
1096 CFX_WideString& sError) {
1096 CJS_Context* pContext = (CJS_Context*)cc; 1097 CJS_Context* pContext = (CJS_Context*)cc;
1097 ASSERT(pContext != NULL); 1098 ASSERT(pContext != NULL);
1098 CJS_EventHandler* pEvent = pContext->GetEventHandler(); 1099 CJS_EventHandler* pEvent = pContext->GetEventHandler();
1099 ASSERT(pEvent != NULL); 1100 ASSERT(pEvent != NULL);
1100 1101
1101 if (params.size() < 2) 1102 if (params.size() < 2)
1102 return FALSE; 1103 return FALSE;
1103 int iSepStyle = params[1].ToInt(); 1104 int iSepStyle = params[1].ToInt();
1104 1105
1105 if (iSepStyle < 0 || iSepStyle > 3) 1106 if (iSepStyle < 0 || iSepStyle > 3)
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
1201 std::wstring w_postfix; 1202 std::wstring w_postfix;
1202 if (pEvent->SelEnd() < (int)w_strValue2.length()) 1203 if (pEvent->SelEnd() < (int)w_strValue2.length())
1203 w_postfix = w_strValue2.substr(pEvent->SelEnd()); 1204 w_postfix = w_strValue2.substr(pEvent->SelEnd());
1204 w_strValue2 = w_prefix + w_strChange2 + w_postfix; 1205 w_strValue2 = w_prefix + w_strChange2 + w_postfix;
1205 w_strValue = w_strValue2.c_str(); 1206 w_strValue = w_strValue2.c_str();
1206 val = w_strValue; 1207 val = w_strValue;
1207 return TRUE; 1208 return TRUE;
1208 } 1209 }
1209 1210
1210 // function AFPercent_Format(nDec, sepStyle) 1211 // function AFPercent_Format(nDec, sepStyle)
1211 FX_BOOL CJS_PublicMethods::AFPercent_Format(IJS_Context* cc, 1212 FX_BOOL CJS_PublicMethods::AFPercent_Format(
1212 const CJS_Parameters& params, 1213 IJS_Context* cc,
1213 CJS_Value& vRet, 1214 const std::vector<CJS_Value>& params,
1214 CFX_WideString& sError) { 1215 CJS_Value& vRet,
1216 CFX_WideString& sError) {
1215 #if _FX_OS_ != _FX_ANDROID_ 1217 #if _FX_OS_ != _FX_ANDROID_
1216 CJS_Context* pContext = (CJS_Context*)cc; 1218 CJS_Context* pContext = (CJS_Context*)cc;
1217 ASSERT(pContext != NULL); 1219 ASSERT(pContext != NULL);
1218 CJS_EventHandler* pEvent = pContext->GetEventHandler(); 1220 CJS_EventHandler* pEvent = pContext->GetEventHandler();
1219 ASSERT(pEvent != NULL); 1221 ASSERT(pEvent != NULL);
1220 1222
1221 if (params.size() != 2) { 1223 if (params.size() != 2) {
1222 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); 1224 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
1223 return FALSE; 1225 return FALSE;
1224 } 1226 }
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
1295 //////////////////////////////////////////////////////////////////// 1297 ////////////////////////////////////////////////////////////////////
1296 // negative mark 1298 // negative mark
1297 if (iNegative) 1299 if (iNegative)
1298 strValue = "-" + strValue; 1300 strValue = "-" + strValue;
1299 strValue += "%"; 1301 strValue += "%";
1300 Value = CFX_WideString::FromLocal(strValue); 1302 Value = CFX_WideString::FromLocal(strValue);
1301 #endif 1303 #endif
1302 return TRUE; 1304 return TRUE;
1303 } 1305 }
1304 // AFPercent_Keystroke(nDec, sepStyle) 1306 // AFPercent_Keystroke(nDec, sepStyle)
1305 FX_BOOL CJS_PublicMethods::AFPercent_Keystroke(IJS_Context* cc, 1307 FX_BOOL CJS_PublicMethods::AFPercent_Keystroke(
1306 const CJS_Parameters& params, 1308 IJS_Context* cc,
1307 CJS_Value& vRet, 1309 const std::vector<CJS_Value>& params,
1308 CFX_WideString& sError) { 1310 CJS_Value& vRet,
1311 CFX_WideString& sError) {
1309 return AFNumber_Keystroke(cc, params, vRet, sError); 1312 return AFNumber_Keystroke(cc, params, vRet, sError);
1310 } 1313 }
1311 1314
1312 // function AFDate_FormatEx(cFormat) 1315 // function AFDate_FormatEx(cFormat)
1313 FX_BOOL CJS_PublicMethods::AFDate_FormatEx(IJS_Context* cc, 1316 FX_BOOL CJS_PublicMethods::AFDate_FormatEx(IJS_Context* cc,
1314 const CJS_Parameters& params, 1317 const std::vector<CJS_Value>& params,
1315 CJS_Value& vRet, 1318 CJS_Value& vRet,
1316 CFX_WideString& sError) { 1319 CFX_WideString& sError) {
1317 CJS_Context* pContext = (CJS_Context*)cc; 1320 CJS_Context* pContext = (CJS_Context*)cc;
1318 ASSERT(pContext != NULL); 1321 ASSERT(pContext != NULL);
1319 CJS_EventHandler* pEvent = pContext->GetEventHandler(); 1322 CJS_EventHandler* pEvent = pContext->GetEventHandler();
1320 ASSERT(pEvent != NULL); 1323 ASSERT(pEvent != NULL);
1321 1324
1322 if (params.size() != 1) { 1325 if (params.size() != 1) {
1323 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); 1326 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
1324 return FALSE; 1327 return FALSE;
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
1419 JS_MakeTime(nHour, nMin, nSec, 0)); 1422 JS_MakeTime(nHour, nMin, nSec, 0));
1420 1423
1421 if (JS_PortIsNan(dRet)) { 1424 if (JS_PortIsNan(dRet)) {
1422 dRet = JS_DateParse(strValue.c_str()); 1425 dRet = JS_DateParse(strValue.c_str());
1423 } 1426 }
1424 1427
1425 return dRet; 1428 return dRet;
1426 } 1429 }
1427 1430
1428 // AFDate_KeystrokeEx(cFormat) 1431 // AFDate_KeystrokeEx(cFormat)
1429 FX_BOOL CJS_PublicMethods::AFDate_KeystrokeEx(IJS_Context* cc, 1432 FX_BOOL CJS_PublicMethods::AFDate_KeystrokeEx(
1430 const CJS_Parameters& params, 1433 IJS_Context* cc,
1431 CJS_Value& vRet, 1434 const std::vector<CJS_Value>& params,
1432 CFX_WideString& sError) { 1435 CJS_Value& vRet,
1436 CFX_WideString& sError) {
1433 CJS_Context* pContext = (CJS_Context*)cc; 1437 CJS_Context* pContext = (CJS_Context*)cc;
1434 ASSERT(pContext != NULL); 1438 ASSERT(pContext != NULL);
1435 CJS_EventHandler* pEvent = pContext->GetEventHandler(); 1439 CJS_EventHandler* pEvent = pContext->GetEventHandler();
1436 ASSERT(pEvent != NULL); 1440 ASSERT(pEvent != NULL);
1437 1441
1438 if (params.size() != 1) { 1442 if (params.size() != 1) {
1439 sError = L"AFDate_KeystrokeEx's parameters' size r not correct"; 1443 sError = L"AFDate_KeystrokeEx's parameters' size r not correct";
1440 return FALSE; 1444 return FALSE;
1441 } 1445 }
1442 1446
(...skipping 13 matching lines...) Expand all
1456 sFormat.c_str()); 1460 sFormat.c_str());
1457 Alert(pContext, swMsg.c_str()); 1461 Alert(pContext, swMsg.c_str());
1458 pEvent->Rc() = FALSE; 1462 pEvent->Rc() = FALSE;
1459 return TRUE; 1463 return TRUE;
1460 } 1464 }
1461 } 1465 }
1462 return TRUE; 1466 return TRUE;
1463 } 1467 }
1464 1468
1465 FX_BOOL CJS_PublicMethods::AFDate_Format(IJS_Context* cc, 1469 FX_BOOL CJS_PublicMethods::AFDate_Format(IJS_Context* cc,
1466 const CJS_Parameters& params, 1470 const std::vector<CJS_Value>& params,
1467 CJS_Value& vRet, 1471 CJS_Value& vRet,
1468 CFX_WideString& sError) { 1472 CFX_WideString& sError) {
1469 CJS_Context* pContext = (CJS_Context*)cc; 1473 CJS_Context* pContext = (CJS_Context*)cc;
1470 if (params.size() != 1) { 1474 if (params.size() != 1) {
1471 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); 1475 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
1472 return FALSE; 1476 return FALSE;
1473 } 1477 }
1474 1478
1475 int iIndex = params[0].ToInt(); 1479 int iIndex = params[0].ToInt();
1476 const FX_WCHAR* cFormats[] = {L"m/d", 1480 const FX_WCHAR* cFormats[] = {L"m/d",
1477 L"m/d/yy", 1481 L"m/d/yy",
1478 L"mm/dd/yy", 1482 L"mm/dd/yy",
1479 L"mm/yy", 1483 L"mm/yy",
1480 L"d-mmm", 1484 L"d-mmm",
1481 L"d-mmm-yy", 1485 L"d-mmm-yy",
1482 L"dd-mmm-yy", 1486 L"dd-mmm-yy",
1483 L"yy-mm-dd", 1487 L"yy-mm-dd",
1484 L"mmm-yy", 1488 L"mmm-yy",
1485 L"mmmm-yy", 1489 L"mmmm-yy",
1486 L"mmm d, yyyy", 1490 L"mmm d, yyyy",
1487 L"mmmm d, yyyy", 1491 L"mmmm d, yyyy",
1488 L"m/d/yy h:MM tt", 1492 L"m/d/yy h:MM tt",
1489 L"m/d/yy HH:MM"}; 1493 L"m/d/yy HH:MM"};
1490 1494
1491 if (iIndex < 0 || (static_cast<size_t>(iIndex) >= FX_ArraySize(cFormats))) 1495 if (iIndex < 0 || (static_cast<size_t>(iIndex) >= FX_ArraySize(cFormats)))
1492 iIndex = 0; 1496 iIndex = 0;
1493 1497
1494 CJS_Parameters newParams; 1498 std::vector<CJS_Value> newParams;
1495 newParams.push_back( 1499 newParams.push_back(
1496 CJS_Value(CJS_Runtime::FromContext(cc), cFormats[iIndex])); 1500 CJS_Value(CJS_Runtime::FromContext(cc), cFormats[iIndex]));
1497 return AFDate_FormatEx(cc, newParams, vRet, sError); 1501 return AFDate_FormatEx(cc, newParams, vRet, sError);
1498 } 1502 }
1499 1503
1500 // AFDate_KeystrokeEx(cFormat) 1504 // AFDate_KeystrokeEx(cFormat)
1501 FX_BOOL CJS_PublicMethods::AFDate_Keystroke(IJS_Context* cc, 1505 FX_BOOL CJS_PublicMethods::AFDate_Keystroke(
1502 const CJS_Parameters& params, 1506 IJS_Context* cc,
1503 CJS_Value& vRet, 1507 const std::vector<CJS_Value>& params,
1504 CFX_WideString& sError) { 1508 CJS_Value& vRet,
1509 CFX_WideString& sError) {
1505 CJS_Context* pContext = (CJS_Context*)cc; 1510 CJS_Context* pContext = (CJS_Context*)cc;
1506 if (params.size() != 1) { 1511 if (params.size() != 1) {
1507 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); 1512 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
1508 return FALSE; 1513 return FALSE;
1509 } 1514 }
1510 1515
1511 int iIndex = params[0].ToInt(); 1516 int iIndex = params[0].ToInt();
1512 const FX_WCHAR* cFormats[] = {L"m/d", 1517 const FX_WCHAR* cFormats[] = {L"m/d",
1513 L"m/d/yy", 1518 L"m/d/yy",
1514 L"mm/dd/yy", 1519 L"mm/dd/yy",
1515 L"mm/yy", 1520 L"mm/yy",
1516 L"d-mmm", 1521 L"d-mmm",
1517 L"d-mmm-yy", 1522 L"d-mmm-yy",
1518 L"dd-mmm-yy", 1523 L"dd-mmm-yy",
1519 L"yy-mm-dd", 1524 L"yy-mm-dd",
1520 L"mmm-yy", 1525 L"mmm-yy",
1521 L"mmmm-yy", 1526 L"mmmm-yy",
1522 L"mmm d, yyyy", 1527 L"mmm d, yyyy",
1523 L"mmmm d, yyyy", 1528 L"mmmm d, yyyy",
1524 L"m/d/yy h:MM tt", 1529 L"m/d/yy h:MM tt",
1525 L"m/d/yy HH:MM"}; 1530 L"m/d/yy HH:MM"};
1526 1531
1527 if (iIndex < 0 || (static_cast<size_t>(iIndex) >= FX_ArraySize(cFormats))) 1532 if (iIndex < 0 || (static_cast<size_t>(iIndex) >= FX_ArraySize(cFormats)))
1528 iIndex = 0; 1533 iIndex = 0;
1529 1534
1530 CJS_Parameters newParams; 1535 std::vector<CJS_Value> newParams;
1531 newParams.push_back( 1536 newParams.push_back(
1532 CJS_Value(CJS_Runtime::FromContext(cc), cFormats[iIndex])); 1537 CJS_Value(CJS_Runtime::FromContext(cc), cFormats[iIndex]));
1533 return AFDate_KeystrokeEx(cc, newParams, vRet, sError); 1538 return AFDate_KeystrokeEx(cc, newParams, vRet, sError);
1534 } 1539 }
1535 1540
1536 // function AFTime_Format(ptf) 1541 // function AFTime_Format(ptf)
1537 FX_BOOL CJS_PublicMethods::AFTime_Format(IJS_Context* cc, 1542 FX_BOOL CJS_PublicMethods::AFTime_Format(IJS_Context* cc,
1538 const CJS_Parameters& params, 1543 const std::vector<CJS_Value>& params,
1539 CJS_Value& vRet, 1544 CJS_Value& vRet,
1540 CFX_WideString& sError) { 1545 CFX_WideString& sError) {
1541 CJS_Context* pContext = (CJS_Context*)cc; 1546 CJS_Context* pContext = (CJS_Context*)cc;
1542 if (params.size() != 1) { 1547 if (params.size() != 1) {
1543 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); 1548 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
1544 return FALSE; 1549 return FALSE;
1545 } 1550 }
1546 1551
1547 int iIndex = params[0].ToInt(); 1552 int iIndex = params[0].ToInt();
1548 const FX_WCHAR* cFormats[] = {L"HH:MM", L"h:MM tt", L"HH:MM:ss", 1553 const FX_WCHAR* cFormats[] = {L"HH:MM", L"h:MM tt", L"HH:MM:ss",
1549 L"h:MM:ss tt"}; 1554 L"h:MM:ss tt"};
1550 1555
1551 if (iIndex < 0 || (static_cast<size_t>(iIndex) >= FX_ArraySize(cFormats))) 1556 if (iIndex < 0 || (static_cast<size_t>(iIndex) >= FX_ArraySize(cFormats)))
1552 iIndex = 0; 1557 iIndex = 0;
1553 1558
1554 CJS_Parameters newParams; 1559 std::vector<CJS_Value> newParams;
1555 newParams.push_back( 1560 newParams.push_back(
1556 CJS_Value(CJS_Runtime::FromContext(cc), cFormats[iIndex])); 1561 CJS_Value(CJS_Runtime::FromContext(cc), cFormats[iIndex]));
1557 return AFDate_FormatEx(cc, newParams, vRet, sError); 1562 return AFDate_FormatEx(cc, newParams, vRet, sError);
1558 } 1563 }
1559 1564
1560 FX_BOOL CJS_PublicMethods::AFTime_Keystroke(IJS_Context* cc, 1565 FX_BOOL CJS_PublicMethods::AFTime_Keystroke(
1561 const CJS_Parameters& params, 1566 IJS_Context* cc,
1562 CJS_Value& vRet, 1567 const std::vector<CJS_Value>& params,
1563 CFX_WideString& sError) { 1568 CJS_Value& vRet,
1569 CFX_WideString& sError) {
1564 CJS_Context* pContext = (CJS_Context*)cc; 1570 CJS_Context* pContext = (CJS_Context*)cc;
1565 if (params.size() != 1) { 1571 if (params.size() != 1) {
1566 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); 1572 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
1567 return FALSE; 1573 return FALSE;
1568 } 1574 }
1569 1575
1570 int iIndex = params[0].ToInt(); 1576 int iIndex = params[0].ToInt();
1571 const FX_WCHAR* cFormats[] = {L"HH:MM", L"h:MM tt", L"HH:MM:ss", 1577 const FX_WCHAR* cFormats[] = {L"HH:MM", L"h:MM tt", L"HH:MM:ss",
1572 L"h:MM:ss tt"}; 1578 L"h:MM:ss tt"};
1573 1579
1574 if (iIndex < 0 || (static_cast<size_t>(iIndex) >= FX_ArraySize(cFormats))) 1580 if (iIndex < 0 || (static_cast<size_t>(iIndex) >= FX_ArraySize(cFormats)))
1575 iIndex = 0; 1581 iIndex = 0;
1576 1582
1577 CJS_Parameters newParams; 1583 std::vector<CJS_Value> newParams;
1578 newParams.push_back( 1584 newParams.push_back(
1579 CJS_Value(CJS_Runtime::FromContext(cc), cFormats[iIndex])); 1585 CJS_Value(CJS_Runtime::FromContext(cc), cFormats[iIndex]));
1580 return AFDate_KeystrokeEx(cc, newParams, vRet, sError); 1586 return AFDate_KeystrokeEx(cc, newParams, vRet, sError);
1581 } 1587 }
1582 1588
1583 FX_BOOL CJS_PublicMethods::AFTime_FormatEx(IJS_Context* cc, 1589 FX_BOOL CJS_PublicMethods::AFTime_FormatEx(IJS_Context* cc,
1584 const CJS_Parameters& params, 1590 const std::vector<CJS_Value>& params,
1585 CJS_Value& vRet, 1591 CJS_Value& vRet,
1586 CFX_WideString& sError) { 1592 CFX_WideString& sError) {
1587 return AFDate_FormatEx(cc, params, vRet, sError); 1593 return AFDate_FormatEx(cc, params, vRet, sError);
1588 } 1594 }
1589 1595
1590 FX_BOOL CJS_PublicMethods::AFTime_KeystrokeEx(IJS_Context* cc, 1596 FX_BOOL CJS_PublicMethods::AFTime_KeystrokeEx(
1591 const CJS_Parameters& params, 1597 IJS_Context* cc,
1592 CJS_Value& vRet, 1598 const std::vector<CJS_Value>& params,
1593 CFX_WideString& sError) { 1599 CJS_Value& vRet,
1600 CFX_WideString& sError) {
1594 return AFDate_KeystrokeEx(cc, params, vRet, sError); 1601 return AFDate_KeystrokeEx(cc, params, vRet, sError);
1595 } 1602 }
1596 1603
1597 // function AFSpecial_Format(psf) 1604 // function AFSpecial_Format(psf)
1598 FX_BOOL CJS_PublicMethods::AFSpecial_Format(IJS_Context* cc, 1605 FX_BOOL CJS_PublicMethods::AFSpecial_Format(
1599 const CJS_Parameters& params, 1606 IJS_Context* cc,
1600 CJS_Value& vRet, 1607 const std::vector<CJS_Value>& params,
1601 CFX_WideString& sError) { 1608 CJS_Value& vRet,
1609 CFX_WideString& sError) {
1602 CJS_Context* pContext = (CJS_Context*)cc; 1610 CJS_Context* pContext = (CJS_Context*)cc;
1603 ASSERT(pContext != NULL); 1611 ASSERT(pContext != NULL);
1604 1612
1605 if (params.size() != 1) { 1613 if (params.size() != 1) {
1606 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); 1614 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
1607 return FALSE; 1615 return FALSE;
1608 } 1616 }
1609 1617
1610 std::string cFormat; 1618 std::string cFormat;
1611 int iIndex = params[0].ToInt(); 1619 int iIndex = params[0].ToInt();
(...skipping 27 matching lines...) Expand all
1639 break; 1647 break;
1640 } 1648 }
1641 1649
1642 std::string strDes; 1650 std::string strDes;
1643 util::printx(cFormat, strSrc, strDes); 1651 util::printx(cFormat, strSrc, strDes);
1644 Value = CFX_WideString::FromLocal(strDes.c_str()); 1652 Value = CFX_WideString::FromLocal(strDes.c_str());
1645 return TRUE; 1653 return TRUE;
1646 } 1654 }
1647 1655
1648 // function AFSpecial_KeystrokeEx(mask) 1656 // function AFSpecial_KeystrokeEx(mask)
1649 FX_BOOL CJS_PublicMethods::AFSpecial_KeystrokeEx(IJS_Context* cc, 1657 FX_BOOL CJS_PublicMethods::AFSpecial_KeystrokeEx(
1650 const CJS_Parameters& params, 1658 IJS_Context* cc,
1651 CJS_Value& vRet, 1659 const std::vector<CJS_Value>& params,
1652 CFX_WideString& sError) { 1660 CJS_Value& vRet,
1661 CFX_WideString& sError) {
1653 CJS_Context* pContext = (CJS_Context*)cc; 1662 CJS_Context* pContext = (CJS_Context*)cc;
1654 ASSERT(pContext != NULL); 1663 ASSERT(pContext != NULL);
1655 CJS_EventHandler* pEvent = pContext->GetEventHandler(); 1664 CJS_EventHandler* pEvent = pContext->GetEventHandler();
1656 1665
1657 ASSERT(pEvent != NULL); 1666 ASSERT(pEvent != NULL);
1658 1667
1659 if (params.size() < 1) { 1668 if (params.size() < 1) {
1660 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); 1669 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
1661 return FALSE; 1670 return FALSE;
1662 } 1671 }
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1732 return TRUE; 1741 return TRUE;
1733 } 1742 }
1734 iIndexMask++; 1743 iIndexMask++;
1735 } 1744 }
1736 1745
1737 wideChange = wChange.c_str(); 1746 wideChange = wChange.c_str();
1738 return TRUE; 1747 return TRUE;
1739 } 1748 }
1740 1749
1741 // function AFSpecial_Keystroke(psf) 1750 // function AFSpecial_Keystroke(psf)
1742 FX_BOOL CJS_PublicMethods::AFSpecial_Keystroke(IJS_Context* cc, 1751 FX_BOOL CJS_PublicMethods::AFSpecial_Keystroke(
1743 const CJS_Parameters& params, 1752 IJS_Context* cc,
1744 CJS_Value& vRet, 1753 const std::vector<CJS_Value>& params,
1745 CFX_WideString& sError) { 1754 CJS_Value& vRet,
1755 CFX_WideString& sError) {
1746 CJS_Context* pContext = (CJS_Context*)cc; 1756 CJS_Context* pContext = (CJS_Context*)cc;
1747 if (params.size() != 1) { 1757 if (params.size() != 1) {
1748 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); 1758 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
1749 return FALSE; 1759 return FALSE;
1750 } 1760 }
1751 1761
1752 CJS_EventHandler* pEvent = pContext->GetEventHandler(); 1762 CJS_EventHandler* pEvent = pContext->GetEventHandler();
1753 if (!pEvent->m_pValue) 1763 if (!pEvent->m_pValue)
1754 return FALSE; 1764 return FALSE;
1755 1765
(...skipping 21 matching lines...) Expand all
1777 // cFormat = "999-9999"; 1787 // cFormat = "999-9999";
1778 cFormat = "9999999"; 1788 cFormat = "9999999";
1779 break; 1789 break;
1780 } 1790 }
1781 case 3: 1791 case 3:
1782 // cFormat = "999-99-9999"; 1792 // cFormat = "999-99-9999";
1783 cFormat = "999999999"; 1793 cFormat = "999999999";
1784 break; 1794 break;
1785 } 1795 }
1786 1796
1787 CJS_Parameters params2; 1797 std::vector<CJS_Value> params2;
1788 params2.push_back(CJS_Value(CJS_Runtime::FromContext(cc), cFormat.c_str())); 1798 params2.push_back(CJS_Value(CJS_Runtime::FromContext(cc), cFormat.c_str()));
1789 return AFSpecial_KeystrokeEx(cc, params2, vRet, sError); 1799 return AFSpecial_KeystrokeEx(cc, params2, vRet, sError);
1790 } 1800 }
1791 1801
1792 FX_BOOL CJS_PublicMethods::AFMergeChange(IJS_Context* cc, 1802 FX_BOOL CJS_PublicMethods::AFMergeChange(IJS_Context* cc,
1793 const CJS_Parameters& params, 1803 const std::vector<CJS_Value>& params,
1794 CJS_Value& vRet, 1804 CJS_Value& vRet,
1795 CFX_WideString& sError) { 1805 CFX_WideString& sError) {
1796 CJS_Context* pContext = (CJS_Context*)cc; 1806 CJS_Context* pContext = (CJS_Context*)cc;
1797 ASSERT(pContext != NULL); 1807 ASSERT(pContext != NULL);
1798 CJS_EventHandler* pEventHandler = pContext->GetEventHandler(); 1808 CJS_EventHandler* pEventHandler = pContext->GetEventHandler();
1799 ASSERT(pEventHandler != NULL); 1809 ASSERT(pEventHandler != NULL);
1800 1810
1801 if (params.size() != 1) { 1811 if (params.size() != 1) {
1802 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); 1812 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
1803 return FALSE; 1813 return FALSE;
(...skipping 21 matching lines...) Expand all
1825 swValue.GetLength() - pEventHandler->SelEnd()); 1835 swValue.GetLength() - pEventHandler->SelEnd());
1826 else 1836 else
1827 postfix = L""; 1837 postfix = L"";
1828 1838
1829 vRet = (prefix + pEventHandler->Change() + postfix).c_str(); 1839 vRet = (prefix + pEventHandler->Change() + postfix).c_str();
1830 1840
1831 return TRUE; 1841 return TRUE;
1832 } 1842 }
1833 1843
1834 FX_BOOL CJS_PublicMethods::AFParseDateEx(IJS_Context* cc, 1844 FX_BOOL CJS_PublicMethods::AFParseDateEx(IJS_Context* cc,
1835 const CJS_Parameters& params, 1845 const std::vector<CJS_Value>& params,
1836 CJS_Value& vRet, 1846 CJS_Value& vRet,
1837 CFX_WideString& sError) { 1847 CFX_WideString& sError) {
1838 CJS_Context* pContext = (CJS_Context*)cc; 1848 CJS_Context* pContext = (CJS_Context*)cc;
1839 ASSERT(pContext != NULL); 1849 ASSERT(pContext != NULL);
1840 1850
1841 if (params.size() != 2) { 1851 if (params.size() != 2) {
1842 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); 1852 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
1843 return FALSE; 1853 return FALSE;
1844 } 1854 }
1845 1855
1846 CFX_WideString sValue = params[0].ToCFXWideString(); 1856 CFX_WideString sValue = params[0].ToCFXWideString();
1847 CFX_WideString sFormat = params[1].ToCFXWideString(); 1857 CFX_WideString sFormat = params[1].ToCFXWideString();
1848 1858
1849 FX_BOOL bWrongFormat = FALSE; 1859 FX_BOOL bWrongFormat = FALSE;
1850 double dDate = MakeRegularDate(sValue, sFormat, bWrongFormat); 1860 double dDate = MakeRegularDate(sValue, sFormat, bWrongFormat);
1851 1861
1852 if (JS_PortIsNan(dDate)) { 1862 if (JS_PortIsNan(dDate)) {
1853 CFX_WideString swMsg; 1863 CFX_WideString swMsg;
1854 swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSPARSEDATE).c_str(), 1864 swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSPARSEDATE).c_str(),
1855 sFormat.c_str()); 1865 sFormat.c_str());
1856 Alert((CJS_Context*)cc, swMsg.c_str()); 1866 Alert((CJS_Context*)cc, swMsg.c_str());
1857 return FALSE; 1867 return FALSE;
1858 } 1868 }
1859 1869
1860 vRet = dDate; 1870 vRet = dDate;
1861 return TRUE; 1871 return TRUE;
1862 } 1872 }
1863 1873
1864 FX_BOOL CJS_PublicMethods::AFSimple(IJS_Context* cc, 1874 FX_BOOL CJS_PublicMethods::AFSimple(IJS_Context* cc,
1865 const CJS_Parameters& params, 1875 const std::vector<CJS_Value>& params,
1866 CJS_Value& vRet, 1876 CJS_Value& vRet,
1867 CFX_WideString& sError) { 1877 CFX_WideString& sError) {
1868 if (params.size() != 3) { 1878 if (params.size() != 3) {
1869 CJS_Context* pContext = (CJS_Context*)cc; 1879 CJS_Context* pContext = (CJS_Context*)cc;
1870 ASSERT(pContext != NULL); 1880 ASSERT(pContext != NULL);
1871 1881
1872 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); 1882 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
1873 return FALSE; 1883 return FALSE;
1874 } 1884 }
1875 1885
1876 vRet = (double)AF_Simple(params[0].ToCFXWideString().c_str(), 1886 vRet = (double)AF_Simple(params[0].ToCFXWideString().c_str(),
1877 params[1].ToDouble(), params[2].ToDouble()); 1887 params[1].ToDouble(), params[2].ToDouble());
1878 return TRUE; 1888 return TRUE;
1879 } 1889 }
1880 1890
1881 FX_BOOL CJS_PublicMethods::AFMakeNumber(IJS_Context* cc, 1891 FX_BOOL CJS_PublicMethods::AFMakeNumber(IJS_Context* cc,
1882 const CJS_Parameters& params, 1892 const std::vector<CJS_Value>& params,
1883 CJS_Value& vRet, 1893 CJS_Value& vRet,
1884 CFX_WideString& sError) { 1894 CFX_WideString& sError) {
1885 if (params.size() != 1) { 1895 if (params.size() != 1) {
1886 CJS_Context* pContext = (CJS_Context*)cc; 1896 CJS_Context* pContext = (CJS_Context*)cc;
1887 ASSERT(pContext != NULL); 1897 ASSERT(pContext != NULL);
1888 1898
1889 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); 1899 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
1890 return FALSE; 1900 return FALSE;
1891 } 1901 }
1892 vRet = ParseStringToNumber(params[0].ToCFXWideString().c_str()); 1902 vRet = ParseStringToNumber(params[0].ToCFXWideString().c_str());
1893 return TRUE; 1903 return TRUE;
1894 } 1904 }
1895 1905
1896 FX_BOOL CJS_PublicMethods::AFSimple_Calculate(IJS_Context* cc, 1906 FX_BOOL CJS_PublicMethods::AFSimple_Calculate(
1897 const CJS_Parameters& params, 1907 IJS_Context* cc,
1898 CJS_Value& vRet, 1908 const std::vector<CJS_Value>& params,
1899 CFX_WideString& sError) { 1909 CJS_Value& vRet,
1910 CFX_WideString& sError) {
1900 CJS_Context* pContext = (CJS_Context*)cc; 1911 CJS_Context* pContext = (CJS_Context*)cc;
1901 if (params.size() != 2) { 1912 if (params.size() != 2) {
1902 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); 1913 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
1903 return FALSE; 1914 return FALSE;
1904 } 1915 }
1905 1916
1906 CJS_Value params1 = params[1]; 1917 CJS_Value params1 = params[1];
1907 if (!params1.IsArrayObject() && params1.GetType() != CJS_Value::VT_string) { 1918 if (!params1.IsArrayObject() && params1.GetType() != CJS_Value::VT_string) {
1908 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); 1919 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
1909 return FALSE; 1920 return FALSE;
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
1986 CJS_Value jsValue(pRuntime, dValue); 1997 CJS_Value jsValue(pRuntime, dValue);
1987 if (pContext->GetEventHandler()->m_pValue) 1998 if (pContext->GetEventHandler()->m_pValue)
1988 pContext->GetEventHandler()->Value() = jsValue.ToCFXWideString(); 1999 pContext->GetEventHandler()->Value() = jsValue.ToCFXWideString();
1989 2000
1990 return TRUE; 2001 return TRUE;
1991 } 2002 }
1992 2003
1993 /* This function validates the current event to ensure that its value is 2004 /* This function validates the current event to ensure that its value is
1994 ** within the specified range. */ 2005 ** within the specified range. */
1995 2006
1996 FX_BOOL CJS_PublicMethods::AFRange_Validate(IJS_Context* cc, 2007 FX_BOOL CJS_PublicMethods::AFRange_Validate(
1997 const CJS_Parameters& params, 2008 IJS_Context* cc,
1998 CJS_Value& vRet, 2009 const std::vector<CJS_Value>& params,
1999 CFX_WideString& sError) { 2010 CJS_Value& vRet,
2011 CFX_WideString& sError) {
2000 CJS_Context* pContext = (CJS_Context*)cc; 2012 CJS_Context* pContext = (CJS_Context*)cc;
2001 ASSERT(pContext != NULL); 2013 ASSERT(pContext != NULL);
2002 CJS_EventHandler* pEvent = pContext->GetEventHandler(); 2014 CJS_EventHandler* pEvent = pContext->GetEventHandler();
2003 ASSERT(pEvent != NULL); 2015 ASSERT(pEvent != NULL);
2004 2016
2005 if (params.size() != 4) { 2017 if (params.size() != 4) {
2006 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); 2018 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
2007 return FALSE; 2019 return FALSE;
2008 } 2020 }
2009 2021
(...skipping 24 matching lines...) Expand all
2034 } 2046 }
2035 2047
2036 if (!swMsg.IsEmpty()) { 2048 if (!swMsg.IsEmpty()) {
2037 Alert(pContext, swMsg.c_str()); 2049 Alert(pContext, swMsg.c_str());
2038 pEvent->Rc() = FALSE; 2050 pEvent->Rc() = FALSE;
2039 } 2051 }
2040 return TRUE; 2052 return TRUE;
2041 } 2053 }
2042 2054
2043 FX_BOOL CJS_PublicMethods::AFExtractNums(IJS_Context* cc, 2055 FX_BOOL CJS_PublicMethods::AFExtractNums(IJS_Context* cc,
2044 const CJS_Parameters& params, 2056 const std::vector<CJS_Value>& params,
2045 CJS_Value& vRet, 2057 CJS_Value& vRet,
2046 CFX_WideString& sError) { 2058 CFX_WideString& sError) {
2047 CJS_Context* pContext = (CJS_Context*)cc; 2059 CJS_Context* pContext = (CJS_Context*)cc;
2048 if (params.size() != 1) { 2060 if (params.size() != 1) {
2049 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); 2061 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
2050 return FALSE; 2062 return FALSE;
2051 } 2063 }
2052 2064
2053 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); 2065 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
2054 CJS_Array nums(pRuntime); 2066 CJS_Array nums(pRuntime);
(...skipping 22 matching lines...) Expand all
2077 nums.SetElement(nIndex, CJS_Value(pRuntime, sPart.c_str())); 2089 nums.SetElement(nIndex, CJS_Value(pRuntime, sPart.c_str()));
2078 } 2090 }
2079 2091
2080 if (nums.GetLength() > 0) 2092 if (nums.GetLength() > 0)
2081 vRet = nums; 2093 vRet = nums;
2082 else 2094 else
2083 vRet.SetNull(); 2095 vRet.SetNull();
2084 2096
2085 return TRUE; 2097 return TRUE;
2086 } 2098 }
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