OLD | NEW |
| (Empty) |
1 // Copyright 2014 PDFium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | |
6 | |
7 #ifndef FPDFSDK_SRC_JAVASCRIPT_PUBLICMETHODS_H_ | |
8 #define FPDFSDK_SRC_JAVASCRIPT_PUBLICMETHODS_H_ | |
9 | |
10 #include <string> | |
11 #include <vector> | |
12 | |
13 #include "fpdfsdk/src/javascript/JS_Define.h" | |
14 | |
15 class CJS_PublicMethods : public CJS_Object { | |
16 public: | |
17 explicit CJS_PublicMethods(v8::Local<v8::Object> pObject) | |
18 : CJS_Object(pObject) {} | |
19 ~CJS_PublicMethods() override {} | |
20 | |
21 public: | |
22 static FX_BOOL AFNumber_Format(IJS_Context* cc, | |
23 const std::vector<CJS_Value>& params, | |
24 CJS_Value& vRet, | |
25 CFX_WideString& sError); | |
26 static FX_BOOL AFNumber_Keystroke(IJS_Context* cc, | |
27 const std::vector<CJS_Value>& params, | |
28 CJS_Value& vRet, | |
29 CFX_WideString& sError); | |
30 static FX_BOOL AFPercent_Format(IJS_Context* cc, | |
31 const std::vector<CJS_Value>& params, | |
32 CJS_Value& vRet, | |
33 CFX_WideString& sError); | |
34 static FX_BOOL AFPercent_Keystroke(IJS_Context* cc, | |
35 const std::vector<CJS_Value>& params, | |
36 CJS_Value& vRet, | |
37 CFX_WideString& sError); | |
38 static FX_BOOL AFDate_FormatEx(IJS_Context* cc, | |
39 const std::vector<CJS_Value>& params, | |
40 CJS_Value& vRet, | |
41 CFX_WideString& sError); | |
42 static FX_BOOL AFDate_KeystrokeEx(IJS_Context* cc, | |
43 const std::vector<CJS_Value>& params, | |
44 CJS_Value& vRet, | |
45 CFX_WideString& sError); | |
46 static FX_BOOL AFDate_Format(IJS_Context* cc, | |
47 const std::vector<CJS_Value>& params, | |
48 CJS_Value& vRet, | |
49 CFX_WideString& sError); | |
50 static FX_BOOL AFDate_Keystroke(IJS_Context* cc, | |
51 const std::vector<CJS_Value>& params, | |
52 CJS_Value& vRet, | |
53 CFX_WideString& sError); | |
54 static FX_BOOL AFTime_FormatEx(IJS_Context* cc, | |
55 const std::vector<CJS_Value>& params, | |
56 CJS_Value& vRet, | |
57 CFX_WideString& sError); // | |
58 static FX_BOOL AFTime_KeystrokeEx(IJS_Context* cc, | |
59 const std::vector<CJS_Value>& params, | |
60 CJS_Value& vRet, | |
61 CFX_WideString& sError); | |
62 static FX_BOOL AFTime_Format(IJS_Context* cc, | |
63 const std::vector<CJS_Value>& params, | |
64 CJS_Value& vRet, | |
65 CFX_WideString& sError); | |
66 static FX_BOOL AFTime_Keystroke(IJS_Context* cc, | |
67 const std::vector<CJS_Value>& params, | |
68 CJS_Value& vRet, | |
69 CFX_WideString& sError); | |
70 static FX_BOOL AFSpecial_Format(IJS_Context* cc, | |
71 const std::vector<CJS_Value>& params, | |
72 CJS_Value& vRet, | |
73 CFX_WideString& sError); | |
74 static FX_BOOL AFSpecial_Keystroke(IJS_Context* cc, | |
75 const std::vector<CJS_Value>& params, | |
76 CJS_Value& vRet, | |
77 CFX_WideString& sError); | |
78 static FX_BOOL AFSpecial_KeystrokeEx(IJS_Context* cc, | |
79 const std::vector<CJS_Value>& params, | |
80 CJS_Value& vRet, | |
81 CFX_WideString& sError); // | |
82 static FX_BOOL AFSimple(IJS_Context* cc, | |
83 const std::vector<CJS_Value>& params, | |
84 CJS_Value& vRet, | |
85 CFX_WideString& sError); | |
86 static FX_BOOL AFMakeNumber(IJS_Context* cc, | |
87 const std::vector<CJS_Value>& params, | |
88 CJS_Value& vRet, | |
89 CFX_WideString& sError); | |
90 static FX_BOOL AFSimple_Calculate(IJS_Context* cc, | |
91 const std::vector<CJS_Value>& params, | |
92 CJS_Value& vRet, | |
93 CFX_WideString& sError); | |
94 static FX_BOOL AFRange_Validate(IJS_Context* cc, | |
95 const std::vector<CJS_Value>& params, | |
96 CJS_Value& vRet, | |
97 CFX_WideString& sError); | |
98 static FX_BOOL AFMergeChange(IJS_Context* cc, | |
99 const std::vector<CJS_Value>& params, | |
100 CJS_Value& vRet, | |
101 CFX_WideString& sError); | |
102 static FX_BOOL AFParseDateEx(IJS_Context* cc, | |
103 const std::vector<CJS_Value>& params, | |
104 CJS_Value& vRet, | |
105 CFX_WideString& sError); | |
106 static FX_BOOL AFExtractNums(IJS_Context* cc, | |
107 const std::vector<CJS_Value>& params, | |
108 CJS_Value& vRet, | |
109 CFX_WideString& sError); | |
110 | |
111 public: | |
112 JS_STATIC_GLOBAL_FUN(AFNumber_Format); | |
113 JS_STATIC_GLOBAL_FUN(AFNumber_Keystroke); | |
114 JS_STATIC_GLOBAL_FUN(AFPercent_Format); | |
115 JS_STATIC_GLOBAL_FUN(AFPercent_Keystroke); | |
116 JS_STATIC_GLOBAL_FUN(AFDate_FormatEx); | |
117 JS_STATIC_GLOBAL_FUN(AFDate_KeystrokeEx); | |
118 JS_STATIC_GLOBAL_FUN(AFDate_Format); | |
119 JS_STATIC_GLOBAL_FUN(AFDate_Keystroke); | |
120 JS_STATIC_GLOBAL_FUN(AFTime_FormatEx); | |
121 JS_STATIC_GLOBAL_FUN(AFTime_KeystrokeEx); | |
122 JS_STATIC_GLOBAL_FUN(AFTime_Format); | |
123 JS_STATIC_GLOBAL_FUN(AFTime_Keystroke); | |
124 JS_STATIC_GLOBAL_FUN(AFSpecial_Format); | |
125 JS_STATIC_GLOBAL_FUN(AFSpecial_Keystroke); | |
126 JS_STATIC_GLOBAL_FUN(AFSpecial_KeystrokeEx); | |
127 JS_STATIC_GLOBAL_FUN(AFSimple); | |
128 JS_STATIC_GLOBAL_FUN(AFMakeNumber); | |
129 JS_STATIC_GLOBAL_FUN(AFSimple_Calculate); | |
130 JS_STATIC_GLOBAL_FUN(AFRange_Validate); | |
131 JS_STATIC_GLOBAL_FUN(AFMergeChange); | |
132 JS_STATIC_GLOBAL_FUN(AFParseDateEx); | |
133 JS_STATIC_GLOBAL_FUN(AFExtractNums); | |
134 | |
135 JS_STATIC_DECLARE_GLOBAL_FUN(); | |
136 | |
137 public: | |
138 static int ParseStringInteger(const CFX_WideString& string, | |
139 int nStart, | |
140 int& nSkip, | |
141 int nMaxStep); | |
142 static CFX_WideString ParseStringString(const CFX_WideString& string, | |
143 int nStart, | |
144 int& nSkip); | |
145 static double MakeRegularDate(const CFX_WideString& value, | |
146 const CFX_WideString& format, | |
147 bool* bWrongFormat); | |
148 static CFX_WideString MakeFormatDate(double dDate, | |
149 const CFX_WideString& format); | |
150 static double ParseNormalDate(const CFX_WideString& value, | |
151 bool* bWrongFormat); | |
152 static double MakeInterDate(CFX_WideString strValue); | |
153 | |
154 public: | |
155 static CFX_WideString StrLTrim(const FX_WCHAR* pStr); | |
156 static CFX_WideString StrRTrim(const FX_WCHAR* pStr); | |
157 static CFX_WideString StrTrim(const FX_WCHAR* pStr); | |
158 | |
159 static CFX_ByteString StrLTrim(const FX_CHAR* pStr); | |
160 static CFX_ByteString StrRTrim(const FX_CHAR* pStr); | |
161 static CFX_ByteString StrTrim(const FX_CHAR* pStr); | |
162 | |
163 static FX_BOOL IsNumber(const FX_CHAR* string); | |
164 static FX_BOOL IsNumber(const FX_WCHAR* string); | |
165 | |
166 static FX_BOOL maskSatisfied(wchar_t c_Change, wchar_t c_Mask); | |
167 static FX_BOOL isReservedMaskChar(wchar_t ch); | |
168 | |
169 static double AF_Simple(const FX_WCHAR* sFuction, | |
170 double dValue1, | |
171 double dValue2); | |
172 static CJS_Array AF_MakeArrayFromList(CJS_Runtime* pRuntime, CJS_Value val); | |
173 }; | |
174 | |
175 #endif // FPDFSDK_SRC_JAVASCRIPT_PUBLICMETHODS_H_ | |
OLD | NEW |