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