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

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

Issue 1386173002: Rename IFXJS_Runtime and IFXJS_Context to IJS_. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Comment in fxjs_v8.h Created 5 years, 2 months 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"
11 #include "Field.h" 11 #include "Field.h"
12 #include "JS_Context.h" 12 #include "JS_Context.h"
13 #include "JS_Define.h" 13 #include "JS_Define.h"
14 #include "JS_EventHandler.h" 14 #include "JS_EventHandler.h"
15 #include "JS_Object.h" 15 #include "JS_Object.h"
16 #include "JS_Runtime.h" 16 #include "JS_Runtime.h"
17 #include "JS_Value.h" 17 #include "JS_Value.h"
18 #include "color.h" 18 #include "color.h"
19 #include "resource.h" 19 #include "resource.h"
20 #include "util.h" 20 #include "util.h"
21 21
22 static v8::Isolate* GetIsolate(IFXJS_Context* cc) { 22 static v8::Isolate* GetIsolate(IJS_Context* cc) {
23 CJS_Context* pContext = (CJS_Context*)cc; 23 CJS_Context* pContext = (CJS_Context*)cc;
24 ASSERT(pContext != NULL); 24 ASSERT(pContext != NULL);
25 25
26 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); 26 CJS_Runtime* pRuntime = pContext->GetJSRuntime();
27 ASSERT(pRuntime != NULL); 27 ASSERT(pRuntime != NULL);
28 28
29 return pRuntime->GetIsolate(); 29 return pRuntime->GetIsolate();
30 } 30 }
31 31
32 /* -------------------------------- CJS_PublicMethods 32 /* -------------------------------- CJS_PublicMethods
(...skipping 866 matching lines...) Expand 10 before | Expand all | Expand 10 after
899 sRet += sPart; 899 sRet += sPart;
900 } 900 }
901 901
902 return sRet; 902 return sRet;
903 } 903 }
904 904
905 /* -------------------------------------------------------------------------- */ 905 /* -------------------------------------------------------------------------- */
906 906
907 // function AFNumber_Format(nDec, sepStyle, negStyle, currStyle, strCurrency, 907 // function AFNumber_Format(nDec, sepStyle, negStyle, currStyle, strCurrency,
908 // bCurrencyPrepend) 908 // bCurrencyPrepend)
909 FX_BOOL CJS_PublicMethods::AFNumber_Format(IFXJS_Context* cc, 909 FX_BOOL CJS_PublicMethods::AFNumber_Format(IJS_Context* cc,
910 const CJS_Parameters& params, 910 const CJS_Parameters& params,
911 CJS_Value& vRet, 911 CJS_Value& vRet,
912 CFX_WideString& sError) { 912 CFX_WideString& sError) {
913 #if _FX_OS_ != _FX_ANDROID_ 913 #if _FX_OS_ != _FX_ANDROID_
914 v8::Isolate* isolate = ::GetIsolate(cc); 914 v8::Isolate* isolate = ::GetIsolate(cc);
915 CJS_Context* pContext = (CJS_Context*)cc; 915 CJS_Context* pContext = (CJS_Context*)cc;
916 ASSERT(pContext != NULL); 916 ASSERT(pContext != NULL);
917 CJS_EventHandler* pEvent = pContext->GetEventHandler(); 917 CJS_EventHandler* pEvent = pContext->GetEventHandler();
918 ASSERT(pEvent != NULL); 918 ASSERT(pEvent != NULL);
919 919
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
1083 } 1083 }
1084 } 1084 }
1085 } 1085 }
1086 Value = strValue2.c_str(); 1086 Value = strValue2.c_str();
1087 #endif 1087 #endif
1088 return TRUE; 1088 return TRUE;
1089 } 1089 }
1090 1090
1091 // function AFNumber_Keystroke(nDec, sepStyle, negStyle, currStyle, strCurrency, 1091 // function AFNumber_Keystroke(nDec, sepStyle, negStyle, currStyle, strCurrency,
1092 // bCurrencyPrepend) 1092 // bCurrencyPrepend)
1093 FX_BOOL CJS_PublicMethods::AFNumber_Keystroke(IFXJS_Context* cc, 1093 FX_BOOL CJS_PublicMethods::AFNumber_Keystroke(IJS_Context* cc,
1094 const CJS_Parameters& params, 1094 const CJS_Parameters& params,
1095 CJS_Value& vRet, 1095 CJS_Value& vRet,
1096 CFX_WideString& sError) { 1096 CFX_WideString& sError) {
1097 CJS_Context* pContext = (CJS_Context*)cc; 1097 CJS_Context* pContext = (CJS_Context*)cc;
1098 ASSERT(pContext != NULL); 1098 ASSERT(pContext != NULL);
1099 CJS_EventHandler* pEvent = pContext->GetEventHandler(); 1099 CJS_EventHandler* pEvent = pContext->GetEventHandler();
1100 ASSERT(pEvent != NULL); 1100 ASSERT(pEvent != NULL);
1101 1101
1102 if (params.size() < 2) 1102 if (params.size() < 2)
1103 return FALSE; 1103 return FALSE;
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
1202 std::wstring w_postfix; 1202 std::wstring w_postfix;
1203 if (pEvent->SelEnd() < (int)w_strValue2.length()) 1203 if (pEvent->SelEnd() < (int)w_strValue2.length())
1204 w_postfix = w_strValue2.substr(pEvent->SelEnd()); 1204 w_postfix = w_strValue2.substr(pEvent->SelEnd());
1205 w_strValue2 = w_prefix + w_strChange2 + w_postfix; 1205 w_strValue2 = w_prefix + w_strChange2 + w_postfix;
1206 w_strValue = w_strValue2.c_str(); 1206 w_strValue = w_strValue2.c_str();
1207 val = w_strValue; 1207 val = w_strValue;
1208 return TRUE; 1208 return TRUE;
1209 } 1209 }
1210 1210
1211 // function AFPercent_Format(nDec, sepStyle) 1211 // function AFPercent_Format(nDec, sepStyle)
1212 FX_BOOL CJS_PublicMethods::AFPercent_Format(IFXJS_Context* cc, 1212 FX_BOOL CJS_PublicMethods::AFPercent_Format(IJS_Context* cc,
1213 const CJS_Parameters& params, 1213 const CJS_Parameters& params,
1214 CJS_Value& vRet, 1214 CJS_Value& vRet,
1215 CFX_WideString& sError) { 1215 CFX_WideString& sError) {
1216 #if _FX_OS_ != _FX_ANDROID_ 1216 #if _FX_OS_ != _FX_ANDROID_
1217 CJS_Context* pContext = (CJS_Context*)cc; 1217 CJS_Context* pContext = (CJS_Context*)cc;
1218 ASSERT(pContext != NULL); 1218 ASSERT(pContext != NULL);
1219 CJS_EventHandler* pEvent = pContext->GetEventHandler(); 1219 CJS_EventHandler* pEvent = pContext->GetEventHandler();
1220 ASSERT(pEvent != NULL); 1220 ASSERT(pEvent != NULL);
1221 1221
1222 if (params.size() != 2) { 1222 if (params.size() != 2) {
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
1299 //////////////////////////////////////////////////////////////////// 1299 ////////////////////////////////////////////////////////////////////
1300 // negative mark 1300 // negative mark
1301 if (iNegative) 1301 if (iNegative)
1302 strValue = "-" + strValue; 1302 strValue = "-" + strValue;
1303 strValue += "%"; 1303 strValue += "%";
1304 Value = CFX_WideString::FromLocal(strValue); 1304 Value = CFX_WideString::FromLocal(strValue);
1305 #endif 1305 #endif
1306 return TRUE; 1306 return TRUE;
1307 } 1307 }
1308 // AFPercent_Keystroke(nDec, sepStyle) 1308 // AFPercent_Keystroke(nDec, sepStyle)
1309 FX_BOOL CJS_PublicMethods::AFPercent_Keystroke(IFXJS_Context* cc, 1309 FX_BOOL CJS_PublicMethods::AFPercent_Keystroke(IJS_Context* cc,
1310 const CJS_Parameters& params, 1310 const CJS_Parameters& params,
1311 CJS_Value& vRet, 1311 CJS_Value& vRet,
1312 CFX_WideString& sError) { 1312 CFX_WideString& sError) {
1313 return AFNumber_Keystroke(cc, params, vRet, sError); 1313 return AFNumber_Keystroke(cc, params, vRet, sError);
1314 } 1314 }
1315 1315
1316 // function AFDate_FormatEx(cFormat) 1316 // function AFDate_FormatEx(cFormat)
1317 FX_BOOL CJS_PublicMethods::AFDate_FormatEx(IFXJS_Context* cc, 1317 FX_BOOL CJS_PublicMethods::AFDate_FormatEx(IJS_Context* cc,
1318 const CJS_Parameters& params, 1318 const CJS_Parameters& params,
1319 CJS_Value& vRet, 1319 CJS_Value& vRet,
1320 CFX_WideString& sError) { 1320 CFX_WideString& sError) {
1321 CJS_Context* pContext = (CJS_Context*)cc; 1321 CJS_Context* pContext = (CJS_Context*)cc;
1322 ASSERT(pContext != NULL); 1322 ASSERT(pContext != NULL);
1323 CJS_EventHandler* pEvent = pContext->GetEventHandler(); 1323 CJS_EventHandler* pEvent = pContext->GetEventHandler();
1324 ASSERT(pEvent != NULL); 1324 ASSERT(pEvent != NULL);
1325 1325
1326 if (params.size() != 1) { 1326 if (params.size() != 1) {
1327 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); 1327 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
1423 JS_MakeTime(nHour, nMin, nSec, 0)); 1423 JS_MakeTime(nHour, nMin, nSec, 0));
1424 1424
1425 if (JS_PortIsNan(dRet)) { 1425 if (JS_PortIsNan(dRet)) {
1426 dRet = JS_DateParse(strValue.c_str()); 1426 dRet = JS_DateParse(strValue.c_str());
1427 } 1427 }
1428 1428
1429 return dRet; 1429 return dRet;
1430 } 1430 }
1431 1431
1432 // AFDate_KeystrokeEx(cFormat) 1432 // AFDate_KeystrokeEx(cFormat)
1433 FX_BOOL CJS_PublicMethods::AFDate_KeystrokeEx(IFXJS_Context* cc, 1433 FX_BOOL CJS_PublicMethods::AFDate_KeystrokeEx(IJS_Context* cc,
1434 const CJS_Parameters& params, 1434 const CJS_Parameters& params,
1435 CJS_Value& vRet, 1435 CJS_Value& vRet,
1436 CFX_WideString& sError) { 1436 CFX_WideString& sError) {
1437 CJS_Context* pContext = (CJS_Context*)cc; 1437 CJS_Context* pContext = (CJS_Context*)cc;
1438 ASSERT(pContext != NULL); 1438 ASSERT(pContext != NULL);
1439 CJS_EventHandler* pEvent = pContext->GetEventHandler(); 1439 CJS_EventHandler* pEvent = pContext->GetEventHandler();
1440 ASSERT(pEvent != NULL); 1440 ASSERT(pEvent != NULL);
1441 1441
1442 if (params.size() != 1) { 1442 if (params.size() != 1) {
1443 sError = L"AFDate_KeystrokeEx's parameters' size r not correct"; 1443 sError = L"AFDate_KeystrokeEx's parameters' size r not correct";
(...skipping 15 matching lines...) Expand all
1459 swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSPARSEDATE).c_str(), 1459 swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSPARSEDATE).c_str(),
1460 sFormat.c_str()); 1460 sFormat.c_str());
1461 Alert(pContext, swMsg.c_str()); 1461 Alert(pContext, swMsg.c_str());
1462 pEvent->Rc() = FALSE; 1462 pEvent->Rc() = FALSE;
1463 return TRUE; 1463 return TRUE;
1464 } 1464 }
1465 } 1465 }
1466 return TRUE; 1466 return TRUE;
1467 } 1467 }
1468 1468
1469 FX_BOOL CJS_PublicMethods::AFDate_Format(IFXJS_Context* cc, 1469 FX_BOOL CJS_PublicMethods::AFDate_Format(IJS_Context* cc,
1470 const CJS_Parameters& params, 1470 const CJS_Parameters& params,
1471 CJS_Value& vRet, 1471 CJS_Value& vRet,
1472 CFX_WideString& sError) { 1472 CFX_WideString& sError) {
1473 v8::Isolate* isolate = ::GetIsolate(cc); 1473 v8::Isolate* isolate = ::GetIsolate(cc);
1474 1474
1475 if (params.size() != 1) { 1475 if (params.size() != 1) {
1476 CJS_Context* pContext = (CJS_Context*)cc; 1476 CJS_Context* pContext = (CJS_Context*)cc;
1477 ASSERT(pContext != NULL); 1477 ASSERT(pContext != NULL);
1478 1478
1479 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); 1479 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
(...skipping 19 matching lines...) Expand all
1499 if (iIndex < 0 || (static_cast<size_t>(iIndex) >= FX_ArraySize(cFormats))) 1499 if (iIndex < 0 || (static_cast<size_t>(iIndex) >= FX_ArraySize(cFormats)))
1500 iIndex = 0; 1500 iIndex = 0;
1501 1501
1502 CJS_Parameters newParams; 1502 CJS_Parameters newParams;
1503 CJS_Value val(isolate, cFormats[iIndex]); 1503 CJS_Value val(isolate, cFormats[iIndex]);
1504 newParams.push_back(val); 1504 newParams.push_back(val);
1505 return AFDate_FormatEx(cc, newParams, vRet, sError); 1505 return AFDate_FormatEx(cc, newParams, vRet, sError);
1506 } 1506 }
1507 1507
1508 // AFDate_KeystrokeEx(cFormat) 1508 // AFDate_KeystrokeEx(cFormat)
1509 FX_BOOL CJS_PublicMethods::AFDate_Keystroke(IFXJS_Context* cc, 1509 FX_BOOL CJS_PublicMethods::AFDate_Keystroke(IJS_Context* cc,
1510 const CJS_Parameters& params, 1510 const CJS_Parameters& params,
1511 CJS_Value& vRet, 1511 CJS_Value& vRet,
1512 CFX_WideString& sError) { 1512 CFX_WideString& sError) {
1513 v8::Isolate* isolate = ::GetIsolate(cc); 1513 v8::Isolate* isolate = ::GetIsolate(cc);
1514 1514
1515 if (params.size() != 1) { 1515 if (params.size() != 1) {
1516 CJS_Context* pContext = (CJS_Context*)cc; 1516 CJS_Context* pContext = (CJS_Context*)cc;
1517 ASSERT(pContext != NULL); 1517 ASSERT(pContext != NULL);
1518 1518
1519 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); 1519 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
(...skipping 19 matching lines...) Expand all
1539 if (iIndex < 0 || (static_cast<size_t>(iIndex) >= FX_ArraySize(cFormats))) 1539 if (iIndex < 0 || (static_cast<size_t>(iIndex) >= FX_ArraySize(cFormats)))
1540 iIndex = 0; 1540 iIndex = 0;
1541 1541
1542 CJS_Parameters newParams; 1542 CJS_Parameters newParams;
1543 CJS_Value val(isolate, cFormats[iIndex]); 1543 CJS_Value val(isolate, cFormats[iIndex]);
1544 newParams.push_back(val); 1544 newParams.push_back(val);
1545 return AFDate_KeystrokeEx(cc, newParams, vRet, sError); 1545 return AFDate_KeystrokeEx(cc, newParams, vRet, sError);
1546 } 1546 }
1547 1547
1548 // function AFTime_Format(ptf) 1548 // function AFTime_Format(ptf)
1549 FX_BOOL CJS_PublicMethods::AFTime_Format(IFXJS_Context* cc, 1549 FX_BOOL CJS_PublicMethods::AFTime_Format(IJS_Context* cc,
1550 const CJS_Parameters& params, 1550 const CJS_Parameters& params,
1551 CJS_Value& vRet, 1551 CJS_Value& vRet,
1552 CFX_WideString& sError) { 1552 CFX_WideString& sError) {
1553 v8::Isolate* isolate = ::GetIsolate(cc); 1553 v8::Isolate* isolate = ::GetIsolate(cc);
1554 1554
1555 if (params.size() != 1) { 1555 if (params.size() != 1) {
1556 CJS_Context* pContext = (CJS_Context*)cc; 1556 CJS_Context* pContext = (CJS_Context*)cc;
1557 ASSERT(pContext != NULL); 1557 ASSERT(pContext != NULL);
1558 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); 1558 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
1559 return FALSE; 1559 return FALSE;
1560 } 1560 }
1561 1561
1562 int iIndex = params[0].ToInt(); 1562 int iIndex = params[0].ToInt();
1563 const FX_WCHAR* cFormats[] = {L"HH:MM", L"h:MM tt", L"HH:MM:ss", 1563 const FX_WCHAR* cFormats[] = {L"HH:MM", L"h:MM tt", L"HH:MM:ss",
1564 L"h:MM:ss tt"}; 1564 L"h:MM:ss tt"};
1565 1565
1566 if (iIndex < 0 || (static_cast<size_t>(iIndex) >= FX_ArraySize(cFormats))) 1566 if (iIndex < 0 || (static_cast<size_t>(iIndex) >= FX_ArraySize(cFormats)))
1567 iIndex = 0; 1567 iIndex = 0;
1568 1568
1569 CJS_Parameters newParams; 1569 CJS_Parameters newParams;
1570 CJS_Value val(isolate, cFormats[iIndex]); 1570 CJS_Value val(isolate, cFormats[iIndex]);
1571 newParams.push_back(val); 1571 newParams.push_back(val);
1572 return AFDate_FormatEx(cc, newParams, vRet, sError); 1572 return AFDate_FormatEx(cc, newParams, vRet, sError);
1573 } 1573 }
1574 1574
1575 FX_BOOL CJS_PublicMethods::AFTime_Keystroke(IFXJS_Context* cc, 1575 FX_BOOL CJS_PublicMethods::AFTime_Keystroke(IJS_Context* cc,
1576 const CJS_Parameters& params, 1576 const CJS_Parameters& params,
1577 CJS_Value& vRet, 1577 CJS_Value& vRet,
1578 CFX_WideString& sError) { 1578 CFX_WideString& sError) {
1579 v8::Isolate* isolate = ::GetIsolate(cc); 1579 v8::Isolate* isolate = ::GetIsolate(cc);
1580 if (params.size() != 1) { 1580 if (params.size() != 1) {
1581 CJS_Context* pContext = (CJS_Context*)cc; 1581 CJS_Context* pContext = (CJS_Context*)cc;
1582 ASSERT(pContext != NULL); 1582 ASSERT(pContext != NULL);
1583 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); 1583 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
1584 return FALSE; 1584 return FALSE;
1585 } 1585 }
1586 1586
1587 int iIndex = params[0].ToInt(); 1587 int iIndex = params[0].ToInt();
1588 const FX_WCHAR* cFormats[] = {L"HH:MM", L"h:MM tt", L"HH:MM:ss", 1588 const FX_WCHAR* cFormats[] = {L"HH:MM", L"h:MM tt", L"HH:MM:ss",
1589 L"h:MM:ss tt"}; 1589 L"h:MM:ss tt"};
1590 1590
1591 if (iIndex < 0 || (static_cast<size_t>(iIndex) >= FX_ArraySize(cFormats))) 1591 if (iIndex < 0 || (static_cast<size_t>(iIndex) >= FX_ArraySize(cFormats)))
1592 iIndex = 0; 1592 iIndex = 0;
1593 1593
1594 CJS_Parameters newParams; 1594 CJS_Parameters newParams;
1595 CJS_Value val(isolate, cFormats[iIndex]); 1595 CJS_Value val(isolate, cFormats[iIndex]);
1596 newParams.push_back(val); 1596 newParams.push_back(val);
1597 return AFDate_KeystrokeEx(cc, newParams, vRet, sError); 1597 return AFDate_KeystrokeEx(cc, newParams, vRet, sError);
1598 } 1598 }
1599 1599
1600 FX_BOOL CJS_PublicMethods::AFTime_FormatEx(IFXJS_Context* cc, 1600 FX_BOOL CJS_PublicMethods::AFTime_FormatEx(IJS_Context* cc,
1601 const CJS_Parameters& params, 1601 const CJS_Parameters& params,
1602 CJS_Value& vRet, 1602 CJS_Value& vRet,
1603 CFX_WideString& sError) { 1603 CFX_WideString& sError) {
1604 return AFDate_FormatEx(cc, params, vRet, sError); 1604 return AFDate_FormatEx(cc, params, vRet, sError);
1605 } 1605 }
1606 1606
1607 FX_BOOL CJS_PublicMethods::AFTime_KeystrokeEx(IFXJS_Context* cc, 1607 FX_BOOL CJS_PublicMethods::AFTime_KeystrokeEx(IJS_Context* cc,
1608 const CJS_Parameters& params, 1608 const CJS_Parameters& params,
1609 CJS_Value& vRet, 1609 CJS_Value& vRet,
1610 CFX_WideString& sError) { 1610 CFX_WideString& sError) {
1611 return AFDate_KeystrokeEx(cc, params, vRet, sError); 1611 return AFDate_KeystrokeEx(cc, params, vRet, sError);
1612 } 1612 }
1613 1613
1614 // function AFSpecial_Format(psf) 1614 // function AFSpecial_Format(psf)
1615 FX_BOOL CJS_PublicMethods::AFSpecial_Format(IFXJS_Context* cc, 1615 FX_BOOL CJS_PublicMethods::AFSpecial_Format(IJS_Context* cc,
1616 const CJS_Parameters& params, 1616 const CJS_Parameters& params,
1617 CJS_Value& vRet, 1617 CJS_Value& vRet,
1618 CFX_WideString& sError) { 1618 CFX_WideString& sError) {
1619 CJS_Context* pContext = (CJS_Context*)cc; 1619 CJS_Context* pContext = (CJS_Context*)cc;
1620 ASSERT(pContext != NULL); 1620 ASSERT(pContext != NULL);
1621 1621
1622 if (params.size() != 1) { 1622 if (params.size() != 1) {
1623 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); 1623 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
1624 return FALSE; 1624 return FALSE;
1625 } 1625 }
(...skipping 30 matching lines...) Expand all
1656 break; 1656 break;
1657 } 1657 }
1658 1658
1659 std::string strDes; 1659 std::string strDes;
1660 util::printx(cFormat, strSrc, strDes); 1660 util::printx(cFormat, strSrc, strDes);
1661 Value = CFX_WideString::FromLocal(strDes.c_str()); 1661 Value = CFX_WideString::FromLocal(strDes.c_str());
1662 return TRUE; 1662 return TRUE;
1663 } 1663 }
1664 1664
1665 // function AFSpecial_KeystrokeEx(mask) 1665 // function AFSpecial_KeystrokeEx(mask)
1666 FX_BOOL CJS_PublicMethods::AFSpecial_KeystrokeEx(IFXJS_Context* cc, 1666 FX_BOOL CJS_PublicMethods::AFSpecial_KeystrokeEx(IJS_Context* cc,
1667 const CJS_Parameters& params, 1667 const CJS_Parameters& params,
1668 CJS_Value& vRet, 1668 CJS_Value& vRet,
1669 CFX_WideString& sError) { 1669 CFX_WideString& sError) {
1670 CJS_Context* pContext = (CJS_Context*)cc; 1670 CJS_Context* pContext = (CJS_Context*)cc;
1671 ASSERT(pContext != NULL); 1671 ASSERT(pContext != NULL);
1672 CJS_EventHandler* pEvent = pContext->GetEventHandler(); 1672 CJS_EventHandler* pEvent = pContext->GetEventHandler();
1673 1673
1674 ASSERT(pEvent != NULL); 1674 ASSERT(pEvent != NULL);
1675 1675
1676 if (params.size() < 1) { 1676 if (params.size() < 1) {
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
1749 return TRUE; 1749 return TRUE;
1750 } 1750 }
1751 iIndexMask++; 1751 iIndexMask++;
1752 } 1752 }
1753 1753
1754 wideChange = wChange.c_str(); 1754 wideChange = wChange.c_str();
1755 return TRUE; 1755 return TRUE;
1756 } 1756 }
1757 1757
1758 // function AFSpecial_Keystroke(psf) 1758 // function AFSpecial_Keystroke(psf)
1759 FX_BOOL CJS_PublicMethods::AFSpecial_Keystroke(IFXJS_Context* cc, 1759 FX_BOOL CJS_PublicMethods::AFSpecial_Keystroke(IJS_Context* cc,
1760 const CJS_Parameters& params, 1760 const CJS_Parameters& params,
1761 CJS_Value& vRet, 1761 CJS_Value& vRet,
1762 CFX_WideString& sError) { 1762 CFX_WideString& sError) {
1763 v8::Isolate* isolate = ::GetIsolate(cc); 1763 v8::Isolate* isolate = ::GetIsolate(cc);
1764 1764
1765 CJS_Context* pContext = (CJS_Context*)cc; 1765 CJS_Context* pContext = (CJS_Context*)cc;
1766 ASSERT(pContext != NULL); 1766 ASSERT(pContext != NULL);
1767 CJS_EventHandler* pEvent = pContext->GetEventHandler(); 1767 CJS_EventHandler* pEvent = pContext->GetEventHandler();
1768 ASSERT(pEvent != NULL); 1768 ASSERT(pEvent != NULL);
1769 1769
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1807 break; 1807 break;
1808 } 1808 }
1809 1809
1810 CJS_Parameters params2; 1810 CJS_Parameters params2;
1811 CJS_Value vMask(isolate, cFormat.c_str()); 1811 CJS_Value vMask(isolate, cFormat.c_str());
1812 params2.push_back(vMask); 1812 params2.push_back(vMask);
1813 1813
1814 return AFSpecial_KeystrokeEx(cc, params2, vRet, sError); 1814 return AFSpecial_KeystrokeEx(cc, params2, vRet, sError);
1815 } 1815 }
1816 1816
1817 FX_BOOL CJS_PublicMethods::AFMergeChange(IFXJS_Context* cc, 1817 FX_BOOL CJS_PublicMethods::AFMergeChange(IJS_Context* cc,
1818 const CJS_Parameters& params, 1818 const CJS_Parameters& params,
1819 CJS_Value& vRet, 1819 CJS_Value& vRet,
1820 CFX_WideString& sError) { 1820 CFX_WideString& sError) {
1821 CJS_Context* pContext = (CJS_Context*)cc; 1821 CJS_Context* pContext = (CJS_Context*)cc;
1822 ASSERT(pContext != NULL); 1822 ASSERT(pContext != NULL);
1823 CJS_EventHandler* pEventHandler = pContext->GetEventHandler(); 1823 CJS_EventHandler* pEventHandler = pContext->GetEventHandler();
1824 ASSERT(pEventHandler != NULL); 1824 ASSERT(pEventHandler != NULL);
1825 1825
1826 if (params.size() != 1) { 1826 if (params.size() != 1) {
1827 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); 1827 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
(...skipping 21 matching lines...) Expand all
1849 postfix = swValue.Mid(pEventHandler->SelEnd(), 1849 postfix = swValue.Mid(pEventHandler->SelEnd(),
1850 swValue.GetLength() - pEventHandler->SelEnd()); 1850 swValue.GetLength() - pEventHandler->SelEnd());
1851 else 1851 else
1852 postfix = L""; 1852 postfix = L"";
1853 1853
1854 vRet = (prefix + pEventHandler->Change() + postfix).c_str(); 1854 vRet = (prefix + pEventHandler->Change() + postfix).c_str();
1855 1855
1856 return TRUE; 1856 return TRUE;
1857 } 1857 }
1858 1858
1859 FX_BOOL CJS_PublicMethods::AFParseDateEx(IFXJS_Context* cc, 1859 FX_BOOL CJS_PublicMethods::AFParseDateEx(IJS_Context* cc,
1860 const CJS_Parameters& params, 1860 const CJS_Parameters& params,
1861 CJS_Value& vRet, 1861 CJS_Value& vRet,
1862 CFX_WideString& sError) { 1862 CFX_WideString& sError) {
1863 CJS_Context* pContext = (CJS_Context*)cc; 1863 CJS_Context* pContext = (CJS_Context*)cc;
1864 ASSERT(pContext != NULL); 1864 ASSERT(pContext != NULL);
1865 1865
1866 if (params.size() != 2) { 1866 if (params.size() != 2) {
1867 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); 1867 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
1868 return FALSE; 1868 return FALSE;
1869 } 1869 }
1870 1870
1871 CFX_WideString sValue = params[0].ToCFXWideString(); 1871 CFX_WideString sValue = params[0].ToCFXWideString();
1872 CFX_WideString sFormat = params[1].ToCFXWideString(); 1872 CFX_WideString sFormat = params[1].ToCFXWideString();
1873 1873
1874 FX_BOOL bWrongFormat = FALSE; 1874 FX_BOOL bWrongFormat = FALSE;
1875 double dDate = MakeRegularDate(sValue, sFormat, bWrongFormat); 1875 double dDate = MakeRegularDate(sValue, sFormat, bWrongFormat);
1876 1876
1877 if (JS_PortIsNan(dDate)) { 1877 if (JS_PortIsNan(dDate)) {
1878 CFX_WideString swMsg; 1878 CFX_WideString swMsg;
1879 swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSPARSEDATE).c_str(), 1879 swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSPARSEDATE).c_str(),
1880 sFormat.c_str()); 1880 sFormat.c_str());
1881 Alert((CJS_Context*)cc, swMsg.c_str()); 1881 Alert((CJS_Context*)cc, swMsg.c_str());
1882 return FALSE; 1882 return FALSE;
1883 } 1883 }
1884 1884
1885 vRet = dDate; 1885 vRet = dDate;
1886 return TRUE; 1886 return TRUE;
1887 } 1887 }
1888 1888
1889 FX_BOOL CJS_PublicMethods::AFSimple(IFXJS_Context* cc, 1889 FX_BOOL CJS_PublicMethods::AFSimple(IJS_Context* cc,
1890 const CJS_Parameters& params, 1890 const CJS_Parameters& params,
1891 CJS_Value& vRet, 1891 CJS_Value& vRet,
1892 CFX_WideString& sError) { 1892 CFX_WideString& sError) {
1893 if (params.size() != 3) { 1893 if (params.size() != 3) {
1894 CJS_Context* pContext = (CJS_Context*)cc; 1894 CJS_Context* pContext = (CJS_Context*)cc;
1895 ASSERT(pContext != NULL); 1895 ASSERT(pContext != NULL);
1896 1896
1897 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); 1897 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
1898 return FALSE; 1898 return FALSE;
1899 } 1899 }
1900 1900
1901 vRet = (double)AF_Simple(params[0].ToCFXWideString().c_str(), 1901 vRet = (double)AF_Simple(params[0].ToCFXWideString().c_str(),
1902 params[1].ToDouble(), params[2].ToDouble()); 1902 params[1].ToDouble(), params[2].ToDouble());
1903 return TRUE; 1903 return TRUE;
1904 } 1904 }
1905 1905
1906 FX_BOOL CJS_PublicMethods::AFMakeNumber(IFXJS_Context* cc, 1906 FX_BOOL CJS_PublicMethods::AFMakeNumber(IJS_Context* cc,
1907 const CJS_Parameters& params, 1907 const CJS_Parameters& params,
1908 CJS_Value& vRet, 1908 CJS_Value& vRet,
1909 CFX_WideString& sError) { 1909 CFX_WideString& sError) {
1910 if (params.size() != 1) { 1910 if (params.size() != 1) {
1911 CJS_Context* pContext = (CJS_Context*)cc; 1911 CJS_Context* pContext = (CJS_Context*)cc;
1912 ASSERT(pContext != NULL); 1912 ASSERT(pContext != NULL);
1913 1913
1914 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); 1914 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
1915 return FALSE; 1915 return FALSE;
1916 } 1916 }
1917 vRet = ParseStringToNumber(params[0].ToCFXWideString().c_str()); 1917 vRet = ParseStringToNumber(params[0].ToCFXWideString().c_str());
1918 return TRUE; 1918 return TRUE;
1919 } 1919 }
1920 1920
1921 FX_BOOL CJS_PublicMethods::AFSimple_Calculate(IFXJS_Context* cc, 1921 FX_BOOL CJS_PublicMethods::AFSimple_Calculate(IJS_Context* cc,
1922 const CJS_Parameters& params, 1922 const CJS_Parameters& params,
1923 CJS_Value& vRet, 1923 CJS_Value& vRet,
1924 CFX_WideString& sError) { 1924 CFX_WideString& sError) {
1925 v8::Isolate* isolate = ::GetIsolate(cc); 1925 v8::Isolate* isolate = ::GetIsolate(cc);
1926 1926
1927 CJS_Context* pContext = (CJS_Context*)cc; 1927 CJS_Context* pContext = (CJS_Context*)cc;
1928 ASSERT(pContext != NULL); 1928 ASSERT(pContext != NULL);
1929 1929
1930 if (params.size() != 2) { 1930 if (params.size() != 2) {
1931 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); 1931 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
2025 CJS_Value jsValue(isolate, dValue); 2025 CJS_Value jsValue(isolate, dValue);
2026 if (pContext->GetEventHandler()->m_pValue) 2026 if (pContext->GetEventHandler()->m_pValue)
2027 pContext->GetEventHandler()->Value() = jsValue.ToCFXWideString(); 2027 pContext->GetEventHandler()->Value() = jsValue.ToCFXWideString();
2028 2028
2029 return TRUE; 2029 return TRUE;
2030 } 2030 }
2031 2031
2032 /* This function validates the current event to ensure that its value is 2032 /* This function validates the current event to ensure that its value is
2033 ** within the specified range. */ 2033 ** within the specified range. */
2034 2034
2035 FX_BOOL CJS_PublicMethods::AFRange_Validate(IFXJS_Context* cc, 2035 FX_BOOL CJS_PublicMethods::AFRange_Validate(IJS_Context* cc,
2036 const CJS_Parameters& params, 2036 const CJS_Parameters& params,
2037 CJS_Value& vRet, 2037 CJS_Value& vRet,
2038 CFX_WideString& sError) { 2038 CFX_WideString& sError) {
2039 CJS_Context* pContext = (CJS_Context*)cc; 2039 CJS_Context* pContext = (CJS_Context*)cc;
2040 ASSERT(pContext != NULL); 2040 ASSERT(pContext != NULL);
2041 CJS_EventHandler* pEvent = pContext->GetEventHandler(); 2041 CJS_EventHandler* pEvent = pContext->GetEventHandler();
2042 ASSERT(pEvent != NULL); 2042 ASSERT(pEvent != NULL);
2043 2043
2044 if (params.size() != 4) { 2044 if (params.size() != 4) {
2045 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); 2045 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
(...skipping 26 matching lines...) Expand all
2072 params[3].ToCFXWideString().c_str()); 2072 params[3].ToCFXWideString().c_str());
2073 } 2073 }
2074 2074
2075 if (!swMsg.IsEmpty()) { 2075 if (!swMsg.IsEmpty()) {
2076 Alert(pContext, swMsg.c_str()); 2076 Alert(pContext, swMsg.c_str());
2077 pEvent->Rc() = FALSE; 2077 pEvent->Rc() = FALSE;
2078 } 2078 }
2079 return TRUE; 2079 return TRUE;
2080 } 2080 }
2081 2081
2082 FX_BOOL CJS_PublicMethods::AFExtractNums(IFXJS_Context* cc, 2082 FX_BOOL CJS_PublicMethods::AFExtractNums(IJS_Context* cc,
2083 const CJS_Parameters& params, 2083 const CJS_Parameters& params,
2084 CJS_Value& vRet, 2084 CJS_Value& vRet,
2085 CFX_WideString& sError) { 2085 CFX_WideString& sError) {
2086 v8::Isolate* isolate = ::GetIsolate(cc); 2086 v8::Isolate* isolate = ::GetIsolate(cc);
2087 CJS_Context* pContext = (CJS_Context*)cc; 2087 CJS_Context* pContext = (CJS_Context*)cc;
2088 ASSERT(pContext != NULL); 2088 ASSERT(pContext != NULL);
2089 2089
2090 if (params.size() != 1) { 2090 if (params.size() != 1) {
2091 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); 2091 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
2092 return FALSE; 2092 return FALSE;
(...skipping 25 matching lines...) Expand all
2118 nums.SetElement(nIndex, CJS_Value(isolate, sPart.c_str())); 2118 nums.SetElement(nIndex, CJS_Value(isolate, sPart.c_str()));
2119 } 2119 }
2120 2120
2121 if (nums.GetLength() > 0) 2121 if (nums.GetLength() > 0)
2122 vRet = nums; 2122 vRet = nums;
2123 else 2123 else
2124 vRet.SetNull(); 2124 vRet.SetNull();
2125 2125
2126 return TRUE; 2126 return TRUE;
2127 } 2127 }
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