blob: 1c8d6beac17a5f1e2313d98e1b81d1836e70df5d [file] [log] [blame]
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001// 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.
Lei Zhanga6d9f0e2015-06-13 00:48:38 -07004
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07005// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
Dan Sinclairf766ad22016-03-14 13:51:24 -04007#ifndef FPDFSDK_JAVASCRIPT_FIELD_H_
8#define FPDFSDK_JAVASCRIPT_FIELD_H_
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07009
Dan Sinclair3ebd1212016-03-09 09:59:23 -050010#include <string>
11#include <vector>
Tom Sepez9a3f8122015-04-07 15:35:48 -070012
dsinclaira52ab742016-09-29 13:59:29 -070013#include "core/fxcrt/cfx_observable.h"
Dan Sinclair7f55a542017-07-13 14:17:10 -040014#include "core/fxge/cfx_color.h"
dsinclair3a7741a2016-10-11 10:39:49 -070015#include "fpdfsdk/cpdfsdk_formfillenvironment.h"
Dan Sinclairf766ad22016-03-14 13:51:24 -040016#include "fpdfsdk/javascript/JS_Define.h"
Tom Sepez9a3f8122015-04-07 15:35:48 -070017
Tom Sepez37458412015-10-06 11:33:46 -070018class CPDFSDK_Widget;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070019class Document;
20
Nico Weber9d8ec5a2015-08-04 13:00:21 -070021enum FIELD_PROP {
22 FP_ALIGNMENT,
23 FP_BORDERSTYLE,
24 FP_BUTTONALIGNX,
25 FP_BUTTONALIGNY,
26 FP_BUTTONFITBOUNDS,
27 FP_BUTTONPOSITION,
28 FP_BUTTONSCALEHOW,
29 FP_BUTTONSCALEWHEN,
30 FP_CALCORDERINDEX,
31 FP_CHARLIMIT,
32 FP_COMB,
33 FP_COMMITONSELCHANGE,
34 FP_CURRENTVALUEINDICES,
35 FP_DEFAULTVALUE,
36 FP_DONOTSCROLL,
37 FP_DISPLAY,
38 FP_FILLCOLOR,
39 FP_HIDDEN,
40 FP_HIGHLIGHT,
41 FP_LINEWIDTH,
42 FP_MULTILINE,
43 FP_MULTIPLESELECTION,
44 FP_PASSWORD,
45 FP_RECT,
46 FP_RICHTEXT,
47 FP_RICHVALUE,
48 FP_ROTATION,
49 FP_STROKECOLOR,
50 FP_STYLE,
51 FP_TEXTCOLOR,
52 FP_TEXTFONT,
53 FP_TEXTSIZE,
54 FP_USERNAME,
55 FP_VALUE
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070056};
57
Nico Weber9d8ec5a2015-08-04 13:00:21 -070058struct CJS_DelayData {
weili625ad662016-06-15 11:21:33 -070059 CJS_DelayData(FIELD_PROP prop, int idx, const CFX_WideString& name);
60 ~CJS_DelayData();
tsepez41a53ad2016-03-28 16:59:30 -070061
62 FIELD_PROP eProp;
Nico Weber9d8ec5a2015-08-04 13:00:21 -070063 int nControlIndex;
tsepez41a53ad2016-03-28 16:59:30 -070064 CFX_WideString sFieldName;
Nico Weber9d8ec5a2015-08-04 13:00:21 -070065 int32_t num;
66 bool b;
67 CFX_ByteString string;
68 CFX_WideString widestring;
Tom Sepez281a9ea2016-02-26 14:24:28 -080069 CFX_FloatRect rect;
Dan Sinclair7f55a542017-07-13 14:17:10 -040070 CFX_Color color;
tsepez41a53ad2016-03-28 16:59:30 -070071 std::vector<uint32_t> wordarray;
72 std::vector<CFX_WideString> widestringarray;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070073};
74
Nico Weber9d8ec5a2015-08-04 13:00:21 -070075class Field : public CJS_EmbedObj {
76 public:
Lei Zhangd88a3642015-11-10 09:38:57 -080077 explicit Field(CJS_Object* pJSObject);
Lei Zhang2b1a2d52015-08-14 22:16:22 -070078 ~Field() override;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070079
Tom Sepezb1670b52017-02-16 17:01:00 -080080 bool alignment(CJS_Runtime* pRuntime,
Tom Sepezd6ae2af2017-02-16 11:49:55 -080081 CJS_PropValue& vp,
82 CFX_WideString& sError);
Tom Sepezb1670b52017-02-16 17:01:00 -080083 bool borderStyle(CJS_Runtime* pRuntime,
Tom Sepezd6ae2af2017-02-16 11:49:55 -080084 CJS_PropValue& vp,
85 CFX_WideString& sError);
Tom Sepezb1670b52017-02-16 17:01:00 -080086 bool buttonAlignX(CJS_Runtime* pRuntime,
Tom Sepezd6ae2af2017-02-16 11:49:55 -080087 CJS_PropValue& vp,
88 CFX_WideString& sError);
Tom Sepezb1670b52017-02-16 17:01:00 -080089 bool buttonAlignY(CJS_Runtime* pRuntime,
Tom Sepezd6ae2af2017-02-16 11:49:55 -080090 CJS_PropValue& vp,
91 CFX_WideString& sError);
Tom Sepezb1670b52017-02-16 17:01:00 -080092 bool buttonFitBounds(CJS_Runtime* pRuntime,
tsepez4cf55152016-11-02 14:37:54 -070093 CJS_PropValue& vp,
94 CFX_WideString& sError);
Tom Sepezb1670b52017-02-16 17:01:00 -080095 bool buttonPosition(CJS_Runtime* pRuntime,
Nico Weber9d8ec5a2015-08-04 13:00:21 -070096 CJS_PropValue& vp,
97 CFX_WideString& sError);
Tom Sepezb1670b52017-02-16 17:01:00 -080098 bool buttonScaleHow(CJS_Runtime* pRuntime,
Nico Weber9d8ec5a2015-08-04 13:00:21 -070099 CJS_PropValue& vp,
100 CFX_WideString& sError);
Tom Sepezb1670b52017-02-16 17:01:00 -0800101 bool buttonScaleWhen(CJS_Runtime* pRuntime,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700102 CJS_PropValue& vp,
103 CFX_WideString& sError);
Tom Sepezb1670b52017-02-16 17:01:00 -0800104 bool calcOrderIndex(CJS_Runtime* pRuntime,
tsepez4cf55152016-11-02 14:37:54 -0700105 CJS_PropValue& vp,
106 CFX_WideString& sError);
Tom Sepezb1670b52017-02-16 17:01:00 -0800107 bool charLimit(CJS_Runtime* pRuntime,
Tom Sepezd6ae2af2017-02-16 11:49:55 -0800108 CJS_PropValue& vp,
109 CFX_WideString& sError);
Tom Sepezb1670b52017-02-16 17:01:00 -0800110 bool comb(CJS_Runtime* pRuntime, CJS_PropValue& vp, CFX_WideString& sError);
111 bool commitOnSelChange(CJS_Runtime* pRuntime,
tsepez4cf55152016-11-02 14:37:54 -0700112 CJS_PropValue& vp,
113 CFX_WideString& sError);
Tom Sepezb1670b52017-02-16 17:01:00 -0800114 bool currentValueIndices(CJS_Runtime* pRuntime,
tsepez4cf55152016-11-02 14:37:54 -0700115 CJS_PropValue& vp,
116 CFX_WideString& sError);
Tom Sepezb1670b52017-02-16 17:01:00 -0800117 bool defaultStyle(CJS_Runtime* pRuntime,
Tom Sepezd6ae2af2017-02-16 11:49:55 -0800118 CJS_PropValue& vp,
119 CFX_WideString& sError);
Tom Sepezb1670b52017-02-16 17:01:00 -0800120 bool defaultValue(CJS_Runtime* pRuntime,
Tom Sepezd6ae2af2017-02-16 11:49:55 -0800121 CJS_PropValue& vp,
122 CFX_WideString& sError);
Tom Sepezb1670b52017-02-16 17:01:00 -0800123 bool doNotScroll(CJS_Runtime* pRuntime,
Tom Sepezd6ae2af2017-02-16 11:49:55 -0800124 CJS_PropValue& vp,
125 CFX_WideString& sError);
Tom Sepezb1670b52017-02-16 17:01:00 -0800126 bool doNotSpellCheck(CJS_Runtime* pRuntime,
tsepez4cf55152016-11-02 14:37:54 -0700127 CJS_PropValue& vp,
128 CFX_WideString& sError);
Tom Sepezb1670b52017-02-16 17:01:00 -0800129 bool delay(CJS_Runtime* pRuntime, CJS_PropValue& vp, CFX_WideString& sError);
130 bool display(CJS_Runtime* pRuntime,
131 CJS_PropValue& vp,
132 CFX_WideString& sError);
133 bool doc(CJS_Runtime* pRuntime, CJS_PropValue& vp, CFX_WideString& sError);
134 bool editable(CJS_Runtime* pRuntime,
Tom Sepezd6ae2af2017-02-16 11:49:55 -0800135 CJS_PropValue& vp,
136 CFX_WideString& sError);
Tom Sepezb1670b52017-02-16 17:01:00 -0800137 bool exportValues(CJS_Runtime* pRuntime,
Tom Sepezd6ae2af2017-02-16 11:49:55 -0800138 CJS_PropValue& vp,
139 CFX_WideString& sError);
Tom Sepezb1670b52017-02-16 17:01:00 -0800140 bool fileSelect(CJS_Runtime* pRuntime,
Tom Sepezd6ae2af2017-02-16 11:49:55 -0800141 CJS_PropValue& vp,
142 CFX_WideString& sError);
Tom Sepezb1670b52017-02-16 17:01:00 -0800143 bool fillColor(CJS_Runtime* pRuntime,
Tom Sepezd6ae2af2017-02-16 11:49:55 -0800144 CJS_PropValue& vp,
145 CFX_WideString& sError);
Tom Sepezb1670b52017-02-16 17:01:00 -0800146 bool hidden(CJS_Runtime* pRuntime, CJS_PropValue& vp, CFX_WideString& sError);
147 bool highlight(CJS_Runtime* pRuntime,
Tom Sepezd6ae2af2017-02-16 11:49:55 -0800148 CJS_PropValue& vp,
149 CFX_WideString& sError);
Tom Sepezb1670b52017-02-16 17:01:00 -0800150 bool lineWidth(CJS_Runtime* pRuntime,
Tom Sepezd6ae2af2017-02-16 11:49:55 -0800151 CJS_PropValue& vp,
152 CFX_WideString& sError);
Tom Sepezb1670b52017-02-16 17:01:00 -0800153 bool multiline(CJS_Runtime* pRuntime,
Tom Sepezd6ae2af2017-02-16 11:49:55 -0800154 CJS_PropValue& vp,
155 CFX_WideString& sError);
Tom Sepezb1670b52017-02-16 17:01:00 -0800156 bool multipleSelection(CJS_Runtime* pRuntime,
tsepez4cf55152016-11-02 14:37:54 -0700157 CJS_PropValue& vp,
158 CFX_WideString& sError);
Tom Sepezb1670b52017-02-16 17:01:00 -0800159 bool name(CJS_Runtime* pRuntime, CJS_PropValue& vp, CFX_WideString& sError);
160 bool numItems(CJS_Runtime* pRuntime,
Tom Sepezd6ae2af2017-02-16 11:49:55 -0800161 CJS_PropValue& vp,
162 CFX_WideString& sError);
Tom Sepezb1670b52017-02-16 17:01:00 -0800163 bool page(CJS_Runtime* pRuntime, CJS_PropValue& vp, CFX_WideString& sError);
164 bool password(CJS_Runtime* pRuntime,
Tom Sepezd6ae2af2017-02-16 11:49:55 -0800165 CJS_PropValue& vp,
166 CFX_WideString& sError);
Tom Sepezb1670b52017-02-16 17:01:00 -0800167 bool print(CJS_Runtime* pRuntime, CJS_PropValue& vp, CFX_WideString& sError);
168 bool radiosInUnison(CJS_Runtime* pRuntime,
tsepez4cf55152016-11-02 14:37:54 -0700169 CJS_PropValue& vp,
170 CFX_WideString& sError);
Tom Sepezb1670b52017-02-16 17:01:00 -0800171 bool readonly(CJS_Runtime* pRuntime,
Tom Sepezd6ae2af2017-02-16 11:49:55 -0800172 CJS_PropValue& vp,
173 CFX_WideString& sError);
Tom Sepezb1670b52017-02-16 17:01:00 -0800174 bool rect(CJS_Runtime* pRuntime, CJS_PropValue& vp, CFX_WideString& sError);
175 bool required(CJS_Runtime* pRuntime,
Tom Sepezd6ae2af2017-02-16 11:49:55 -0800176 CJS_PropValue& vp,
177 CFX_WideString& sError);
Tom Sepezb1670b52017-02-16 17:01:00 -0800178 bool richText(CJS_Runtime* pRuntime,
Tom Sepezd6ae2af2017-02-16 11:49:55 -0800179 CJS_PropValue& vp,
180 CFX_WideString& sError);
Tom Sepezb1670b52017-02-16 17:01:00 -0800181 bool richValue(CJS_Runtime* pRuntime,
Tom Sepezd6ae2af2017-02-16 11:49:55 -0800182 CJS_PropValue& vp,
183 CFX_WideString& sError);
Tom Sepezb1670b52017-02-16 17:01:00 -0800184 bool rotation(CJS_Runtime* pRuntime,
Tom Sepezd6ae2af2017-02-16 11:49:55 -0800185 CJS_PropValue& vp,
186 CFX_WideString& sError);
Tom Sepezb1670b52017-02-16 17:01:00 -0800187 bool strokeColor(CJS_Runtime* pRuntime,
Tom Sepezd6ae2af2017-02-16 11:49:55 -0800188 CJS_PropValue& vp,
189 CFX_WideString& sError);
Tom Sepezb1670b52017-02-16 17:01:00 -0800190 bool style(CJS_Runtime* pRuntime, CJS_PropValue& vp, CFX_WideString& sError);
191 bool submitName(CJS_Runtime* pRuntime,
Tom Sepezd6ae2af2017-02-16 11:49:55 -0800192 CJS_PropValue& vp,
193 CFX_WideString& sError);
Tom Sepezb1670b52017-02-16 17:01:00 -0800194 bool textColor(CJS_Runtime* pRuntime,
Tom Sepezd6ae2af2017-02-16 11:49:55 -0800195 CJS_PropValue& vp,
196 CFX_WideString& sError);
Tom Sepezb1670b52017-02-16 17:01:00 -0800197 bool textFont(CJS_Runtime* pRuntime,
Tom Sepezd6ae2af2017-02-16 11:49:55 -0800198 CJS_PropValue& vp,
199 CFX_WideString& sError);
Tom Sepezb1670b52017-02-16 17:01:00 -0800200 bool textSize(CJS_Runtime* pRuntime,
Tom Sepezd6ae2af2017-02-16 11:49:55 -0800201 CJS_PropValue& vp,
202 CFX_WideString& sError);
Tom Sepezb1670b52017-02-16 17:01:00 -0800203 bool type(CJS_Runtime* pRuntime, CJS_PropValue& vp, CFX_WideString& sError);
204 bool userName(CJS_Runtime* pRuntime,
Tom Sepezd6ae2af2017-02-16 11:49:55 -0800205 CJS_PropValue& vp,
206 CFX_WideString& sError);
Tom Sepezb1670b52017-02-16 17:01:00 -0800207 bool value(CJS_Runtime* pRuntime, CJS_PropValue& vp, CFX_WideString& sError);
208 bool valueAsString(CJS_Runtime* pRuntime,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700209 CJS_PropValue& vp,
210 CFX_WideString& sError);
Tom Sepezb1670b52017-02-16 17:01:00 -0800211 bool source(CJS_Runtime* pRuntime, CJS_PropValue& vp, CFX_WideString& sError);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700212
Tom Sepezb1670b52017-02-16 17:01:00 -0800213 bool browseForFileToSubmit(CJS_Runtime* pRuntime,
tsepez4cf55152016-11-02 14:37:54 -0700214 const std::vector<CJS_Value>& params,
215 CJS_Value& vRet,
216 CFX_WideString& sError);
Tom Sepezb1670b52017-02-16 17:01:00 -0800217 bool buttonGetCaption(CJS_Runtime* pRuntime,
Lei Zhang945fdb72015-11-11 10:18:16 -0800218 const std::vector<CJS_Value>& params,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700219 CJS_Value& vRet,
220 CFX_WideString& sError);
Tom Sepezb1670b52017-02-16 17:01:00 -0800221 bool buttonGetIcon(CJS_Runtime* pRuntime,
Lei Zhang945fdb72015-11-11 10:18:16 -0800222 const std::vector<CJS_Value>& params,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700223 CJS_Value& vRet,
224 CFX_WideString& sError);
Tom Sepezb1670b52017-02-16 17:01:00 -0800225 bool buttonImportIcon(CJS_Runtime* pRuntime,
Lei Zhang945fdb72015-11-11 10:18:16 -0800226 const std::vector<CJS_Value>& params,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700227 CJS_Value& vRet,
228 CFX_WideString& sError);
Tom Sepezb1670b52017-02-16 17:01:00 -0800229 bool buttonSetCaption(CJS_Runtime* pRuntime,
Lei Zhang945fdb72015-11-11 10:18:16 -0800230 const std::vector<CJS_Value>& params,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700231 CJS_Value& vRet,
232 CFX_WideString& sError);
Tom Sepezb1670b52017-02-16 17:01:00 -0800233 bool buttonSetIcon(CJS_Runtime* pRuntime,
tsepez4cf55152016-11-02 14:37:54 -0700234 const std::vector<CJS_Value>& params,
235 CJS_Value& vRet,
236 CFX_WideString& sError);
Tom Sepezb1670b52017-02-16 17:01:00 -0800237 bool checkThisBox(CJS_Runtime* pRuntime,
tsepez4cf55152016-11-02 14:37:54 -0700238 const std::vector<CJS_Value>& params,
239 CJS_Value& vRet,
240 CFX_WideString& sError);
Tom Sepezb1670b52017-02-16 17:01:00 -0800241 bool clearItems(CJS_Runtime* pRuntime,
tsepez4cf55152016-11-02 14:37:54 -0700242 const std::vector<CJS_Value>& params,
243 CJS_Value& vRet,
244 CFX_WideString& sError);
Tom Sepezb1670b52017-02-16 17:01:00 -0800245 bool defaultIsChecked(CJS_Runtime* pRuntime,
tsepez4cf55152016-11-02 14:37:54 -0700246 const std::vector<CJS_Value>& params,
247 CJS_Value& vRet,
248 CFX_WideString& sError);
Tom Sepezb1670b52017-02-16 17:01:00 -0800249 bool deleteItemAt(CJS_Runtime* pRuntime,
tsepez4cf55152016-11-02 14:37:54 -0700250 const std::vector<CJS_Value>& params,
251 CJS_Value& vRet,
252 CFX_WideString& sError);
Tom Sepezb1670b52017-02-16 17:01:00 -0800253 bool getArray(CJS_Runtime* pRuntime,
tsepez4cf55152016-11-02 14:37:54 -0700254 const std::vector<CJS_Value>& params,
255 CJS_Value& vRet,
256 CFX_WideString& sError);
Tom Sepezb1670b52017-02-16 17:01:00 -0800257 bool getItemAt(CJS_Runtime* pRuntime,
tsepez4cf55152016-11-02 14:37:54 -0700258 const std::vector<CJS_Value>& params,
259 CJS_Value& vRet,
260 CFX_WideString& sError);
Tom Sepezb1670b52017-02-16 17:01:00 -0800261 bool getLock(CJS_Runtime* pRuntime,
tsepez4cf55152016-11-02 14:37:54 -0700262 const std::vector<CJS_Value>& params,
263 CJS_Value& vRet,
264 CFX_WideString& sError);
Tom Sepezb1670b52017-02-16 17:01:00 -0800265 bool insertItemAt(CJS_Runtime* pRuntime,
tsepez4cf55152016-11-02 14:37:54 -0700266 const std::vector<CJS_Value>& params,
267 CJS_Value& vRet,
268 CFX_WideString& sError);
Tom Sepezb1670b52017-02-16 17:01:00 -0800269 bool isBoxChecked(CJS_Runtime* pRuntime,
tsepez4cf55152016-11-02 14:37:54 -0700270 const std::vector<CJS_Value>& params,
271 CJS_Value& vRet,
272 CFX_WideString& sError);
Tom Sepezb1670b52017-02-16 17:01:00 -0800273 bool isDefaultChecked(CJS_Runtime* pRuntime,
tsepez4cf55152016-11-02 14:37:54 -0700274 const std::vector<CJS_Value>& params,
275 CJS_Value& vRet,
276 CFX_WideString& sError);
Tom Sepezb1670b52017-02-16 17:01:00 -0800277 bool setAction(CJS_Runtime* pRuntime,
tsepez4cf55152016-11-02 14:37:54 -0700278 const std::vector<CJS_Value>& params,
279 CJS_Value& vRet,
280 CFX_WideString& sError);
Tom Sepezb1670b52017-02-16 17:01:00 -0800281 bool setFocus(CJS_Runtime* pRuntime,
tsepez4cf55152016-11-02 14:37:54 -0700282 const std::vector<CJS_Value>& params,
283 CJS_Value& vRet,
284 CFX_WideString& sError);
Tom Sepezb1670b52017-02-16 17:01:00 -0800285 bool setItems(CJS_Runtime* pRuntime,
tsepez4cf55152016-11-02 14:37:54 -0700286 const std::vector<CJS_Value>& params,
287 CJS_Value& vRet,
288 CFX_WideString& sError);
Tom Sepezb1670b52017-02-16 17:01:00 -0800289 bool setLock(CJS_Runtime* pRuntime,
tsepez4cf55152016-11-02 14:37:54 -0700290 const std::vector<CJS_Value>& params,
291 CJS_Value& vRet,
292 CFX_WideString& sError);
Tom Sepezb1670b52017-02-16 17:01:00 -0800293 bool signatureGetModifications(CJS_Runtime* pRuntime,
tsepez4cf55152016-11-02 14:37:54 -0700294 const std::vector<CJS_Value>& params,
295 CJS_Value& vRet,
296 CFX_WideString& sError);
Tom Sepezb1670b52017-02-16 17:01:00 -0800297 bool signatureGetSeedValue(CJS_Runtime* pRuntime,
tsepez4cf55152016-11-02 14:37:54 -0700298 const std::vector<CJS_Value>& params,
299 CJS_Value& vRet,
300 CFX_WideString& sError);
Tom Sepezb1670b52017-02-16 17:01:00 -0800301 bool signatureInfo(CJS_Runtime* pRuntime,
tsepez4cf55152016-11-02 14:37:54 -0700302 const std::vector<CJS_Value>& params,
303 CJS_Value& vRet,
304 CFX_WideString& sError);
Tom Sepezb1670b52017-02-16 17:01:00 -0800305 bool signatureSetSeedValue(CJS_Runtime* pRuntime,
tsepez4cf55152016-11-02 14:37:54 -0700306 const std::vector<CJS_Value>& params,
307 CJS_Value& vRet,
308 CFX_WideString& sError);
Tom Sepezb1670b52017-02-16 17:01:00 -0800309 bool signatureSign(CJS_Runtime* pRuntime,
tsepez4cf55152016-11-02 14:37:54 -0700310 const std::vector<CJS_Value>& params,
311 CJS_Value& vRet,
312 CFX_WideString& sError);
Tom Sepezb1670b52017-02-16 17:01:00 -0800313 bool signatureValidate(CJS_Runtime* pRuntime,
tsepez4cf55152016-11-02 14:37:54 -0700314 const std::vector<CJS_Value>& params,
315 CJS_Value& vRet,
316 CFX_WideString& sError);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700317
dsinclair3a7741a2016-10-11 10:39:49 -0700318 static void SetAlignment(CPDFSDK_FormFillEnvironment* pFormFillEnv,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700319 const CFX_WideString& swFieldName,
320 int nControlIndex,
321 const CFX_ByteString& string);
dsinclair3a7741a2016-10-11 10:39:49 -0700322 static void SetBorderStyle(CPDFSDK_FormFillEnvironment* pFormFillEnv,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700323 const CFX_WideString& swFieldName,
324 int nControlIndex,
325 const CFX_ByteString& string);
dsinclair3a7741a2016-10-11 10:39:49 -0700326 static void SetButtonAlignX(CPDFSDK_FormFillEnvironment* pFormFillEnv,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700327 const CFX_WideString& swFieldName,
328 int nControlIndex,
329 int number);
dsinclair3a7741a2016-10-11 10:39:49 -0700330 static void SetButtonAlignY(CPDFSDK_FormFillEnvironment* pFormFillEnv,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700331 const CFX_WideString& swFieldName,
332 int nControlIndex,
333 int number);
dsinclair3a7741a2016-10-11 10:39:49 -0700334 static void SetButtonFitBounds(CPDFSDK_FormFillEnvironment* pFormFillEnv,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700335 const CFX_WideString& swFieldName,
336 int nControlIndex,
337 bool b);
dsinclair3a7741a2016-10-11 10:39:49 -0700338 static void SetButtonPosition(CPDFSDK_FormFillEnvironment* pFormFillEnv,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700339 const CFX_WideString& swFieldName,
340 int nControlIndex,
341 int number);
dsinclair3a7741a2016-10-11 10:39:49 -0700342 static void SetButtonScaleHow(CPDFSDK_FormFillEnvironment* pFormFillEnv,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700343 const CFX_WideString& swFieldName,
344 int nControlIndex,
345 int number);
dsinclair3a7741a2016-10-11 10:39:49 -0700346 static void SetButtonScaleWhen(CPDFSDK_FormFillEnvironment* pFormFillEnv,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700347 const CFX_WideString& swFieldName,
348 int nControlIndex,
349 int number);
dsinclair3a7741a2016-10-11 10:39:49 -0700350 static void SetCalcOrderIndex(CPDFSDK_FormFillEnvironment* pFormFillEnv,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700351 const CFX_WideString& swFieldName,
352 int nControlIndex,
353 int number);
dsinclair3a7741a2016-10-11 10:39:49 -0700354 static void SetCharLimit(CPDFSDK_FormFillEnvironment* pFormFillEnv,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700355 const CFX_WideString& swFieldName,
356 int nControlIndex,
357 int number);
dsinclair3a7741a2016-10-11 10:39:49 -0700358 static void SetComb(CPDFSDK_FormFillEnvironment* pFormFillEnv,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700359 const CFX_WideString& swFieldName,
360 int nControlIndex,
361 bool b);
dsinclair3a7741a2016-10-11 10:39:49 -0700362 static void SetCommitOnSelChange(CPDFSDK_FormFillEnvironment* pFormFillEnv,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700363 const CFX_WideString& swFieldName,
364 int nControlIndex,
365 bool b);
dsinclair3a7741a2016-10-11 10:39:49 -0700366 static void SetCurrentValueIndices(CPDFSDK_FormFillEnvironment* pFormFillEnv,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700367 const CFX_WideString& swFieldName,
368 int nControlIndex,
tsepez41a53ad2016-03-28 16:59:30 -0700369 const std::vector<uint32_t>& array);
dsinclair3a7741a2016-10-11 10:39:49 -0700370 static void SetDefaultStyle(CPDFSDK_FormFillEnvironment* pFormFillEnv,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700371 const CFX_WideString& swFieldName,
372 int nControlIndex);
dsinclair3a7741a2016-10-11 10:39:49 -0700373 static void SetDefaultValue(CPDFSDK_FormFillEnvironment* pFormFillEnv,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700374 const CFX_WideString& swFieldName,
375 int nControlIndex,
376 const CFX_WideString& string);
dsinclair3a7741a2016-10-11 10:39:49 -0700377 static void SetDoNotScroll(CPDFSDK_FormFillEnvironment* pFormFillEnv,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700378 const CFX_WideString& swFieldName,
379 int nControlIndex,
380 bool b);
dsinclair3a7741a2016-10-11 10:39:49 -0700381 static void SetDisplay(CPDFSDK_FormFillEnvironment* pFormFillEnv,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700382 const CFX_WideString& swFieldName,
383 int nControlIndex,
384 int number);
dsinclair3a7741a2016-10-11 10:39:49 -0700385 static void SetFillColor(CPDFSDK_FormFillEnvironment* pFormFillEnv,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700386 const CFX_WideString& swFieldName,
387 int nControlIndex,
Dan Sinclair7f55a542017-07-13 14:17:10 -0400388 const CFX_Color& color);
dsinclair3a7741a2016-10-11 10:39:49 -0700389 static void SetHidden(CPDFSDK_FormFillEnvironment* pFormFillEnv,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700390 const CFX_WideString& swFieldName,
391 int nControlIndex,
392 bool b);
dsinclair3a7741a2016-10-11 10:39:49 -0700393 static void SetHighlight(CPDFSDK_FormFillEnvironment* pFormFillEnv,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700394 const CFX_WideString& swFieldName,
395 int nControlIndex,
396 const CFX_ByteString& string);
dsinclair3a7741a2016-10-11 10:39:49 -0700397 static void SetLineWidth(CPDFSDK_FormFillEnvironment* pFormFillEnv,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700398 const CFX_WideString& swFieldName,
399 int nControlIndex,
400 int number);
dsinclair3a7741a2016-10-11 10:39:49 -0700401 static void SetMultiline(CPDFSDK_FormFillEnvironment* pFormFillEnv,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700402 const CFX_WideString& swFieldName,
403 int nControlIndex,
404 bool b);
dsinclair3a7741a2016-10-11 10:39:49 -0700405 static void SetMultipleSelection(CPDFSDK_FormFillEnvironment* pFormFillEnv,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700406 const CFX_WideString& swFieldName,
407 int nControlIndex,
408 bool b);
dsinclair3a7741a2016-10-11 10:39:49 -0700409 static void SetPassword(CPDFSDK_FormFillEnvironment* pFormFillEnv,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700410 const CFX_WideString& swFieldName,
411 int nControlIndex,
412 bool b);
dsinclair3a7741a2016-10-11 10:39:49 -0700413 static void SetRect(CPDFSDK_FormFillEnvironment* pFormFillEnv,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700414 const CFX_WideString& swFieldName,
415 int nControlIndex,
Tom Sepez281a9ea2016-02-26 14:24:28 -0800416 const CFX_FloatRect& rect);
dsinclair3a7741a2016-10-11 10:39:49 -0700417 static void SetRotation(CPDFSDK_FormFillEnvironment* pFormFillEnv,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700418 const CFX_WideString& swFieldName,
419 int nControlIndex,
420 int number);
dsinclair3a7741a2016-10-11 10:39:49 -0700421 static void SetStrokeColor(CPDFSDK_FormFillEnvironment* pFormFillEnv,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700422 const CFX_WideString& swFieldName,
423 int nControlIndex,
Dan Sinclair7f55a542017-07-13 14:17:10 -0400424 const CFX_Color& color);
dsinclair3a7741a2016-10-11 10:39:49 -0700425 static void SetStyle(CPDFSDK_FormFillEnvironment* pFormFillEnv,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700426 const CFX_WideString& swFieldName,
427 int nControlIndex,
428 const CFX_ByteString& string);
dsinclair3a7741a2016-10-11 10:39:49 -0700429 static void SetTextColor(CPDFSDK_FormFillEnvironment* pFormFillEnv,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700430 const CFX_WideString& swFieldName,
431 int nControlIndex,
Dan Sinclair7f55a542017-07-13 14:17:10 -0400432 const CFX_Color& color);
dsinclair3a7741a2016-10-11 10:39:49 -0700433 static void SetTextFont(CPDFSDK_FormFillEnvironment* pFormFillEnv,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700434 const CFX_WideString& swFieldName,
435 int nControlIndex,
436 const CFX_ByteString& string);
dsinclair3a7741a2016-10-11 10:39:49 -0700437 static void SetTextSize(CPDFSDK_FormFillEnvironment* pFormFillEnv,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700438 const CFX_WideString& swFieldName,
439 int nControlIndex,
440 int number);
dsinclair3a7741a2016-10-11 10:39:49 -0700441 static void SetUserName(CPDFSDK_FormFillEnvironment* pFormFillEnv,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700442 const CFX_WideString& swFieldName,
443 int nControlIndex,
444 const CFX_WideString& string);
dsinclair3a7741a2016-10-11 10:39:49 -0700445 static void SetValue(CPDFSDK_FormFillEnvironment* pFormFillEnv,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700446 const CFX_WideString& swFieldName,
447 int nControlIndex,
tsepez41a53ad2016-03-28 16:59:30 -0700448 const std::vector<CFX_WideString>& strArray);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700449
dsinclair3a7741a2016-10-11 10:39:49 -0700450 static void AddField(CPDFSDK_FormFillEnvironment* pFormFillEnv,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700451 int nPageIndex,
452 int nFieldType,
453 const CFX_WideString& sName,
Tom Sepez281a9ea2016-02-26 14:24:28 -0800454 const CFX_FloatRect& rcCoords);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700455
dsinclair3a7741a2016-10-11 10:39:49 -0700456 static void UpdateFormField(CPDFSDK_FormFillEnvironment* pFormFillEnv,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700457 CPDF_FormField* pFormField,
tsepez4cf55152016-11-02 14:37:54 -0700458 bool bChangeMark,
459 bool bResetAP,
460 bool bRefresh);
dsinclair3a7741a2016-10-11 10:39:49 -0700461 static void UpdateFormControl(CPDFSDK_FormFillEnvironment* pFormFillEnv,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700462 CPDF_FormControl* pFormControl,
tsepez4cf55152016-11-02 14:37:54 -0700463 bool bChangeMark,
464 bool bResetAP,
465 bool bRefresh);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700466
dsinclair3a7741a2016-10-11 10:39:49 -0700467 static CPDFSDK_Widget* GetWidget(CPDFSDK_FormFillEnvironment* pFormFillEnv,
dsinclairc5267c52016-11-04 15:35:12 -0700468 CPDF_FormControl* pFormControl);
Lei Zhangd88a3642015-11-10 09:38:57 -0800469 static std::vector<CPDF_FormField*> GetFormFields(
dsinclair3a7741a2016-10-11 10:39:49 -0700470 CPDFSDK_FormFillEnvironment* pFormFillEnv,
Lei Zhangd88a3642015-11-10 09:38:57 -0800471 const CFX_WideString& csFieldName);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700472
dsinclair3a7741a2016-10-11 10:39:49 -0700473 static void DoDelay(CPDFSDK_FormFillEnvironment* pFormFillEnv,
474 CJS_DelayData* pData);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700475
tsepez4cf55152016-11-02 14:37:54 -0700476 bool AttachField(Document* pDocument, const CFX_WideString& csFieldName);
477 void SetDelay(bool bDelay);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700478
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700479 protected:
480 void ParseFieldName(const std::wstring& strFieldNameParsed,
481 std::wstring& strFieldName,
482 int& iControlNo);
Lei Zhangd88a3642015-11-10 09:38:57 -0800483 std::vector<CPDF_FormField*> GetFormFields(
484 const CFX_WideString& csFieldName) const;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700485 CPDF_FormControl* GetSmartFieldControl(CPDF_FormField* pFormField);
tsepez4cf55152016-11-02 14:37:54 -0700486 bool ValueIsOccur(CPDF_FormField* pFormField, CFX_WideString csOptLabel);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700487
tsepez41a53ad2016-03-28 16:59:30 -0700488 void AddDelay_Int(FIELD_PROP prop, int32_t n);
489 void AddDelay_Bool(FIELD_PROP prop, bool b);
490 void AddDelay_String(FIELD_PROP prop, const CFX_ByteString& string);
491 void AddDelay_WideString(FIELD_PROP prop, const CFX_WideString& string);
492 void AddDelay_Rect(FIELD_PROP prop, const CFX_FloatRect& rect);
Dan Sinclair7f55a542017-07-13 14:17:10 -0400493 void AddDelay_Color(FIELD_PROP prop, const CFX_Color& color);
tsepez41a53ad2016-03-28 16:59:30 -0700494 void AddDelay_WordArray(FIELD_PROP prop, const std::vector<uint32_t>& array);
495 void AddDelay_WideStringArray(FIELD_PROP prop,
496 const std::vector<CFX_WideString>& array);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700497
498 void DoDelay();
499
500 public:
501 Document* m_pJSDoc;
dsinclair3a7741a2016-10-11 10:39:49 -0700502 CPDFSDK_FormFillEnvironment::ObservedPtr m_pFormFillEnv;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700503 CFX_WideString m_FieldName;
504 int m_nFormControlIndex;
tsepez4cf55152016-11-02 14:37:54 -0700505 bool m_bCanSet;
506 bool m_bDelay;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700507};
508
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700509class CJS_Field : public CJS_Object {
510 public:
Lei Zhangd88a3642015-11-10 09:38:57 -0800511 explicit CJS_Field(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {}
weilibff506d2016-06-20 11:37:05 -0700512 ~CJS_Field() override {}
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700513
Tom Sepez33420902015-10-13 15:00:10 -0700514 void InitInstance(IJS_Runtime* pIRuntime) override;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700515
Tom Sepezcd56a7d2015-10-06 11:45:28 -0700516 DECLARE_JS_CLASS();
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700517 JS_STATIC_PROP(alignment, Field);
518 JS_STATIC_PROP(borderStyle, Field);
519 JS_STATIC_PROP(buttonAlignX, Field);
520 JS_STATIC_PROP(buttonAlignY, Field);
521 JS_STATIC_PROP(buttonFitBounds, Field);
522 JS_STATIC_PROP(buttonPosition, Field);
523 JS_STATIC_PROP(buttonScaleHow, Field);
524 JS_STATIC_PROP(buttonScaleWhen, Field);
525 JS_STATIC_PROP(calcOrderIndex, Field);
526 JS_STATIC_PROP(charLimit, Field);
527 JS_STATIC_PROP(comb, Field);
528 JS_STATIC_PROP(commitOnSelChange, Field);
529 JS_STATIC_PROP(currentValueIndices, Field);
530 JS_STATIC_PROP(defaultStyle, Field);
531 JS_STATIC_PROP(defaultValue, Field);
532 JS_STATIC_PROP(doNotScroll, Field);
533 JS_STATIC_PROP(doNotSpellCheck, Field);
534 JS_STATIC_PROP(delay, Field);
535 JS_STATIC_PROP(display, Field);
536 JS_STATIC_PROP(doc, Field);
537 JS_STATIC_PROP(editable, Field);
538 JS_STATIC_PROP(exportValues, Field);
539 JS_STATIC_PROP(fileSelect, Field);
540 JS_STATIC_PROP(fillColor, Field);
541 JS_STATIC_PROP(hidden, Field);
542 JS_STATIC_PROP(highlight, Field);
543 JS_STATIC_PROP(lineWidth, Field);
544 JS_STATIC_PROP(multiline, Field);
545 JS_STATIC_PROP(multipleSelection, Field);
546 JS_STATIC_PROP(name, Field);
547 JS_STATIC_PROP(numItems, Field);
548 JS_STATIC_PROP(page, Field);
549 JS_STATIC_PROP(password, Field);
550 JS_STATIC_PROP(print, Field);
551 JS_STATIC_PROP(radiosInUnison, Field);
552 JS_STATIC_PROP(readonly, Field);
553 JS_STATIC_PROP(rect, Field);
554 JS_STATIC_PROP(required, Field);
555 JS_STATIC_PROP(richText, Field);
556 JS_STATIC_PROP(richValue, Field);
557 JS_STATIC_PROP(rotation, Field);
558 JS_STATIC_PROP(strokeColor, Field);
559 JS_STATIC_PROP(style, Field);
560 JS_STATIC_PROP(submitName, Field);
561 JS_STATIC_PROP(textColor, Field);
562 JS_STATIC_PROP(textFont, Field);
563 JS_STATIC_PROP(textSize, Field);
564 JS_STATIC_PROP(type, Field);
565 JS_STATIC_PROP(userName, Field);
566 JS_STATIC_PROP(value, Field);
567 JS_STATIC_PROP(valueAsString, Field);
568 JS_STATIC_PROP(source, Field);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700569
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700570 JS_STATIC_METHOD(browseForFileToSubmit, Field);
571 JS_STATIC_METHOD(buttonGetCaption, Field);
572 JS_STATIC_METHOD(buttonGetIcon, Field);
573 JS_STATIC_METHOD(buttonImportIcon, Field);
574 JS_STATIC_METHOD(buttonSetCaption, Field);
575 JS_STATIC_METHOD(buttonSetIcon, Field);
576 JS_STATIC_METHOD(checkThisBox, Field);
577 JS_STATIC_METHOD(clearItems, Field);
578 JS_STATIC_METHOD(defaultIsChecked, Field);
579 JS_STATIC_METHOD(deleteItemAt, Field);
580 JS_STATIC_METHOD(getArray, Field);
581 JS_STATIC_METHOD(getItemAt, Field);
582 JS_STATIC_METHOD(getLock, Field);
583 JS_STATIC_METHOD(insertItemAt, Field);
584 JS_STATIC_METHOD(isBoxChecked, Field);
585 JS_STATIC_METHOD(isDefaultChecked, Field);
586 JS_STATIC_METHOD(setAction, Field);
587 JS_STATIC_METHOD(setFocus, Field);
588 JS_STATIC_METHOD(setItems, Field);
589 JS_STATIC_METHOD(setLock, Field);
590 JS_STATIC_METHOD(signatureGetModifications, Field);
591 JS_STATIC_METHOD(signatureGetSeedValue, Field);
592 JS_STATIC_METHOD(signatureInfo, Field);
593 JS_STATIC_METHOD(signatureSetSeedValue, Field);
594 JS_STATIC_METHOD(signatureSign, Field);
595 JS_STATIC_METHOD(signatureValidate, Field);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700596};
597
Dan Sinclairf766ad22016-03-14 13:51:24 -0400598#endif // FPDFSDK_JAVASCRIPT_FIELD_H_