Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(22)

Side by Side Diff: fpdfsdk/javascript/Document.cpp

Issue 1918113002: Clean up CPDF_Page. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: More cleanup, fix build Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« fpdfsdk/fpdfview.cpp ('K') | « fpdfsdk/fpdfxfa/fpdfxfa_page.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/javascript/Document.h" 7 #include "fpdfsdk/javascript/Document.h"
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 1330 matching lines...) Expand 10 before | Expand all | Expand 10 after
1341 CJS_Context* pContext = static_cast<CJS_Context*>(cc); 1341 CJS_Context* pContext = static_cast<CJS_Context*>(cc);
1342 if (nPageNo < 0 || nPageNo >= pDocument->GetPageCount()) { 1342 if (nPageNo < 0 || nPageNo >= pDocument->GetPageCount()) {
1343 sError = JSGetStringFromID(pContext, IDS_STRING_JSVALUEERROR); 1343 sError = JSGetStringFromID(pContext, IDS_STRING_JSVALUEERROR);
1344 return FALSE; 1344 return FALSE;
1345 } 1345 }
1346 1346
1347 CPDF_Dictionary* pPageDict = pDocument->GetPage(nPageNo); 1347 CPDF_Dictionary* pPageDict = pDocument->GetPage(nPageNo);
1348 if (!pPageDict) 1348 if (!pPageDict)
1349 return FALSE; 1349 return FALSE;
1350 1350
1351 CPDF_Page page; 1351 CPDF_Page page(pDocument, pPageDict, true);
1352 page.Load(pDocument, pPageDict); 1352 page.ParseContent();
1353 page.ParseContent(nullptr);
1354 1353
1355 int nWords = 0; 1354 int nWords = 0;
1356 CFX_WideString swRet; 1355 CFX_WideString swRet;
1357 for (auto& pPageObj : *page.GetPageObjectList()) { 1356 for (auto& pPageObj : *page.GetPageObjectList()) {
1358 if (pPageObj->IsText()) { 1357 if (pPageObj->IsText()) {
1359 CPDF_TextObject* pTextObj = pPageObj->AsText(); 1358 CPDF_TextObject* pTextObj = pPageObj->AsText();
1360 int nObjWords = CountWords(pTextObj); 1359 int nObjWords = CountWords(pTextObj);
1361 if (nWords + nObjWords >= nWordNo) { 1360 if (nWords + nObjWords >= nWordNo) {
1362 swRet = GetObjWordStr(pTextObj, nWordNo - nWords); 1361 swRet = GetObjWordStr(pTextObj, nWordNo - nWords);
1363 break; 1362 break;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1397 CJS_Context* pContext = static_cast<CJS_Context*>(cc); 1396 CJS_Context* pContext = static_cast<CJS_Context*>(cc);
1398 if (nPageNo < 0 || nPageNo >= pDocument->GetPageCount()) { 1397 if (nPageNo < 0 || nPageNo >= pDocument->GetPageCount()) {
1399 sError = JSGetStringFromID(pContext, IDS_STRING_JSVALUEERROR); 1398 sError = JSGetStringFromID(pContext, IDS_STRING_JSVALUEERROR);
1400 return FALSE; 1399 return FALSE;
1401 } 1400 }
1402 1401
1403 CPDF_Dictionary* pPageDict = pDocument->GetPage(nPageNo); 1402 CPDF_Dictionary* pPageDict = pDocument->GetPage(nPageNo);
1404 if (!pPageDict) 1403 if (!pPageDict)
1405 return FALSE; 1404 return FALSE;
1406 1405
1407 CPDF_Page page; 1406 CPDF_Page page(pDocument, pPageDict, true);
1408 page.Load(pDocument, pPageDict); 1407 page.ParseContent();
1409 page.ParseContent(nullptr);
1410 1408
1411 int nWords = 0; 1409 int nWords = 0;
1412 for (auto& pPageObj : *page.GetPageObjectList()) { 1410 for (auto& pPageObj : *page.GetPageObjectList()) {
1413 if (pPageObj->IsText()) 1411 if (pPageObj->IsText())
1414 nWords += CountWords(pPageObj->AsText()); 1412 nWords += CountWords(pPageObj->AsText());
1415 } 1413 }
1416 1414
1417 vRet = nWords; 1415 vRet = nWords;
1418 return TRUE; 1416 return TRUE;
1419 } 1417 }
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
1584 } 1582 }
1585 } 1583 }
1586 1584
1587 for (const auto& pData : DelayDataForFieldAndControlIndex) 1585 for (const auto& pData : DelayDataForFieldAndControlIndex)
1588 Field::DoDelay(m_pDocument, pData.get()); 1586 Field::DoDelay(m_pDocument, pData.get());
1589 } 1587 }
1590 1588
1591 CJS_Document* Document::GetCJSDoc() const { 1589 CJS_Document* Document::GetCJSDoc() const {
1592 return static_cast<CJS_Document*>(m_pJSObject); 1590 return static_cast<CJS_Document*>(m_pJSObject);
1593 } 1591 }
OLDNEW
« fpdfsdk/fpdfview.cpp ('K') | « fpdfsdk/fpdfxfa/fpdfxfa_page.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698