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 | 10 |
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
489 if (CPDF_Stream* pStream = p->AsStream()) | 489 if (CPDF_Stream* pStream = p->AsStream()) |
490 return pStream->GetDict(); | 490 return pStream->GetDict(); |
491 return NULL; | 491 return NULL; |
492 } | 492 } |
493 CPDF_Stream* CPDF_Array::GetStream(FX_DWORD i) const { | 493 CPDF_Stream* CPDF_Array::GetStream(FX_DWORD i) const { |
494 return ToStream(GetElementValue(i)); | 494 return ToStream(GetElementValue(i)); |
495 } | 495 } |
496 CPDF_Array* CPDF_Array::GetArray(FX_DWORD i) const { | 496 CPDF_Array* CPDF_Array::GetArray(FX_DWORD i) const { |
497 return ToArray(GetElementValue(i)); | 497 return ToArray(GetElementValue(i)); |
498 } | 498 } |
499 void CPDF_Array::RemoveAt(FX_DWORD i) { | 499 void CPDF_Array::RemoveAt(FX_DWORD i, int nCount) { |
500 ASSERT(IsArray()); | 500 ASSERT(IsArray()); |
Tom Sepez
2015/11/12 17:39:19
nit: probably pointless given that we've cleaned u
Oliver Chang
2015/11/12 18:39:45
removed.
| |
501 if (i >= (FX_DWORD)m_Objects.GetSize()) | 501 if (i >= (FX_DWORD)m_Objects.GetSize()) |
502 return; | 502 return; |
503 if (CPDF_Object* p = static_cast<CPDF_Object*>(m_Objects.GetAt(i))) | 503 |
504 p->Release(); | 504 if (nCount <= 0 || nCount > m_Objects.GetSize() - i) |
505 m_Objects.RemoveAt(i); | 505 return; |
506 | |
507 for (int j = 0; j < nCount; ++j) { | |
508 if (CPDF_Object* p = static_cast<CPDF_Object*>(m_Objects.GetAt(i + j))) | |
509 p->Release(); | |
510 } | |
511 m_Objects.RemoveAt(i, nCount); | |
506 } | 512 } |
507 void CPDF_Array::SetAt(FX_DWORD i, | 513 void CPDF_Array::SetAt(FX_DWORD i, |
508 CPDF_Object* pObj, | 514 CPDF_Object* pObj, |
509 CPDF_IndirectObjects* pObjs) { | 515 CPDF_IndirectObjects* pObjs) { |
510 ASSERT(IsArray()); | 516 ASSERT(IsArray()); |
511 ASSERT(i < (FX_DWORD)m_Objects.GetSize()); | 517 ASSERT(i < (FX_DWORD)m_Objects.GetSize()); |
512 if (i >= (FX_DWORD)m_Objects.GetSize()) | 518 if (i >= (FX_DWORD)m_Objects.GetSize()) |
513 return; | 519 return; |
514 if (CPDF_Object* pOld = static_cast<CPDF_Object*>(m_Objects.GetAt(i))) | 520 if (CPDF_Object* pOld = static_cast<CPDF_Object*>(m_Objects.GetAt(i))) |
515 pOld->Release(); | 521 pOld->Release(); |
(...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1169 } | 1175 } |
1170 pObj->m_ObjNum = objnum; | 1176 pObj->m_ObjNum = objnum; |
1171 m_IndirectObjs.SetAt((void*)(uintptr_t)objnum, pObj); | 1177 m_IndirectObjs.SetAt((void*)(uintptr_t)objnum, pObj); |
1172 if (m_LastObjNum < objnum) { | 1178 if (m_LastObjNum < objnum) { |
1173 m_LastObjNum = objnum; | 1179 m_LastObjNum = objnum; |
1174 } | 1180 } |
1175 } | 1181 } |
1176 FX_DWORD CPDF_IndirectObjects::GetLastObjNum() const { | 1182 FX_DWORD CPDF_IndirectObjects::GetLastObjNum() const { |
1177 return m_LastObjNum; | 1183 return m_LastObjNum; |
1178 } | 1184 } |
OLD | NEW |