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 "PublicMethods.h" | 7 #include "PublicMethods.h" |
8 | 8 |
9 #include "Field.h" | 9 #include "Field.h" |
10 #include "JS_Context.h" | 10 #include "JS_Context.h" |
11 #include "JS_Define.h" | 11 #include "JS_Define.h" |
12 #include "JS_EventHandler.h" | 12 #include "JS_EventHandler.h" |
13 #include "JS_Object.h" | 13 #include "JS_Object.h" |
14 #include "JS_Runtime.h" | 14 #include "JS_Runtime.h" |
15 #include "JS_Value.h" | 15 #include "JS_Value.h" |
16 #include "color.h" | 16 #include "color.h" |
| 17 #include "core/include/fxcrt/fx_ext.h" |
17 #include "fpdfsdk/include/fsdk_mgr.h" // For CPDFDoc_Environment. | 18 #include "fpdfsdk/include/fsdk_mgr.h" // For CPDFDoc_Environment. |
18 #include "fpdfsdk/include/javascript/IJavaScript.h" | 19 #include "fpdfsdk/include/javascript/IJavaScript.h" |
19 #include "resource.h" | 20 #include "resource.h" |
20 #include "util.h" | 21 #include "util.h" |
21 | 22 |
22 #define DOUBLE_CORRECT 0.000000000000001 | 23 #define DOUBLE_CORRECT 0.000000000000001 |
23 | 24 |
24 BEGIN_JS_STATIC_GLOBAL_FUN(CJS_PublicMethods) | 25 BEGIN_JS_STATIC_GLOBAL_FUN(CJS_PublicMethods) |
25 JS_STATIC_GLOBAL_FUN_ENTRY(AFNumber_Format) | 26 JS_STATIC_GLOBAL_FUN_ENTRY(AFNumber_Format) |
26 JS_STATIC_GLOBAL_FUN_ENTRY(AFNumber_Keystroke) | 27 JS_STATIC_GLOBAL_FUN_ENTRY(AFNumber_Keystroke) |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 } | 102 } |
102 | 103 |
103 return TRUE; | 104 return TRUE; |
104 } | 105 } |
105 | 106 |
106 FX_BOOL CJS_PublicMethods::IsDigit(wchar_t ch) { | 107 FX_BOOL CJS_PublicMethods::IsDigit(wchar_t ch) { |
107 return (ch >= L'0' && ch <= L'9'); | 108 return (ch >= L'0' && ch <= L'9'); |
108 } | 109 } |
109 | 110 |
110 FX_BOOL CJS_PublicMethods::IsDigit(char ch) { | 111 FX_BOOL CJS_PublicMethods::IsDigit(char ch) { |
111 return (ch >= '0' && ch <= '9'); | 112 return std::isdigit(ch); |
112 } | 113 } |
113 | 114 |
114 FX_BOOL CJS_PublicMethods::IsAlphabetic(wchar_t ch) { | 115 FX_BOOL CJS_PublicMethods::IsAlphabetic(wchar_t ch) { |
115 return ((ch >= L'a' && ch <= L'z') || (ch >= L'A' && ch <= L'Z')); | 116 return ((ch >= L'a' && ch <= L'z') || (ch >= L'A' && ch <= L'Z')); |
116 } | 117 } |
117 | 118 |
118 FX_BOOL CJS_PublicMethods::IsAlphaNumeric(wchar_t ch) { | 119 FX_BOOL CJS_PublicMethods::IsAlphaNumeric(wchar_t ch) { |
119 return (IsDigit(ch) || IsAlphabetic(ch)); | 120 return (IsDigit(ch) || IsAlphabetic(ch)); |
120 } | 121 } |
121 | 122 |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 int& nSkip, | 382 int& nSkip, |
382 int nMaxStep) { | 383 int nMaxStep) { |
383 int nRet = 0; | 384 int nRet = 0; |
384 nSkip = 0; | 385 nSkip = 0; |
385 for (int i = nStart, sz = string.GetLength(); i < sz; i++) { | 386 for (int i = nStart, sz = string.GetLength(); i < sz; i++) { |
386 if (i - nStart > 10) | 387 if (i - nStart > 10) |
387 break; | 388 break; |
388 | 389 |
389 FX_WCHAR c = string.GetAt(i); | 390 FX_WCHAR c = string.GetAt(i); |
390 if (IsDigit((wchar_t)c)) { | 391 if (IsDigit((wchar_t)c)) { |
391 nRet = nRet * 10 + (c - '0'); | 392 nRet = nRet * 10 + FXSYS_toDecimalDigitWide(c); |
392 nSkip = i - nStart + 1; | 393 nSkip = i - nStart + 1; |
393 if (nSkip >= nMaxStep) | 394 if (nSkip >= nMaxStep) |
394 break; | 395 break; |
395 } else | 396 } else |
396 break; | 397 break; |
397 } | 398 } |
398 | 399 |
399 return nRet; | 400 return nRet; |
400 } | 401 } |
401 | 402 |
(...skipping 1679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2081 nums.SetElement(nIndex, CJS_Value(pRuntime, sPart.c_str())); | 2082 nums.SetElement(nIndex, CJS_Value(pRuntime, sPart.c_str())); |
2082 } | 2083 } |
2083 | 2084 |
2084 if (nums.GetLength() > 0) | 2085 if (nums.GetLength() > 0) |
2085 vRet = nums; | 2086 vRet = nums; |
2086 else | 2087 else |
2087 vRet.SetNull(); | 2088 vRet.SetNull(); |
2088 | 2089 |
2089 return TRUE; | 2090 return TRUE; |
2090 } | 2091 } |
OLD | NEW |