| 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 #include "Field.h" | 7 #include "Field.h" |
| 8 | 8 |
| 9 #include "../../include/fsdk_mgr.h" // For CPDFDoc_Environment. | 9 #include "../../include/fsdk_mgr.h" // For CPDFDoc_Environment. |
| 10 #include "../../include/javascript/IJavaScript.h" | 10 #include "../../include/javascript/IJavaScript.h" |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 JS_STATIC_METHOD_ENTRY(signatureGetModifications) | 103 JS_STATIC_METHOD_ENTRY(signatureGetModifications) |
| 104 JS_STATIC_METHOD_ENTRY(signatureGetSeedValue) | 104 JS_STATIC_METHOD_ENTRY(signatureGetSeedValue) |
| 105 JS_STATIC_METHOD_ENTRY(signatureInfo) | 105 JS_STATIC_METHOD_ENTRY(signatureInfo) |
| 106 JS_STATIC_METHOD_ENTRY(signatureSetSeedValue) | 106 JS_STATIC_METHOD_ENTRY(signatureSetSeedValue) |
| 107 JS_STATIC_METHOD_ENTRY(signatureSign) | 107 JS_STATIC_METHOD_ENTRY(signatureSign) |
| 108 JS_STATIC_METHOD_ENTRY(signatureValidate) | 108 JS_STATIC_METHOD_ENTRY(signatureValidate) |
| 109 END_JS_STATIC_METHOD() | 109 END_JS_STATIC_METHOD() |
| 110 | 110 |
| 111 IMPLEMENT_JS_CLASS(CJS_Field, Field) | 111 IMPLEMENT_JS_CLASS(CJS_Field, Field) |
| 112 | 112 |
| 113 FX_BOOL CJS_Field::InitInstance(IJS_Context* cc) { | 113 void CJS_Field::InitInstance(IJS_Runtime* pIRuntime) { |
| 114 CJS_Context* pContext = (CJS_Context*)cc; | 114 CJS_Runtime* pRuntime = static_cast<CJS_Runtime*>(pIRuntime); |
| 115 ASSERT(pContext != NULL); | 115 Field* pField = static_cast<Field*>(GetEmbedObject()); |
| 116 | 116 pField->SetIsolate(pRuntime->GetIsolate()); |
| 117 Field* pField = (Field*)GetEmbedObject(); | |
| 118 ASSERT(pField != NULL); | |
| 119 | |
| 120 pField->SetIsolate(pContext->GetJSRuntime()->GetIsolate()); | |
| 121 | |
| 122 return TRUE; | |
| 123 }; | 117 }; |
| 124 | 118 |
| 125 Field::Field(CJS_Object* pJSObject) | 119 Field::Field(CJS_Object* pJSObject) |
| 126 : CJS_EmbedObj(pJSObject), | 120 : CJS_EmbedObj(pJSObject), |
| 127 m_pJSDoc(NULL), | 121 m_pJSDoc(NULL), |
| 128 m_pDocument(NULL), | 122 m_pDocument(NULL), |
| 129 m_nFormControlIndex(-1), | 123 m_nFormControlIndex(-1), |
| 130 m_bCanSet(FALSE), | 124 m_bCanSet(FALSE), |
| 131 m_bDelay(FALSE), | 125 m_bDelay(FALSE), |
| 132 m_isolate(NULL) {} | 126 m_isolate(NULL) {} |
| (...skipping 3139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3272 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON) | 3266 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON) |
| 3273 return FALSE; | 3267 return FALSE; |
| 3274 | 3268 |
| 3275 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); | 3269 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); |
| 3276 if (!pFormControl) | 3270 if (!pFormControl) |
| 3277 return FALSE; | 3271 return FALSE; |
| 3278 | 3272 |
| 3279 CJS_Context* pContext = (CJS_Context*)cc; | 3273 CJS_Context* pContext = (CJS_Context*)cc; |
| 3280 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 3274 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
| 3281 v8::Local<v8::Object> pObj = FXJS_NewFxDynamicObj( | 3275 v8::Local<v8::Object> pObj = FXJS_NewFxDynamicObj( |
| 3282 pRuntime->GetIsolate(), pContext, CJS_Icon::g_nObjDefnID); | 3276 pRuntime->GetIsolate(), pRuntime, CJS_Icon::g_nObjDefnID); |
| 3283 ASSERT(pObj.IsEmpty() == FALSE); | 3277 ASSERT(pObj.IsEmpty() == FALSE); |
| 3284 | 3278 |
| 3285 CJS_Icon* pJS_Icon = (CJS_Icon*)FXJS_GetPrivate(pRuntime->GetIsolate(), pObj); | 3279 CJS_Icon* pJS_Icon = (CJS_Icon*)FXJS_GetPrivate(pRuntime->GetIsolate(), pObj); |
| 3286 Icon* pIcon = (Icon*)pJS_Icon->GetEmbedObject(); | 3280 Icon* pIcon = (Icon*)pJS_Icon->GetEmbedObject(); |
| 3287 | 3281 |
| 3288 CPDF_Stream* pIconStream = NULL; | 3282 CPDF_Stream* pIconStream = NULL; |
| 3289 if (nface == 0) | 3283 if (nface == 0) |
| 3290 pIconStream = pFormControl->GetNormalIcon(); | 3284 pIconStream = pFormControl->GetNormalIcon(); |
| 3291 else if (nface == 1) | 3285 else if (nface == 1) |
| 3292 pIconStream = pFormControl->GetDownIcon(); | 3286 pIconStream = pFormControl->GetDownIcon(); |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3481 | 3475 |
| 3482 CJS_Context* pContext = (CJS_Context*)cc; | 3476 CJS_Context* pContext = (CJS_Context*)cc; |
| 3483 ASSERT(pContext != NULL); | 3477 ASSERT(pContext != NULL); |
| 3484 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 3478 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
| 3485 ASSERT(pRuntime != NULL); | 3479 ASSERT(pRuntime != NULL); |
| 3486 | 3480 |
| 3487 CJS_Array FormFieldArray(pRuntime); | 3481 CJS_Array FormFieldArray(pRuntime); |
| 3488 for (int j = 0, jsz = swSort.GetSize(); j < jsz; j++) { | 3482 for (int j = 0, jsz = swSort.GetSize(); j < jsz; j++) { |
| 3489 nonstd::unique_ptr<CFX_WideString> pStr(swSort.GetAt(j)); | 3483 nonstd::unique_ptr<CFX_WideString> pStr(swSort.GetAt(j)); |
| 3490 v8::Local<v8::Object> pObj = FXJS_NewFxDynamicObj( | 3484 v8::Local<v8::Object> pObj = FXJS_NewFxDynamicObj( |
| 3491 pRuntime->GetIsolate(), pContext, CJS_Field::g_nObjDefnID); | 3485 pRuntime->GetIsolate(), pRuntime, CJS_Field::g_nObjDefnID); |
| 3492 ASSERT(!pObj.IsEmpty()); | 3486 ASSERT(!pObj.IsEmpty()); |
| 3493 | 3487 |
| 3494 CJS_Field* pJSField = | 3488 CJS_Field* pJSField = |
| 3495 (CJS_Field*)FXJS_GetPrivate(pRuntime->GetIsolate(), pObj); | 3489 (CJS_Field*)FXJS_GetPrivate(pRuntime->GetIsolate(), pObj); |
| 3496 Field* pField = (Field*)pJSField->GetEmbedObject(); | 3490 Field* pField = (Field*)pJSField->GetEmbedObject(); |
| 3497 pField->AttachField(m_pJSDoc, *pStr); | 3491 pField->AttachField(m_pJSDoc, *pStr); |
| 3498 | 3492 |
| 3499 CJS_Value FormFieldValue(pRuntime); | 3493 CJS_Value FormFieldValue(pRuntime); |
| 3500 FormFieldValue = pJSField; | 3494 FormFieldValue = pJSField; |
| 3501 FormFieldArray.SetElement(j, FormFieldValue); | 3495 FormFieldArray.SetElement(j, FormFieldValue); |
| (...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4007 #define JS_FIELD_MINWIDTH 1 | 4001 #define JS_FIELD_MINWIDTH 1 |
| 4008 #define JS_FIELD_MINHEIGHT 1 | 4002 #define JS_FIELD_MINHEIGHT 1 |
| 4009 | 4003 |
| 4010 void Field::AddField(CPDFSDK_Document* pDocument, | 4004 void Field::AddField(CPDFSDK_Document* pDocument, |
| 4011 int nPageIndex, | 4005 int nPageIndex, |
| 4012 int nFieldType, | 4006 int nFieldType, |
| 4013 const CFX_WideString& sName, | 4007 const CFX_WideString& sName, |
| 4014 const CPDF_Rect& rcCoords) { | 4008 const CPDF_Rect& rcCoords) { |
| 4015 // Not supported. | 4009 // Not supported. |
| 4016 } | 4010 } |
| OLD | NEW |