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