| 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 "../../include/javascript/JavaScript.h" | 7 #include "../../include/javascript/JavaScript.h" |
| 8 #include "../../include/javascript/IJavaScript.h" | 8 #include "../../include/javascript/IJavaScript.h" |
| 9 #include "../../include/javascript/JS_Define.h" | 9 #include "../../include/javascript/JS_Define.h" |
| 10 #include "../../include/javascript/JS_Object.h" | 10 #include "../../include/javascript/JS_Object.h" |
| (...skipping 3282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3293 int iSize = params.size(); | 3293 int iSize = params.size(); |
| 3294 if (iSize >= 1) | 3294 if (iSize >= 1) |
| 3295 nface = params[0].ToInt(); | 3295 nface = params[0].ToInt(); |
| 3296 | 3296 |
| 3297 CFX_PtrArray FieldArray; | 3297 CFX_PtrArray FieldArray; |
| 3298 GetFormFields(m_FieldName, FieldArray); | 3298 GetFormFields(m_FieldName, FieldArray); |
| 3299 if (FieldArray.GetSize() <= 0) | 3299 if (FieldArray.GetSize() <= 0) |
| 3300 return FALSE; | 3300 return FALSE; |
| 3301 | 3301 |
| 3302 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); | 3302 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); |
| 3303 ASSERT(pFormField != NULL); | |
| 3304 | |
| 3305 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON) | 3303 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON) |
| 3306 return FALSE; | 3304 return FALSE; |
| 3307 | 3305 |
| 3308 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); | 3306 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); |
| 3309 if (!pFormControl) | 3307 if (!pFormControl) |
| 3310 return FALSE; | 3308 return FALSE; |
| 3311 | 3309 |
| 3312 CJS_Context* pContext = (CJS_Context*)cc; | 3310 CJS_Context* pContext = (CJS_Context*)cc; |
| 3313 ASSERT(pContext != NULL); | |
| 3314 | |
| 3315 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 3311 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
| 3316 ASSERT(pRuntime != NULL); | |
| 3317 | |
| 3318 v8::Local<v8::Object> pObj = | 3312 v8::Local<v8::Object> pObj = |
| 3319 FXJS_NewFxDynamicObj(pRuntime->GetIsolate(), pContext, | 3313 FXJS_NewFxDynamicObj(pRuntime->GetIsolate(), pContext, |
| 3320 FXJS_GetObjDefnID(pRuntime->GetIsolate(), L"Icon")); | 3314 FXJS_GetObjDefnID(pRuntime->GetIsolate(), L"Icon")); |
| 3321 ASSERT(pObj.IsEmpty() == FALSE); | 3315 ASSERT(pObj.IsEmpty() == FALSE); |
| 3322 | 3316 |
| 3323 CJS_Icon* pJS_Icon = (CJS_Icon*)FXJS_GetPrivate(pObj); | 3317 CJS_Icon* pJS_Icon = (CJS_Icon*)FXJS_GetPrivate(pRuntime->GetIsolate(), pObj); |
| 3324 Icon* pIcon = (Icon*)pJS_Icon->GetEmbedObject(); | 3318 Icon* pIcon = (Icon*)pJS_Icon->GetEmbedObject(); |
| 3325 | 3319 |
| 3326 CPDF_Stream* pIconStream = NULL; | 3320 CPDF_Stream* pIconStream = NULL; |
| 3327 if (nface == 0) | 3321 if (nface == 0) |
| 3328 pIconStream = pFormControl->GetNormalIcon(); | 3322 pIconStream = pFormControl->GetNormalIcon(); |
| 3329 else if (nface == 1) | 3323 else if (nface == 1) |
| 3330 pIconStream = pFormControl->GetDownIcon(); | 3324 pIconStream = pFormControl->GetDownIcon(); |
| 3331 else if (nface == 2) | 3325 else if (nface == 2) |
| 3332 pIconStream = pFormControl->GetRolloverIcon(); | 3326 pIconStream = pFormControl->GetRolloverIcon(); |
| 3333 else | 3327 else |
| 3334 return FALSE; | 3328 return FALSE; |
| 3335 | 3329 |
| 3336 pIcon->SetStream(pIconStream); | 3330 pIcon->SetStream(pIconStream); |
| 3337 vRet = pJS_Icon; | 3331 vRet = pJS_Icon; |
| 3338 | 3332 |
| 3339 return TRUE; | 3333 return TRUE; |
| 3340 } | 3334 } |
| 3341 | 3335 |
| 3342 //#pragma warning(default: 4800) | |
| 3343 | |
| 3344 FX_BOOL Field::buttonImportIcon(IFXJS_Context* cc, | 3336 FX_BOOL Field::buttonImportIcon(IFXJS_Context* cc, |
| 3345 const CJS_Parameters& params, | 3337 const CJS_Parameters& params, |
| 3346 CJS_Value& vRet, | 3338 CJS_Value& vRet, |
| 3347 CFX_WideString& sError) { | 3339 CFX_WideString& sError) { |
| 3348 #if 0 | 3340 #if 0 |
| 3349 ASSERT(m_pDocument != NULL); | 3341 ASSERT(m_pDocument != NULL); |
| 3350 | 3342 |
| 3351 CFX_PtrArray FieldArray; | 3343 CFX_PtrArray FieldArray; |
| 3352 GetFormFields(m_FieldName,FieldArray); | 3344 GetFormFields(m_FieldName,FieldArray); |
| 3353 if (FieldArray.GetSize() <= 0) return FALSE; | 3345 if (FieldArray.GetSize() <= 0) return FALSE; |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3519 } | 3511 } |
| 3520 swSort.Sort(JS_COMPARESTRING); | 3512 swSort.Sort(JS_COMPARESTRING); |
| 3521 | 3513 |
| 3522 CJS_Context* pContext = (CJS_Context*)cc; | 3514 CJS_Context* pContext = (CJS_Context*)cc; |
| 3523 ASSERT(pContext != NULL); | 3515 ASSERT(pContext != NULL); |
| 3524 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 3516 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
| 3525 ASSERT(pRuntime != NULL); | 3517 ASSERT(pRuntime != NULL); |
| 3526 | 3518 |
| 3527 CJS_Array FormFieldArray(m_isolate); | 3519 CJS_Array FormFieldArray(m_isolate); |
| 3528 for (int j = 0, jsz = swSort.GetSize(); j < jsz; j++) { | 3520 for (int j = 0, jsz = swSort.GetSize(); j < jsz; j++) { |
| 3529 CFX_WideString* pStr = swSort.GetAt(j); | 3521 nonstd::unique_ptr<CFX_WideString> pStr(swSort.GetAt(j)); |
| 3530 | |
| 3531 v8::Local<v8::Object> pObj = FXJS_NewFxDynamicObj( | 3522 v8::Local<v8::Object> pObj = FXJS_NewFxDynamicObj( |
| 3532 pRuntime->GetIsolate(), pContext, | 3523 pRuntime->GetIsolate(), pContext, |
| 3533 FXJS_GetObjDefnID(pRuntime->GetIsolate(), L"Field")); | 3524 FXJS_GetObjDefnID(pRuntime->GetIsolate(), L"Field")); |
| 3534 ASSERT(pObj.IsEmpty() == FALSE); | 3525 ASSERT(pObj.IsEmpty() == FALSE); |
| 3535 | 3526 |
| 3536 CJS_Field* pJSField = (CJS_Field*)FXJS_GetPrivate(pObj); | 3527 CJS_Field* pJSField = |
| 3528 (CJS_Field*)FXJS_GetPrivate(pRuntime->GetIsolate(), pObj); |
| 3537 Field* pField = (Field*)pJSField->GetEmbedObject(); | 3529 Field* pField = (Field*)pJSField->GetEmbedObject(); |
| 3538 pField->AttachField(m_pJSDoc, *pStr); | 3530 pField->AttachField(m_pJSDoc, *pStr); |
| 3539 | 3531 |
| 3540 CJS_Value FormFieldValue(m_isolate); | 3532 CJS_Value FormFieldValue(m_isolate); |
| 3541 FormFieldValue = pJSField; | 3533 FormFieldValue = pJSField; |
| 3542 FormFieldArray.SetElement(j, FormFieldValue); | 3534 FormFieldArray.SetElement(j, FormFieldValue); |
| 3543 | |
| 3544 delete pStr; | |
| 3545 } | 3535 } |
| 3546 | 3536 |
| 3547 vRet = FormFieldArray; | 3537 vRet = FormFieldArray; |
| 3548 swSort.RemoveAll(); | 3538 swSort.RemoveAll(); |
| 3549 return TRUE; | 3539 return TRUE; |
| 3550 } | 3540 } |
| 3551 | 3541 |
| 3552 FX_BOOL Field::getItemAt(IFXJS_Context* cc, | 3542 FX_BOOL Field::getItemAt(IFXJS_Context* cc, |
| 3553 const CJS_Parameters& params, | 3543 const CJS_Parameters& params, |
| 3554 CJS_Value& vRet, | 3544 CJS_Value& vRet, |
| (...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4050 #define JS_FIELD_MINWIDTH 1 | 4040 #define JS_FIELD_MINWIDTH 1 |
| 4051 #define JS_FIELD_MINHEIGHT 1 | 4041 #define JS_FIELD_MINHEIGHT 1 |
| 4052 | 4042 |
| 4053 void Field::AddField(CPDFSDK_Document* pDocument, | 4043 void Field::AddField(CPDFSDK_Document* pDocument, |
| 4054 int nPageIndex, | 4044 int nPageIndex, |
| 4055 int nFieldType, | 4045 int nFieldType, |
| 4056 const CFX_WideString& sName, | 4046 const CFX_WideString& sName, |
| 4057 const CPDF_Rect& rcCoords) { | 4047 const CPDF_Rect& rcCoords) { |
| 4058 // Not supported. | 4048 // Not supported. |
| 4059 } | 4049 } |
| OLD | NEW |