| 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 "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 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 m_iFirstPageNo(0), | 489 m_iFirstPageNo(0), |
| 490 m_dwFirstPageObjNum(0), | 490 m_dwFirstPageObjNum(0), |
| 491 m_pDocPage(new CPDF_DocPageData(this)), | 491 m_pDocPage(new CPDF_DocPageData(this)), |
| 492 m_pDocRender(new CPDF_DocRenderData(this)) {} | 492 m_pDocRender(new CPDF_DocRenderData(this)) {} |
| 493 | 493 |
| 494 CPDF_Document::~CPDF_Document() { | 494 CPDF_Document::~CPDF_Document() { |
| 495 delete m_pDocPage; | 495 delete m_pDocPage; |
| 496 CPDF_ModuleMgr::Get()->GetPageModule()->ClearStockFont(this); | 496 CPDF_ModuleMgr::Get()->GetPageModule()->ClearStockFont(this); |
| 497 } | 497 } |
| 498 | 498 |
| 499 void CPDF_Document::LoadDoc() { | 499 void CPDF_Document::LoadDocInternal() { |
| 500 m_LastObjNum = m_pParser->GetLastObjNum(); | 500 m_LastObjNum = m_pParser->GetLastObjNum(); |
| 501 |
| 501 CPDF_Object* pRootObj = GetIndirectObject(m_pParser->GetRootObjNum()); | 502 CPDF_Object* pRootObj = GetIndirectObject(m_pParser->GetRootObjNum()); |
| 502 if (!pRootObj) { | 503 if (!pRootObj) |
| 503 return; | 504 return; |
| 504 } | 505 |
| 505 m_pRootDict = pRootObj->GetDict(); | 506 m_pRootDict = pRootObj->GetDict(); |
| 506 if (!m_pRootDict) { | 507 if (!m_pRootDict) |
| 507 return; | 508 return; |
| 508 } | 509 |
| 509 CPDF_Object* pInfoObj = GetIndirectObject(m_pParser->GetInfoObjNum()); | 510 CPDF_Object* pInfoObj = GetIndirectObject(m_pParser->GetInfoObjNum()); |
| 510 if (pInfoObj) { | 511 if (pInfoObj) |
| 511 m_pInfoDict = pInfoObj->GetDict(); | 512 m_pInfoDict = pInfoObj->GetDict(); |
| 512 } | 513 if (CPDF_Array* pIDArray = m_pParser->GetIDArray()) { |
| 513 CPDF_Array* pIDArray = m_pParser->GetIDArray(); | |
| 514 if (pIDArray) { | |
| 515 m_ID1 = pIDArray->GetStringAt(0); | 514 m_ID1 = pIDArray->GetStringAt(0); |
| 516 m_ID2 = pIDArray->GetStringAt(1); | 515 m_ID2 = pIDArray->GetStringAt(1); |
| 517 } | 516 } |
| 517 } |
| 518 |
| 519 void CPDF_Document::LoadDoc() { |
| 520 LoadDocInternal(); |
| 518 m_PageList.SetSize(RetrievePageCount()); | 521 m_PageList.SetSize(RetrievePageCount()); |
| 519 } | 522 } |
| 520 | 523 |
| 521 void CPDF_Document::LoadAsynDoc(CPDF_Dictionary* pLinearized) { | 524 void CPDF_Document::LoadLinearizedDoc(CPDF_Dictionary* pLinearizationParams) { |
| 522 m_bLinearized = true; | 525 m_bLinearized = true; |
| 523 m_LastObjNum = m_pParser->GetLastObjNum(); | 526 LoadDocInternal(); |
| 524 CPDF_Object* pIndirectObj = GetIndirectObject(m_pParser->GetRootObjNum()); | 527 |
| 525 m_pRootDict = pIndirectObj ? pIndirectObj->GetDict() : nullptr; | |
| 526 if (!m_pRootDict) { | |
| 527 return; | |
| 528 } | |
| 529 pIndirectObj = GetIndirectObject(m_pParser->GetInfoObjNum()); | |
| 530 m_pInfoDict = pIndirectObj ? pIndirectObj->GetDict() : nullptr; | |
| 531 CPDF_Array* pIDArray = m_pParser->GetIDArray(); | |
| 532 if (pIDArray) { | |
| 533 m_ID1 = pIDArray->GetStringAt(0); | |
| 534 m_ID2 = pIDArray->GetStringAt(1); | |
| 535 } | |
| 536 uint32_t dwPageCount = 0; | 528 uint32_t dwPageCount = 0; |
| 537 CPDF_Object* pCount = pLinearized->GetObjectBy("N"); | 529 CPDF_Object* pCount = pLinearizationParams->GetObjectBy("N"); |
| 538 if (ToNumber(pCount)) | 530 if (ToNumber(pCount)) |
| 539 dwPageCount = pCount->GetInteger(); | 531 dwPageCount = pCount->GetInteger(); |
| 532 m_PageList.SetSize(dwPageCount); |
| 540 | 533 |
| 541 m_PageList.SetSize(dwPageCount); | 534 CPDF_Object* pNo = pLinearizationParams->GetObjectBy("P"); |
| 542 CPDF_Object* pNo = pLinearized->GetObjectBy("P"); | |
| 543 if (ToNumber(pNo)) | 535 if (ToNumber(pNo)) |
| 544 m_iFirstPageNo = pNo->GetInteger(); | 536 m_iFirstPageNo = pNo->GetInteger(); |
| 545 | 537 |
| 546 CPDF_Object* pObjNum = pLinearized->GetObjectBy("O"); | 538 CPDF_Object* pObjNum = pLinearizationParams->GetObjectBy("O"); |
| 547 if (ToNumber(pObjNum)) | 539 if (ToNumber(pObjNum)) |
| 548 m_dwFirstPageObjNum = pObjNum->GetInteger(); | 540 m_dwFirstPageObjNum = pObjNum->GetInteger(); |
| 549 } | 541 } |
| 550 | 542 |
| 551 void CPDF_Document::LoadPages() { | 543 void CPDF_Document::LoadPages() { |
| 552 m_PageList.SetSize(RetrievePageCount()); | 544 m_PageList.SetSize(RetrievePageCount()); |
| 553 } | 545 } |
| 554 | 546 |
| 555 CPDF_Dictionary* CPDF_Document::FindPDFPage(CPDF_Dictionary* pPages, | 547 CPDF_Dictionary* CPDF_Document::FindPDFPage(CPDF_Dictionary* pPages, |
| 556 int iPage, | 548 int iPage, |
| (...skipping 892 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1449 } | 1441 } |
| 1450 } | 1442 } |
| 1451 pFontDesc->SetAtInteger("StemV", fStemV); | 1443 pFontDesc->SetAtInteger("StemV", fStemV); |
| 1452 AddIndirectObject(pFontDesc); | 1444 AddIndirectObject(pFontDesc); |
| 1453 pFontDict->SetAtReference("FontDescriptor", this, pFontDesc); | 1445 pFontDict->SetAtReference("FontDescriptor", this, pFontDesc); |
| 1454 CFRelease(traits); | 1446 CFRelease(traits); |
| 1455 CFRelease(languages); | 1447 CFRelease(languages); |
| 1456 return LoadFont(pBaseDict); | 1448 return LoadFont(pBaseDict); |
| 1457 } | 1449 } |
| 1458 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | 1450 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
| OLD | NEW |