• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 FXJS_CJS_PUBLICMETHODS_H_
8 #define FXJS_CJS_PUBLICMETHODS_H_
9 
10 #include <vector>
11 
12 #include "fxjs/cjs_object.h"
13 #include "fxjs/cjs_result.h"
14 
15 class CJS_PublicMethods final : public CJS_Object {
16  public:
17   CJS_PublicMethods() = delete;
18 
19   static void DefineJSObjects(CFXJS_Engine* pEngine);
20 
21   static double ParseDate(const WideString& value, bool* bWrongFormat);
22   static double ParseDateAsGMT(const WideString& value);
23   static double ParseDateUsingFormat(const WideString& value,
24                                      const WideString& format,
25                                      bool* bWrongFormat);
26 
27   // Exposed for testing.
28   static WideString PrintDateUsingFormat(double dDate,
29                                          const WideString& format);
30   static bool IsNumber(const WideString& str);
31 
32   static CJS_Result AFNumber_Format(
33       CJS_Runtime* pRuntime,
34       const std::vector<v8::Local<v8::Value>>& params);
35   static CJS_Result AFNumber_Keystroke(
36       CJS_Runtime* pRuntime,
37       const std::vector<v8::Local<v8::Value>>& params);
38   static CJS_Result AFPercent_Format(
39       CJS_Runtime* pRuntime,
40       const std::vector<v8::Local<v8::Value>>& params);
41   static CJS_Result AFPercent_Keystroke(
42       CJS_Runtime* pRuntime,
43       const std::vector<v8::Local<v8::Value>>& params);
44   static CJS_Result AFDate_FormatEx(
45       CJS_Runtime* pRuntime,
46       const std::vector<v8::Local<v8::Value>>& params);
47   static CJS_Result AFDate_KeystrokeEx(
48       CJS_Runtime* pRuntime,
49       const std::vector<v8::Local<v8::Value>>& params);
50   static CJS_Result AFDate_Format(
51       CJS_Runtime* pRuntime,
52       const std::vector<v8::Local<v8::Value>>& params);
53   static CJS_Result AFDate_Keystroke(
54       CJS_Runtime* pRuntime,
55       const std::vector<v8::Local<v8::Value>>& params);
56   static CJS_Result AFTime_FormatEx(
57       CJS_Runtime* pRuntime,
58       const std::vector<v8::Local<v8::Value>>& params);
59   static CJS_Result AFTime_KeystrokeEx(
60       CJS_Runtime* pRuntime,
61       const std::vector<v8::Local<v8::Value>>& params);
62   static CJS_Result AFTime_Format(
63       CJS_Runtime* pRuntime,
64       const std::vector<v8::Local<v8::Value>>& params);
65   static CJS_Result AFTime_Keystroke(
66       CJS_Runtime* pRuntime,
67       const std::vector<v8::Local<v8::Value>>& params);
68   static CJS_Result AFSpecial_Format(
69       CJS_Runtime* pRuntime,
70       const std::vector<v8::Local<v8::Value>>& params);
71   static CJS_Result AFSpecial_Keystroke(
72       CJS_Runtime* pRuntime,
73       const std::vector<v8::Local<v8::Value>>& params);
74   static CJS_Result AFSpecial_KeystrokeEx(
75       CJS_Runtime* pRuntime,
76       const std::vector<v8::Local<v8::Value>>& params);
77   static CJS_Result AFSimple(CJS_Runtime* pRuntime,
78                              const std::vector<v8::Local<v8::Value>>& params);
79   static CJS_Result AFMakeNumber(
80       CJS_Runtime* pRuntime,
81       const std::vector<v8::Local<v8::Value>>& params);
82   static CJS_Result AFSimple_Calculate(
83       CJS_Runtime* pRuntime,
84       const std::vector<v8::Local<v8::Value>>& params);
85   static CJS_Result AFRange_Validate(
86       CJS_Runtime* pRuntime,
87       const std::vector<v8::Local<v8::Value>>& params);
88   static CJS_Result AFMergeChange(
89       CJS_Runtime* pRuntime,
90       const std::vector<v8::Local<v8::Value>>& params);
91   static CJS_Result AFParseDateEx(
92       CJS_Runtime* pRuntime,
93       const std::vector<v8::Local<v8::Value>>& params);
94   static CJS_Result AFExtractNums(
95       CJS_Runtime* pRuntime,
96       const std::vector<v8::Local<v8::Value>>& params);
97 
98   static void AFNumber_Format_static(
99       const v8::FunctionCallbackInfo<v8::Value>& info);
100   static void AFNumber_Keystroke_static(
101       const v8::FunctionCallbackInfo<v8::Value>& info);
102   static void AFPercent_Format_static(
103       const v8::FunctionCallbackInfo<v8::Value>& info);
104   static void AFPercent_Keystroke_static(
105       const v8::FunctionCallbackInfo<v8::Value>& info);
106   static void AFDate_FormatEx_static(
107       const v8::FunctionCallbackInfo<v8::Value>& info);
108   static void AFDate_KeystrokeEx_static(
109       const v8::FunctionCallbackInfo<v8::Value>& info);
110   static void AFDate_Format_static(
111       const v8::FunctionCallbackInfo<v8::Value>& info);
112   static void AFDate_Keystroke_static(
113       const v8::FunctionCallbackInfo<v8::Value>& info);
114   static void AFTime_FormatEx_static(
115       const v8::FunctionCallbackInfo<v8::Value>& info);
116   static void AFTime_KeystrokeEx_static(
117       const v8::FunctionCallbackInfo<v8::Value>& info);
118   static void AFTime_Format_static(
119       const v8::FunctionCallbackInfo<v8::Value>& info);
120   static void AFTime_Keystroke_static(
121       const v8::FunctionCallbackInfo<v8::Value>& info);
122   static void AFSpecial_Format_static(
123       const v8::FunctionCallbackInfo<v8::Value>& info);
124   static void AFSpecial_Keystroke_static(
125       const v8::FunctionCallbackInfo<v8::Value>& info);
126   static void AFSpecial_KeystrokeEx_static(
127       const v8::FunctionCallbackInfo<v8::Value>& info);
128   static void AFSimple_static(const v8::FunctionCallbackInfo<v8::Value>& info);
129   static void AFMakeNumber_static(
130       const v8::FunctionCallbackInfo<v8::Value>& info);
131   static void AFSimple_Calculate_static(
132       const v8::FunctionCallbackInfo<v8::Value>& info);
133   static void AFRange_Validate_static(
134       const v8::FunctionCallbackInfo<v8::Value>& info);
135   static void AFMergeChange_static(
136       const v8::FunctionCallbackInfo<v8::Value>& info);
137   static void AFParseDateEx_static(
138       const v8::FunctionCallbackInfo<v8::Value>& info);
139   static void AFExtractNums_static(
140       const v8::FunctionCallbackInfo<v8::Value>& info);
141 
142   static bool MaskSatisfied(wchar_t c_Change, wchar_t c_Mask);
143   static bool IsReservedMaskChar(wchar_t ch);
144   static v8::Local<v8::Array> AF_MakeArrayFromList(CJS_Runtime* pRuntime,
145                                                    v8::Local<v8::Value> val);
146 
147  private:
148   static const JSMethodSpec GlobalFunctionSpecs[];
149 };
150 
151 #endif  // FXJS_CJS_PUBLICMETHODS_H_
152