Chromium Code Reviews| Index: core/fpdfapi/fpdf_parser/cpdf_document.cpp |
| diff --git a/core/fpdfapi/fpdf_parser/cpdf_document.cpp b/core/fpdfapi/fpdf_parser/cpdf_document.cpp |
| index bf1f93f887c6bf999efcba4926ee667ad659e60f..71007ce946919371e9246e50ae666d7b8a3e97d3 100644 |
| --- a/core/fpdfapi/fpdf_parser/cpdf_document.cpp |
| +++ b/core/fpdfapi/fpdf_parser/cpdf_document.cpp |
| @@ -482,20 +482,49 @@ int CountPages(CPDF_Dictionary* pPages, |
| } // namespace |
| CPDF_Document::CPDF_Document(CPDF_Parser* pParser) |
| - : CPDF_IndirectObjectHolder(pParser), |
| + : CPDF_IndirectObjectHolder(), |
| + m_pParser(pParser), |
| m_pRootDict(nullptr), |
| m_pInfoDict(nullptr), |
| m_bLinearized(false), |
| m_iFirstPageNo(0), |
| m_dwFirstPageObjNum(0), |
| m_pDocPage(new CPDF_DocPageData(this)), |
| - m_pDocRender(new CPDF_DocRenderData(this)) {} |
| + m_pDocRender(new CPDF_DocRenderData(this)) { |
| + if (pParser) |
| + m_LastObjNum = m_pParser->GetLastObjNum(); |
| +} |
| CPDF_Document::~CPDF_Document() { |
| delete m_pDocPage; |
| CPDF_ModuleMgr::Get()->GetPageModule()->ClearStockFont(this); |
| } |
| +CPDF_Object* CPDF_Document::GetIndirectObject(uint32_t objnum) { |
| + if (objnum == 0) |
| + return nullptr; |
| + |
| + 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.
|
| + if (it != m_IndirectObjs.end()) |
| + return it->second->GetObjNum() != CPDF_Object::kInvalidObjNum ? it->second |
| + : nullptr; |
| + |
| + if (!m_pParser) |
| + return nullptr; |
| + |
| + CPDF_Object* pObj = m_pParser->ParseIndirectObject(this, objnum); |
| + if (!pObj) |
| + return nullptr; |
| + |
| + pObj->m_ObjNum = objnum; |
| + 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.
|
| + if (m_IndirectObjs[objnum]) |
| + m_IndirectObjs[objnum]->Destroy(); |
| + |
| + m_IndirectObjs[objnum] = pObj; |
| + return pObj; |
| +} |
| + |
| void CPDF_Document::LoadDocInternal() { |
| m_LastObjNum = m_pParser->GetLastObjNum(); |