#include "fxjs/cjs_publicmethods.h"
#include <math.h>
#include <algorithm>
#include <array>
#include <iomanip>
#include <iterator>
#include <limits>
#include <optional>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
#include "build/build_config.h"
#include "core/fpdfapi/parser/cpdf_stream.h"
#include "core/fpdfdoc/cpdf_formcontrol.h"
#include "core/fpdfdoc/cpdf_interactiveform.h"
#include "core/fxcrt/check.h"
#include "core/fxcrt/compiler_specific.h"
#include "core/fxcrt/fx_extension.h"
#include "core/fxcrt/fx_string_wrappers.h"
#include "core/fxcrt/numerics/safe_conversions.h"
#include "core/fxcrt/span.h"
#include "core/fxge/cfx_color.h"
#include "fpdfsdk/cpdfsdk_formfillenvironment.h"
#include "fpdfsdk/cpdfsdk_interactiveform.h"
#include "fxjs/cjs_color.h"
#include "fxjs/cjs_event_context.h"
#include "fxjs/cjs_field.h"
#include "fxjs/cjs_object.h"
#include "fxjs/cjs_runtime.h"
#include "fxjs/cjs_util.h"
#include "fxjs/fx_date_helpers.h"
#include "fxjs/js_define.h"
#include "fxjs/js_resources.h"
#include "v8/include/v8-container.h"
const JSMethodSpec CJS_PublicMethods::GlobalFunctionSpecs[] = …;
namespace {
#if !BUILDFLAG(IS_ANDROID)
constexpr double kDoubleCorrect = …;
#endif
constexpr std::array<const char*, 14> kDateFormats = …;
constexpr std::array<const char*, 4> kTimeFormats = …;
template <typename T>
T StrTrim(const T& str) { … }
void AlertIfPossible(CJS_EventContext* pContext,
const WideString& wsCaller,
const WideString& wsMsg) { … }
#if !BUILDFLAG(IS_ANDROID)
ByteString CalculateString(double dValue,
int iDec,
int* iDec2,
bool* bNegative) { … }
#endif
WideString CalcMergedString(const CJS_EventContext* event,
const WideString& value,
const WideString& change) { … }
template <CJS_Result (*F)(CJS_Runtime*, pdfium::span<v8::Local<v8::Value>>)>
void JSGlobalFunc(const char* func_name_string,
const v8::FunctionCallbackInfo<v8::Value>& info) { … }
int WithinBoundsOrZero(int value, size_t size) { … }
int ValidStyleOrZero(int style) { … }
bool IsDigitSeparatorOrDecimalMark(int c) { … }
#if !BUILDFLAG(IS_ANDROID)
bool IsStyleWithDigitSeparator(int style) { … }
char DigitSeparatorForStyle(int style) { … }
bool IsStyleWithApostropheSeparator(int style) { … }
#endif
bool IsStyleWithCommaDecimalMark(int style) { … }
char DecimalMarkForStyle(int style) { … }
#if !BUILDFLAG(IS_ANDROID)
void NormalizeDecimalMark(ByteString* str) { … }
#endif
void NormalizeDecimalMarkW(WideString* str) { … }
std::optional<double> ApplyNamedOperation(const WideString& wsFunction,
double dValue1,
double dValue2) { … }
}
void CJS_PublicMethods::DefineJSObjects(CFXJS_Engine* pEngine) { … }
#define JS_STATIC_GLOBAL_FUN(fun_name) …
JS_STATIC_GLOBAL_FUN(…)
JS_STATIC_GLOBAL_FUN(…)
JS_STATIC_GLOBAL_FUN(…)
JS_STATIC_GLOBAL_FUN(…)
JS_STATIC_GLOBAL_FUN(…)
JS_STATIC_GLOBAL_FUN(…)
JS_STATIC_GLOBAL_FUN(…)
JS_STATIC_GLOBAL_FUN(…)
JS_STATIC_GLOBAL_FUN(…)
JS_STATIC_GLOBAL_FUN(…)
JS_STATIC_GLOBAL_FUN(…)
JS_STATIC_GLOBAL_FUN(…)
JS_STATIC_GLOBAL_FUN(…)
JS_STATIC_GLOBAL_FUN(…)
JS_STATIC_GLOBAL_FUN(…)
JS_STATIC_GLOBAL_FUN(…)
JS_STATIC_GLOBAL_FUN(…)
JS_STATIC_GLOBAL_FUN(…)
JS_STATIC_GLOBAL_FUN(…)
JS_STATIC_GLOBAL_FUN(…)
JS_STATIC_GLOBAL_FUN(…)
JS_STATIC_GLOBAL_FUN(…)
bool CJS_PublicMethods::IsNumber(const WideString& str) { … }
bool CJS_PublicMethods::MaskSatisfied(wchar_t c_Change, wchar_t c_Mask) { … }
bool CJS_PublicMethods::IsReservedMaskChar(wchar_t ch) { … }
v8::Local<v8::Array> CJS_PublicMethods::AF_MakeArrayFromList(
CJS_Runtime* pRuntime,
v8::Local<v8::Value> val) { … }
double CJS_PublicMethods::ParseDate(v8::Isolate* isolate,
const WideString& value,
bool* bWrongFormat) { … }
double CJS_PublicMethods::ParseDateUsingFormat(v8::Isolate* isolate,
const WideString& value,
const WideString& format,
bool* bWrongFormat) { … }
WideString CJS_PublicMethods::PrintDateUsingFormat(double dDate,
const WideString& format) { … }
CJS_Result CJS_PublicMethods::AFNumber_Format(
CJS_Runtime* pRuntime,
pdfium::span<v8::Local<v8::Value>> params) { … }
CJS_Result CJS_PublicMethods::AFNumber_Keystroke(
CJS_Runtime* pRuntime,
pdfium::span<v8::Local<v8::Value>> params) { … }
CJS_Result CJS_PublicMethods::AFPercent_Format(
CJS_Runtime* pRuntime,
pdfium::span<v8::Local<v8::Value>> params) { … }
CJS_Result CJS_PublicMethods::AFPercent_Keystroke(
CJS_Runtime* pRuntime,
pdfium::span<v8::Local<v8::Value>> params) { … }
CJS_Result CJS_PublicMethods::AFDate_FormatEx(
CJS_Runtime* pRuntime,
pdfium::span<v8::Local<v8::Value>> params) { … }
double CJS_PublicMethods::ParseDateAsGMT(v8::Isolate* isolate,
const WideString& strValue) { … }
CJS_Result CJS_PublicMethods::AFDate_KeystrokeEx(
CJS_Runtime* pRuntime,
pdfium::span<v8::Local<v8::Value>> params) { … }
CJS_Result CJS_PublicMethods::AFDate_Format(
CJS_Runtime* pRuntime,
pdfium::span<v8::Local<v8::Value>> params) { … }
CJS_Result CJS_PublicMethods::AFDate_Keystroke(
CJS_Runtime* pRuntime,
pdfium::span<v8::Local<v8::Value>> params) { … }
CJS_Result CJS_PublicMethods::AFTime_Format(
CJS_Runtime* pRuntime,
pdfium::span<v8::Local<v8::Value>> params) { … }
CJS_Result CJS_PublicMethods::AFTime_Keystroke(
CJS_Runtime* pRuntime,
pdfium::span<v8::Local<v8::Value>> params) { … }
CJS_Result CJS_PublicMethods::AFTime_FormatEx(
CJS_Runtime* pRuntime,
pdfium::span<v8::Local<v8::Value>> params) { … }
CJS_Result CJS_PublicMethods::AFTime_KeystrokeEx(
CJS_Runtime* pRuntime,
pdfium::span<v8::Local<v8::Value>> params) { … }
CJS_Result CJS_PublicMethods::AFSpecial_Format(
CJS_Runtime* pRuntime,
pdfium::span<v8::Local<v8::Value>> params) { … }
CJS_Result CJS_PublicMethods::AFSpecial_KeystrokeEx(
CJS_Runtime* pRuntime,
pdfium::span<v8::Local<v8::Value>> params) { … }
CJS_Result CJS_PublicMethods::AFSpecial_Keystroke(
CJS_Runtime* pRuntime,
pdfium::span<v8::Local<v8::Value>> params) { … }
CJS_Result CJS_PublicMethods::AFMergeChange(
CJS_Runtime* pRuntime,
pdfium::span<v8::Local<v8::Value>> params) { … }
CJS_Result CJS_PublicMethods::AFParseDateEx(
CJS_Runtime* pRuntime,
pdfium::span<v8::Local<v8::Value>> params) { … }
CJS_Result CJS_PublicMethods::AFSimple(
CJS_Runtime* pRuntime,
pdfium::span<v8::Local<v8::Value>> params) { … }
CJS_Result CJS_PublicMethods::AFMakeNumber(
CJS_Runtime* pRuntime,
pdfium::span<v8::Local<v8::Value>> params) { … }
CJS_Result CJS_PublicMethods::AFSimple_Calculate(
CJS_Runtime* pRuntime,
pdfium::span<v8::Local<v8::Value>> params) { … }
CJS_Result CJS_PublicMethods::AFRange_Validate(
CJS_Runtime* pRuntime,
pdfium::span<v8::Local<v8::Value>> params) { … }
CJS_Result CJS_PublicMethods::AFExtractNums(
CJS_Runtime* pRuntime,
pdfium::span<v8::Local<v8::Value>> params) { … }