blob: e5597801544d7dca8970622baffd66a6e81dff31 [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"
dsinclairf34518b2016-09-13 12:03:48 -070014#include "fpdfsdk/include/cpdfsdk_document.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 Sepezba038bc2015-10-08 12:03:00 -070080 FX_BOOL alignment(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
81 FX_BOOL borderStyle(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -070082 CJS_PropValue& vp,
83 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -070084 FX_BOOL buttonAlignX(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -070085 CJS_PropValue& vp,
86 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -070087 FX_BOOL buttonAlignY(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -070088 CJS_PropValue& vp,
89 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -070090 FX_BOOL buttonFitBounds(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -070091 CJS_PropValue& vp,
92 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -070093 FX_BOOL buttonPosition(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -070094 CJS_PropValue& vp,
95 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -070096 FX_BOOL buttonScaleHow(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 buttonScaleWhen(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 calcOrderIndex(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 charLimit(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
106 FX_BOOL comb(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
107 FX_BOOL commitOnSelChange(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700108 CJS_PropValue& vp,
109 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700110 FX_BOOL currentValueIndices(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700111 CJS_PropValue& vp,
112 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700113 FX_BOOL defaultStyle(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700114 CJS_PropValue& vp,
115 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700116 FX_BOOL defaultValue(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700117 CJS_PropValue& vp,
118 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700119 FX_BOOL doNotScroll(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700120 CJS_PropValue& vp,
121 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700122 FX_BOOL doNotSpellCheck(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 delay(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
126 FX_BOOL display(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
127 FX_BOOL doc(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
128 FX_BOOL editable(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
129 FX_BOOL exportValues(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700130 CJS_PropValue& vp,
131 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700132 FX_BOOL fileSelect(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700133 CJS_PropValue& vp,
134 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700135 FX_BOOL fillColor(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
136 FX_BOOL hidden(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
137 FX_BOOL highlight(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
138 FX_BOOL lineWidth(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
139 FX_BOOL multiline(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
140 FX_BOOL multipleSelection(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700141 CJS_PropValue& vp,
142 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700143 FX_BOOL name(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
144 FX_BOOL numItems(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
145 FX_BOOL page(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
146 FX_BOOL password(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
147 FX_BOOL print(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
148 FX_BOOL radiosInUnison(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700149 CJS_PropValue& vp,
150 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700151 FX_BOOL readonly(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
152 FX_BOOL rect(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
153 FX_BOOL required(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
154 FX_BOOL richText(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
155 FX_BOOL richValue(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
156 FX_BOOL rotation(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
157 FX_BOOL strokeColor(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700158 CJS_PropValue& vp,
159 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700160 FX_BOOL style(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
161 FX_BOOL submitName(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700162 CJS_PropValue& vp,
163 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700164 FX_BOOL textColor(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
165 FX_BOOL textFont(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
166 FX_BOOL textSize(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
167 FX_BOOL type(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
168 FX_BOOL userName(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
169 FX_BOOL value(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
170 FX_BOOL valueAsString(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700171 CJS_PropValue& vp,
172 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700173 FX_BOOL source(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700174
Tom Sepezba038bc2015-10-08 12:03:00 -0700175 FX_BOOL browseForFileToSubmit(IJS_Context* cc,
Lei Zhang945fdb72015-11-11 10:18:16 -0800176 const std::vector<CJS_Value>& params,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700177 CJS_Value& vRet,
178 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700179 FX_BOOL buttonGetCaption(IJS_Context* cc,
Lei Zhang945fdb72015-11-11 10:18:16 -0800180 const std::vector<CJS_Value>& params,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700181 CJS_Value& vRet,
182 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700183 FX_BOOL buttonGetIcon(IJS_Context* cc,
Lei Zhang945fdb72015-11-11 10:18:16 -0800184 const std::vector<CJS_Value>& params,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700185 CJS_Value& vRet,
186 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700187 FX_BOOL buttonImportIcon(IJS_Context* cc,
Lei Zhang945fdb72015-11-11 10:18:16 -0800188 const std::vector<CJS_Value>& params,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700189 CJS_Value& vRet,
190 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700191 FX_BOOL buttonSetCaption(IJS_Context* cc,
Lei Zhang945fdb72015-11-11 10:18:16 -0800192 const std::vector<CJS_Value>& params,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700193 CJS_Value& vRet,
194 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700195 FX_BOOL buttonSetIcon(IJS_Context* cc,
Lei Zhang945fdb72015-11-11 10:18:16 -0800196 const std::vector<CJS_Value>& params,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700197 CJS_Value& vRet,
198 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700199 FX_BOOL checkThisBox(IJS_Context* cc,
Lei Zhang945fdb72015-11-11 10:18:16 -0800200 const std::vector<CJS_Value>& params,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700201 CJS_Value& vRet,
202 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700203 FX_BOOL clearItems(IJS_Context* cc,
Lei Zhang945fdb72015-11-11 10:18:16 -0800204 const std::vector<CJS_Value>& params,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700205 CJS_Value& vRet,
206 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700207 FX_BOOL defaultIsChecked(IJS_Context* cc,
Lei Zhang945fdb72015-11-11 10:18:16 -0800208 const std::vector<CJS_Value>& params,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700209 CJS_Value& vRet,
210 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700211 FX_BOOL deleteItemAt(IJS_Context* cc,
Lei Zhang945fdb72015-11-11 10:18:16 -0800212 const std::vector<CJS_Value>& params,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700213 CJS_Value& vRet,
214 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700215 FX_BOOL getArray(IJS_Context* 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 Sepezba038bc2015-10-08 12:03:00 -0700219 FX_BOOL getItemAt(IJS_Context* 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 Sepezba038bc2015-10-08 12:03:00 -0700223 FX_BOOL getLock(IJS_Context* 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 Sepezba038bc2015-10-08 12:03:00 -0700227 FX_BOOL insertItemAt(IJS_Context* 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 Sepezba038bc2015-10-08 12:03:00 -0700231 FX_BOOL isBoxChecked(IJS_Context* cc,
Lei Zhang945fdb72015-11-11 10:18:16 -0800232 const std::vector<CJS_Value>& params,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700233 CJS_Value& vRet,
234 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700235 FX_BOOL isDefaultChecked(IJS_Context* cc,
Lei Zhang945fdb72015-11-11 10:18:16 -0800236 const std::vector<CJS_Value>& params,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700237 CJS_Value& vRet,
238 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700239 FX_BOOL setAction(IJS_Context* cc,
Lei Zhang945fdb72015-11-11 10:18:16 -0800240 const std::vector<CJS_Value>& params,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700241 CJS_Value& vRet,
242 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700243 FX_BOOL setFocus(IJS_Context* cc,
Lei Zhang945fdb72015-11-11 10:18:16 -0800244 const std::vector<CJS_Value>& params,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700245 CJS_Value& vRet,
246 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700247 FX_BOOL setItems(IJS_Context* cc,
Lei Zhang945fdb72015-11-11 10:18:16 -0800248 const std::vector<CJS_Value>& params,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700249 CJS_Value& vRet,
250 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700251 FX_BOOL setLock(IJS_Context* cc,
Lei Zhang945fdb72015-11-11 10:18:16 -0800252 const std::vector<CJS_Value>& params,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700253 CJS_Value& vRet,
254 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700255 FX_BOOL signatureGetModifications(IJS_Context* cc,
Lei Zhang945fdb72015-11-11 10:18:16 -0800256 const std::vector<CJS_Value>& params,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700257 CJS_Value& vRet,
258 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700259 FX_BOOL signatureGetSeedValue(IJS_Context* cc,
Lei Zhang945fdb72015-11-11 10:18:16 -0800260 const std::vector<CJS_Value>& params,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700261 CJS_Value& vRet,
262 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700263 FX_BOOL signatureInfo(IJS_Context* cc,
Lei Zhang945fdb72015-11-11 10:18:16 -0800264 const std::vector<CJS_Value>& params,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700265 CJS_Value& vRet,
266 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700267 FX_BOOL signatureSetSeedValue(IJS_Context* cc,
Lei Zhang945fdb72015-11-11 10:18:16 -0800268 const std::vector<CJS_Value>& params,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700269 CJS_Value& vRet,
270 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700271 FX_BOOL signatureSign(IJS_Context* cc,
Lei Zhang945fdb72015-11-11 10:18:16 -0800272 const std::vector<CJS_Value>& params,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700273 CJS_Value& vRet,
274 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700275 FX_BOOL signatureValidate(IJS_Context* cc,
Lei Zhang945fdb72015-11-11 10:18:16 -0800276 const std::vector<CJS_Value>& params,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700277 CJS_Value& vRet,
278 CFX_WideString& sError);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700279
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700280 static void SetAlignment(CPDFSDK_Document* pDocument,
281 const CFX_WideString& swFieldName,
282 int nControlIndex,
283 const CFX_ByteString& string);
284 static void SetBorderStyle(CPDFSDK_Document* pDocument,
285 const CFX_WideString& swFieldName,
286 int nControlIndex,
287 const CFX_ByteString& string);
288 static void SetButtonAlignX(CPDFSDK_Document* pDocument,
289 const CFX_WideString& swFieldName,
290 int nControlIndex,
291 int number);
292 static void SetButtonAlignY(CPDFSDK_Document* pDocument,
293 const CFX_WideString& swFieldName,
294 int nControlIndex,
295 int number);
296 static void SetButtonFitBounds(CPDFSDK_Document* pDocument,
297 const CFX_WideString& swFieldName,
298 int nControlIndex,
299 bool b);
300 static void SetButtonPosition(CPDFSDK_Document* pDocument,
301 const CFX_WideString& swFieldName,
302 int nControlIndex,
303 int number);
304 static void SetButtonScaleHow(CPDFSDK_Document* pDocument,
305 const CFX_WideString& swFieldName,
306 int nControlIndex,
307 int number);
308 static void SetButtonScaleWhen(CPDFSDK_Document* pDocument,
309 const CFX_WideString& swFieldName,
310 int nControlIndex,
311 int number);
312 static void SetCalcOrderIndex(CPDFSDK_Document* pDocument,
313 const CFX_WideString& swFieldName,
314 int nControlIndex,
315 int number);
316 static void SetCharLimit(CPDFSDK_Document* pDocument,
317 const CFX_WideString& swFieldName,
318 int nControlIndex,
319 int number);
320 static void SetComb(CPDFSDK_Document* pDocument,
321 const CFX_WideString& swFieldName,
322 int nControlIndex,
323 bool b);
324 static void SetCommitOnSelChange(CPDFSDK_Document* pDocument,
325 const CFX_WideString& swFieldName,
326 int nControlIndex,
327 bool b);
328 static void SetCurrentValueIndices(CPDFSDK_Document* pDocument,
329 const CFX_WideString& swFieldName,
330 int nControlIndex,
tsepez41a53ad2016-03-28 16:59:30 -0700331 const std::vector<uint32_t>& array);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700332 static void SetDefaultStyle(CPDFSDK_Document* pDocument,
333 const CFX_WideString& swFieldName,
334 int nControlIndex);
335 static void SetDefaultValue(CPDFSDK_Document* pDocument,
336 const CFX_WideString& swFieldName,
337 int nControlIndex,
338 const CFX_WideString& string);
339 static void SetDoNotScroll(CPDFSDK_Document* pDocument,
340 const CFX_WideString& swFieldName,
341 int nControlIndex,
342 bool b);
343 static void SetDisplay(CPDFSDK_Document* pDocument,
344 const CFX_WideString& swFieldName,
345 int nControlIndex,
346 int number);
347 static void SetFillColor(CPDFSDK_Document* pDocument,
348 const CFX_WideString& swFieldName,
349 int nControlIndex,
350 const CPWL_Color& color);
351 static void SetHidden(CPDFSDK_Document* pDocument,
352 const CFX_WideString& swFieldName,
353 int nControlIndex,
354 bool b);
355 static void SetHighlight(CPDFSDK_Document* pDocument,
356 const CFX_WideString& swFieldName,
357 int nControlIndex,
358 const CFX_ByteString& string);
359 static void SetLineWidth(CPDFSDK_Document* pDocument,
360 const CFX_WideString& swFieldName,
361 int nControlIndex,
362 int number);
363 static void SetMultiline(CPDFSDK_Document* pDocument,
364 const CFX_WideString& swFieldName,
365 int nControlIndex,
366 bool b);
367 static void SetMultipleSelection(CPDFSDK_Document* pDocument,
368 const CFX_WideString& swFieldName,
369 int nControlIndex,
370 bool b);
371 static void SetPassword(CPDFSDK_Document* pDocument,
372 const CFX_WideString& swFieldName,
373 int nControlIndex,
374 bool b);
375 static void SetRect(CPDFSDK_Document* pDocument,
376 const CFX_WideString& swFieldName,
377 int nControlIndex,
Tom Sepez281a9ea2016-02-26 14:24:28 -0800378 const CFX_FloatRect& rect);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700379 static void SetRotation(CPDFSDK_Document* pDocument,
380 const CFX_WideString& swFieldName,
381 int nControlIndex,
382 int number);
383 static void SetStrokeColor(CPDFSDK_Document* pDocument,
384 const CFX_WideString& swFieldName,
385 int nControlIndex,
386 const CPWL_Color& color);
387 static void SetStyle(CPDFSDK_Document* pDocument,
388 const CFX_WideString& swFieldName,
389 int nControlIndex,
390 const CFX_ByteString& string);
391 static void SetTextColor(CPDFSDK_Document* pDocument,
392 const CFX_WideString& swFieldName,
393 int nControlIndex,
394 const CPWL_Color& color);
395 static void SetTextFont(CPDFSDK_Document* pDocument,
396 const CFX_WideString& swFieldName,
397 int nControlIndex,
398 const CFX_ByteString& string);
399 static void SetTextSize(CPDFSDK_Document* pDocument,
400 const CFX_WideString& swFieldName,
401 int nControlIndex,
402 int number);
403 static void SetUserName(CPDFSDK_Document* pDocument,
404 const CFX_WideString& swFieldName,
405 int nControlIndex,
406 const CFX_WideString& string);
407 static void SetValue(CPDFSDK_Document* pDocument,
408 const CFX_WideString& swFieldName,
409 int nControlIndex,
tsepez41a53ad2016-03-28 16:59:30 -0700410 const std::vector<CFX_WideString>& strArray);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700411
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700412 static void AddField(CPDFSDK_Document* pDocument,
413 int nPageIndex,
414 int nFieldType,
415 const CFX_WideString& sName,
Tom Sepez281a9ea2016-02-26 14:24:28 -0800416 const CFX_FloatRect& rcCoords);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700417
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700418 static void UpdateFormField(CPDFSDK_Document* pDocument,
419 CPDF_FormField* pFormField,
420 FX_BOOL bChangeMark,
421 FX_BOOL bResetAP,
422 FX_BOOL bRefresh);
423 static void UpdateFormControl(CPDFSDK_Document* pDocument,
424 CPDF_FormControl* pFormControl,
425 FX_BOOL bChangeMark,
426 FX_BOOL bResetAP,
427 FX_BOOL bRefresh);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700428
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700429 static CPDFSDK_Widget* GetWidget(CPDFSDK_Document* pDocument,
dsinclairef523dd2016-08-15 13:10:03 -0700430 CPDF_FormControl* pFormControl,
431 bool createIfNeeded);
Lei Zhangd88a3642015-11-10 09:38:57 -0800432 static std::vector<CPDF_FormField*> GetFormFields(
433 CPDFSDK_Document* pDocument,
434 const CFX_WideString& csFieldName);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700435
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700436 static void DoDelay(CPDFSDK_Document* pDocument, CJS_DelayData* pData);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700437
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700438 FX_BOOL AttachField(Document* pDocument, const CFX_WideString& csFieldName);
439 void SetDelay(FX_BOOL bDelay);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700440
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700441 protected:
442 void ParseFieldName(const std::wstring& strFieldNameParsed,
443 std::wstring& strFieldName,
444 int& iControlNo);
Lei Zhangd88a3642015-11-10 09:38:57 -0800445 std::vector<CPDF_FormField*> GetFormFields(
446 const CFX_WideString& csFieldName) const;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700447 CPDF_FormControl* GetSmartFieldControl(CPDF_FormField* pFormField);
448 FX_BOOL ValueIsOccur(CPDF_FormField* pFormField, CFX_WideString csOptLabel);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700449
tsepez41a53ad2016-03-28 16:59:30 -0700450 void AddDelay_Int(FIELD_PROP prop, int32_t n);
451 void AddDelay_Bool(FIELD_PROP prop, bool b);
452 void AddDelay_String(FIELD_PROP prop, const CFX_ByteString& string);
453 void AddDelay_WideString(FIELD_PROP prop, const CFX_WideString& string);
454 void AddDelay_Rect(FIELD_PROP prop, const CFX_FloatRect& rect);
455 void AddDelay_Color(FIELD_PROP prop, const CPWL_Color& color);
456 void AddDelay_WordArray(FIELD_PROP prop, const std::vector<uint32_t>& array);
457 void AddDelay_WideStringArray(FIELD_PROP prop,
458 const std::vector<CFX_WideString>& array);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700459
460 void DoDelay();
461
462 public:
463 Document* m_pJSDoc;
tsepez56cf5192016-09-12 11:59:30 -0700464 CPDFSDK_Document::ObservedPtr m_pDocument;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700465 CFX_WideString m_FieldName;
466 int m_nFormControlIndex;
467 FX_BOOL m_bCanSet;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700468 FX_BOOL m_bDelay;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700469};
470
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700471class CJS_Field : public CJS_Object {
472 public:
Lei Zhangd88a3642015-11-10 09:38:57 -0800473 explicit CJS_Field(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {}
weilibff506d2016-06-20 11:37:05 -0700474 ~CJS_Field() override {}
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700475
Tom Sepez33420902015-10-13 15:00:10 -0700476 void InitInstance(IJS_Runtime* pIRuntime) override;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700477
Tom Sepezcd56a7d2015-10-06 11:45:28 -0700478 DECLARE_JS_CLASS();
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700479 JS_STATIC_PROP(alignment, Field);
480 JS_STATIC_PROP(borderStyle, Field);
481 JS_STATIC_PROP(buttonAlignX, Field);
482 JS_STATIC_PROP(buttonAlignY, Field);
483 JS_STATIC_PROP(buttonFitBounds, Field);
484 JS_STATIC_PROP(buttonPosition, Field);
485 JS_STATIC_PROP(buttonScaleHow, Field);
486 JS_STATIC_PROP(buttonScaleWhen, Field);
487 JS_STATIC_PROP(calcOrderIndex, Field);
488 JS_STATIC_PROP(charLimit, Field);
489 JS_STATIC_PROP(comb, Field);
490 JS_STATIC_PROP(commitOnSelChange, Field);
491 JS_STATIC_PROP(currentValueIndices, Field);
492 JS_STATIC_PROP(defaultStyle, Field);
493 JS_STATIC_PROP(defaultValue, Field);
494 JS_STATIC_PROP(doNotScroll, Field);
495 JS_STATIC_PROP(doNotSpellCheck, Field);
496 JS_STATIC_PROP(delay, Field);
497 JS_STATIC_PROP(display, Field);
498 JS_STATIC_PROP(doc, Field);
499 JS_STATIC_PROP(editable, Field);
500 JS_STATIC_PROP(exportValues, Field);
501 JS_STATIC_PROP(fileSelect, Field);
502 JS_STATIC_PROP(fillColor, Field);
503 JS_STATIC_PROP(hidden, Field);
504 JS_STATIC_PROP(highlight, Field);
505 JS_STATIC_PROP(lineWidth, Field);
506 JS_STATIC_PROP(multiline, Field);
507 JS_STATIC_PROP(multipleSelection, Field);
508 JS_STATIC_PROP(name, Field);
509 JS_STATIC_PROP(numItems, Field);
510 JS_STATIC_PROP(page, Field);
511 JS_STATIC_PROP(password, Field);
512 JS_STATIC_PROP(print, Field);
513 JS_STATIC_PROP(radiosInUnison, Field);
514 JS_STATIC_PROP(readonly, Field);
515 JS_STATIC_PROP(rect, Field);
516 JS_STATIC_PROP(required, Field);
517 JS_STATIC_PROP(richText, Field);
518 JS_STATIC_PROP(richValue, Field);
519 JS_STATIC_PROP(rotation, Field);
520 JS_STATIC_PROP(strokeColor, Field);
521 JS_STATIC_PROP(style, Field);
522 JS_STATIC_PROP(submitName, Field);
523 JS_STATIC_PROP(textColor, Field);
524 JS_STATIC_PROP(textFont, Field);
525 JS_STATIC_PROP(textSize, Field);
526 JS_STATIC_PROP(type, Field);
527 JS_STATIC_PROP(userName, Field);
528 JS_STATIC_PROP(value, Field);
529 JS_STATIC_PROP(valueAsString, Field);
530 JS_STATIC_PROP(source, Field);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700531
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700532 JS_STATIC_METHOD(browseForFileToSubmit, Field);
533 JS_STATIC_METHOD(buttonGetCaption, Field);
534 JS_STATIC_METHOD(buttonGetIcon, Field);
535 JS_STATIC_METHOD(buttonImportIcon, Field);
536 JS_STATIC_METHOD(buttonSetCaption, Field);
537 JS_STATIC_METHOD(buttonSetIcon, Field);
538 JS_STATIC_METHOD(checkThisBox, Field);
539 JS_STATIC_METHOD(clearItems, Field);
540 JS_STATIC_METHOD(defaultIsChecked, Field);
541 JS_STATIC_METHOD(deleteItemAt, Field);
542 JS_STATIC_METHOD(getArray, Field);
543 JS_STATIC_METHOD(getItemAt, Field);
544 JS_STATIC_METHOD(getLock, Field);
545 JS_STATIC_METHOD(insertItemAt, Field);
546 JS_STATIC_METHOD(isBoxChecked, Field);
547 JS_STATIC_METHOD(isDefaultChecked, Field);
548 JS_STATIC_METHOD(setAction, Field);
549 JS_STATIC_METHOD(setFocus, Field);
550 JS_STATIC_METHOD(setItems, Field);
551 JS_STATIC_METHOD(setLock, Field);
552 JS_STATIC_METHOD(signatureGetModifications, Field);
553 JS_STATIC_METHOD(signatureGetSeedValue, Field);
554 JS_STATIC_METHOD(signatureInfo, Field);
555 JS_STATIC_METHOD(signatureSetSeedValue, Field);
556 JS_STATIC_METHOD(signatureSign, Field);
557 JS_STATIC_METHOD(signatureValidate, Field);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700558};
559
Dan Sinclairf766ad22016-03-14 13:51:24 -0400560#endif // FPDFSDK_JAVASCRIPT_FIELD_H_