blob: 9087f8270301fa0dd7bd87239bdc5f0f57eb6d02 [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"
dsinclair3a7741a2016-10-11 10:39:49 -070014#include "fpdfsdk/cpdfsdk_formfillenvironment.h"
Dan Sinclairf766ad22016-03-14 13:51:24 -040015#include "fpdfsdk/javascript/JS_Define.h"
dan sinclair89e904b2016-03-23 19:29:15 -040016#include "fpdfsdk/pdfwindow/PWL_Wnd.h" // For CPWL_Color.
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;
Nico Weber9d8ec5a2015-08-04 13:00:21 -070070 CPWL_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 Sepezd6ae2af2017-02-16 11:49:55 -080080 bool alignment(IJS_EventContext* cc,
81 CJS_PropValue& vp,
82 CFX_WideString& sError);
83 bool borderStyle(IJS_EventContext* cc,
84 CJS_PropValue& vp,
85 CFX_WideString& sError);
86 bool buttonAlignX(IJS_EventContext* cc,
87 CJS_PropValue& vp,
88 CFX_WideString& sError);
89 bool buttonAlignY(IJS_EventContext* cc,
90 CJS_PropValue& vp,
91 CFX_WideString& sError);
92 bool buttonFitBounds(IJS_EventContext* cc,
tsepez4cf55152016-11-02 14:37:54 -070093 CJS_PropValue& vp,
94 CFX_WideString& sError);
Tom Sepezd6ae2af2017-02-16 11:49:55 -080095 bool buttonPosition(IJS_EventContext* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -070096 CJS_PropValue& vp,
97 CFX_WideString& sError);
Tom Sepezd6ae2af2017-02-16 11:49:55 -080098 bool buttonScaleHow(IJS_EventContext* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -070099 CJS_PropValue& vp,
100 CFX_WideString& sError);
Tom Sepezd6ae2af2017-02-16 11:49:55 -0800101 bool buttonScaleWhen(IJS_EventContext* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700102 CJS_PropValue& vp,
103 CFX_WideString& sError);
Tom Sepezd6ae2af2017-02-16 11:49:55 -0800104 bool calcOrderIndex(IJS_EventContext* cc,
tsepez4cf55152016-11-02 14:37:54 -0700105 CJS_PropValue& vp,
106 CFX_WideString& sError);
Tom Sepezd6ae2af2017-02-16 11:49:55 -0800107 bool charLimit(IJS_EventContext* cc,
108 CJS_PropValue& vp,
109 CFX_WideString& sError);
110 bool comb(IJS_EventContext* cc, CJS_PropValue& vp, CFX_WideString& sError);
111 bool commitOnSelChange(IJS_EventContext* cc,
tsepez4cf55152016-11-02 14:37:54 -0700112 CJS_PropValue& vp,
113 CFX_WideString& sError);
Tom Sepezd6ae2af2017-02-16 11:49:55 -0800114 bool currentValueIndices(IJS_EventContext* cc,
tsepez4cf55152016-11-02 14:37:54 -0700115 CJS_PropValue& vp,
116 CFX_WideString& sError);
Tom Sepezd6ae2af2017-02-16 11:49:55 -0800117 bool defaultStyle(IJS_EventContext* cc,
118 CJS_PropValue& vp,
119 CFX_WideString& sError);
120 bool defaultValue(IJS_EventContext* cc,
121 CJS_PropValue& vp,
122 CFX_WideString& sError);
123 bool doNotScroll(IJS_EventContext* cc,
124 CJS_PropValue& vp,
125 CFX_WideString& sError);
126 bool doNotSpellCheck(IJS_EventContext* cc,
tsepez4cf55152016-11-02 14:37:54 -0700127 CJS_PropValue& vp,
128 CFX_WideString& sError);
Tom Sepezd6ae2af2017-02-16 11:49:55 -0800129 bool delay(IJS_EventContext* cc, CJS_PropValue& vp, CFX_WideString& sError);
130 bool display(IJS_EventContext* cc, CJS_PropValue& vp, CFX_WideString& sError);
131 bool doc(IJS_EventContext* cc, CJS_PropValue& vp, CFX_WideString& sError);
132 bool editable(IJS_EventContext* cc,
133 CJS_PropValue& vp,
134 CFX_WideString& sError);
135 bool exportValues(IJS_EventContext* cc,
136 CJS_PropValue& vp,
137 CFX_WideString& sError);
138 bool fileSelect(IJS_EventContext* cc,
139 CJS_PropValue& vp,
140 CFX_WideString& sError);
141 bool fillColor(IJS_EventContext* cc,
142 CJS_PropValue& vp,
143 CFX_WideString& sError);
144 bool hidden(IJS_EventContext* cc, CJS_PropValue& vp, CFX_WideString& sError);
145 bool highlight(IJS_EventContext* cc,
146 CJS_PropValue& vp,
147 CFX_WideString& sError);
148 bool lineWidth(IJS_EventContext* cc,
149 CJS_PropValue& vp,
150 CFX_WideString& sError);
151 bool multiline(IJS_EventContext* cc,
152 CJS_PropValue& vp,
153 CFX_WideString& sError);
154 bool multipleSelection(IJS_EventContext* cc,
tsepez4cf55152016-11-02 14:37:54 -0700155 CJS_PropValue& vp,
156 CFX_WideString& sError);
Tom Sepezd6ae2af2017-02-16 11:49:55 -0800157 bool name(IJS_EventContext* cc, CJS_PropValue& vp, CFX_WideString& sError);
158 bool numItems(IJS_EventContext* cc,
159 CJS_PropValue& vp,
160 CFX_WideString& sError);
161 bool page(IJS_EventContext* cc, CJS_PropValue& vp, CFX_WideString& sError);
162 bool password(IJS_EventContext* cc,
163 CJS_PropValue& vp,
164 CFX_WideString& sError);
165 bool print(IJS_EventContext* cc, CJS_PropValue& vp, CFX_WideString& sError);
166 bool radiosInUnison(IJS_EventContext* cc,
tsepez4cf55152016-11-02 14:37:54 -0700167 CJS_PropValue& vp,
168 CFX_WideString& sError);
Tom Sepezd6ae2af2017-02-16 11:49:55 -0800169 bool readonly(IJS_EventContext* cc,
170 CJS_PropValue& vp,
171 CFX_WideString& sError);
172 bool rect(IJS_EventContext* cc, CJS_PropValue& vp, CFX_WideString& sError);
173 bool required(IJS_EventContext* cc,
174 CJS_PropValue& vp,
175 CFX_WideString& sError);
176 bool richText(IJS_EventContext* cc,
177 CJS_PropValue& vp,
178 CFX_WideString& sError);
179 bool richValue(IJS_EventContext* cc,
180 CJS_PropValue& vp,
181 CFX_WideString& sError);
182 bool rotation(IJS_EventContext* cc,
183 CJS_PropValue& vp,
184 CFX_WideString& sError);
185 bool strokeColor(IJS_EventContext* cc,
186 CJS_PropValue& vp,
187 CFX_WideString& sError);
188 bool style(IJS_EventContext* cc, CJS_PropValue& vp, CFX_WideString& sError);
189 bool submitName(IJS_EventContext* cc,
190 CJS_PropValue& vp,
191 CFX_WideString& sError);
192 bool textColor(IJS_EventContext* cc,
193 CJS_PropValue& vp,
194 CFX_WideString& sError);
195 bool textFont(IJS_EventContext* cc,
196 CJS_PropValue& vp,
197 CFX_WideString& sError);
198 bool textSize(IJS_EventContext* cc,
199 CJS_PropValue& vp,
200 CFX_WideString& sError);
201 bool type(IJS_EventContext* cc, CJS_PropValue& vp, CFX_WideString& sError);
202 bool userName(IJS_EventContext* cc,
203 CJS_PropValue& vp,
204 CFX_WideString& sError);
205 bool value(IJS_EventContext* cc, CJS_PropValue& vp, CFX_WideString& sError);
206 bool valueAsString(IJS_EventContext* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700207 CJS_PropValue& vp,
208 CFX_WideString& sError);
Tom Sepezd6ae2af2017-02-16 11:49:55 -0800209 bool source(IJS_EventContext* cc, CJS_PropValue& vp, CFX_WideString& sError);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700210
Tom Sepezd6ae2af2017-02-16 11:49:55 -0800211 bool browseForFileToSubmit(IJS_EventContext* cc,
tsepez4cf55152016-11-02 14:37:54 -0700212 const std::vector<CJS_Value>& params,
213 CJS_Value& vRet,
214 CFX_WideString& sError);
Tom Sepezd6ae2af2017-02-16 11:49:55 -0800215 bool buttonGetCaption(IJS_EventContext* cc,
Lei Zhang945fdb72015-11-11 10:18:16 -0800216 const std::vector<CJS_Value>& params,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700217 CJS_Value& vRet,
218 CFX_WideString& sError);
Tom Sepezd6ae2af2017-02-16 11:49:55 -0800219 bool buttonGetIcon(IJS_EventContext* cc,
Lei Zhang945fdb72015-11-11 10:18:16 -0800220 const std::vector<CJS_Value>& params,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700221 CJS_Value& vRet,
222 CFX_WideString& sError);
Tom Sepezd6ae2af2017-02-16 11:49:55 -0800223 bool buttonImportIcon(IJS_EventContext* cc,
Lei Zhang945fdb72015-11-11 10:18:16 -0800224 const std::vector<CJS_Value>& params,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700225 CJS_Value& vRet,
226 CFX_WideString& sError);
Tom Sepezd6ae2af2017-02-16 11:49:55 -0800227 bool buttonSetCaption(IJS_EventContext* cc,
Lei Zhang945fdb72015-11-11 10:18:16 -0800228 const std::vector<CJS_Value>& params,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700229 CJS_Value& vRet,
230 CFX_WideString& sError);
Tom Sepezd6ae2af2017-02-16 11:49:55 -0800231 bool buttonSetIcon(IJS_EventContext* cc,
tsepez4cf55152016-11-02 14:37:54 -0700232 const std::vector<CJS_Value>& params,
233 CJS_Value& vRet,
234 CFX_WideString& sError);
Tom Sepezd6ae2af2017-02-16 11:49:55 -0800235 bool checkThisBox(IJS_EventContext* cc,
tsepez4cf55152016-11-02 14:37:54 -0700236 const std::vector<CJS_Value>& params,
237 CJS_Value& vRet,
238 CFX_WideString& sError);
Tom Sepezd6ae2af2017-02-16 11:49:55 -0800239 bool clearItems(IJS_EventContext* cc,
tsepez4cf55152016-11-02 14:37:54 -0700240 const std::vector<CJS_Value>& params,
241 CJS_Value& vRet,
242 CFX_WideString& sError);
Tom Sepezd6ae2af2017-02-16 11:49:55 -0800243 bool defaultIsChecked(IJS_EventContext* cc,
tsepez4cf55152016-11-02 14:37:54 -0700244 const std::vector<CJS_Value>& params,
245 CJS_Value& vRet,
246 CFX_WideString& sError);
Tom Sepezd6ae2af2017-02-16 11:49:55 -0800247 bool deleteItemAt(IJS_EventContext* cc,
tsepez4cf55152016-11-02 14:37:54 -0700248 const std::vector<CJS_Value>& params,
249 CJS_Value& vRet,
250 CFX_WideString& sError);
Tom Sepezd6ae2af2017-02-16 11:49:55 -0800251 bool getArray(IJS_EventContext* cc,
tsepez4cf55152016-11-02 14:37:54 -0700252 const std::vector<CJS_Value>& params,
253 CJS_Value& vRet,
254 CFX_WideString& sError);
Tom Sepezd6ae2af2017-02-16 11:49:55 -0800255 bool getItemAt(IJS_EventContext* cc,
tsepez4cf55152016-11-02 14:37:54 -0700256 const std::vector<CJS_Value>& params,
257 CJS_Value& vRet,
258 CFX_WideString& sError);
Tom Sepezd6ae2af2017-02-16 11:49:55 -0800259 bool getLock(IJS_EventContext* cc,
tsepez4cf55152016-11-02 14:37:54 -0700260 const std::vector<CJS_Value>& params,
261 CJS_Value& vRet,
262 CFX_WideString& sError);
Tom Sepezd6ae2af2017-02-16 11:49:55 -0800263 bool insertItemAt(IJS_EventContext* cc,
tsepez4cf55152016-11-02 14:37:54 -0700264 const std::vector<CJS_Value>& params,
265 CJS_Value& vRet,
266 CFX_WideString& sError);
Tom Sepezd6ae2af2017-02-16 11:49:55 -0800267 bool isBoxChecked(IJS_EventContext* cc,
tsepez4cf55152016-11-02 14:37:54 -0700268 const std::vector<CJS_Value>& params,
269 CJS_Value& vRet,
270 CFX_WideString& sError);
Tom Sepezd6ae2af2017-02-16 11:49:55 -0800271 bool isDefaultChecked(IJS_EventContext* cc,
tsepez4cf55152016-11-02 14:37:54 -0700272 const std::vector<CJS_Value>& params,
273 CJS_Value& vRet,
274 CFX_WideString& sError);
Tom Sepezd6ae2af2017-02-16 11:49:55 -0800275 bool setAction(IJS_EventContext* cc,
tsepez4cf55152016-11-02 14:37:54 -0700276 const std::vector<CJS_Value>& params,
277 CJS_Value& vRet,
278 CFX_WideString& sError);
Tom Sepezd6ae2af2017-02-16 11:49:55 -0800279 bool setFocus(IJS_EventContext* cc,
tsepez4cf55152016-11-02 14:37:54 -0700280 const std::vector<CJS_Value>& params,
281 CJS_Value& vRet,
282 CFX_WideString& sError);
Tom Sepezd6ae2af2017-02-16 11:49:55 -0800283 bool setItems(IJS_EventContext* cc,
tsepez4cf55152016-11-02 14:37:54 -0700284 const std::vector<CJS_Value>& params,
285 CJS_Value& vRet,
286 CFX_WideString& sError);
Tom Sepezd6ae2af2017-02-16 11:49:55 -0800287 bool setLock(IJS_EventContext* cc,
tsepez4cf55152016-11-02 14:37:54 -0700288 const std::vector<CJS_Value>& params,
289 CJS_Value& vRet,
290 CFX_WideString& sError);
Tom Sepezd6ae2af2017-02-16 11:49:55 -0800291 bool signatureGetModifications(IJS_EventContext* cc,
tsepez4cf55152016-11-02 14:37:54 -0700292 const std::vector<CJS_Value>& params,
293 CJS_Value& vRet,
294 CFX_WideString& sError);
Tom Sepezd6ae2af2017-02-16 11:49:55 -0800295 bool signatureGetSeedValue(IJS_EventContext* cc,
tsepez4cf55152016-11-02 14:37:54 -0700296 const std::vector<CJS_Value>& params,
297 CJS_Value& vRet,
298 CFX_WideString& sError);
Tom Sepezd6ae2af2017-02-16 11:49:55 -0800299 bool signatureInfo(IJS_EventContext* cc,
tsepez4cf55152016-11-02 14:37:54 -0700300 const std::vector<CJS_Value>& params,
301 CJS_Value& vRet,
302 CFX_WideString& sError);
Tom Sepezd6ae2af2017-02-16 11:49:55 -0800303 bool signatureSetSeedValue(IJS_EventContext* cc,
tsepez4cf55152016-11-02 14:37:54 -0700304 const std::vector<CJS_Value>& params,
305 CJS_Value& vRet,
306 CFX_WideString& sError);
Tom Sepezd6ae2af2017-02-16 11:49:55 -0800307 bool signatureSign(IJS_EventContext* cc,
tsepez4cf55152016-11-02 14:37:54 -0700308 const std::vector<CJS_Value>& params,
309 CJS_Value& vRet,
310 CFX_WideString& sError);
Tom Sepezd6ae2af2017-02-16 11:49:55 -0800311 bool signatureValidate(IJS_EventContext* cc,
tsepez4cf55152016-11-02 14:37:54 -0700312 const std::vector<CJS_Value>& params,
313 CJS_Value& vRet,
314 CFX_WideString& sError);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700315
dsinclair3a7741a2016-10-11 10:39:49 -0700316 static void SetAlignment(CPDFSDK_FormFillEnvironment* pFormFillEnv,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700317 const CFX_WideString& swFieldName,
318 int nControlIndex,
319 const CFX_ByteString& string);
dsinclair3a7741a2016-10-11 10:39:49 -0700320 static void SetBorderStyle(CPDFSDK_FormFillEnvironment* pFormFillEnv,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700321 const CFX_WideString& swFieldName,
322 int nControlIndex,
323 const CFX_ByteString& string);
dsinclair3a7741a2016-10-11 10:39:49 -0700324 static void SetButtonAlignX(CPDFSDK_FormFillEnvironment* pFormFillEnv,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700325 const CFX_WideString& swFieldName,
326 int nControlIndex,
327 int number);
dsinclair3a7741a2016-10-11 10:39:49 -0700328 static void SetButtonAlignY(CPDFSDK_FormFillEnvironment* pFormFillEnv,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700329 const CFX_WideString& swFieldName,
330 int nControlIndex,
331 int number);
dsinclair3a7741a2016-10-11 10:39:49 -0700332 static void SetButtonFitBounds(CPDFSDK_FormFillEnvironment* pFormFillEnv,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700333 const CFX_WideString& swFieldName,
334 int nControlIndex,
335 bool b);
dsinclair3a7741a2016-10-11 10:39:49 -0700336 static void SetButtonPosition(CPDFSDK_FormFillEnvironment* pFormFillEnv,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700337 const CFX_WideString& swFieldName,
338 int nControlIndex,
339 int number);
dsinclair3a7741a2016-10-11 10:39:49 -0700340 static void SetButtonScaleHow(CPDFSDK_FormFillEnvironment* pFormFillEnv,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700341 const CFX_WideString& swFieldName,
342 int nControlIndex,
343 int number);
dsinclair3a7741a2016-10-11 10:39:49 -0700344 static void SetButtonScaleWhen(CPDFSDK_FormFillEnvironment* pFormFillEnv,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700345 const CFX_WideString& swFieldName,
346 int nControlIndex,
347 int number);
dsinclair3a7741a2016-10-11 10:39:49 -0700348 static void SetCalcOrderIndex(CPDFSDK_FormFillEnvironment* pFormFillEnv,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700349 const CFX_WideString& swFieldName,
350 int nControlIndex,
351 int number);
dsinclair3a7741a2016-10-11 10:39:49 -0700352 static void SetCharLimit(CPDFSDK_FormFillEnvironment* pFormFillEnv,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700353 const CFX_WideString& swFieldName,
354 int nControlIndex,
355 int number);
dsinclair3a7741a2016-10-11 10:39:49 -0700356 static void SetComb(CPDFSDK_FormFillEnvironment* pFormFillEnv,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700357 const CFX_WideString& swFieldName,
358 int nControlIndex,
359 bool b);
dsinclair3a7741a2016-10-11 10:39:49 -0700360 static void SetCommitOnSelChange(CPDFSDK_FormFillEnvironment* pFormFillEnv,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700361 const CFX_WideString& swFieldName,
362 int nControlIndex,
363 bool b);
dsinclair3a7741a2016-10-11 10:39:49 -0700364 static void SetCurrentValueIndices(CPDFSDK_FormFillEnvironment* pFormFillEnv,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700365 const CFX_WideString& swFieldName,
366 int nControlIndex,
tsepez41a53ad2016-03-28 16:59:30 -0700367 const std::vector<uint32_t>& array);
dsinclair3a7741a2016-10-11 10:39:49 -0700368 static void SetDefaultStyle(CPDFSDK_FormFillEnvironment* pFormFillEnv,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700369 const CFX_WideString& swFieldName,
370 int nControlIndex);
dsinclair3a7741a2016-10-11 10:39:49 -0700371 static void SetDefaultValue(CPDFSDK_FormFillEnvironment* pFormFillEnv,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700372 const CFX_WideString& swFieldName,
373 int nControlIndex,
374 const CFX_WideString& string);
dsinclair3a7741a2016-10-11 10:39:49 -0700375 static void SetDoNotScroll(CPDFSDK_FormFillEnvironment* pFormFillEnv,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700376 const CFX_WideString& swFieldName,
377 int nControlIndex,
378 bool b);
dsinclair3a7741a2016-10-11 10:39:49 -0700379 static void SetDisplay(CPDFSDK_FormFillEnvironment* pFormFillEnv,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700380 const CFX_WideString& swFieldName,
381 int nControlIndex,
382 int number);
dsinclair3a7741a2016-10-11 10:39:49 -0700383 static void SetFillColor(CPDFSDK_FormFillEnvironment* pFormFillEnv,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700384 const CFX_WideString& swFieldName,
385 int nControlIndex,
386 const CPWL_Color& color);
dsinclair3a7741a2016-10-11 10:39:49 -0700387 static void SetHidden(CPDFSDK_FormFillEnvironment* pFormFillEnv,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700388 const CFX_WideString& swFieldName,
389 int nControlIndex,
390 bool b);
dsinclair3a7741a2016-10-11 10:39:49 -0700391 static void SetHighlight(CPDFSDK_FormFillEnvironment* pFormFillEnv,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700392 const CFX_WideString& swFieldName,
393 int nControlIndex,
394 const CFX_ByteString& string);
dsinclair3a7741a2016-10-11 10:39:49 -0700395 static void SetLineWidth(CPDFSDK_FormFillEnvironment* pFormFillEnv,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700396 const CFX_WideString& swFieldName,
397 int nControlIndex,
398 int number);
dsinclair3a7741a2016-10-11 10:39:49 -0700399 static void SetMultiline(CPDFSDK_FormFillEnvironment* pFormFillEnv,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700400 const CFX_WideString& swFieldName,
401 int nControlIndex,
402 bool b);
dsinclair3a7741a2016-10-11 10:39:49 -0700403 static void SetMultipleSelection(CPDFSDK_FormFillEnvironment* pFormFillEnv,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700404 const CFX_WideString& swFieldName,
405 int nControlIndex,
406 bool b);
dsinclair3a7741a2016-10-11 10:39:49 -0700407 static void SetPassword(CPDFSDK_FormFillEnvironment* pFormFillEnv,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700408 const CFX_WideString& swFieldName,
409 int nControlIndex,
410 bool b);
dsinclair3a7741a2016-10-11 10:39:49 -0700411 static void SetRect(CPDFSDK_FormFillEnvironment* pFormFillEnv,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700412 const CFX_WideString& swFieldName,
413 int nControlIndex,
Tom Sepez281a9ea2016-02-26 14:24:28 -0800414 const CFX_FloatRect& rect);
dsinclair3a7741a2016-10-11 10:39:49 -0700415 static void SetRotation(CPDFSDK_FormFillEnvironment* pFormFillEnv,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700416 const CFX_WideString& swFieldName,
417 int nControlIndex,
418 int number);
dsinclair3a7741a2016-10-11 10:39:49 -0700419 static void SetStrokeColor(CPDFSDK_FormFillEnvironment* pFormFillEnv,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700420 const CFX_WideString& swFieldName,
421 int nControlIndex,
422 const CPWL_Color& color);
dsinclair3a7741a2016-10-11 10:39:49 -0700423 static void SetStyle(CPDFSDK_FormFillEnvironment* pFormFillEnv,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700424 const CFX_WideString& swFieldName,
425 int nControlIndex,
426 const CFX_ByteString& string);
dsinclair3a7741a2016-10-11 10:39:49 -0700427 static void SetTextColor(CPDFSDK_FormFillEnvironment* pFormFillEnv,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700428 const CFX_WideString& swFieldName,
429 int nControlIndex,
430 const CPWL_Color& color);
dsinclair3a7741a2016-10-11 10:39:49 -0700431 static void SetTextFont(CPDFSDK_FormFillEnvironment* pFormFillEnv,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700432 const CFX_WideString& swFieldName,
433 int nControlIndex,
434 const CFX_ByteString& string);
dsinclair3a7741a2016-10-11 10:39:49 -0700435 static void SetTextSize(CPDFSDK_FormFillEnvironment* pFormFillEnv,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700436 const CFX_WideString& swFieldName,
437 int nControlIndex,
438 int number);
dsinclair3a7741a2016-10-11 10:39:49 -0700439 static void SetUserName(CPDFSDK_FormFillEnvironment* pFormFillEnv,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700440 const CFX_WideString& swFieldName,
441 int nControlIndex,
442 const CFX_WideString& string);
dsinclair3a7741a2016-10-11 10:39:49 -0700443 static void SetValue(CPDFSDK_FormFillEnvironment* pFormFillEnv,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700444 const CFX_WideString& swFieldName,
445 int nControlIndex,
tsepez41a53ad2016-03-28 16:59:30 -0700446 const std::vector<CFX_WideString>& strArray);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700447
dsinclair3a7741a2016-10-11 10:39:49 -0700448 static void AddField(CPDFSDK_FormFillEnvironment* pFormFillEnv,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700449 int nPageIndex,
450 int nFieldType,
451 const CFX_WideString& sName,
Tom Sepez281a9ea2016-02-26 14:24:28 -0800452 const CFX_FloatRect& rcCoords);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700453
dsinclair3a7741a2016-10-11 10:39:49 -0700454 static void UpdateFormField(CPDFSDK_FormFillEnvironment* pFormFillEnv,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700455 CPDF_FormField* pFormField,
tsepez4cf55152016-11-02 14:37:54 -0700456 bool bChangeMark,
457 bool bResetAP,
458 bool bRefresh);
dsinclair3a7741a2016-10-11 10:39:49 -0700459 static void UpdateFormControl(CPDFSDK_FormFillEnvironment* pFormFillEnv,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700460 CPDF_FormControl* pFormControl,
tsepez4cf55152016-11-02 14:37:54 -0700461 bool bChangeMark,
462 bool bResetAP,
463 bool bRefresh);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700464
dsinclair3a7741a2016-10-11 10:39:49 -0700465 static CPDFSDK_Widget* GetWidget(CPDFSDK_FormFillEnvironment* pFormFillEnv,
dsinclairc5267c52016-11-04 15:35:12 -0700466 CPDF_FormControl* pFormControl);
Lei Zhangd88a3642015-11-10 09:38:57 -0800467 static std::vector<CPDF_FormField*> GetFormFields(
dsinclair3a7741a2016-10-11 10:39:49 -0700468 CPDFSDK_FormFillEnvironment* pFormFillEnv,
Lei Zhangd88a3642015-11-10 09:38:57 -0800469 const CFX_WideString& csFieldName);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700470
dsinclair3a7741a2016-10-11 10:39:49 -0700471 static void DoDelay(CPDFSDK_FormFillEnvironment* pFormFillEnv,
472 CJS_DelayData* pData);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700473
tsepez4cf55152016-11-02 14:37:54 -0700474 bool AttachField(Document* pDocument, const CFX_WideString& csFieldName);
475 void SetDelay(bool bDelay);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700476
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700477 protected:
478 void ParseFieldName(const std::wstring& strFieldNameParsed,
479 std::wstring& strFieldName,
480 int& iControlNo);
Lei Zhangd88a3642015-11-10 09:38:57 -0800481 std::vector<CPDF_FormField*> GetFormFields(
482 const CFX_WideString& csFieldName) const;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700483 CPDF_FormControl* GetSmartFieldControl(CPDF_FormField* pFormField);
tsepez4cf55152016-11-02 14:37:54 -0700484 bool ValueIsOccur(CPDF_FormField* pFormField, CFX_WideString csOptLabel);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700485
tsepez41a53ad2016-03-28 16:59:30 -0700486 void AddDelay_Int(FIELD_PROP prop, int32_t n);
487 void AddDelay_Bool(FIELD_PROP prop, bool b);
488 void AddDelay_String(FIELD_PROP prop, const CFX_ByteString& string);
489 void AddDelay_WideString(FIELD_PROP prop, const CFX_WideString& string);
490 void AddDelay_Rect(FIELD_PROP prop, const CFX_FloatRect& rect);
491 void AddDelay_Color(FIELD_PROP prop, const CPWL_Color& color);
492 void AddDelay_WordArray(FIELD_PROP prop, const std::vector<uint32_t>& array);
493 void AddDelay_WideStringArray(FIELD_PROP prop,
494 const std::vector<CFX_WideString>& array);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700495
496 void DoDelay();
497
498 public:
499 Document* m_pJSDoc;
dsinclair3a7741a2016-10-11 10:39:49 -0700500 CPDFSDK_FormFillEnvironment::ObservedPtr m_pFormFillEnv;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700501 CFX_WideString m_FieldName;
502 int m_nFormControlIndex;
tsepez4cf55152016-11-02 14:37:54 -0700503 bool m_bCanSet;
504 bool m_bDelay;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700505};
506
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700507class CJS_Field : public CJS_Object {
508 public:
Lei Zhangd88a3642015-11-10 09:38:57 -0800509 explicit CJS_Field(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {}
weilibff506d2016-06-20 11:37:05 -0700510 ~CJS_Field() override {}
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700511
Tom Sepez33420902015-10-13 15:00:10 -0700512 void InitInstance(IJS_Runtime* pIRuntime) override;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700513
Tom Sepezcd56a7d2015-10-06 11:45:28 -0700514 DECLARE_JS_CLASS();
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700515 JS_STATIC_PROP(alignment, Field);
516 JS_STATIC_PROP(borderStyle, Field);
517 JS_STATIC_PROP(buttonAlignX, Field);
518 JS_STATIC_PROP(buttonAlignY, Field);
519 JS_STATIC_PROP(buttonFitBounds, Field);
520 JS_STATIC_PROP(buttonPosition, Field);
521 JS_STATIC_PROP(buttonScaleHow, Field);
522 JS_STATIC_PROP(buttonScaleWhen, Field);
523 JS_STATIC_PROP(calcOrderIndex, Field);
524 JS_STATIC_PROP(charLimit, Field);
525 JS_STATIC_PROP(comb, Field);
526 JS_STATIC_PROP(commitOnSelChange, Field);
527 JS_STATIC_PROP(currentValueIndices, Field);
528 JS_STATIC_PROP(defaultStyle, Field);
529 JS_STATIC_PROP(defaultValue, Field);
530 JS_STATIC_PROP(doNotScroll, Field);
531 JS_STATIC_PROP(doNotSpellCheck, Field);
532 JS_STATIC_PROP(delay, Field);
533 JS_STATIC_PROP(display, Field);
534 JS_STATIC_PROP(doc, Field);
535 JS_STATIC_PROP(editable, Field);
536 JS_STATIC_PROP(exportValues, Field);
537 JS_STATIC_PROP(fileSelect, Field);
538 JS_STATIC_PROP(fillColor, Field);
539 JS_STATIC_PROP(hidden, Field);
540 JS_STATIC_PROP(highlight, Field);
541 JS_STATIC_PROP(lineWidth, Field);
542 JS_STATIC_PROP(multiline, Field);
543 JS_STATIC_PROP(multipleSelection, Field);
544 JS_STATIC_PROP(name, Field);
545 JS_STATIC_PROP(numItems, Field);
546 JS_STATIC_PROP(page, Field);
547 JS_STATIC_PROP(password, Field);
548 JS_STATIC_PROP(print, Field);
549 JS_STATIC_PROP(radiosInUnison, Field);
550 JS_STATIC_PROP(readonly, Field);
551 JS_STATIC_PROP(rect, Field);
552 JS_STATIC_PROP(required, Field);
553 JS_STATIC_PROP(richText, Field);
554 JS_STATIC_PROP(richValue, Field);
555 JS_STATIC_PROP(rotation, Field);
556 JS_STATIC_PROP(strokeColor, Field);
557 JS_STATIC_PROP(style, Field);
558 JS_STATIC_PROP(submitName, Field);
559 JS_STATIC_PROP(textColor, Field);
560 JS_STATIC_PROP(textFont, Field);
561 JS_STATIC_PROP(textSize, Field);
562 JS_STATIC_PROP(type, Field);
563 JS_STATIC_PROP(userName, Field);
564 JS_STATIC_PROP(value, Field);
565 JS_STATIC_PROP(valueAsString, Field);
566 JS_STATIC_PROP(source, Field);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700567
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700568 JS_STATIC_METHOD(browseForFileToSubmit, Field);
569 JS_STATIC_METHOD(buttonGetCaption, Field);
570 JS_STATIC_METHOD(buttonGetIcon, Field);
571 JS_STATIC_METHOD(buttonImportIcon, Field);
572 JS_STATIC_METHOD(buttonSetCaption, Field);
573 JS_STATIC_METHOD(buttonSetIcon, Field);
574 JS_STATIC_METHOD(checkThisBox, Field);
575 JS_STATIC_METHOD(clearItems, Field);
576 JS_STATIC_METHOD(defaultIsChecked, Field);
577 JS_STATIC_METHOD(deleteItemAt, Field);
578 JS_STATIC_METHOD(getArray, Field);
579 JS_STATIC_METHOD(getItemAt, Field);
580 JS_STATIC_METHOD(getLock, Field);
581 JS_STATIC_METHOD(insertItemAt, Field);
582 JS_STATIC_METHOD(isBoxChecked, Field);
583 JS_STATIC_METHOD(isDefaultChecked, Field);
584 JS_STATIC_METHOD(setAction, Field);
585 JS_STATIC_METHOD(setFocus, Field);
586 JS_STATIC_METHOD(setItems, Field);
587 JS_STATIC_METHOD(setLock, Field);
588 JS_STATIC_METHOD(signatureGetModifications, Field);
589 JS_STATIC_METHOD(signatureGetSeedValue, Field);
590 JS_STATIC_METHOD(signatureInfo, Field);
591 JS_STATIC_METHOD(signatureSetSeedValue, Field);
592 JS_STATIC_METHOD(signatureSign, Field);
593 JS_STATIC_METHOD(signatureValidate, Field);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700594};
595
Dan Sinclairf766ad22016-03-14 13:51:24 -0400596#endif // FPDFSDK_JAVASCRIPT_FIELD_H_