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 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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(pParser), | 485 : CPDF_IndirectObjectHolder(), |
| 486 m_pParser(pParser), | |
| 486 m_pRootDict(nullptr), | 487 m_pRootDict(nullptr), |
| 487 m_pInfoDict(nullptr), | 488 m_pInfoDict(nullptr), |
| 488 m_bLinearized(false), | 489 m_bLinearized(false), |
| 489 m_iFirstPageNo(0), | 490 m_iFirstPageNo(0), |
| 490 m_dwFirstPageObjNum(0), | 491 m_dwFirstPageObjNum(0), |
| 491 m_pDocPage(new CPDF_DocPageData(this)), | 492 m_pDocPage(new CPDF_DocPageData(this)), |
| 492 m_pDocRender(new CPDF_DocRenderData(this)) {} | 493 m_pDocRender(new CPDF_DocRenderData(this)) { |
| 494 if (pParser) | |
| 495 m_LastObjNum = m_pParser->GetLastObjNum(); | |
| 496 } | |
| 493 | 497 |
| 494 CPDF_Document::~CPDF_Document() { | 498 CPDF_Document::~CPDF_Document() { |
| 495 delete m_pDocPage; | 499 delete m_pDocPage; |
| 496 CPDF_ModuleMgr::Get()->GetPageModule()->ClearStockFont(this); | 500 CPDF_ModuleMgr::Get()->GetPageModule()->ClearStockFont(this); |
| 497 } | 501 } |
| 498 | 502 |
| 503 CPDF_Object* CPDF_Document::GetIndirectObject(uint32_t objnum) { | |
| 504 if (objnum == 0) | |
| 505 return nullptr; | |
| 506 | |
| 507 auto it = m_IndirectObjs.find(objnum); | |
|
Tom Sepez
2016/08/16 21:15:48
This part (507 - 509) should still be a method on
dsinclair
2016/08/17 15:57:46
Done.
| |
| 508 if (it != m_IndirectObjs.end()) | |
| 509 return it->second->GetObjNum() != CPDF_Object::kInvalidObjNum ? it->second | |
| 510 : nullptr; | |
| 511 | |
| 512 if (!m_pParser) | |
| 513 return nullptr; | |
| 514 | |
| 515 CPDF_Object* pObj = m_pParser->ParseIndirectObject(this, objnum); | |
| 516 if (!pObj) | |
| 517 return nullptr; | |
| 518 | |
| 519 pObj->m_ObjNum = objnum; | |
| 520 m_LastObjNum = std::max(m_LastObjNum, objnum); | |
|
Tom Sepez
2016/08/16 21:15:48
This section feels like a method as well. Documen
dsinclair
2016/08/17 15:57:46
Done.
| |
| 521 if (m_IndirectObjs[objnum]) | |
| 522 m_IndirectObjs[objnum]->Destroy(); | |
| 523 | |
| 524 m_IndirectObjs[objnum] = pObj; | |
| 525 return pObj; | |
| 526 } | |
| 527 | |
| 499 void CPDF_Document::LoadDocInternal() { | 528 void CPDF_Document::LoadDocInternal() { |
| 500 m_LastObjNum = m_pParser->GetLastObjNum(); | 529 m_LastObjNum = m_pParser->GetLastObjNum(); |
| 501 | 530 |
| 502 CPDF_Object* pRootObj = GetIndirectObject(m_pParser->GetRootObjNum()); | 531 CPDF_Object* pRootObj = GetIndirectObject(m_pParser->GetRootObjNum()); |
| 503 if (!pRootObj) | 532 if (!pRootObj) |
| 504 return; | 533 return; |
| 505 | 534 |
| 506 m_pRootDict = pRootObj->GetDict(); | 535 m_pRootDict = pRootObj->GetDict(); |
| 507 if (!m_pRootDict) | 536 if (!m_pRootDict) |
| 508 return; | 537 return; |
| (...skipping 932 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1441 } | 1470 } |
| 1442 } | 1471 } |
| 1443 pFontDesc->SetAtInteger("StemV", fStemV); | 1472 pFontDesc->SetAtInteger("StemV", fStemV); |
| 1444 AddIndirectObject(pFontDesc); | 1473 AddIndirectObject(pFontDesc); |
| 1445 pFontDict->SetAtReference("FontDescriptor", this, pFontDesc); | 1474 pFontDict->SetAtReference("FontDescriptor", this, pFontDesc); |
| 1446 CFRelease(traits); | 1475 CFRelease(traits); |
| 1447 CFRelease(languages); | 1476 CFRelease(languages); |
| 1448 return LoadFont(pBaseDict); | 1477 return LoadFont(pBaseDict); |
| 1449 } | 1478 } |
| 1450 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | 1479 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
| OLD | NEW |