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