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_parser.h" | 7 #include "core/include/fpdfapi/fpdf_parser.h" |
8 | 8 |
9 #include "core/include/fxcrt/fx_string.h" | 9 #include "core/include/fxcrt/fx_string.h" |
| 10 #include "third_party/base/stl_util.h" |
10 | 11 |
11 namespace { | 12 namespace { |
12 | 13 |
13 const FX_DWORD kBlockSize = 1024; | 14 const FX_DWORD kBlockSize = 1024; |
14 | 15 |
15 } // namespace | 16 } // namespace |
16 | 17 |
17 // static | 18 // static |
18 int CPDF_Object::s_nCurRefDepth = 0; | 19 int CPDF_Object::s_nCurRefDepth = 0; |
19 | 20 |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 FX_DWORD streamSize = acc.GetSize(); | 278 FX_DWORD streamSize = acc.GetSize(); |
278 CPDF_Dictionary* pDict = pThis->GetDict(); | 279 CPDF_Dictionary* pDict = pThis->GetDict(); |
279 if (pDict) { | 280 if (pDict) { |
280 pDict = ToDictionary(pDict->CloneInternal(bDirect, visited)); | 281 pDict = ToDictionary(pDict->CloneInternal(bDirect, visited)); |
281 } | 282 } |
282 return new CPDF_Stream(acc.DetachData(), streamSize, pDict); | 283 return new CPDF_Stream(acc.DetachData(), streamSize, pDict); |
283 } | 284 } |
284 case PDFOBJ_REFERENCE: { | 285 case PDFOBJ_REFERENCE: { |
285 const CPDF_Reference* pRef = AsReference(); | 286 const CPDF_Reference* pRef = AsReference(); |
286 FX_DWORD obj_num = pRef->GetRefObjNum(); | 287 FX_DWORD obj_num = pRef->GetRefObjNum(); |
287 if (bDirect && visited->find(obj_num) == visited->end()) { | 288 if (bDirect && !pdfium::ContainsKey(*visited, obj_num)) { |
288 visited->insert(obj_num); | 289 visited->insert(obj_num); |
289 if (!pRef->GetDirect()) | 290 auto* pDirect = pRef->GetDirect(); |
290 return nullptr; | 291 return pDirect ? pDirect->CloneInternal(TRUE, visited) : nullptr; |
291 | |
292 return pRef->GetDirect()->CloneInternal(TRUE, visited); | |
293 } | 292 } |
294 return new CPDF_Reference(pRef->m_pObjList, obj_num); | 293 return new CPDF_Reference(pRef->m_pObjList, obj_num); |
295 } | 294 } |
296 } | 295 } |
297 return NULL; | 296 return NULL; |
298 } | 297 } |
299 CPDF_Object* CPDF_Object::CloneRef(CPDF_IndirectObjects* pDoc) const { | 298 CPDF_Object* CPDF_Object::CloneRef(CPDF_IndirectObjects* pDoc) const { |
300 if (m_ObjNum) { | 299 if (m_ObjNum) { |
301 return new CPDF_Reference(pDoc, m_ObjNum); | 300 return new CPDF_Reference(pDoc, m_ObjNum); |
302 } | 301 } |
(...skipping 867 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1170 } | 1169 } |
1171 pObj->m_ObjNum = objnum; | 1170 pObj->m_ObjNum = objnum; |
1172 m_IndirectObjs.SetAt((void*)(uintptr_t)objnum, pObj); | 1171 m_IndirectObjs.SetAt((void*)(uintptr_t)objnum, pObj); |
1173 if (m_LastObjNum < objnum) | 1172 if (m_LastObjNum < objnum) |
1174 m_LastObjNum = objnum; | 1173 m_LastObjNum = objnum; |
1175 return TRUE; | 1174 return TRUE; |
1176 } | 1175 } |
1177 FX_DWORD CPDF_IndirectObjects::GetLastObjNum() const { | 1176 FX_DWORD CPDF_IndirectObjects::GetLastObjNum() const { |
1178 return m_LastObjNum; | 1177 return m_LastObjNum; |
1179 } | 1178 } |
OLD | NEW |