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