John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1 | // 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 Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 4 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 5 | // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | |
Tom Sepez | 3745841 | 2015-10-06 11:33:46 -0700 | [diff] [blame] | 7 | #ifndef FPDFSDK_SRC_JAVASCRIPT_FIELD_H_ |
| 8 | #define FPDFSDK_SRC_JAVASCRIPT_FIELD_H_ |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 9 | |
Tom Sepez | 9a3f812 | 2015-04-07 15:35:48 -0700 | [diff] [blame] | 10 | #include <string> // For std::wstring. |
| 11 | |
Tom Sepez | 3745841 | 2015-10-06 11:33:46 -0700 | [diff] [blame] | 12 | #include "../../include/pdfwindow/PWL_Wnd.h" // For CPWL_Color. |
Tom Sepez | 9a3f812 | 2015-04-07 15:35:48 -0700 | [diff] [blame] | 13 | #include "JS_Define.h" |
| 14 | |
Tom Sepez | 3745841 | 2015-10-06 11:33:46 -0700 | [diff] [blame] | 15 | class CPDFSDK_Widget; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 16 | class Document; |
| 17 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 18 | enum 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 53 | }; |
| 54 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 55 | class 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 63 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 64 | void Add(const CFX_WideString& string) { |
| 65 | m_Data.Add(new CFX_WideString(string)); |
| 66 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 67 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 68 | int GetSize() const { return m_Data.GetSize(); } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 69 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 70 | CFX_WideString GetAt(int i) const { return *m_Data.GetAt(i); } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 71 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 72 | private: |
| 73 | CFX_ArrayTemplate<CFX_WideString*> m_Data; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 74 | }; |
| 75 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 76 | struct CJS_DelayData { |
| 77 | CFX_WideString sFieldName; |
| 78 | int nControlIndex; |
| 79 | enum FIELD_PROP eProp; |
| 80 | int32_t num; |
| 81 | bool b; |
| 82 | CFX_ByteString string; |
| 83 | CFX_WideString widestring; |
| 84 | CPDF_Rect rect; |
| 85 | CPWL_Color color; |
| 86 | CFX_DWordArray wordarray; |
| 87 | CJS_WideStringArray widestringarray; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 88 | }; |
| 89 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 90 | class Field : public CJS_EmbedObj { |
| 91 | public: |
| 92 | Field(CJS_Object* pJSObject); |
Lei Zhang | 2b1a2d5 | 2015-08-14 22:16:22 -0700 | [diff] [blame] | 93 | ~Field() override; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 94 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 95 | FX_BOOL alignment(IFXJS_Context* cc, |
| 96 | CJS_PropValue& vp, |
| 97 | CFX_WideString& sError); |
| 98 | FX_BOOL borderStyle(IFXJS_Context* cc, |
| 99 | CJS_PropValue& vp, |
| 100 | CFX_WideString& sError); |
| 101 | FX_BOOL buttonAlignX(IFXJS_Context* cc, |
| 102 | CJS_PropValue& vp, |
| 103 | CFX_WideString& sError); |
| 104 | FX_BOOL buttonAlignY(IFXJS_Context* cc, |
| 105 | CJS_PropValue& vp, |
| 106 | CFX_WideString& sError); |
| 107 | FX_BOOL buttonFitBounds(IFXJS_Context* cc, |
| 108 | CJS_PropValue& vp, |
| 109 | CFX_WideString& sError); |
| 110 | FX_BOOL buttonPosition(IFXJS_Context* cc, |
| 111 | CJS_PropValue& vp, |
| 112 | CFX_WideString& sError); |
| 113 | FX_BOOL buttonScaleHow(IFXJS_Context* cc, |
| 114 | CJS_PropValue& vp, |
| 115 | CFX_WideString& sError); |
| 116 | FX_BOOL buttonScaleWhen(IFXJS_Context* cc, |
| 117 | CJS_PropValue& vp, |
| 118 | CFX_WideString& sError); |
| 119 | FX_BOOL calcOrderIndex(IFXJS_Context* cc, |
| 120 | CJS_PropValue& vp, |
| 121 | CFX_WideString& sError); |
| 122 | FX_BOOL charLimit(IFXJS_Context* cc, |
| 123 | CJS_PropValue& vp, |
| 124 | CFX_WideString& sError); |
| 125 | FX_BOOL comb(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); |
| 126 | FX_BOOL commitOnSelChange(IFXJS_Context* cc, |
| 127 | CJS_PropValue& vp, |
| 128 | CFX_WideString& sError); |
| 129 | FX_BOOL currentValueIndices(IFXJS_Context* cc, |
| 130 | CJS_PropValue& vp, |
| 131 | CFX_WideString& sError); |
| 132 | FX_BOOL defaultStyle(IFXJS_Context* cc, |
| 133 | CJS_PropValue& vp, |
| 134 | CFX_WideString& sError); |
| 135 | FX_BOOL defaultValue(IFXJS_Context* cc, |
| 136 | CJS_PropValue& vp, |
| 137 | CFX_WideString& sError); |
| 138 | FX_BOOL doNotScroll(IFXJS_Context* cc, |
| 139 | CJS_PropValue& vp, |
| 140 | CFX_WideString& sError); |
| 141 | FX_BOOL doNotSpellCheck(IFXJS_Context* cc, |
| 142 | CJS_PropValue& vp, |
| 143 | CFX_WideString& sError); |
| 144 | FX_BOOL delay(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); |
| 145 | FX_BOOL display(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); |
| 146 | FX_BOOL doc(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); |
| 147 | FX_BOOL editable(IFXJS_Context* cc, |
| 148 | CJS_PropValue& vp, |
| 149 | CFX_WideString& sError); |
| 150 | FX_BOOL exportValues(IFXJS_Context* cc, |
| 151 | CJS_PropValue& vp, |
| 152 | CFX_WideString& sError); |
| 153 | FX_BOOL fileSelect(IFXJS_Context* cc, |
| 154 | CJS_PropValue& vp, |
| 155 | CFX_WideString& sError); |
| 156 | FX_BOOL fillColor(IFXJS_Context* cc, |
| 157 | CJS_PropValue& vp, |
| 158 | CFX_WideString& sError); |
| 159 | FX_BOOL hidden(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); |
| 160 | FX_BOOL highlight(IFXJS_Context* cc, |
| 161 | CJS_PropValue& vp, |
| 162 | CFX_WideString& sError); |
| 163 | FX_BOOL lineWidth(IFXJS_Context* cc, |
| 164 | CJS_PropValue& vp, |
| 165 | CFX_WideString& sError); |
| 166 | FX_BOOL multiline(IFXJS_Context* cc, |
| 167 | CJS_PropValue& vp, |
| 168 | CFX_WideString& sError); |
| 169 | FX_BOOL multipleSelection(IFXJS_Context* cc, |
| 170 | CJS_PropValue& vp, |
| 171 | CFX_WideString& sError); |
| 172 | FX_BOOL name(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); |
| 173 | FX_BOOL numItems(IFXJS_Context* cc, |
| 174 | CJS_PropValue& vp, |
| 175 | CFX_WideString& sError); |
| 176 | FX_BOOL page(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); |
| 177 | FX_BOOL password(IFXJS_Context* cc, |
| 178 | CJS_PropValue& vp, |
| 179 | CFX_WideString& sError); |
| 180 | FX_BOOL print(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); |
| 181 | FX_BOOL radiosInUnison(IFXJS_Context* cc, |
| 182 | CJS_PropValue& vp, |
| 183 | CFX_WideString& sError); |
| 184 | FX_BOOL readonly(IFXJS_Context* cc, |
| 185 | CJS_PropValue& vp, |
| 186 | CFX_WideString& sError); |
| 187 | FX_BOOL rect(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); |
| 188 | FX_BOOL required(IFXJS_Context* cc, |
| 189 | CJS_PropValue& vp, |
| 190 | CFX_WideString& sError); |
| 191 | FX_BOOL richText(IFXJS_Context* cc, |
| 192 | CJS_PropValue& vp, |
| 193 | CFX_WideString& sError); |
| 194 | FX_BOOL richValue(IFXJS_Context* cc, |
| 195 | CJS_PropValue& vp, |
| 196 | CFX_WideString& sError); |
| 197 | FX_BOOL rotation(IFXJS_Context* cc, |
| 198 | CJS_PropValue& vp, |
| 199 | CFX_WideString& sError); |
| 200 | FX_BOOL strokeColor(IFXJS_Context* cc, |
| 201 | CJS_PropValue& vp, |
| 202 | CFX_WideString& sError); |
| 203 | FX_BOOL style(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); |
| 204 | FX_BOOL submitName(IFXJS_Context* cc, |
| 205 | CJS_PropValue& vp, |
| 206 | CFX_WideString& sError); |
| 207 | FX_BOOL textColor(IFXJS_Context* cc, |
| 208 | CJS_PropValue& vp, |
| 209 | CFX_WideString& sError); |
| 210 | FX_BOOL textFont(IFXJS_Context* cc, |
| 211 | CJS_PropValue& vp, |
| 212 | CFX_WideString& sError); |
| 213 | FX_BOOL textSize(IFXJS_Context* cc, |
| 214 | CJS_PropValue& vp, |
| 215 | CFX_WideString& sError); |
| 216 | FX_BOOL type(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); |
| 217 | FX_BOOL userName(IFXJS_Context* cc, |
| 218 | CJS_PropValue& vp, |
| 219 | CFX_WideString& sError); |
| 220 | FX_BOOL value(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); |
| 221 | FX_BOOL valueAsString(IFXJS_Context* cc, |
| 222 | CJS_PropValue& vp, |
| 223 | CFX_WideString& sError); |
| 224 | FX_BOOL source(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 225 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 226 | FX_BOOL browseForFileToSubmit(IFXJS_Context* cc, |
| 227 | const CJS_Parameters& params, |
| 228 | CJS_Value& vRet, |
| 229 | CFX_WideString& sError); |
| 230 | FX_BOOL buttonGetCaption(IFXJS_Context* cc, |
| 231 | const CJS_Parameters& params, |
| 232 | CJS_Value& vRet, |
| 233 | CFX_WideString& sError); |
| 234 | FX_BOOL buttonGetIcon(IFXJS_Context* cc, |
| 235 | const CJS_Parameters& params, |
| 236 | CJS_Value& vRet, |
| 237 | CFX_WideString& sError); |
| 238 | FX_BOOL buttonImportIcon(IFXJS_Context* cc, |
| 239 | const CJS_Parameters& params, |
| 240 | CJS_Value& vRet, |
| 241 | CFX_WideString& sError); |
| 242 | FX_BOOL buttonSetCaption(IFXJS_Context* cc, |
| 243 | const CJS_Parameters& params, |
| 244 | CJS_Value& vRet, |
| 245 | CFX_WideString& sError); |
| 246 | FX_BOOL buttonSetIcon(IFXJS_Context* cc, |
| 247 | const CJS_Parameters& params, |
| 248 | CJS_Value& vRet, |
| 249 | CFX_WideString& sError); |
| 250 | FX_BOOL checkThisBox(IFXJS_Context* cc, |
| 251 | const CJS_Parameters& params, |
| 252 | CJS_Value& vRet, |
| 253 | CFX_WideString& sError); |
| 254 | FX_BOOL clearItems(IFXJS_Context* cc, |
| 255 | const CJS_Parameters& params, |
| 256 | CJS_Value& vRet, |
| 257 | CFX_WideString& sError); |
| 258 | FX_BOOL defaultIsChecked(IFXJS_Context* cc, |
| 259 | const CJS_Parameters& params, |
| 260 | CJS_Value& vRet, |
| 261 | CFX_WideString& sError); |
| 262 | FX_BOOL deleteItemAt(IFXJS_Context* cc, |
| 263 | const CJS_Parameters& params, |
| 264 | CJS_Value& vRet, |
| 265 | CFX_WideString& sError); |
| 266 | FX_BOOL getArray(IFXJS_Context* cc, |
| 267 | const CJS_Parameters& params, |
| 268 | CJS_Value& vRet, |
| 269 | CFX_WideString& sError); |
| 270 | FX_BOOL getItemAt(IFXJS_Context* cc, |
| 271 | const CJS_Parameters& params, |
| 272 | CJS_Value& vRet, |
| 273 | CFX_WideString& sError); |
| 274 | FX_BOOL getLock(IFXJS_Context* cc, |
| 275 | const CJS_Parameters& params, |
| 276 | CJS_Value& vRet, |
| 277 | CFX_WideString& sError); |
| 278 | FX_BOOL insertItemAt(IFXJS_Context* cc, |
| 279 | const CJS_Parameters& params, |
| 280 | CJS_Value& vRet, |
| 281 | CFX_WideString& sError); |
| 282 | FX_BOOL isBoxChecked(IFXJS_Context* cc, |
| 283 | const CJS_Parameters& params, |
| 284 | CJS_Value& vRet, |
| 285 | CFX_WideString& sError); |
| 286 | FX_BOOL isDefaultChecked(IFXJS_Context* cc, |
| 287 | const CJS_Parameters& params, |
| 288 | CJS_Value& vRet, |
| 289 | CFX_WideString& sError); |
| 290 | FX_BOOL setAction(IFXJS_Context* cc, |
| 291 | const CJS_Parameters& params, |
| 292 | CJS_Value& vRet, |
| 293 | CFX_WideString& sError); |
| 294 | FX_BOOL setFocus(IFXJS_Context* cc, |
| 295 | const CJS_Parameters& params, |
| 296 | CJS_Value& vRet, |
| 297 | CFX_WideString& sError); |
| 298 | FX_BOOL setItems(IFXJS_Context* cc, |
| 299 | const CJS_Parameters& params, |
| 300 | CJS_Value& vRet, |
| 301 | CFX_WideString& sError); |
| 302 | FX_BOOL setLock(IFXJS_Context* cc, |
| 303 | const CJS_Parameters& params, |
| 304 | CJS_Value& vRet, |
| 305 | CFX_WideString& sError); |
| 306 | FX_BOOL signatureGetModifications(IFXJS_Context* cc, |
| 307 | const CJS_Parameters& params, |
| 308 | CJS_Value& vRet, |
| 309 | CFX_WideString& sError); |
| 310 | FX_BOOL signatureGetSeedValue(IFXJS_Context* cc, |
| 311 | const CJS_Parameters& params, |
| 312 | CJS_Value& vRet, |
| 313 | CFX_WideString& sError); |
| 314 | FX_BOOL signatureInfo(IFXJS_Context* cc, |
| 315 | const CJS_Parameters& params, |
| 316 | CJS_Value& vRet, |
| 317 | CFX_WideString& sError); |
| 318 | FX_BOOL signatureSetSeedValue(IFXJS_Context* cc, |
| 319 | const CJS_Parameters& params, |
| 320 | CJS_Value& vRet, |
| 321 | CFX_WideString& sError); |
| 322 | FX_BOOL signatureSign(IFXJS_Context* cc, |
| 323 | const CJS_Parameters& params, |
| 324 | CJS_Value& vRet, |
| 325 | CFX_WideString& sError); |
| 326 | FX_BOOL signatureValidate(IFXJS_Context* cc, |
| 327 | const CJS_Parameters& params, |
| 328 | CJS_Value& vRet, |
| 329 | CFX_WideString& sError); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 330 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 331 | public: |
| 332 | static void SetAlignment(CPDFSDK_Document* pDocument, |
| 333 | const CFX_WideString& swFieldName, |
| 334 | int nControlIndex, |
| 335 | const CFX_ByteString& string); |
| 336 | static void SetBorderStyle(CPDFSDK_Document* pDocument, |
| 337 | const CFX_WideString& swFieldName, |
| 338 | int nControlIndex, |
| 339 | const CFX_ByteString& string); |
| 340 | static void SetButtonAlignX(CPDFSDK_Document* pDocument, |
| 341 | const CFX_WideString& swFieldName, |
| 342 | int nControlIndex, |
| 343 | int number); |
| 344 | static void SetButtonAlignY(CPDFSDK_Document* pDocument, |
| 345 | const CFX_WideString& swFieldName, |
| 346 | int nControlIndex, |
| 347 | int number); |
| 348 | static void SetButtonFitBounds(CPDFSDK_Document* pDocument, |
| 349 | const CFX_WideString& swFieldName, |
| 350 | int nControlIndex, |
| 351 | bool b); |
| 352 | static void SetButtonPosition(CPDFSDK_Document* pDocument, |
| 353 | const CFX_WideString& swFieldName, |
| 354 | int nControlIndex, |
| 355 | int number); |
| 356 | static void SetButtonScaleHow(CPDFSDK_Document* pDocument, |
| 357 | const CFX_WideString& swFieldName, |
| 358 | int nControlIndex, |
| 359 | int number); |
| 360 | static void SetButtonScaleWhen(CPDFSDK_Document* pDocument, |
| 361 | const CFX_WideString& swFieldName, |
| 362 | int nControlIndex, |
| 363 | int number); |
| 364 | static void SetCalcOrderIndex(CPDFSDK_Document* pDocument, |
| 365 | const CFX_WideString& swFieldName, |
| 366 | int nControlIndex, |
| 367 | int number); |
| 368 | static void SetCharLimit(CPDFSDK_Document* pDocument, |
| 369 | const CFX_WideString& swFieldName, |
| 370 | int nControlIndex, |
| 371 | int number); |
| 372 | static void SetComb(CPDFSDK_Document* pDocument, |
| 373 | const CFX_WideString& swFieldName, |
| 374 | int nControlIndex, |
| 375 | bool b); |
| 376 | static void SetCommitOnSelChange(CPDFSDK_Document* pDocument, |
| 377 | const CFX_WideString& swFieldName, |
| 378 | int nControlIndex, |
| 379 | bool b); |
| 380 | static void SetCurrentValueIndices(CPDFSDK_Document* pDocument, |
| 381 | const CFX_WideString& swFieldName, |
| 382 | int nControlIndex, |
| 383 | const CFX_DWordArray& array); |
| 384 | static void SetDefaultStyle(CPDFSDK_Document* pDocument, |
| 385 | const CFX_WideString& swFieldName, |
| 386 | int nControlIndex); |
| 387 | static void SetDefaultValue(CPDFSDK_Document* pDocument, |
| 388 | const CFX_WideString& swFieldName, |
| 389 | int nControlIndex, |
| 390 | const CFX_WideString& string); |
| 391 | static void SetDoNotScroll(CPDFSDK_Document* pDocument, |
| 392 | const CFX_WideString& swFieldName, |
| 393 | int nControlIndex, |
| 394 | bool b); |
| 395 | static void SetDisplay(CPDFSDK_Document* pDocument, |
| 396 | const CFX_WideString& swFieldName, |
| 397 | int nControlIndex, |
| 398 | int number); |
| 399 | static void SetFillColor(CPDFSDK_Document* pDocument, |
| 400 | const CFX_WideString& swFieldName, |
| 401 | int nControlIndex, |
| 402 | const CPWL_Color& color); |
| 403 | static void SetHidden(CPDFSDK_Document* pDocument, |
| 404 | const CFX_WideString& swFieldName, |
| 405 | int nControlIndex, |
| 406 | bool b); |
| 407 | static void SetHighlight(CPDFSDK_Document* pDocument, |
| 408 | const CFX_WideString& swFieldName, |
| 409 | int nControlIndex, |
| 410 | const CFX_ByteString& string); |
| 411 | static void SetLineWidth(CPDFSDK_Document* pDocument, |
| 412 | const CFX_WideString& swFieldName, |
| 413 | int nControlIndex, |
| 414 | int number); |
| 415 | static void SetMultiline(CPDFSDK_Document* pDocument, |
| 416 | const CFX_WideString& swFieldName, |
| 417 | int nControlIndex, |
| 418 | bool b); |
| 419 | static void SetMultipleSelection(CPDFSDK_Document* pDocument, |
| 420 | const CFX_WideString& swFieldName, |
| 421 | int nControlIndex, |
| 422 | bool b); |
| 423 | static void SetPassword(CPDFSDK_Document* pDocument, |
| 424 | const CFX_WideString& swFieldName, |
| 425 | int nControlIndex, |
| 426 | bool b); |
| 427 | static void SetRect(CPDFSDK_Document* pDocument, |
| 428 | const CFX_WideString& swFieldName, |
| 429 | int nControlIndex, |
| 430 | const CPDF_Rect& rect); |
| 431 | static void SetRichText(CPDFSDK_Document* pDocument, |
| 432 | const CFX_WideString& swFieldName, |
| 433 | int nControlIndex, |
| 434 | bool b); |
| 435 | static void SetRichValue(CPDFSDK_Document* pDocument, |
| 436 | const CFX_WideString& swFieldName, |
| 437 | int nControlIndex); |
| 438 | static void SetRotation(CPDFSDK_Document* pDocument, |
| 439 | const CFX_WideString& swFieldName, |
| 440 | int nControlIndex, |
| 441 | int number); |
| 442 | static void SetStrokeColor(CPDFSDK_Document* pDocument, |
| 443 | const CFX_WideString& swFieldName, |
| 444 | int nControlIndex, |
| 445 | const CPWL_Color& color); |
| 446 | static void SetStyle(CPDFSDK_Document* pDocument, |
| 447 | const CFX_WideString& swFieldName, |
| 448 | int nControlIndex, |
| 449 | const CFX_ByteString& string); |
| 450 | static void SetTextColor(CPDFSDK_Document* pDocument, |
| 451 | const CFX_WideString& swFieldName, |
| 452 | int nControlIndex, |
| 453 | const CPWL_Color& color); |
| 454 | static void SetTextFont(CPDFSDK_Document* pDocument, |
| 455 | const CFX_WideString& swFieldName, |
| 456 | int nControlIndex, |
| 457 | const CFX_ByteString& string); |
| 458 | static void SetTextSize(CPDFSDK_Document* pDocument, |
| 459 | const CFX_WideString& swFieldName, |
| 460 | int nControlIndex, |
| 461 | int number); |
| 462 | static void SetUserName(CPDFSDK_Document* pDocument, |
| 463 | const CFX_WideString& swFieldName, |
| 464 | int nControlIndex, |
| 465 | const CFX_WideString& string); |
| 466 | static void SetValue(CPDFSDK_Document* pDocument, |
| 467 | const CFX_WideString& swFieldName, |
| 468 | int nControlIndex, |
| 469 | const CJS_WideStringArray& strArray); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 470 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 471 | public: |
| 472 | static void AddField(CPDFSDK_Document* pDocument, |
| 473 | int nPageIndex, |
| 474 | int nFieldType, |
| 475 | const CFX_WideString& sName, |
| 476 | const CPDF_Rect& rcCoords); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 477 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 478 | public: |
| 479 | static void UpdateFormField(CPDFSDK_Document* pDocument, |
| 480 | CPDF_FormField* pFormField, |
| 481 | FX_BOOL bChangeMark, |
| 482 | FX_BOOL bResetAP, |
| 483 | FX_BOOL bRefresh); |
| 484 | static void UpdateFormControl(CPDFSDK_Document* pDocument, |
| 485 | CPDF_FormControl* pFormControl, |
| 486 | FX_BOOL bChangeMark, |
| 487 | FX_BOOL bResetAP, |
| 488 | FX_BOOL bRefresh); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 489 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 490 | static CPDFSDK_Widget* GetWidget(CPDFSDK_Document* pDocument, |
| 491 | CPDF_FormControl* pFormControl); |
| 492 | static void GetFormFields(CPDFSDK_Document* pDocument, |
| 493 | const CFX_WideString& csFieldName, |
| 494 | CFX_PtrArray& FieldsArray); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 495 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 496 | static void DoDelay(CPDFSDK_Document* pDocument, CJS_DelayData* pData); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 497 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 498 | public: |
| 499 | FX_BOOL AttachField(Document* pDocument, const CFX_WideString& csFieldName); |
| 500 | void SetDelay(FX_BOOL bDelay); |
| 501 | void SetIsolate(v8::Isolate* isolate) { m_isolate = isolate; } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 502 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 503 | protected: |
| 504 | void ParseFieldName(const std::wstring& strFieldNameParsed, |
| 505 | std::wstring& strFieldName, |
| 506 | int& iControlNo); |
| 507 | void GetFormFields(const CFX_WideString& csFieldName, |
| 508 | CFX_PtrArray& FieldsArray); |
| 509 | CPDF_FormControl* GetSmartFieldControl(CPDF_FormField* pFormField); |
| 510 | FX_BOOL ValueIsOccur(CPDF_FormField* pFormField, CFX_WideString csOptLabel); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 511 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 512 | void AddDelay_Int(enum FIELD_PROP prop, int32_t n); |
| 513 | void AddDelay_Bool(enum FIELD_PROP prop, bool b); |
| 514 | void AddDelay_String(enum FIELD_PROP prop, const CFX_ByteString& string); |
| 515 | void AddDelay_WideString(enum FIELD_PROP prop, const CFX_WideString& string); |
| 516 | void AddDelay_Rect(enum FIELD_PROP prop, const CPDF_Rect& rect); |
| 517 | void AddDelay_Color(enum FIELD_PROP prop, const CPWL_Color& color); |
| 518 | void AddDelay_WordArray(enum FIELD_PROP prop, const CFX_DWordArray& array); |
| 519 | void AddDelay_WideStringArray(enum FIELD_PROP prop, |
| 520 | const CJS_WideStringArray& array); |
| 521 | |
| 522 | void DoDelay(); |
| 523 | |
| 524 | public: |
| 525 | Document* m_pJSDoc; |
| 526 | CPDFSDK_Document* m_pDocument; |
| 527 | CFX_WideString m_FieldName; |
| 528 | int m_nFormControlIndex; |
| 529 | FX_BOOL m_bCanSet; |
| 530 | |
| 531 | FX_BOOL m_bDelay; |
| 532 | v8::Isolate* m_isolate; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 533 | }; |
| 534 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 535 | class CJS_Field : public CJS_Object { |
| 536 | public: |
Tom Sepez | 808a99e | 2015-09-10 12:28:37 -0700 | [diff] [blame] | 537 | CJS_Field(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {} |
Lei Zhang | 2b1a2d5 | 2015-08-14 22:16:22 -0700 | [diff] [blame] | 538 | ~CJS_Field(void) override {} |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 539 | |
Lei Zhang | 2b1a2d5 | 2015-08-14 22:16:22 -0700 | [diff] [blame] | 540 | FX_BOOL InitInstance(IFXJS_Context* cc) override; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 541 | |
Tom Sepez | cd56a7d | 2015-10-06 11:45:28 -0700 | [diff] [blame^] | 542 | DECLARE_JS_CLASS(); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 543 | JS_STATIC_PROP(alignment, Field); |
| 544 | JS_STATIC_PROP(borderStyle, Field); |
| 545 | JS_STATIC_PROP(buttonAlignX, Field); |
| 546 | JS_STATIC_PROP(buttonAlignY, Field); |
| 547 | JS_STATIC_PROP(buttonFitBounds, Field); |
| 548 | JS_STATIC_PROP(buttonPosition, Field); |
| 549 | JS_STATIC_PROP(buttonScaleHow, Field); |
| 550 | JS_STATIC_PROP(buttonScaleWhen, Field); |
| 551 | JS_STATIC_PROP(calcOrderIndex, Field); |
| 552 | JS_STATIC_PROP(charLimit, Field); |
| 553 | JS_STATIC_PROP(comb, Field); |
| 554 | JS_STATIC_PROP(commitOnSelChange, Field); |
| 555 | JS_STATIC_PROP(currentValueIndices, Field); |
| 556 | JS_STATIC_PROP(defaultStyle, Field); |
| 557 | JS_STATIC_PROP(defaultValue, Field); |
| 558 | JS_STATIC_PROP(doNotScroll, Field); |
| 559 | JS_STATIC_PROP(doNotSpellCheck, Field); |
| 560 | JS_STATIC_PROP(delay, Field); |
| 561 | JS_STATIC_PROP(display, Field); |
| 562 | JS_STATIC_PROP(doc, Field); |
| 563 | JS_STATIC_PROP(editable, Field); |
| 564 | JS_STATIC_PROP(exportValues, Field); |
| 565 | JS_STATIC_PROP(fileSelect, Field); |
| 566 | JS_STATIC_PROP(fillColor, Field); |
| 567 | JS_STATIC_PROP(hidden, Field); |
| 568 | JS_STATIC_PROP(highlight, Field); |
| 569 | JS_STATIC_PROP(lineWidth, Field); |
| 570 | JS_STATIC_PROP(multiline, Field); |
| 571 | JS_STATIC_PROP(multipleSelection, Field); |
| 572 | JS_STATIC_PROP(name, Field); |
| 573 | JS_STATIC_PROP(numItems, Field); |
| 574 | JS_STATIC_PROP(page, Field); |
| 575 | JS_STATIC_PROP(password, Field); |
| 576 | JS_STATIC_PROP(print, Field); |
| 577 | JS_STATIC_PROP(radiosInUnison, Field); |
| 578 | JS_STATIC_PROP(readonly, Field); |
| 579 | JS_STATIC_PROP(rect, Field); |
| 580 | JS_STATIC_PROP(required, Field); |
| 581 | JS_STATIC_PROP(richText, Field); |
| 582 | JS_STATIC_PROP(richValue, Field); |
| 583 | JS_STATIC_PROP(rotation, Field); |
| 584 | JS_STATIC_PROP(strokeColor, Field); |
| 585 | JS_STATIC_PROP(style, Field); |
| 586 | JS_STATIC_PROP(submitName, Field); |
| 587 | JS_STATIC_PROP(textColor, Field); |
| 588 | JS_STATIC_PROP(textFont, Field); |
| 589 | JS_STATIC_PROP(textSize, Field); |
| 590 | JS_STATIC_PROP(type, Field); |
| 591 | JS_STATIC_PROP(userName, Field); |
| 592 | JS_STATIC_PROP(value, Field); |
| 593 | JS_STATIC_PROP(valueAsString, Field); |
| 594 | JS_STATIC_PROP(source, Field); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 595 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 596 | JS_STATIC_METHOD(browseForFileToSubmit, Field); |
| 597 | JS_STATIC_METHOD(buttonGetCaption, Field); |
| 598 | JS_STATIC_METHOD(buttonGetIcon, Field); |
| 599 | JS_STATIC_METHOD(buttonImportIcon, Field); |
| 600 | JS_STATIC_METHOD(buttonSetCaption, Field); |
| 601 | JS_STATIC_METHOD(buttonSetIcon, Field); |
| 602 | JS_STATIC_METHOD(checkThisBox, Field); |
| 603 | JS_STATIC_METHOD(clearItems, Field); |
| 604 | JS_STATIC_METHOD(defaultIsChecked, Field); |
| 605 | JS_STATIC_METHOD(deleteItemAt, Field); |
| 606 | JS_STATIC_METHOD(getArray, Field); |
| 607 | JS_STATIC_METHOD(getItemAt, Field); |
| 608 | JS_STATIC_METHOD(getLock, Field); |
| 609 | JS_STATIC_METHOD(insertItemAt, Field); |
| 610 | JS_STATIC_METHOD(isBoxChecked, Field); |
| 611 | JS_STATIC_METHOD(isDefaultChecked, Field); |
| 612 | JS_STATIC_METHOD(setAction, Field); |
| 613 | JS_STATIC_METHOD(setFocus, Field); |
| 614 | JS_STATIC_METHOD(setItems, Field); |
| 615 | JS_STATIC_METHOD(setLock, Field); |
| 616 | JS_STATIC_METHOD(signatureGetModifications, Field); |
| 617 | JS_STATIC_METHOD(signatureGetSeedValue, Field); |
| 618 | JS_STATIC_METHOD(signatureInfo, Field); |
| 619 | JS_STATIC_METHOD(signatureSetSeedValue, Field); |
| 620 | JS_STATIC_METHOD(signatureSign, Field); |
| 621 | JS_STATIC_METHOD(signatureValidate, Field); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 622 | }; |
| 623 | |
Tom Sepez | 3745841 | 2015-10-06 11:33:46 -0700 | [diff] [blame] | 624 | #endif // FPDFSDK_SRC_JAVASCRIPT_FIELD_H_ |