| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #ifndef FPDFSDK_SRC_JAVASCRIPT_FIELD_H_ | 7 #ifndef FPDFSDK_SRC_JAVASCRIPT_FIELD_H_ |
| 8 #define FPDFSDK_SRC_JAVASCRIPT_FIELD_H_ | 8 #define FPDFSDK_SRC_JAVASCRIPT_FIELD_H_ |
| 9 | 9 |
| 10 #include <string> // For std::wstring. | 10 #include <string> // For std::wstring. |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 CFX_ByteString string; | 82 CFX_ByteString string; |
| 83 CFX_WideString widestring; | 83 CFX_WideString widestring; |
| 84 CPDF_Rect rect; | 84 CPDF_Rect rect; |
| 85 CPWL_Color color; | 85 CPWL_Color color; |
| 86 CFX_DWordArray wordarray; | 86 CFX_DWordArray wordarray; |
| 87 CJS_WideStringArray widestringarray; | 87 CJS_WideStringArray widestringarray; |
| 88 }; | 88 }; |
| 89 | 89 |
| 90 class Field : public CJS_EmbedObj { | 90 class Field : public CJS_EmbedObj { |
| 91 public: | 91 public: |
| 92 Field(CJS_Object* pJSObject); | 92 explicit Field(CJS_Object* pJSObject); |
| 93 ~Field() override; | 93 ~Field() override; |
| 94 | 94 |
| 95 FX_BOOL alignment(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); | 95 FX_BOOL alignment(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); |
| 96 FX_BOOL borderStyle(IJS_Context* cc, | 96 FX_BOOL borderStyle(IJS_Context* cc, |
| 97 CJS_PropValue& vp, | 97 CJS_PropValue& vp, |
| 98 CFX_WideString& sError); | 98 CFX_WideString& sError); |
| 99 FX_BOOL buttonAlignX(IJS_Context* cc, | 99 FX_BOOL buttonAlignX(IJS_Context* cc, |
| 100 CJS_PropValue& vp, | 100 CJS_PropValue& vp, |
| 101 CFX_WideString& sError); | 101 CFX_WideString& sError); |
| 102 FX_BOOL buttonAlignY(IJS_Context* cc, | 102 FX_BOOL buttonAlignY(IJS_Context* cc, |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 CFX_WideString& sError); | 285 CFX_WideString& sError); |
| 286 FX_BOOL signatureSign(IJS_Context* cc, | 286 FX_BOOL signatureSign(IJS_Context* cc, |
| 287 const CJS_Parameters& params, | 287 const CJS_Parameters& params, |
| 288 CJS_Value& vRet, | 288 CJS_Value& vRet, |
| 289 CFX_WideString& sError); | 289 CFX_WideString& sError); |
| 290 FX_BOOL signatureValidate(IJS_Context* cc, | 290 FX_BOOL signatureValidate(IJS_Context* cc, |
| 291 const CJS_Parameters& params, | 291 const CJS_Parameters& params, |
| 292 CJS_Value& vRet, | 292 CJS_Value& vRet, |
| 293 CFX_WideString& sError); | 293 CFX_WideString& sError); |
| 294 | 294 |
| 295 public: | |
| 296 static void SetAlignment(CPDFSDK_Document* pDocument, | 295 static void SetAlignment(CPDFSDK_Document* pDocument, |
| 297 const CFX_WideString& swFieldName, | 296 const CFX_WideString& swFieldName, |
| 298 int nControlIndex, | 297 int nControlIndex, |
| 299 const CFX_ByteString& string); | 298 const CFX_ByteString& string); |
| 300 static void SetBorderStyle(CPDFSDK_Document* pDocument, | 299 static void SetBorderStyle(CPDFSDK_Document* pDocument, |
| 301 const CFX_WideString& swFieldName, | 300 const CFX_WideString& swFieldName, |
| 302 int nControlIndex, | 301 int nControlIndex, |
| 303 const CFX_ByteString& string); | 302 const CFX_ByteString& string); |
| 304 static void SetButtonAlignX(CPDFSDK_Document* pDocument, | 303 static void SetButtonAlignX(CPDFSDK_Document* pDocument, |
| 305 const CFX_WideString& swFieldName, | 304 const CFX_WideString& swFieldName, |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 int number); | 424 int number); |
| 426 static void SetUserName(CPDFSDK_Document* pDocument, | 425 static void SetUserName(CPDFSDK_Document* pDocument, |
| 427 const CFX_WideString& swFieldName, | 426 const CFX_WideString& swFieldName, |
| 428 int nControlIndex, | 427 int nControlIndex, |
| 429 const CFX_WideString& string); | 428 const CFX_WideString& string); |
| 430 static void SetValue(CPDFSDK_Document* pDocument, | 429 static void SetValue(CPDFSDK_Document* pDocument, |
| 431 const CFX_WideString& swFieldName, | 430 const CFX_WideString& swFieldName, |
| 432 int nControlIndex, | 431 int nControlIndex, |
| 433 const CJS_WideStringArray& strArray); | 432 const CJS_WideStringArray& strArray); |
| 434 | 433 |
| 435 public: | |
| 436 static void AddField(CPDFSDK_Document* pDocument, | 434 static void AddField(CPDFSDK_Document* pDocument, |
| 437 int nPageIndex, | 435 int nPageIndex, |
| 438 int nFieldType, | 436 int nFieldType, |
| 439 const CFX_WideString& sName, | 437 const CFX_WideString& sName, |
| 440 const CPDF_Rect& rcCoords); | 438 const CPDF_Rect& rcCoords); |
| 441 | 439 |
| 442 public: | |
| 443 static void UpdateFormField(CPDFSDK_Document* pDocument, | 440 static void UpdateFormField(CPDFSDK_Document* pDocument, |
| 444 CPDF_FormField* pFormField, | 441 CPDF_FormField* pFormField, |
| 445 FX_BOOL bChangeMark, | 442 FX_BOOL bChangeMark, |
| 446 FX_BOOL bResetAP, | 443 FX_BOOL bResetAP, |
| 447 FX_BOOL bRefresh); | 444 FX_BOOL bRefresh); |
| 448 static void UpdateFormControl(CPDFSDK_Document* pDocument, | 445 static void UpdateFormControl(CPDFSDK_Document* pDocument, |
| 449 CPDF_FormControl* pFormControl, | 446 CPDF_FormControl* pFormControl, |
| 450 FX_BOOL bChangeMark, | 447 FX_BOOL bChangeMark, |
| 451 FX_BOOL bResetAP, | 448 FX_BOOL bResetAP, |
| 452 FX_BOOL bRefresh); | 449 FX_BOOL bRefresh); |
| 453 | 450 |
| 454 static CPDFSDK_Widget* GetWidget(CPDFSDK_Document* pDocument, | 451 static CPDFSDK_Widget* GetWidget(CPDFSDK_Document* pDocument, |
| 455 CPDF_FormControl* pFormControl); | 452 CPDF_FormControl* pFormControl); |
| 456 static void GetFormFields(CPDFSDK_Document* pDocument, | 453 static std::vector<CPDF_FormField*> GetFormFields( |
| 457 const CFX_WideString& csFieldName, | 454 CPDFSDK_Document* pDocument, |
| 458 CFX_PtrArray& FieldsArray); | 455 const CFX_WideString& csFieldName); |
| 459 | 456 |
| 460 static void DoDelay(CPDFSDK_Document* pDocument, CJS_DelayData* pData); | 457 static void DoDelay(CPDFSDK_Document* pDocument, CJS_DelayData* pData); |
| 461 | 458 |
| 462 public: | |
| 463 FX_BOOL AttachField(Document* pDocument, const CFX_WideString& csFieldName); | 459 FX_BOOL AttachField(Document* pDocument, const CFX_WideString& csFieldName); |
| 464 void SetDelay(FX_BOOL bDelay); | 460 void SetDelay(FX_BOOL bDelay); |
| 465 void SetIsolate(v8::Isolate* isolate) { m_isolate = isolate; } | 461 void SetIsolate(v8::Isolate* isolate) { m_isolate = isolate; } |
| 466 | 462 |
| 467 protected: | 463 protected: |
| 468 void ParseFieldName(const std::wstring& strFieldNameParsed, | 464 void ParseFieldName(const std::wstring& strFieldNameParsed, |
| 469 std::wstring& strFieldName, | 465 std::wstring& strFieldName, |
| 470 int& iControlNo); | 466 int& iControlNo); |
| 471 void GetFormFields(const CFX_WideString& csFieldName, | 467 std::vector<CPDF_FormField*> GetFormFields( |
| 472 CFX_PtrArray& FieldsArray); | 468 const CFX_WideString& csFieldName) const; |
| 473 CPDF_FormControl* GetSmartFieldControl(CPDF_FormField* pFormField); | 469 CPDF_FormControl* GetSmartFieldControl(CPDF_FormField* pFormField); |
| 474 FX_BOOL ValueIsOccur(CPDF_FormField* pFormField, CFX_WideString csOptLabel); | 470 FX_BOOL ValueIsOccur(CPDF_FormField* pFormField, CFX_WideString csOptLabel); |
| 475 | 471 |
| 476 void AddDelay_Int(enum FIELD_PROP prop, int32_t n); | 472 void AddDelay_Int(enum FIELD_PROP prop, int32_t n); |
| 477 void AddDelay_Bool(enum FIELD_PROP prop, bool b); | 473 void AddDelay_Bool(enum FIELD_PROP prop, bool b); |
| 478 void AddDelay_String(enum FIELD_PROP prop, const CFX_ByteString& string); | 474 void AddDelay_String(enum FIELD_PROP prop, const CFX_ByteString& string); |
| 479 void AddDelay_WideString(enum FIELD_PROP prop, const CFX_WideString& string); | 475 void AddDelay_WideString(enum FIELD_PROP prop, const CFX_WideString& string); |
| 480 void AddDelay_Rect(enum FIELD_PROP prop, const CPDF_Rect& rect); | 476 void AddDelay_Rect(enum FIELD_PROP prop, const CPDF_Rect& rect); |
| 481 void AddDelay_Color(enum FIELD_PROP prop, const CPWL_Color& color); | 477 void AddDelay_Color(enum FIELD_PROP prop, const CPWL_Color& color); |
| 482 void AddDelay_WordArray(enum FIELD_PROP prop, const CFX_DWordArray& array); | 478 void AddDelay_WordArray(enum FIELD_PROP prop, const CFX_DWordArray& array); |
| 483 void AddDelay_WideStringArray(enum FIELD_PROP prop, | 479 void AddDelay_WideStringArray(enum FIELD_PROP prop, |
| 484 const CJS_WideStringArray& array); | 480 const CJS_WideStringArray& array); |
| 485 | 481 |
| 486 void DoDelay(); | 482 void DoDelay(); |
| 487 | 483 |
| 488 public: | 484 public: |
| 489 Document* m_pJSDoc; | 485 Document* m_pJSDoc; |
| 490 CPDFSDK_Document* m_pDocument; | 486 CPDFSDK_Document* m_pDocument; |
| 491 CFX_WideString m_FieldName; | 487 CFX_WideString m_FieldName; |
| 492 int m_nFormControlIndex; | 488 int m_nFormControlIndex; |
| 493 FX_BOOL m_bCanSet; | 489 FX_BOOL m_bCanSet; |
| 494 | 490 |
| 495 FX_BOOL m_bDelay; | 491 FX_BOOL m_bDelay; |
| 496 v8::Isolate* m_isolate; | 492 v8::Isolate* m_isolate; |
| 497 }; | 493 }; |
| 498 | 494 |
| 499 class CJS_Field : public CJS_Object { | 495 class CJS_Field : public CJS_Object { |
| 500 public: | 496 public: |
| 501 CJS_Field(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {} | 497 explicit CJS_Field(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {} |
| 502 ~CJS_Field(void) override {} | 498 ~CJS_Field(void) override {} |
| 503 | 499 |
| 504 void InitInstance(IJS_Runtime* pIRuntime) override; | 500 void InitInstance(IJS_Runtime* pIRuntime) override; |
| 505 | 501 |
| 506 DECLARE_JS_CLASS(); | 502 DECLARE_JS_CLASS(); |
| 507 JS_STATIC_PROP(alignment, Field); | 503 JS_STATIC_PROP(alignment, Field); |
| 508 JS_STATIC_PROP(borderStyle, Field); | 504 JS_STATIC_PROP(borderStyle, Field); |
| 509 JS_STATIC_PROP(buttonAlignX, Field); | 505 JS_STATIC_PROP(buttonAlignX, Field); |
| 510 JS_STATIC_PROP(buttonAlignY, Field); | 506 JS_STATIC_PROP(buttonAlignY, Field); |
| 511 JS_STATIC_PROP(buttonFitBounds, Field); | 507 JS_STATIC_PROP(buttonFitBounds, Field); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 579 JS_STATIC_METHOD(setLock, Field); | 575 JS_STATIC_METHOD(setLock, Field); |
| 580 JS_STATIC_METHOD(signatureGetModifications, Field); | 576 JS_STATIC_METHOD(signatureGetModifications, Field); |
| 581 JS_STATIC_METHOD(signatureGetSeedValue, Field); | 577 JS_STATIC_METHOD(signatureGetSeedValue, Field); |
| 582 JS_STATIC_METHOD(signatureInfo, Field); | 578 JS_STATIC_METHOD(signatureInfo, Field); |
| 583 JS_STATIC_METHOD(signatureSetSeedValue, Field); | 579 JS_STATIC_METHOD(signatureSetSeedValue, Field); |
| 584 JS_STATIC_METHOD(signatureSign, Field); | 580 JS_STATIC_METHOD(signatureSign, Field); |
| 585 JS_STATIC_METHOD(signatureValidate, Field); | 581 JS_STATIC_METHOD(signatureValidate, Field); |
| 586 }; | 582 }; |
| 587 | 583 |
| 588 #endif // FPDFSDK_SRC_JAVASCRIPT_FIELD_H_ | 584 #endif // FPDFSDK_SRC_JAVASCRIPT_FIELD_H_ |
| OLD | NEW |