• 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_JAVASCRIPT_PUBLICMETHODS_H_
8 #define FPDFSDK_JAVASCRIPT_PUBLICMETHODS_H_
9 
10 #include <string>
11 #include <vector>
12 
13 #include "fpdfsdk/javascript/JS_Define.h"
14 
15 class CJS_PublicMethods : public CJS_Object {
16  public:
CJS_PublicMethods(v8::Local<v8::Object> pObject)17   explicit CJS_PublicMethods(v8::Local<v8::Object> pObject)
18       : CJS_Object(pObject) {}
~CJS_PublicMethods()19   ~CJS_PublicMethods() override {}
20 
21   static bool AFNumber_Format(CJS_Runtime* pRuntime,
22                               const std::vector<CJS_Value>& params,
23                               CJS_Value& vRet,
24                               CFX_WideString& sError);
25   static bool AFNumber_Keystroke(CJS_Runtime* pRuntime,
26                                  const std::vector<CJS_Value>& params,
27                                  CJS_Value& vRet,
28                                  CFX_WideString& sError);
29   static bool AFPercent_Format(CJS_Runtime* pRuntime,
30                                const std::vector<CJS_Value>& params,
31                                CJS_Value& vRet,
32                                CFX_WideString& sError);
33   static bool AFPercent_Keystroke(CJS_Runtime* pRuntime,
34                                   const std::vector<CJS_Value>& params,
35                                   CJS_Value& vRet,
36                                   CFX_WideString& sError);
37   static bool AFDate_FormatEx(CJS_Runtime* pRuntime,
38                               const std::vector<CJS_Value>& params,
39                               CJS_Value& vRet,
40                               CFX_WideString& sError);
41   static bool AFDate_KeystrokeEx(CJS_Runtime* pRuntime,
42                                  const std::vector<CJS_Value>& params,
43                                  CJS_Value& vRet,
44                                  CFX_WideString& sError);
45   static bool AFDate_Format(CJS_Runtime* pRuntime,
46                             const std::vector<CJS_Value>& params,
47                             CJS_Value& vRet,
48                             CFX_WideString& sError);
49   static bool AFDate_Keystroke(CJS_Runtime* pRuntime,
50                                const std::vector<CJS_Value>& params,
51                                CJS_Value& vRet,
52                                CFX_WideString& sError);
53   static bool AFTime_FormatEx(CJS_Runtime* pRuntime,
54                               const std::vector<CJS_Value>& params,
55                               CJS_Value& vRet,
56                               CFX_WideString& sError);  //
57   static bool AFTime_KeystrokeEx(CJS_Runtime* pRuntime,
58                                  const std::vector<CJS_Value>& params,
59                                  CJS_Value& vRet,
60                                  CFX_WideString& sError);
61   static bool AFTime_Format(CJS_Runtime* pRuntime,
62                             const std::vector<CJS_Value>& params,
63                             CJS_Value& vRet,
64                             CFX_WideString& sError);
65   static bool AFTime_Keystroke(CJS_Runtime* pRuntime,
66                                const std::vector<CJS_Value>& params,
67                                CJS_Value& vRet,
68                                CFX_WideString& sError);
69   static bool AFSpecial_Format(CJS_Runtime* pRuntime,
70                                const std::vector<CJS_Value>& params,
71                                CJS_Value& vRet,
72                                CFX_WideString& sError);
73   static bool AFSpecial_Keystroke(CJS_Runtime* pRuntime,
74                                   const std::vector<CJS_Value>& params,
75                                   CJS_Value& vRet,
76                                   CFX_WideString& sError);
77   static bool AFSpecial_KeystrokeEx(CJS_Runtime* pRuntime,
78                                     const std::vector<CJS_Value>& params,
79                                     CJS_Value& vRet,
80                                     CFX_WideString& sError);  //
81   static bool AFSimple(CJS_Runtime* pRuntime,
82                        const std::vector<CJS_Value>& params,
83                        CJS_Value& vRet,
84                        CFX_WideString& sError);
85   static bool AFMakeNumber(CJS_Runtime* pRuntime,
86                            const std::vector<CJS_Value>& params,
87                            CJS_Value& vRet,
88                            CFX_WideString& sError);
89   static bool AFSimple_Calculate(CJS_Runtime* pRuntime,
90                                  const std::vector<CJS_Value>& params,
91                                  CJS_Value& vRet,
92                                  CFX_WideString& sError);
93   static bool AFRange_Validate(CJS_Runtime* pRuntime,
94                                const std::vector<CJS_Value>& params,
95                                CJS_Value& vRet,
96                                CFX_WideString& sError);
97   static bool AFMergeChange(CJS_Runtime* pRuntime,
98                             const std::vector<CJS_Value>& params,
99                             CJS_Value& vRet,
100                             CFX_WideString& sError);
101   static bool AFParseDateEx(CJS_Runtime* pRuntime,
102                             const std::vector<CJS_Value>& params,
103                             CJS_Value& vRet,
104                             CFX_WideString& sError);
105   static bool AFExtractNums(CJS_Runtime* pRuntime,
106                             const std::vector<CJS_Value>& params,
107                             CJS_Value& vRet,
108                             CFX_WideString& sError);
109 
110   JS_STATIC_GLOBAL_FUN(AFNumber_Format);
111   JS_STATIC_GLOBAL_FUN(AFNumber_Keystroke);
112   JS_STATIC_GLOBAL_FUN(AFPercent_Format);
113   JS_STATIC_GLOBAL_FUN(AFPercent_Keystroke);
114   JS_STATIC_GLOBAL_FUN(AFDate_FormatEx);
115   JS_STATIC_GLOBAL_FUN(AFDate_KeystrokeEx);
116   JS_STATIC_GLOBAL_FUN(AFDate_Format);
117   JS_STATIC_GLOBAL_FUN(AFDate_Keystroke);
118   JS_STATIC_GLOBAL_FUN(AFTime_FormatEx);
119   JS_STATIC_GLOBAL_FUN(AFTime_KeystrokeEx);
120   JS_STATIC_GLOBAL_FUN(AFTime_Format);
121   JS_STATIC_GLOBAL_FUN(AFTime_Keystroke);
122   JS_STATIC_GLOBAL_FUN(AFSpecial_Format);
123   JS_STATIC_GLOBAL_FUN(AFSpecial_Keystroke);
124   JS_STATIC_GLOBAL_FUN(AFSpecial_KeystrokeEx);
125   JS_STATIC_GLOBAL_FUN(AFSimple);
126   JS_STATIC_GLOBAL_FUN(AFMakeNumber);
127   JS_STATIC_GLOBAL_FUN(AFSimple_Calculate);
128   JS_STATIC_GLOBAL_FUN(AFRange_Validate);
129   JS_STATIC_GLOBAL_FUN(AFMergeChange);
130   JS_STATIC_GLOBAL_FUN(AFParseDateEx);
131   JS_STATIC_GLOBAL_FUN(AFExtractNums);
132 
133   JS_STATIC_DECLARE_GLOBAL_FUN();
134 
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 double ParseNormalDate(const CFX_WideString& value,
148                                 bool* bWrongFormat);
149   static double MakeInterDate(const CFX_WideString& value);
150 
151   static bool IsNumber(const CFX_WideString& str);
152 
153   static bool maskSatisfied(wchar_t c_Change, wchar_t c_Mask);
154   static bool isReservedMaskChar(wchar_t ch);
155 
156   static double AF_Simple(const FX_WCHAR* sFuction,
157                           double dValue1,
158                           double dValue2);
159   static CJS_Array AF_MakeArrayFromList(CJS_Runtime* pRuntime, CJS_Value val);
160 };
161 
162 #endif  // FPDFSDK_JAVASCRIPT_PUBLICMETHODS_H_
163