chromium/third_party/pdfium/fxjs/cjs_field.cpp

// Copyright 2014 The PDFium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com

#include "fxjs/cjs_field.h"

#include <algorithm>
#include <memory>
#include <optional>
#include <utility>

#include "constants/access_permissions.h"
#include "constants/annotation_flags.h"
#include "constants/form_flags.h"
#include "core/fpdfapi/parser/cpdf_stream.h"
#include "core/fpdfdoc/cpdf_formcontrol.h"
#include "core/fpdfdoc/cpdf_formfield.h"
#include "core/fpdfdoc/cpdf_interactiveform.h"
#include "core/fxcrt/check.h"
#include "core/fxcrt/notreached.h"
#include "core/fxcrt/span.h"
#include "fpdfsdk/cpdfsdk_formfillenvironment.h"
#include "fpdfsdk/cpdfsdk_interactiveform.h"
#include "fpdfsdk/cpdfsdk_pageview.h"
#include "fpdfsdk/cpdfsdk_widget.h"
#include "fxjs/cjs_color.h"
#include "fxjs/cjs_delaydata.h"
#include "fxjs/cjs_document.h"
#include "fxjs/cjs_icon.h"
#include "fxjs/fxv8.h"
#include "fxjs/js_resources.h"
#include "v8/include/v8-container.h"

namespace {

constexpr wchar_t kCheckSelector =;
constexpr wchar_t kCircleSelector =;
constexpr wchar_t kCrossSelector =;
constexpr wchar_t kDiamondSelector =;
constexpr wchar_t kSquareSelector =;
constexpr wchar_t kStarSelector =;

bool IsCheckBoxOrRadioButton(const CPDF_FormField* pFormField) {}

bool IsComboBoxOrListBox(const CPDF_FormField* pFormField) {}

bool IsComboBoxOrTextField(const CPDF_FormField* pFormField) {}

void UpdateFormField(CPDFSDK_FormFillEnvironment* pFormFillEnv,
                     CPDF_FormField* pFormField,
                     bool bResetAP) {}

void UpdateFormControl(CPDFSDK_FormFillEnvironment* pFormFillEnv,
                       CPDF_FormControl* pFormControl,
                       bool bResetAP) {}

struct FieldNameData {};

std::optional<FieldNameData> ParseFieldName(const WideString& field_name) {}

std::vector<CPDF_FormField*> GetFormFieldsForName(
    CPDFSDK_FormFillEnvironment* pFormFillEnv,
    const WideString& csFieldName) {}

CFX_Color GetFormControlColor(CPDF_FormControl* pFormControl,
                              const ByteString& entry) {}

bool SetWidgetDisplayStatus(CPDFSDK_Widget* pWidget, int value) {}

void SetBorderStyle(CPDFSDK_FormFillEnvironment* pFormFillEnv,
                    const WideString& swFieldName,
                    int nControlIndex,
                    const ByteString& bsString) {}

void SetCurrentValueIndices(CPDFSDK_FormFillEnvironment* pFormFillEnv,
                            const WideString& swFieldName,
                            int nControlIndex,
                            const std::vector<uint32_t>& array) {}

void SetDisplay(CPDFSDK_FormFillEnvironment* pFormFillEnv,
                const WideString& swFieldName,
                int nControlIndex,
                int number) {}

void SetHidden(CPDFSDK_FormFillEnvironment* pFormFillEnv,
               const WideString& swFieldName,
               int nControlIndex,
               bool b) {}

void SetLineWidth(CPDFSDK_FormFillEnvironment* pFormFillEnv,
                  const WideString& swFieldName,
                  int nControlIndex,
                  int number) {}

void SetRect(CPDFSDK_FormFillEnvironment* pFormFillEnv,
             const WideString& swFieldName,
             int nControlIndex,
             const CFX_FloatRect& rect) {}

void SetFieldValue(CPDFSDK_FormFillEnvironment* pFormFillEnv,
                   const WideString& swFieldName,
                   int nControlIndex,
                   const std::vector<WideString>& strArray) {}

wchar_t GetSelectorFromCaptionForFieldType(const WideString& caption,
                                           CPDF_FormField::Type type) {}

}  // namespace

const JSPropertySpec CJS_Field::PropertySpecs[] =;

const JSMethodSpec CJS_Field::MethodSpecs[] =;

uint32_t CJS_Field::ObjDefnID =;
const char CJS_Field::kName[] =;

