xref: /aosp_15_r20/external/pdfium/fxjs/cjs_publicmethods.h (revision 3ac0a46f773bac49fa9476ec2b1cf3f8da5ec3a4)
1*3ac0a46fSAndroid Build Coastguard Worker // Copyright 2014 The PDFium Authors
2*3ac0a46fSAndroid Build Coastguard Worker // Use of this source code is governed by a BSD-style license that can be
3*3ac0a46fSAndroid Build Coastguard Worker // found in the LICENSE file.
4*3ac0a46fSAndroid Build Coastguard Worker 
5*3ac0a46fSAndroid Build Coastguard Worker // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6*3ac0a46fSAndroid Build Coastguard Worker 
7*3ac0a46fSAndroid Build Coastguard Worker #ifndef FXJS_CJS_PUBLICMETHODS_H_
8*3ac0a46fSAndroid Build Coastguard Worker #define FXJS_CJS_PUBLICMETHODS_H_
9*3ac0a46fSAndroid Build Coastguard Worker 
10*3ac0a46fSAndroid Build Coastguard Worker #include <vector>
11*3ac0a46fSAndroid Build Coastguard Worker 
12*3ac0a46fSAndroid Build Coastguard Worker #include "fxjs/cjs_object.h"
13*3ac0a46fSAndroid Build Coastguard Worker #include "fxjs/cjs_result.h"
14*3ac0a46fSAndroid Build Coastguard Worker 
15*3ac0a46fSAndroid Build Coastguard Worker class CJS_PublicMethods final : public CJS_Object {
16*3ac0a46fSAndroid Build Coastguard Worker  public:
17*3ac0a46fSAndroid Build Coastguard Worker   CJS_PublicMethods() = delete;
18*3ac0a46fSAndroid Build Coastguard Worker 
19*3ac0a46fSAndroid Build Coastguard Worker   static void DefineJSObjects(CFXJS_Engine* pEngine);
20*3ac0a46fSAndroid Build Coastguard Worker 
21*3ac0a46fSAndroid Build Coastguard Worker   static double ParseDate(v8::Isolate* isolate,
22*3ac0a46fSAndroid Build Coastguard Worker                           const WideString& value,
23*3ac0a46fSAndroid Build Coastguard Worker                           bool* bWrongFormat);
24*3ac0a46fSAndroid Build Coastguard Worker   static double ParseDateAsGMT(v8::Isolate* isolate, const WideString& value);
25*3ac0a46fSAndroid Build Coastguard Worker   static double ParseDateUsingFormat(v8::Isolate* isolate,
26*3ac0a46fSAndroid Build Coastguard Worker                                      const WideString& value,
27*3ac0a46fSAndroid Build Coastguard Worker                                      const WideString& format,
28*3ac0a46fSAndroid Build Coastguard Worker                                      bool* bWrongFormat);
29*3ac0a46fSAndroid Build Coastguard Worker 
30*3ac0a46fSAndroid Build Coastguard Worker   // Exposed for testing.
31*3ac0a46fSAndroid Build Coastguard Worker   static WideString PrintDateUsingFormat(double dDate,
32*3ac0a46fSAndroid Build Coastguard Worker                                          const WideString& format);
33*3ac0a46fSAndroid Build Coastguard Worker   static bool IsNumber(const WideString& str);
34*3ac0a46fSAndroid Build Coastguard Worker 
35*3ac0a46fSAndroid Build Coastguard Worker   static CJS_Result AFNumber_Format(
36*3ac0a46fSAndroid Build Coastguard Worker       CJS_Runtime* pRuntime,
37*3ac0a46fSAndroid Build Coastguard Worker       const std::vector<v8::Local<v8::Value>>& params);
38*3ac0a46fSAndroid Build Coastguard Worker   static CJS_Result AFNumber_Keystroke(
39*3ac0a46fSAndroid Build Coastguard Worker       CJS_Runtime* pRuntime,
40*3ac0a46fSAndroid Build Coastguard Worker       const std::vector<v8::Local<v8::Value>>& params);
41*3ac0a46fSAndroid Build Coastguard Worker   static CJS_Result AFPercent_Format(
42*3ac0a46fSAndroid Build Coastguard Worker       CJS_Runtime* pRuntime,
43*3ac0a46fSAndroid Build Coastguard Worker       const std::vector<v8::Local<v8::Value>>& params);
44*3ac0a46fSAndroid Build Coastguard Worker   static CJS_Result AFPercent_Keystroke(
45*3ac0a46fSAndroid Build Coastguard Worker       CJS_Runtime* pRuntime,
46*3ac0a46fSAndroid Build Coastguard Worker       const std::vector<v8::Local<v8::Value>>& params);
47*3ac0a46fSAndroid Build Coastguard Worker   static CJS_Result AFDate_FormatEx(
48*3ac0a46fSAndroid Build Coastguard Worker       CJS_Runtime* pRuntime,
49*3ac0a46fSAndroid Build Coastguard Worker       const std::vector<v8::Local<v8::Value>>& params);
50*3ac0a46fSAndroid Build Coastguard Worker   static CJS_Result AFDate_KeystrokeEx(
51*3ac0a46fSAndroid Build Coastguard Worker       CJS_Runtime* pRuntime,
52*3ac0a46fSAndroid Build Coastguard Worker       const std::vector<v8::Local<v8::Value>>& params);
53*3ac0a46fSAndroid Build Coastguard Worker   static CJS_Result AFDate_Format(
54*3ac0a46fSAndroid Build Coastguard Worker       CJS_Runtime* pRuntime,
55*3ac0a46fSAndroid Build Coastguard Worker       const std::vector<v8::Local<v8::Value>>& params);
56*3ac0a46fSAndroid Build Coastguard Worker   static CJS_Result AFDate_Keystroke(
57*3ac0a46fSAndroid Build Coastguard Worker       CJS_Runtime* pRuntime,
58*3ac0a46fSAndroid Build Coastguard Worker       const std::vector<v8::Local<v8::Value>>& params);
59*3ac0a46fSAndroid Build Coastguard Worker   static CJS_Result AFTime_FormatEx(
60*3ac0a46fSAndroid Build Coastguard Worker       CJS_Runtime* pRuntime,
61*3ac0a46fSAndroid Build Coastguard Worker       const std::vector<v8::Local<v8::Value>>& params);
62*3ac0a46fSAndroid Build Coastguard Worker   static CJS_Result AFTime_KeystrokeEx(
63*3ac0a46fSAndroid Build Coastguard Worker       CJS_Runtime* pRuntime,
64*3ac0a46fSAndroid Build Coastguard Worker       const std::vector<v8::Local<v8::Value>>& params);
65*3ac0a46fSAndroid Build Coastguard Worker   static CJS_Result AFTime_Format(
66*3ac0a46fSAndroid Build Coastguard Worker       CJS_Runtime* pRuntime,
67*3ac0a46fSAndroid Build Coastguard Worker       const std::vector<v8::Local<v8::Value>>& params);
68*3ac0a46fSAndroid Build Coastguard Worker   static CJS_Result AFTime_Keystroke(
69*3ac0a46fSAndroid Build Coastguard Worker       CJS_Runtime* pRuntime,
70*3ac0a46fSAndroid Build Coastguard Worker       const std::vector<v8::Local<v8::Value>>& params);
71*3ac0a46fSAndroid Build Coastguard Worker   static CJS_Result AFSpecial_Format(
72*3ac0a46fSAndroid Build Coastguard Worker       CJS_Runtime* pRuntime,
73*3ac0a46fSAndroid Build Coastguard Worker       const std::vector<v8::Local<v8::Value>>& params);
74*3ac0a46fSAndroid Build Coastguard Worker   static CJS_Result AFSpecial_Keystroke(
75*3ac0a46fSAndroid Build Coastguard Worker       CJS_Runtime* pRuntime,
76*3ac0a46fSAndroid Build Coastguard Worker       const std::vector<v8::Local<v8::Value>>& params);
77*3ac0a46fSAndroid Build Coastguard Worker   static CJS_Result AFSpecial_KeystrokeEx(
78*3ac0a46fSAndroid Build Coastguard Worker       CJS_Runtime* pRuntime,
79*3ac0a46fSAndroid Build Coastguard Worker       const std::vector<v8::Local<v8::Value>>& params);
80*3ac0a46fSAndroid Build Coastguard Worker   static CJS_Result AFSimple(CJS_Runtime* pRuntime,
81*3ac0a46fSAndroid Build Coastguard Worker                              const std::vector<v8::Local<v8::Value>>& params);
82*3ac0a46fSAndroid Build Coastguard Worker   static CJS_Result AFMakeNumber(
83*3ac0a46fSAndroid Build Coastguard Worker       CJS_Runtime* pRuntime,
84*3ac0a46fSAndroid Build Coastguard Worker       const std::vector<v8::Local<v8::Value>>& params);
85*3ac0a46fSAndroid Build Coastguard Worker   static CJS_Result AFSimple_Calculate(
86*3ac0a46fSAndroid Build Coastguard Worker       CJS_Runtime* pRuntime,
87*3ac0a46fSAndroid Build Coastguard Worker       const std::vector<v8::Local<v8::Value>>& params);
88*3ac0a46fSAndroid Build Coastguard Worker   static CJS_Result AFRange_Validate(
89*3ac0a46fSAndroid Build Coastguard Worker       CJS_Runtime* pRuntime,
90*3ac0a46fSAndroid Build Coastguard Worker       const std::vector<v8::Local<v8::Value>>& params);
91*3ac0a46fSAndroid Build Coastguard Worker   static CJS_Result AFMergeChange(
92*3ac0a46fSAndroid Build Coastguard Worker       CJS_Runtime* pRuntime,
93*3ac0a46fSAndroid Build Coastguard Worker       const std::vector<v8::Local<v8::Value>>& params);
94*3ac0a46fSAndroid Build Coastguard Worker   static CJS_Result AFParseDateEx(
95*3ac0a46fSAndroid Build Coastguard Worker       CJS_Runtime* pRuntime,
96*3ac0a46fSAndroid Build Coastguard Worker       const std::vector<v8::Local<v8::Value>>& params);
97*3ac0a46fSAndroid Build Coastguard Worker   static CJS_Result AFExtractNums(
98*3ac0a46fSAndroid Build Coastguard Worker       CJS_Runtime* pRuntime,
99*3ac0a46fSAndroid Build Coastguard Worker       const std::vector<v8::Local<v8::Value>>& params);
100*3ac0a46fSAndroid Build Coastguard Worker 
101*3ac0a46fSAndroid Build Coastguard Worker   static void AFNumber_Format_static(
102*3ac0a46fSAndroid Build Coastguard Worker       const v8::FunctionCallbackInfo<v8::Value>& info);
103*3ac0a46fSAndroid Build Coastguard Worker   static void AFNumber_Keystroke_static(
104*3ac0a46fSAndroid Build Coastguard Worker       const v8::FunctionCallbackInfo<v8::Value>& info);
105*3ac0a46fSAndroid Build Coastguard Worker   static void AFPercent_Format_static(
106*3ac0a46fSAndroid Build Coastguard Worker       const v8::FunctionCallbackInfo<v8::Value>& info);
107*3ac0a46fSAndroid Build Coastguard Worker   static void AFPercent_Keystroke_static(
108*3ac0a46fSAndroid Build Coastguard Worker       const v8::FunctionCallbackInfo<v8::Value>& info);
109*3ac0a46fSAndroid Build Coastguard Worker   static void AFDate_FormatEx_static(
110*3ac0a46fSAndroid Build Coastguard Worker       const v8::FunctionCallbackInfo<v8::Value>& info);
111*3ac0a46fSAndroid Build Coastguard Worker   static void AFDate_KeystrokeEx_static(
112*3ac0a46fSAndroid Build Coastguard Worker       const v8::FunctionCallbackInfo<v8::Value>& info);
113*3ac0a46fSAndroid Build Coastguard Worker   static void AFDate_Format_static(
114*3ac0a46fSAndroid Build Coastguard Worker       const v8::FunctionCallbackInfo<v8::Value>& info);
115*3ac0a46fSAndroid Build Coastguard Worker   static void AFDate_Keystroke_static(
116*3ac0a46fSAndroid Build Coastguard Worker       const v8::FunctionCallbackInfo<v8::Value>& info);
117*3ac0a46fSAndroid Build Coastguard Worker   static void AFTime_FormatEx_static(
118*3ac0a46fSAndroid Build Coastguard Worker       const v8::FunctionCallbackInfo<v8::Value>& info);
119*3ac0a46fSAndroid Build Coastguard Worker   static void AFTime_KeystrokeEx_static(
120*3ac0a46fSAndroid Build Coastguard Worker       const v8::FunctionCallbackInfo<v8::Value>& info);
121*3ac0a46fSAndroid Build Coastguard Worker   static void AFTime_Format_static(
122*3ac0a46fSAndroid Build Coastguard Worker       const v8::FunctionCallbackInfo<v8::Value>& info);
123*3ac0a46fSAndroid Build Coastguard Worker   static void AFTime_Keystroke_static(
124*3ac0a46fSAndroid Build Coastguard Worker       const v8::FunctionCallbackInfo<v8::Value>& info);
125*3ac0a46fSAndroid Build Coastguard Worker   static void AFSpecial_Format_static(
126*3ac0a46fSAndroid Build Coastguard Worker       const v8::FunctionCallbackInfo<v8::Value>& info);
127*3ac0a46fSAndroid Build Coastguard Worker   static void AFSpecial_Keystroke_static(
128*3ac0a46fSAndroid Build Coastguard Worker       const v8::FunctionCallbackInfo<v8::Value>& info);
129*3ac0a46fSAndroid Build Coastguard Worker   static void AFSpecial_KeystrokeEx_static(
130*3ac0a46fSAndroid Build Coastguard Worker       const v8::FunctionCallbackInfo<v8::Value>& info);
131*3ac0a46fSAndroid Build Coastguard Worker   static void AFSimple_static(const v8::FunctionCallbackInfo<v8::Value>& info);
132*3ac0a46fSAndroid Build Coastguard Worker   static void AFMakeNumber_static(
133*3ac0a46fSAndroid Build Coastguard Worker       const v8::FunctionCallbackInfo<v8::Value>& info);
134*3ac0a46fSAndroid Build Coastguard Worker   static void AFSimple_Calculate_static(
135*3ac0a46fSAndroid Build Coastguard Worker       const v8::FunctionCallbackInfo<v8::Value>& info);
136*3ac0a46fSAndroid Build Coastguard Worker   static void AFRange_Validate_static(
137*3ac0a46fSAndroid Build Coastguard Worker       const v8::FunctionCallbackInfo<v8::Value>& info);
138*3ac0a46fSAndroid Build Coastguard Worker   static void AFMergeChange_static(
139*3ac0a46fSAndroid Build Coastguard Worker       const v8::FunctionCallbackInfo<v8::Value>& info);
140*3ac0a46fSAndroid Build Coastguard Worker   static void AFParseDateEx_static(
141*3ac0a46fSAndroid Build Coastguard Worker       const v8::FunctionCallbackInfo<v8::Value>& info);
142*3ac0a46fSAndroid Build Coastguard Worker   static void AFExtractNums_static(
143*3ac0a46fSAndroid Build Coastguard Worker       const v8::FunctionCallbackInfo<v8::Value>& info);
144*3ac0a46fSAndroid Build Coastguard Worker 
145*3ac0a46fSAndroid Build Coastguard Worker   static bool MaskSatisfied(wchar_t c_Change, wchar_t c_Mask);
146*3ac0a46fSAndroid Build Coastguard Worker   static bool IsReservedMaskChar(wchar_t ch);
147*3ac0a46fSAndroid Build Coastguard Worker   static v8::Local<v8::Array> AF_MakeArrayFromList(CJS_Runtime* pRuntime,
148*3ac0a46fSAndroid Build Coastguard Worker                                                    v8::Local<v8::Value> val);
149*3ac0a46fSAndroid Build Coastguard Worker 
150*3ac0a46fSAndroid Build Coastguard Worker  private:
151*3ac0a46fSAndroid Build Coastguard Worker   static const JSMethodSpec GlobalFunctionSpecs[];
152*3ac0a46fSAndroid Build Coastguard Worker };
153*3ac0a46fSAndroid Build Coastguard Worker 
154*3ac0a46fSAndroid Build Coastguard Worker #endif  // FXJS_CJS_PUBLICMETHODS_H_
155