blob: 84bba6862d4614f880220647fa00392fc047ff1f [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
Dan Sinclairf766ad22016-03-14 13:51:24 -040013#include "fpdfsdk/javascript/JS_Define.h"
dan sinclair89e904b2016-03-23 19:29:15 -040014#include "fpdfsdk/pdfwindow/PWL_Wnd.h" // For CPWL_Color.
Tom Sepez9a3f8122015-04-07 15:35:48 -070015
Tom Sepez37458412015-10-06 11:33:46 -070016class CPDFSDK_Widget;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070017class Document;
18
Nico Weber9d8ec5a2015-08-04 13:00:21 -070019enum FIELD_PROP {
20 FP_ALIGNMENT,
21 FP_BORDERSTYLE,
22 FP_BUTTONALIGNX,
23 FP_BUTTONALIGNY,
24 FP_BUTTONFITBOUNDS,
25 FP_BUTTONPOSITION,
26 FP_BUTTONSCALEHOW,
27 FP_BUTTONSCALEWHEN,
28 FP_CALCORDERINDEX,
29 FP_CHARLIMIT,
30 FP_COMB,
31 FP_COMMITONSELCHANGE,
32 FP_CURRENTVALUEINDICES,
33 FP_DEFAULTVALUE,
34 FP_DONOTSCROLL,
35 FP_DISPLAY,
36 FP_FILLCOLOR,
37 FP_HIDDEN,
38 FP_HIGHLIGHT,
39 FP_LINEWIDTH,
40 FP_MULTILINE,
41 FP_MULTIPLESELECTION,
42 FP_PASSWORD,
43 FP_RECT,
44 FP_RICHTEXT,
45 FP_RICHVALUE,
46 FP_ROTATION,
47 FP_STROKECOLOR,
48 FP_STYLE,
49 FP_TEXTCOLOR,
50 FP_TEXTFONT,
51 FP_TEXTSIZE,
52 FP_USERNAME,
53 FP_VALUE
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070054};
55
Nico Weber9d8ec5a2015-08-04 13:00:21 -070056struct CJS_DelayData {
weili625ad662016-06-15 11:21:33 -070057 CJS_DelayData(FIELD_PROP prop, int idx, const CFX_WideString& name);
58 ~CJS_DelayData();
tsepez41a53ad2016-03-28 16:59:30 -070059
60 FIELD_PROP eProp;
Nico Weber9d8ec5a2015-08-04 13:00:21 -070061 int nControlIndex;
tsepez41a53ad2016-03-28 16:59:30 -070062 CFX_WideString sFieldName;
Nico Weber9d8ec5a2015-08-04 13:00:21 -070063 int32_t num;
64 bool b;
65 CFX_ByteString string;
66 CFX_WideString widestring;
Tom Sepez281a9ea2016-02-26 14:24:28 -080067 CFX_FloatRect rect;
Nico Weber9d8ec5a2015-08-04 13:00:21 -070068 CPWL_Color color;
tsepez41a53ad2016-03-28 16:59:30 -070069 std::vector<uint32_t> wordarray;
70 std::vector<CFX_WideString> widestringarray;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070071};
72
Nico Weber9d8ec5a2015-08-04 13:00:21 -070073class Field : public CJS_EmbedObj {
74 public:
Lei Zhangd88a3642015-11-10 09:38:57 -080075 explicit Field(CJS_Object* pJSObject);
Lei Zhang2b1a2d52015-08-14 22:16:22 -070076 ~Field() override;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070077
Tom Sepezba038bc2015-10-08 12:03:00 -070078 FX_BOOL alignment(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
79 FX_BOOL borderStyle(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -070080 CJS_PropValue& vp,
81 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -070082 FX_BOOL buttonAlignX(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -070083 CJS_PropValue& vp,
84 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -070085 FX_BOOL buttonAlignY(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -070086 CJS_PropValue& vp,
87 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -070088 FX_BOOL buttonFitBounds(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -070089 CJS_PropValue& vp,
90 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -070091 FX_BOOL buttonPosition(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -070092 CJS_PropValue& vp,
93 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -070094 FX_BOOL buttonScaleHow(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -070095 CJS_PropValue& vp,
96 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -070097 FX_BOOL buttonScaleWhen(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -070098 CJS_PropValue& vp,
99 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700100 FX_BOOL calcOrderIndex(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700101 CJS_PropValue& vp,
102 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700103 FX_BOOL charLimit(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
104 FX_BOOL comb(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
105 FX_BOOL commitOnSelChange(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 currentValueIndices(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 defaultStyle(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 defaultValue(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 doNotScroll(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 doNotSpellCheck(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700121 CJS_PropValue& vp,
122 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700123 FX_BOOL delay(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
124 FX_BOOL display(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
125 FX_BOOL doc(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
126 FX_BOOL editable(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
127 FX_BOOL exportValues(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700128 CJS_PropValue& vp,
129 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700130 FX_BOOL fileSelect(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700131 CJS_PropValue& vp,
132 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700133 FX_BOOL fillColor(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
134 FX_BOOL hidden(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
135 FX_BOOL highlight(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
136 FX_BOOL lineWidth(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
137 FX_BOOL multiline(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
138 FX_BOOL multipleSelection(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700139 CJS_PropValue& vp,
140 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700141 FX_BOOL name(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
142 FX_BOOL numItems(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
143 FX_BOOL page(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
144 FX_BOOL password(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
145 FX_BOOL print(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
146 FX_BOOL radiosInUnison(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700147 CJS_PropValue& vp,
148 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700149 FX_BOOL readonly(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
150 FX_BOOL rect(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
151 FX_BOOL required(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
152 FX_BOOL richText(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
153 FX_BOOL richValue(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
154 FX_BOOL rotation(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
155 FX_BOOL strokeColor(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 style(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
159 FX_BOOL submitName(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700160 CJS_PropValue& vp,
161 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700162 FX_BOOL textColor(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
163 FX_BOOL textFont(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
164 FX_BOOL textSize(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
165 FX_BOOL type(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
166 FX_BOOL userName(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
167 FX_BOOL value(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
168 FX_BOOL valueAsString(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700169 CJS_PropValue& vp,
170 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700171 FX_BOOL source(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700172
Tom Sepezba038bc2015-10-08 12:03:00 -0700173 FX_BOOL browseForFileToSubmit(IJS_Context* cc,
Lei Zhang945fdb72015-11-11 10:18:16 -0800174 const std::vector<CJS_Value>& params,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700175 CJS_Value& vRet,
176 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700177 FX_BOOL buttonGetCaption(IJS_Context* cc,
Lei Zhang945fdb72015-11-11 10:18:16 -0800178 const std::vector<CJS_Value>& params,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700179 CJS_Value& vRet,
180 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700181 FX_BOOL buttonGetIcon(IJS_Context* cc,
Lei Zhang945fdb72015-11-11 10:18:16 -0800182 const std::vector<CJS_Value>& params,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700183 CJS_Value& vRet,
184 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700185 FX_BOOL buttonImportIcon(IJS_Context* cc,
Lei Zhang945fdb72015-11-11 10:18:16 -0800186 const std::vector<CJS_Value>& params,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700187 CJS_Value& vRet,
188 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700189 FX_BOOL buttonSetCaption(IJS_Context* cc,
Lei Zhang945fdb72015-11-11 10:18:16 -0800190 const std::vector<CJS_Value>& params,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700191 CJS_Value& vRet,
192 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700193 FX_BOOL buttonSetIcon(IJS_Context* cc,
Lei Zhang945fdb72015-11-11 10:18:16 -0800194 const std::vector<CJS_Value>& params,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700195 CJS_Value& vRet,
196 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700197 FX_BOOL checkThisBox(IJS_Context* cc,
Lei Zhang945fdb72015-11-11 10:18:16 -0800198 const std::vector<CJS_Value>& params,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700199 CJS_Value& vRet,
200 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700201 FX_BOOL clearItems(IJS_Context* cc,
Lei Zhang945fdb72015-11-11 10:18:16 -0800202 const std::vector<CJS_Value>& params,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700203 CJS_Value& vRet,
204 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700205 FX_BOOL defaultIsChecked(IJS_Context* cc,
Lei Zhang945fdb72015-11-11 10:18:16 -0800206 const std::vector<CJS_Value>& params,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700207 CJS_Value& vRet,
208 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700209 FX_BOOL deleteItemAt(IJS_Context* cc,
Lei Zhang945fdb72015-11-11 10:18:16 -0800210 const std::vector<CJS_Value>& params,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700211 CJS_Value& vRet,
212 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700213 FX_BOOL getArray(IJS_Context* cc,
Lei Zhang945fdb72015-11-11 10:18:16 -0800214 const std::vector<CJS_Value>& params,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700215 CJS_Value& vRet,
216 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700217 FX_BOOL getItemAt(IJS_Context* cc,
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 Sepezba038bc2015-10-08 12:03:00 -0700221 FX_BOOL getLock(IJS_Context* cc,
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 Sepezba038bc2015-10-08 12:03:00 -0700225 FX_BOOL insertItemAt(IJS_Context* cc,
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 Sepezba038bc2015-10-08 12:03:00 -0700229 FX_BOOL isBoxChecked(IJS_Context* cc,
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 Sepezba038bc2015-10-08 12:03:00 -0700233 FX_BOOL isDefaultChecked(IJS_Context* cc,
Lei Zhang945fdb72015-11-11 10:18:16 -0800234 const std::vector<CJS_Value>& params,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700235 CJS_Value& vRet,
236 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700237 FX_BOOL setAction(IJS_Context* cc,
Lei Zhang945fdb72015-11-11 10:18:16 -0800238 const std::vector<CJS_Value>& params,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700239 CJS_Value& vRet,
240 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700241 FX_BOOL setFocus(IJS_Context* cc,
Lei Zhang945fdb72015-11-11 10:18:16 -0800242 const std::vector<CJS_Value>& params,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700243 CJS_Value& vRet,
244 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700245 FX_BOOL setItems(IJS_Context* cc,
Lei Zhang945fdb72015-11-11 10:18:16 -0800246 const std::vector<CJS_Value>& params,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700247 CJS_Value& vRet,
248 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700249 FX_BOOL setLock(IJS_Context* cc,
Lei Zhang945fdb72015-11-11 10:18:16 -0800250 const std::vector<CJS_Value>& params,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700251 CJS_Value& vRet,
252 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700253 FX_BOOL signatureGetModifications(IJS_Context* cc,
Lei Zhang945fdb72015-11-11 10:18:16 -0800254 const std::vector<CJS_Value>& params,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700255 CJS_Value& vRet,
256 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700257 FX_BOOL signatureGetSeedValue(IJS_Context* cc,
Lei Zhang945fdb72015-11-11 10:18:16 -0800258 const std::vector<CJS_Value>& params,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700259 CJS_Value& vRet,
260 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700261 FX_BOOL signatureInfo(IJS_Context* cc,
Lei Zhang945fdb72015-11-11 10:18:16 -0800262 const std::vector<CJS_Value>& params,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700263 CJS_Value& vRet,
264 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700265 FX_BOOL signatureSetSeedValue(IJS_Context* cc,
Lei Zhang945fdb72015-11-11 10:18:16 -0800266 const std::vector<CJS_Value>& params,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700267 CJS_Value& vRet,
268 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700269 FX_BOOL signatureSign(IJS_Context* cc,
Lei Zhang945fdb72015-11-11 10:18:16 -0800270 const std::vector<CJS_Value>& params,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700271 CJS_Value& vRet,
272 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700273 FX_BOOL signatureValidate(IJS_Context* cc,
Lei Zhang945fdb72015-11-11 10:18:16 -0800274 const std::vector<CJS_Value>& params,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700275 CJS_Value& vRet,
276 CFX_WideString& sError);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700277
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700278 static void SetAlignment(CPDFSDK_Document* pDocument,
279 const CFX_WideString& swFieldName,
280 int nControlIndex,
281 const CFX_ByteString& string);
282 static void SetBorderStyle(CPDFSDK_Document* pDocument,
283 const CFX_WideString& swFieldName,
284 int nControlIndex,
285 const CFX_ByteString& string);
286 static void SetButtonAlignX(CPDFSDK_Document* pDocument,
287 const CFX_WideString& swFieldName,
288 int nControlIndex,
289 int number);
290 static void SetButtonAlignY(CPDFSDK_Document* pDocument,
291 const CFX_WideString& swFieldName,
292 int nControlIndex,
293 int number);
294 static void SetButtonFitBounds(CPDFSDK_Document* pDocument,
295 const CFX_WideString& swFieldName,
296 int nControlIndex,
297 bool b);
298 static void SetButtonPosition(CPDFSDK_Document* pDocument,
299 const CFX_WideString& swFieldName,
300 int nControlIndex,
301 int number);
302 static void SetButtonScaleHow(CPDFSDK_Document* pDocument,
303 const CFX_WideString& swFieldName,
304 int nControlIndex,
305 int number);
306 static void SetButtonScaleWhen(CPDFSDK_Document* pDocument,
307 const CFX_WideString& swFieldName,
308 int nControlIndex,
309 int number);
310 static void SetCalcOrderIndex(CPDFSDK_Document* pDocument,
311 const CFX_WideString& swFieldName,
312 int nControlIndex,
313 int number);
314 static void SetCharLimit(CPDFSDK_Document* pDocument,
315 const CFX_WideString& swFieldName,
316 int nControlIndex,
317 int number);
318 static void SetComb(CPDFSDK_Document* pDocument,
319 const CFX_WideString& swFieldName,
320 int nControlIndex,
321 bool b);
322 static void SetCommitOnSelChange(CPDFSDK_Document* pDocument,
323 const CFX_WideString& swFieldName,
324 int nControlIndex,
325 bool b);
326 static void SetCurrentValueIndices(CPDFSDK_Document* pDocument,
327 const CFX_WideString& swFieldName,
328 int nControlIndex,
tsepez41a53ad2016-03-28 16:59:30 -0700329 const std::vector<uint32_t>& array);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700330 static void SetDefaultStyle(CPDFSDK_Document* pDocument,
331 const CFX_WideString& swFieldName,
332 int nControlIndex);
333 static void SetDefaultValue(CPDFSDK_Document* pDocument,
334 const CFX_WideString& swFieldName,
335 int nControlIndex,
336 const CFX_WideString& string);
337 static void SetDoNotScroll(CPDFSDK_Document* pDocument,
338 const CFX_WideString& swFieldName,
339 int nControlIndex,
340 bool b);
341 static void SetDisplay(CPDFSDK_Document* pDocument,
342 const CFX_WideString& swFieldName,
343 int nControlIndex,
344 int number);
345 static void SetFillColor(CPDFSDK_Document* pDocument,
346 const CFX_WideString& swFieldName,
347 int nControlIndex,
348 const CPWL_Color& color);
349 static void SetHidden(CPDFSDK_Document* pDocument,
350 const CFX_WideString& swFieldName,
351 int nControlIndex,
352 bool b);
353 static void SetHighlight(CPDFSDK_Document* pDocument,
354 const CFX_WideString& swFieldName,
355 int nControlIndex,
356 const CFX_ByteString& string);
357 static void SetLineWidth(CPDFSDK_Document* pDocument,
358 const CFX_WideString& swFieldName,
359 int nControlIndex,
360 int number);
361 static void SetMultiline(CPDFSDK_Document* pDocument,
362 const CFX_WideString& swFieldName,
363 int nControlIndex,
364 bool b);
365 static void SetMultipleSelection(CPDFSDK_Document* pDocument,
366 const CFX_WideString& swFieldName,
367 int nControlIndex,
368 bool b);
369 static void SetPassword(CPDFSDK_Document* pDocument,
370 const CFX_WideString& swFieldName,
371 int nControlIndex,
372 bool b);
373 static void SetRect(CPDFSDK_Document* pDocument,
374 const CFX_WideString& swFieldName,
375 int nControlIndex,
Tom Sepez281a9ea2016-02-26 14:24:28 -0800376 const CFX_FloatRect& rect);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700377 static void SetRichText(CPDFSDK_Document* pDocument,
378 const CFX_WideString& swFieldName,
379 int nControlIndex,
380 bool b);
381 static void SetRichValue(CPDFSDK_Document* pDocument,
382 const CFX_WideString& swFieldName,
383 int nControlIndex);
384 static void SetRotation(CPDFSDK_Document* pDocument,
385 const CFX_WideString& swFieldName,
386 int nControlIndex,
387 int number);
388 static void SetStrokeColor(CPDFSDK_Document* pDocument,
389 const CFX_WideString& swFieldName,
390 int nControlIndex,
391 const CPWL_Color& color);
392 static void SetStyle(CPDFSDK_Document* pDocument,
393 const CFX_WideString& swFieldName,
394 int nControlIndex,
395 const CFX_ByteString& string);
396 static void SetTextColor(CPDFSDK_Document* pDocument,
397 const CFX_WideString& swFieldName,
398 int nControlIndex,
399 const CPWL_Color& color);
400 static void SetTextFont(CPDFSDK_Document* pDocument,
401 const CFX_WideString& swFieldName,
402 int nControlIndex,
403 const CFX_ByteString& string);
404 static void SetTextSize(CPDFSDK_Document* pDocument,
405 const CFX_WideString& swFieldName,
406 int nControlIndex,
407 int number);
408 static void SetUserName(CPDFSDK_Document* pDocument,
409 const CFX_WideString& swFieldName,
410 int nControlIndex,
411 const CFX_WideString& string);
412 static void SetValue(CPDFSDK_Document* pDocument,
413 const CFX_WideString& swFieldName,
414 int nControlIndex,
tsepez41a53ad2016-03-28 16:59:30 -0700415 const std::vector<CFX_WideString>& strArray);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700416
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700417 static void AddField(CPDFSDK_Document* pDocument,
418 int nPageIndex,
419 int nFieldType,
420 const CFX_WideString& sName,
Tom Sepez281a9ea2016-02-26 14:24:28 -0800421 const CFX_FloatRect& rcCoords);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700422
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700423 static void UpdateFormField(CPDFSDK_Document* pDocument,
424 CPDF_FormField* pFormField,
425 FX_BOOL bChangeMark,
426 FX_BOOL bResetAP,
427 FX_BOOL bRefresh);
428 static void UpdateFormControl(CPDFSDK_Document* pDocument,
429 CPDF_FormControl* pFormControl,
430 FX_BOOL bChangeMark,
431 FX_BOOL bResetAP,
432 FX_BOOL bRefresh);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700433
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700434 static CPDFSDK_Widget* GetWidget(CPDFSDK_Document* pDocument,
435 CPDF_FormControl* pFormControl);
Lei Zhangd88a3642015-11-10 09:38:57 -0800436 static std::vector<CPDF_FormField*> GetFormFields(
437 CPDFSDK_Document* pDocument,
438 const CFX_WideString& csFieldName);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700439
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700440 static void DoDelay(CPDFSDK_Document* pDocument, CJS_DelayData* pData);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700441
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700442 FX_BOOL AttachField(Document* pDocument, const CFX_WideString& csFieldName);
443 void SetDelay(FX_BOOL bDelay);
444 void SetIsolate(v8::Isolate* isolate) { m_isolate = isolate; }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700445
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700446 protected:
447 void ParseFieldName(const std::wstring& strFieldNameParsed,
448 std::wstring& strFieldName,
449 int& iControlNo);
Lei Zhangd88a3642015-11-10 09:38:57 -0800450 std::vector<CPDF_FormField*> GetFormFields(
451 const CFX_WideString& csFieldName) const;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700452 CPDF_FormControl* GetSmartFieldControl(CPDF_FormField* pFormField);
453 FX_BOOL ValueIsOccur(CPDF_FormField* pFormField, CFX_WideString csOptLabel);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700454
tsepez41a53ad2016-03-28 16:59:30 -0700455 void AddDelay_Int(FIELD_PROP prop, int32_t n);
456 void AddDelay_Bool(FIELD_PROP prop, bool b);
457 void AddDelay_String(FIELD_PROP prop, const CFX_ByteString& string);
458 void AddDelay_WideString(FIELD_PROP prop, const CFX_WideString& string);
459 void AddDelay_Rect(FIELD_PROP prop, const CFX_FloatRect& rect);
460 void AddDelay_Color(FIELD_PROP prop, const CPWL_Color& color);
461 void AddDelay_WordArray(FIELD_PROP prop, const std::vector<uint32_t>& array);
462 void AddDelay_WideStringArray(FIELD_PROP prop,
463 const std::vector<CFX_WideString>& array);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700464
465 void DoDelay();
466
467 public:
468 Document* m_pJSDoc;
469 CPDFSDK_Document* m_pDocument;
470 CFX_WideString m_FieldName;
471 int m_nFormControlIndex;
472 FX_BOOL m_bCanSet;
473
474 FX_BOOL m_bDelay;
475 v8::Isolate* m_isolate;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700476};
477
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700478class CJS_Field : public CJS_Object {
479 public:
Lei Zhangd88a3642015-11-10 09:38:57 -0800480 explicit CJS_Field(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {}
Lei Zhang2b1a2d52015-08-14 22:16:22 -0700481 ~CJS_Field(void) override {}
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700482
Tom Sepez33420902015-10-13 15:00:10 -0700483 void InitInstance(IJS_Runtime* pIRuntime) override;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700484
Tom Sepezcd56a7d2015-10-06 11:45:28 -0700485 DECLARE_JS_CLASS();
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700486 JS_STATIC_PROP(alignment, Field);
487 JS_STATIC_PROP(borderStyle, Field);
488 JS_STATIC_PROP(buttonAlignX, Field);
489 JS_STATIC_PROP(buttonAlignY, Field);
490 JS_STATIC_PROP(buttonFitBounds, Field);
491 JS_STATIC_PROP(buttonPosition, Field);
492 JS_STATIC_PROP(buttonScaleHow, Field);
493 JS_STATIC_PROP(buttonScaleWhen, Field);
494 JS_STATIC_PROP(calcOrderIndex, Field);
495 JS_STATIC_PROP(charLimit, Field);
496 JS_STATIC_PROP(comb, Field);
497 JS_STATIC_PROP(commitOnSelChange, Field);
498 JS_STATIC_PROP(currentValueIndices, Field);
499 JS_STATIC_PROP(defaultStyle, Field);
500 JS_STATIC_PROP(defaultValue, Field);
501 JS_STATIC_PROP(doNotScroll, Field);
502 JS_STATIC_PROP(doNotSpellCheck, Field);
503 JS_STATIC_PROP(delay, Field);
504 JS_STATIC_PROP(display, Field);
505 JS_STATIC_PROP(doc, Field);
506 JS_STATIC_PROP(editable, Field);
507 JS_STATIC_PROP(exportValues, Field);
508 JS_STATIC_PROP(fileSelect, Field);
509 JS_STATIC_PROP(fillColor, Field);
510 JS_STATIC_PROP(hidden, Field);
511 JS_STATIC_PROP(highlight, Field);
512 JS_STATIC_PROP(lineWidth, Field);
513 JS_STATIC_PROP(multiline, Field);
514 JS_STATIC_PROP(multipleSelection, Field);
515 JS_STATIC_PROP(name, Field);
516 JS_STATIC_PROP(numItems, Field);
517 JS_STATIC_PROP(page, Field);
518 JS_STATIC_PROP(password, Field);
519 JS_STATIC_PROP(print, Field);
520 JS_STATIC_PROP(radiosInUnison, Field);
521 JS_STATIC_PROP(readonly, Field);
522 JS_STATIC_PROP(rect, Field);
523 JS_STATIC_PROP(required, Field);
524 JS_STATIC_PROP(richText, Field);
525 JS_STATIC_PROP(richValue, Field);
526 JS_STATIC_PROP(rotation, Field);
527 JS_STATIC_PROP(strokeColor, Field);
528 JS_STATIC_PROP(style, Field);
529 JS_STATIC_PROP(submitName, Field);
530 JS_STATIC_PROP(textColor, Field);
531 JS_STATIC_PROP(textFont, Field);
532 JS_STATIC_PROP(textSize, Field);
533 JS_STATIC_PROP(type, Field);
534 JS_STATIC_PROP(userName, Field);
535 JS_STATIC_PROP(value, Field);
536 JS_STATIC_PROP(valueAsString, Field);
537 JS_STATIC_PROP(source, Field);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700538
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700539 JS_STATIC_METHOD(browseForFileToSubmit, Field);
540 JS_STATIC_METHOD(buttonGetCaption, Field);
541 JS_STATIC_METHOD(buttonGetIcon, Field);
542 JS_STATIC_METHOD(buttonImportIcon, Field);
543 JS_STATIC_METHOD(buttonSetCaption, Field);
544 JS_STATIC_METHOD(buttonSetIcon, Field);
545 JS_STATIC_METHOD(checkThisBox, Field);
546 JS_STATIC_METHOD(clearItems, Field);
547 JS_STATIC_METHOD(defaultIsChecked, Field);
548 JS_STATIC_METHOD(deleteItemAt, Field);
549 JS_STATIC_METHOD(getArray, Field);
550 JS_STATIC_METHOD(getItemAt, Field);
551 JS_STATIC_METHOD(getLock, Field);
552 JS_STATIC_METHOD(insertItemAt, Field);
553 JS_STATIC_METHOD(isBoxChecked, Field);
554 JS_STATIC_METHOD(isDefaultChecked, Field);
555 JS_STATIC_METHOD(setAction, Field);
556 JS_STATIC_METHOD(setFocus, Field);
557 JS_STATIC_METHOD(setItems, Field);
558 JS_STATIC_METHOD(setLock, Field);
559 JS_STATIC_METHOD(signatureGetModifications, Field);
560 JS_STATIC_METHOD(signatureGetSeedValue, Field);
561 JS_STATIC_METHOD(signatureInfo, Field);
562 JS_STATIC_METHOD(signatureSetSeedValue, Field);
563 JS_STATIC_METHOD(signatureSign, Field);
564 JS_STATIC_METHOD(signatureValidate, Field);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700565};
566
Dan Sinclairf766ad22016-03-14 13:51:24 -0400567#endif // FPDFSDK_JAVASCRIPT_FIELD_H_