// static
uint32_t CJS_Field::GetObjDefnID() {}

// static
void CJS_Field::DefineJSObjects(CFXJS_Engine* pEngine) {}

CJS_Field::CJS_Field(v8::Local<v8::Object> pObject, CJS_Runtime* pRuntime)
    :{}

CJS_Field::~CJS_Field() = default;

bool CJS_Field::AttachField(CJS_Document* pDocument,
                            const WideString& csFieldName) {}

std::vector<CPDF_FormField*> CJS_Field::GetFormFields() const {}

CPDF_FormField* CJS_Field::GetFirstFormField() const {}

CPDF_FormControl* CJS_Field::GetSmartFieldControl(CPDF_FormField* pFormField) {}

CJS_Result CJS_Field::get_alignment(CJS_Runtime* pRuntime) {}

CJS_Result CJS_Field::set_alignment(CJS_Runtime* pRuntime,
                                    v8::Local<v8::Value> vp) {}

CJS_Result CJS_Field::get_border_style(CJS_Runtime* pRuntime) {}

CJS_Result CJS_Field::set_border_style(CJS_Runtime* pRuntime,
                                       v8::Local<v8::Value> vp) {}

CJS_Result CJS_Field::get_button_align_x(CJS_Runtime* pRuntime) {}

CJS_Result CJS_Field::set_button_align_x(CJS_Runtime* pRuntime,
                                         v8::Local<v8::Value> vp) {}

CJS_Result CJS_Field::get_button_align_y(CJS_Runtime* pRuntime) {}

CJS_Result CJS_Field::set_button_align_y(CJS_Runtime* pRuntime,
                                         v8::Local<v8::Value> vp) {}

CJS_Result CJS_Field::get_button_fit_bounds(CJS_Runtime* pRuntime) {}

CJS_Result CJS_Field::set_button_fit_bounds(CJS_Runtime* pRuntime,
                                            v8::Local<v8::Value> vp) {}

CJS_Result CJS_Field::get_button_position(CJS_Runtime* pRuntime) {}

CJS_Result CJS_Field::set_button_position(CJS_Runtime* pRuntime,
                                          v8::Local<v8::Value> vp) {}

CJS_Result CJS_Field::get_button_scale_how(CJS_Runtime* pRuntime) {}

CJS_Result CJS_Field::set_button_scale_how(CJS_Runtime* pRuntime,
                                           v8::Local<v8::Value> vp) {}

CJS_Result CJS_Field::get_button_scale_when(CJS_Runtime* pRuntime) {}

CJS_Result CJS_Field::set_button_scale_when(CJS_Runtime* pRuntime,
                                            v8::Local<v8::Value> vp) {}

CJS_Result CJS_Field::get_calc_order_index(CJS_Runtime* pRuntime) {}

CJS_Result CJS_Field::set_calc_order_index(CJS_Runtime* pRuntime,
                                           v8::Local<v8::Value> vp) {}

CJS_Result CJS_Field::get_char_limit(CJS_Runtime* pRuntime) {}

CJS_Result CJS_Field::set_char_limit(CJS_Runtime* pRuntime,
                                     v8::Local<v8::Value> vp) {}

CJS_Result CJS_Field::get_comb(CJS_Runtime* pRuntime) {}

