blob: 4fba1ddfa107be7a3ee2e395e81c1b594e1cd5f8 [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
Lei Zhangbde53d22015-11-12 22:21:30 -080012#include "fpdfsdk/include/pdfwindow/PWL_Wnd.h" // For CPWL_Color.
Dan Sinclairefbc1912016-02-17 16:54:43 -050013#include "fpdfsdk/src/javascript/JS_Define.h"
Tom Sepez9a3f8122015-04-07 15:35:48 -070014
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;
Tom Sepez281a9ea2016-02-26 14:24:28 -080084 CFX_FloatRect rect;
Nico Weber9d8ec5a2015-08-04 13:00:21 -070085 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:
Lei Zhangd88a3642015-11-10 09:38:57 -080092 explicit 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,
Lei Zhang945fdb72015-11-11 10:18:16 -0800191 const std::vector<CJS_Value>& params,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700192 CJS_Value& vRet,
193 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700194 FX_BOOL buttonGetCaption(IJS_Context* cc,
Lei Zhang945fdb72015-11-11 10:18:16 -0800195 const std::vector<CJS_Value>& params,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700196 CJS_Value& vRet,
197 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700198 FX_BOOL buttonGetIcon(IJS_Context* cc,
Lei Zhang945fdb72015-11-11 10:18:16 -0800199 const std::vector<CJS_Value>& params,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700200 CJS_Value& vRet,
201 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700202 FX_BOOL buttonImportIcon(IJS_Context* cc,
Lei Zhang945fdb72015-11-11 10:18:16 -0800203 const std::vector<CJS_Value>& params,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700204 CJS_Value& vRet,
205 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700206 FX_BOOL buttonSetCaption(IJS_Context* cc,
Lei Zhang945fdb72015-11-11 10:18:16 -0800207 const std::vector<CJS_Value>& params,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700208 CJS_Value& vRet,
209 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700210 FX_BOOL buttonSetIcon(IJS_Context* cc,
Lei Zhang945fdb72015-11-11 10:18:16 -0800211 const std::vector<CJS_Value>& params,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700212 CJS_Value& vRet,
213 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700214 FX_BOOL checkThisBox(IJS_Context* cc,
Lei Zhang945fdb72015-11-11 10:18:16 -0800215 const std::vector<CJS_Value>& params,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700216 CJS_Value& vRet,
217 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700218 FX_BOOL clearItems(IJS_Context* cc,
Lei Zhang945fdb72015-11-11 10:18:16 -0800219 const std::vector<CJS_Value>& params,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700220 CJS_Value& vRet,
221 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700222 FX_BOOL defaultIsChecked(IJS_Context* cc,
Lei Zhang945fdb72015-11-11 10:18:16 -0800223 const std::vector<CJS_Value>& params,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700224 CJS_Value& vRet,
225 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700226 FX_BOOL deleteItemAt(IJS_Context* cc,
Lei Zhang945fdb72015-11-11 10:18:16 -0800227 const std::vector<CJS_Value>& params,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700228 CJS_Value& vRet,
229 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700230 FX_BOOL getArray(IJS_Context* cc,
Lei Zhang945fdb72015-11-11 10:18:16 -0800231 const std::vector<CJS_Value>& params,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700232 CJS_Value& vRet,
233 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700234 FX_BOOL getItemAt(IJS_Context* cc,
Lei Zhang945fdb72015-11-11 10:18:16 -0800235 const std::vector<CJS_Value>& params,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700236 CJS_Value& vRet,
237 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700238 FX_BOOL getLock(IJS_Context* cc,
Lei Zhang945fdb72015-11-11 10:18:16 -0800239 const std::vector<CJS_Value>& params,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700240 CJS_Value& vRet,
241 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700242 FX_BOOL insertItemAt(IJS_Context* cc,
Lei Zhang945fdb72015-11-11 10:18:16 -0800243 const std::vector<CJS_Value>& params,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700244 CJS_Value& vRet,
245 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700246 FX_BOOL isBoxChecked(IJS_Context* cc,
Lei Zhang945fdb72015-11-11 10:18:16 -0800247 const std::vector<CJS_Value>& params,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700248 CJS_Value& vRet,
249 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700250 FX_BOOL isDefaultChecked(IJS_Context* cc,
Lei Zhang945fdb72015-11-11 10:18:16 -0800251 const std::vector<CJS_Value>& params,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700252 CJS_Value& vRet,
253 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700254 FX_BOOL setAction(IJS_Context* cc,
Lei Zhang945fdb72015-11-11 10:18:16 -0800255 const std::vector<CJS_Value>& params,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700256 CJS_Value& vRet,
257 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700258 FX_BOOL setFocus(IJS_Context* cc,
Lei Zhang945fdb72015-11-11 10:18:16 -0800259 const std::vector<CJS_Value>& params,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700260 CJS_Value& vRet,
261 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700262 FX_BOOL setItems(IJS_Context* cc,
Lei Zhang945fdb72015-11-11 10:18:16 -0800263 const std::vector<CJS_Value>& params,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700264 CJS_Value& vRet,
265 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700266 FX_BOOL setLock(IJS_Context* cc,
Lei Zhang945fdb72015-11-11 10:18:16 -0800267 const std::vector<CJS_Value>& params,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700268 CJS_Value& vRet,
269 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700270 FX_BOOL signatureGetModifications(IJS_Context* cc,
Lei Zhang945fdb72015-11-11 10:18:16 -0800271 const std::vector<CJS_Value>& params,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700272 CJS_Value& vRet,
273 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700274 FX_BOOL signatureGetSeedValue(IJS_Context* cc,
Lei Zhang945fdb72015-11-11 10:18:16 -0800275 const std::vector<CJS_Value>& params,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700276 CJS_Value& vRet,
277 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700278 FX_BOOL signatureInfo(IJS_Context* cc,
Lei Zhang945fdb72015-11-11 10:18:16 -0800279 const std::vector<CJS_Value>& params,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700280 CJS_Value& vRet,
281 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700282 FX_BOOL signatureSetSeedValue(IJS_Context* cc,
Lei Zhang945fdb72015-11-11 10:18:16 -0800283 const std::vector<CJS_Value>& params,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700284 CJS_Value& vRet,
285 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700286 FX_BOOL signatureSign(IJS_Context* cc,
Lei Zhang945fdb72015-11-11 10:18:16 -0800287 const std::vector<CJS_Value>& params,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700288 CJS_Value& vRet,
289 CFX_WideString& sError);
Tom Sepezba038bc2015-10-08 12:03:00 -0700290 FX_BOOL signatureValidate(IJS_Context* cc,
Lei Zhang945fdb72015-11-11 10:18:16 -0800291 const std::vector<CJS_Value>& params,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700292 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 static void SetAlignment(CPDFSDK_Document* pDocument,
296 const CFX_WideString& swFieldName,
297 int nControlIndex,
298 const CFX_ByteString& string);
299 static void SetBorderStyle(CPDFSDK_Document* pDocument,
300 const CFX_WideString& swFieldName,
301 int nControlIndex,
302 const CFX_ByteString& string);
303 static void SetButtonAlignX(CPDFSDK_Document* pDocument,
304 const CFX_WideString& swFieldName,
305 int nControlIndex,
306 int number);
307 static void SetButtonAlignY(CPDFSDK_Document* pDocument,
308 const CFX_WideString& swFieldName,
309 int nControlIndex,
310 int number);
311 static void SetButtonFitBounds(CPDFSDK_Document* pDocument,
312 const CFX_WideString& swFieldName,
313 int nControlIndex,
314 bool b);
315 static void SetButtonPosition(CPDFSDK_Document* pDocument,
316 const CFX_WideString& swFieldName,
317 int nControlIndex,
318 int number);
319 static void SetButtonScaleHow(CPDFSDK_Document* pDocument,
320 const CFX_WideString& swFieldName,
321 int nControlIndex,
322 int number);
323 static void SetButtonScaleWhen(CPDFSDK_Document* pDocument,
324 const CFX_WideString& swFieldName,
325 int nControlIndex,
326 int number);
327 static void SetCalcOrderIndex(CPDFSDK_Document* pDocument,
328 const CFX_WideString& swFieldName,
329 int nControlIndex,
330 int number);
331 static void SetCharLimit(CPDFSDK_Document* pDocument,
332 const CFX_WideString& swFieldName,
333 int nControlIndex,
334 int number);
335 static void SetComb(CPDFSDK_Document* pDocument,
336 const CFX_WideString& swFieldName,
337 int nControlIndex,
338 bool b);
339 static void SetCommitOnSelChange(CPDFSDK_Document* pDocument,
340 const CFX_WideString& swFieldName,
341 int nControlIndex,
342 bool b);
343 static void SetCurrentValueIndices(CPDFSDK_Document* pDocument,
344 const CFX_WideString& swFieldName,
345 int nControlIndex,
346 const CFX_DWordArray& array);
347 static void SetDefaultStyle(CPDFSDK_Document* pDocument,
348 const CFX_WideString& swFieldName,
349 int nControlIndex);
350 static void SetDefaultValue(CPDFSDK_Document* pDocument,
351 const CFX_WideString& swFieldName,
352 int nControlIndex,
353 const CFX_WideString& string);
354 static void SetDoNotScroll(CPDFSDK_Document* pDocument,
355 const CFX_WideString& swFieldName,
356 int nControlIndex,
357 bool b);
358 static void SetDisplay(CPDFSDK_Document* pDocument,
359 const CFX_WideString& swFieldName,
360 int nControlIndex,
361 int number);
362 static void SetFillColor(CPDFSDK_Document* pDocument,
363 const CFX_WideString& swFieldName,
364 int nControlIndex,
365 const CPWL_Color& color);
366 static void SetHidden(CPDFSDK_Document* pDocument,
367 const CFX_WideString& swFieldName,
368 int nControlIndex,
369 bool b);
370 static void SetHighlight(CPDFSDK_Document* pDocument,
371 const CFX_WideString& swFieldName,
372 int nControlIndex,
373 const CFX_ByteString& string);
374 static void SetLineWidth(CPDFSDK_Document* pDocument,
375 const CFX_WideString& swFieldName,
376 int nControlIndex,
377 int number);
378 static void SetMultiline(CPDFSDK_Document* pDocument,
379 const CFX_WideString& swFieldName,
380 int nControlIndex,
381 bool b);
382 static void SetMultipleSelection(CPDFSDK_Document* pDocument,
383 const CFX_WideString& swFieldName,
384 int nControlIndex,
385 bool b);
386 static void SetPassword(CPDFSDK_Document* pDocument,
387 const CFX_WideString& swFieldName,
388 int nControlIndex,
389 bool b);
390 static void SetRect(CPDFSDK_Document* pDocument,
391 const CFX_WideString& swFieldName,
392 int nControlIndex,
Tom Sepez281a9ea2016-02-26 14:24:28 -0800393 const CFX_FloatRect& rect);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700394 static void SetRichText(CPDFSDK_Document* pDocument,
395 const CFX_WideString& swFieldName,
396 int nControlIndex,
397 bool b);
398 static void SetRichValue(CPDFSDK_Document* pDocument,
399 const CFX_WideString& swFieldName,
400 int nControlIndex);
401 static void SetRotation(CPDFSDK_Document* pDocument,
402 const CFX_WideString& swFieldName,
403 int nControlIndex,
404 int number);
405 static void SetStrokeColor(CPDFSDK_Document* pDocument,
406 const CFX_WideString& swFieldName,
407 int nControlIndex,
408 const CPWL_Color& color);
409 static void SetStyle(CPDFSDK_Document* pDocument,
410 const CFX_WideString& swFieldName,
411 int nControlIndex,
412 const CFX_ByteString& string);
413 static void SetTextColor(CPDFSDK_Document* pDocument,
414 const CFX_WideString& swFieldName,
415 int nControlIndex,
416 const CPWL_Color& color);
417 static void SetTextFont(CPDFSDK_Document* pDocument,
418 const CFX_WideString& swFieldName,
419 int nControlIndex,
420 const CFX_ByteString& string);
421 static void SetTextSize(CPDFSDK_Document* pDocument,
422 const CFX_WideString& swFieldName,
423 int nControlIndex,
424 int number);
425 static void SetUserName(CPDFSDK_Document* pDocument,
426 const CFX_WideString& swFieldName,
427 int nControlIndex,
428 const CFX_WideString& string);
429 static void SetValue(CPDFSDK_Document* pDocument,
430 const CFX_WideString& swFieldName,
431 int nControlIndex,
432 const CJS_WideStringArray& strArray);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700433
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700434 static void AddField(CPDFSDK_Document* pDocument,
435 int nPageIndex,
436 int nFieldType,
437 const CFX_WideString& sName,
Tom Sepez281a9ea2016-02-26 14:24:28 -0800438 const CFX_FloatRect& rcCoords);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700439
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700440 static void UpdateFormField(CPDFSDK_Document* pDocument,
441 CPDF_FormField* pFormField,
442 FX_BOOL bChangeMark,
443 FX_BOOL bResetAP,
444 FX_BOOL bRefresh);
445 static void UpdateFormControl(CPDFSDK_Document* pDocument,
446 CPDF_FormControl* pFormControl,
447 FX_BOOL bChangeMark,
448 FX_BOOL bResetAP,
449 FX_BOOL bRefresh);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700450
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700451 static CPDFSDK_Widget* GetWidget(CPDFSDK_Document* pDocument,
452 CPDF_FormControl* pFormControl);
Lei Zhangd88a3642015-11-10 09:38:57 -0800453 static std::vector<CPDF_FormField*> GetFormFields(
454 CPDFSDK_Document* pDocument,
455 const CFX_WideString& csFieldName);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700456
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700457 static void DoDelay(CPDFSDK_Document* pDocument, CJS_DelayData* pData);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700458
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700459 FX_BOOL AttachField(Document* pDocument, const CFX_WideString& csFieldName);
460 void SetDelay(FX_BOOL bDelay);
461 void SetIsolate(v8::Isolate* isolate) { m_isolate = isolate; }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700462
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700463 protected:
464 void ParseFieldName(const std::wstring& strFieldNameParsed,
465 std::wstring& strFieldName,
466 int& iControlNo);
Lei Zhangd88a3642015-11-10 09:38:57 -0800467 std::vector<CPDF_FormField*> GetFormFields(
468 const CFX_WideString& csFieldName) const;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700469 CPDF_FormControl* GetSmartFieldControl(CPDF_FormField* pFormField);
470 FX_BOOL ValueIsOccur(CPDF_FormField* pFormField, CFX_WideString csOptLabel);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700471
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700472 void AddDelay_Int(enum FIELD_PROP prop, int32_t n);
473 void AddDelay_Bool(enum FIELD_PROP prop, bool b);
474 void AddDelay_String(enum FIELD_PROP prop, const CFX_ByteString& string);
475 void AddDelay_WideString(enum FIELD_PROP prop, const CFX_WideString& string);
Tom Sepez281a9ea2016-02-26 14:24:28 -0800476 void AddDelay_Rect(enum FIELD_PROP prop, const CFX_FloatRect& rect);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700477 void AddDelay_Color(enum FIELD_PROP prop, const CPWL_Color& color);
478 void AddDelay_WordArray(enum FIELD_PROP prop, const CFX_DWordArray& array);
479 void AddDelay_WideStringArray(enum FIELD_PROP prop,
480 const CJS_WideStringArray& array);
481
482 void DoDelay();
483
484 public:
485 Document* m_pJSDoc;
486 CPDFSDK_Document* m_pDocument;
487 CFX_WideString m_FieldName;
488 int m_nFormControlIndex;
489 FX_BOOL m_bCanSet;
490
491 FX_BOOL m_bDelay;
492 v8::Isolate* m_isolate;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700493};
494
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700495class CJS_Field : public CJS_Object {
496 public:
Lei Zhangd88a3642015-11-10 09:38:57 -0800497 explicit CJS_Field(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {}
Lei Zhang2b1a2d52015-08-14 22:16:22 -0700498 ~CJS_Field(void) override {}
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700499
Tom Sepez33420902015-10-13 15:00:10 -0700500 void InitInstance(IJS_Runtime* pIRuntime) override;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700501
Tom Sepezcd56a7d2015-10-06 11:45:28 -0700502 DECLARE_JS_CLASS();
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700503 JS_STATIC_PROP(alignment, Field);
504 JS_STATIC_PROP(borderStyle, Field);
505 JS_STATIC_PROP(buttonAlignX, Field);
506 JS_STATIC_PROP(buttonAlignY, Field);
507 JS_STATIC_PROP(buttonFitBounds, Field);
508 JS_STATIC_PROP(buttonPosition, Field);
509 JS_STATIC_PROP(buttonScaleHow, Field);
510 JS_STATIC_PROP(buttonScaleWhen, Field);
511 JS_STATIC_PROP(calcOrderIndex, Field);
512 JS_STATIC_PROP(charLimit, Field);
513 JS_STATIC_PROP(comb, Field);
514 JS_STATIC_PROP(commitOnSelChange, Field);
515 JS_STATIC_PROP(currentValueIndices, Field);
516 JS_STATIC_PROP(defaultStyle, Field);
517 JS_STATIC_PROP(defaultValue, Field);
518 JS_STATIC_PROP(doNotScroll, Field);
519 JS_STATIC_PROP(doNotSpellCheck, Field);
520 JS_STATIC_PROP(delay, Field);
521 JS_STATIC_PROP(display, Field);
522 JS_STATIC_PROP(doc, Field);
523 JS_STATIC_PROP(editable, Field);
524 JS_STATIC_PROP(exportValues, Field);
525 JS_STATIC_PROP(fileSelect, Field);
526 JS_STATIC_PROP(fillColor, Field);
527 JS_STATIC_PROP(hidden, Field);
528 JS_STATIC_PROP(highlight, Field);
529 JS_STATIC_PROP(lineWidth, Field);
530 JS_STATIC_PROP(multiline, Field);
531 JS_STATIC_PROP(multipleSelection, Field);
532 JS_STATIC_PROP(name, Field);
533 JS_STATIC_PROP(numItems, Field);
534 JS_STATIC_PROP(page, Field);
535 JS_STATIC_PROP(password, Field);
536 JS_STATIC_PROP(print, Field);
537 JS_STATIC_PROP(radiosInUnison, Field);
538 JS_STATIC_PROP(readonly, Field);
539 JS_STATIC_PROP(rect, Field);
540 JS_STATIC_PROP(required, Field);
541 JS_STATIC_PROP(richText, Field);
542 JS_STATIC_PROP(richValue, Field);
543 JS_STATIC_PROP(rotation, Field);
544 JS_STATIC_PROP(strokeColor, Field);
545 JS_STATIC_PROP(style, Field);
546 JS_STATIC_PROP(submitName, Field);
547 JS_STATIC_PROP(textColor, Field);
548 JS_STATIC_PROP(textFont, Field);
549 JS_STATIC_PROP(textSize, Field);
550 JS_STATIC_PROP(type, Field);
551 JS_STATIC_PROP(userName, Field);
552 JS_STATIC_PROP(value, Field);
553 JS_STATIC_PROP(valueAsString, Field);
554 JS_STATIC_PROP(source, Field);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700555
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700556 JS_STATIC_METHOD(browseForFileToSubmit, Field);
557 JS_STATIC_METHOD(buttonGetCaption, Field);
558 JS_STATIC_METHOD(buttonGetIcon, Field);
559 JS_STATIC_METHOD(buttonImportIcon, Field);
560 JS_STATIC_METHOD(buttonSetCaption, Field);
561 JS_STATIC_METHOD(buttonSetIcon, Field);
562 JS_STATIC_METHOD(checkThisBox, Field);
563 JS_STATIC_METHOD(clearItems, Field);
564 JS_STATIC_METHOD(defaultIsChecked, Field);
565 JS_STATIC_METHOD(deleteItemAt, Field);
566 JS_STATIC_METHOD(getArray, Field);
567 JS_STATIC_METHOD(getItemAt, Field);
568 JS_STATIC_METHOD(getLock, Field);
569 JS_STATIC_METHOD(insertItemAt, Field);
570 JS_STATIC_METHOD(isBoxChecked, Field);
571 JS_STATIC_METHOD(isDefaultChecked, Field);
572 JS_STATIC_METHOD(setAction, Field);
573 JS_STATIC_METHOD(setFocus, Field);
574 JS_STATIC_METHOD(setItems, Field);
575 JS_STATIC_METHOD(setLock, Field);
576 JS_STATIC_METHOD(signatureGetModifications, Field);
577 JS_STATIC_METHOD(signatureGetSeedValue, Field);
578 JS_STATIC_METHOD(signatureInfo, Field);
579 JS_STATIC_METHOD(signatureSetSeedValue, Field);
580 JS_STATIC_METHOD(signatureSign, Field);
581 JS_STATIC_METHOD(signatureValidate, Field);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700582};
583
Tom Sepez37458412015-10-06 11:33:46 -0700584#endif // FPDFSDK_SRC_JAVASCRIPT_FIELD_H_