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 "fpdfsdk/src/javascript/Document.h" | 7 #include "fpdfsdk/src/javascript/Document.h" |
8 | 8 |
9 #include "fpdfsdk/include/fsdk_mgr.h" // For CPDFDoc_Environment. | 9 #include "fpdfsdk/include/fsdk_mgr.h" // For CPDFDoc_Environment. |
10 #include "fpdfsdk/include/javascript/IJavaScript.h" | 10 #include "fpdfsdk/include/javascript/IJavaScript.h" |
(...skipping 1365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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.ParseContent(nullptr); | 1381 page.ParseContent(nullptr); |
1382 | 1382 |
1383 int nWords = 0; | 1383 int nWords = 0; |
1384 CFX_WideString swRet; | 1384 CFX_WideString swRet; |
1385 for (auto& pPageObj : *page.GetPageObjectList()) { | 1385 for (auto& pPageObj : *page.GetPageObjectList()) { |
1386 if (pPageObj->m_Type == CPDF_PageObject::TEXT) { | 1386 if (pPageObj->IsText()) { |
1387 CPDF_TextObject* pTextObj = static_cast<CPDF_TextObject*>(pPageObj.get()); | 1387 CPDF_TextObject* pTextObj = pPageObj->AsText(); |
1388 int nObjWords = CountWords(pTextObj); | 1388 int nObjWords = CountWords(pTextObj); |
1389 if (nWords + nObjWords >= nWordNo) { | 1389 if (nWords + nObjWords >= nWordNo) { |
1390 swRet = GetObjWordStr(pTextObj, nWordNo - nWords); | 1390 swRet = GetObjWordStr(pTextObj, nWordNo - nWords); |
1391 break; | 1391 break; |
1392 } | 1392 } |
1393 nWords += nObjWords; | 1393 nWords += nObjWords; |
1394 } | 1394 } |
1395 } | 1395 } |
1396 | 1396 |
1397 if (bStrip) { | 1397 if (bStrip) { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1431 CPDF_Dictionary* pPageDict = pDocument->GetPage(nPageNo); | 1431 CPDF_Dictionary* pPageDict = pDocument->GetPage(nPageNo); |
1432 if (!pPageDict) | 1432 if (!pPageDict) |
1433 return FALSE; | 1433 return FALSE; |
1434 | 1434 |
1435 CPDF_Page page; | 1435 CPDF_Page page; |
1436 page.Load(pDocument, pPageDict); | 1436 page.Load(pDocument, pPageDict); |
1437 page.ParseContent(nullptr); | 1437 page.ParseContent(nullptr); |
1438 | 1438 |
1439 int nWords = 0; | 1439 int nWords = 0; |
1440 for (auto& pPageObj : *page.GetPageObjectList()) { | 1440 for (auto& pPageObj : *page.GetPageObjectList()) { |
1441 if (pPageObj->m_Type == CPDF_PageObject::TEXT) | 1441 if (pPageObj->IsText()) |
1442 nWords += CountWords(static_cast<CPDF_TextObject*>(pPageObj.get())); | 1442 nWords += CountWords(pPageObj->AsText()); |
1443 } | 1443 } |
1444 | 1444 |
1445 vRet = nWords; | 1445 vRet = nWords; |
1446 return TRUE; | 1446 return TRUE; |
1447 } | 1447 } |
1448 | 1448 |
1449 FX_BOOL Document::getPrintParams(IJS_Context* cc, | 1449 FX_BOOL Document::getPrintParams(IJS_Context* cc, |
1450 const std::vector<CJS_Value>& params, | 1450 const std::vector<CJS_Value>& params, |
1451 CJS_Value& vRet, | 1451 CJS_Value& vRet, |
1452 CFX_WideString& sError) { | 1452 CFX_WideString& sError) { |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1624 CJS_DelayData* pData = DelayDataForFieldAndControlIndex.GetAt(i); | 1624 CJS_DelayData* pData = DelayDataForFieldAndControlIndex.GetAt(i); |
1625 Field::DoDelay(m_pDocument, pData); | 1625 Field::DoDelay(m_pDocument, pData); |
1626 DelayDataForFieldAndControlIndex.SetAt(i, NULL); | 1626 DelayDataForFieldAndControlIndex.SetAt(i, NULL); |
1627 delete pData; | 1627 delete pData; |
1628 } | 1628 } |
1629 } | 1629 } |
1630 | 1630 |
1631 CJS_Document* Document::GetCJSDoc() const { | 1631 CJS_Document* Document::GetCJSDoc() const { |
1632 return static_cast<CJS_Document*>(m_pJSObject); | 1632 return static_cast<CJS_Document*>(m_pJSObject); |
1633 } | 1633 } |
OLD | NEW |