| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 JS_STATIC_GLOBAL_FUN_ENTRY(AFRange_Validate) | 57 JS_STATIC_GLOBAL_FUN_ENTRY(AFRange_Validate) |
| 58 JS_STATIC_GLOBAL_FUN_ENTRY(AFMergeChange) | 58 JS_STATIC_GLOBAL_FUN_ENTRY(AFMergeChange) |
| 59 JS_STATIC_GLOBAL_FUN_ENTRY(AFParseDateEx) | 59 JS_STATIC_GLOBAL_FUN_ENTRY(AFParseDateEx) |
| 60 JS_STATIC_GLOBAL_FUN_ENTRY(AFExtractNums) | 60 JS_STATIC_GLOBAL_FUN_ENTRY(AFExtractNums) |
| 61 END_JS_STATIC_GLOBAL_FUN() | 61 END_JS_STATIC_GLOBAL_FUN() |
| 62 | 62 |
| 63 IMPLEMENT_JS_STATIC_GLOBAL_FUN(CJS_PublicMethods) | 63 IMPLEMENT_JS_STATIC_GLOBAL_FUN(CJS_PublicMethods) |
| 64 | 64 |
| 65 struct stru_TbConvert | 65 struct stru_TbConvert |
| 66 { | 66 { |
| 67 » FX_LPCSTR lpszJSMark; | 67 » const FX_CHAR* lpszJSMark; |
| 68 » FX_LPCSTR lpszCppMark; | 68 » const FX_CHAR* lpszCppMark; |
| 69 }; | 69 }; |
| 70 | 70 |
| 71 static const stru_TbConvert fcTable[] = { | 71 static const stru_TbConvert fcTable[] = { |
| 72 { "mmmm","%B" }, | 72 { "mmmm","%B" }, |
| 73 { "mmm", "%b" }, | 73 { "mmm", "%b" }, |
| 74 { "mm", "%m" }, | 74 { "mm", "%m" }, |
| 75 //"m" | 75 //"m" |
| 76 { "dddd","%A" }, | 76 { "dddd","%A" }, |
| 77 { "ddd", "%a" }, | 77 { "ddd", "%a" }, |
| 78 { "dd", "%d" }, | 78 { "dd", "%d" }, |
| 79 //"d", "%w", | 79 //"d", "%w", |
| 80 { "yyyy","%Y" }, | 80 { "yyyy","%Y" }, |
| 81 { "yy", "%y" }, | 81 { "yy", "%y" }, |
| 82 { "HH", "%H" }, | 82 { "HH", "%H" }, |
| 83 //"H" | 83 //"H" |
| 84 { "hh", "%I" }, | 84 { "hh", "%I" }, |
| 85 //"h" | 85 //"h" |
| 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 const FX_WCHAR* months[] = |
| 95 { | 95 { |
| 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" | 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 const FX_WCHAR* fullmonths[] = |
| 100 { | 100 { |
| 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" | 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(const FX_WCHAR* string) |
| 105 { | 105 { |
| 106 CFX_WideString sTrim = StrTrim(string); | 106 CFX_WideString sTrim = StrTrim(string); |
| 107 » FX_LPCWSTR pTrim = sTrim.c_str(); | 107 » const FX_WCHAR* pTrim = sTrim.c_str(); |
| 108 » FX_LPCWSTR p = pTrim; | 108 » const FX_WCHAR* p = pTrim; |
| 109 | 109 |
| 110 | 110 |
| 111 FX_BOOL bDot = FALSE; | 111 FX_BOOL bDot = FALSE; |
| 112 FX_BOOL bKXJS = FALSE; | 112 FX_BOOL bKXJS = FALSE; |
| 113 | 113 |
| 114 wchar_t c; | 114 wchar_t c; |
| 115 while ((c = *p)) | 115 while ((c = *p)) |
| 116 { | 116 { |
| 117 if (c == '.' || c == ',') | 117 if (c == '.' || c == ',') |
| 118 { | 118 { |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 default: | 184 default: |
| 185 return (c_Change == c_Mask); | 185 return (c_Change == c_Mask); |
| 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(const FX_WCHAR* sFuction, double dValue1, do
uble dValue2) |
| 195 { | 195 { |
| 196 if (FXSYS_wcsicmp(sFuction,L"AVG") == 0 || FXSYS_wcsicmp(sFuction,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, 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,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,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(const FX_WCHAR* pStr) |
| 217 { | 217 { |
| 218 while (*pStr && *pStr == L' ') pStr++; | 218 while (*pStr && *pStr == L' ') pStr++; |
| 219 | 219 |
| 220 return pStr; | 220 return pStr; |
| 221 } | 221 } |
| 222 | 222 |
| 223 CFX_WideString CJS_PublicMethods::StrRTrim(FX_LPCWSTR pStr) | 223 CFX_WideString CJS_PublicMethods::StrRTrim(const FX_WCHAR* pStr) |
| 224 { | 224 { |
| 225 » FX_LPCWSTR p = pStr; | 225 » const FX_WCHAR* p = pStr; |
| 226 while (*p) p++; | 226 while (*p) p++; |
| 227 while (p > pStr && *(p - 1) == L' ') p--; | 227 while (p > pStr && *(p - 1) == L' ') p--; |
| 228 | 228 |
| 229 return CFX_WideString(pStr, p - pStr); | 229 return CFX_WideString(pStr, p - pStr); |
| 230 } | 230 } |
| 231 | 231 |
| 232 CFX_WideString CJS_PublicMethods::StrTrim(FX_LPCWSTR pStr) | 232 CFX_WideString CJS_PublicMethods::StrTrim(const FX_WCHAR* pStr) |
| 233 { | 233 { |
| 234 return StrRTrim(StrLTrim(pStr).c_str()); | 234 return StrRTrim(StrLTrim(pStr).c_str()); |
| 235 } | 235 } |
| 236 | 236 |
| 237 CFX_ByteString CJS_PublicMethods::StrLTrim(FX_LPCSTR pStr) | 237 CFX_ByteString CJS_PublicMethods::StrLTrim(const FX_CHAR* pStr) |
| 238 { | 238 { |
| 239 while (*pStr && *pStr == ' ') pStr++; | 239 while (*pStr && *pStr == ' ') pStr++; |
| 240 | 240 |
| 241 return pStr; | 241 return pStr; |
| 242 } | 242 } |
| 243 | 243 |
| 244 CFX_ByteString CJS_PublicMethods::StrRTrim(FX_LPCSTR pStr) | 244 CFX_ByteString CJS_PublicMethods::StrRTrim(const FX_CHAR* pStr) |
| 245 { | 245 { |
| 246 » FX_LPCSTR p = pStr; | 246 » const FX_CHAR* p = pStr; |
| 247 while (*p) p++; | 247 while (*p) p++; |
| 248 while (p > pStr && *(p - 1) == L' ') p--; | 248 while (p > pStr && *(p - 1) == L' ') p--; |
| 249 | 249 |
| 250 return CFX_ByteString(pStr,p-pStr); | 250 return CFX_ByteString(pStr,p-pStr); |
| 251 } | 251 } |
| 252 | 252 |
| 253 CFX_ByteString CJS_PublicMethods::StrTrim(FX_LPCSTR pStr) | 253 CFX_ByteString CJS_PublicMethods::StrTrim(const FX_CHAR* pStr) |
| 254 { | 254 { |
| 255 return StrRTrim(StrLTrim(pStr)); | 255 return StrRTrim(StrLTrim(pStr)); |
| 256 } | 256 } |
| 257 | 257 |
| 258 double CJS_PublicMethods::ParseNumber(FX_LPCWSTR swSource, FX_BOOL& bAllDigits,
FX_BOOL& bDot, FX_BOOL& bSign, FX_BOOL& bKXJS) | 258 double CJS_PublicMethods::ParseNumber(const FX_WCHAR* swSource, FX_BOOL& bAllDig
its, FX_BOOL& bDot, FX_BOOL& bSign, FX_BOOL& bKXJS) |
| 259 { | 259 { |
| 260 bDot = FALSE; | 260 bDot = FALSE; |
| 261 bSign = FALSE; | 261 bSign = FALSE; |
| 262 bKXJS = FALSE; | 262 bKXJS = FALSE; |
| 263 | 263 |
| 264 FX_BOOL bDigitExist = FALSE; | 264 FX_BOOL bDigitExist = FALSE; |
| 265 | 265 |
| 266 » FX_LPCWSTR p = swSource; | 266 » const FX_WCHAR* p = swSource; |
| 267 wchar_t c; | 267 wchar_t c; |
| 268 | 268 |
| 269 » FX_LPCWSTR pStart = NULL; | 269 » const FX_WCHAR* pStart = NULL; |
| 270 » FX_LPCWSTR pEnd = NULL; | 270 » const FX_WCHAR* pEnd = NULL; |
| 271 | 271 |
| 272 while ((c = *p)) | 272 while ((c = *p)) |
| 273 { | 273 { |
| 274 if (!pStart && c != L' ') | 274 if (!pStart && c != L' ') |
| 275 { | 275 { |
| 276 pStart = p; | 276 pStart = p; |
| 277 } | 277 } |
| 278 | 278 |
| 279 pEnd = p; | 279 pEnd = p; |
| 280 p++; | 280 p++; |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 { | 394 { |
| 395 dRet = atol(sDigits); | 395 dRet = atol(sDigits); |
| 396 } | 396 } |
| 397 } | 397 } |
| 398 | 398 |
| 399 } | 399 } |
| 400 | 400 |
| 401 return dRet; | 401 return dRet; |
| 402 } | 402 } |
| 403 | 403 |
| 404 double CJS_PublicMethods::ParseStringToNumber(FX_LPCWSTR swSource) | 404 double CJS_PublicMethods::ParseStringToNumber(const FX_WCHAR* swSource) |
| 405 { | 405 { |
| 406 FX_BOOL bAllDigits = FALSE; | 406 FX_BOOL bAllDigits = FALSE; |
| 407 FX_BOOL bDot = FALSE; | 407 FX_BOOL bDot = FALSE; |
| 408 FX_BOOL bSign = FALSE; | 408 FX_BOOL bSign = FALSE; |
| 409 FX_BOOL bKXJS = FALSE; | 409 FX_BOOL bKXJS = FALSE; |
| 410 | 410 |
| 411 return ParseNumber(swSource, bAllDigits, bDot, bSign, bKXJS); | 411 return ParseNumber(swSource, bAllDigits, bDot, bSign, bKXJS); |
| 412 } | 412 } |
| 413 | 413 |
| 414 FX_BOOL»CJS_PublicMethods::ConvertStringToNumber(FX_LPCWSTR swSource, double & d
Ret, FX_BOOL & bDot) | 414 FX_BOOL»CJS_PublicMethods::ConvertStringToNumber(const FX_WCHAR* swSource, doubl
e & dRet, FX_BOOL & bDot) |
| 415 { | 415 { |
| 416 FX_BOOL bAllDigits = FALSE; | 416 FX_BOOL bAllDigits = FALSE; |
| 417 FX_BOOL bSign = FALSE; | 417 FX_BOOL bSign = FALSE; |
| 418 FX_BOOL bKXJS = FALSE; | 418 FX_BOOL bKXJS = FALSE; |
| 419 | 419 |
| 420 dRet = ParseNumber(swSource, bAllDigits, bDot, bSign, bKXJS); | 420 dRet = ParseNumber(swSource, bAllDigits, bDot, bSign, bKXJS); |
| 421 | 421 |
| 422 return bAllDigits; | 422 return bAllDigits; |
| 423 } | 423 } |
| 424 | 424 |
| (...skipping 1228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1653 if (params.size() != 1) | 1653 if (params.size() != 1) |
| 1654 { | 1654 { |
| 1655 CJS_Context* pContext = (CJS_Context*)cc; | 1655 CJS_Context* pContext = (CJS_Context*)cc; |
| 1656 ASSERT(pContext != NULL); | 1656 ASSERT(pContext != NULL); |
| 1657 | 1657 |
| 1658 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); | 1658 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); |
| 1659 return FALSE; | 1659 return FALSE; |
| 1660 } | 1660 } |
| 1661 | 1661 |
| 1662 int iIndex = params[0].ToInt(); | 1662 int iIndex = params[0].ToInt(); |
| 1663 » 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", | 1663 » const FX_WCHAR* 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", |
| 1664 L"yy-mm-dd", L"mmm-yy", L"mmmm-yy", L"mmm d, yyyy", L"mmmm d, yy
yy", | 1664 L"yy-mm-dd", L"mmm-yy", L"mmmm-yy", L"mmm d, yyyy", L"mmmm d, yy
yy", |
| 1665 L"m/d/yy h:MM tt", L"m/d/yy HH:MM" }; | 1665 L"m/d/yy h:MM tt", L"m/d/yy HH:MM" }; |
| 1666 | 1666 |
| 1667 ASSERT(iIndex < FX_ArraySize(cFormats)); | 1667 ASSERT(iIndex < FX_ArraySize(cFormats)); |
| 1668 | 1668 |
| 1669 if (iIndex < 0) | 1669 if (iIndex < 0) |
| 1670 iIndex = 0; | 1670 iIndex = 0; |
| 1671 if (iIndex >= FX_ArraySize(cFormats)) | 1671 if (iIndex >= FX_ArraySize(cFormats)) |
| 1672 iIndex = 0; | 1672 iIndex = 0; |
| 1673 CJS_Parameters newParams; | 1673 CJS_Parameters newParams; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1684 if (params.size() != 1) | 1684 if (params.size() != 1) |
| 1685 { | 1685 { |
| 1686 CJS_Context* pContext = (CJS_Context*)cc; | 1686 CJS_Context* pContext = (CJS_Context*)cc; |
| 1687 ASSERT(pContext != NULL); | 1687 ASSERT(pContext != NULL); |
| 1688 | 1688 |
| 1689 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); | 1689 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); |
| 1690 return FALSE; | 1690 return FALSE; |
| 1691 } | 1691 } |
| 1692 | 1692 |
| 1693 int iIndex = params[0].ToInt(); | 1693 int iIndex = params[0].ToInt(); |
| 1694 » 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", | 1694 » const FX_WCHAR* 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", |
| 1695 L"yy-mm-dd", L"mmm-yy", L"mmmm-yy", L"mmm d, yyyy", L"mmmm d, yy
yy", | 1695 L"yy-mm-dd", L"mmm-yy", L"mmmm-yy", L"mmm d, yyyy", L"mmmm d, yy
yy", |
| 1696 L"m/d/yy h:MM tt", L"m/d/yy HH:MM" }; | 1696 L"m/d/yy h:MM tt", L"m/d/yy HH:MM" }; |
| 1697 | 1697 |
| 1698 ASSERT(iIndex<FX_ArraySize(cFormats)); | 1698 ASSERT(iIndex<FX_ArraySize(cFormats)); |
| 1699 | 1699 |
| 1700 if (iIndex < 0) | 1700 if (iIndex < 0) |
| 1701 iIndex = 0; | 1701 iIndex = 0; |
| 1702 if (iIndex >= FX_ArraySize(cFormats)) | 1702 if (iIndex >= FX_ArraySize(cFormats)) |
| 1703 iIndex = 0; | 1703 iIndex = 0; |
| 1704 CJS_Parameters newParams; | 1704 CJS_Parameters newParams; |
| 1705 CJS_Value val(isolate,cFormats[iIndex]); | 1705 CJS_Value val(isolate,cFormats[iIndex]); |
| 1706 newParams.push_back(val); | 1706 newParams.push_back(val); |
| 1707 return AFDate_KeystrokeEx(cc,newParams,vRet,sError); | 1707 return AFDate_KeystrokeEx(cc,newParams,vRet,sError); |
| 1708 } | 1708 } |
| 1709 | 1709 |
| 1710 //function AFTime_Format(ptf) | 1710 //function AFTime_Format(ptf) |
| 1711 FX_BOOL CJS_PublicMethods::AFTime_Format(IFXJS_Context* cc, const CJS_Parameters
& params, CJS_Value& vRet, CFX_WideString& sError) | 1711 FX_BOOL CJS_PublicMethods::AFTime_Format(IFXJS_Context* cc, const CJS_Parameters
& params, CJS_Value& vRet, CFX_WideString& sError) |
| 1712 { | 1712 { |
| 1713 v8::Isolate* isolate = ::GetIsolate(cc); | 1713 v8::Isolate* isolate = ::GetIsolate(cc); |
| 1714 | 1714 |
| 1715 if (params.size() != 1) | 1715 if (params.size() != 1) |
| 1716 { | 1716 { |
| 1717 CJS_Context* pContext = (CJS_Context*)cc; | 1717 CJS_Context* pContext = (CJS_Context*)cc; |
| 1718 ASSERT(pContext != NULL); | 1718 ASSERT(pContext != NULL); |
| 1719 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); | 1719 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); |
| 1720 return FALSE; | 1720 return FALSE; |
| 1721 } | 1721 } |
| 1722 | 1722 |
| 1723 int iIndex = params[0].ToInt(); | 1723 int iIndex = params[0].ToInt(); |
| 1724 » FX_LPCWSTR cFormats[] = {L"HH:MM", L"h:MM tt", L"HH:MM:ss", L"h:MM:ss tt
"}; | 1724 » const FX_WCHAR* cFormats[] = {L"HH:MM", L"h:MM tt", L"HH:MM:ss", L"h:MM:
ss tt"}; |
| 1725 | 1725 |
| 1726 ASSERT(iIndex<FX_ArraySize(cFormats)); | 1726 ASSERT(iIndex<FX_ArraySize(cFormats)); |
| 1727 | 1727 |
| 1728 if (iIndex < 0) | 1728 if (iIndex < 0) |
| 1729 iIndex = 0; | 1729 iIndex = 0; |
| 1730 if (iIndex >= FX_ArraySize(cFormats)) | 1730 if (iIndex >= FX_ArraySize(cFormats)) |
| 1731 iIndex = 0; | 1731 iIndex = 0; |
| 1732 CJS_Parameters newParams; | 1732 CJS_Parameters newParams; |
| 1733 CJS_Value val(isolate,cFormats[iIndex]); | 1733 CJS_Value val(isolate,cFormats[iIndex]); |
| 1734 newParams.push_back(val); | 1734 newParams.push_back(val); |
| 1735 return AFDate_FormatEx(cc,newParams,vRet,sError); | 1735 return AFDate_FormatEx(cc,newParams,vRet,sError); |
| 1736 } | 1736 } |
| 1737 | 1737 |
| 1738 FX_BOOL CJS_PublicMethods::AFTime_Keystroke(IFXJS_Context* cc, const CJS_Paramet
ers& params, CJS_Value& vRet, CFX_WideString& sError) | 1738 FX_BOOL CJS_PublicMethods::AFTime_Keystroke(IFXJS_Context* cc, const CJS_Paramet
ers& params, CJS_Value& vRet, CFX_WideString& sError) |
| 1739 { | 1739 { |
| 1740 v8::Isolate* isolate = ::GetIsolate(cc); | 1740 v8::Isolate* isolate = ::GetIsolate(cc); |
| 1741 if (params.size() != 1) | 1741 if (params.size() != 1) |
| 1742 { | 1742 { |
| 1743 CJS_Context* pContext = (CJS_Context*)cc; | 1743 CJS_Context* pContext = (CJS_Context*)cc; |
| 1744 ASSERT(pContext != NULL); | 1744 ASSERT(pContext != NULL); |
| 1745 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); | 1745 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); |
| 1746 return FALSE; | 1746 return FALSE; |
| 1747 } | 1747 } |
| 1748 | 1748 |
| 1749 int iIndex = params[0].ToInt(); | 1749 int iIndex = params[0].ToInt(); |
| 1750 » FX_LPCWSTR cFormats[] = {L"HH:MM", L"h:MM tt", L"HH:MM:ss", L"h:MM:ss tt
"}; | 1750 » const FX_WCHAR* cFormats[] = {L"HH:MM", L"h:MM tt", L"HH:MM:ss", L"h:MM:
ss tt"}; |
| 1751 | 1751 |
| 1752 ASSERT(iIndex<FX_ArraySize(cFormats)); | 1752 ASSERT(iIndex<FX_ArraySize(cFormats)); |
| 1753 | 1753 |
| 1754 if (iIndex < 0) | 1754 if (iIndex < 0) |
| 1755 iIndex = 0; | 1755 iIndex = 0; |
| 1756 if (iIndex >= FX_ArraySize(cFormats)) | 1756 if (iIndex >= FX_ArraySize(cFormats)) |
| 1757 iIndex = 0; | 1757 iIndex = 0; |
| 1758 CJS_Parameters newParams; | 1758 CJS_Parameters newParams; |
| 1759 CJS_Value val(isolate,cFormats[iIndex]); | 1759 CJS_Value val(isolate,cFormats[iIndex]); |
| 1760 newParams.push_back(val); | 1760 newParams.push_back(val); |
| (...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2296 nums.SetElement(nIndex,CJS_Value(isolate,sPart.c_str())); | 2296 nums.SetElement(nIndex,CJS_Value(isolate,sPart.c_str())); |
| 2297 } | 2297 } |
| 2298 | 2298 |
| 2299 if (nums.GetLength() > 0) | 2299 if (nums.GetLength() > 0) |
| 2300 vRet = nums; | 2300 vRet = nums; |
| 2301 else | 2301 else |
| 2302 vRet.SetNull(); | 2302 vRet.SetNull(); |
| 2303 | 2303 |
| 2304 return TRUE; | 2304 return TRUE; |
| 2305 } | 2305 } |
| OLD | NEW |