blob: 21ae04c9600ddeff69f0c001595f7f6c38b4b160 [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
Tom Sepez37458412015-10-06 11:33:46 -07007#ifndef FPDFSDK_SRC_JAVASCRIPT_FIELD_H_
8#define FPDFSDK_SRC_JAVASCRIPT_FIELD_H_
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07009
Tom Sepez9a3f8122015-04-07 15:35:48 -070010#include <string> // For std::wstring.
11
Tom Sepez37458412015-10-06 11:33:46 -070012#include "../../include/pdfwindow/PWL_Wnd.h" // For CPWL_Color.
Tom Sepez9a3f8122015-04-07 15:35:48 -070013#include "JS_Define.h"
14
Tom Sepez37458412015-10-06 11:33:46 -070015class CPDFSDK_Widget;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070016class Document;
17
Nico Weber9d8ec5a2015-08-04 13:00:21 -070018enum FIELD_PROP {
19 FP_ALIGNMENT,
20 FP_BORDERSTYLE,
21 FP_BUTTONALIGNX,
22 FP_BUTTONALIGNY,
23 FP_BUTTONFITBOUNDS,
24 FP_BUTTONPOSITION,
25 FP_BUTTONSCALEHOW,
26 FP_BUTTONSCALEWHEN,
27 FP_CALCORDERINDEX,
28 FP_CHARLIMIT,
29 FP_COMB,
30 FP_COMMITONSELCHANGE,
31 FP_CURRENTVALUEINDICES,
32 FP_DEFAULTVALUE,
33 FP_DONOTSCROLL,
34 FP_DISPLAY,
35 FP_FILLCOLOR,
36 FP_HIDDEN,
37 FP_HIGHLIGHT,
38 FP_LINEWIDTH,
39 FP_MULTILINE,
40 FP_MULTIPLESELECTION,
41 FP_PASSWORD,
42 FP_RECT,
43 FP_RICHTEXT,
44 FP_RICHVALUE,
45 FP_ROTATION,
46 FP_STROKECOLOR,
47 FP_STYLE,
48 FP_TEXTCOLOR,
49 FP_TEXTFONT,
50 FP_TEXTSIZE,
51 FP_USERNAME,
52 FP_VALUE
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070053};
54
Nico Weber9d8ec5a2015-08-04 13:00:21 -070055class CJS_WideStringArray {
56 public:
57 CJS_WideStringArray() {}
58 virtual ~CJS_WideStringArray() {
59 for (int i = 0, sz = m_Data.GetSize(); i < sz; i++)
60 delete m_Data.GetAt(i);
61 m_Data.RemoveAll();
62 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070063
Nico Weber9d8ec5a2015-08-04 13:00:21 -070064 void Add(const CFX_WideString& string) {
65 m_Data.Add(new CFX_WideString(string));
66 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070067
Nico Weber9d8ec5a2015-08-04 13:00:21 -070068 int GetSize() const { return m_Data.GetSize(); }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070069
Nico Weber9d8ec5a2015-08-04 13:00:21 -070070 CFX_WideString GetAt(int i) const { return *m_Data.GetAt(i); }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070071
Nico Weber9d8ec5a2015-08-04 13:00:21 -070072 private:
73 CFX_ArrayTemplate<CFX_WideString*> m_Data;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070074};
75
Nico Weber9d8ec5a2015-08-04 13:00:21 -070076struct CJS_DelayData {
77 CFX_WideString sFieldName;
78 int nControlIndex;
79 enum FIELD_PROP eProp;
80 int32_t num;
81 bool b;
82 CFX_ByteString string;
83 CFX_WideString widestring;
84 CPDF_Rect rect;
85 CPWL_Color color;
86 CFX_DWordArray wordarray;
87 CJS_WideStringArray widestringarray;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070088};
89
Nico Weber9d8ec5a2015-08-04 13:00:21 -070090class Field : public CJS_EmbedObj {
91 public:
92 Field(CJS_Object* pJSObject);
Lei Zhang2b1a2d52015-08-14 22:16:22 -070093 ~Field() override;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070094
Tom Sepezba038bc2015-10-08 12:03:00 -070095 FX_BOOL alignment(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
96 FX_BOOL borderStyle(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -070097 CJS_PropValue& vp,
98 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -070099 FX_BOOL buttonAlignX(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700100 CJS_PropValue& vp,
101 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700102 FX_BOOL buttonAlignY(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700103 CJS_PropValue& vp,
104 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700105 FX_BOOL buttonFitBounds(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700106 CJS_PropValue& vp,
107 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700108 FX_BOOL buttonPosition(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700109 CJS_PropValue& vp,
110 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700111 FX_BOOL buttonScaleHow(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700112 CJS_PropValue& vp,
113 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700114 FX_BOOL buttonScaleWhen(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700115 CJS_PropValue& vp,
116 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700117 FX_BOOL calcOrderIndex(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700118 CJS_PropValue& vp,
119 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700120 FX_BOOL charLimit(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
121 FX_BOOL comb(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
122 FX_BOOL commitOnSelChange(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700123 CJS_PropValue& vp,
124 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700125 FX_BOOL currentValueIndices(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700126 CJS_PropValue& vp,
127 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700128 FX_BOOL defaultStyle(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700129 CJS_PropValue& vp,
130 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700131 FX_BOOL defaultValue(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700132 CJS_PropValue& vp,
133 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700134 FX_BOOL doNotScroll(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700135 CJS_PropValue& vp,
136 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700137 FX_BOOL doNotSpellCheck(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700138 CJS_PropValue& vp,
139 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700140 FX_BOOL delay(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
141 FX_BOOL display(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
142 FX_BOOL doc(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
143 FX_BOOL editable(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
144 FX_BOOL exportValues(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700145 CJS_PropValue& vp,
146 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700147 FX_BOOL fileSelect(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700148 CJS_PropValue& vp,
149 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700150 FX_BOOL fillColor(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
151 FX_BOOL hidden(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
152 FX_BOOL highlight(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
153 FX_BOOL lineWidth(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
154 FX_BOOL multiline(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
155 FX_BOOL multipleSelection(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700156 CJS_PropValue& vp,
157 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700158 FX_BOOL name(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
159 FX_BOOL numItems(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
160 FX_BOOL page(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
161 FX_BOOL password(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
162 FX_BOOL print(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
163 FX_BOOL radiosInUnison(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700164 CJS_PropValue& vp,
165 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700166 FX_BOOL readonly(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
167 FX_BOOL rect(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
168 FX_BOOL required(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
169 FX_BOOL richText(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
170 FX_BOOL richValue(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
171 FX_BOOL rotation(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
172 FX_BOOL strokeColor(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700173 CJS_PropValue& vp,
174 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700175 FX_BOOL style(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
176 FX_BOOL submitName(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700177 CJS_PropValue& vp,
178 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700179 FX_BOOL textColor(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
180 FX_BOOL textFont(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
181 FX_BOOL textSize(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
182 FX_BOOL type(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
183 FX_BOOL userName(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
184 FX_BOOL value(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
185 FX_BOOL valueAsString(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700186 CJS_PropValue& vp,
187 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700188 FX_BOOL source(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700189
Tom Sepezba038bc2015-10-08 12:03:00 -0700190 FX_BOOL browseForFileToSubmit(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700191 const CJS_Parameters& params,
192 CJS_Value& vRet,
193 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700194 FX_BOOL buttonGetCaption(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700195 const CJS_Parameters& params,
196 CJS_Value& vRet,
197 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700198 FX_BOOL buttonGetIcon(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700199 const CJS_Parameters& params,
200 CJS_Value& vRet,
201 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700202 FX_BOOL buttonImportIcon(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700203 const CJS_Parameters& params,
204 CJS_Value& vRet,
205 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700206 FX_BOOL buttonSetCaption(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700207 const CJS_Parameters& params,
208 CJS_Value& vRet,
209 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700210 FX_BOOL buttonSetIcon(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700211 const CJS_Parameters& params,
212 CJS_Value& vRet,
213 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700214 FX_BOOL checkThisBox(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700215 const CJS_Parameters& params,
216 CJS_Value& vRet,
217 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700218 FX_BOOL clearItems(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700219 const CJS_Parameters& params,
220 CJS_Value& vRet,
221 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700222 FX_BOOL defaultIsChecked(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700223 const CJS_Parameters& params,
224 CJS_Value& vRet,
225 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700226 FX_BOOL deleteItemAt(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700227 const CJS_Parameters& params,
228 CJS_Value& vRet,
229 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700230 FX_BOOL getArray(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700231 const CJS_Parameters& params,
232 CJS_Value& vRet,
233 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700234 FX_BOOL getItemAt(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700235 const CJS_Parameters& params,
236 CJS_Value& vRet,
237 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700238 FX_BOOL getLock(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700239 const CJS_Parameters& params,
240 CJS_Value& vRet,
241 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700242 FX_BOOL insertItemAt(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700243 const CJS_Parameters& params,
244 CJS_Value& vRet,
245 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700246 FX_BOOL isBoxChecked(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700247 const CJS_Parameters& params,
248 CJS_Value& vRet,
249 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700250 FX_BOOL isDefaultChecked(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700251 const CJS_Parameters& params,
252 CJS_Value& vRet,
253 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700254 FX_BOOL setAction(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700255 const CJS_Parameters& params,
256 CJS_Value& vRet,
257 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700258 FX_BOOL setFocus(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700259 const CJS_Parameters& params,
260 CJS_Value& vRet,
261 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700262 FX_BOOL setItems(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700263 const CJS_Parameters& params,
264 CJS_Value& vRet,
265 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700266 FX_BOOL setLock(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700267 const CJS_Parameters& params,
268 CJS_Value& vRet,
269 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700270 FX_BOOL signatureGetModifications(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700271 const CJS_Parameters& params,
272 CJS_Value& vRet,
273 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700274 FX_BOOL signatureGetSeedValue(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700275 const CJS_Parameters& params,
276 CJS_Value& vRet,
277 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700278 FX_BOOL signatureInfo(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700279 const CJS_Parameters& params,
280 CJS_Value& vRet,
281 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700282 FX_BOOL signatureSetSeedValue(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700283 const CJS_Parameters& params,
284 CJS_Value& vRet,
285 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700286 FX_BOOL signatureSign(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700287 const CJS_Parameters& params,
288 CJS_Value& vRet,
289 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700290 FX_BOOL signatureValidate(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700291 const CJS_Parameters& params,
292 CJS_Value& vRet,
293 CFX_WideString& sError);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700294
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700295 public:
296 static void SetAlignment(CPDFSDK_Document* pDocument,
297 const CFX_WideString& swFieldName,
298 int nControlIndex,
299 const CFX_ByteString& string);
300 static void SetBorderStyle(CPDFSDK_Document* pDocument,
301 const CFX_WideString& swFieldName,
302 int nControlIndex,
303 const CFX_ByteString& string);
304 static void SetButtonAlignX(CPDFSDK_Document* pDocument,
305 const CFX_WideString& swFieldName,
306 int nControlIndex,
307 int number);
308 static void SetButtonAlignY(CPDFSDK_Document* pDocument,
309 const CFX_WideString& swFieldName,
310 int nControlIndex,
311 int number);
312 static void SetButtonFitBounds(CPDFSDK_Document* pDocument,
313 const CFX_WideString& swFieldName,
314 int nControlIndex,
315 bool b);
316 static void SetButtonPosition(CPDFSDK_Document* pDocument,
317 const CFX_WideString& swFieldName,
318 int nControlIndex,
319 int number);
320 static void SetButtonScaleHow(CPDFSDK_Document* pDocument,
321 const CFX_WideString& swFieldName,
322 int nControlIndex,
323 int number);
324 static void SetButtonScaleWhen(CPDFSDK_Document* pDocument,
325 const CFX_WideString& swFieldName,
326 int nControlIndex,
327 int number);
328 static void SetCalcOrderIndex(CPDFSDK_Document* pDocument,
329 const CFX_WideString& swFieldName,
330 int nControlIndex,
331 int number);
332 static void SetCharLimit(CPDFSDK_Document* pDocument,
333 const CFX_WideString& swFieldName,
334 int nControlIndex,
335 int number);
336 static void SetComb(CPDFSDK_Document* pDocument,
337 const CFX_WideString& swFieldName,
338 int nControlIndex,
339 bool b);
340 static void SetCommitOnSelChange(CPDFSDK_Document* pDocument,
341 const CFX_WideString& swFieldName,
342 int nControlIndex,
343 bool b);
344 static void SetCurrentValueIndices(CPDFSDK_Document* pDocument,
345 const CFX_WideString& swFieldName,
346 int nControlIndex,
347 const CFX_DWordArray& array);
348 static void SetDefaultStyle(CPDFSDK_Document* pDocument,
349 const CFX_WideString& swFieldName,
350 int nControlIndex);
351 static void SetDefaultValue(CPDFSDK_Document* pDocument,
352 const CFX_WideString& swFieldName,
353 int nControlIndex,
354 const CFX_WideString& string);
355 static void SetDoNotScroll(CPDFSDK_Document* pDocument,
356 const CFX_WideString& swFieldName,
357 int nControlIndex,
358 bool b);
359 static void SetDisplay(CPDFSDK_Document* pDocument,
360 const CFX_WideString& swFieldName,
361 int nControlIndex,
362 int number);
363 static void SetFillColor(CPDFSDK_Document* pDocument,
364 const CFX_WideString& swFieldName,
365 int nControlIndex,
366 const CPWL_Color& color);
367 static void SetHidden(CPDFSDK_Document* pDocument,
368 const CFX_WideString& swFieldName,
369 int nControlIndex,
370 bool b);
371 static void SetHighlight(CPDFSDK_Document* pDocument,
372 const CFX_WideString& swFieldName,
373 int nControlIndex,
374 const CFX_ByteString& string);
375 static void SetLineWidth(CPDFSDK_Document* pDocument,
376 const CFX_WideString& swFieldName,
377 int nControlIndex,
378 int number);
379 static void SetMultiline(CPDFSDK_Document* pDocument,
380 const CFX_WideString& swFieldName,
381 int nControlIndex,
382 bool b);
383 static void SetMultipleSelection(CPDFSDK_Document* pDocument,
384 const CFX_WideString& swFieldName,
385 int nControlIndex,
386 bool b);
387 static void SetPassword(CPDFSDK_Document* pDocument,
388 const CFX_WideString& swFieldName,
389 int nControlIndex,
390 bool b);
391 static void SetRect(CPDFSDK_Document* pDocument,
392 const CFX_WideString& swFieldName,
393 int nControlIndex,
394 const CPDF_Rect& rect);
395 static void SetRichText(CPDFSDK_Document* pDocument,
396 const CFX_WideString& swFieldName,
397 int nControlIndex,
398 bool b);
399 static void SetRichValue(CPDFSDK_Document* pDocument,
400 const CFX_WideString& swFieldName,
401 int nControlIndex);
402 static void SetRotation(CPDFSDK_Document* pDocument,
403 const CFX_WideString& swFieldName,
404 int nControlIndex,
405 int number);
406 static void SetStrokeColor(CPDFSDK_Document* pDocument,
407 const CFX_WideString& swFieldName,
408 int nControlIndex,
409 const CPWL_Color& color);
410 static void SetStyle(CPDFSDK_Document* pDocument,
411 const CFX_WideString& swFieldName,
412 int nControlIndex,
413 const CFX_ByteString& string);
414 static void SetTextColor(CPDFSDK_Document* pDocument,
415 const CFX_WideString& swFieldName,
416 int nControlIndex,
417 const CPWL_Color& color);
418 static void SetTextFont(CPDFSDK_Document* pDocument,
419 const CFX_WideString& swFieldName,
420 int nControlIndex,
421 const CFX_ByteString& string);
422 static void SetTextSize(CPDFSDK_Document* pDocument,
423 const CFX_WideString& swFieldName,
424 int nControlIndex,
425 int number);
426 static void SetUserName(CPDFSDK_Document* pDocument,
427 const CFX_WideString& swFieldName,
428 int nControlIndex,
429 const CFX_WideString& string);
430 static void SetValue(CPDFSDK_Document* pDocument,
431 const CFX_WideString& swFieldName,
432 int nControlIndex,
433 const CJS_WideStringArray& strArray);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700434
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700435 public:
436 static void AddField(CPDFSDK_Document* pDocument,
437 int nPageIndex,
438 int nFieldType,
439 const CFX_WideString& sName,
440 const CPDF_Rect& rcCoords);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700441
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700442 public:
443 static void UpdateFormField(CPDFSDK_Document* pDocument,
444 CPDF_FormField* pFormField,
445 FX_BOOL bChangeMark,
446 FX_BOOL bResetAP,
447 FX_BOOL bRefresh);
448 static void UpdateFormControl(CPDFSDK_Document* pDocument,
449 CPDF_FormControl* pFormControl,
450 FX_BOOL bChangeMark,
451 FX_BOOL bResetAP,
452 FX_BOOL bRefresh);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700453
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700454 static CPDFSDK_Widget* GetWidget(CPDFSDK_Document* pDocument,
455 CPDF_FormControl* pFormControl);
456 static void GetFormFields(CPDFSDK_Document* pDocument,
457 const CFX_WideString& csFieldName,
458 CFX_PtrArray& FieldsArray);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700459
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700460 static void DoDelay(CPDFSDK_Document* pDocument, CJS_DelayData* pData);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700461
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700462 public:
463 FX_BOOL AttachField(Document* pDocument, const CFX_WideString& csFieldName);
464 void SetDelay(FX_BOOL bDelay);
465 void SetIsolate(v8::Isolate* isolate) { m_isolate = isolate; }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700466
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700467 protected:
468 void ParseFieldName(const std::wstring& strFieldNameParsed,
469 std::wstring& strFieldName,
470 int& iControlNo);
471 void GetFormFields(const CFX_WideString& csFieldName,
472 CFX_PtrArray& FieldsArray);
473 CPDF_FormControl* GetSmartFieldControl(CPDF_FormField* pFormField);
474 FX_BOOL ValueIsOccur(CPDF_FormField* pFormField, CFX_WideString csOptLabel);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700475
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700476 void AddDelay_Int(enum FIELD_PROP prop, int32_t n);
477 void AddDelay_Bool(enum FIELD_PROP prop, bool b);
478 void AddDelay_String(enum FIELD_PROP prop, const CFX_ByteString& string);
479 void AddDelay_WideString(enum FIELD_PROP prop, const CFX_WideString& string);
480 void AddDelay_Rect(enum FIELD_PROP prop, const CPDF_Rect& rect);
481 void AddDelay_Color(enum FIELD_PROP prop, const CPWL_Color& color);
482 void AddDelay_WordArray(enum FIELD_PROP prop, const CFX_DWordArray& array);
483 void AddDelay_WideStringArray(enum FIELD_PROP prop,
484 const CJS_WideStringArray& array);
485
486 void DoDelay();
487
488 public:
489 Document* m_pJSDoc;
490 CPDFSDK_Document* m_pDocument;
491 CFX_WideString m_FieldName;
492 int m_nFormControlIndex;
493 FX_BOOL m_bCanSet;
494
495 FX_BOOL m_bDelay;
496 v8::Isolate* m_isolate;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700497};
498
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700499class CJS_Field : public CJS_Object {
500 public:
Tom Sepez808a99e2015-09-10 12:28:37 -0700501 CJS_Field(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {}
Lei Zhang2b1a2d52015-08-14 22:16:22 -0700502 ~CJS_Field(void) override {}
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700503
Tom Sepez33420902015-10-13 15:00:10 -0700504 void InitInstance(IJS_Runtime* pIRuntime) override;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700505
Tom Sepezcd56a7d2015-10-06 11:45:28 -0700506 DECLARE_JS_CLASS();
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700507 JS_STATIC_PROP(alignment, Field);
508 JS_STATIC_PROP(borderStyle, Field);
509 JS_STATIC_PROP(buttonAlignX, Field);
510 JS_STATIC_PROP(buttonAlignY, Field);
511 JS_STATIC_PROP(buttonFitBounds, Field);
512 JS_STATIC_PROP(buttonPosition, Field);
513 JS_STATIC_PROP(buttonScaleHow, Field);
514 JS_STATIC_PROP(buttonScaleWhen, Field);
515 JS_STATIC_PROP(calcOrderIndex, Field);
516 JS_STATIC_PROP(charLimit, Field);
517 JS_STATIC_PROP(comb, Field);
518 JS_STATIC_PROP(commitOnSelChange, Field);
519 JS_STATIC_PROP(currentValueIndices, Field);
520 JS_STATIC_PROP(defaultStyle, Field);
521 JS_STATIC_PROP(defaultValue, Field);
522 JS_STATIC_PROP(doNotScroll, Field);
523 JS_STATIC_PROP(doNotSpellCheck, Field);
524 JS_STATIC_PROP(delay, Field);
525 JS_STATIC_PROP(display, Field);
526 JS_STATIC_PROP(doc, Field);
527 JS_STATIC_PROP(editable, Field);
528 JS_STATIC_PROP(exportValues, Field);
529 JS_STATIC_PROP(fileSelect, Field);
530 JS_STATIC_PROP(fillColor, Field);
531 JS_STATIC_PROP(hidden, Field);
532 JS_STATIC_PROP(highlight, Field);
533 JS_STATIC_PROP(lineWidth, Field);
534 JS_STATIC_PROP(multiline, Field);
535 JS_STATIC_PROP(multipleSelection, Field);
536 JS_STATIC_PROP(name, Field);
537 JS_STATIC_PROP(numItems, Field);
538 JS_STATIC_PROP(page, Field);
539 JS_STATIC_PROP(password, Field);
540 JS_STATIC_PROP(print, Field);
541 JS_STATIC_PROP(radiosInUnison, Field);
542 JS_STATIC_PROP(readonly, Field);
543 JS_STATIC_PROP(rect, Field);
544 JS_STATIC_PROP(required, Field);
545 JS_STATIC_PROP(richText, Field);
546 JS_STATIC_PROP(richValue, Field);
547 JS_STATIC_PROP(rotation, Field);
548 JS_STATIC_PROP(strokeColor, Field);
549 JS_STATIC_PROP(style, Field);
550 JS_STATIC_PROP(submitName, Field);
551 JS_STATIC_PROP(textColor, Field);
552 JS_STATIC_PROP(textFont, Field);
553 JS_STATIC_PROP(textSize, Field);
554 JS_STATIC_PROP(type, Field);
555 JS_STATIC_PROP(userName, Field);
556 JS_STATIC_PROP(value, Field);
557 JS_STATIC_PROP(valueAsString, Field);
558 JS_STATIC_PROP(source, Field);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700559
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700560 JS_STATIC_METHOD(browseForFileToSubmit, Field);
561 JS_STATIC_METHOD(buttonGetCaption, Field);
562 JS_STATIC_METHOD(buttonGetIcon, Field);
563 JS_STATIC_METHOD(buttonImportIcon, Field);
564 JS_STATIC_METHOD(buttonSetCaption, Field);
565 JS_STATIC_METHOD(buttonSetIcon, Field);
566 JS_STATIC_METHOD(checkThisBox, Field);
567 JS_STATIC_METHOD(clearItems, Field);
568 JS_STATIC_METHOD(defaultIsChecked, Field);
569 JS_STATIC_METHOD(deleteItemAt, Field);
570 JS_STATIC_METHOD(getArray, Field);
571 JS_STATIC_METHOD(getItemAt, Field);
572 JS_STATIC_METHOD(getLock, Field);
573 JS_STATIC_METHOD(insertItemAt, Field);
574 JS_STATIC_METHOD(isBoxChecked, Field);
575 JS_STATIC_METHOD(isDefaultChecked, Field);
576 JS_STATIC_METHOD(setAction, Field);
577 JS_STATIC_METHOD(setFocus, Field);
578 JS_STATIC_METHOD(setItems, Field);
579 JS_STATIC_METHOD(setLock, Field);
580 JS_STATIC_METHOD(signatureGetModifications, Field);
581 JS_STATIC_METHOD(signatureGetSeedValue, Field);
582 JS_STATIC_METHOD(signatureInfo, Field);
583 JS_STATIC_METHOD(signatureSetSeedValue, Field);
584 JS_STATIC_METHOD(signatureSign, Field);
585 JS_STATIC_METHOD(signatureValidate, Field);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700586};
587
Tom Sepez37458412015-10-06 11:33:46 -0700588#endif // FPDFSDK_SRC_JAVASCRIPT_FIELD_H_