| 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_array.h" | 7 #include "core/fpdfapi/parser/cpdf_array.h" |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 | 10 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 } | 37 } |
| 38 | 38 |
| 39 CPDF_Array* CPDF_Array::AsArray() { | 39 CPDF_Array* CPDF_Array::AsArray() { |
| 40 return this; | 40 return this; |
| 41 } | 41 } |
| 42 | 42 |
| 43 const CPDF_Array* CPDF_Array::AsArray() const { | 43 const CPDF_Array* CPDF_Array::AsArray() const { |
| 44 return this; | 44 return this; |
| 45 } | 45 } |
| 46 | 46 |
| 47 CPDF_Object* CPDF_Array::Clone() const { | 47 std::unique_ptr<CPDF_Object> CPDF_Array::Clone() const { |
| 48 return CloneObjectNonCyclic(false); | 48 return CloneObjectNonCyclic(false); |
| 49 } | 49 } |
| 50 | 50 |
| 51 CPDF_Object* CPDF_Array::CloneNonCyclic( | 51 std::unique_ptr<CPDF_Object> CPDF_Array::CloneNonCyclic( |
| 52 bool bDirect, | 52 bool bDirect, |
| 53 std::set<const CPDF_Object*>* pVisited) const { | 53 std::set<const CPDF_Object*>* pVisited) const { |
| 54 pVisited->insert(this); | 54 pVisited->insert(this); |
| 55 CPDF_Array* pCopy = new CPDF_Array(); | 55 auto pCopy = pdfium::MakeUnique<CPDF_Array>(); |
| 56 for (size_t i = 0; i < GetCount(); i++) { | 56 for (CPDF_Object* value : m_Objects) { |
| 57 CPDF_Object* value = m_Objects[i]; | 57 if (!pdfium::ContainsKey(*pVisited, value)) { |
| 58 if (!pdfium::ContainsKey(*pVisited, value)) | 58 pCopy->m_Objects.push_back( |
| 59 pCopy->m_Objects.push_back(value->CloneNonCyclic(bDirect, pVisited)); | 59 value->CloneNonCyclic(bDirect, pVisited).release()); |
| 60 } |
| 60 } | 61 } |
| 61 return pCopy; | 62 return std::move(pCopy); |
| 62 } | 63 } |
| 63 | 64 |
| 64 CFX_FloatRect CPDF_Array::GetRect() { | 65 CFX_FloatRect CPDF_Array::GetRect() { |
| 65 CFX_FloatRect rect; | 66 CFX_FloatRect rect; |
| 66 if (!IsArray() || m_Objects.size() != 4) | 67 if (!IsArray() || m_Objects.size() != 4) |
| 67 return rect; | 68 return rect; |
| 68 | 69 |
| 69 rect.left = GetNumberAt(0); | 70 rect.left = GetNumberAt(0); |
| 70 rect.bottom = GetNumberAt(1); | 71 rect.bottom = GetNumberAt(1); |
| 71 rect.right = GetNumberAt(2); | 72 rect.right = GetNumberAt(2); |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 } | 202 } |
| 202 | 203 |
| 203 void CPDF_Array::AddNumber(FX_FLOAT f) { | 204 void CPDF_Array::AddNumber(FX_FLOAT f) { |
| 204 Add(new CPDF_Number(f)); | 205 Add(new CPDF_Number(f)); |
| 205 } | 206 } |
| 206 | 207 |
| 207 void CPDF_Array::AddReference(CPDF_IndirectObjectHolder* pDoc, | 208 void CPDF_Array::AddReference(CPDF_IndirectObjectHolder* pDoc, |
| 208 uint32_t objnum) { | 209 uint32_t objnum) { |
| 209 Add(new CPDF_Reference(pDoc, objnum)); | 210 Add(new CPDF_Reference(pDoc, objnum)); |
| 210 } | 211 } |
| OLD | NEW |