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

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

Issue 1936383002: Remove std::string usage in PublicMethods.cpp. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: Created 4 years, 7 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 | « no previous file | no next file » | 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 "fpdfsdk/javascript/PublicMethods.h" 7 #include "fpdfsdk/javascript/PublicMethods.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <string>
11 #include <vector> 10 #include <vector>
12 11
13 #include "core/fxcrt/include/fx_ext.h" 12 #include "core/fxcrt/include/fx_ext.h"
14 #include "fpdfsdk/include/fsdk_mgr.h" 13 #include "fpdfsdk/include/fsdk_mgr.h"
15 #include "fpdfsdk/javascript/Field.h" 14 #include "fpdfsdk/javascript/Field.h"
16 #include "fpdfsdk/javascript/JS_Define.h" 15 #include "fpdfsdk/javascript/JS_Define.h"
17 #include "fpdfsdk/javascript/JS_EventHandler.h" 16 #include "fpdfsdk/javascript/JS_EventHandler.h"
18 #include "fpdfsdk/javascript/JS_Object.h" 17 #include "fpdfsdk/javascript/JS_Object.h"
19 #include "fpdfsdk/javascript/JS_Value.h" 18 #include "fpdfsdk/javascript/JS_Value.h"
20 #include "fpdfsdk/javascript/cjs_context.h" 19 #include "fpdfsdk/javascript/cjs_context.h"
(...skipping 711 matching lines...) Expand 10 before | Expand all | Expand 10 after
732 731
733 CFX_WideString& Value = pEvent->Value(); 732 CFX_WideString& Value = pEvent->Value();
734 CFX_ByteString strValue = StrTrim(CFX_ByteString::FromUnicode(Value)); 733 CFX_ByteString strValue = StrTrim(CFX_ByteString::FromUnicode(Value));
735 if (strValue.IsEmpty()) 734 if (strValue.IsEmpty())
736 return TRUE; 735 return TRUE;
737 736
738 int iDec = params[0].ToInt(); 737 int iDec = params[0].ToInt();
739 int iSepStyle = params[1].ToInt(); 738 int iSepStyle = params[1].ToInt();
740 int iNegStyle = params[2].ToInt(); 739 int iNegStyle = params[2].ToInt();
741 // params[3] is iCurrStyle, it's not used. 740 // params[3] is iCurrStyle, it's not used.
742 std::wstring wstrCurrency(params[4].ToCFXWideString().c_str()); 741 CFX_WideString wstrCurrency = params[4].ToCFXWideString();
743 FX_BOOL bCurrencyPrepend = params[5].ToBool(); 742 FX_BOOL bCurrencyPrepend = params[5].ToBool();
744 743
745 if (iDec < 0) 744 if (iDec < 0)
746 iDec = -iDec; 745 iDec = -iDec;
747 746
748 if (iSepStyle < 0 || iSepStyle > 3) 747 if (iSepStyle < 0 || iSepStyle > 3)
749 iSepStyle = 0; 748 iSepStyle = 0;
750 749
751 if (iNegStyle < 0 || iNegStyle > 3) 750 if (iNegStyle < 0 || iNegStyle > 3)
752 iNegStyle = 0; 751 iNegStyle = 0;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
805 cSeperator = '.'; 804 cSeperator = '.';
806 805
807 for (int iDecPositive = iDec2 - 3; iDecPositive > 0; iDecPositive -= 3) { 806 for (int iDecPositive = iDec2 - 3; iDecPositive > 0; iDecPositive -= 3) {
808 strValue.Insert(iDecPositive, cSeperator); 807 strValue.Insert(iDecPositive, cSeperator);
809 iMax++; 808 iMax++;
810 } 809 }
811 } 810 }
812 811
813 // for processing currency string 812 // for processing currency string
814 Value = CFX_WideString::FromLocal(strValue.AsStringC()); 813 Value = CFX_WideString::FromLocal(strValue.AsStringC());
815 std::wstring strValue2 = Value.c_str();
816 814
817 if (bCurrencyPrepend) 815 if (bCurrencyPrepend)
818 strValue2 = wstrCurrency + strValue2; 816 Value = wstrCurrency + Value;
819 else 817 else
820 strValue2 = strValue2 + wstrCurrency; 818 Value = Value + wstrCurrency;
821 819
822 // for processing negative style 820 // for processing negative style
823 if (iNegative) { 821 if (iNegative) {
824 if (iNegStyle == 0) { 822 if (iNegStyle == 0) {
825 strValue2.insert(0, L"-"); 823 Value = L"-" + Value;
826 } 824 } else if (iNegStyle == 2 || iNegStyle == 3) {
827 if (iNegStyle == 2 || iNegStyle == 3) { 825 Value = L"(" + Value + L")";
828 strValue2.insert(0, L"(");
829 strValue2.insert(strValue2.length(), L")");
830 } 826 }
831 if (iNegStyle == 1 || iNegStyle == 3) { 827 if (iNegStyle == 1 || iNegStyle == 3) {
832 if (Field* fTarget = pEvent->Target_Field()) { 828 if (Field* fTarget = pEvent->Target_Field()) {
833 CJS_Array arColor(pRuntime); 829 CJS_Array arColor(pRuntime);
834 CJS_Value vColElm(pRuntime); 830 CJS_Value vColElm(pRuntime);
835 vColElm = L"RGB"; 831 vColElm = L"RGB";
836 arColor.SetElement(0, vColElm); 832 arColor.SetElement(0, vColElm);
837 vColElm = 1; 833 vColElm = 1;
838 arColor.SetElement(1, vColElm); 834 arColor.SetElement(1, vColElm);
839 vColElm = 0; 835 vColElm = 0;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
875 if (crColor != crProp) { 871 if (crColor != crProp) {
876 CJS_PropValue vProp2(pRuntime); 872 CJS_PropValue vProp2(pRuntime);
877 vProp2.StartGetting(); 873 vProp2.StartGetting();
878 vProp2 << arColor; 874 vProp2 << arColor;
879 vProp2.StartSetting(); 875 vProp2.StartSetting();
880 fTarget->textColor(cc, vProp2, sError); 876 fTarget->textColor(cc, vProp2, sError);
881 } 877 }
882 } 878 }
883 } 879 }
884 } 880 }
885 Value = strValue2.c_str();
886 #endif 881 #endif
887 return TRUE; 882 return TRUE;
888 } 883 }
889 884
890 // function AFNumber_Keystroke(nDec, sepStyle, negStyle, currStyle, strCurrency, 885 // function AFNumber_Keystroke(nDec, sepStyle, negStyle, currStyle, strCurrency,
891 // bCurrencyPrepend) 886 // bCurrencyPrepend)
892 FX_BOOL CJS_PublicMethods::AFNumber_Keystroke( 887 FX_BOOL CJS_PublicMethods::AFNumber_Keystroke(
893 IJS_Context* cc, 888 IJS_Context* cc,
894 const std::vector<CJS_Value>& params, 889 const std::vector<CJS_Value>& params,
895 CJS_Value& vRet, 890 CJS_Value& vRet,
896 CFX_WideString& sError) { 891 CFX_WideString& sError) {
897 CJS_Context* pContext = (CJS_Context*)cc; 892 CJS_Context* pContext = (CJS_Context*)cc;
898 CJS_EventHandler* pEvent = pContext->GetEventHandler(); 893 CJS_EventHandler* pEvent = pContext->GetEventHandler();
899 894
900 if (params.size() < 2) 895 if (params.size() < 2)
901 return FALSE; 896 return FALSE;
902 int iSepStyle = params[1].ToInt();
903 897
904 if (iSepStyle < 0 || iSepStyle > 3)
905 iSepStyle = 0;
906 if (!pEvent->m_pValue) 898 if (!pEvent->m_pValue)
907 return FALSE; 899 return FALSE;
900
908 CFX_WideString& val = pEvent->Value(); 901 CFX_WideString& val = pEvent->Value();
909 CFX_WideString& w_strChange = pEvent->Change(); 902 CFX_WideString& w_strChange = pEvent->Change();
910 CFX_WideString w_strValue = val; 903 CFX_WideString w_strValue = val;
Tom Sepez 2016/05/03 23:34:30 nit: can we lose the _ in these local names?
Lei Zhang 2016/05/09 19:22:35 Done.
911 904
912 if (pEvent->WillCommit()) { 905 if (pEvent->WillCommit()) {
913 CFX_WideString wstrChange = w_strChange; 906 CFX_WideString wstrChange = w_strChange;
914 CFX_WideString wstrValue = StrTrim(w_strValue); 907 CFX_WideString wstrValue = StrTrim(w_strValue);
915 if (wstrValue.IsEmpty()) 908 if (wstrValue.IsEmpty())
916 return TRUE; 909 return TRUE;
917 910
918 CFX_WideString swTemp = wstrValue; 911 CFX_WideString swTemp = wstrValue;
919 swTemp.Replace(L",", L"."); 912 swTemp.Replace(L",", L".");
920 if (!IsNumber(swTemp.c_str())) { 913 if (!IsNumber(swTemp.c_str())) {
921 pEvent->Rc() = FALSE; 914 pEvent->Rc() = FALSE;
922 sError = JSGetStringFromID(pContext, IDS_STRING_JSAFNUMBER_KEYSTROKE); 915 sError = JSGetStringFromID(pContext, IDS_STRING_JSAFNUMBER_KEYSTROKE);
923 Alert(pContext, sError.c_str()); 916 Alert(pContext, sError.c_str());
924 return TRUE;
925 } 917 }
926 return TRUE; // it happens after the last keystroke and before validating, 918 return TRUE; // it happens after the last keystroke and before validating,
927 } 919 }
928 920
929 std::wstring w_strValue2 = w_strValue.c_str(); 921 CFX_WideString w_strSelected;
930 std::wstring w_strChange2 = w_strChange.c_str(); 922 if (pEvent->SelStart() != -1) {
931 std::wstring w_strSelected; 923 w_strSelected = w_strValue.Mid(pEvent->SelStart(),
932 if (-1 != pEvent->SelStart()) 924 pEvent->SelEnd() - pEvent->SelStart());
933 w_strSelected = w_strValue2.substr(pEvent->SelStart(), 925 }
934 (pEvent->SelEnd() - pEvent->SelStart())); 926
935 bool bHasSign = (w_strValue2.find('-') != std::wstring::npos) && 927 bool bHasSign = w_strValue.Find(L'-') != -1 && w_strSelected.Find(L'-') == -1;
936 (w_strSelected.find('-') == std::wstring::npos);
937 if (bHasSign) { 928 if (bHasSign) {
938 // can't insert "change" in front to sign postion. 929 // can't insert "change" in front to sign postion.
939 if (pEvent->SelStart() == 0) { 930 if (pEvent->SelStart() == 0) {
940 FX_BOOL& bRc = pEvent->Rc(); 931 FX_BOOL& bRc = pEvent->Rc();
941 bRc = FALSE; 932 bRc = FALSE;
942 return TRUE; 933 return TRUE;
943 } 934 }
944 } 935 }
945 936
946 char cSep = L'.'; 937 int iSepStyle = params[1].ToInt();
938 if (iSepStyle < 0 || iSepStyle > 3)
939 iSepStyle = 0;
940 const FX_WCHAR cSep = iSepStyle < 2 ? L'.' : L',';
947 941
948 switch (iSepStyle) { 942 bool bHasSep = w_strValue.Find(cSep) != -1;
949 case 0: 943 for (FX_STRSIZE i = 0; i < w_strChange.GetLength(); ++i) {
950 case 1: 944 if (w_strChange[i] == cSep) {
951 cSep = L'.';
952 break;
953 case 2:
954 case 3:
955 cSep = L',';
956 break;
957 }
958
959 bool bHasSep = (w_strValue2.find(cSep) != std::wstring::npos);
960 for (std::wstring::iterator it = w_strChange2.begin();
961 it != w_strChange2.end(); it++) {
962 if (*it == cSep) {
963 if (bHasSep) { 945 if (bHasSep) {
964 FX_BOOL& bRc = pEvent->Rc(); 946 FX_BOOL& bRc = pEvent->Rc();
965 bRc = FALSE; 947 bRc = FALSE;
966 return TRUE; 948 return TRUE;
967 } 949 }
968 bHasSep = TRUE; 950 bHasSep = TRUE;
969 continue; 951 continue;
970 } 952 }
971 if (*it == L'-') { 953 if (w_strChange[i] == L'-') {
972 if (bHasSign) { 954 if (bHasSign) {
973 FX_BOOL& bRc = pEvent->Rc(); 955 FX_BOOL& bRc = pEvent->Rc();
974 bRc = FALSE; 956 bRc = FALSE;
975 return TRUE; 957 return TRUE;
976 } 958 }
977 // sign's position is not correct 959 // sign's position is not correct
978 if (it != w_strChange2.begin()) { 960 if (i != 0) {
979 FX_BOOL& bRc = pEvent->Rc(); 961 FX_BOOL& bRc = pEvent->Rc();
980 bRc = FALSE; 962 bRc = FALSE;
981 return TRUE; 963 return TRUE;
982 } 964 }
983 if (pEvent->SelStart() != 0) { 965 if (pEvent->SelStart() != 0) {
984 FX_BOOL& bRc = pEvent->Rc(); 966 FX_BOOL& bRc = pEvent->Rc();
985 bRc = FALSE; 967 bRc = FALSE;
986 return TRUE; 968 return TRUE;
987 } 969 }
988 bHasSign = TRUE; 970 bHasSign = TRUE;
989 continue; 971 continue;
990 } 972 }
991 973
992 if (!FXSYS_iswdigit(*it)) { 974 if (!FXSYS_iswdigit(w_strChange[i])) {
993 FX_BOOL& bRc = pEvent->Rc(); 975 FX_BOOL& bRc = pEvent->Rc();
994 bRc = FALSE; 976 bRc = FALSE;
995 return TRUE; 977 return TRUE;
996 } 978 }
997 } 979 }
998 980
999 std::wstring w_prefix = w_strValue2.substr(0, pEvent->SelStart()); 981 CFX_WideString w_prefix = w_strValue.Mid(0, pEvent->SelStart());
1000 std::wstring w_postfix; 982 CFX_WideString w_postfix;
1001 if (pEvent->SelEnd() < (int)w_strValue2.length()) 983 if (pEvent->SelEnd() < w_strValue.GetLength())
1002 w_postfix = w_strValue2.substr(pEvent->SelEnd()); 984 w_postfix = w_strValue.Mid(pEvent->SelEnd());
1003 w_strValue2 = w_prefix + w_strChange2 + w_postfix; 985 val = w_prefix + w_strChange + w_postfix;
1004 w_strValue = w_strValue2.c_str();
1005 val = w_strValue;
1006 return TRUE; 986 return TRUE;
1007 } 987 }
1008 988
1009 // function AFPercent_Format(nDec, sepStyle) 989 // function AFPercent_Format(nDec, sepStyle)
1010 FX_BOOL CJS_PublicMethods::AFPercent_Format( 990 FX_BOOL CJS_PublicMethods::AFPercent_Format(
1011 IJS_Context* cc, 991 IJS_Context* cc,
1012 const std::vector<CJS_Value>& params, 992 const std::vector<CJS_Value>& params,
1013 CJS_Value& vRet, 993 CJS_Value& vRet,
1014 CFX_WideString& sError) { 994 CFX_WideString& sError) {
1015 #if _FX_OS_ != _FX_ANDROID_ 995 #if _FX_OS_ != _FX_ANDROID_
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
1433 } 1413 }
1434 1414
1435 if (!pEvent->m_pValue) 1415 if (!pEvent->m_pValue)
1436 return FALSE; 1416 return FALSE;
1437 CFX_WideString& valEvent = pEvent->Value(); 1417 CFX_WideString& valEvent = pEvent->Value();
1438 1418
1439 CFX_WideString wstrMask = params[0].ToCFXWideString(); 1419 CFX_WideString wstrMask = params[0].ToCFXWideString();
1440 if (wstrMask.IsEmpty()) 1420 if (wstrMask.IsEmpty())
1441 return TRUE; 1421 return TRUE;
1442 1422
1443 const size_t wstrMaskLen = wstrMask.GetLength(); 1423 if (pEvent->WillCommit()) {
1444 const std::wstring wstrValue = valEvent.c_str(); 1424 if (valEvent.IsEmpty())
1425 return TRUE;
1445 1426
1446 if (pEvent->WillCommit()) { 1427 FX_STRSIZE iIndexMask = 0;
1447 if (wstrValue.empty()) 1428 for (; iIndexMask < valEvent.GetLength(); ++iIndexMask) {
1448 return TRUE; 1429 if (!maskSatisfied(valEvent[iIndexMask], wstrMask[iIndexMask]))
1449 size_t iIndexMask = 0;
1450 for (const auto& w_Value : wstrValue) {
1451 if (!maskSatisfied(w_Value, wstrMask[iIndexMask]))
1452 break; 1430 break;
1453 iIndexMask++;
1454 } 1431 }
1455 1432
1456 if (iIndexMask != wstrMaskLen || 1433 if (iIndexMask != wstrMask.GetLength() ||
1457 (iIndexMask != wstrValue.size() && wstrMaskLen != 0)) { 1434 (iIndexMask != valEvent.GetLength() && wstrMask.GetLength() != 0)) {
1458 Alert( 1435 Alert(
1459 pContext, 1436 pContext,
1460 JSGetStringFromID(pContext, IDS_STRING_JSAFNUMBER_KEYSTROKE).c_str()); 1437 JSGetStringFromID(pContext, IDS_STRING_JSAFNUMBER_KEYSTROKE).c_str());
1461 pEvent->Rc() = FALSE; 1438 pEvent->Rc() = FALSE;
1462 } 1439 }
1463 return TRUE; 1440 return TRUE;
1464 } 1441 }
1465 1442
1466 CFX_WideString& wideChange = pEvent->Change(); 1443 CFX_WideString& wideChange = pEvent->Change();
1467 std::wstring wChange = wideChange.c_str(); 1444 if (wideChange.IsEmpty())
1468 if (wChange.empty())
1469 return TRUE; 1445 return TRUE;
1470 1446
1471 size_t iIndexMask = pEvent->SelStart(); 1447 CFX_WideString wChange = wideChange;
1472 1448 FX_STRSIZE iIndexMask = pEvent->SelStart();
1473 size_t combined_len = wstrValue.length() + wChange.length() - 1449 FX_STRSIZE combined_len = valEvent.GetLength() + wChange.GetLength() +
1474 (pEvent->SelEnd() - pEvent->SelStart()); 1450 pEvent->SelStart() - pEvent->SelEnd();
1475 if (combined_len > wstrMaskLen) { 1451 if (combined_len > wstrMask.GetLength()) {
1476 Alert(pContext, 1452 Alert(pContext,
1477 JSGetStringFromID(pContext, IDS_STRING_JSPARAM_TOOLONG).c_str()); 1453 JSGetStringFromID(pContext, IDS_STRING_JSPARAM_TOOLONG).c_str());
1478 pEvent->Rc() = FALSE; 1454 pEvent->Rc() = FALSE;
1479 return TRUE; 1455 return TRUE;
1480 } 1456 }
1481 1457
1482 if (iIndexMask >= wstrMaskLen && (!wChange.empty())) { 1458 if (iIndexMask >= wstrMask.GetLength() && !wChange.IsEmpty()) {
1483 Alert(pContext, 1459 Alert(pContext,
1484 JSGetStringFromID(pContext, IDS_STRING_JSPARAM_TOOLONG).c_str()); 1460 JSGetStringFromID(pContext, IDS_STRING_JSPARAM_TOOLONG).c_str());
1485 pEvent->Rc() = FALSE; 1461 pEvent->Rc() = FALSE;
1486 return TRUE; 1462 return TRUE;
1487 } 1463 }
1488 1464
1489 for (std::wstring::iterator it = wChange.begin(); it != wChange.end(); it++) { 1465 for (FX_STRSIZE i = 0; i < wChange.GetLength(); ++i) {
1490 if (iIndexMask >= wstrMaskLen) { 1466 if (iIndexMask >= wstrMask.GetLength()) {
1491 Alert(pContext, 1467 Alert(pContext,
1492 JSGetStringFromID(pContext, IDS_STRING_JSPARAM_TOOLONG).c_str()); 1468 JSGetStringFromID(pContext, IDS_STRING_JSPARAM_TOOLONG).c_str());
1493 pEvent->Rc() = FALSE; 1469 pEvent->Rc() = FALSE;
1494 return TRUE; 1470 return TRUE;
1495 } 1471 }
1496 wchar_t w_Mask = wstrMask[iIndexMask]; 1472 FX_WCHAR w_Mask = wstrMask[iIndexMask];
1497 if (!isReservedMaskChar(w_Mask)) { 1473 if (!isReservedMaskChar(w_Mask))
1498 *it = w_Mask; 1474 wChange.SetAt(i, w_Mask);
1499 } 1475
1500 wchar_t w_Change = *it; 1476 if (!maskSatisfied(wChange[i], w_Mask)) {
1501 if (!maskSatisfied(w_Change, w_Mask)) {
1502 pEvent->Rc() = FALSE; 1477 pEvent->Rc() = FALSE;
1503 return TRUE; 1478 return TRUE;
1504 } 1479 }
1505 iIndexMask++; 1480 iIndexMask++;
1506 } 1481 }
1507 1482 wideChange = wChange;
1508 wideChange = wChange.c_str();
1509 return TRUE; 1483 return TRUE;
1510 } 1484 }
1511 1485
1512 // function AFSpecial_Keystroke(psf) 1486 // function AFSpecial_Keystroke(psf)
1513 FX_BOOL CJS_PublicMethods::AFSpecial_Keystroke( 1487 FX_BOOL CJS_PublicMethods::AFSpecial_Keystroke(
1514 IJS_Context* cc, 1488 IJS_Context* cc,
1515 const std::vector<CJS_Value>& params, 1489 const std::vector<CJS_Value>& params,
1516 CJS_Value& vRet, 1490 CJS_Value& vRet,
1517 CFX_WideString& sError) { 1491 CFX_WideString& sError) {
1518 CJS_Context* pContext = (CJS_Context*)cc; 1492 CJS_Context* pContext = (CJS_Context*)cc;
1519 if (params.size() != 1) { 1493 if (params.size() != 1) {
1520 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); 1494 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
1521 return FALSE; 1495 return FALSE;
1522 } 1496 }
1523 1497
1524 CJS_EventHandler* pEvent = pContext->GetEventHandler(); 1498 CJS_EventHandler* pEvent = pContext->GetEventHandler();
1525 if (!pEvent->m_pValue) 1499 if (!pEvent->m_pValue)
1526 return FALSE; 1500 return FALSE;
1527 1501
1528 std::string cFormat; 1502 const char* cFormat = "";
1529 int iIndex = params[0].ToInt(); 1503 switch (params[0].ToInt()) {
1530 CFX_WideString& val = pEvent->Value();
1531 std::string strSrc = CFX_ByteString::FromUnicode(val).c_str();
1532 std::wstring wstrChange = pEvent->Change().c_str();
1533
1534 switch (iIndex) {
1535 case 0: 1504 case 0:
1536 cFormat = "99999"; 1505 cFormat = "99999";
1537 break; 1506 break;
1538 case 1: 1507 case 1:
1539 cFormat = "999999999"; 1508 cFormat = "999999999";
1540 break; 1509 break;
1541 case 2: 1510 case 2:
1542 if (strSrc.length() + wstrChange.length() > 7) 1511 if (pEvent->Value().GetLength() + pEvent->Change().GetLength() > 7)
1543 cFormat = "9999999999"; 1512 cFormat = "9999999999";
1544 else 1513 else
1545 cFormat = "9999999"; 1514 cFormat = "9999999";
1546 break; 1515 break;
1547 case 3: 1516 case 3:
1548 cFormat = "999999999"; 1517 cFormat = "999999999";
1549 break; 1518 break;
1550 } 1519 }
1551 1520
1552 std::vector<CJS_Value> params2; 1521 std::vector<CJS_Value> params2;
1553 params2.push_back(CJS_Value(CJS_Runtime::FromContext(cc), cFormat.c_str())); 1522 params2.push_back(CJS_Value(CJS_Runtime::FromContext(cc), cFormat));
1554 return AFSpecial_KeystrokeEx(cc, params2, vRet, sError); 1523 return AFSpecial_KeystrokeEx(cc, params2, vRet, sError);
1555 } 1524 }
1556 1525
1557 FX_BOOL CJS_PublicMethods::AFMergeChange(IJS_Context* cc, 1526 FX_BOOL CJS_PublicMethods::AFMergeChange(IJS_Context* cc,
1558 const std::vector<CJS_Value>& params, 1527 const std::vector<CJS_Value>& params,
1559 CJS_Value& vRet, 1528 CJS_Value& vRet,
1560 CFX_WideString& sError) { 1529 CFX_WideString& sError) {
1561 CJS_Context* pContext = (CJS_Context*)cc; 1530 CJS_Context* pContext = (CJS_Context*)cc;
1562 CJS_EventHandler* pEventHandler = pContext->GetEventHandler(); 1531 CJS_EventHandler* pEventHandler = pContext->GetEventHandler();
1563 1532
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
1842 nums.SetElement(nIndex, CJS_Value(pRuntime, sPart.c_str())); 1811 nums.SetElement(nIndex, CJS_Value(pRuntime, sPart.c_str()));
1843 } 1812 }
1844 1813
1845 if (nums.GetLength() > 0) 1814 if (nums.GetLength() > 0)
1846 vRet = nums; 1815 vRet = nums;
1847 else 1816 else
1848 vRet.SetNull(); 1817 vRet.SetNull();
1849 1818
1850 return TRUE; 1819 return TRUE;
1851 } 1820 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698