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/include/fpdfapi/fpdf_objects.h" | 7 #include "core/include/fpdfapi/fpdf_objects.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 return; | 144 return; |
145 case PDFOBJ_STRING: | 145 case PDFOBJ_STRING: |
146 AsString()->m_String = str; | 146 AsString()->m_String = str; |
147 return; | 147 return; |
148 case PDFOBJ_NAME: | 148 case PDFOBJ_NAME: |
149 AsName()->m_Name = str; | 149 AsName()->m_Name = str; |
150 return; | 150 return; |
151 } | 151 } |
152 ASSERT(FALSE); | 152 ASSERT(FALSE); |
153 } | 153 } |
154 int CPDF_Object::GetDirectType() const { | |
155 const CPDF_Reference* pRef = AsReference(); | |
156 if (!pRef) | |
157 return m_Type; | |
158 return pRef->m_pObjList->GetIndirectType(pRef->GetRefObjNum()); | |
159 } | |
160 FX_BOOL CPDF_Object::IsIdentical(CPDF_Object* pOther) const { | 154 FX_BOOL CPDF_Object::IsIdentical(CPDF_Object* pOther) const { |
161 if (this == pOther) | 155 if (this == pOther) |
162 return TRUE; | 156 return TRUE; |
163 if (!pOther) | 157 if (!pOther) |
164 return FALSE; | 158 return FALSE; |
165 if (pOther->m_Type != m_Type) { | 159 if (pOther->m_Type != m_Type) { |
166 if (IsReference() && GetDirect()) | 160 if (IsReference() && GetDirect()) |
167 return GetDirect()->IsIdentical(pOther); | 161 return GetDirect()->IsIdentical(pOther); |
168 if (pOther->IsReference()) | 162 if (pOther->IsReference()) |
169 return IsIdentical(pOther->GetDirect()); | 163 return IsIdentical(pOther->GetDirect()); |
(...skipping 882 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1052 return nullptr; | 1046 return nullptr; |
1053 | 1047 |
1054 pObj->m_ObjNum = objnum; | 1048 pObj->m_ObjNum = objnum; |
1055 m_LastObjNum = std::max(m_LastObjNum, objnum); | 1049 m_LastObjNum = std::max(m_LastObjNum, objnum); |
1056 if (m_IndirectObjs[objnum]) | 1050 if (m_IndirectObjs[objnum]) |
1057 m_IndirectObjs[objnum]->Destroy(); | 1051 m_IndirectObjs[objnum]->Destroy(); |
1058 | 1052 |
1059 m_IndirectObjs[objnum] = pObj; | 1053 m_IndirectObjs[objnum] = pObj; |
1060 return pObj; | 1054 return pObj; |
1061 } | 1055 } |
1062 int CPDF_IndirectObjectHolder::GetIndirectType(FX_DWORD objnum) { | |
1063 auto it = m_IndirectObjs.find(objnum); | |
1064 if (it != m_IndirectObjs.end()) | |
1065 return it->second->GetType(); | |
1066 | |
1067 if (!m_pParser) | |
1068 return 0; | |
1069 | |
1070 PARSE_CONTEXT context; | |
1071 FXSYS_memset(&context, 0, sizeof(PARSE_CONTEXT)); | |
1072 context.m_Flags = PDFPARSE_TYPEONLY; | |
1073 return (int)(uintptr_t)m_pParser->ParseIndirectObject(this, objnum, &context); | |
1074 } | |
1075 FX_DWORD CPDF_IndirectObjectHolder::AddIndirectObject(CPDF_Object* pObj) { | 1056 FX_DWORD CPDF_IndirectObjectHolder::AddIndirectObject(CPDF_Object* pObj) { |
1076 if (pObj->m_ObjNum) { | 1057 if (pObj->m_ObjNum) { |
1077 return pObj->m_ObjNum; | 1058 return pObj->m_ObjNum; |
1078 } | 1059 } |
1079 m_LastObjNum++; | 1060 m_LastObjNum++; |
1080 m_IndirectObjs[m_LastObjNum] = pObj; | 1061 m_IndirectObjs[m_LastObjNum] = pObj; |
1081 pObj->m_ObjNum = m_LastObjNum; | 1062 pObj->m_ObjNum = m_LastObjNum; |
1082 return m_LastObjNum; | 1063 return m_LastObjNum; |
1083 } | 1064 } |
1084 void CPDF_IndirectObjectHolder::ReleaseIndirectObject(FX_DWORD objnum) { | 1065 void CPDF_IndirectObjectHolder::ReleaseIndirectObject(FX_DWORD objnum) { |
(...skipping 13 matching lines...) Expand all Loading... |
1098 pObj->Destroy(); | 1079 pObj->Destroy(); |
1099 return FALSE; | 1080 return FALSE; |
1100 } | 1081 } |
1101 it->second->Destroy(); | 1082 it->second->Destroy(); |
1102 } | 1083 } |
1103 pObj->m_ObjNum = objnum; | 1084 pObj->m_ObjNum = objnum; |
1104 m_IndirectObjs[objnum] = pObj; | 1085 m_IndirectObjs[objnum] = pObj; |
1105 m_LastObjNum = std::max(m_LastObjNum, objnum); | 1086 m_LastObjNum = std::max(m_LastObjNum, objnum); |
1106 return TRUE; | 1087 return TRUE; |
1107 } | 1088 } |
OLD | NEW |