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

Side by Side Diff: core/fpdfapi/fpdf_parser/cpdf_document.cpp

Issue 2355813002: CPDF_Document and CPDF_DataAvail are no longer friends (Closed)
Patch Set: Created 4 years, 3 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
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 "core/fpdfapi/fpdf_parser/include/cpdf_document.h" 7 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h"
8 8
9 #include <memory> 9 #include <memory>
10 #include <set> 10 #include <set>
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 } 506 }
507 } 507 }
508 return nullptr; 508 return nullptr;
509 } 509 }
510 510
511 CPDF_Dictionary* CPDF_Document::GetPagesDict() const { 511 CPDF_Dictionary* CPDF_Document::GetPagesDict() const {
512 CPDF_Dictionary* pRoot = GetRoot(); 512 CPDF_Dictionary* pRoot = GetRoot();
513 return pRoot ? pRoot->GetDictFor("Pages") : nullptr; 513 return pRoot ? pRoot->GetDictFor("Pages") : nullptr;
514 } 514 }
515 515
516 bool CPDF_Document::IsPageLoaded(int iPage) {
Tom Sepez 2016/09/20 17:26:04 nit: const method.
dsinclair 2016/09/20 19:21:46 Done.
517 return !!m_PageList.GetAt(iPage);
518 }
519
516 CPDF_Dictionary* CPDF_Document::GetPage(int iPage) { 520 CPDF_Dictionary* CPDF_Document::GetPage(int iPage) {
517 if (iPage < 0 || iPage >= m_PageList.GetSize()) 521 if (iPage < 0 || iPage >= m_PageList.GetSize())
518 return nullptr; 522 return nullptr;
519 523
520 if (m_bLinearized && (iPage == m_iFirstPageNo)) { 524 if (m_bLinearized && (iPage == m_iFirstPageNo)) {
521 if (CPDF_Dictionary* pDict = 525 if (CPDF_Dictionary* pDict =
522 ToDictionary(GetOrParseIndirectObject(m_dwFirstPageObjNum))) { 526 ToDictionary(GetOrParseIndirectObject(m_dwFirstPageObjNum))) {
523 return pDict; 527 return pDict;
524 } 528 }
525 } 529 }
526 530
527 int objnum = m_PageList.GetAt(iPage); 531 int objnum = m_PageList.GetAt(iPage);
528 if (objnum) { 532 if (objnum) {
529 if (CPDF_Dictionary* pDict = ToDictionary(GetOrParseIndirectObject(objnum))) 533 if (CPDF_Dictionary* pDict = ToDictionary(GetOrParseIndirectObject(objnum)))
530 return pDict; 534 return pDict;
531 } 535 }
532 536
533 CPDF_Dictionary* pPages = GetPagesDict(); 537 CPDF_Dictionary* pPages = GetPagesDict();
534 if (!pPages) 538 if (!pPages)
535 return nullptr; 539 return nullptr;
536 540
537 CPDF_Dictionary* pPage = FindPDFPage(pPages, iPage, iPage, 0); 541 CPDF_Dictionary* pPage = FindPDFPage(pPages, iPage, iPage, 0);
538 if (!pPage) 542 if (!pPage)
539 return nullptr; 543 return nullptr;
540 544
541 m_PageList.SetAt(iPage, pPage->GetObjNum()); 545 m_PageList.SetAt(iPage, pPage->GetObjNum());
542 return pPage; 546 return pPage;
543 } 547 }
544 548
549 void CPDF_Document::SetPageObjNum(int iPage, uint32_t objNum) {
550 m_PageList.SetAt(iPage, objNum);
551 }
552
545 int CPDF_Document::FindPageIndex(CPDF_Dictionary* pNode, 553 int CPDF_Document::FindPageIndex(CPDF_Dictionary* pNode,
546 uint32_t& skip_count, 554 uint32_t& skip_count,
547 uint32_t objnum, 555 uint32_t objnum,
548 int& index, 556 int& index,
549 int level) { 557 int level) {
550 if (!pNode->KeyExist("Kids")) { 558 if (!pNode->KeyExist("Kids")) {
551 if (objnum == pNode->GetObjNum()) 559 if (objnum == pNode->GetObjNum())
552 return index; 560 return index;
553 561
554 if (skip_count) 562 if (skip_count)
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
1000 pLogFont->lfWeight / 5); 1008 pLogFont->lfWeight / 5);
1001 pFontDesc->SetIntegerFor("CapHeight", capheight); 1009 pFontDesc->SetIntegerFor("CapHeight", capheight);
1002 AddIndirectObject(pFontDesc); 1010 AddIndirectObject(pFontDesc);
1003 pFontDict->SetReferenceFor("FontDescriptor", this, pFontDesc); 1011 pFontDict->SetReferenceFor("FontDescriptor", this, pFontDesc);
1004 hFont = SelectObject(hDC, hFont); 1012 hFont = SelectObject(hDC, hFont);
1005 DeleteObject(hFont); 1013 DeleteObject(hFont);
1006 DeleteDC(hDC); 1014 DeleteDC(hDC);
1007 return LoadFont(pBaseDict); 1015 return LoadFont(pBaseDict);
1008 } 1016 }
1009 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ 1017 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
OLDNEW
« no previous file with comments | « core/fpdfapi/fpdf_parser/cpdf_data_avail.cpp ('k') | core/fpdfapi/fpdf_parser/include/cpdf_document.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698