Chromium Code Reviews| 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(); | |
| 521 | |
|
Tom Sepez
2016/08/16 18:08:01
nit: blank line not needed here.
dsinclair
2016/08/16 18:28:18
Done.
| |
| 518 m_PageList.SetSize(RetrievePageCount()); | 522 m_PageList.SetSize(RetrievePageCount()); |
| 519 } | 523 } |
| 520 | 524 |
| 521 void CPDF_Document::LoadAsynDoc(CPDF_Dictionary* pLinearized) { | 525 void CPDF_Document::LoadLinearizedDoc(CPDF_Dictionary* pLinearized) { |
| 522 m_bLinearized = true; | 526 m_bLinearized = true; |
| 523 m_LastObjNum = m_pParser->GetLastObjNum(); | 527 |
|
Tom Sepez
2016/08/16 18:08:01
nit: blank line not needed here (but the one at 52
dsinclair
2016/08/16 18:28:18
Done.
| |
| 524 CPDF_Object* pIndirectObj = GetIndirectObject(m_pParser->GetRootObjNum()); | 528 LoadDocInternal(); |
| 525 m_pRootDict = pIndirectObj ? pIndirectObj->GetDict() : nullptr; | 529 |
| 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; | 530 uint32_t dwPageCount = 0; |
| 537 CPDF_Object* pCount = pLinearized->GetObjectBy("N"); | 531 CPDF_Object* pCount = pLinearized->GetObjectBy("N"); |
| 538 if (ToNumber(pCount)) | 532 if (ToNumber(pCount)) |
| 539 dwPageCount = pCount->GetInteger(); | 533 dwPageCount = pCount->GetInteger(); |
| 534 m_PageList.SetSize(dwPageCount); | |
| 540 | 535 |
| 541 m_PageList.SetSize(dwPageCount); | |
| 542 CPDF_Object* pNo = pLinearized->GetObjectBy("P"); | 536 CPDF_Object* pNo = pLinearized->GetObjectBy("P"); |
| 543 if (ToNumber(pNo)) | 537 if (ToNumber(pNo)) |
| 544 m_iFirstPageNo = pNo->GetInteger(); | 538 m_iFirstPageNo = pNo->GetInteger(); |
| 545 | 539 |
| 546 CPDF_Object* pObjNum = pLinearized->GetObjectBy("O"); | 540 CPDF_Object* pObjNum = pLinearized->GetObjectBy("O"); |
| 547 if (ToNumber(pObjNum)) | 541 if (ToNumber(pObjNum)) |
| 548 m_dwFirstPageObjNum = pObjNum->GetInteger(); | 542 m_dwFirstPageObjNum = pObjNum->GetInteger(); |
| 549 } | 543 } |
| 550 | 544 |
| 551 void CPDF_Document::LoadPages() { | 545 void CPDF_Document::LoadPages() { |
| (...skipping 897 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1449 } | 1443 } |
| 1450 } | 1444 } |
| 1451 pFontDesc->SetAtInteger("StemV", fStemV); | 1445 pFontDesc->SetAtInteger("StemV", fStemV); |
| 1452 AddIndirectObject(pFontDesc); | 1446 AddIndirectObject(pFontDesc); |
| 1453 pFontDict->SetAtReference("FontDescriptor", this, pFontDesc); | 1447 pFontDict->SetAtReference("FontDescriptor", this, pFontDesc); |
| 1454 CFRelease(traits); | 1448 CFRelease(traits); |
| 1455 CFRelease(languages); | 1449 CFRelease(languages); |
| 1456 return LoadFont(pBaseDict); | 1450 return LoadFont(pBaseDict); |
| 1457 } | 1451 } |
| 1458 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | 1452 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
| OLD | NEW |