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

Side by Side Diff: xfa/fxfa/fm2js/xfa_fm2jscontext.cpp

Issue 2467203003: Remove FX_BOOL from xfa. (Closed)
Patch Set: Created 4 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 | « xfa/fxfa/fm2js/xfa_fm2jscontext.h ('k') | xfa/fxfa/fm2js/xfa_fmparse.cpp » ('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 "xfa/fxfa/fm2js/xfa_fm2jscontext.h" 7 #include "xfa/fxfa/fm2js/xfa_fm2jscontext.h"
8 8
9 #include <time.h> 9 #include <time.h>
10 10
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 255, 6, 255, 255, 255, 255, 255, 7, 255, 255, 255, 370 255, 6, 255, 255, 255, 255, 255, 7, 255, 255, 255,
371 255, 255, 1, 17, 255, 255, 255, 255, 255, 255, 255, 371 255, 255, 1, 17, 255, 255, 255, 255, 255, 255, 255,
372 }; 372 };
373 static_assert(FX_ArraySize(g_sAltTable_Time) == L'a' - L'A' + 1, 373 static_assert(FX_ArraySize(g_sAltTable_Time) == L'a' - L'A' + 1,
374 "Invalid g_sAltTable_Time size."); 374 "Invalid g_sAltTable_Time size.");
375 375
376 void AlternateDateTimeSymbols(CFX_WideString& wsPattern, 376 void AlternateDateTimeSymbols(CFX_WideString& wsPattern,
377 const CFX_WideString& wsAltSymbols, 377 const CFX_WideString& wsAltSymbols,
378 const uint8_t* pAltTable) { 378 const uint8_t* pAltTable) {
379 int32_t nLength = wsPattern.GetLength(); 379 int32_t nLength = wsPattern.GetLength();
380 FX_BOOL bInConstRange = FALSE; 380 bool bInConstRange = false;
381 FX_BOOL bEscape = FALSE; 381 bool bEscape = false;
382 int32_t i = 0; 382 int32_t i = 0;
383 while (i < nLength) { 383 while (i < nLength) {
384 FX_WCHAR wc = wsPattern[i]; 384 FX_WCHAR wc = wsPattern[i];
385 if (wc == L'\'') { 385 if (wc == L'\'') {
386 bInConstRange = !bInConstRange; 386 bInConstRange = !bInConstRange;
387 if (bEscape) { 387 if (bEscape) {
388 i++; 388 i++;
389 } else { 389 } else {
390 wsPattern.Delete(i); 390 wsPattern.Delete(i);
391 nLength--; 391 nLength--;
392 } 392 }
393 bEscape = !bEscape; 393 bEscape = !bEscape;
394 continue; 394 continue;
395 } 395 }
396 if (!bInConstRange && wc >= L'A' && wc <= L'a') { 396 if (!bInConstRange && wc >= L'A' && wc <= L'a') {
397 uint8_t nAlt = pAltTable[wc - L'A']; 397 uint8_t nAlt = pAltTable[wc - L'A'];
398 if (nAlt != 255) 398 if (nAlt != 255)
399 wsPattern.SetAt(i, wsAltSymbols[nAlt]); 399 wsPattern.SetAt(i, wsAltSymbols[nAlt]);
400 } 400 }
401 i++; 401 i++;
402 bEscape = FALSE; 402 bEscape = false;
403 } 403 }
404 } 404 }
405 405
406 bool PatternStringType(const CFX_ByteStringC& szPattern, 406 bool PatternStringType(const CFX_ByteStringC& szPattern,
407 uint32_t& patternType) { 407 uint32_t& patternType) {
408 CFX_WideString wsPattern = CFX_WideString::FromUTF8(szPattern); 408 CFX_WideString wsPattern = CFX_WideString::FromUTF8(szPattern);
409 if (FX_WSTRC(L"datetime") == wsPattern.Left(8)) { 409 if (FX_WSTRC(L"datetime") == wsPattern.Left(8)) {
410 patternType = XFA_VT_DATETIME; 410 patternType = XFA_VT_DATETIME;
411 return true; 411 return true;
412 } 412 }
(...skipping 22 matching lines...) Expand all
435 patternType = XFA_VT_FLOAT; 435 patternType = XFA_VT_FLOAT;
436 } 436 }
437 return true; 437 return true;
438 } 438 }
439 439
440 patternType = XFA_VT_NULL; 440 patternType = XFA_VT_NULL;
441 wsPattern.MakeLower(); 441 wsPattern.MakeLower();
442 const FX_WCHAR* pData = wsPattern.c_str(); 442 const FX_WCHAR* pData = wsPattern.c_str();
443 int32_t iLength = wsPattern.GetLength(); 443 int32_t iLength = wsPattern.GetLength();
444 int32_t iIndex = 0; 444 int32_t iIndex = 0;
445 FX_BOOL bSingleQuotation = FALSE; 445 bool bSingleQuotation = false;
446 FX_WCHAR patternChar; 446 FX_WCHAR patternChar;
447 while (iIndex < iLength) { 447 while (iIndex < iLength) {
448 patternChar = pData[iIndex]; 448 patternChar = pData[iIndex];
449 if (patternChar == 0x27) { 449 if (patternChar == 0x27) {
450 bSingleQuotation = !bSingleQuotation; 450 bSingleQuotation = !bSingleQuotation;
451 } else if (!bSingleQuotation && 451 } else if (!bSingleQuotation &&
452 (patternChar == 'y' || patternChar == 'j')) { 452 (patternChar == 'y' || patternChar == 'j')) {
453 patternType = XFA_VT_DATE; 453 patternType = XFA_VT_DATE;
454 iIndex++; 454 iIndex++;
455 FX_WCHAR timePatternChar; 455 FX_WCHAR timePatternChar;
(...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after
1226 if (argc > 1) { 1226 if (argc > 1) {
1227 std::unique_ptr<CFXJSE_Value> argLocal = GetSimpleValue(pThis, args, 1); 1227 std::unique_ptr<CFXJSE_Value> argLocal = GetSimpleValue(pThis, args, 1);
1228 if (argLocal->IsNull()) { 1228 if (argLocal->IsNull()) {
1229 args.GetReturnValue()->SetNull(); 1229 args.GetReturnValue()->SetNull();
1230 return; 1230 return;
1231 } 1231 }
1232 ValueToUTF8String(argLocal.get(), szLocal); 1232 ValueToUTF8String(argLocal.get(), szLocal);
1233 } 1233 }
1234 1234
1235 CFX_ByteString formatStr; 1235 CFX_ByteString formatStr;
1236 GetLocalDateFormat(pThis, iStyle, szLocal.AsStringC(), formatStr, FALSE); 1236 GetLocalDateFormat(pThis, iStyle, szLocal.AsStringC(), formatStr, false);
1237 args.GetReturnValue()->SetString(formatStr.AsStringC()); 1237 args.GetReturnValue()->SetString(formatStr.AsStringC());
1238 } 1238 }
1239 1239
1240 // static 1240 // static
1241 void CXFA_FM2JSContext::LocalTimeFmt(CFXJSE_Value* pThis, 1241 void CXFA_FM2JSContext::LocalTimeFmt(CFXJSE_Value* pThis,
1242 const CFX_ByteStringC& szFuncName, 1242 const CFX_ByteStringC& szFuncName,
1243 CFXJSE_Arguments& args) { 1243 CFXJSE_Arguments& args) {
1244 int32_t argc = args.GetLength(); 1244 int32_t argc = args.GetLength();
1245 if (argc > 2) { 1245 if (argc > 2) {
1246 ToJSContext(pThis, nullptr) 1246 ToJSContext(pThis, nullptr)
(...skipping 17 matching lines...) Expand all
1264 if (argc > 1) { 1264 if (argc > 1) {
1265 std::unique_ptr<CFXJSE_Value> argLocal = GetSimpleValue(pThis, args, 1); 1265 std::unique_ptr<CFXJSE_Value> argLocal = GetSimpleValue(pThis, args, 1);
1266 if (argLocal->IsNull()) { 1266 if (argLocal->IsNull()) {
1267 args.GetReturnValue()->SetNull(); 1267 args.GetReturnValue()->SetNull();
1268 return; 1268 return;
1269 } 1269 }
1270 ValueToUTF8String(argLocal.get(), szLocal); 1270 ValueToUTF8String(argLocal.get(), szLocal);
1271 } 1271 }
1272 1272
1273 CFX_ByteString formatStr; 1273 CFX_ByteString formatStr;
1274 GetLocalTimeFormat(pThis, iStyle, szLocal.AsStringC(), formatStr, FALSE); 1274 GetLocalTimeFormat(pThis, iStyle, szLocal.AsStringC(), formatStr, false);
1275 args.GetReturnValue()->SetString(formatStr.AsStringC()); 1275 args.GetReturnValue()->SetString(formatStr.AsStringC());
1276 } 1276 }
1277 1277
1278 // static 1278 // static
1279 void CXFA_FM2JSContext::Num2Date(CFXJSE_Value* pThis, 1279 void CXFA_FM2JSContext::Num2Date(CFXJSE_Value* pThis,
1280 const CFX_ByteStringC& szFuncName, 1280 const CFX_ByteStringC& szFuncName,
1281 CFXJSE_Arguments& args) { 1281 CFXJSE_Arguments& args) {
1282 int32_t argc = args.GetLength(); 1282 int32_t argc = args.GetLength();
1283 if (argc < 1 || argc > 3) { 1283 if (argc < 1 || argc > 3) {
1284 ToJSContext(pThis, nullptr) 1284 ToJSContext(pThis, nullptr)
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
1454 std::unique_ptr<CFXJSE_Value> localValue = GetSimpleValue(pThis, args, 2); 1454 std::unique_ptr<CFXJSE_Value> localValue = GetSimpleValue(pThis, args, 2);
1455 if (localValue->IsNull()) { 1455 if (localValue->IsNull()) {
1456 args.GetReturnValue()->SetNull(); 1456 args.GetReturnValue()->SetNull();
1457 return; 1457 return;
1458 } 1458 }
1459 ValueToUTF8String(localValue.get(), localString); 1459 ValueToUTF8String(localValue.get(), localString);
1460 } 1460 }
1461 1461
1462 CFX_ByteString szGMTTimeString; 1462 CFX_ByteString szGMTTimeString;
1463 Num2AllTime(pThis, iTime, formatString.AsStringC(), localString.AsStringC(), 1463 Num2AllTime(pThis, iTime, formatString.AsStringC(), localString.AsStringC(),
1464 TRUE, szGMTTimeString); 1464 true, szGMTTimeString);
1465 args.GetReturnValue()->SetString(szGMTTimeString.AsStringC()); 1465 args.GetReturnValue()->SetString(szGMTTimeString.AsStringC());
1466 } 1466 }
1467 1467
1468 // static 1468 // static
1469 void CXFA_FM2JSContext::Num2Time(CFXJSE_Value* pThis, 1469 void CXFA_FM2JSContext::Num2Time(CFXJSE_Value* pThis,
1470 const CFX_ByteStringC& szFuncName, 1470 const CFX_ByteStringC& szFuncName,
1471 CFXJSE_Arguments& args) { 1471 CFXJSE_Arguments& args) {
1472 int32_t argc = args.GetLength(); 1472 int32_t argc = args.GetLength();
1473 if (argc < 1 || argc > 3) { 1473 if (argc < 1 || argc > 3) {
1474 ToJSContext(pThis, nullptr) 1474 ToJSContext(pThis, nullptr)
(...skipping 27 matching lines...) Expand all
1502 std::unique_ptr<CFXJSE_Value> localValue = GetSimpleValue(pThis, args, 2); 1502 std::unique_ptr<CFXJSE_Value> localValue = GetSimpleValue(pThis, args, 2);
1503 if (localValue->IsNull()) { 1503 if (localValue->IsNull()) {
1504 args.GetReturnValue()->SetNull(); 1504 args.GetReturnValue()->SetNull();
1505 return; 1505 return;
1506 } 1506 }
1507 ValueToUTF8String(localValue.get(), localString); 1507 ValueToUTF8String(localValue.get(), localString);
1508 } 1508 }
1509 1509
1510 CFX_ByteString szLocalTimeString; 1510 CFX_ByteString szLocalTimeString;
1511 Num2AllTime(pThis, (int32_t)fTime, formatString.AsStringC(), 1511 Num2AllTime(pThis, (int32_t)fTime, formatString.AsStringC(),
1512 localString.AsStringC(), FALSE, szLocalTimeString); 1512 localString.AsStringC(), false, szLocalTimeString);
1513 args.GetReturnValue()->SetString(szLocalTimeString.AsStringC()); 1513 args.GetReturnValue()->SetString(szLocalTimeString.AsStringC());
1514 } 1514 }
1515 1515
1516 // static 1516 // static
1517 void CXFA_FM2JSContext::Time(CFXJSE_Value* pThis, 1517 void CXFA_FM2JSContext::Time(CFXJSE_Value* pThis,
1518 const CFX_ByteStringC& szFuncName, 1518 const CFX_ByteStringC& szFuncName,
1519 CFXJSE_Arguments& args) { 1519 CFXJSE_Arguments& args) {
1520 if (args.GetLength() != 0) { 1520 if (args.GetLength() != 0) {
1521 ToJSContext(pThis, nullptr) 1521 ToJSContext(pThis, nullptr)
1522 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Time"); 1522 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Time");
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
1654 } 1654 }
1655 ValueToUTF8String(argLocal.get(), szLocal); 1655 ValueToUTF8String(argLocal.get(), szLocal);
1656 } 1656 }
1657 1657
1658 CFX_ByteString formatStr; 1658 CFX_ByteString formatStr;
1659 GetStandardTimeFormat(pThis, iStyle, szLocal.AsStringC(), formatStr); 1659 GetStandardTimeFormat(pThis, iStyle, szLocal.AsStringC(), formatStr);
1660 args.GetReturnValue()->SetString(formatStr.AsStringC()); 1660 args.GetReturnValue()->SetString(formatStr.AsStringC());
1661 } 1661 }
1662 1662
1663 // static 1663 // static
1664 FX_BOOL CXFA_FM2JSContext::IsIsoDateFormat(const FX_CHAR* pData, 1664 bool CXFA_FM2JSContext::IsIsoDateFormat(const FX_CHAR* pData,
1665 int32_t iLength, 1665 int32_t iLength,
1666 int32_t& iStyle, 1666 int32_t& iStyle,
1667 int32_t& iYear, 1667 int32_t& iYear,
1668 int32_t& iMonth, 1668 int32_t& iMonth,
1669 int32_t& iDay) { 1669 int32_t& iDay) {
1670 iYear = 0; 1670 iYear = 0;
1671 iMonth = 1; 1671 iMonth = 1;
1672 iDay = 1; 1672 iDay = 1;
1673 1673
1674 if (iLength < 4) 1674 if (iLength < 4)
1675 return FALSE; 1675 return false;
1676 1676
1677 FX_CHAR strYear[5]; 1677 FX_CHAR strYear[5];
1678 strYear[4] = '\0'; 1678 strYear[4] = '\0';
1679 for (int32_t i = 0; i < 4; ++i) { 1679 for (int32_t i = 0; i < 4; ++i) {
1680 if (pData[i] > '9' || pData[i] < '0') 1680 if (pData[i] > '9' || pData[i] < '0')
1681 return FALSE; 1681 return false;
1682 1682
1683 strYear[i] = pData[i]; 1683 strYear[i] = pData[i];
1684 } 1684 }
1685 iYear = FXSYS_atoi(strYear); 1685 iYear = FXSYS_atoi(strYear);
1686 iStyle = 0; 1686 iStyle = 0;
1687 if (iLength == 4) 1687 if (iLength == 4)
1688 return TRUE; 1688 return true;
1689 1689
1690 iStyle = pData[4] == '-' ? 1 : 0; 1690 iStyle = pData[4] == '-' ? 1 : 0;
1691 1691
1692 FX_CHAR strTemp[3]; 1692 FX_CHAR strTemp[3];
1693 strTemp[2] = '\0'; 1693 strTemp[2] = '\0';
1694 int32_t iPosOff = iStyle == 0 ? 4 : 5; 1694 int32_t iPosOff = iStyle == 0 ? 4 : 5;
1695 if ((pData[iPosOff] > '9' || pData[iPosOff] < '0') || 1695 if ((pData[iPosOff] > '9' || pData[iPosOff] < '0') ||
1696 (pData[iPosOff + 1] > '9' || pData[iPosOff + 1] < '0')) 1696 (pData[iPosOff + 1] > '9' || pData[iPosOff + 1] < '0'))
1697 return FALSE; 1697 return false;
1698 1698
1699 strTemp[0] = pData[iPosOff]; 1699 strTemp[0] = pData[iPosOff];
1700 strTemp[1] = pData[iPosOff + 1]; 1700 strTemp[1] = pData[iPosOff + 1];
1701 iMonth = FXSYS_atoi(strTemp); 1701 iMonth = FXSYS_atoi(strTemp);
1702 if (iMonth > 12 || iMonth < 1) 1702 if (iMonth > 12 || iMonth < 1)
1703 return FALSE; 1703 return false;
1704 1704
1705 if (iStyle == 0) { 1705 if (iStyle == 0) {
1706 iPosOff += 2; 1706 iPosOff += 2;
1707 if (iLength == 6) 1707 if (iLength == 6)
1708 return TRUE; 1708 return true;
1709 } else { 1709 } else {
1710 iPosOff += 3; 1710 iPosOff += 3;
1711 if (iLength == 7) 1711 if (iLength == 7)
1712 return TRUE; 1712 return true;
1713 } 1713 }
1714 if ((pData[iPosOff] > '9' || pData[iPosOff] < '0') || 1714 if ((pData[iPosOff] > '9' || pData[iPosOff] < '0') ||
1715 (pData[iPosOff + 1] > '9' || pData[iPosOff + 1] < '0')) 1715 (pData[iPosOff + 1] > '9' || pData[iPosOff + 1] < '0'))
1716 return FALSE; 1716 return false;
1717 1717
1718 strTemp[0] = pData[iPosOff]; 1718 strTemp[0] = pData[iPosOff];
1719 strTemp[1] = pData[iPosOff + 1]; 1719 strTemp[1] = pData[iPosOff + 1];
1720 iDay = FXSYS_atoi(strTemp); 1720 iDay = FXSYS_atoi(strTemp);
1721 if (iPosOff + 2 < iLength) 1721 if (iPosOff + 2 < iLength)
1722 return FALSE; 1722 return false;
1723 1723
1724 if ((!(iYear % 4) && (iYear % 100)) || !(iYear % 400)) { 1724 if ((!(iYear % 4) && (iYear % 100)) || !(iYear % 400)) {
1725 if (iMonth == 2 && iDay > 29) 1725 if (iMonth == 2 && iDay > 29)
1726 return FALSE; 1726 return false;
1727 } else { 1727 } else {
1728 if (iMonth == 2 && iDay > 28) 1728 if (iMonth == 2 && iDay > 28)
1729 return FALSE; 1729 return false;
1730 } 1730 }
1731 if (iMonth != 2) { 1731 if (iMonth != 2) {
1732 if (iMonth < 8) { 1732 if (iMonth < 8) {
1733 if (iDay > (iMonth % 2 == 0 ? 30 : 31)) 1733 if (iDay > (iMonth % 2 == 0 ? 30 : 31))
1734 return FALSE; 1734 return false;
1735 } else if (iDay > (iMonth % 2 == 0 ? 31 : 30)) { 1735 } else if (iDay > (iMonth % 2 == 0 ? 31 : 30)) {
1736 return FALSE; 1736 return false;
1737 } 1737 }
1738 } 1738 }
1739 return TRUE; 1739 return true;
1740 } 1740 }
1741 1741
1742 // static 1742 // static
1743 FX_BOOL CXFA_FM2JSContext::IsIsoTimeFormat(const FX_CHAR* pData, 1743 bool CXFA_FM2JSContext::IsIsoTimeFormat(const FX_CHAR* pData,
1744 int32_t iLength, 1744 int32_t iLength,
1745 int32_t& iHour, 1745 int32_t& iHour,
1746 int32_t& iMinute, 1746 int32_t& iMinute,
1747 int32_t& iSecond, 1747 int32_t& iSecond,
1748 int32_t& iMilliSecond, 1748 int32_t& iMilliSecond,
1749 int32_t& iZoneHour, 1749 int32_t& iZoneHour,
1750 int32_t& iZoneMinute) { 1750 int32_t& iZoneMinute) {
1751 iHour = 0; 1751 iHour = 0;
1752 iMinute = 0; 1752 iMinute = 0;
1753 iSecond = 0; 1753 iSecond = 0;
1754 iMilliSecond = 0; 1754 iMilliSecond = 0;
1755 iZoneHour = 0; 1755 iZoneHour = 0;
1756 iZoneMinute = 0; 1756 iZoneMinute = 0;
1757 if (!pData) 1757 if (!pData)
1758 return FALSE; 1758 return false;
1759 1759
1760 FX_CHAR strTemp[3]; 1760 FX_CHAR strTemp[3];
1761 strTemp[2] = '\0'; 1761 strTemp[2] = '\0';
1762 int32_t iZone = 0; 1762 int32_t iZone = 0;
1763 int32_t i = 0; 1763 int32_t i = 0;
1764 while (i < iLength) { 1764 while (i < iLength) {
1765 if ((pData[i] > '9' || pData[i] < '0') && pData[i] != ':') { 1765 if ((pData[i] > '9' || pData[i] < '0') && pData[i] != ':') {
1766 iZone = i; 1766 iZone = i;
1767 break; 1767 break;
1768 } 1768 }
1769 ++i; 1769 ++i;
1770 } 1770 }
1771 if (i == iLength) 1771 if (i == iLength)
1772 iZone = iLength; 1772 iZone = iLength;
1773 1773
1774 int32_t iPos = 0; 1774 int32_t iPos = 0;
1775 int32_t iIndex = 0; 1775 int32_t iIndex = 0;
1776 while (iIndex < iZone) { 1776 while (iIndex < iZone) {
1777 if (iIndex >= iZone) 1777 if (iIndex >= iZone)
1778 break; 1778 break;
1779 1779
1780 if (pData[iIndex] > '9' || pData[iIndex] < '0') 1780 if (pData[iIndex] > '9' || pData[iIndex] < '0')
1781 return FALSE; 1781 return false;
1782 1782
1783 strTemp[0] = pData[iIndex]; 1783 strTemp[0] = pData[iIndex];
1784 if (pData[iIndex + 1] > '9' || pData[iIndex + 1] < '0') 1784 if (pData[iIndex + 1] > '9' || pData[iIndex + 1] < '0')
1785 return FALSE; 1785 return false;
1786 1786
1787 strTemp[1] = pData[iIndex + 1]; 1787 strTemp[1] = pData[iIndex + 1];
1788 if (FXSYS_atoi(strTemp) > 60) 1788 if (FXSYS_atoi(strTemp) > 60)
1789 return FALSE; 1789 return false;
1790 1790
1791 if (pData[2] == ':') { 1791 if (pData[2] == ':') {
1792 if (iPos == 0) { 1792 if (iPos == 0) {
1793 iHour = FXSYS_atoi(strTemp); 1793 iHour = FXSYS_atoi(strTemp);
1794 ++iPos; 1794 ++iPos;
1795 } else if (iPos == 1) { 1795 } else if (iPos == 1) {
1796 iMinute = FXSYS_atoi(strTemp); 1796 iMinute = FXSYS_atoi(strTemp);
1797 ++iPos; 1797 ++iPos;
1798 } else { 1798 } else {
1799 iSecond = FXSYS_atoi(strTemp); 1799 iSecond = FXSYS_atoi(strTemp);
(...skipping 11 matching lines...) Expand all
1811 ++iPos; 1811 ++iPos;
1812 } 1812 }
1813 iIndex += 2; 1813 iIndex += 2;
1814 } 1814 }
1815 } 1815 }
1816 if (pData[iIndex] == '.') { 1816 if (pData[iIndex] == '.') {
1817 ++iIndex; 1817 ++iIndex;
1818 FX_CHAR strSec[4]; 1818 FX_CHAR strSec[4];
1819 strSec[3] = '\0'; 1819 strSec[3] = '\0';
1820 if (pData[iIndex] > '9' || pData[iIndex] < '0') 1820 if (pData[iIndex] > '9' || pData[iIndex] < '0')
1821 return FALSE; 1821 return false;
1822 1822
1823 strSec[0] = pData[iIndex]; 1823 strSec[0] = pData[iIndex];
1824 if (pData[iIndex + 1] > '9' || pData[iIndex + 1] < '0') 1824 if (pData[iIndex + 1] > '9' || pData[iIndex + 1] < '0')
1825 return FALSE; 1825 return false;
1826 1826
1827 strSec[1] = pData[iIndex + 1]; 1827 strSec[1] = pData[iIndex + 1];
1828 if (pData[iIndex + 2] > '9' || pData[iIndex + 2] < '0') 1828 if (pData[iIndex + 2] > '9' || pData[iIndex + 2] < '0')
1829 return FALSE; 1829 return false;
1830 1830
1831 strSec[2] = pData[iIndex + 2]; 1831 strSec[2] = pData[iIndex + 2];
1832 iMilliSecond = FXSYS_atoi(strSec); 1832 iMilliSecond = FXSYS_atoi(strSec);
1833 if (iMilliSecond > 100) { 1833 if (iMilliSecond > 100) {
1834 iMilliSecond = 0; 1834 iMilliSecond = 0;
1835 return FALSE; 1835 return false;
1836 } 1836 }
1837 iIndex += 3; 1837 iIndex += 3;
1838 } 1838 }
1839 if (pData[iIndex] == 'z' || pData[iIndex] == 'Z') 1839 if (pData[iIndex] == 'z' || pData[iIndex] == 'Z')
1840 return TRUE; 1840 return true;
1841 1841
1842 int32_t iSign = 1; 1842 int32_t iSign = 1;
1843 if (pData[iIndex] == '+') { 1843 if (pData[iIndex] == '+') {
1844 ++iIndex; 1844 ++iIndex;
1845 } else if (pData[iIndex] == '-') { 1845 } else if (pData[iIndex] == '-') {
1846 iSign = -1; 1846 iSign = -1;
1847 ++iIndex; 1847 ++iIndex;
1848 } 1848 }
1849 iPos = 0; 1849 iPos = 0;
1850 while (iIndex < iLength) { 1850 while (iIndex < iLength) {
1851 if (iIndex >= iLength) 1851 if (iIndex >= iLength)
1852 return FALSE; 1852 return false;
1853 if (pData[iIndex] > '9' || pData[iIndex] < '0') 1853 if (pData[iIndex] > '9' || pData[iIndex] < '0')
1854 return FALSE; 1854 return false;
1855 1855
1856 strTemp[0] = pData[iIndex]; 1856 strTemp[0] = pData[iIndex];
1857 if (pData[iIndex + 1] > '9' || pData[iIndex + 1] < '0') 1857 if (pData[iIndex + 1] > '9' || pData[iIndex + 1] < '0')
1858 return FALSE; 1858 return false;
1859 1859
1860 strTemp[1] = pData[iIndex + 1]; 1860 strTemp[1] = pData[iIndex + 1];
1861 if (FXSYS_atoi(strTemp) > 60) 1861 if (FXSYS_atoi(strTemp) > 60)
1862 return FALSE; 1862 return false;
1863 1863
1864 if (pData[2] == ':') { 1864 if (pData[2] == ':') {
1865 if (iPos == 0) { 1865 if (iPos == 0) {
1866 iZoneHour = FXSYS_atoi(strTemp); 1866 iZoneHour = FXSYS_atoi(strTemp);
1867 } else if (iPos == 1) { 1867 } else if (iPos == 1) {
1868 iZoneMinute = FXSYS_atoi(strTemp); 1868 iZoneMinute = FXSYS_atoi(strTemp);
1869 } 1869 }
1870 iIndex += 3; 1870 iIndex += 3;
1871 } else { 1871 } else {
1872 if (!iPos) { 1872 if (!iPos) {
1873 iZoneHour = FXSYS_atoi(strTemp); 1873 iZoneHour = FXSYS_atoi(strTemp);
1874 ++iPos; 1874 ++iPos;
1875 } else if (iPos == 1) { 1875 } else if (iPos == 1) {
1876 iZoneMinute = FXSYS_atoi(strTemp); 1876 iZoneMinute = FXSYS_atoi(strTemp);
1877 ++iPos; 1877 ++iPos;
1878 } 1878 }
1879 iIndex += 2; 1879 iIndex += 2;
1880 } 1880 }
1881 } 1881 }
1882 if (iIndex < iLength) 1882 if (iIndex < iLength)
1883 return FALSE; 1883 return false;
1884 1884
1885 iZoneHour *= iSign; 1885 iZoneHour *= iSign;
1886 return TRUE; 1886 return true;
1887 } 1887 }
1888 1888
1889 // static 1889 // static
1890 FX_BOOL CXFA_FM2JSContext::IsIsoDateTimeFormat(const FX_CHAR* pData, 1890 bool CXFA_FM2JSContext::IsIsoDateTimeFormat(const FX_CHAR* pData,
1891 int32_t iLength, 1891 int32_t iLength,
1892 int32_t& iYear, 1892 int32_t& iYear,
1893 int32_t& iMonth, 1893 int32_t& iMonth,
1894 int32_t& iDay, 1894 int32_t& iDay,
1895 int32_t& iHour, 1895 int32_t& iHour,
1896 int32_t& iMinute, 1896 int32_t& iMinute,
1897 int32_t& iSecond, 1897 int32_t& iSecond,
1898 int32_t& iMillionSecond, 1898 int32_t& iMillionSecond,
1899 int32_t& iZoneHour, 1899 int32_t& iZoneHour,
1900 int32_t& iZoneMinute) { 1900 int32_t& iZoneMinute) {
1901 iYear = 0; 1901 iYear = 0;
1902 iMonth = 0; 1902 iMonth = 0;
1903 iDay = 0; 1903 iDay = 0;
1904 iHour = 0; 1904 iHour = 0;
1905 iMinute = 0; 1905 iMinute = 0;
1906 iSecond = 0; 1906 iSecond = 0;
1907 if (!pData) 1907 if (!pData)
1908 return FALSE; 1908 return false;
1909 1909
1910 int32_t iIndex = 0; 1910 int32_t iIndex = 0;
1911 while (pData[iIndex] != 'T' && pData[iIndex] != 't') { 1911 while (pData[iIndex] != 'T' && pData[iIndex] != 't') {
1912 if (iIndex >= iLength) 1912 if (iIndex >= iLength)
1913 return FALSE; 1913 return false;
1914 ++iIndex; 1914 ++iIndex;
1915 } 1915 }
1916 if (iIndex != 8 && iIndex != 10) 1916 if (iIndex != 8 && iIndex != 10)
1917 return FALSE; 1917 return false;
1918 1918
1919 int32_t iStyle = -1; 1919 int32_t iStyle = -1;
1920 if (!IsIsoDateFormat(pData, iIndex, iStyle, iYear, iMonth, iDay)) 1920 if (!IsIsoDateFormat(pData, iIndex, iStyle, iYear, iMonth, iDay))
1921 return FALSE; 1921 return false;
1922 if (pData[iIndex] != 'T' && pData[iIndex] != 't') 1922 if (pData[iIndex] != 'T' && pData[iIndex] != 't')
1923 return TRUE; 1923 return true;
1924 1924
1925 ++iIndex; 1925 ++iIndex;
1926 if (((iLength - iIndex > 13) && (iLength - iIndex < 6)) && 1926 if (((iLength - iIndex > 13) && (iLength - iIndex < 6)) &&
1927 (iLength - iIndex != 15)) { 1927 (iLength - iIndex != 15)) {
1928 return TRUE; 1928 return true;
1929 } 1929 }
1930 if (!IsIsoTimeFormat(pData + iIndex, iLength - iIndex, iHour, iMinute, 1930 if (!IsIsoTimeFormat(pData + iIndex, iLength - iIndex, iHour, iMinute,
1931 iSecond, iMillionSecond, iZoneHour, iZoneMinute)) { 1931 iSecond, iMillionSecond, iZoneHour, iZoneMinute)) {
1932 return FALSE; 1932 return false;
1933 } 1933 }
1934 1934
1935 return TRUE; 1935 return true;
1936 } 1936 }
1937 1937
1938 // static 1938 // static
1939 FX_BOOL CXFA_FM2JSContext::Local2IsoDate(CFXJSE_Value* pThis, 1939 bool CXFA_FM2JSContext::Local2IsoDate(CFXJSE_Value* pThis,
1940 const CFX_ByteStringC& szDate, 1940 const CFX_ByteStringC& szDate,
1941 const CFX_ByteStringC& szFormat, 1941 const CFX_ByteStringC& szFormat,
1942 const CFX_ByteStringC& szLocale, 1942 const CFX_ByteStringC& szLocale,
1943 CFX_ByteString& strIsoDate) { 1943 CFX_ByteString& strIsoDate) {
1944 CXFA_Document* pDoc = ToJSContext(pThis, nullptr)->GetDocument(); 1944 CXFA_Document* pDoc = ToJSContext(pThis, nullptr)->GetDocument();
1945 if (!pDoc) 1945 if (!pDoc)
1946 return FALSE; 1946 return false;
1947 1947
1948 CXFA_LocaleMgr* pMgr = pDoc->GetLocalMgr(); 1948 CXFA_LocaleMgr* pMgr = pDoc->GetLocalMgr();
1949 IFX_Locale* pLocale = nullptr; 1949 IFX_Locale* pLocale = nullptr;
1950 if (szLocale.IsEmpty()) { 1950 if (szLocale.IsEmpty()) {
1951 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); 1951 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject());
1952 ASSERT(pThisNode); 1952 ASSERT(pThisNode);
1953 1953
1954 CXFA_WidgetData widgetData(pThisNode); 1954 CXFA_WidgetData widgetData(pThisNode);
1955 pLocale = widgetData.GetLocal(); 1955 pLocale = widgetData.GetLocal();
1956 } else { 1956 } else {
1957 pLocale = pMgr->GetLocaleByName(CFX_WideString::FromUTF8(szLocale)); 1957 pLocale = pMgr->GetLocaleByName(CFX_WideString::FromUTF8(szLocale));
1958 } 1958 }
1959 if (!pLocale) 1959 if (!pLocale)
1960 return FALSE; 1960 return false;
1961 1961
1962 CFX_WideString wsFormat; 1962 CFX_WideString wsFormat;
1963 if (szFormat.IsEmpty()) 1963 if (szFormat.IsEmpty())
1964 pLocale->GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat); 1964 pLocale->GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat);
1965 else 1965 else
1966 wsFormat = CFX_WideString::FromUTF8(szFormat); 1966 wsFormat = CFX_WideString::FromUTF8(szFormat);
1967 1967
1968 CXFA_LocaleValue widgetValue(XFA_VT_DATE, CFX_WideString::FromUTF8(szDate), 1968 CXFA_LocaleValue widgetValue(XFA_VT_DATE, CFX_WideString::FromUTF8(szDate),
1969 wsFormat, pLocale, pMgr); 1969 wsFormat, pLocale, pMgr);
1970 CFX_Unitime dt = widgetValue.GetDate(); 1970 CFX_Unitime dt = widgetValue.GetDate();
1971 strIsoDate.Format("%4d-%02d-%02d", dt.GetYear(), dt.GetMonth(), dt.GetDay()); 1971 strIsoDate.Format("%4d-%02d-%02d", dt.GetYear(), dt.GetMonth(), dt.GetDay());
1972 return TRUE; 1972 return true;
1973 } 1973 }
1974 1974
1975 // static 1975 // static
1976 FX_BOOL CXFA_FM2JSContext::Local2IsoTime(CFXJSE_Value* pThis, 1976 bool CXFA_FM2JSContext::Local2IsoTime(CFXJSE_Value* pThis,
1977 const CFX_ByteStringC& szTime, 1977 const CFX_ByteStringC& szTime,
1978 const CFX_ByteStringC& szFormat, 1978 const CFX_ByteStringC& szFormat,
1979 const CFX_ByteStringC& szLocale, 1979 const CFX_ByteStringC& szLocale,
1980 CFX_ByteString& strIsoTime) { 1980 CFX_ByteString& strIsoTime) {
1981 CXFA_Document* pDoc = ToJSContext(pThis, nullptr)->GetDocument(); 1981 CXFA_Document* pDoc = ToJSContext(pThis, nullptr)->GetDocument();
1982 if (!pDoc) 1982 if (!pDoc)
1983 return FALSE; 1983 return false;
1984 1984
1985 CXFA_LocaleMgr* pMgr = pDoc->GetLocalMgr(); 1985 CXFA_LocaleMgr* pMgr = pDoc->GetLocalMgr();
1986 IFX_Locale* pLocale = nullptr; 1986 IFX_Locale* pLocale = nullptr;
1987 if (szLocale.IsEmpty()) { 1987 if (szLocale.IsEmpty()) {
1988 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); 1988 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject());
1989 ASSERT(pThisNode); 1989 ASSERT(pThisNode);
1990 1990
1991 CXFA_WidgetData widgetData(pThisNode); 1991 CXFA_WidgetData widgetData(pThisNode);
1992 pLocale = widgetData.GetLocal(); 1992 pLocale = widgetData.GetLocal();
1993 } else { 1993 } else {
1994 pLocale = pMgr->GetLocaleByName(CFX_WideString::FromUTF8(szLocale)); 1994 pLocale = pMgr->GetLocaleByName(CFX_WideString::FromUTF8(szLocale));
1995 } 1995 }
1996 if (!pLocale) 1996 if (!pLocale)
1997 return FALSE; 1997 return false;
1998 1998
1999 CFX_WideString wsFormat; 1999 CFX_WideString wsFormat;
2000 if (szFormat.IsEmpty()) 2000 if (szFormat.IsEmpty())
2001 pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat); 2001 pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat);
2002 else 2002 else
2003 wsFormat = CFX_WideString::FromUTF8(szFormat); 2003 wsFormat = CFX_WideString::FromUTF8(szFormat);
2004 2004
2005 wsFormat = L"time{" + wsFormat + L"}"; 2005 wsFormat = L"time{" + wsFormat + L"}";
2006 CXFA_LocaleValue widgetValue(XFA_VT_TIME, CFX_WideString::FromUTF8(szTime), 2006 CXFA_LocaleValue widgetValue(XFA_VT_TIME, CFX_WideString::FromUTF8(szTime),
2007 wsFormat, pLocale, pMgr); 2007 wsFormat, pLocale, pMgr);
2008 CFX_Unitime utime = widgetValue.GetTime(); 2008 CFX_Unitime utime = widgetValue.GetTime();
2009 strIsoTime.Format("%02d:%02d:%02d.%03d", utime.GetHour(), utime.GetMinute(), 2009 strIsoTime.Format("%02d:%02d:%02d.%03d", utime.GetHour(), utime.GetMinute(),
2010 utime.GetSecond(), utime.GetMillisecond()); 2010 utime.GetSecond(), utime.GetMillisecond());
2011 return TRUE; 2011 return true;
2012 } 2012 }
2013 2013
2014 // static 2014 // static
2015 FX_BOOL CXFA_FM2JSContext::IsoDate2Local(CFXJSE_Value* pThis, 2015 bool CXFA_FM2JSContext::IsoDate2Local(CFXJSE_Value* pThis,
2016 const CFX_ByteStringC& szDate, 2016 const CFX_ByteStringC& szDate,
2017 const CFX_ByteStringC& szFormat, 2017 const CFX_ByteStringC& szFormat,
2018 const CFX_ByteStringC& szLocale, 2018 const CFX_ByteStringC& szLocale,
2019 CFX_ByteString& strLocalDate) { 2019 CFX_ByteString& strLocalDate) {
2020 CXFA_Document* pDoc = ToJSContext(pThis, nullptr)->GetDocument(); 2020 CXFA_Document* pDoc = ToJSContext(pThis, nullptr)->GetDocument();
2021 if (!pDoc) 2021 if (!pDoc)
2022 return FALSE; 2022 return false;
2023 2023
2024 CXFA_LocaleMgr* pMgr = pDoc->GetLocalMgr(); 2024 CXFA_LocaleMgr* pMgr = pDoc->GetLocalMgr();
2025 IFX_Locale* pLocale = nullptr; 2025 IFX_Locale* pLocale = nullptr;
2026 if (szLocale.IsEmpty()) { 2026 if (szLocale.IsEmpty()) {
2027 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); 2027 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject());
2028 ASSERT(pThisNode); 2028 ASSERT(pThisNode);
2029 CXFA_WidgetData widgetData(pThisNode); 2029 CXFA_WidgetData widgetData(pThisNode);
2030 pLocale = widgetData.GetLocal(); 2030 pLocale = widgetData.GetLocal();
2031 } else { 2031 } else {
2032 pLocale = pMgr->GetLocaleByName(CFX_WideString::FromUTF8(szLocale)); 2032 pLocale = pMgr->GetLocaleByName(CFX_WideString::FromUTF8(szLocale));
2033 } 2033 }
2034 if (!pLocale) 2034 if (!pLocale)
2035 return FALSE; 2035 return false;
2036 2036
2037 CFX_WideString wsFormat; 2037 CFX_WideString wsFormat;
2038 if (szFormat.IsEmpty()) 2038 if (szFormat.IsEmpty())
2039 pLocale->GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat); 2039 pLocale->GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat);
2040 else 2040 else
2041 wsFormat = CFX_WideString::FromUTF8(szFormat); 2041 wsFormat = CFX_WideString::FromUTF8(szFormat);
2042 2042
2043 CXFA_LocaleValue widgetValue(XFA_VT_DATE, CFX_WideString::FromUTF8(szDate), 2043 CXFA_LocaleValue widgetValue(XFA_VT_DATE, CFX_WideString::FromUTF8(szDate),
2044 pMgr); 2044 pMgr);
2045 CFX_WideString wsRet; 2045 CFX_WideString wsRet;
2046 widgetValue.FormatPatterns(wsRet, wsFormat, pLocale, 2046 widgetValue.FormatPatterns(wsRet, wsFormat, pLocale,
2047 XFA_VALUEPICTURE_Display); 2047 XFA_VALUEPICTURE_Display);
2048 strLocalDate = FX_UTF8Encode(wsRet.c_str(), wsRet.GetLength()); 2048 strLocalDate = FX_UTF8Encode(wsRet.c_str(), wsRet.GetLength());
2049 return TRUE; 2049 return true;
2050 } 2050 }
2051 2051
2052 // static 2052 // static
2053 FX_BOOL CXFA_FM2JSContext::IsoTime2Local(CFXJSE_Value* pThis, 2053 bool CXFA_FM2JSContext::IsoTime2Local(CFXJSE_Value* pThis,
2054 const CFX_ByteStringC& szTime, 2054 const CFX_ByteStringC& szTime,
2055 const CFX_ByteStringC& szFormat, 2055 const CFX_ByteStringC& szFormat,
2056 const CFX_ByteStringC& szLocale, 2056 const CFX_ByteStringC& szLocale,
2057 CFX_ByteString& strLocalTime) { 2057 CFX_ByteString& strLocalTime) {
2058 CXFA_Document* pDoc = ToJSContext(pThis, nullptr)->GetDocument(); 2058 CXFA_Document* pDoc = ToJSContext(pThis, nullptr)->GetDocument();
2059 if (!pDoc) 2059 if (!pDoc)
2060 return FALSE; 2060 return false;
2061 2061
2062 CXFA_LocaleMgr* pMgr = pDoc->GetLocalMgr(); 2062 CXFA_LocaleMgr* pMgr = pDoc->GetLocalMgr();
2063 IFX_Locale* pLocale = nullptr; 2063 IFX_Locale* pLocale = nullptr;
2064 if (szLocale.IsEmpty()) { 2064 if (szLocale.IsEmpty()) {
2065 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); 2065 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject());
2066 ASSERT(pThisNode); 2066 ASSERT(pThisNode);
2067 CXFA_WidgetData widgetData(pThisNode); 2067 CXFA_WidgetData widgetData(pThisNode);
2068 pLocale = widgetData.GetLocal(); 2068 pLocale = widgetData.GetLocal();
2069 } else { 2069 } else {
2070 pLocale = pMgr->GetLocaleByName(CFX_WideString::FromUTF8(szLocale)); 2070 pLocale = pMgr->GetLocaleByName(CFX_WideString::FromUTF8(szLocale));
2071 } 2071 }
2072 if (!pLocale) 2072 if (!pLocale)
2073 return FALSE; 2073 return false;
2074 2074
2075 CFX_WideString wsFormat; 2075 CFX_WideString wsFormat;
2076 if (szFormat.IsEmpty()) 2076 if (szFormat.IsEmpty())
2077 pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat); 2077 pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat);
2078 else 2078 else
2079 wsFormat = CFX_WideString::FromUTF8(szFormat); 2079 wsFormat = CFX_WideString::FromUTF8(szFormat);
2080 2080
2081 wsFormat = L"time{" + wsFormat + L"}"; 2081 wsFormat = L"time{" + wsFormat + L"}";
2082 CXFA_LocaleValue widgetValue(XFA_VT_TIME, CFX_WideString::FromUTF8(szTime), 2082 CXFA_LocaleValue widgetValue(XFA_VT_TIME, CFX_WideString::FromUTF8(szTime),
2083 pMgr); 2083 pMgr);
2084 CFX_WideString wsRet; 2084 CFX_WideString wsRet;
2085 widgetValue.FormatPatterns(wsRet, wsFormat, pLocale, 2085 widgetValue.FormatPatterns(wsRet, wsFormat, pLocale,
2086 XFA_VALUEPICTURE_Display); 2086 XFA_VALUEPICTURE_Display);
2087 strLocalTime = FX_UTF8Encode(wsRet.c_str(), wsRet.GetLength()); 2087 strLocalTime = FX_UTF8Encode(wsRet.c_str(), wsRet.GetLength());
2088 return TRUE; 2088 return true;
2089 } 2089 }
2090 2090
2091 // static 2091 // static
2092 FX_BOOL CXFA_FM2JSContext::GetGMTTime(CFXJSE_Value* pThis, 2092 bool CXFA_FM2JSContext::GetGMTTime(CFXJSE_Value* pThis,
2093 const CFX_ByteStringC& szTime, 2093 const CFX_ByteStringC& szTime,
2094 const CFX_ByteStringC& szFormat, 2094 const CFX_ByteStringC& szFormat,
2095 const CFX_ByteStringC& szLocale, 2095 const CFX_ByteStringC& szLocale,
2096 CFX_ByteString& strGMTTime) { 2096 CFX_ByteString& strGMTTime) {
2097 CXFA_Document* pDoc = ToJSContext(pThis, nullptr)->GetDocument(); 2097 CXFA_Document* pDoc = ToJSContext(pThis, nullptr)->GetDocument();
2098 if (!pDoc) 2098 if (!pDoc)
2099 return FALSE; 2099 return false;
2100 2100
2101 CXFA_LocaleMgr* pMgr = pDoc->GetLocalMgr(); 2101 CXFA_LocaleMgr* pMgr = pDoc->GetLocalMgr();
2102 IFX_Locale* pLocale = nullptr; 2102 IFX_Locale* pLocale = nullptr;
2103 if (szLocale.IsEmpty()) { 2103 if (szLocale.IsEmpty()) {
2104 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); 2104 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject());
2105 ASSERT(pThisNode); 2105 ASSERT(pThisNode);
2106 CXFA_WidgetData widgetData(pThisNode); 2106 CXFA_WidgetData widgetData(pThisNode);
2107 pLocale = widgetData.GetLocal(); 2107 pLocale = widgetData.GetLocal();
2108 } else { 2108 } else {
2109 pLocale = pMgr->GetLocaleByName(CFX_WideString::FromUTF8(szLocale)); 2109 pLocale = pMgr->GetLocaleByName(CFX_WideString::FromUTF8(szLocale));
2110 } 2110 }
2111 if (!pLocale) 2111 if (!pLocale)
2112 return FALSE; 2112 return false;
2113 2113
2114 CFX_WideString wsFormat; 2114 CFX_WideString wsFormat;
2115 if (szFormat.IsEmpty()) 2115 if (szFormat.IsEmpty())
2116 pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat); 2116 pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat);
2117 else 2117 else
2118 wsFormat = CFX_WideString::FromUTF8(szFormat); 2118 wsFormat = CFX_WideString::FromUTF8(szFormat);
2119 2119
2120 wsFormat = L"time{" + wsFormat + L"}"; 2120 wsFormat = L"time{" + wsFormat + L"}";
2121 CXFA_LocaleValue widgetValue(XFA_VT_TIME, CFX_WideString::FromUTF8(szTime), 2121 CXFA_LocaleValue widgetValue(XFA_VT_TIME, CFX_WideString::FromUTF8(szTime),
2122 pMgr); 2122 pMgr);
2123 CFX_WideString wsRet; 2123 CFX_WideString wsRet;
2124 widgetValue.FormatPatterns(wsRet, wsFormat, pLocale, 2124 widgetValue.FormatPatterns(wsRet, wsFormat, pLocale,
2125 XFA_VALUEPICTURE_Display); 2125 XFA_VALUEPICTURE_Display);
2126 strGMTTime = FX_UTF8Encode(wsRet.c_str(), wsRet.GetLength()); 2126 strGMTTime = FX_UTF8Encode(wsRet.c_str(), wsRet.GetLength());
2127 return TRUE; 2127 return true;
2128 } 2128 }
2129 2129
2130 // static 2130 // static
2131 int32_t CXFA_FM2JSContext::DateString2Num(const CFX_ByteStringC& szDateString) { 2131 int32_t CXFA_FM2JSContext::DateString2Num(const CFX_ByteStringC& szDateString) {
2132 int32_t iLength = szDateString.GetLength(); 2132 int32_t iLength = szDateString.GetLength();
2133 int32_t iYear = 0; 2133 int32_t iYear = 0;
2134 int32_t iMonth = 0; 2134 int32_t iMonth = 0;
2135 int32_t iDay = 0; 2135 int32_t iDay = 0;
2136 if (iLength <= 10) { 2136 if (iLength <= 10) {
2137 int32_t iStyle = -1; 2137 int32_t iStyle = -1;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
2182 ++i; 2182 ++i;
2183 } 2183 }
2184 return (int32_t)dDays; 2184 return (int32_t)dDays;
2185 } 2185 }
2186 2186
2187 // static 2187 // static
2188 void CXFA_FM2JSContext::GetLocalDateFormat(CFXJSE_Value* pThis, 2188 void CXFA_FM2JSContext::GetLocalDateFormat(CFXJSE_Value* pThis,
2189 int32_t iStyle, 2189 int32_t iStyle,
2190 const CFX_ByteStringC& szLocalStr, 2190 const CFX_ByteStringC& szLocalStr,
2191 CFX_ByteString& strFormat, 2191 CFX_ByteString& strFormat,
2192 FX_BOOL bStandard) { 2192 bool bStandard) {
2193 FX_LOCALEDATETIMESUBCATEGORY strStyle; 2193 FX_LOCALEDATETIMESUBCATEGORY strStyle;
2194 switch (iStyle) { 2194 switch (iStyle) {
2195 case 1: 2195 case 1:
2196 strStyle = FX_LOCALEDATETIMESUBCATEGORY_Short; 2196 strStyle = FX_LOCALEDATETIMESUBCATEGORY_Short;
2197 break; 2197 break;
2198 case 3: 2198 case 3:
2199 strStyle = FX_LOCALEDATETIMESUBCATEGORY_Long; 2199 strStyle = FX_LOCALEDATETIMESUBCATEGORY_Long;
2200 break; 2200 break;
2201 case 4: 2201 case 4:
2202 strStyle = FX_LOCALEDATETIMESUBCATEGORY_Full; 2202 strStyle = FX_LOCALEDATETIMESUBCATEGORY_Full;
(...skipping 30 matching lines...) Expand all
2233 AlternateDateTimeSymbols(strRet, wsSymbols, g_sAltTable_Date); 2233 AlternateDateTimeSymbols(strRet, wsSymbols, g_sAltTable_Date);
2234 } 2234 }
2235 strFormat = FX_UTF8Encode(strRet.c_str(), strRet.GetLength()); 2235 strFormat = FX_UTF8Encode(strRet.c_str(), strRet.GetLength());
2236 } 2236 }
2237 2237
2238 // static 2238 // static
2239 void CXFA_FM2JSContext::GetLocalTimeFormat(CFXJSE_Value* pThis, 2239 void CXFA_FM2JSContext::GetLocalTimeFormat(CFXJSE_Value* pThis,
2240 int32_t iStyle, 2240 int32_t iStyle,
2241 const CFX_ByteStringC& szLocalStr, 2241 const CFX_ByteStringC& szLocalStr,
2242 CFX_ByteString& strFormat, 2242 CFX_ByteString& strFormat,
2243 FX_BOOL bStandard) { 2243 bool bStandard) {
2244 FX_LOCALEDATETIMESUBCATEGORY strStyle; 2244 FX_LOCALEDATETIMESUBCATEGORY strStyle;
2245 switch (iStyle) { 2245 switch (iStyle) {
2246 case 1: 2246 case 1:
2247 strStyle = FX_LOCALEDATETIMESUBCATEGORY_Short; 2247 strStyle = FX_LOCALEDATETIMESUBCATEGORY_Short;
2248 break; 2248 break;
2249 case 3: 2249 case 3:
2250 strStyle = FX_LOCALEDATETIMESUBCATEGORY_Long; 2250 strStyle = FX_LOCALEDATETIMESUBCATEGORY_Long;
2251 break; 2251 break;
2252 case 4: 2252 case 4:
2253 strStyle = FX_LOCALEDATETIMESUBCATEGORY_Full; 2253 strStyle = FX_LOCALEDATETIMESUBCATEGORY_Full;
(...skipping 30 matching lines...) Expand all
2284 AlternateDateTimeSymbols(strRet, wsSymbols, g_sAltTable_Time); 2284 AlternateDateTimeSymbols(strRet, wsSymbols, g_sAltTable_Time);
2285 } 2285 }
2286 strFormat = FX_UTF8Encode(strRet.c_str(), strRet.GetLength()); 2286 strFormat = FX_UTF8Encode(strRet.c_str(), strRet.GetLength());
2287 } 2287 }
2288 2288
2289 // static 2289 // static
2290 void CXFA_FM2JSContext::GetStandardDateFormat(CFXJSE_Value* pThis, 2290 void CXFA_FM2JSContext::GetStandardDateFormat(CFXJSE_Value* pThis,
2291 int32_t iStyle, 2291 int32_t iStyle,
2292 const CFX_ByteStringC& szLocalStr, 2292 const CFX_ByteStringC& szLocalStr,
2293 CFX_ByteString& strFormat) { 2293 CFX_ByteString& strFormat) {
2294 GetLocalDateFormat(pThis, iStyle, szLocalStr, strFormat, TRUE); 2294 GetLocalDateFormat(pThis, iStyle, szLocalStr, strFormat, true);
2295 } 2295 }
2296 2296
2297 // static 2297 // static
2298 void CXFA_FM2JSContext::GetStandardTimeFormat(CFXJSE_Value* pThis, 2298 void CXFA_FM2JSContext::GetStandardTimeFormat(CFXJSE_Value* pThis,
2299 int32_t iStyle, 2299 int32_t iStyle,
2300 const CFX_ByteStringC& szLocalStr, 2300 const CFX_ByteStringC& szLocalStr,
2301 CFX_ByteString& strFormat) { 2301 CFX_ByteString& strFormat) {
2302 GetLocalTimeFormat(pThis, iStyle, szLocalStr, strFormat, TRUE); 2302 GetLocalTimeFormat(pThis, iStyle, szLocalStr, strFormat, true);
2303 } 2303 }
2304 2304
2305 // static 2305 // static
2306 void CXFA_FM2JSContext::Num2AllTime(CFXJSE_Value* pThis, 2306 void CXFA_FM2JSContext::Num2AllTime(CFXJSE_Value* pThis,
2307 int32_t iTime, 2307 int32_t iTime,
2308 const CFX_ByteStringC& szFormat, 2308 const CFX_ByteStringC& szFormat,
2309 const CFX_ByteStringC& szLocale, 2309 const CFX_ByteStringC& szLocale,
2310 FX_BOOL bGM, 2310 bool bGM,
2311 CFX_ByteString& strTime) { 2311 CFX_ByteString& strTime) {
2312 int32_t iHour = 0; 2312 int32_t iHour = 0;
2313 int32_t iMin = 0; 2313 int32_t iMin = 0;
2314 int32_t iSec = 0; 2314 int32_t iSec = 0;
2315 iHour = static_cast<int>(iTime) / 3600000; 2315 iHour = static_cast<int>(iTime) / 3600000;
2316 iMin = (static_cast<int>(iTime) - iHour * 3600000) / 60000; 2316 iMin = (static_cast<int>(iTime) - iHour * 3600000) / 60000;
2317 iSec = (static_cast<int>(iTime) - iHour * 3600000 - iMin * 60000) / 1000; 2317 iSec = (static_cast<int>(iTime) - iHour * 3600000 - iMin * 60000) / 1000;
2318 2318
2319 if (!bGM) { 2319 if (!bGM) {
2320 int32_t iZoneHour = 0; 2320 int32_t iZoneHour = 0;
2321 int32_t iZoneMin = 0; 2321 int32_t iZoneMin = 0;
2322 int32_t iZoneSec = 0; 2322 int32_t iZoneSec = 0;
2323 GetLocalTimeZone(iZoneHour, iZoneMin, iZoneSec); 2323 GetLocalTimeZone(iZoneHour, iZoneMin, iZoneSec);
2324 iHour += iZoneHour; 2324 iHour += iZoneHour;
2325 iMin += iZoneMin; 2325 iMin += iZoneMin;
2326 iSec += iZoneSec; 2326 iSec += iZoneSec;
2327 } 2327 }
2328 2328
2329 FX_BOOL iRet = FALSE; 2329 bool iRet = false;
2330 CFX_ByteString strIsoTime; 2330 CFX_ByteString strIsoTime;
2331 strIsoTime.Format("%02d:%02d:%02d", iHour, iMin, iSec); 2331 strIsoTime.Format("%02d:%02d:%02d", iHour, iMin, iSec);
2332 if (bGM) { 2332 if (bGM) {
2333 iRet = 2333 iRet =
2334 GetGMTTime(pThis, strIsoTime.AsStringC(), szFormat, szLocale, strTime); 2334 GetGMTTime(pThis, strIsoTime.AsStringC(), szFormat, szLocale, strTime);
2335 } else { 2335 } else {
2336 iRet = IsoTime2Local(pThis, strIsoTime.AsStringC(), szFormat, szLocale, 2336 iRet = IsoTime2Local(pThis, strIsoTime.AsStringC(), szFormat, szLocale,
2337 strTime); 2337 strTime);
2338 } 2338 }
2339 if (!iRet) 2339 if (!iRet)
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after
2789 args.GetReturnValue()->SetNull(); 2789 args.GetReturnValue()->SetNull();
2790 return; 2790 return;
2791 } 2791 }
2792 2792
2793 int32_t iIndex = (int32_t)ValueToFloat(pThis, argOne.get()); 2793 int32_t iIndex = (int32_t)ValueToFloat(pThis, argOne.get());
2794 if (iIndex < 1) { 2794 if (iIndex < 1) {
2795 args.GetReturnValue()->SetString(""); 2795 args.GetReturnValue()->SetString("");
2796 return; 2796 return;
2797 } 2797 }
2798 2798
2799 FX_BOOL bFound = FALSE; 2799 bool bFound = false;
2800 FX_BOOL bStopCounterFlags = FALSE; 2800 bool bStopCounterFlags = false;
2801 int32_t iArgIndex = 1; 2801 int32_t iArgIndex = 1;
2802 int32_t iValueIndex = 0; 2802 int32_t iValueIndex = 0;
2803 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); 2803 v8::Isolate* pIsolate = pContext->GetScriptRuntime();
2804 while (!bFound && !bStopCounterFlags && (iArgIndex < argc)) { 2804 while (!bFound && !bStopCounterFlags && (iArgIndex < argc)) {
2805 std::unique_ptr<CFXJSE_Value> argIndexValue = args.GetValue(iArgIndex); 2805 std::unique_ptr<CFXJSE_Value> argIndexValue = args.GetValue(iArgIndex);
2806 if (argIndexValue->IsArray()) { 2806 if (argIndexValue->IsArray()) {
2807 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); 2807 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate));
2808 argIndexValue->GetObjectProperty("length", lengthValue.get()); 2808 argIndexValue->GetObjectProperty("length", lengthValue.get());
2809 int32_t iLength = lengthValue->ToInteger(); 2809 int32_t iLength = lengthValue->ToInteger();
2810 if (iLength > 3) 2810 if (iLength > 3)
2811 bStopCounterFlags = TRUE; 2811 bStopCounterFlags = true;
2812 2812
2813 iValueIndex += (iLength - 2); 2813 iValueIndex += (iLength - 2);
2814 if (iValueIndex >= iIndex) { 2814 if (iValueIndex >= iIndex) {
2815 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); 2815 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate));
2816 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); 2816 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate));
2817 std::unique_ptr<CFXJSE_Value> newPropertyValue( 2817 std::unique_ptr<CFXJSE_Value> newPropertyValue(
2818 new CFXJSE_Value(pIsolate)); 2818 new CFXJSE_Value(pIsolate));
2819 argIndexValue->GetObjectPropertyByIdx(1, propertyValue.get()); 2819 argIndexValue->GetObjectPropertyByIdx(1, propertyValue.get());
2820 argIndexValue->GetObjectPropertyByIdx( 2820 argIndexValue->GetObjectPropertyByIdx(
2821 (iLength - 1) - (iValueIndex - iIndex), jsObjectValue.get()); 2821 (iLength - 1) - (iValueIndex - iIndex), jsObjectValue.get());
2822 if (propertyValue->IsNull()) { 2822 if (propertyValue->IsNull()) {
2823 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get()); 2823 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get());
2824 } else { 2824 } else {
2825 jsObjectValue->GetObjectProperty( 2825 jsObjectValue->GetObjectProperty(
2826 propertyValue->ToString().AsStringC(), newPropertyValue.get()); 2826 propertyValue->ToString().AsStringC(), newPropertyValue.get());
2827 } 2827 }
2828 CFX_ByteString bsChoosed; 2828 CFX_ByteString bsChoosed;
2829 ValueToUTF8String(newPropertyValue.get(), bsChoosed); 2829 ValueToUTF8String(newPropertyValue.get(), bsChoosed);
2830 args.GetReturnValue()->SetString(bsChoosed.AsStringC()); 2830 args.GetReturnValue()->SetString(bsChoosed.AsStringC());
2831 bFound = TRUE; 2831 bFound = true;
2832 } 2832 }
2833 } else { 2833 } else {
2834 iValueIndex++; 2834 iValueIndex++;
2835 if (iValueIndex == iIndex) { 2835 if (iValueIndex == iIndex) {
2836 CFX_ByteString bsChoosed; 2836 CFX_ByteString bsChoosed;
2837 ValueToUTF8String(argIndexValue.get(), bsChoosed); 2837 ValueToUTF8String(argIndexValue.get(), bsChoosed);
2838 args.GetReturnValue()->SetString(bsChoosed.AsStringC()); 2838 args.GetReturnValue()->SetString(bsChoosed.AsStringC());
2839 bFound = TRUE; 2839 bFound = true;
2840 } 2840 }
2841 } 2841 }
2842 iArgIndex++; 2842 iArgIndex++;
2843 } 2843 }
2844 if (!bFound) 2844 if (!bFound)
2845 args.GetReturnValue()->SetString(""); 2845 args.GetReturnValue()->SetString("");
2846 } 2846 }
2847 2847
2848 // static 2848 // static
2849 void CXFA_FM2JSContext::Exists(CFXJSE_Value* pThis, 2849 void CXFA_FM2JSContext::Exists(CFXJSE_Value* pThis,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
2882 // static 2882 // static
2883 void CXFA_FM2JSContext::Oneof(CFXJSE_Value* pThis, 2883 void CXFA_FM2JSContext::Oneof(CFXJSE_Value* pThis,
2884 const CFX_ByteStringC& szFuncName, 2884 const CFX_ByteStringC& szFuncName,
2885 CFXJSE_Arguments& args) { 2885 CFXJSE_Arguments& args) {
2886 if (args.GetLength() < 2) { 2886 if (args.GetLength() < 2) {
2887 ToJSContext(pThis, nullptr) 2887 ToJSContext(pThis, nullptr)
2888 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Oneof"); 2888 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Oneof");
2889 return; 2889 return;
2890 } 2890 }
2891 2891
2892 FX_BOOL bFlags = FALSE; 2892 bool bFlags = false;
2893 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 2893 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
2894 CFXJSE_Value** parametersValue = nullptr; 2894 CFXJSE_Value** parametersValue = nullptr;
2895 int32_t iCount = 0; 2895 int32_t iCount = 0;
2896 unfoldArgs(pThis, args, parametersValue, iCount, 1); 2896 unfoldArgs(pThis, args, parametersValue, iCount, 1);
2897 for (int32_t i = 0; i < iCount; i++) { 2897 for (int32_t i = 0; i < iCount; i++) {
2898 if (simpleValueCompare(pThis, argOne.get(), parametersValue[i])) { 2898 if (simpleValueCompare(pThis, argOne.get(), parametersValue[i])) {
2899 bFlags = TRUE; 2899 bFlags = true;
2900 break; 2900 break;
2901 } 2901 }
2902 } 2902 }
2903 for (int32_t i = 0; i < iCount; i++) 2903 for (int32_t i = 0; i < iCount; i++)
2904 delete parametersValue[i]; 2904 delete parametersValue[i];
2905 FX_Free(parametersValue); 2905 FX_Free(parametersValue);
2906 2906
2907 args.GetReturnValue()->SetInteger(bFlags); 2907 args.GetReturnValue()->SetInteger(bFlags);
2908 } 2908 }
2909 2909
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
3353 const CFX_ByteStringC& szFuncName, 3353 const CFX_ByteStringC& szFuncName,
3354 CFXJSE_Arguments& args) { 3354 CFXJSE_Arguments& args) {
3355 int32_t argc = args.GetLength(); 3355 int32_t argc = args.GetLength();
3356 if (argc < 1) { 3356 if (argc < 1) {
3357 ToJSContext(pThis, nullptr) 3357 ToJSContext(pThis, nullptr)
3358 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Concat"); 3358 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Concat");
3359 return; 3359 return;
3360 } 3360 }
3361 3361
3362 CFX_ByteString resultString; 3362 CFX_ByteString resultString;
3363 FX_BOOL bAllNull = TRUE; 3363 bool bAllNull = true;
3364 for (int32_t i = 0; i < argc; i++) { 3364 for (int32_t i = 0; i < argc; i++) {
3365 std::unique_ptr<CFXJSE_Value> value = GetSimpleValue(pThis, args, i); 3365 std::unique_ptr<CFXJSE_Value> value = GetSimpleValue(pThis, args, i);
3366 if (ValueIsNull(pThis, value.get())) 3366 if (ValueIsNull(pThis, value.get()))
3367 continue; 3367 continue;
3368 3368
3369 bAllNull = FALSE; 3369 bAllNull = false;
3370 3370
3371 CFX_ByteString valueStr; 3371 CFX_ByteString valueStr;
3372 ValueToUTF8String(value.get(), valueStr); 3372 ValueToUTF8String(value.get(), valueStr);
3373 resultString += valueStr; 3373 resultString += valueStr;
3374 } 3374 }
3375 3375
3376 if (bAllNull) { 3376 if (bAllNull) {
3377 args.GetReturnValue()->SetNull(); 3377 args.GetReturnValue()->SetNull();
3378 return; 3378 return;
3379 } 3379 }
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after
3926 } 3926 }
3927 } 3927 }
3928 wsResultBuf.AppendChar(0); 3928 wsResultBuf.AppendChar(0);
3929 szResultBuf.Clear(); 3929 szResultBuf.Clear();
3930 3930
3931 szResultBuf << FX_UTF8Encode(wsResultBuf.GetBuffer(), wsResultBuf.GetLength()) 3931 szResultBuf << FX_UTF8Encode(wsResultBuf.GetBuffer(), wsResultBuf.GetLength())
3932 .AsStringC(); 3932 .AsStringC();
3933 } 3933 }
3934 3934
3935 // static 3935 // static
3936 FX_BOOL CXFA_FM2JSContext::HTMLSTR2Code(const CFX_WideStringC& pData, 3936 bool CXFA_FM2JSContext::HTMLSTR2Code(const CFX_WideStringC& pData,
3937 uint32_t& iCode) { 3937 uint32_t& iCode) {
3938 uint32_t uHash = FX_HashCode_GetW(pData, false); 3938 uint32_t uHash = FX_HashCode_GetW(pData, false);
3939 int32_t iStart = 0; 3939 int32_t iStart = 0;
3940 int32_t iEnd = FX_ArraySize(reservesForDecode) - 1; 3940 int32_t iEnd = FX_ArraySize(reservesForDecode) - 1;
3941 do { 3941 do {
3942 int32_t iMid = (iStart + iEnd) / 2; 3942 int32_t iMid = (iStart + iEnd) / 2;
3943 XFA_FMHtmlHashedReserveCode htmlhashedreservecode = reservesForDecode[iMid]; 3943 XFA_FMHtmlHashedReserveCode htmlhashedreservecode = reservesForDecode[iMid];
3944 if (uHash == htmlhashedreservecode.m_uHash) { 3944 if (uHash == htmlhashedreservecode.m_uHash) {
3945 iCode = htmlhashedreservecode.m_uCode; 3945 iCode = htmlhashedreservecode.m_uCode;
3946 return TRUE; 3946 return true;
3947 } 3947 }
3948 3948
3949 if (uHash < htmlhashedreservecode.m_uHash) 3949 if (uHash < htmlhashedreservecode.m_uHash)
3950 iEnd = iMid - 1; 3950 iEnd = iMid - 1;
3951 else 3951 else
3952 iStart = iMid + 1; 3952 iStart = iMid + 1;
3953 } while (iStart <= iEnd); 3953 } while (iStart <= iEnd);
3954 return FALSE; 3954 return false;
3955 } 3955 }
3956 3956
3957 // static 3957 // static
3958 FX_BOOL CXFA_FM2JSContext::HTMLCode2STR(uint32_t iCode, 3958 bool CXFA_FM2JSContext::HTMLCode2STR(uint32_t iCode,
3959 CFX_WideString& wsHTMLReserve) { 3959 CFX_WideString& wsHTMLReserve) {
3960 int32_t iStart = 0; 3960 int32_t iStart = 0;
3961 int32_t iEnd = FX_ArraySize(reservesForEncode) - 1; 3961 int32_t iEnd = FX_ArraySize(reservesForEncode) - 1;
3962 do { 3962 do {
3963 int32_t iMid = (iStart + iEnd) / 2; 3963 int32_t iMid = (iStart + iEnd) / 2;
3964 XFA_FMHtmlReserveCode htmlreservecode = reservesForEncode[iMid]; 3964 XFA_FMHtmlReserveCode htmlreservecode = reservesForEncode[iMid];
3965 if (iCode == htmlreservecode.m_uCode) { 3965 if (iCode == htmlreservecode.m_uCode) {
3966 wsHTMLReserve = htmlreservecode.m_htmlReserve; 3966 wsHTMLReserve = htmlreservecode.m_htmlReserve;
3967 return TRUE; 3967 return true;
3968 } 3968 }
3969 3969
3970 if (iCode < htmlreservecode.m_uCode) 3970 if (iCode < htmlreservecode.m_uCode)
3971 iEnd = iMid - 1; 3971 iEnd = iMid - 1;
3972 else 3972 else
3973 iStart = iMid + 1; 3973 iStart = iMid + 1;
3974 } while (iStart <= iEnd); 3974 } while (iStart <= iEnd);
3975 return FALSE; 3975 return false;
3976 } 3976 }
3977 3977
3978 // static 3978 // static
3979 void CXFA_FM2JSContext::Format(CFXJSE_Value* pThis, 3979 void CXFA_FM2JSContext::Format(CFXJSE_Value* pThis,
3980 const CFX_ByteStringC& szFuncName, 3980 const CFX_ByteStringC& szFuncName,
3981 CFXJSE_Arguments& args) { 3981 CFXJSE_Arguments& args) {
3982 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr); 3982 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
3983 if (args.GetLength() < 2) { 3983 if (args.GetLength() < 2) {
3984 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Format"); 3984 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Format");
3985 return; 3985 return;
(...skipping 1197 matching lines...) Expand 10 before | Expand all | Expand 10 after
5183 argSecond->ToString()); 5183 argSecond->ToString());
5184 return; 5184 return;
5185 } 5185 }
5186 5186
5187 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); 5187 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get());
5188 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); 5188 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get());
5189 args.GetReturnValue()->SetInteger(first != second); 5189 args.GetReturnValue()->SetInteger(first != second);
5190 } 5190 }
5191 5191
5192 // static 5192 // static
5193 FX_BOOL CXFA_FM2JSContext::fm_ref_equal(CFXJSE_Value* pThis, 5193 bool CXFA_FM2JSContext::fm_ref_equal(CFXJSE_Value* pThis,
5194 CFXJSE_Arguments& args) { 5194 CFXJSE_Arguments& args) {
5195 std::unique_ptr<CFXJSE_Value> argFirst = args.GetValue(0); 5195 std::unique_ptr<CFXJSE_Value> argFirst = args.GetValue(0);
5196 std::unique_ptr<CFXJSE_Value> argSecond = args.GetValue(1); 5196 std::unique_ptr<CFXJSE_Value> argSecond = args.GetValue(1);
5197 if (!argFirst->IsArray() || !argSecond->IsArray()) 5197 if (!argFirst->IsArray() || !argSecond->IsArray())
5198 return FALSE; 5198 return false;
5199 5199
5200 v8::Isolate* pIsolate = ToJSContext(pThis, nullptr)->GetScriptRuntime(); 5200 v8::Isolate* pIsolate = ToJSContext(pThis, nullptr)->GetScriptRuntime();
5201 std::unique_ptr<CFXJSE_Value> firstFlagValue(new CFXJSE_Value(pIsolate)); 5201 std::unique_ptr<CFXJSE_Value> firstFlagValue(new CFXJSE_Value(pIsolate));
5202 std::unique_ptr<CFXJSE_Value> secondFlagValue(new CFXJSE_Value(pIsolate)); 5202 std::unique_ptr<CFXJSE_Value> secondFlagValue(new CFXJSE_Value(pIsolate));
5203 argFirst->GetObjectPropertyByIdx(0, firstFlagValue.get()); 5203 argFirst->GetObjectPropertyByIdx(0, firstFlagValue.get());
5204 argSecond->GetObjectPropertyByIdx(0, secondFlagValue.get()); 5204 argSecond->GetObjectPropertyByIdx(0, secondFlagValue.get());
5205 if (firstFlagValue->ToInteger() != 3 || secondFlagValue->ToInteger() != 3) 5205 if (firstFlagValue->ToInteger() != 3 || secondFlagValue->ToInteger() != 3)
5206 return FALSE; 5206 return false;
5207 5207
5208 std::unique_ptr<CFXJSE_Value> firstJSObject(new CFXJSE_Value(pIsolate)); 5208 std::unique_ptr<CFXJSE_Value> firstJSObject(new CFXJSE_Value(pIsolate));
5209 std::unique_ptr<CFXJSE_Value> secondJSObject(new CFXJSE_Value(pIsolate)); 5209 std::unique_ptr<CFXJSE_Value> secondJSObject(new CFXJSE_Value(pIsolate));
5210 argFirst->GetObjectPropertyByIdx(2, firstJSObject.get()); 5210 argFirst->GetObjectPropertyByIdx(2, firstJSObject.get());
5211 argSecond->GetObjectPropertyByIdx(2, secondJSObject.get()); 5211 argSecond->GetObjectPropertyByIdx(2, secondJSObject.get());
5212 if (firstJSObject->IsNull() || secondJSObject->IsNull()) 5212 if (firstJSObject->IsNull() || secondJSObject->IsNull())
5213 return FALSE; 5213 return false;
5214 5214
5215 return (firstJSObject->ToHostObject(nullptr) == 5215 return (firstJSObject->ToHostObject(nullptr) ==
5216 secondJSObject->ToHostObject(nullptr)); 5216 secondJSObject->ToHostObject(nullptr));
5217 } 5217 }
5218 5218
5219 // static 5219 // static
5220 void CXFA_FM2JSContext::less_operator(CFXJSE_Value* pThis, 5220 void CXFA_FM2JSContext::less_operator(CFXJSE_Value* pThis,
5221 const CFX_ByteStringC& szFuncName, 5221 const CFX_ByteStringC& szFuncName,
5222 CFXJSE_Arguments& args) { 5222 CFXJSE_Arguments& args) {
5223 if (args.GetLength() != 2) { 5223 if (args.GetLength() != 2) {
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
5498 if (argAccessor->IsArray()) { 5498 if (argAccessor->IsArray()) {
5499 std::unique_ptr<CFXJSE_Value> pLengthValue(new CFXJSE_Value(pIsolate)); 5499 std::unique_ptr<CFXJSE_Value> pLengthValue(new CFXJSE_Value(pIsolate));
5500 argAccessor->GetObjectProperty("length", pLengthValue.get()); 5500 argAccessor->GetObjectProperty("length", pLengthValue.get());
5501 int32_t iLength = pLengthValue->ToInteger(); 5501 int32_t iLength = pLengthValue->ToInteger();
5502 CFXJSE_Value*** hResolveValues = FX_Alloc(CFXJSE_Value**, iLength - 2); 5502 CFXJSE_Value*** hResolveValues = FX_Alloc(CFXJSE_Value**, iLength - 2);
5503 int32_t* iSizes = FX_Alloc(int32_t, iLength - 2); 5503 int32_t* iSizes = FX_Alloc(int32_t, iLength - 2);
5504 for (int32_t i = 0; i < (iLength - 2); i++) 5504 for (int32_t i = 0; i < (iLength - 2); i++)
5505 iSizes[i] = 0; 5505 iSizes[i] = 0;
5506 5506
5507 std::unique_ptr<CFXJSE_Value> hJSObjValue(new CFXJSE_Value(pIsolate)); 5507 std::unique_ptr<CFXJSE_Value> hJSObjValue(new CFXJSE_Value(pIsolate));
5508 FX_BOOL bAttribute = FALSE; 5508 bool bAttribute = false;
5509 int32_t iCounter = 0; 5509 int32_t iCounter = 0;
5510 for (int32_t i = 2; i < iLength; i++) { 5510 for (int32_t i = 2; i < iLength; i++) {
5511 argAccessor->GetObjectPropertyByIdx(i, hJSObjValue.get()); 5511 argAccessor->GetObjectPropertyByIdx(i, hJSObjValue.get());
5512 5512
5513 XFA_RESOLVENODE_RS resoveNodeRS; 5513 XFA_RESOLVENODE_RS resoveNodeRS;
5514 if (ResolveObjects(pThis, hJSObjValue.get(), szSomExp.AsStringC(), 5514 if (ResolveObjects(pThis, hJSObjValue.get(), szSomExp.AsStringC(),
5515 resoveNodeRS, TRUE, szName.IsEmpty()) > 0) { 5515 resoveNodeRS, true, szName.IsEmpty()) > 0) {
5516 ParseResolveResult(pThis, resoveNodeRS, hJSObjValue.get(), 5516 ParseResolveResult(pThis, resoveNodeRS, hJSObjValue.get(),
5517 hResolveValues[i - 2], iSizes[i - 2], bAttribute); 5517 hResolveValues[i - 2], iSizes[i - 2], bAttribute);
5518 iCounter += iSizes[i - 2]; 5518 iCounter += iSizes[i - 2];
5519 } 5519 }
5520 } 5520 }
5521 if (iCounter < 1) { 5521 if (iCounter < 1) {
5522 CFX_WideString wsPropertyName = 5522 CFX_WideString wsPropertyName =
5523 CFX_WideString::FromUTF8(szName.AsStringC()); 5523 CFX_WideString::FromUTF8(szName.AsStringC());
5524 CFX_WideString wsSomExpression = 5524 CFX_WideString wsSomExpression =
5525 CFX_WideString::FromUTF8(szSomExp.AsStringC()); 5525 CFX_WideString::FromUTF8(szSomExp.AsStringC());
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
5563 5563
5564 return; 5564 return;
5565 } 5565 }
5566 5566
5567 XFA_RESOLVENODE_RS resoveNodeRS; 5567 XFA_RESOLVENODE_RS resoveNodeRS;
5568 int32_t iRet = 0; 5568 int32_t iRet = 0;
5569 CFX_ByteString bsAccessorName = args.GetUTF8String(1); 5569 CFX_ByteString bsAccessorName = args.GetUTF8String(1);
5570 if (argAccessor->IsObject() || 5570 if (argAccessor->IsObject() ||
5571 (argAccessor->IsNull() && bsAccessorName.IsEmpty())) { 5571 (argAccessor->IsNull() && bsAccessorName.IsEmpty())) {
5572 iRet = ResolveObjects(pThis, argAccessor.get(), szSomExp.AsStringC(), 5572 iRet = ResolveObjects(pThis, argAccessor.get(), szSomExp.AsStringC(),
5573 resoveNodeRS, TRUE, szName.IsEmpty()); 5573 resoveNodeRS, true, szName.IsEmpty());
5574 } else if (!argAccessor->IsObject() && !bsAccessorName.IsEmpty() && 5574 } else if (!argAccessor->IsObject() && !bsAccessorName.IsEmpty() &&
5575 GetObjectForName(pThis, argAccessor.get(), 5575 GetObjectForName(pThis, argAccessor.get(),
5576 bsAccessorName.AsStringC())) { 5576 bsAccessorName.AsStringC())) {
5577 iRet = ResolveObjects(pThis, argAccessor.get(), szSomExp.AsStringC(), 5577 iRet = ResolveObjects(pThis, argAccessor.get(), szSomExp.AsStringC(),
5578 resoveNodeRS, TRUE, szName.IsEmpty()); 5578 resoveNodeRS, true, szName.IsEmpty());
5579 } 5579 }
5580 if (iRet < 1) { 5580 if (iRet < 1) {
5581 CFX_WideString wsPropertyName = 5581 CFX_WideString wsPropertyName =
5582 CFX_WideString::FromUTF8(szName.AsStringC()); 5582 CFX_WideString::FromUTF8(szName.AsStringC());
5583 CFX_WideString wsSomExpression = 5583 CFX_WideString wsSomExpression =
5584 CFX_WideString::FromUTF8(szSomExp.AsStringC()); 5584 CFX_WideString::FromUTF8(szSomExp.AsStringC());
5585 pContext->ThrowException(XFA_IDS_ACCESS_PROPERTY_IN_NOT_OBJECT, 5585 pContext->ThrowException(XFA_IDS_ACCESS_PROPERTY_IN_NOT_OBJECT,
5586 wsPropertyName.c_str(), wsSomExpression.c_str()); 5586 wsPropertyName.c_str(), wsSomExpression.c_str());
5587 return; 5587 return;
5588 } 5588 }
5589 5589
5590 CFXJSE_Value** hResolveValues; 5590 CFXJSE_Value** hResolveValues;
5591 int32_t iSize = 0; 5591 int32_t iSize = 0;
5592 FX_BOOL bAttribute = FALSE; 5592 bool bAttribute = false;
5593 ParseResolveResult(pThis, resoveNodeRS, argAccessor.get(), hResolveValues, 5593 ParseResolveResult(pThis, resoveNodeRS, argAccessor.get(), hResolveValues,
5594 iSize, bAttribute); 5594 iSize, bAttribute);
5595 CFXJSE_Value** rgValues = FX_Alloc(CFXJSE_Value*, iSize + 2); 5595 CFXJSE_Value** rgValues = FX_Alloc(CFXJSE_Value*, iSize + 2);
5596 for (int32_t i = 0; i < (iSize + 2); i++) 5596 for (int32_t i = 0; i < (iSize + 2); i++)
5597 rgValues[i] = new CFXJSE_Value(pIsolate); 5597 rgValues[i] = new CFXJSE_Value(pIsolate);
5598 5598
5599 rgValues[0]->SetInteger(1); 5599 rgValues[0]->SetInteger(1);
5600 if (bAttribute) 5600 if (bAttribute)
5601 rgValues[1]->SetString(szName.AsStringC()); 5601 rgValues[1]->SetString(szName.AsStringC());
5602 else 5602 else
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
5642 std::unique_ptr<CFXJSE_Value> argAccessor = args.GetValue(0); 5642 std::unique_ptr<CFXJSE_Value> argAccessor = args.GetValue(0);
5643 if (argAccessor->IsArray()) { 5643 if (argAccessor->IsArray()) {
5644 std::unique_ptr<CFXJSE_Value> pLengthValue(new CFXJSE_Value(pIsolate)); 5644 std::unique_ptr<CFXJSE_Value> pLengthValue(new CFXJSE_Value(pIsolate));
5645 argAccessor->GetObjectProperty("length", pLengthValue.get()); 5645 argAccessor->GetObjectProperty("length", pLengthValue.get());
5646 int32_t iLength = pLengthValue->ToInteger(); 5646 int32_t iLength = pLengthValue->ToInteger();
5647 int32_t iCounter = 0; 5647 int32_t iCounter = 0;
5648 5648
5649 CFXJSE_Value*** hResolveValues = FX_Alloc(CFXJSE_Value**, iLength - 2); 5649 CFXJSE_Value*** hResolveValues = FX_Alloc(CFXJSE_Value**, iLength - 2);
5650 int32_t* iSizes = FX_Alloc(int32_t, iLength - 2); 5650 int32_t* iSizes = FX_Alloc(int32_t, iLength - 2);
5651 std::unique_ptr<CFXJSE_Value> hJSObjValue(new CFXJSE_Value(pIsolate)); 5651 std::unique_ptr<CFXJSE_Value> hJSObjValue(new CFXJSE_Value(pIsolate));
5652 FX_BOOL bAttribute = FALSE; 5652 bool bAttribute = false;
5653 for (int32_t i = 2; i < iLength; i++) { 5653 for (int32_t i = 2; i < iLength; i++) {
5654 argAccessor->GetObjectPropertyByIdx(i, hJSObjValue.get()); 5654 argAccessor->GetObjectPropertyByIdx(i, hJSObjValue.get());
5655 XFA_RESOLVENODE_RS resoveNodeRS; 5655 XFA_RESOLVENODE_RS resoveNodeRS;
5656 if (ResolveObjects(pThis, hJSObjValue.get(), szSomExp.AsStringC(), 5656 if (ResolveObjects(pThis, hJSObjValue.get(), szSomExp.AsStringC(),
5657 resoveNodeRS, FALSE) > 0) { 5657 resoveNodeRS, false) > 0) {
5658 ParseResolveResult(pThis, resoveNodeRS, hJSObjValue.get(), 5658 ParseResolveResult(pThis, resoveNodeRS, hJSObjValue.get(),
5659 hResolveValues[i - 2], iSizes[i - 2], bAttribute); 5659 hResolveValues[i - 2], iSizes[i - 2], bAttribute);
5660 iCounter += iSizes[i - 2]; 5660 iCounter += iSizes[i - 2];
5661 } 5661 }
5662 } 5662 }
5663 if (iCounter < 1) { 5663 if (iCounter < 1) {
5664 CFX_WideString wsPropertyName = 5664 CFX_WideString wsPropertyName =
5665 CFX_WideString::FromUTF8(szName.AsStringC()); 5665 CFX_WideString::FromUTF8(szName.AsStringC());
5666 CFX_WideString wsSomExpression = 5666 CFX_WideString wsSomExpression =
5667 CFX_WideString::FromUTF8(szSomExp.AsStringC()); 5667 CFX_WideString::FromUTF8(szSomExp.AsStringC());
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
5701 FX_Free(iSizes); 5701 FX_Free(iSizes);
5702 return; 5702 return;
5703 } 5703 }
5704 5704
5705 XFA_RESOLVENODE_RS resoveNodeRS; 5705 XFA_RESOLVENODE_RS resoveNodeRS;
5706 int32_t iRet = 0; 5706 int32_t iRet = 0;
5707 CFX_ByteString bsAccessorName = args.GetUTF8String(1); 5707 CFX_ByteString bsAccessorName = args.GetUTF8String(1);
5708 if (argAccessor->IsObject() || 5708 if (argAccessor->IsObject() ||
5709 (argAccessor->IsNull() && bsAccessorName.IsEmpty())) { 5709 (argAccessor->IsNull() && bsAccessorName.IsEmpty())) {
5710 iRet = ResolveObjects(pThis, argAccessor.get(), szSomExp.AsStringC(), 5710 iRet = ResolveObjects(pThis, argAccessor.get(), szSomExp.AsStringC(),
5711 resoveNodeRS, FALSE); 5711 resoveNodeRS, false);
5712 } else if (!argAccessor->IsObject() && !bsAccessorName.IsEmpty() && 5712 } else if (!argAccessor->IsObject() && !bsAccessorName.IsEmpty() &&
5713 GetObjectForName(pThis, argAccessor.get(), 5713 GetObjectForName(pThis, argAccessor.get(),
5714 bsAccessorName.AsStringC())) { 5714 bsAccessorName.AsStringC())) {
5715 iRet = ResolveObjects(pThis, argAccessor.get(), szSomExp.AsStringC(), 5715 iRet = ResolveObjects(pThis, argAccessor.get(), szSomExp.AsStringC(),
5716 resoveNodeRS, FALSE); 5716 resoveNodeRS, false);
5717 } 5717 }
5718 if (iRet < 1) { 5718 if (iRet < 1) {
5719 CFX_WideString wsPropertyName = 5719 CFX_WideString wsPropertyName =
5720 CFX_WideString::FromUTF8(szName.AsStringC()); 5720 CFX_WideString::FromUTF8(szName.AsStringC());
5721 CFX_WideString wsSomExpression = 5721 CFX_WideString wsSomExpression =
5722 CFX_WideString::FromUTF8(szSomExp.AsStringC()); 5722 CFX_WideString::FromUTF8(szSomExp.AsStringC());
5723 pContext->ThrowException(XFA_IDS_ACCESS_PROPERTY_IN_NOT_OBJECT, 5723 pContext->ThrowException(XFA_IDS_ACCESS_PROPERTY_IN_NOT_OBJECT,
5724 wsPropertyName.c_str(), wsSomExpression.c_str()); 5724 wsPropertyName.c_str(), wsSomExpression.c_str());
5725 return; 5725 return;
5726 } 5726 }
5727 5727
5728 CFXJSE_Value** hResolveValues; 5728 CFXJSE_Value** hResolveValues;
5729 int32_t iSize = 0; 5729 int32_t iSize = 0;
5730 FX_BOOL bAttribute = FALSE; 5730 bool bAttribute = false;
5731 ParseResolveResult(pThis, resoveNodeRS, argAccessor.get(), hResolveValues, 5731 ParseResolveResult(pThis, resoveNodeRS, argAccessor.get(), hResolveValues,
5732 iSize, bAttribute); 5732 iSize, bAttribute);
5733 CFXJSE_Value** rgValues = FX_Alloc(CFXJSE_Value*, iSize + 2); 5733 CFXJSE_Value** rgValues = FX_Alloc(CFXJSE_Value*, iSize + 2);
5734 for (int32_t i = 0; i < (iSize + 2); i++) 5734 for (int32_t i = 0; i < (iSize + 2); i++)
5735 rgValues[i] = new CFXJSE_Value(pIsolate); 5735 rgValues[i] = new CFXJSE_Value(pIsolate);
5736 5736
5737 rgValues[0]->SetInteger(1); 5737 rgValues[0]->SetInteger(1);
5738 if (bAttribute) 5738 if (bAttribute)
5739 rgValues[1]->SetString(szName.AsStringC()); 5739 rgValues[1]->SetString(szName.AsStringC());
5740 else 5740 else
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
5785 CFX_WideString javaScript = wsJavaScriptBuf.MakeString(); 5785 CFX_WideString javaScript = wsJavaScriptBuf.MakeString();
5786 args.GetReturnValue()->SetString( 5786 args.GetReturnValue()->SetString(
5787 FX_UTF8Encode(javaScript.c_str(), javaScript.GetLength()).AsStringC()); 5787 FX_UTF8Encode(javaScript.c_str(), javaScript.GetLength()).AsStringC());
5788 } 5788 }
5789 5789
5790 // static 5790 // static
5791 void CXFA_FM2JSContext::is_fm_object(CFXJSE_Value* pThis, 5791 void CXFA_FM2JSContext::is_fm_object(CFXJSE_Value* pThis,
5792 const CFX_ByteStringC& szFuncName, 5792 const CFX_ByteStringC& szFuncName,
5793 CFXJSE_Arguments& args) { 5793 CFXJSE_Arguments& args) {
5794 if (args.GetLength() != 1) { 5794 if (args.GetLength() != 1) {
5795 args.GetReturnValue()->SetBoolean(FALSE); 5795 args.GetReturnValue()->SetBoolean(false);
5796 return; 5796 return;
5797 } 5797 }
5798 5798
5799 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); 5799 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0);
5800 args.GetReturnValue()->SetBoolean(argOne->IsObject()); 5800 args.GetReturnValue()->SetBoolean(argOne->IsObject());
5801 } 5801 }
5802 5802
5803 // static 5803 // static
5804 void CXFA_FM2JSContext::is_fm_array(CFXJSE_Value* pThis, 5804 void CXFA_FM2JSContext::is_fm_array(CFXJSE_Value* pThis,
5805 const CFX_ByteStringC& szFuncName, 5805 const CFX_ByteStringC& szFuncName,
5806 CFXJSE_Arguments& args) { 5806 CFXJSE_Arguments& args) {
5807 if (args.GetLength() != 1) { 5807 if (args.GetLength() != 1) {
5808 args.GetReturnValue()->SetBoolean(FALSE); 5808 args.GetReturnValue()->SetBoolean(false);
5809 return; 5809 return;
5810 } 5810 }
5811 5811
5812 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); 5812 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0);
5813 args.GetReturnValue()->SetBoolean(argOne->IsArray()); 5813 args.GetReturnValue()->SetBoolean(argOne->IsArray());
5814 } 5814 }
5815 5815
5816 // static 5816 // static
5817 void CXFA_FM2JSContext::get_fm_value(CFXJSE_Value* pThis, 5817 void CXFA_FM2JSContext::get_fm_value(CFXJSE_Value* pThis,
5818 const CFX_ByteStringC& szFuncName, 5818 const CFX_ByteStringC& szFuncName,
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
6010 simpleValue.get()); 6010 simpleValue.get());
6011 return simpleValue; 6011 return simpleValue;
6012 } 6012 }
6013 6013
6014 std::unique_ptr<CFXJSE_Value> defaultValue(new CFXJSE_Value(pIsolate)); 6014 std::unique_ptr<CFXJSE_Value> defaultValue(new CFXJSE_Value(pIsolate));
6015 GetObjectDefaultValue(argIndex.get(), defaultValue.get()); 6015 GetObjectDefaultValue(argIndex.get(), defaultValue.get());
6016 return defaultValue; 6016 return defaultValue;
6017 } 6017 }
6018 6018
6019 // static 6019 // static
6020 FX_BOOL CXFA_FM2JSContext::ValueIsNull(CFXJSE_Value* pThis, CFXJSE_Value* arg) { 6020 bool CXFA_FM2JSContext::ValueIsNull(CFXJSE_Value* pThis, CFXJSE_Value* arg) {
6021 if (!arg || arg->IsNull()) 6021 if (!arg || arg->IsNull())
6022 return TRUE; 6022 return true;
6023 6023
6024 if (!arg->IsArray() && !arg->IsObject()) 6024 if (!arg->IsArray() && !arg->IsObject())
6025 return FALSE; 6025 return false;
6026 6026
6027 v8::Isolate* pIsolate = ToJSContext(pThis, nullptr)->GetScriptRuntime(); 6027 v8::Isolate* pIsolate = ToJSContext(pThis, nullptr)->GetScriptRuntime();
6028 if (arg->IsArray()) { 6028 if (arg->IsArray()) {
6029 int32_t iLength = hvalue_get_array_length(pThis, arg); 6029 int32_t iLength = hvalue_get_array_length(pThis, arg);
6030 if (iLength < 3) 6030 if (iLength < 3)
6031 return TRUE; 6031 return true;
6032 6032
6033 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); 6033 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate));
6034 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); 6034 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate));
6035 arg->GetObjectPropertyByIdx(1, propertyValue.get()); 6035 arg->GetObjectPropertyByIdx(1, propertyValue.get());
6036 arg->GetObjectPropertyByIdx(2, jsObjectValue.get()); 6036 arg->GetObjectPropertyByIdx(2, jsObjectValue.get());
6037 if (propertyValue->IsNull()) { 6037 if (propertyValue->IsNull()) {
6038 std::unique_ptr<CFXJSE_Value> defaultValue(new CFXJSE_Value(pIsolate)); 6038 std::unique_ptr<CFXJSE_Value> defaultValue(new CFXJSE_Value(pIsolate));
6039 GetObjectDefaultValue(jsObjectValue.get(), defaultValue.get()); 6039 GetObjectDefaultValue(jsObjectValue.get(), defaultValue.get());
6040 return defaultValue->IsNull(); 6040 return defaultValue->IsNull();
6041 } 6041 }
(...skipping 15 matching lines...) Expand all
6057 if (!arg || !arg->IsArray()) 6057 if (!arg || !arg->IsArray())
6058 return 0; 6058 return 0;
6059 6059
6060 v8::Isolate* pIsolate = ToJSContext(pThis, nullptr)->GetScriptRuntime(); 6060 v8::Isolate* pIsolate = ToJSContext(pThis, nullptr)->GetScriptRuntime();
6061 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); 6061 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate));
6062 arg->GetObjectProperty("length", lengthValue.get()); 6062 arg->GetObjectProperty("length", lengthValue.get());
6063 return lengthValue->ToInteger(); 6063 return lengthValue->ToInteger();
6064 } 6064 }
6065 6065
6066 // static 6066 // static
6067 FX_BOOL CXFA_FM2JSContext::simpleValueCompare(CFXJSE_Value* pThis, 6067 bool CXFA_FM2JSContext::simpleValueCompare(CFXJSE_Value* pThis,
6068 CFXJSE_Value* firstValue, 6068 CFXJSE_Value* firstValue,
6069 CFXJSE_Value* secondValue) { 6069 CFXJSE_Value* secondValue) {
6070 if (!firstValue) 6070 if (!firstValue)
6071 return FALSE; 6071 return false;
6072 6072
6073 if (firstValue->IsString()) { 6073 if (firstValue->IsString()) {
6074 CFX_ByteString firstString, secondString; 6074 CFX_ByteString firstString, secondString;
6075 ValueToUTF8String(firstValue, firstString); 6075 ValueToUTF8String(firstValue, firstString);
6076 ValueToUTF8String(secondValue, secondString); 6076 ValueToUTF8String(secondValue, secondString);
6077 return firstString == secondString; 6077 return firstString == secondString;
6078 } 6078 }
6079 if (firstValue->IsNumber()) { 6079 if (firstValue->IsNumber()) {
6080 FX_FLOAT first = ValueToFloat(pThis, firstValue); 6080 FX_FLOAT first = ValueToFloat(pThis, firstValue);
6081 FX_FLOAT second = ValueToFloat(pThis, secondValue); 6081 FX_FLOAT second = ValueToFloat(pThis, secondValue);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
6150 } 6150 }
6151 6151
6152 // static 6152 // static
6153 void CXFA_FM2JSContext::GetObjectDefaultValue(CFXJSE_Value* pValue, 6153 void CXFA_FM2JSContext::GetObjectDefaultValue(CFXJSE_Value* pValue,
6154 CFXJSE_Value* pDefaultValue) { 6154 CFXJSE_Value* pDefaultValue) {
6155 CXFA_Node* pNode = ToNode(CXFA_ScriptContext::ToObject(pValue, nullptr)); 6155 CXFA_Node* pNode = ToNode(CXFA_ScriptContext::ToObject(pValue, nullptr));
6156 if (!pNode) { 6156 if (!pNode) {
6157 pDefaultValue->SetNull(); 6157 pDefaultValue->SetNull();
6158 return; 6158 return;
6159 } 6159 }
6160 pNode->Script_Som_DefaultValue(pDefaultValue, FALSE, (XFA_ATTRIBUTE)-1); 6160 pNode->Script_Som_DefaultValue(pDefaultValue, false, (XFA_ATTRIBUTE)-1);
6161 } 6161 }
6162 6162
6163 // static 6163 // static
6164 FX_BOOL CXFA_FM2JSContext::SetObjectDefaultValue(CFXJSE_Value* pValue, 6164 bool CXFA_FM2JSContext::SetObjectDefaultValue(CFXJSE_Value* pValue,
6165 CFXJSE_Value* hNewValue) { 6165 CFXJSE_Value* hNewValue) {
6166 CXFA_Node* pNode = ToNode(CXFA_ScriptContext::ToObject(pValue, nullptr)); 6166 CXFA_Node* pNode = ToNode(CXFA_ScriptContext::ToObject(pValue, nullptr));
6167 if (!pNode) 6167 if (!pNode)
6168 return FALSE; 6168 return false;
6169 6169
6170 pNode->Script_Som_DefaultValue(hNewValue, TRUE, (XFA_ATTRIBUTE)-1); 6170 pNode->Script_Som_DefaultValue(hNewValue, true, (XFA_ATTRIBUTE)-1);
6171 return TRUE; 6171 return true;
6172 } 6172 }
6173 6173
6174 // static 6174 // static
6175 void CXFA_FM2JSContext::GenerateSomExpression(const CFX_ByteStringC& szName, 6175 void CXFA_FM2JSContext::GenerateSomExpression(const CFX_ByteStringC& szName,
6176 int32_t iIndexFlags, 6176 int32_t iIndexFlags,
6177 int32_t iIndexValue, 6177 int32_t iIndexValue,
6178 bool bIsStar, 6178 bool bIsStar,
6179 CFX_ByteString& szSomExp) { 6179 CFX_ByteString& szSomExp) {
6180 if (bIsStar) { 6180 if (bIsStar) {
6181 szSomExp = szName + "[*]"; 6181 szSomExp = szName + "[*]";
(...skipping 14 matching lines...) Expand all
6196 szSomExp += "]"; 6196 szSomExp += "]";
6197 } else { 6197 } else {
6198 szSomExp = (iIndexValue < 0) ? (szName + "[") : (szName + "[-"); 6198 szSomExp = (iIndexValue < 0) ? (szName + "[") : (szName + "[-");
6199 iIndexValue = (iIndexValue < 0) ? (0 - iIndexValue) : iIndexValue; 6199 iIndexValue = (iIndexValue < 0) ? (0 - iIndexValue) : iIndexValue;
6200 szSomExp += CFX_ByteString::FormatInteger(iIndexValue); 6200 szSomExp += CFX_ByteString::FormatInteger(iIndexValue);
6201 szSomExp += "]"; 6201 szSomExp += "]";
6202 } 6202 }
6203 } 6203 }
6204 6204
6205 // static 6205 // static
6206 FX_BOOL CXFA_FM2JSContext::GetObjectForName( 6206 bool CXFA_FM2JSContext::GetObjectForName(
6207 CFXJSE_Value* pThis, 6207 CFXJSE_Value* pThis,
6208 CFXJSE_Value* accessorValue, 6208 CFXJSE_Value* accessorValue,
6209 const CFX_ByteStringC& szAccessorName) { 6209 const CFX_ByteStringC& szAccessorName) {
6210 CXFA_Document* pDoc = ToJSContext(pThis, nullptr)->GetDocument(); 6210 CXFA_Document* pDoc = ToJSContext(pThis, nullptr)->GetDocument();
6211 if (!pDoc) 6211 if (!pDoc)
6212 return FALSE; 6212 return false;
6213 6213
6214 CXFA_ScriptContext* pScriptContext = pDoc->GetScriptContext(); 6214 CXFA_ScriptContext* pScriptContext = pDoc->GetScriptContext();
6215 XFA_RESOLVENODE_RS resoveNodeRS; 6215 XFA_RESOLVENODE_RS resoveNodeRS;
6216 uint32_t dwFlags = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties | 6216 uint32_t dwFlags = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties |
6217 XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent; 6217 XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent;
6218 int32_t iRet = pScriptContext->ResolveObjects( 6218 int32_t iRet = pScriptContext->ResolveObjects(
6219 pScriptContext->GetThisObject(), 6219 pScriptContext->GetThisObject(),
6220 CFX_WideString::FromUTF8(szAccessorName).AsStringC(), resoveNodeRS, 6220 CFX_WideString::FromUTF8(szAccessorName).AsStringC(), resoveNodeRS,
6221 dwFlags); 6221 dwFlags);
6222 if (iRet >= 1 && resoveNodeRS.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) { 6222 if (iRet >= 1 && resoveNodeRS.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) {
6223 accessorValue->Assign( 6223 accessorValue->Assign(
6224 pScriptContext->GetJSValueFromMap(resoveNodeRS.nodes.GetAt(0))); 6224 pScriptContext->GetJSValueFromMap(resoveNodeRS.nodes.GetAt(0)));
6225 return TRUE; 6225 return true;
6226 } 6226 }
6227 return FALSE; 6227 return false;
6228 } 6228 }
6229 6229
6230 // static 6230 // static
6231 int32_t CXFA_FM2JSContext::ResolveObjects(CFXJSE_Value* pThis, 6231 int32_t CXFA_FM2JSContext::ResolveObjects(CFXJSE_Value* pThis,
6232 CFXJSE_Value* pRefValue, 6232 CFXJSE_Value* pRefValue,
6233 const CFX_ByteStringC& bsSomExp, 6233 const CFX_ByteStringC& bsSomExp,
6234 XFA_RESOLVENODE_RS& resoveNodeRS, 6234 XFA_RESOLVENODE_RS& resoveNodeRS,
6235 FX_BOOL bdotAccessor, 6235 bool bdotAccessor,
6236 FX_BOOL bHasNoResolveName) { 6236 bool bHasNoResolveName) {
6237 CXFA_Document* pDoc = ToJSContext(pThis, nullptr)->GetDocument(); 6237 CXFA_Document* pDoc = ToJSContext(pThis, nullptr)->GetDocument();
6238 if (!pDoc) 6238 if (!pDoc)
6239 return -1; 6239 return -1;
6240 6240
6241 CFX_WideString wsSomExpression = CFX_WideString::FromUTF8(bsSomExp); 6241 CFX_WideString wsSomExpression = CFX_WideString::FromUTF8(bsSomExp);
6242 CXFA_ScriptContext* pScriptContext = pDoc->GetScriptContext(); 6242 CXFA_ScriptContext* pScriptContext = pDoc->GetScriptContext();
6243 CXFA_Object* pNode = nullptr; 6243 CXFA_Object* pNode = nullptr;
6244 uint32_t dFlags = 0UL; 6244 uint32_t dFlags = 0UL;
6245 if (bdotAccessor) { 6245 if (bdotAccessor) {
6246 if (pRefValue && pRefValue->IsNull()) { 6246 if (pRefValue && pRefValue->IsNull()) {
6247 pNode = pScriptContext->GetThisObject(); 6247 pNode = pScriptContext->GetThisObject();
6248 dFlags = XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent; 6248 dFlags = XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent;
6249 } else { 6249 } else {
6250 pNode = CXFA_ScriptContext::ToObject(pRefValue, nullptr); 6250 pNode = CXFA_ScriptContext::ToObject(pRefValue, nullptr);
6251 ASSERT(pNode); 6251 ASSERT(pNode);
6252 if (bHasNoResolveName) { 6252 if (bHasNoResolveName) {
6253 CFX_WideString wsName; 6253 CFX_WideString wsName;
6254 if (CXFA_Node* pXFANode = pNode->AsNode()) 6254 if (CXFA_Node* pXFANode = pNode->AsNode())
6255 pXFANode->GetAttribute(XFA_ATTRIBUTE_Name, wsName, FALSE); 6255 pXFANode->GetAttribute(XFA_ATTRIBUTE_Name, wsName, false);
6256 if (wsName.IsEmpty()) 6256 if (wsName.IsEmpty())
6257 wsName = FX_WSTRC(L"#") + pNode->GetClassName(); 6257 wsName = FX_WSTRC(L"#") + pNode->GetClassName();
6258 6258
6259 wsSomExpression = wsName + wsSomExpression; 6259 wsSomExpression = wsName + wsSomExpression;
6260 dFlags = XFA_RESOLVENODE_Siblings; 6260 dFlags = XFA_RESOLVENODE_Siblings;
6261 } else { 6261 } else {
6262 dFlags = (bsSomExp == "*") 6262 dFlags = (bsSomExp == "*")
6263 ? (XFA_RESOLVENODE_Children) 6263 ? (XFA_RESOLVENODE_Children)
6264 : (XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Attributes | 6264 : (XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Attributes |
6265 XFA_RESOLVENODE_Properties); 6265 XFA_RESOLVENODE_Properties);
6266 } 6266 }
6267 } 6267 }
6268 } else { 6268 } else {
6269 pNode = CXFA_ScriptContext::ToObject(pRefValue, nullptr); 6269 pNode = CXFA_ScriptContext::ToObject(pRefValue, nullptr);
6270 dFlags = XFA_RESOLVENODE_AnyChild; 6270 dFlags = XFA_RESOLVENODE_AnyChild;
6271 } 6271 }
6272 return pScriptContext->ResolveObjects(pNode, wsSomExpression.AsStringC(), 6272 return pScriptContext->ResolveObjects(pNode, wsSomExpression.AsStringC(),
6273 resoveNodeRS, dFlags); 6273 resoveNodeRS, dFlags);
6274 } 6274 }
6275 6275
6276 // static 6276 // static
6277 void CXFA_FM2JSContext::ParseResolveResult( 6277 void CXFA_FM2JSContext::ParseResolveResult(
6278 CFXJSE_Value* pThis, 6278 CFXJSE_Value* pThis,
6279 const XFA_RESOLVENODE_RS& resoveNodeRS, 6279 const XFA_RESOLVENODE_RS& resoveNodeRS,
6280 CFXJSE_Value* pParentValue, 6280 CFXJSE_Value* pParentValue,
6281 CFXJSE_Value**& resultValues, 6281 CFXJSE_Value**& resultValues,
6282 int32_t& iSize, 6282 int32_t& iSize,
6283 FX_BOOL& bAttribute) { 6283 bool& bAttribute) {
6284 iSize = 0; 6284 iSize = 0;
6285 resultValues = nullptr; 6285 resultValues = nullptr;
6286 6286
6287 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr); 6287 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
6288 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); 6288 v8::Isolate* pIsolate = pContext->GetScriptRuntime();
6289 if (resoveNodeRS.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) { 6289 if (resoveNodeRS.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) {
6290 bAttribute = FALSE; 6290 bAttribute = false;
6291 iSize = resoveNodeRS.nodes.GetSize(); 6291 iSize = resoveNodeRS.nodes.GetSize();
6292 resultValues = FX_Alloc(CFXJSE_Value*, iSize); 6292 resultValues = FX_Alloc(CFXJSE_Value*, iSize);
6293 for (int32_t i = 0; i < iSize; i++) { 6293 for (int32_t i = 0; i < iSize; i++) {
6294 resultValues[i] = new CFXJSE_Value(pIsolate); 6294 resultValues[i] = new CFXJSE_Value(pIsolate);
6295 resultValues[i]->Assign( 6295 resultValues[i]->Assign(
6296 pContext->GetDocument()->GetScriptContext()->GetJSValueFromMap( 6296 pContext->GetDocument()->GetScriptContext()->GetJSValueFromMap(
6297 resoveNodeRS.nodes.GetAt(i))); 6297 resoveNodeRS.nodes.GetAt(i)));
6298 } 6298 }
6299 return; 6299 return;
6300 } 6300 }
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
6518 CFX_WideString wsFormat; 6518 CFX_WideString wsFormat;
6519 pAppProvider->LoadString(iStringID, wsFormat); 6519 pAppProvider->LoadString(iStringID, wsFormat);
6520 CFX_WideString wsMessage; 6520 CFX_WideString wsMessage;
6521 va_list arg_ptr; 6521 va_list arg_ptr;
6522 va_start(arg_ptr, iStringID); 6522 va_start(arg_ptr, iStringID);
6523 wsMessage.FormatV(wsFormat.c_str(), arg_ptr); 6523 wsMessage.FormatV(wsFormat.c_str(), arg_ptr);
6524 va_end(arg_ptr); 6524 va_end(arg_ptr);
6525 FXJSE_ThrowMessage( 6525 FXJSE_ThrowMessage(
6526 FX_UTF8Encode(wsMessage.c_str(), wsMessage.GetLength()).AsStringC()); 6526 FX_UTF8Encode(wsMessage.c_str(), wsMessage.GetLength()).AsStringC());
6527 } 6527 }
OLDNEW
« no previous file with comments | « xfa/fxfa/fm2js/xfa_fm2jscontext.h ('k') | xfa/fxfa/fm2js/xfa_fmparse.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698