blob: 171b081669ff963bc10bc616bce7f8c282c936b4 [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
Lei Zhangbde53d22015-11-12 22:21:30 -080013#include "fpdfsdk/include/pdfwindow/PWL_Wnd.h" // For CPWL_Color.
Dan Sinclairf766ad22016-03-14 13:51:24 -040014#include "fpdfsdk/javascript/JS_Define.h"
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 -070056class CJS_WideStringArray {
57 public:
58 CJS_WideStringArray() {}
59 virtual ~CJS_WideStringArray() {
60 for (int i = 0, sz = m_Data.GetSize(); i < sz; i++)
61 delete m_Data.GetAt(i);
62 m_Data.RemoveAll();
63 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070064
Nico Weber9d8ec5a2015-08-04 13:00:21 -070065 void Add(const CFX_WideString& string) {
66 m_Data.Add(new CFX_WideString(string));
67 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070068
Nico Weber9d8ec5a2015-08-04 13:00:21 -070069 int GetSize() const { return m_Data.GetSize(); }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070070
Nico Weber9d8ec5a2015-08-04 13:00:21 -070071 CFX_WideString GetAt(int i) const { return *m_Data.GetAt(i); }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070072
Nico Weber9d8ec5a2015-08-04 13:00:21 -070073 private:
74 CFX_ArrayTemplate<CFX_WideString*> m_Data;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070075};
76
Nico Weber9d8ec5a2015-08-04 13:00:21 -070077struct CJS_DelayData {
78 CFX_WideString sFieldName;
79 int nControlIndex;
80 enum FIELD_PROP eProp;
81 int32_t num;
82 bool b;
83 CFX_ByteString string;
84 CFX_WideString widestring;
Tom Sepez281a9ea2016-02-26 14:24:28 -080085 CFX_FloatRect rect;
Nico Weber9d8ec5a2015-08-04 13:00:21 -070086 CPWL_Color color;
87 CFX_DWordArray wordarray;
88 CJS_WideStringArray widestringarray;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070089};
90
Nico Weber9d8ec5a2015-08-04 13:00:21 -070091class Field : public CJS_EmbedObj {
92 public:
Lei Zhangd88a3642015-11-10 09:38:57 -080093 explicit Field(CJS_Object* pJSObject);
Lei Zhang2b1a2d52015-08-14 22:16:22 -070094 ~Field() override;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070095
Tom Sepezba038bc2015-10-08 12:03:00 -070096 FX_BOOL alignment(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
97 FX_BOOL borderStyle(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 buttonAlignX(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 buttonAlignY(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700104 CJS_PropValue& vp,
105 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700106 FX_BOOL buttonFitBounds(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700107 CJS_PropValue& vp,
108 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700109 FX_BOOL buttonPosition(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700110 CJS_PropValue& vp,
111 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700112 FX_BOOL buttonScaleHow(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700113 CJS_PropValue& vp,
114 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700115 FX_BOOL buttonScaleWhen(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700116 CJS_PropValue& vp,
117 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700118 FX_BOOL calcOrderIndex(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700119 CJS_PropValue& vp,
120 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700121 FX_BOOL charLimit(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
122 FX_BOOL comb(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
123 FX_BOOL commitOnSelChange(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700124 CJS_PropValue& vp,
125 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700126 FX_BOOL currentValueIndices(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700127 CJS_PropValue& vp,
128 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700129 FX_BOOL defaultStyle(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 defaultValue(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 doNotScroll(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700136 CJS_PropValue& vp,
137 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700138 FX_BOOL doNotSpellCheck(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 delay(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
142 FX_BOOL display(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
143 FX_BOOL doc(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
144 FX_BOOL editable(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
145 FX_BOOL exportValues(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700146 CJS_PropValue& vp,
147 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700148 FX_BOOL fileSelect(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 fillColor(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
152 FX_BOOL hidden(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
153 FX_BOOL highlight(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
154 FX_BOOL lineWidth(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
155 FX_BOOL multiline(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
156 FX_BOOL multipleSelection(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700157 CJS_PropValue& vp,
158 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700159 FX_BOOL name(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
160 FX_BOOL numItems(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
161 FX_BOOL page(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
162 FX_BOOL password(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
163 FX_BOOL print(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
164 FX_BOOL radiosInUnison(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700165 CJS_PropValue& vp,
166 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700167 FX_BOOL readonly(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
168 FX_BOOL rect(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
169 FX_BOOL required(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
170 FX_BOOL richText(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
171 FX_BOOL richValue(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
172 FX_BOOL rotation(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
173 FX_BOOL strokeColor(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700174 CJS_PropValue& vp,
175 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700176 FX_BOOL style(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
177 FX_BOOL submitName(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700178 CJS_PropValue& vp,
179 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700180 FX_BOOL textColor(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
181 FX_BOOL textFont(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
182 FX_BOOL textSize(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
183 FX_BOOL type(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
184 FX_BOOL userName(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
185 FX_BOOL value(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
186 FX_BOOL valueAsString(IJS_Context* cc,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700187 CJS_PropValue& vp,
188 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700189 FX_BOOL source(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700190
Tom Sepezba038bc2015-10-08 12:03:00 -0700191 FX_BOOL browseForFileToSubmit(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 buttonGetCaption(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 buttonGetIcon(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 buttonImportIcon(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 buttonSetCaption(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 buttonSetIcon(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 checkThisBox(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 clearItems(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 defaultIsChecked(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 deleteItemAt(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 getArray(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 getItemAt(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 getLock(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 insertItemAt(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 isBoxChecked(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 isDefaultChecked(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 setAction(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 setFocus(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 setItems(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 setLock(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 signatureGetModifications(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 signatureGetSeedValue(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);
Tom Sepezba038bc2015-10-08 12:03:00 -0700279 FX_BOOL signatureInfo(IJS_Context* cc,
Lei Zhang945fdb72015-11-11 10:18:16 -0800280 const std::vector<CJS_Value>& params,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700281 CJS_Value& vRet,
282 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700283 FX_BOOL signatureSetSeedValue(IJS_Context* cc,
Lei Zhang945fdb72015-11-11 10:18:16 -0800284 const std::vector<CJS_Value>& params,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700285 CJS_Value& vRet,
286 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700287 FX_BOOL signatureSign(IJS_Context* cc,
Lei Zhang945fdb72015-11-11 10:18:16 -0800288 const std::vector<CJS_Value>& params,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700289 CJS_Value& vRet,
290 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700291 FX_BOOL signatureValidate(IJS_Context* cc,
Lei Zhang945fdb72015-11-11 10:18:16 -0800292 const std::vector<CJS_Value>& params,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700293 CJS_Value& vRet,
294 CFX_WideString& sError);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700295
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700296 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,
Tom Sepez281a9ea2016-02-26 14:24:28 -0800394 const CFX_FloatRect& rect);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700395 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 static void AddField(CPDFSDK_Document* pDocument,
436 int nPageIndex,
437 int nFieldType,
438 const CFX_WideString& sName,
Tom Sepez281a9ea2016-02-26 14:24:28 -0800439 const CFX_FloatRect& rcCoords);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700440
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700441 static void UpdateFormField(CPDFSDK_Document* pDocument,
442 CPDF_FormField* pFormField,
443 FX_BOOL bChangeMark,
444 FX_BOOL bResetAP,
445 FX_BOOL bRefresh);
446 static void UpdateFormControl(CPDFSDK_Document* pDocument,
447 CPDF_FormControl* pFormControl,
448 FX_BOOL bChangeMark,
449 FX_BOOL bResetAP,
450 FX_BOOL bRefresh);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700451
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700452 static CPDFSDK_Widget* GetWidget(CPDFSDK_Document* pDocument,
453 CPDF_FormControl* pFormControl);
Lei Zhangd88a3642015-11-10 09:38:57 -0800454 static std::vector<CPDF_FormField*> GetFormFields(
455 CPDFSDK_Document* pDocument,
456 const CFX_WideString& csFieldName);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700457
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700458 static void DoDelay(CPDFSDK_Document* pDocument, CJS_DelayData* pData);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700459
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700460 FX_BOOL AttachField(Document* pDocument, const CFX_WideString& csFieldName);
461 void SetDelay(FX_BOOL bDelay);
462 void SetIsolate(v8::Isolate* isolate) { m_isolate = isolate; }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700463
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700464 protected:
465 void ParseFieldName(const std::wstring& strFieldNameParsed,
466 std::wstring& strFieldName,
467 int& iControlNo);
Lei Zhangd88a3642015-11-10 09:38:57 -0800468 std::vector<CPDF_FormField*> GetFormFields(
469 const CFX_WideString& csFieldName) const;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700470 CPDF_FormControl* GetSmartFieldControl(CPDF_FormField* pFormField);
471 FX_BOOL ValueIsOccur(CPDF_FormField* pFormField, CFX_WideString csOptLabel);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700472
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700473 void AddDelay_Int(enum FIELD_PROP prop, int32_t n);
474 void AddDelay_Bool(enum FIELD_PROP prop, bool b);
475 void AddDelay_String(enum FIELD_PROP prop, const CFX_ByteString& string);
476 void AddDelay_WideString(enum FIELD_PROP prop, const CFX_WideString& string);
Tom Sepez281a9ea2016-02-26 14:24:28 -0800477 void AddDelay_Rect(enum FIELD_PROP prop, const CFX_FloatRect& rect);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700478 void AddDelay_Color(enum FIELD_PROP prop, const CPWL_Color& color);
479 void AddDelay_WordArray(enum FIELD_PROP prop, const CFX_DWordArray& array);
480 void AddDelay_WideStringArray(enum FIELD_PROP prop,
481 const CJS_WideStringArray& array);
482
483 void DoDelay();
484
485 public:
486 Document* m_pJSDoc;
487 CPDFSDK_Document* m_pDocument;
488 CFX_WideString m_FieldName;
489 int m_nFormControlIndex;
490 FX_BOOL m_bCanSet;
491
492 FX_BOOL m_bDelay;
493 v8::Isolate* m_isolate;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700494};
495
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700496class CJS_Field : public CJS_Object {
497 public:
Lei Zhangd88a3642015-11-10 09:38:57 -0800498 explicit CJS_Field(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {}
Lei Zhang2b1a2d52015-08-14 22:16:22 -0700499 ~CJS_Field(void) override {}
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700500
Tom Sepez33420902015-10-13 15:00:10 -0700501 void InitInstance(IJS_Runtime* pIRuntime) override;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700502
Tom Sepezcd56a7d2015-10-06 11:45:28 -0700503 DECLARE_JS_CLASS();
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700504 JS_STATIC_PROP(alignment, Field);
505 JS_STATIC_PROP(borderStyle, Field);
506 JS_STATIC_PROP(buttonAlignX, Field);
507 JS_STATIC_PROP(buttonAlignY, Field);
508 JS_STATIC_PROP(buttonFitBounds, Field);
509 JS_STATIC_PROP(buttonPosition, Field);
510 JS_STATIC_PROP(buttonScaleHow, Field);
511 JS_STATIC_PROP(buttonScaleWhen, Field);
512 JS_STATIC_PROP(calcOrderIndex, Field);
513 JS_STATIC_PROP(charLimit, Field);
514 JS_STATIC_PROP(comb, Field);
515 JS_STATIC_PROP(commitOnSelChange, Field);
516 JS_STATIC_PROP(currentValueIndices, Field);
517 JS_STATIC_PROP(defaultStyle, Field);
518 JS_STATIC_PROP(defaultValue, Field);
519 JS_STATIC_PROP(doNotScroll, Field);
520 JS_STATIC_PROP(doNotSpellCheck, Field);
521 JS_STATIC_PROP(delay, Field);
522 JS_STATIC_PROP(display, Field);
523 JS_STATIC_PROP(doc, Field);
524 JS_STATIC_PROP(editable, Field);
525 JS_STATIC_PROP(exportValues, Field);
526 JS_STATIC_PROP(fileSelect, Field);
527 JS_STATIC_PROP(fillColor, Field);
528 JS_STATIC_PROP(hidden, Field);
529 JS_STATIC_PROP(highlight, Field);
530 JS_STATIC_PROP(lineWidth, Field);
531 JS_STATIC_PROP(multiline, Field);
532 JS_STATIC_PROP(multipleSelection, Field);
533 JS_STATIC_PROP(name, Field);
534 JS_STATIC_PROP(numItems, Field);
535 JS_STATIC_PROP(page, Field);
536 JS_STATIC_PROP(password, Field);
537 JS_STATIC_PROP(print, Field);
538 JS_STATIC_PROP(radiosInUnison, Field);
539 JS_STATIC_PROP(readonly, Field);
540 JS_STATIC_PROP(rect, Field);
541 JS_STATIC_PROP(required, Field);
542 JS_STATIC_PROP(richText, Field);
543 JS_STATIC_PROP(richValue, Field);
544 JS_STATIC_PROP(rotation, Field);
545 JS_STATIC_PROP(strokeColor, Field);
546 JS_STATIC_PROP(style, Field);
547 JS_STATIC_PROP(submitName, Field);
548 JS_STATIC_PROP(textColor, Field);
549 JS_STATIC_PROP(textFont, Field);
550 JS_STATIC_PROP(textSize, Field);
551 JS_STATIC_PROP(type, Field);
552 JS_STATIC_PROP(userName, Field);
553 JS_STATIC_PROP(value, Field);
554 JS_STATIC_PROP(valueAsString, Field);
555 JS_STATIC_PROP(source, Field);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700556
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700557 JS_STATIC_METHOD(browseForFileToSubmit, Field);
558 JS_STATIC_METHOD(buttonGetCaption, Field);
559 JS_STATIC_METHOD(buttonGetIcon, Field);
560 JS_STATIC_METHOD(buttonImportIcon, Field);
561 JS_STATIC_METHOD(buttonSetCaption, Field);
562 JS_STATIC_METHOD(buttonSetIcon, Field);
563 JS_STATIC_METHOD(checkThisBox, Field);
564 JS_STATIC_METHOD(clearItems, Field);
565 JS_STATIC_METHOD(defaultIsChecked, Field);
566 JS_STATIC_METHOD(deleteItemAt, Field);
567 JS_STATIC_METHOD(getArray, Field);
568 JS_STATIC_METHOD(getItemAt, Field);
569 JS_STATIC_METHOD(getLock, Field);
570 JS_STATIC_METHOD(insertItemAt, Field);
571 JS_STATIC_METHOD(isBoxChecked, Field);
572 JS_STATIC_METHOD(isDefaultChecked, Field);
573 JS_STATIC_METHOD(setAction, Field);
574 JS_STATIC_METHOD(setFocus, Field);
575 JS_STATIC_METHOD(setItems, Field);
576 JS_STATIC_METHOD(setLock, Field);
577 JS_STATIC_METHOD(signatureGetModifications, Field);
578 JS_STATIC_METHOD(signatureGetSeedValue, Field);
579 JS_STATIC_METHOD(signatureInfo, Field);
580 JS_STATIC_METHOD(signatureSetSeedValue, Field);
581 JS_STATIC_METHOD(signatureSign, Field);
582 JS_STATIC_METHOD(signatureValidate, Field);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700583};
584
Dan Sinclairf766ad22016-03-14 13:51:24 -0400585#endif // FPDFSDK_JAVASCRIPT_FIELD_H_