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

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

Issue 2266033002: Revert of Move parser pointer to CPDF_Document (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 4 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 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 count++; 475 count++;
476 } 476 }
477 } 477 }
478 pPages->SetAtInteger("Count", count); 478 pPages->SetAtInteger("Count", count);
479 return count; 479 return count;
480 } 480 }
481 481
482 } // namespace 482 } // namespace
483 483
484 CPDF_Document::CPDF_Document(CPDF_Parser* pParser) 484 CPDF_Document::CPDF_Document(CPDF_Parser* pParser)
485 : CPDF_IndirectObjectHolder(), 485 : CPDF_IndirectObjectHolder(pParser),
486 m_pParser(pParser),
487 m_pRootDict(nullptr), 486 m_pRootDict(nullptr),
488 m_pInfoDict(nullptr), 487 m_pInfoDict(nullptr),
489 m_bLinearized(false), 488 m_bLinearized(false),
490 m_iFirstPageNo(0), 489 m_iFirstPageNo(0),
491 m_dwFirstPageObjNum(0), 490 m_dwFirstPageObjNum(0),
492 m_pDocPage(new CPDF_DocPageData(this)), 491 m_pDocPage(new CPDF_DocPageData(this)),
493 m_pDocRender(new CPDF_DocRenderData(this)) { 492 m_pDocRender(new CPDF_DocRenderData(this)) {}
494 if (pParser)
495 SetLastObjNum(m_pParser->GetLastObjNum());
496 }
497 493
498 CPDF_Document::~CPDF_Document() { 494 CPDF_Document::~CPDF_Document() {
499 delete m_pDocPage; 495 delete m_pDocPage;
500 CPDF_ModuleMgr::Get()->GetPageModule()->ClearStockFont(this); 496 CPDF_ModuleMgr::Get()->GetPageModule()->ClearStockFont(this);
501 } 497 }
502 498
503 CPDF_Object* CPDF_Document::ParseIndirectObject(uint32_t objnum) { 499 void CPDF_Document::LoadDocInternal() {
504 return m_pParser ? m_pParser->ParseIndirectObject(this, objnum) : nullptr; 500 m_LastObjNum = m_pParser->GetLastObjNum();
505 }
506 501
507 void CPDF_Document::LoadDocInternal() { 502 CPDF_Object* pRootObj = GetIndirectObject(m_pParser->GetRootObjNum());
508 SetLastObjNum(m_pParser->GetLastObjNum());
509
510 CPDF_Object* pRootObj = GetOrParseIndirectObject(m_pParser->GetRootObjNum());
511 if (!pRootObj) 503 if (!pRootObj)
512 return; 504 return;
513 505
514 m_pRootDict = pRootObj->GetDict(); 506 m_pRootDict = pRootObj->GetDict();
515 if (!m_pRootDict) 507 if (!m_pRootDict)
516 return; 508 return;
517 509
518 CPDF_Object* pInfoObj = GetOrParseIndirectObject(m_pParser->GetInfoObjNum()); 510 CPDF_Object* pInfoObj = GetIndirectObject(m_pParser->GetInfoObjNum());
519 if (pInfoObj) 511 if (pInfoObj)
520 m_pInfoDict = pInfoObj->GetDict(); 512 m_pInfoDict = pInfoObj->GetDict();
521 if (CPDF_Array* pIDArray = m_pParser->GetIDArray()) { 513 if (CPDF_Array* pIDArray = m_pParser->GetIDArray()) {
522 m_ID1 = pIDArray->GetStringAt(0); 514 m_ID1 = pIDArray->GetStringAt(0);
523 m_ID2 = pIDArray->GetStringAt(1); 515 m_ID2 = pIDArray->GetStringAt(1);
524 } 516 }
525 } 517 }
526 518
527 void CPDF_Document::LoadDoc() { 519 void CPDF_Document::LoadDoc() {
528 LoadDocInternal(); 520 LoadDocInternal();
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 } 580 }
589 return nullptr; 581 return nullptr;
590 } 582 }
591 583
592 CPDF_Dictionary* CPDF_Document::GetPage(int iPage) { 584 CPDF_Dictionary* CPDF_Document::GetPage(int iPage) {
593 if (iPage < 0 || iPage >= m_PageList.GetSize()) 585 if (iPage < 0 || iPage >= m_PageList.GetSize())
594 return nullptr; 586 return nullptr;
595 587
596 if (m_bLinearized && (iPage == m_iFirstPageNo)) { 588 if (m_bLinearized && (iPage == m_iFirstPageNo)) {
597 if (CPDF_Dictionary* pDict = 589 if (CPDF_Dictionary* pDict =
598 ToDictionary(GetOrParseIndirectObject(m_dwFirstPageObjNum))) { 590 ToDictionary(GetIndirectObject(m_dwFirstPageObjNum))) {
599 return pDict; 591 return pDict;
600 } 592 }
601 } 593 }
602 594
603 int objnum = m_PageList.GetAt(iPage); 595 int objnum = m_PageList.GetAt(iPage);
604 if (objnum) { 596 if (objnum) {
605 if (CPDF_Dictionary* pDict = ToDictionary(GetOrParseIndirectObject(objnum))) 597 if (CPDF_Dictionary* pDict = ToDictionary(GetIndirectObject(objnum)))
606 return pDict; 598 return pDict;
607 } 599 }
608 600
609 CPDF_Dictionary* pRoot = GetRoot(); 601 CPDF_Dictionary* pRoot = GetRoot();
610 if (!pRoot) 602 if (!pRoot)
611 return nullptr; 603 return nullptr;
612 604
613 CPDF_Dictionary* pPages = pRoot->GetDictBy("Pages"); 605 CPDF_Dictionary* pPages = pRoot->GetDictBy("Pages");
614 if (!pPages) 606 if (!pPages)
615 return nullptr; 607 return nullptr;
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
728 #ifndef PDF_ENABLE_XFA 720 #ifndef PDF_ENABLE_XFA
729 return 0; 721 return 0;
730 #else // PDF_ENABLE_XFA 722 #else // PDF_ENABLE_XFA
731 return 0xFFFFFFFF; 723 return 0xFFFFFFFF;
732 #endif 724 #endif
733 } 725 }
734 return m_pParser->GetPermissions(); 726 return m_pParser->GetPermissions();
735 } 727 }
736 728
737 FX_BOOL CPDF_Document::IsFormStream(uint32_t objnum, FX_BOOL& bForm) const { 729 FX_BOOL CPDF_Document::IsFormStream(uint32_t objnum, FX_BOOL& bForm) const {
738 if (CPDF_Object* pObj = GetIndirectObject(objnum)) { 730 auto it = m_IndirectObjs.find(objnum);
739 CPDF_Stream* pStream = pObj->AsStream(); 731 if (it != m_IndirectObjs.end()) {
732 CPDF_Stream* pStream = it->second->AsStream();
740 bForm = pStream && pStream->GetDict()->GetStringBy("Subtype") == "Form"; 733 bForm = pStream && pStream->GetDict()->GetStringBy("Subtype") == "Form";
741 return TRUE; 734 return TRUE;
742 } 735 }
743 if (!m_pParser) { 736 if (!m_pParser) {
744 bForm = FALSE; 737 bForm = FALSE;
745 return TRUE; 738 return TRUE;
746 } 739 }
747 return m_pParser->IsFormStream(objnum, bForm); 740 return m_pParser->IsFormStream(objnum, bForm);
748 } 741 }
749 742
(...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after
1448 } 1441 }
1449 } 1442 }
1450 pFontDesc->SetAtInteger("StemV", fStemV); 1443 pFontDesc->SetAtInteger("StemV", fStemV);
1451 AddIndirectObject(pFontDesc); 1444 AddIndirectObject(pFontDesc);
1452 pFontDict->SetAtReference("FontDescriptor", this, pFontDesc); 1445 pFontDict->SetAtReference("FontDescriptor", this, pFontDesc);
1453 CFRelease(traits); 1446 CFRelease(traits);
1454 CFRelease(languages); 1447 CFRelease(languages);
1455 return LoadFont(pBaseDict); 1448 return LoadFont(pBaseDict);
1456 } 1449 }
1457 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ 1450 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
OLDNEW
« no previous file with comments | « core/fpdfapi/fpdf_parser/cpdf_data_avail.cpp ('k') | core/fpdfapi/fpdf_parser/cpdf_indirect_object_holder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698