OLD | NEW |
1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 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/parser/cpdf_indirect_object_holder.h" | 7 #include "core/fpdfapi/parser/cpdf_indirect_object_holder.h" |
8 | 8 |
9 #include "core/fpdfapi/parser/cpdf_object.h" | 9 #include "core/fpdfapi/parser/cpdf_object.h" |
10 #include "core/fpdfapi/parser/cpdf_parser.h" | 10 #include "core/fpdfapi/parser/cpdf_parser.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 m_LastObjNum = std::max(m_LastObjNum, objnum); | 36 m_LastObjNum = std::max(m_LastObjNum, objnum); |
37 m_IndirectObjs[objnum].reset(pObj); | 37 m_IndirectObjs[objnum].reset(pObj); |
38 return pObj; | 38 return pObj; |
39 } | 39 } |
40 | 40 |
41 CPDF_Object* CPDF_IndirectObjectHolder::ParseIndirectObject(uint32_t objnum) { | 41 CPDF_Object* CPDF_IndirectObjectHolder::ParseIndirectObject(uint32_t objnum) { |
42 return nullptr; | 42 return nullptr; |
43 } | 43 } |
44 | 44 |
45 uint32_t CPDF_IndirectObjectHolder::AddIndirectObject(CPDF_Object* pObj) { | 45 uint32_t CPDF_IndirectObjectHolder::AddIndirectObject(CPDF_Object* pObj) { |
46 if (pObj->m_ObjNum) | 46 CHECK(!pObj->m_ObjNum); |
47 return pObj->m_ObjNum; | |
48 | |
49 m_LastObjNum++; | 47 m_LastObjNum++; |
50 m_IndirectObjs[m_LastObjNum].release(); // TODO(tsepez): stop this leak. | 48 m_IndirectObjs[m_LastObjNum].release(); // TODO(tsepez): stop this leak. |
51 m_IndirectObjs[m_LastObjNum].reset(pObj); | 49 m_IndirectObjs[m_LastObjNum].reset(pObj); |
52 pObj->m_ObjNum = m_LastObjNum; | 50 pObj->m_ObjNum = m_LastObjNum; |
53 return m_LastObjNum; | 51 return m_LastObjNum; |
54 } | 52 } |
55 | 53 |
56 bool CPDF_IndirectObjectHolder::ReplaceIndirectObjectIfHigherGeneration( | 54 bool CPDF_IndirectObjectHolder::ReplaceIndirectObjectIfHigherGeneration( |
57 uint32_t objnum, | 55 uint32_t objnum, |
58 CPDF_Object* pObj) { | 56 CPDF_Object* pObj) { |
(...skipping 12 matching lines...) Expand all Loading... |
71 return true; | 69 return true; |
72 } | 70 } |
73 | 71 |
74 void CPDF_IndirectObjectHolder::DeleteIndirectObject(uint32_t objnum) { | 72 void CPDF_IndirectObjectHolder::DeleteIndirectObject(uint32_t objnum) { |
75 CPDF_Object* pObj = GetIndirectObject(objnum); | 73 CPDF_Object* pObj = GetIndirectObject(objnum); |
76 if (!pObj || pObj->GetObjNum() == CPDF_Object::kInvalidObjNum) | 74 if (!pObj || pObj->GetObjNum() == CPDF_Object::kInvalidObjNum) |
77 return; | 75 return; |
78 | 76 |
79 m_IndirectObjs.erase(objnum); | 77 m_IndirectObjs.erase(objnum); |
80 } | 78 } |
OLD | NEW |