| 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 "Document.h" | 7 #include "Document.h" |
| 8 | 8 |
| 9 #include "../../../third_party/base/numerics/safe_math.h" | 9 #include "../../../third_party/base/numerics/safe_math.h" |
| 10 #include "../../include/fsdk_mgr.h" // For CPDFDoc_Environment. | 10 #include "../../include/fsdk_mgr.h" // For CPDFDoc_Environment. |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 CFX_WideString wideName = params[0].ToCFXWideString(); | 318 CFX_WideString wideName = params[0].ToCFXWideString(); |
| 319 | 319 |
| 320 CPDFSDK_InterForm* pInterForm = m_pDocument->GetInterForm(); | 320 CPDFSDK_InterForm* pInterForm = m_pDocument->GetInterForm(); |
| 321 CPDF_InterForm* pPDFForm = pInterForm->GetInterForm(); | 321 CPDF_InterForm* pPDFForm = pInterForm->GetInterForm(); |
| 322 if (pPDFForm->CountFields(wideName) <= 0) { | 322 if (pPDFForm->CountFields(wideName) <= 0) { |
| 323 vRet.SetNull(); | 323 vRet.SetNull(); |
| 324 return TRUE; | 324 return TRUE; |
| 325 } | 325 } |
| 326 | 326 |
| 327 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 327 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
| 328 v8::Local<v8::Object> pFieldObj = | 328 v8::Local<v8::Object> pFieldObj = FXJS_NewFxDynamicObj( |
| 329 FXJS_NewFxDynamicObj(pRuntime->GetIsolate(), pContext, | 329 pRuntime->GetIsolate(), pContext, CJS_Field::g_nObjDefnID); |
| 330 FXJS_GetObjDefnID(pRuntime->GetIsolate(), L"Field")); | |
| 331 | 330 |
| 332 v8::Isolate* isolate = GetIsolate(cc); | 331 v8::Isolate* isolate = GetIsolate(cc); |
| 333 CJS_Field* pJSField = (CJS_Field*)FXJS_GetPrivate(isolate, pFieldObj); | 332 CJS_Field* pJSField = (CJS_Field*)FXJS_GetPrivate(isolate, pFieldObj); |
| 334 Field* pField = (Field*)pJSField->GetEmbedObject(); | 333 Field* pField = (Field*)pJSField->GetEmbedObject(); |
| 335 pField->AttachField(this, wideName); | 334 pField->AttachField(this, wideName); |
| 336 | 335 |
| 337 vRet = pJSField; | 336 vRet = pJSField; |
| 338 return TRUE; | 337 return TRUE; |
| 339 } | 338 } |
| 340 | 339 |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 cTo.c_str(), cSubject.c_str(), cCc.c_str(), cBcc.c_str(), | 433 cTo.c_str(), cSubject.c_str(), cCc.c_str(), cBcc.c_str(), |
| 435 cMsg.c_str()); | 434 cMsg.c_str()); |
| 436 pRuntime->EndBlock(); | 435 pRuntime->EndBlock(); |
| 437 return TRUE; | 436 return TRUE; |
| 438 } | 437 } |
| 439 | 438 |
| 440 FX_BOOL Document::print(IFXJS_Context* cc, | 439 FX_BOOL Document::print(IFXJS_Context* cc, |
| 441 const CJS_Parameters& params, | 440 const CJS_Parameters& params, |
| 442 CJS_Value& vRet, | 441 CJS_Value& vRet, |
| 443 CFX_WideString& sError) { | 442 CFX_WideString& sError) { |
| 444 CJS_Context* pContext = (CJS_Context*)cc; | |
| 445 ASSERT(pContext != NULL); | |
| 446 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | |
| 447 ASSERT(pRuntime != NULL); | |
| 448 | |
| 449 FX_BOOL bUI = TRUE; | 443 FX_BOOL bUI = TRUE; |
| 450 int nStart = 0; | 444 int nStart = 0; |
| 451 int nEnd = 0; | 445 int nEnd = 0; |
| 452 FX_BOOL bSilent = FALSE; | 446 FX_BOOL bSilent = FALSE; |
| 453 FX_BOOL bShrinkToFit = FALSE; | 447 FX_BOOL bShrinkToFit = FALSE; |
| 454 FX_BOOL bPrintAsImage = FALSE; | 448 FX_BOOL bPrintAsImage = FALSE; |
| 455 FX_BOOL bReverse = FALSE; | 449 FX_BOOL bReverse = FALSE; |
| 456 FX_BOOL bAnnotations = FALSE; | 450 FX_BOOL bAnnotations = FALSE; |
| 457 | 451 |
| 458 int nlength = params.size(); | 452 int nlength = params.size(); |
| 459 if (nlength == 9) { | 453 if (nlength == 9) { |
| 460 if (params[8].GetType() == CJS_Value::VT_fxobject) { | 454 if (params[8].GetType() == CJS_Value::VT_fxobject) { |
| 461 v8::Local<v8::Object> pObj = params[8].ToV8Object(); | 455 v8::Local<v8::Object> pObj = params[8].ToV8Object(); |
| 462 { | 456 { |
| 463 if (FXJS_GetObjDefnID(pObj) == | 457 if (FXJS_GetObjDefnID(pObj) == CJS_PrintParamsObj::g_nObjDefnID) { |
| 464 FXJS_GetObjDefnID(pRuntime->GetIsolate(), L"PrintParamsObj")) { | |
| 465 if (CJS_Object* pJSObj = params[8].ToCJSObject()) { | 458 if (CJS_Object* pJSObj = params[8].ToCJSObject()) { |
| 466 if (PrintParamsObj* pprintparamsObj = | 459 if (PrintParamsObj* pprintparamsObj = |
| 467 (PrintParamsObj*)pJSObj->GetEmbedObject()) { | 460 (PrintParamsObj*)pJSObj->GetEmbedObject()) { |
| 468 bUI = pprintparamsObj->bUI; | 461 bUI = pprintparamsObj->bUI; |
| 469 nStart = pprintparamsObj->nStart; | 462 nStart = pprintparamsObj->nStart; |
| 470 nEnd = pprintparamsObj->nEnd; | 463 nEnd = pprintparamsObj->nEnd; |
| 471 bSilent = pprintparamsObj->bSilent; | 464 bSilent = pprintparamsObj->bSilent; |
| 472 bShrinkToFit = pprintparamsObj->bShrinkToFit; | 465 bShrinkToFit = pprintparamsObj->bShrinkToFit; |
| 473 bPrintAsImage = pprintparamsObj->bPrintAsImage; | 466 bPrintAsImage = pprintparamsObj->bPrintAsImage; |
| 474 bReverse = pprintparamsObj->bReverse; | 467 bReverse = pprintparamsObj->bReverse; |
| (...skipping 928 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1403 if (params.size() != 2) { | 1396 if (params.size() != 2) { |
| 1404 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); | 1397 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); |
| 1405 return FALSE; | 1398 return FALSE; |
| 1406 } | 1399 } |
| 1407 CFX_WideString swIconName = params[0].ToCFXWideString(); | 1400 CFX_WideString swIconName = params[0].ToCFXWideString(); |
| 1408 | 1401 |
| 1409 if (params[1].GetType() != CJS_Value::VT_object) { | 1402 if (params[1].GetType() != CJS_Value::VT_object) { |
| 1410 sError = JSGetStringFromID(pContext, IDS_STRING_JSTYPEERROR); | 1403 sError = JSGetStringFromID(pContext, IDS_STRING_JSTYPEERROR); |
| 1411 return FALSE; | 1404 return FALSE; |
| 1412 } | 1405 } |
| 1406 |
| 1413 v8::Local<v8::Object> pJSIcon = params[1].ToV8Object(); | 1407 v8::Local<v8::Object> pJSIcon = params[1].ToV8Object(); |
| 1414 | 1408 if (FXJS_GetObjDefnID(pJSIcon) != CJS_Icon::g_nObjDefnID) { |
| 1415 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | |
| 1416 if (FXJS_GetObjDefnID(pJSIcon) != | |
| 1417 FXJS_GetObjDefnID(pRuntime->GetIsolate(), L"Icon")) { | |
| 1418 sError = JSGetStringFromID(pContext, IDS_STRING_JSTYPEERROR); | 1409 sError = JSGetStringFromID(pContext, IDS_STRING_JSTYPEERROR); |
| 1419 return FALSE; | 1410 return FALSE; |
| 1420 } | 1411 } |
| 1421 | 1412 |
| 1422 CJS_EmbedObj* pEmbedObj = params[1].ToCJSObject()->GetEmbedObject(); | 1413 CJS_EmbedObj* pEmbedObj = params[1].ToCJSObject()->GetEmbedObject(); |
| 1423 if (!pEmbedObj) { | 1414 if (!pEmbedObj) { |
| 1424 sError = JSGetStringFromID(pContext, IDS_STRING_JSTYPEERROR); | 1415 sError = JSGetStringFromID(pContext, IDS_STRING_JSTYPEERROR); |
| 1425 return FALSE; | 1416 return FALSE; |
| 1426 } | 1417 } |
| 1427 | 1418 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1455 IconElement* pIconElement = NULL; | 1446 IconElement* pIconElement = NULL; |
| 1456 int iIconTreeLength = m_pIconTree->GetLength(); | 1447 int iIconTreeLength = m_pIconTree->GetLength(); |
| 1457 | 1448 |
| 1458 CJS_Context* pContext = (CJS_Context*)cc; | 1449 CJS_Context* pContext = (CJS_Context*)cc; |
| 1459 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 1450 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
| 1460 | 1451 |
| 1461 for (int i = 0; i < iIconTreeLength; i++) { | 1452 for (int i = 0; i < iIconTreeLength; i++) { |
| 1462 pIconElement = (*m_pIconTree)[i]; | 1453 pIconElement = (*m_pIconTree)[i]; |
| 1463 | 1454 |
| 1464 v8::Local<v8::Object> pObj = FXJS_NewFxDynamicObj( | 1455 v8::Local<v8::Object> pObj = FXJS_NewFxDynamicObj( |
| 1465 pRuntime->GetIsolate(), pContext, | 1456 pRuntime->GetIsolate(), pContext, CJS_Icon::g_nObjDefnID); |
| 1466 FXJS_GetObjDefnID(pRuntime->GetIsolate(), L"Icon")); | |
| 1467 if (pObj.IsEmpty()) | 1457 if (pObj.IsEmpty()) |
| 1468 return FALSE; | 1458 return FALSE; |
| 1469 | 1459 |
| 1470 CJS_Icon* pJS_Icon = (CJS_Icon*)FXJS_GetPrivate(m_isolate, pObj); | 1460 CJS_Icon* pJS_Icon = (CJS_Icon*)FXJS_GetPrivate(m_isolate, pObj); |
| 1471 if (!pJS_Icon) | 1461 if (!pJS_Icon) |
| 1472 return FALSE; | 1462 return FALSE; |
| 1473 | 1463 |
| 1474 Icon* pIcon = (Icon*)pJS_Icon->GetEmbedObject(); | 1464 Icon* pIcon = (Icon*)pJS_Icon->GetEmbedObject(); |
| 1475 if (!pIcon) | 1465 if (!pIcon) |
| 1476 return FALSE; | 1466 return FALSE; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1499 CFX_WideString swIconName = params[0].ToCFXWideString(); | 1489 CFX_WideString swIconName = params[0].ToCFXWideString(); |
| 1500 int iIconCounts = m_pIconTree->GetLength(); | 1490 int iIconCounts = m_pIconTree->GetLength(); |
| 1501 | 1491 |
| 1502 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 1492 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
| 1503 | 1493 |
| 1504 for (int i = 0; i < iIconCounts; i++) { | 1494 for (int i = 0; i < iIconCounts; i++) { |
| 1505 if ((*m_pIconTree)[i]->IconName == swIconName) { | 1495 if ((*m_pIconTree)[i]->IconName == swIconName) { |
| 1506 Icon* pRetIcon = (*m_pIconTree)[i]->IconStream; | 1496 Icon* pRetIcon = (*m_pIconTree)[i]->IconStream; |
| 1507 | 1497 |
| 1508 v8::Local<v8::Object> pObj = FXJS_NewFxDynamicObj( | 1498 v8::Local<v8::Object> pObj = FXJS_NewFxDynamicObj( |
| 1509 pRuntime->GetIsolate(), pContext, | 1499 pRuntime->GetIsolate(), pContext, CJS_Icon::g_nObjDefnID); |
| 1510 FXJS_GetObjDefnID(pRuntime->GetIsolate(), L"Icon")); | |
| 1511 if (pObj.IsEmpty()) | 1500 if (pObj.IsEmpty()) |
| 1512 return FALSE; | 1501 return FALSE; |
| 1513 | 1502 |
| 1514 CJS_Icon* pJS_Icon = (CJS_Icon*)FXJS_GetPrivate(m_isolate, pObj); | 1503 CJS_Icon* pJS_Icon = (CJS_Icon*)FXJS_GetPrivate(m_isolate, pObj); |
| 1515 if (!pJS_Icon) | 1504 if (!pJS_Icon) |
| 1516 return FALSE; | 1505 return FALSE; |
| 1517 | 1506 |
| 1518 Icon* pIcon = (Icon*)pJS_Icon->GetEmbedObject(); | 1507 Icon* pIcon = (Icon*)pJS_Icon->GetEmbedObject(); |
| 1519 if (!pIcon) | 1508 if (!pIcon) |
| 1520 return FALSE; | 1509 return FALSE; |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1701 return TRUE; | 1690 return TRUE; |
| 1702 } | 1691 } |
| 1703 | 1692 |
| 1704 FX_BOOL Document::getPrintParams(IFXJS_Context* cc, | 1693 FX_BOOL Document::getPrintParams(IFXJS_Context* cc, |
| 1705 const CJS_Parameters& params, | 1694 const CJS_Parameters& params, |
| 1706 CJS_Value& vRet, | 1695 CJS_Value& vRet, |
| 1707 CFX_WideString& sError) { | 1696 CFX_WideString& sError) { |
| 1708 CJS_Context* pContext = (CJS_Context*)cc; | 1697 CJS_Context* pContext = (CJS_Context*)cc; |
| 1709 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 1698 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
| 1710 v8::Local<v8::Object> pRetObj = FXJS_NewFxDynamicObj( | 1699 v8::Local<v8::Object> pRetObj = FXJS_NewFxDynamicObj( |
| 1711 pRuntime->GetIsolate(), pContext, | 1700 pRuntime->GetIsolate(), pContext, CJS_PrintParamsObj::g_nObjDefnID); |
| 1712 FXJS_GetObjDefnID(pRuntime->GetIsolate(), L"PrintParamsObj")); | |
| 1713 | 1701 |
| 1714 // Not implemented yet. | 1702 // Not implemented yet. |
| 1715 | 1703 |
| 1716 vRet = pRetObj; | 1704 vRet = pRetObj; |
| 1717 return TRUE; | 1705 return TRUE; |
| 1718 } | 1706 } |
| 1719 | 1707 |
| 1720 #define ISLATINWORD(u) (u != 0x20 && u <= 0x28FF) | 1708 #define ISLATINWORD(u) (u != 0x20 && u <= 0x28FF) |
| 1721 | 1709 |
| 1722 int Document::CountWords(CPDF_TextObject* pTextObj) { | 1710 int Document::CountWords(CPDF_TextObject* pTextObj) { |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1929 CFX_DWordArray DelArray; | 1917 CFX_DWordArray DelArray; |
| 1930 | 1918 |
| 1931 for (int j = DelArray.GetSize() - 1; j >= 0; j--) { | 1919 for (int j = DelArray.GetSize() - 1; j >= 0; j--) { |
| 1932 m_DelayData.RemoveAt(DelArray[j]); | 1920 m_DelayData.RemoveAt(DelArray[j]); |
| 1933 } | 1921 } |
| 1934 } | 1922 } |
| 1935 | 1923 |
| 1936 CJS_Document* Document::GetCJSDoc() const { | 1924 CJS_Document* Document::GetCJSDoc() const { |
| 1937 return static_cast<CJS_Document*>(m_pJSObject); | 1925 return static_cast<CJS_Document*>(m_pJSObject); |
| 1938 } | 1926 } |
| OLD | NEW |