OLD | NEW |
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 "../../include/javascript/JavaScript.h" | 7 #include "../../include/javascript/JavaScript.h" |
8 #include "../../include/javascript/IJavaScript.h" | 8 #include "../../include/javascript/IJavaScript.h" |
9 #include "../../include/javascript/JS_Define.h" | 9 #include "../../include/javascript/JS_Define.h" |
10 #include "../../include/javascript/JS_Object.h" | 10 #include "../../include/javascript/JS_Object.h" |
(...skipping 1661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1672 | 1672 |
1673 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); | 1673 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); |
1674 return FALSE; | 1674 return FALSE; |
1675 } | 1675 } |
1676 | 1676 |
1677 int iIndex = params[0]; | 1677 int iIndex = params[0]; |
1678 FX_LPCWSTR cFormats[] = {L"m/d", L"m/d/yy", L"mm/dd/yy", L"mm/yy", L"d-
mmm", L"d-mmm-yy", L"dd-mmm-yy", | 1678 FX_LPCWSTR cFormats[] = {L"m/d", L"m/d/yy", L"mm/dd/yy", L"mm/yy", L"d-
mmm", L"d-mmm-yy", L"dd-mmm-yy", |
1679 L"yy-mm-dd", L"mmm-yy", L"mmmm-yy", L"mmm d, yyyy", L"mmmm d, yy
yy", | 1679 L"yy-mm-dd", L"mmm-yy", L"mmmm-yy", L"mmm d, yyyy", L"mmmm d, yy
yy", |
1680 L"m/d/yy h:MM tt", L"m/d/yy HH:MM" }; | 1680 L"m/d/yy h:MM tt", L"m/d/yy HH:MM" }; |
1681 | 1681 |
1682 » ASSERT(iIndex < sizeof(cFormats)/sizeof(FX_LPCWSTR)); | 1682 » ASSERT(iIndex < FX_ArraySize(cFormats)); |
1683 | 1683 |
1684 if (iIndex < 0) | 1684 if (iIndex < 0) |
1685 iIndex = 0; | 1685 iIndex = 0; |
1686 » if (iIndex >= sizeof(cFormats)/sizeof(FX_LPCWSTR)) | 1686 » if (iIndex >= FX_ArraySize(cFormats)) |
1687 iIndex = 0; | 1687 iIndex = 0; |
1688 CJS_Parameters newParams; | 1688 CJS_Parameters newParams; |
1689 CJS_Value val(isolate,cFormats[iIndex]); | 1689 CJS_Value val(isolate,cFormats[iIndex]); |
1690 newParams.push_back(val); | 1690 newParams.push_back(val); |
1691 return AFDate_FormatEx(cc,newParams,vRet,sError); | 1691 return AFDate_FormatEx(cc,newParams,vRet,sError); |
1692 } | 1692 } |
1693 | 1693 |
1694 //AFDate_KeystrokeEx(cFormat) | 1694 //AFDate_KeystrokeEx(cFormat) |
1695 FX_BOOL CJS_PublicMethods::AFDate_Keystroke(OBJ_METHOD_PARAMS) | 1695 FX_BOOL CJS_PublicMethods::AFDate_Keystroke(OBJ_METHOD_PARAMS) |
1696 { | 1696 { |
1697 v8::Isolate* isolate = ::GetIsolate(cc); | 1697 v8::Isolate* isolate = ::GetIsolate(cc); |
1698 | 1698 |
1699 if (params.size() != 1) | 1699 if (params.size() != 1) |
1700 { | 1700 { |
1701 CJS_Context* pContext = (CJS_Context*)cc; | 1701 CJS_Context* pContext = (CJS_Context*)cc; |
1702 ASSERT(pContext != NULL); | 1702 ASSERT(pContext != NULL); |
1703 | 1703 |
1704 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); | 1704 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); |
1705 return FALSE; | 1705 return FALSE; |
1706 } | 1706 } |
1707 | 1707 |
1708 int iIndex = params[0]; | 1708 int iIndex = params[0]; |
1709 FX_LPCWSTR cFormats[] = {L"m/d", L"m/d/yy", L"mm/dd/yy", L"mm/yy", L"d-
mmm", L"d-mmm-yy", L"dd-mmm-yy", | 1709 FX_LPCWSTR cFormats[] = {L"m/d", L"m/d/yy", L"mm/dd/yy", L"mm/yy", L"d-
mmm", L"d-mmm-yy", L"dd-mmm-yy", |
1710 L"yy-mm-dd", L"mmm-yy", L"mmmm-yy", L"mmm d, yyyy", L"mmmm d, yy
yy", | 1710 L"yy-mm-dd", L"mmm-yy", L"mmmm-yy", L"mmm d, yyyy", L"mmmm d, yy
yy", |
1711 L"m/d/yy h:MM tt", L"m/d/yy HH:MM" }; | 1711 L"m/d/yy h:MM tt", L"m/d/yy HH:MM" }; |
1712 | 1712 |
1713 » ASSERT(iIndex<sizeof(cFormats)/sizeof(FX_LPCWSTR)); | 1713 » ASSERT(iIndex<FX_ArraySize(cFormats)); |
1714 | 1714 |
1715 if (iIndex < 0) | 1715 if (iIndex < 0) |
1716 iIndex = 0; | 1716 iIndex = 0; |
1717 » if (iIndex >= sizeof(cFormats)/sizeof(FX_LPCWSTR)) | 1717 » if (iIndex >= FX_ArraySize(cFormats)) |
1718 iIndex = 0; | 1718 iIndex = 0; |
1719 CJS_Parameters newParams; | 1719 CJS_Parameters newParams; |
1720 CJS_Value val(isolate,cFormats[iIndex]); | 1720 CJS_Value val(isolate,cFormats[iIndex]); |
1721 newParams.push_back(val); | 1721 newParams.push_back(val); |
1722 return AFDate_KeystrokeEx(cc,newParams,vRet,sError); | 1722 return AFDate_KeystrokeEx(cc,newParams,vRet,sError); |
1723 } | 1723 } |
1724 | 1724 |
1725 //function AFTime_Format(ptf) | 1725 //function AFTime_Format(ptf) |
1726 FX_BOOL CJS_PublicMethods::AFTime_Format(OBJ_METHOD_PARAMS) | 1726 FX_BOOL CJS_PublicMethods::AFTime_Format(OBJ_METHOD_PARAMS) |
1727 { | 1727 { |
1728 v8::Isolate* isolate = ::GetIsolate(cc); | 1728 v8::Isolate* isolate = ::GetIsolate(cc); |
1729 | 1729 |
1730 if (params.size() != 1) | 1730 if (params.size() != 1) |
1731 { | 1731 { |
1732 CJS_Context* pContext = (CJS_Context*)cc; | 1732 CJS_Context* pContext = (CJS_Context*)cc; |
1733 ASSERT(pContext != NULL); | 1733 ASSERT(pContext != NULL); |
1734 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); | 1734 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); |
1735 return FALSE; | 1735 return FALSE; |
1736 } | 1736 } |
1737 | 1737 |
1738 int iIndex = params[0]; | 1738 int iIndex = params[0]; |
1739 FX_LPCWSTR cFormats[] = {L"HH:MM", L"h:MM tt", L"HH:MM:ss", L"h:MM:ss tt
"}; | 1739 FX_LPCWSTR cFormats[] = {L"HH:MM", L"h:MM tt", L"HH:MM:ss", L"h:MM:ss tt
"}; |
1740 | 1740 |
1741 » ASSERT(iIndex<sizeof(cFormats)/sizeof(FX_LPCWSTR)); | 1741 » ASSERT(iIndex<FX_ArraySize(cFormats)); |
1742 | 1742 |
1743 if (iIndex < 0) | 1743 if (iIndex < 0) |
1744 iIndex = 0; | 1744 iIndex = 0; |
1745 » if (iIndex >= sizeof(cFormats)/sizeof(FX_LPCWSTR)) | 1745 » if (iIndex >= FX_ArraySize(cFormats)) |
1746 iIndex = 0; | 1746 iIndex = 0; |
1747 CJS_Parameters newParams; | 1747 CJS_Parameters newParams; |
1748 CJS_Value val(isolate,cFormats[iIndex]); | 1748 CJS_Value val(isolate,cFormats[iIndex]); |
1749 newParams.push_back(val); | 1749 newParams.push_back(val); |
1750 return AFDate_FormatEx(cc,newParams,vRet,sError); | 1750 return AFDate_FormatEx(cc,newParams,vRet,sError); |
1751 } | 1751 } |
1752 | 1752 |
1753 FX_BOOL CJS_PublicMethods::AFTime_Keystroke(OBJ_METHOD_PARAMS) | 1753 FX_BOOL CJS_PublicMethods::AFTime_Keystroke(OBJ_METHOD_PARAMS) |
1754 { | 1754 { |
1755 v8::Isolate* isolate = ::GetIsolate(cc); | 1755 v8::Isolate* isolate = ::GetIsolate(cc); |
1756 if (params.size() != 1) | 1756 if (params.size() != 1) |
1757 { | 1757 { |
1758 CJS_Context* pContext = (CJS_Context*)cc; | 1758 CJS_Context* pContext = (CJS_Context*)cc; |
1759 ASSERT(pContext != NULL); | 1759 ASSERT(pContext != NULL); |
1760 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); | 1760 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); |
1761 return FALSE; | 1761 return FALSE; |
1762 } | 1762 } |
1763 | 1763 |
1764 int iIndex = params[0]; | 1764 int iIndex = params[0]; |
1765 FX_LPCWSTR cFormats[] = {L"HH:MM", L"h:MM tt", L"HH:MM:ss", L"h:MM:ss tt
"}; | 1765 FX_LPCWSTR cFormats[] = {L"HH:MM", L"h:MM tt", L"HH:MM:ss", L"h:MM:ss tt
"}; |
1766 | 1766 |
1767 » ASSERT(iIndex<sizeof(cFormats)/sizeof(FX_LPCWSTR)); | 1767 » ASSERT(iIndex<FX_ArraySize(cFormats)); |
1768 | 1768 |
1769 if (iIndex < 0) | 1769 if (iIndex < 0) |
1770 iIndex = 0; | 1770 iIndex = 0; |
1771 » if (iIndex >= sizeof(cFormats)/sizeof(FX_LPCWSTR)) | 1771 » if (iIndex >= FX_ArraySize(cFormats)) |
1772 iIndex = 0; | 1772 iIndex = 0; |
1773 CJS_Parameters newParams; | 1773 CJS_Parameters newParams; |
1774 CJS_Value val(isolate,cFormats[iIndex]); | 1774 CJS_Value val(isolate,cFormats[iIndex]); |
1775 newParams.push_back(val); | 1775 newParams.push_back(val); |
1776 return AFDate_KeystrokeEx(cc,newParams,vRet,sError); | 1776 return AFDate_KeystrokeEx(cc,newParams,vRet,sError); |
1777 } | 1777 } |
1778 | 1778 |
1779 FX_BOOL CJS_PublicMethods::AFTime_FormatEx(OBJ_METHOD_PARAMS) | 1779 FX_BOOL CJS_PublicMethods::AFTime_FormatEx(OBJ_METHOD_PARAMS) |
1780 { | 1780 { |
1781 return AFDate_FormatEx(cc,params,vRet,sError); | 1781 return AFDate_FormatEx(cc,params,vRet,sError); |
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2316 nums.SetElement(nIndex,CJS_Value(isolate,sPart.c_str())); | 2316 nums.SetElement(nIndex,CJS_Value(isolate,sPart.c_str())); |
2317 } | 2317 } |
2318 | 2318 |
2319 if (nums.GetLength() > 0) | 2319 if (nums.GetLength() > 0) |
2320 vRet = nums; | 2320 vRet = nums; |
2321 else | 2321 else |
2322 vRet.SetNull(); | 2322 vRet.SetNull(); |
2323 | 2323 |
2324 return TRUE; | 2324 return TRUE; |
2325 } | 2325 } |
OLD | NEW |