| 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(FX_DWORD i) const { | 79 CPDF_Object* CPDF_Array::GetElement(uint32_t i) const { |
| 80 if (i >= (FX_DWORD)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(FX_DWORD i) const { | 85 CPDF_Object* CPDF_Array::GetElementValue(uint32_t i) const { |
| 86 if (i >= (FX_DWORD)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(FX_DWORD i) const { | 91 CFX_ByteString CPDF_Array::GetStringAt(uint32_t i) const { |
| 92 if (i >= (FX_DWORD)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 } |
| 96 | 96 |
| 97 CFX_ByteStringC CPDF_Array::GetConstStringAt(FX_DWORD i) const { | 97 CFX_ByteStringC CPDF_Array::GetConstStringAt(uint32_t i) const { |
| 98 if (i >= (FX_DWORD)m_Objects.GetSize()) | 98 if (i >= (uint32_t)m_Objects.GetSize()) |
| 99 return CFX_ByteStringC(); | 99 return CFX_ByteStringC(); |
| 100 return m_Objects.GetAt(i)->GetConstString(); | 100 return m_Objects.GetAt(i)->GetConstString(); |
| 101 } | 101 } |
| 102 | 102 |
| 103 int CPDF_Array::GetIntegerAt(FX_DWORD i) const { | 103 int CPDF_Array::GetIntegerAt(uint32_t i) const { |
| 104 if (i >= (FX_DWORD)m_Objects.GetSize()) | 104 if (i >= (uint32_t)m_Objects.GetSize()) |
| 105 return 0; | 105 return 0; |
| 106 return m_Objects.GetAt(i)->GetInteger(); | 106 return m_Objects.GetAt(i)->GetInteger(); |
| 107 } | 107 } |
| 108 | 108 |
| 109 FX_FLOAT CPDF_Array::GetNumberAt(FX_DWORD i) const { | 109 FX_FLOAT CPDF_Array::GetNumberAt(uint32_t i) const { |
| 110 if (i >= (FX_DWORD)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(FX_DWORD i) const { | 115 CPDF_Dictionary* CPDF_Array::GetDictAt(uint32_t i) const { |
| 116 CPDF_Object* p = GetElementValue(i); | 116 CPDF_Object* p = GetElementValue(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(FX_DWORD i) const { | 126 CPDF_Stream* CPDF_Array::GetStreamAt(uint32_t i) const { |
| 127 return ToStream(GetElementValue(i)); | 127 return ToStream(GetElementValue(i)); |
| 128 } | 128 } |
| 129 | 129 |
| 130 CPDF_Array* CPDF_Array::GetArrayAt(FX_DWORD i) const { | 130 CPDF_Array* CPDF_Array::GetArrayAt(uint32_t i) const { |
| 131 return ToArray(GetElementValue(i)); | 131 return ToArray(GetElementValue(i)); |
| 132 } | 132 } |
| 133 | 133 |
| 134 void CPDF_Array::RemoveAt(FX_DWORD i, int nCount) { | 134 void CPDF_Array::RemoveAt(uint32_t i, int nCount) { |
| 135 if (i >= (FX_DWORD)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) { |
| 142 if (CPDF_Object* p = m_Objects.GetAt(i + j)) | 142 if (CPDF_Object* p = m_Objects.GetAt(i + j)) |
| 143 p->Release(); | 143 p->Release(); |
| 144 } | 144 } |
| 145 m_Objects.RemoveAt(i, nCount); | 145 m_Objects.RemoveAt(i, nCount); |
| 146 } | 146 } |
| 147 | 147 |
| 148 void CPDF_Array::SetAt(FX_DWORD i, | 148 void CPDF_Array::SetAt(uint32_t i, |
| 149 CPDF_Object* pObj, | 149 CPDF_Object* pObj, |
| 150 CPDF_IndirectObjectHolder* pObjs) { | 150 CPDF_IndirectObjectHolder* pObjs) { |
| 151 ASSERT(IsArray()); | 151 ASSERT(IsArray()); |
| 152 ASSERT(i < (FX_DWORD)m_Objects.GetSize()); | 152 ASSERT(i < (uint32_t)m_Objects.GetSize()); |
| 153 if (i >= (FX_DWORD)m_Objects.GetSize()) | 153 if (i >= (uint32_t)m_Objects.GetSize()) |
| 154 return; | 154 return; |
| 155 if (CPDF_Object* pOld = m_Objects.GetAt(i)) | 155 if (CPDF_Object* pOld = m_Objects.GetAt(i)) |
| 156 pOld->Release(); | 156 pOld->Release(); |
| 157 if (pObj->GetObjNum()) { | 157 if (pObj->GetObjNum()) { |
| 158 ASSERT(pObjs); | 158 ASSERT(pObjs); |
| 159 pObj = new CPDF_Reference(pObjs, pObj->GetObjNum()); | 159 pObj = new CPDF_Reference(pObjs, pObj->GetObjNum()); |
| 160 } | 160 } |
| 161 m_Objects.SetAt(i, pObj); | 161 m_Objects.SetAt(i, pObj); |
| 162 } | 162 } |
| 163 | 163 |
| 164 void CPDF_Array::InsertAt(FX_DWORD index, | 164 void CPDF_Array::InsertAt(uint32_t index, |
| 165 CPDF_Object* pObj, | 165 CPDF_Object* pObj, |
| 166 CPDF_IndirectObjectHolder* pObjs) { | 166 CPDF_IndirectObjectHolder* pObjs) { |
| 167 if (pObj->GetObjNum()) { | 167 if (pObj->GetObjNum()) { |
| 168 ASSERT(pObjs); | 168 ASSERT(pObjs); |
| 169 pObj = new CPDF_Reference(pObjs, pObj->GetObjNum()); | 169 pObj = new CPDF_Reference(pObjs, pObj->GetObjNum()); |
| 170 } | 170 } |
| 171 m_Objects.InsertAt(index, pObj); | 171 m_Objects.InsertAt(index, pObj); |
| 172 } | 172 } |
| 173 | 173 |
| 174 void CPDF_Array::Add(CPDF_Object* pObj, CPDF_IndirectObjectHolder* pObjs) { | 174 void CPDF_Array::Add(CPDF_Object* pObj, CPDF_IndirectObjectHolder* pObjs) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 194 Add(new CPDF_Number(i)); | 194 Add(new CPDF_Number(i)); |
| 195 } | 195 } |
| 196 | 196 |
| 197 void CPDF_Array::AddNumber(FX_FLOAT f) { | 197 void CPDF_Array::AddNumber(FX_FLOAT f) { |
| 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 FX_DWORD 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 |