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_array.h" | 7 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" |
8 | 8 |
9 #include "core/fpdfapi/fpdf_parser/include/cpdf_name.h" | 9 #include "core/fpdfapi/fpdf_parser/include/cpdf_name.h" |
10 #include "core/fpdfapi/fpdf_parser/include/cpdf_number.h" | 10 #include "core/fpdfapi/fpdf_parser/include/cpdf_number.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 CFX_Matrix CPDF_Array::GetMatrix() { | 69 CFX_Matrix CPDF_Array::GetMatrix() { |
70 CFX_Matrix matrix; | 70 CFX_Matrix matrix; |
71 if (!IsArray() || m_Objects.GetSize() != 6) | 71 if (!IsArray() || m_Objects.GetSize() != 6) |
72 return matrix; | 72 return matrix; |
73 | 73 |
74 matrix.Set(GetNumberAt(0), GetNumberAt(1), GetNumberAt(2), GetNumberAt(3), | 74 matrix.Set(GetNumberAt(0), GetNumberAt(1), GetNumberAt(2), GetNumberAt(3), |
75 GetNumberAt(4), GetNumberAt(5)); | 75 GetNumberAt(4), GetNumberAt(5)); |
76 return matrix; | 76 return matrix; |
77 } | 77 } |
78 | 78 |
79 CPDF_Object* CPDF_Array::GetElement(uint32_t i) const { | 79 CPDF_Object* CPDF_Array::GetObjectAt(uint32_t i) const { |
80 if (i >= (uint32_t)m_Objects.GetSize()) | 80 if (i >= (uint32_t)m_Objects.GetSize()) |
81 return nullptr; | 81 return nullptr; |
82 return m_Objects.GetAt(i); | 82 return m_Objects.GetAt(i); |
83 } | 83 } |
84 | 84 |
85 CPDF_Object* CPDF_Array::GetElementValue(uint32_t i) const { | 85 CPDF_Object* CPDF_Array::GetDirectObjectAt(uint32_t i) const { |
86 if (i >= (uint32_t)m_Objects.GetSize()) | 86 if (i >= (uint32_t)m_Objects.GetSize()) |
87 return nullptr; | 87 return nullptr; |
88 return m_Objects.GetAt(i)->GetDirect(); | 88 return m_Objects.GetAt(i)->GetDirect(); |
89 } | 89 } |
90 | 90 |
91 CFX_ByteString CPDF_Array::GetStringAt(uint32_t i) const { | 91 CFX_ByteString CPDF_Array::GetStringAt(uint32_t i) const { |
92 if (i >= (uint32_t)m_Objects.GetSize()) | 92 if (i >= (uint32_t)m_Objects.GetSize()) |
93 return CFX_ByteString(); | 93 return CFX_ByteString(); |
94 return m_Objects.GetAt(i)->GetString(); | 94 return m_Objects.GetAt(i)->GetString(); |
95 } | 95 } |
(...skipping 10 matching lines...) Expand all Loading... |
106 return m_Objects.GetAt(i)->GetInteger(); | 106 return m_Objects.GetAt(i)->GetInteger(); |
107 } | 107 } |
108 | 108 |
109 FX_FLOAT CPDF_Array::GetNumberAt(uint32_t i) const { | 109 FX_FLOAT CPDF_Array::GetNumberAt(uint32_t i) const { |
110 if (i >= (uint32_t)m_Objects.GetSize()) | 110 if (i >= (uint32_t)m_Objects.GetSize()) |
111 return 0; | 111 return 0; |
112 return m_Objects.GetAt(i)->GetNumber(); | 112 return m_Objects.GetAt(i)->GetNumber(); |
113 } | 113 } |
114 | 114 |
115 CPDF_Dictionary* CPDF_Array::GetDictAt(uint32_t i) const { | 115 CPDF_Dictionary* CPDF_Array::GetDictAt(uint32_t i) const { |
116 CPDF_Object* p = GetElementValue(i); | 116 CPDF_Object* p = GetDirectObjectAt(i); |
117 if (!p) | 117 if (!p) |
118 return NULL; | 118 return NULL; |
119 if (CPDF_Dictionary* pDict = p->AsDictionary()) | 119 if (CPDF_Dictionary* pDict = p->AsDictionary()) |
120 return pDict; | 120 return pDict; |
121 if (CPDF_Stream* pStream = p->AsStream()) | 121 if (CPDF_Stream* pStream = p->AsStream()) |
122 return pStream->GetDict(); | 122 return pStream->GetDict(); |
123 return NULL; | 123 return NULL; |
124 } | 124 } |
125 | 125 |
126 CPDF_Stream* CPDF_Array::GetStreamAt(uint32_t i) const { | 126 CPDF_Stream* CPDF_Array::GetStreamAt(uint32_t i) const { |
127 return ToStream(GetElementValue(i)); | 127 return ToStream(GetDirectObjectAt(i)); |
128 } | 128 } |
129 | 129 |
130 CPDF_Array* CPDF_Array::GetArrayAt(uint32_t i) const { | 130 CPDF_Array* CPDF_Array::GetArrayAt(uint32_t i) const { |
131 return ToArray(GetElementValue(i)); | 131 return ToArray(GetDirectObjectAt(i)); |
132 } | 132 } |
133 | 133 |
134 void CPDF_Array::RemoveAt(uint32_t i, int nCount) { | 134 void CPDF_Array::RemoveAt(uint32_t i, int nCount) { |
135 if (i >= (uint32_t)m_Objects.GetSize()) | 135 if (i >= (uint32_t)m_Objects.GetSize()) |
136 return; | 136 return; |
137 | 137 |
138 if (nCount <= 0 || nCount > m_Objects.GetSize() - i) | 138 if (nCount <= 0 || nCount > m_Objects.GetSize() - i) |
139 return; | 139 return; |
140 | 140 |
141 for (int j = 0; j < nCount; ++j) { | 141 for (int j = 0; j < nCount; ++j) { |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 ASSERT(IsArray()); | 198 ASSERT(IsArray()); |
199 CPDF_Number* pNumber = new CPDF_Number(f); | 199 CPDF_Number* pNumber = new CPDF_Number(f); |
200 Add(pNumber); | 200 Add(pNumber); |
201 } | 201 } |
202 | 202 |
203 void CPDF_Array::AddReference(CPDF_IndirectObjectHolder* pDoc, | 203 void CPDF_Array::AddReference(CPDF_IndirectObjectHolder* pDoc, |
204 uint32_t objnum) { | 204 uint32_t objnum) { |
205 ASSERT(IsArray()); | 205 ASSERT(IsArray()); |
206 Add(new CPDF_Reference(pDoc, objnum)); | 206 Add(new CPDF_Reference(pDoc, objnum)); |
207 } | 207 } |
OLD | NEW |