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/fpdf_parser/include/cpdf_indirect_object_holder.h" | 7 #include "core/fpdfapi/fpdf_parser/include/cpdf_indirect_object_holder.h" |
8 | 8 |
9 #include "core/fpdfapi/fpdf_parser/include/cpdf_object.h" | 9 #include "core/fpdfapi/fpdf_parser/include/cpdf_object.h" |
10 #include "core/fpdfapi/fpdf_parser/include/cpdf_parser.h" | 10 #include "core/fpdfapi/fpdf_parser/include/cpdf_parser.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 void CPDF_IndirectObjectHolder::ReleaseIndirectObject(uint32_t objnum) { | 58 void CPDF_IndirectObjectHolder::ReleaseIndirectObject(uint32_t objnum) { |
59 auto it = m_IndirectObjs.find(objnum); | 59 auto it = m_IndirectObjs.find(objnum); |
60 if (it == m_IndirectObjs.end() || | 60 if (it == m_IndirectObjs.end() || |
61 it->second->GetObjNum() == CPDF_Object::kInvalidObjNum) { | 61 it->second->GetObjNum() == CPDF_Object::kInvalidObjNum) { |
62 return; | 62 return; |
63 } | 63 } |
64 it->second->Destroy(); | 64 it->second->Destroy(); |
65 m_IndirectObjs.erase(it); | 65 m_IndirectObjs.erase(it); |
66 } | 66 } |
67 | 67 |
68 FX_BOOL CPDF_IndirectObjectHolder::InsertIndirectObject(uint32_t objnum, | 68 bool CPDF_IndirectObjectHolder::InsertIndirectObject(uint32_t objnum, |
69 CPDF_Object* pObj) { | 69 CPDF_Object* pObj) { |
70 if (!objnum || !pObj) | 70 if (!objnum || !pObj) |
71 return FALSE; | 71 return false; |
| 72 |
72 auto it = m_IndirectObjs.find(objnum); | 73 auto it = m_IndirectObjs.find(objnum); |
73 if (it != m_IndirectObjs.end()) { | 74 if (it != m_IndirectObjs.end()) { |
74 if (pObj->GetGenNum() <= it->second->GetGenNum()) { | 75 if (pObj->GetGenNum() <= it->second->GetGenNum()) { |
75 pObj->Destroy(); | 76 pObj->Destroy(); |
76 return FALSE; | 77 return false; |
77 } | 78 } |
78 it->second->Destroy(); | 79 it->second->Destroy(); |
79 } | 80 } |
80 pObj->m_ObjNum = objnum; | 81 pObj->m_ObjNum = objnum; |
81 m_IndirectObjs[objnum] = pObj; | 82 m_IndirectObjs[objnum] = pObj; |
82 m_LastObjNum = std::max(m_LastObjNum, objnum); | 83 m_LastObjNum = std::max(m_LastObjNum, objnum); |
83 return TRUE; | 84 return true; |
84 } | 85 } |
OLD | NEW |