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

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

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