| 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 "Field.h" | 9 #include "Field.h" |
| 10 #include "Icon.h" | 10 #include "Icon.h" |
| (...skipping 1360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1371 sError = JSGetStringFromID(pContext, IDS_STRING_JSVALUEERROR); | 1371 sError = JSGetStringFromID(pContext, IDS_STRING_JSVALUEERROR); |
| 1372 return FALSE; | 1372 return FALSE; |
| 1373 } | 1373 } |
| 1374 | 1374 |
| 1375 CPDF_Dictionary* pPageDict = pDocument->GetPage(nPageNo); | 1375 CPDF_Dictionary* pPageDict = pDocument->GetPage(nPageNo); |
| 1376 if (!pPageDict) | 1376 if (!pPageDict) |
| 1377 return FALSE; | 1377 return FALSE; |
| 1378 | 1378 |
| 1379 CPDF_Page page; | 1379 CPDF_Page page; |
| 1380 page.Load(pDocument, pPageDict); | 1380 page.Load(pDocument, pPageDict); |
| 1381 page.StartParse(); | 1381 page.ParseContent(nullptr); |
| 1382 page.ParseContent(); | |
| 1383 | 1382 |
| 1384 FX_POSITION pos = page.GetFirstObjectPosition(); | 1383 FX_POSITION pos = page.GetFirstObjectPosition(); |
| 1385 | 1384 |
| 1386 int nWords = 0; | 1385 int nWords = 0; |
| 1387 | 1386 |
| 1388 CFX_WideString swRet; | 1387 CFX_WideString swRet; |
| 1389 | 1388 |
| 1390 while (pos) { | 1389 while (pos) { |
| 1391 if (CPDF_PageObject* pPageObj = page.GetNextObject(pos)) { | 1390 if (CPDF_PageObject* pPageObj = page.GetNextObject(pos)) { |
| 1392 if (pPageObj->m_Type == PDFPAGE_TEXT) { | 1391 if (pPageObj->m_Type == PDFPAGE_TEXT) { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1422 } | 1421 } |
| 1423 | 1422 |
| 1424 FX_BOOL Document::getPageNumWords(IJS_Context* cc, | 1423 FX_BOOL Document::getPageNumWords(IJS_Context* cc, |
| 1425 const std::vector<CJS_Value>& params, | 1424 const std::vector<CJS_Value>& params, |
| 1426 CJS_Value& vRet, | 1425 CJS_Value& vRet, |
| 1427 CFX_WideString& sError) { | 1426 CFX_WideString& sError) { |
| 1428 if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) | 1427 if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) |
| 1429 return FALSE; | 1428 return FALSE; |
| 1430 | 1429 |
| 1431 int nPageNo = params.size() > 0 ? params[0].ToInt() : 0; | 1430 int nPageNo = params.size() > 0 ? params[0].ToInt() : 0; |
| 1432 | |
| 1433 CPDF_Document* pDocument = m_pDocument->GetPDFDocument(); | 1431 CPDF_Document* pDocument = m_pDocument->GetPDFDocument(); |
| 1434 CJS_Context* pContext = static_cast<CJS_Context*>(cc); | 1432 CJS_Context* pContext = static_cast<CJS_Context*>(cc); |
| 1435 if (nPageNo < 0 || nPageNo >= pDocument->GetPageCount()) { | 1433 if (nPageNo < 0 || nPageNo >= pDocument->GetPageCount()) { |
| 1436 sError = JSGetStringFromID(pContext, IDS_STRING_JSVALUEERROR); | 1434 sError = JSGetStringFromID(pContext, IDS_STRING_JSVALUEERROR); |
| 1437 return FALSE; | 1435 return FALSE; |
| 1438 } | 1436 } |
| 1439 | 1437 |
| 1440 CPDF_Dictionary* pPageDict = pDocument->GetPage(nPageNo); | 1438 CPDF_Dictionary* pPageDict = pDocument->GetPage(nPageNo); |
| 1441 if (!pPageDict) | 1439 if (!pPageDict) |
| 1442 return FALSE; | 1440 return FALSE; |
| 1443 | 1441 |
| 1444 CPDF_Page page; | 1442 CPDF_Page page; |
| 1445 page.Load(pDocument, pPageDict); | 1443 page.Load(pDocument, pPageDict); |
| 1446 page.StartParse(); | 1444 page.ParseContent(nullptr); |
| 1447 page.ParseContent(); | |
| 1448 | |
| 1449 FX_POSITION pos = page.GetFirstObjectPosition(); | |
| 1450 | 1445 |
| 1451 int nWords = 0; | 1446 int nWords = 0; |
| 1452 | 1447 FX_POSITION pos = page.GetFirstObjectPosition(); |
| 1453 while (pos) { | 1448 while (pos) { |
| 1454 if (CPDF_PageObject* pPageObj = page.GetNextObject(pos)) { | 1449 if (CPDF_PageObject* pPageObj = page.GetNextObject(pos)) { |
| 1455 if (pPageObj->m_Type == PDFPAGE_TEXT) { | 1450 if (pPageObj->m_Type == PDFPAGE_TEXT) { |
| 1456 CPDF_TextObject* pTextObj = (CPDF_TextObject*)pPageObj; | 1451 CPDF_TextObject* pTextObj = (CPDF_TextObject*)pPageObj; |
| 1457 nWords += CountWords(pTextObj); | 1452 nWords += CountWords(pTextObj); |
| 1458 } | 1453 } |
| 1459 } | 1454 } |
| 1460 } | 1455 } |
| 1461 | 1456 |
| 1462 vRet = nWords; | 1457 vRet = nWords; |
| 1463 | |
| 1464 return TRUE; | 1458 return TRUE; |
| 1465 } | 1459 } |
| 1466 | 1460 |
| 1467 FX_BOOL Document::getPrintParams(IJS_Context* cc, | 1461 FX_BOOL Document::getPrintParams(IJS_Context* cc, |
| 1468 const std::vector<CJS_Value>& params, | 1462 const std::vector<CJS_Value>& params, |
| 1469 CJS_Value& vRet, | 1463 CJS_Value& vRet, |
| 1470 CFX_WideString& sError) { | 1464 CFX_WideString& sError) { |
| 1471 CJS_Context* pContext = (CJS_Context*)cc; | 1465 CJS_Context* pContext = (CJS_Context*)cc; |
| 1472 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 1466 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
| 1473 v8::Local<v8::Object> pRetObj = FXJS_NewFxDynamicObj( | 1467 v8::Local<v8::Object> pRetObj = FXJS_NewFxDynamicObj( |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1642 CJS_DelayData* pData = DelayDataForFieldAndControlIndex.GetAt(i); | 1636 CJS_DelayData* pData = DelayDataForFieldAndControlIndex.GetAt(i); |
| 1643 Field::DoDelay(m_pDocument, pData); | 1637 Field::DoDelay(m_pDocument, pData); |
| 1644 DelayDataForFieldAndControlIndex.SetAt(i, NULL); | 1638 DelayDataForFieldAndControlIndex.SetAt(i, NULL); |
| 1645 delete pData; | 1639 delete pData; |
| 1646 } | 1640 } |
| 1647 } | 1641 } |
| 1648 | 1642 |
| 1649 CJS_Document* Document::GetCJSDoc() const { | 1643 CJS_Document* Document::GetCJSDoc() const { |
| 1650 return static_cast<CJS_Document*>(m_pJSObject); | 1644 return static_cast<CJS_Document*>(m_pJSObject); |
| 1651 } | 1645 } |
| OLD | NEW |