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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 { "MM", "%M" }, | 86 { "MM", "%M" }, |
87 //"M" | 87 //"M" |
88 { "ss", "%S" }, | 88 { "ss", "%S" }, |
89 //"s | 89 //"s |
90 { "tt", "%p" }, | 90 { "tt", "%p" }, |
91 //"t" | 91 //"t" |
92 }; | 92 }; |
93 | 93 |
94 static FX_LPCWSTR months[] = | 94 static FX_LPCWSTR months[] = |
95 { | 95 { |
96 » (FX_LPCWSTR)L"Jan", (FX_LPCWSTR)L"Feb", (FX_LPCWSTR)L"Mar", (FX_LPCWSTR)
L"Apr", (FX_LPCWSTR)L"May", (FX_LPCWSTR)L"Jun", (FX_LPCWSTR)L"Jul", (FX_LPCWSTR)
L"Aug", (FX_LPCWSTR)L"Sep", (FX_LPCWSTR)L"Oct", (FX_LPCWSTR)L"Nov", (FX_LPCWSTR)
L"Dec" | 96 » L"Jan", L"Feb", L"Mar", L"Apr", L"May", L"Jun", L"Jul", L"Aug", L"Sep",
L"Oct", L"Nov", L"Dec" |
97 }; | 97 }; |
98 | 98 |
99 static FX_LPCWSTR fullmonths[] = | 99 static FX_LPCWSTR fullmonths[] = |
100 { | 100 { |
101 » (FX_LPCWSTR)L"January", (FX_LPCWSTR)L"February", (FX_LPCWSTR)L"March", (
FX_LPCWSTR)L"April", (FX_LPCWSTR)L"May", (FX_LPCWSTR)L"June", (FX_LPCWSTR)L"July
", (FX_LPCWSTR)L"August", (FX_LPCWSTR)L"September", (FX_LPCWSTR)L"October", (FX_
LPCWSTR)L"November", (FX_LPCWSTR)L"December" | 101 » L"January", L"February", L"March", L"April", L"May", L"June", L"July", L
"August", L"September", L"October", L"November", L"December" |
102 }; | 102 }; |
103 | 103 |
104 FX_BOOL CJS_PublicMethods::IsNumber(FX_LPCWSTR string) | 104 FX_BOOL CJS_PublicMethods::IsNumber(FX_LPCWSTR string) |
105 { | 105 { |
106 CFX_WideString sTrim = StrTrim(string); | 106 CFX_WideString sTrim = StrTrim(string); |
107 FX_LPCWSTR pTrim = sTrim; | 107 FX_LPCWSTR pTrim = sTrim; |
108 FX_LPCWSTR p = pTrim; | 108 FX_LPCWSTR p = pTrim; |
109 | 109 |
110 | 110 |
111 FX_BOOL bDot = FALSE; | 111 FX_BOOL bDot = FALSE; |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 } | 186 } |
187 } | 187 } |
188 | 188 |
189 FX_BOOL CJS_PublicMethods::isReservedMaskChar(wchar_t ch) | 189 FX_BOOL CJS_PublicMethods::isReservedMaskChar(wchar_t ch) |
190 { | 190 { |
191 return ch == L'9' || ch == L'A' || ch == L'O' || ch == L'X'; | 191 return ch == L'9' || ch == L'A' || ch == L'O' || ch == L'X'; |
192 } | 192 } |
193 | 193 |
194 double CJS_PublicMethods::AF_Simple(FX_LPCWSTR sFuction, double dValue1, double
dValue2) | 194 double CJS_PublicMethods::AF_Simple(FX_LPCWSTR sFuction, double dValue1, double
dValue2) |
195 { | 195 { |
196 » if (FXSYS_wcsicmp(sFuction,(FX_LPCWSTR)L"AVG") == 0 || FXSYS_wcsicmp(sFu
ction,(FX_LPCWSTR)L"SUM") == 0) | 196 » if (FXSYS_wcsicmp(sFuction,L"AVG") == 0 || FXSYS_wcsicmp(sFuction,L"SUM"
) == 0) |
197 { | 197 { |
198 return dValue1 + dValue2; | 198 return dValue1 + dValue2; |
199 } | 199 } |
200 » else if (FXSYS_wcsicmp(sFuction, (FX_LPCWSTR)L"PRD") == 0) | 200 » else if (FXSYS_wcsicmp(sFuction, L"PRD") == 0) |
201 { | 201 { |
202 return dValue1 * dValue2; | 202 return dValue1 * dValue2; |
203 } | 203 } |
204 » else if (FXSYS_wcsicmp(sFuction,(FX_LPCWSTR)L"MIN") == 0) | 204 » else if (FXSYS_wcsicmp(sFuction,L"MIN") == 0) |
205 { | 205 { |
206 return FX_MIN(dValue1, dValue2); | 206 return FX_MIN(dValue1, dValue2); |
207 } | 207 } |
208 » else if (FXSYS_wcsicmp(sFuction,(FX_LPCWSTR)L"MAX") == 0) | 208 » else if (FXSYS_wcsicmp(sFuction,L"MAX") == 0) |
209 { | 209 { |
210 return FX_MAX(dValue1, dValue2); | 210 return FX_MAX(dValue1, dValue2); |
211 } | 211 } |
212 | 212 |
213 return dValue1; | 213 return dValue1; |
214 } | 214 } |
215 | 215 |
216 CFX_WideString CJS_PublicMethods::StrLTrim(FX_LPCWSTR pStr) | 216 CFX_WideString CJS_PublicMethods::StrLTrim(FX_LPCWSTR pStr) |
217 { | 217 { |
218 while (*pStr && *pStr == L' ') pStr++; | 218 while (*pStr && *pStr == L' ') pStr++; |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
583 | 583 |
584 bWrongFormat = FALSE; | 584 bWrongFormat = FALSE; |
585 } | 585 } |
586 else | 586 else |
587 { | 587 { |
588 bWrongFormat = TRUE; | 588 bWrongFormat = TRUE; |
589 return dt; | 589 return dt; |
590 } | 590 } |
591 | 591 |
592 CFX_WideString swTemp; | 592 CFX_WideString swTemp; |
593 » swTemp.Format((FX_LPCWSTR)L"%d/%d/%d %d:%d:%d",nMonth,nDay,nYear,nHour,n
Min,nSec); | 593 » swTemp.Format(L"%d/%d/%d %d:%d:%d",nMonth,nDay,nYear,nHour,nMin,nSec); |
594 return JS_DateParse(swTemp); | 594 return JS_DateParse(swTemp); |
595 } | 595 } |
596 | 596 |
597 double CJS_PublicMethods::MakeRegularDate(const CFX_WideString & value, const CF
X_WideString & format, FX_BOOL& bWrongFormat) | 597 double CJS_PublicMethods::MakeRegularDate(const CFX_WideString & value, const CF
X_WideString & format, FX_BOOL& bWrongFormat) |
598 { | 598 { |
599 double dt = JS_GetDateTime(); | 599 double dt = JS_GetDateTime(); |
600 | 600 |
601 if (format.IsEmpty() || value.IsEmpty()) | 601 if (format.IsEmpty() || value.IsEmpty()) |
602 return dt; | 602 return dt; |
603 | 603 |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
929 case 's': | 929 case 's': |
930 case 't': | 930 case 't': |
931 if (remaining == 0 || format.GetAt(i+1) != c) | 931 if (remaining == 0 || format.GetAt(i+1) != c) |
932 { | 932 { |
933 switch (c) | 933 switch (c) |
934 { | 934 { |
935 case 'y': | 935 case 'y': |
936 sPart += c; | 936 sPart += c; |
937 break; | 937 break; |
938 case 'm': | 938 case 'm': |
939 » » » » » » » sPart.Format((FX_LPCWSTR
)L"%d",nMonth); | 939 » » » » » » » sPart.Format(L"%d",nMont
h); |
940 break; | 940 break; |
941 case 'd': | 941 case 'd': |
942 » » » » » » » sPart.Format((FX_LPCWSTR
)L"%d",nDay); | 942 » » » » » » » sPart.Format(L"%d",nDay)
; |
943 break; | 943 break; |
944 case 'H': | 944 case 'H': |
945 » » » » » » » sPart.Format((FX_LPCWSTR
)L"%d",nHour); | 945 » » » » » » » sPart.Format(L"%d",nHour
); |
946 break; | 946 break; |
947 case 'h': | 947 case 'h': |
948 » » » » » » » sPart.Format((FX_LPCWSTR
)L"%d",nHour>12?nHour - 12:nHour); | 948 » » » » » » » sPart.Format(L"%d",nHour
>12?nHour - 12:nHour); |
949 break; | 949 break; |
950 case 'M': | 950 case 'M': |
951 » » » » » » » sPart.Format((FX_LPCWSTR
)L"%d",nMin); | 951 » » » » » » » sPart.Format(L"%d",nMin)
; |
952 break; | 952 break; |
953 case 's': | 953 case 's': |
954 » » » » » » » sPart.Format((FX_LPCWSTR
)L"%d",nSec); | 954 » » » » » » » sPart.Format(L"%d",nSec)
; |
955 break; | 955 break; |
956 case 't': | 956 case 't': |
957 sPart += nHour>12?'p':'a
'; | 957 sPart += nHour>12?'p':'a
'; |
958 break; | 958 break; |
959 } | 959 } |
960 i++; | 960 i++; |
961 } | 961 } |
962 else if (remaining == 1 || format.GetAt(i+2) !=
c) | 962 else if (remaining == 1 || format.GetAt(i+2) !=
c) |
963 { | 963 { |
964 switch (c) | 964 switch (c) |
965 { | 965 { |
966 case 'y': | 966 case 'y': |
967 » » » » » » » sPart.Format((FX_LPCWSTR
)L"%02d",nYear - (nYear / 100) * 100); | 967 » » » » » » » sPart.Format(L"%02d",nYe
ar - (nYear / 100) * 100); |
968 break; | 968 break; |
969 case 'm': | 969 case 'm': |
970 » » » » » » » sPart.Format((FX_LPCWSTR
)L"%02d",nMonth); | 970 » » » » » » » sPart.Format(L"%02d",nMo
nth); |
971 break; | 971 break; |
972 case 'd': | 972 case 'd': |
973 » » » » » » » sPart.Format((FX_LPCWSTR
)L"%02d",nDay); | 973 » » » » » » » sPart.Format(L"%02d",nDa
y); |
974 break; | 974 break; |
975 case 'H': | 975 case 'H': |
976 » » » » » » » sPart.Format((FX_LPCWSTR
)L"%02d",nHour); | 976 » » » » » » » sPart.Format(L"%02d",nHo
ur); |
977 break; | 977 break; |
978 case 'h': | 978 case 'h': |
979 » » » » » » » sPart.Format((FX_LPCWSTR
)L"%02d",nHour>12?nHour - 12:nHour); | 979 » » » » » » » sPart.Format(L"%02d",nHo
ur>12?nHour - 12:nHour); |
980 break; | 980 break; |
981 case 'M': | 981 case 'M': |
982 » » » » » » » sPart.Format((FX_LPCWSTR
)L"%02d",nMin); | 982 » » » » » » » sPart.Format(L"%02d",nMi
n); |
983 break; | 983 break; |
984 case 's': | 984 case 's': |
985 » » » » » » » sPart.Format((FX_LPCWSTR
)L"%02d",nSec); | 985 » » » » » » » sPart.Format(L"%02d",nSe
c); |
986 break; | 986 break; |
987 case 't': | 987 case 't': |
988 » » » » » » » sPart = nHour>12? (FX_LP
CWSTR)L"pm": (FX_LPCWSTR)L"am"; | 988 » » » » » » » sPart = nHour>12? L"pm":
L"am"; |
989 break; | 989 break; |
990 } | 990 } |
991 i+=2; | 991 i+=2; |
992 } | 992 } |
993 else if (remaining == 2 || format.GetAt(i+3) !=
c) | 993 else if (remaining == 2 || format.GetAt(i+3) !=
c) |
994 { | 994 { |
995 switch (c) | 995 switch (c) |
996 { | 996 { |
997 case 'm': | 997 case 'm': |
998 i+=3; | 998 i+=3; |
999 if (nMonth > 0&&nMonth <
= 12) | 999 if (nMonth > 0&&nMonth <
= 12) |
1000 sPart += months[
nMonth - 1]; | 1000 sPart += months[
nMonth - 1]; |
1001 break; | 1001 break; |
1002 default: | 1002 default: |
1003 i+=3; | 1003 i+=3; |
1004 sPart += c; | 1004 sPart += c; |
1005 sPart += c; | 1005 sPart += c; |
1006 sPart += c; | 1006 sPart += c; |
1007 break; | 1007 break; |
1008 } | 1008 } |
1009 } | 1009 } |
1010 else if (remaining == 3 || format.GetAt(i+4) !=
c) | 1010 else if (remaining == 3 || format.GetAt(i+4) !=
c) |
1011 { | 1011 { |
1012 switch (c) | 1012 switch (c) |
1013 { | 1013 { |
1014 case 'y': | 1014 case 'y': |
1015 » » » » » » » sPart.Format((FX_LPCWSTR
)L"%04d",nYear); | 1015 » » » » » » » sPart.Format(L"%04d",nYe
ar); |
1016 i += 4; | 1016 i += 4; |
1017 break; | 1017 break; |
1018 case 'm': | 1018 case 'm': |
1019 i+=4; | 1019 i+=4; |
1020 if (nMonth > 0&&nMonth <
= 12) | 1020 if (nMonth > 0&&nMonth <
= 12) |
1021 sPart += fullmon
ths[nMonth - 1]; | 1021 sPart += fullmon
ths[nMonth - 1]; |
1022 break; | 1022 break; |
1023 default: | 1023 default: |
1024 i += 4; | 1024 i += 4; |
1025 sPart += c; | 1025 sPart += c; |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1279 CFX_WideString w_strValue = val; | 1279 CFX_WideString w_strValue = val; |
1280 | 1280 |
1281 if (pEvent->WillCommit()) | 1281 if (pEvent->WillCommit()) |
1282 { | 1282 { |
1283 CFX_WideString wstrChange = w_strChange; | 1283 CFX_WideString wstrChange = w_strChange; |
1284 CFX_WideString wstrValue = StrLTrim(w_strValue); | 1284 CFX_WideString wstrValue = StrLTrim(w_strValue); |
1285 if (wstrValue.IsEmpty()) | 1285 if (wstrValue.IsEmpty()) |
1286 return TRUE; | 1286 return TRUE; |
1287 | 1287 |
1288 CFX_WideString swTemp = wstrValue; | 1288 CFX_WideString swTemp = wstrValue; |
1289 » » swTemp.Replace((FX_LPCWSTR)L",", (FX_LPCWSTR)L"."); | 1289 » » swTemp.Replace(L",", L"."); |
1290 if (!IsNumber(swTemp)) //!(IsNumber(wstrChange) && | 1290 if (!IsNumber(swTemp)) //!(IsNumber(wstrChange) && |
1291 { | 1291 { |
1292 pEvent->Rc() = FALSE; | 1292 pEvent->Rc() = FALSE; |
1293 sError = JSGetStringFromID(pContext, IDS_STRING_JSAFNUMB
ER_KEYSTROKE); | 1293 sError = JSGetStringFromID(pContext, IDS_STRING_JSAFNUMB
ER_KEYSTROKE); |
1294 Alert(pContext, sError); | 1294 Alert(pContext, sError); |
1295 return TRUE; | 1295 return TRUE; |
1296 } | 1296 } |
1297 return TRUE; // it happens after the last keystroke and before v
alidating, | 1297 return TRUE; // it happens after the last keystroke and before v
alidating, |
1298 } | 1298 } |
1299 | 1299 |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1668 if (params.size() != 1) | 1668 if (params.size() != 1) |
1669 { | 1669 { |
1670 CJS_Context* pContext = (CJS_Context*)cc; | 1670 CJS_Context* pContext = (CJS_Context*)cc; |
1671 ASSERT(pContext != NULL); | 1671 ASSERT(pContext != NULL); |
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[] = {(FX_LPCWSTR)L"m/d", (FX_LPCWSTR)L"m/d/yy", (FX
_LPCWSTR)L"mm/dd/yy", (FX_LPCWSTR)L"mm/yy", (FX_LPCWSTR)L"d-mmm", (FX_LPCWSTR)L"
d-mmm-yy", (FX_LPCWSTR)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 » » (FX_LPCWSTR)L"yy-mm-dd", (FX_LPCWSTR)L"mmm-yy", (FX_LPCWSTR)L"mm
mm-yy", (FX_LPCWSTR)L"mmm d, yyyy", (FX_LPCWSTR)L"mmmm d, yyyy", | 1679 » » L"yy-mm-dd", L"mmm-yy", L"mmmm-yy", L"mmm d, yyyy", L"mmmm d, yy
yy", |
1680 » » (FX_LPCWSTR)L"m/d/yy h:MM tt", (FX_LPCWSTR)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 < sizeof(cFormats)/sizeof(FX_LPCWSTR)); |
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 >= sizeof(cFormats)/sizeof(FX_LPCWSTR)) |
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[] = {(FX_LPCWSTR)L"m/d", (FX_LPCWSTR)L"m/d/yy", (FX
_LPCWSTR)L"mm/dd/yy", (FX_LPCWSTR)L"mm/yy", (FX_LPCWSTR)L"d-mmm", (FX_LPCWSTR)L"
d-mmm-yy", (FX_LPCWSTR)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 » » (FX_LPCWSTR)L"yy-mm-dd", (FX_LPCWSTR)L"mmm-yy", (FX_LPCWSTR)L"mm
mm-yy", (FX_LPCWSTR)L"mmm d, yyyy", (FX_LPCWSTR)L"mmmm d, yyyy", | 1710 » » L"yy-mm-dd", L"mmm-yy", L"mmmm-yy", L"mmm d, yyyy", L"mmmm d, yy
yy", |
1711 » » (FX_LPCWSTR)L"m/d/yy h:MM tt", (FX_LPCWSTR)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<sizeof(cFormats)/sizeof(FX_LPCWSTR)); |
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 >= sizeof(cFormats)/sizeof(FX_LPCWSTR)) |
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[] = {(FX_LPCWSTR)L"HH:MM", (FX_LPCWSTR)L"h:MM tt", (
FX_LPCWSTR)L"HH:MM:ss", (FX_LPCWSTR)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<sizeof(cFormats)/sizeof(FX_LPCWSTR)); |
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 >= sizeof(cFormats)/sizeof(FX_LPCWSTR)) |
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[] = {(FX_LPCWSTR)L"HH:MM", (FX_LPCWSTR)L"h:MM tt", (
FX_LPCWSTR)L"HH:MM:ss", (FX_LPCWSTR)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<sizeof(cFormats)/sizeof(FX_LPCWSTR)); |
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 >= sizeof(cFormats)/sizeof(FX_LPCWSTR)) |
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); |
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2316 nums.SetElement(nIndex,CJS_Value(isolate,(FX_LPCWSTR)sPart)); | 2316 nums.SetElement(nIndex,CJS_Value(isolate,(FX_LPCWSTR)sPart)); |
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 |