CJS_Result CJS_Field::set_comb(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {}

CJS_Result CJS_Field::get_commit_on_sel_change(CJS_Runtime* pRuntime) {}

CJS_Result CJS_Field::set_commit_on_sel_change(CJS_Runtime* pRuntime,
                                               v8::Local<v8::Value> vp) {}

CJS_Result CJS_Field::get_current_value_indices(CJS_Runtime* pRuntime) {}

CJS_Result CJS_Field::set_current_value_indices(CJS_Runtime* pRuntime,
                                                v8::Local<v8::Value> vp) {}

CJS_Result CJS_Field::get_default_style(CJS_Runtime* pRuntime) {}

CJS_Result CJS_Field::set_default_style(CJS_Runtime* pRuntime,
                                        v8::Local<v8::Value> vp) {}

CJS_Result CJS_Field::get_default_value(CJS_Runtime* pRuntime) {}

CJS_Result CJS_Field::set_default_value(CJS_Runtime* pRuntime,
                                        v8::Local<v8::Value> vp) {}

CJS_Result CJS_Field::get_do_not_scroll(CJS_Runtime* pRuntime) {}

CJS_Result CJS_Field::set_do_not_scroll(CJS_Runtime* pRuntime,
                                        v8::Local<v8::Value> vp) {}

CJS_Result CJS_Field::get_do_not_spell_check(CJS_Runtime* pRuntime) {}

CJS_Result CJS_Field::set_do_not_spell_check(CJS_Runtime* pRuntime,
                                             v8::Local<v8::Value> vp) {}

CJS_Result CJS_Field::get_delay(CJS_Runtime* pRuntime) {}

CJS_Result CJS_Field::set_delay(CJS_Runtime* pRuntime,
                                v8::Local<v8::Value> vp) {}

CJS_Result CJS_Field::get_display(CJS_Runtime* pRuntime) {}

CJS_Result CJS_Field::set_display(CJS_Runtime* pRuntime,
                                  v8::Local<v8::Value> vp) {}

CJS_Result CJS_Field::get_doc(CJS_Runtime* pRuntime) {}

CJS_Result CJS_Field::set_doc(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {}

CJS_Result CJS_Field::get_editable(CJS_Runtime* pRuntime) {}

CJS_Result CJS_Field::set_editable(CJS_Runtime* pRuntime,
                                   v8::Local<v8::Value> vp) {}

CJS_Result CJS_Field::get_export_values(CJS_Runtime* pRuntime) {}

CJS_Result CJS_Field::set_export_values(CJS_Runtime* pRuntime,
                                        v8::Local<v8::Value> vp) {}

CJS_Result CJS_Field::get_file_select(CJS_Runtime* pRuntime) {}

CJS_Result CJS_Field::set_file_select(CJS_Runtime* pRuntime,
                                      v8::Local<v8::Value> vp) {}

CJS_Result CJS_Field::get_fill_color(CJS_Runtime* pRuntime) {}

CJS_Result CJS_Field::set_fill_color(CJS_Runtime* pRuntime,
                                     v8::Local<v8::Value> vp) {}

CJS_Result CJS_Field::get_hidden(CJS_Runtime* pRuntime) {}

CJS_Result CJS_Field::set_hidden(CJS_Runtime* pRuntime,
                                 v8::Local<v8::Value> vp) {}

CJS_Result CJS_Field::get_highlight(CJS_Runtime* pRuntime) {}

CJS_Result CJS_Field::set_highlight(CJS_Runtime* pRuntime,
                                    v8::Local<v8::Value> vp) {}

CJS_Result CJS_Field::get_line_width(CJS_Runtime* pRuntime) {}

CJS_Result CJS_Field::set_line_width(CJS_Runtime* pRuntime,
                                     v8::Local<v8::Value> vp) {}

CJS_Result CJS_Field::get_multiline(CJS_Runtime* pRuntime) {}

CJS_Result CJS_Field::set_multiline(CJS_Runtime* pRuntime,
                                    v8::Local<v8::Value> vp) {}

CJS_Result CJS_Field::get_multiple_selection(CJS_Runtime* pRuntime) {}

CJS_Result CJS_Field::set_multiple_selection(CJS_Runtime* pRuntime,
                                             v8::Local<v8::Value> vp) {}

CJS_Result CJS_Field::get_name(CJS_Runtime* pRuntime) {}

CJS_Result CJS_Field::set_name(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {}

CJS_Result CJS_Field::get_num_items(CJS_Runtime* pRuntime) {}

CJS_Result CJS_Field::set_num_items(CJS_Runtime* pRuntime,
                                    v8::Local<v8::Value> vp) {}

CJS_Result CJS_Field::get_page(CJS_Runtime* pRuntime) {}

CJS_Result CJS_Field::set_page(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {}

CJS_Result CJS_Field::get_password(CJS_Runtime* pRuntime) {}

CJS_Result CJS_Field::set_password(CJS_Runtime* pRuntime,
                                   v8::Local<v8::Value> vp) {}

CJS_Result CJS_Field::get_print(CJS_Runtime* pRuntime) {}

CJS_Result CJS_Field::set_print(CJS_Runtime* pRuntime,
                                v8::Local<v8::Value> vp) {}

CJS_Result CJS_Field::get_radios_in_unison(CJS_Runtime* pRuntime) {}

CJS_Result CJS_Field::set_radios_in_unison(CJS_Runtime* pRuntime,
                                           v8::Local<v8::Value> vp) {}

CJS_Result CJS_Field::get_readonly(CJS_Runtime* pRuntime) {}

CJS_Result CJS_Field::set_readonly(CJS_Runtime* pRuntime,
                                   v8::Local<v8::Value> vp) {}

CJS_Result CJS_Field::get_rect(CJS_Runtime* pRuntime) {}

CJS_Result CJS_Field::set_rect(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {}

CJS_Result CJS_Field::get_required(CJS_Runtime* pRuntime) {}

CJS_Result CJS_Field::set_required(CJS_Runtime* pRuntime,
                                   v8::Local<v8::Value> vp) {}

CJS_Result CJS_Field::get_rich_text(CJS_Runtime* pRuntime) {}

CJS_Result CJS_Field::set_rich_text(CJS_Runtime* pRuntime,
                                    v8::Local<v8::Value> vp) {}

CJS_Result CJS_Field::get_rich_value(CJS_Runtime* pRuntime) {}

CJS_Result CJS_Field::set_rich_value(CJS_Runtime* pRuntime,
                                     v8::Local<v8::Value> vp) {}

CJS_Result CJS_Field::get_rotation(CJS_Runtime* pRuntime) {}

CJS_Result CJS_Field::set_rotation(CJS_Runtime* pRuntime,
                                   v8::Local<v8::Value> vp) {}

CJS_Result CJS_Field::get_source(CJS_Runtime* pRuntime) {}

CJS_Result CJS_Field::set_source(CJS_Runtime* pRuntime,
                                 v8::Local<v8::Value> vp) {}

CJS_Result CJS_Field::get_stroke_color(CJS_Runtime* pRuntime) {}

CJS_Result CJS_Field::set_stroke_color(CJS_Runtime* pRuntime,
                                       v8::Local<v8::Value> vp) {}

CJS_Result CJS_Field::get_style(CJS_Runtime* pRuntime) {}

CJS_Result CJS_Field::set_style(CJS_Runtime* pRuntime,
                                v8::Local<v8::Value> vp) {}

CJS_Result CJS_Field::get_submit_name(CJS_Runtime* pRuntime) {}

CJS_Result CJS_Field::set_submit_name(CJS_Runtime* pRuntime,
                                      v8::Local<v8::Value> vp) {}

CJS_Result CJS_Field::get_text_color(CJS_Runtime* pRuntime) {}

CJS_Result CJS_Field::set_text_color(CJS_Runtime* pRuntime,
                                     v8::Local<v8::Value> vp) {}

CJS_Result CJS_Field::get_text_font(CJS_Runtime* pRuntime) {}

CJS_Result CJS_Field::set_text_font(CJS_Runtime* pRuntime,
                                    v8::Local<v8::Value> vp) {}

CJS_Result CJS_Field::get_text_size(CJS_Runtime* pRuntime) {}

CJS_Result CJS_Field::set_text_size(CJS_Runtime* pRuntime,
                                    v8::Local<v8::Value> vp) {}

CJS_Result CJS_Field::get_type(CJS_Runtime* pRuntime) {}

CJS_Result CJS_Field::set_type(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {}

CJS_Result CJS_Field::get_user_name(CJS_Runtime* pRuntime) {}

CJS_Result CJS_Field::set_user_name(CJS_Runtime* pRuntime,
                                    v8::Local<v8::Value> vp) {}

CJS_Result CJS_Field::get_value(CJS_Runtime* pRuntime) {}

CJS_Result CJS_Field::set_value(CJS_Runtime* pRuntime,
                                v8::Local<v8::Value> vp) {}

CJS_Result CJS_Field::get_value_as_string(CJS_Runtime* pRuntime) {}

CJS_Result CJS_Field::set_value_as_string(CJS_Runtime* pRuntime,
                                          v8::Local<v8::Value> vp) {}

CJS_Result CJS_Field::browseForFileToSubmit(
    CJS_Runtime* pRuntime,
    pdfium::span<v8::Local<v8::Value>> params) {}

CJS_Result CJS_Field::buttonGetCaption(
    CJS_Runtime* pRuntime,
    pdfium::span<v8::Local<v8::Value>> params) {}

CJS_Result CJS_Field::buttonGetIcon(CJS_Runtime* pRuntime,
                                    pdfium::span<v8::Local<v8::Value>> params) {}

CJS_Result CJS_Field::buttonImportIcon(
    CJS_Runtime* pRuntime,
    pdfium::span<v8::Local<v8::Value>> params) {}

CJS_Result CJS_Field::buttonSetCaption(
    CJS_Runtime* pRuntime,
    pdfium::span<v8::Local<v8::Value>> params) {}

CJS_Result CJS_Field::buttonSetIcon(CJS_Runtime* pRuntime,
                                    pdfium::span<v8::Local<v8::Value>> params) {}

CJS_Result CJS_Field::checkThisBox(CJS_Runtime* pRuntime,
                                   pdfium::span<v8::Local<v8::Value>> params) {}

CJS_Result CJS_Field::clearItems(CJS_Runtime* pRuntime,
                                 pdfium::span<v8::Local<v8::Value>> params) {}

CJS_Result CJS_Field::defaultIsChecked(
    CJS_Runtime* pRuntime,
    pdfium::span<v8::Local<v8::Value>> params) {}

CJS_Result CJS_Field::deleteItemAt(CJS_Runtime* pRuntime,
                                   pdfium::span<v8::Local<v8::Value>> params) {}

CJS_Result CJS_Field::getArray(CJS_Runtime* pRuntime,
                               pdfium::span<v8::Local<v8::Value>> params) {}

CJS_Result CJS_Field::getItemAt(CJS_Runtime* pRuntime,
                                pdfium::span<v8::Local<v8::Value>> params) {}

CJS_Result CJS_Field::getLock(CJS_Runtime* pRuntime,
                              pdfium::span<v8::Local<v8::Value>> params) {}

CJS_Result CJS_Field::insertItemAt(CJS_Runtime* pRuntime,
                                   pdfium::span<v8::Local<v8::Value>> params) {}

CJS_Result CJS_Field::isBoxChecked(CJS_Runtime* pRuntime,
                                   pdfium::span<v8::Local<v8::Value>> params) {}

CJS_Result CJS_Field::isDefaultChecked(
    CJS_Runtime* pRuntime,
    pdfium::span<v8::Local<v8::Value>> params) {}

CJS_Result CJS_Field::setAction(CJS_Runtime* pRuntime,
                                pdfium::span<v8::Local<v8::Value>> params) {}

CJS_Result CJS_Field::setFocus(CJS_Runtime* pRuntime,
                               pdfium::span<v8::Local<v8::Value>> params) {}

CJS_Result CJS_Field::setItems(CJS_Runtime* pRuntime,
                               pdfium::span<v8::Local<v8::Value>> params) {}

CJS_Result CJS_Field::setLock(CJS_Runtime* pRuntime,
                              pdfium::span<v8::Local<v8::Value>> params) {}

CJS_Result CJS_Field::signatureGetModifications(
    CJS_Runtime* pRuntime,
    pdfium::span<v8::Local<v8::Value>> params) {}

CJS_Result CJS_Field::signatureGetSeedValue(
    CJS_Runtime* pRuntime,
    pdfium::span<v8::Local<v8::Value>> params) {}

CJS_Result CJS_Field::signatureInfo(CJS_Runtime* pRuntime,
                                    pdfium::span<v8::Local<v8::Value>> params) {}

CJS_Result CJS_Field::signatureSetSeedValue(
    CJS_Runtime* pRuntime,
    pdfium::span<v8::Local<v8::Value>> params) {}

CJS_Result CJS_Field::signatureSign(CJS_Runtime* pRuntime,
                                    pdfium::span<v8::Local<v8::Value>> params) {}

CJS_Result CJS_Field::signatureValidate(
    CJS_Runtime* pRuntime,
    pdfium::span<v8::Local<v8::Value>> params) {}

void CJS_Field::SetDelay(bool bDelay) {}

void CJS_Field::AddDelay_Int(FIELD_PROP prop, int32_t n) {}

void CJS_Field::AddDelay_Bool(FIELD_PROP prop, bool b) {}

void CJS_Field::AddDelay_String(FIELD_PROP prop, const ByteString& str) {}

void CJS_Field::AddDelay_Rect(FIELD_PROP prop, const CFX_FloatRect& rect) {}

void CJS_Field::AddDelay_WordArray(FIELD_PROP prop,
                                   const std::vector<uint32_t>& array) {}

void CJS_Field::AddDelay_WideStringArray(FIELD_PROP prop,
                                         const std::vector<WideString>& array) {}

void CJS_Field::DoDelay(CPDFSDK_FormFillEnvironment* pFormFillEnv,
                        CJS_DelayData* pData) {}