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 "fpdfsdk/src/javascript/PublicMethods.h" | 7 #include "fpdfsdk/javascript/PublicMethods.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <string> | 10 #include <string> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "core/include/fxcrt/fx_ext.h" | 13 #include "core/include/fxcrt/fx_ext.h" |
14 #include "fpdfsdk/include/fsdk_mgr.h" // For CPDFDoc_Environment. | 14 #include "fpdfsdk/include/fsdk_mgr.h" // For CPDFDoc_Environment. |
15 #include "fpdfsdk/include/javascript/IJavaScript.h" | 15 #include "fpdfsdk/include/javascript/IJavaScript.h" |
16 #include "fpdfsdk/src/javascript/Field.h" | 16 #include "fpdfsdk/javascript/Field.h" |
17 #include "fpdfsdk/src/javascript/JS_Context.h" | 17 #include "fpdfsdk/javascript/JS_Context.h" |
18 #include "fpdfsdk/src/javascript/JS_Define.h" | 18 #include "fpdfsdk/javascript/JS_Define.h" |
19 #include "fpdfsdk/src/javascript/JS_EventHandler.h" | 19 #include "fpdfsdk/javascript/JS_EventHandler.h" |
20 #include "fpdfsdk/src/javascript/JS_Object.h" | 20 #include "fpdfsdk/javascript/JS_Object.h" |
21 #include "fpdfsdk/src/javascript/JS_Runtime.h" | 21 #include "fpdfsdk/javascript/JS_Runtime.h" |
22 #include "fpdfsdk/src/javascript/JS_Value.h" | 22 #include "fpdfsdk/javascript/JS_Value.h" |
23 #include "fpdfsdk/src/javascript/color.h" | 23 #include "fpdfsdk/javascript/color.h" |
24 #include "fpdfsdk/src/javascript/resource.h" | 24 #include "fpdfsdk/javascript/resource.h" |
25 #include "fpdfsdk/src/javascript/util.h" | 25 #include "fpdfsdk/javascript/util.h" |
26 | 26 |
27 #define DOUBLE_CORRECT 0.000000000000001 | 27 #define DOUBLE_CORRECT 0.000000000000001 |
28 | 28 |
29 BEGIN_JS_STATIC_GLOBAL_FUN(CJS_PublicMethods) | 29 BEGIN_JS_STATIC_GLOBAL_FUN(CJS_PublicMethods) |
30 JS_STATIC_GLOBAL_FUN_ENTRY(AFNumber_Format) | 30 JS_STATIC_GLOBAL_FUN_ENTRY(AFNumber_Format) |
31 JS_STATIC_GLOBAL_FUN_ENTRY(AFNumber_Keystroke) | 31 JS_STATIC_GLOBAL_FUN_ENTRY(AFNumber_Keystroke) |
32 JS_STATIC_GLOBAL_FUN_ENTRY(AFPercent_Format) | 32 JS_STATIC_GLOBAL_FUN_ENTRY(AFPercent_Format) |
33 JS_STATIC_GLOBAL_FUN_ENTRY(AFPercent_Keystroke) | 33 JS_STATIC_GLOBAL_FUN_ENTRY(AFPercent_Keystroke) |
34 JS_STATIC_GLOBAL_FUN_ENTRY(AFDate_FormatEx) | 34 JS_STATIC_GLOBAL_FUN_ENTRY(AFDate_FormatEx) |
35 JS_STATIC_GLOBAL_FUN_ENTRY(AFDate_KeystrokeEx) | 35 JS_STATIC_GLOBAL_FUN_ENTRY(AFDate_KeystrokeEx) |
(...skipping 10 matching lines...) Expand all Loading... |
46 JS_STATIC_GLOBAL_FUN_ENTRY(AFMakeNumber) | 46 JS_STATIC_GLOBAL_FUN_ENTRY(AFMakeNumber) |
47 JS_STATIC_GLOBAL_FUN_ENTRY(AFSimple_Calculate) | 47 JS_STATIC_GLOBAL_FUN_ENTRY(AFSimple_Calculate) |
48 JS_STATIC_GLOBAL_FUN_ENTRY(AFRange_Validate) | 48 JS_STATIC_GLOBAL_FUN_ENTRY(AFRange_Validate) |
49 JS_STATIC_GLOBAL_FUN_ENTRY(AFMergeChange) | 49 JS_STATIC_GLOBAL_FUN_ENTRY(AFMergeChange) |
50 JS_STATIC_GLOBAL_FUN_ENTRY(AFParseDateEx) | 50 JS_STATIC_GLOBAL_FUN_ENTRY(AFParseDateEx) |
51 JS_STATIC_GLOBAL_FUN_ENTRY(AFExtractNums) | 51 JS_STATIC_GLOBAL_FUN_ENTRY(AFExtractNums) |
52 END_JS_STATIC_GLOBAL_FUN() | 52 END_JS_STATIC_GLOBAL_FUN() |
53 | 53 |
54 IMPLEMENT_JS_STATIC_GLOBAL_FUN(CJS_PublicMethods) | 54 IMPLEMENT_JS_STATIC_GLOBAL_FUN(CJS_PublicMethods) |
55 | 55 |
56 static const FX_WCHAR* const months[] = {L"Jan", | 56 static const FX_WCHAR* const months[] = {L"Jan", L"Feb", L"Mar", L"Apr", |
57 L"Feb", | 57 L"May", L"Jun", L"Jul", L"Aug", |
58 L"Mar", | 58 L"Sep", L"Oct", L"Nov", L"Dec"}; |
59 L"Apr", | |
60 L"May", | |
61 L"Jun", | |
62 L"Jul", | |
63 L"Aug", | |
64 L"Sep", | |
65 L"Oct", | |
66 L"Nov", | |
67 L"Dec"}; | |
68 | 59 |
69 static const FX_WCHAR* const fullmonths[] = {L"January", | 60 static const FX_WCHAR* const fullmonths[] = { |
70 L"February", | 61 L"January", L"February", L"March", L"April", |
71 L"March", | 62 L"May", L"June", L"July", L"August", |
72 L"April", | 63 L"September", L"October", L"November", L"December"}; |
73 L"May", | |
74 L"June", | |
75 L"July", | |
76 L"August", | |
77 L"September", | |
78 L"October", | |
79 L"November", | |
80 L"December"}; | |
81 | 64 |
82 FX_BOOL CJS_PublicMethods::IsNumber(const FX_WCHAR* str) { | 65 FX_BOOL CJS_PublicMethods::IsNumber(const FX_WCHAR* str) { |
83 CFX_WideString sTrim = StrTrim(str); | 66 CFX_WideString sTrim = StrTrim(str); |
84 const FX_WCHAR* pTrim = sTrim.c_str(); | 67 const FX_WCHAR* pTrim = sTrim.c_str(); |
85 const FX_WCHAR* p = pTrim; | 68 const FX_WCHAR* p = pTrim; |
86 | 69 |
87 FX_BOOL bDot = FALSE; | 70 FX_BOOL bDot = FALSE; |
88 FX_BOOL bKXJS = FALSE; | 71 FX_BOOL bKXJS = FALSE; |
89 | 72 |
90 wchar_t c; | 73 wchar_t c; |
(...skipping 1816 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1907 nums.SetElement(nIndex, CJS_Value(pRuntime, sPart.c_str())); | 1890 nums.SetElement(nIndex, CJS_Value(pRuntime, sPart.c_str())); |
1908 } | 1891 } |
1909 | 1892 |
1910 if (nums.GetLength() > 0) | 1893 if (nums.GetLength() > 0) |
1911 vRet = nums; | 1894 vRet = nums; |
1912 else | 1895 else |
1913 vRet.SetNull(); | 1896 vRet.SetNull(); |
1914 | 1897 |
1915 return TRUE; | 1898 return TRUE; |
1916 } | 1899 } |
OLD | NEW |