| 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 <map> | 7 #include <map> |
| 8 | 8 |
| 9 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" | 9 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" |
| 10 #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" | 10 #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 return TRUE; | 198 return TRUE; |
| 199 } | 199 } |
| 200 CPDF_StructElementImpl::CPDF_StructElementImpl(CPDF_StructTreeImpl* pTree, | 200 CPDF_StructElementImpl::CPDF_StructElementImpl(CPDF_StructTreeImpl* pTree, |
| 201 CPDF_StructElementImpl* pParent, | 201 CPDF_StructElementImpl* pParent, |
| 202 CPDF_Dictionary* pDict) | 202 CPDF_Dictionary* pDict) |
| 203 : m_RefCount(0) { | 203 : m_RefCount(0) { |
| 204 m_pTree = pTree; | 204 m_pTree = pTree; |
| 205 m_pDict = pDict; | 205 m_pDict = pDict; |
| 206 m_Type = pDict->GetStringBy("S"); | 206 m_Type = pDict->GetStringBy("S"); |
| 207 if (pTree->m_pRoleMap) { | 207 if (pTree->m_pRoleMap) { |
| 208 CFX_ByteString mapped = pTree->m_pRoleMap->GetStringBy(m_Type); | 208 CFX_ByteString mapped = |
| 209 pTree->m_pRoleMap->GetStringBy(m_Type.AsByteStringC()); |
| 209 if (!mapped.IsEmpty()) { | 210 if (!mapped.IsEmpty()) { |
| 210 m_Type = mapped; | 211 m_Type = mapped; |
| 211 } | 212 } |
| 212 } | 213 } |
| 213 m_pParent = pParent; | 214 m_pParent = pParent; |
| 214 LoadKids(pDict); | 215 LoadKids(pDict); |
| 215 } | 216 } |
| 216 CPDF_StructElementImpl::~CPDF_StructElementImpl() { | 217 CPDF_StructElementImpl::~CPDF_StructElementImpl() { |
| 217 for (int i = 0; i < m_Kids.GetSize(); i++) { | 218 for (int i = 0; i < m_Kids.GetSize(); i++) { |
| 218 if (m_Kids[i].m_Type == CPDF_StructKid::Element && | 219 if (m_Kids[i].m_Type == CPDF_StructKid::Element && |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 if (!pC) | 367 if (!pC) |
| 367 return nullptr; | 368 return nullptr; |
| 368 | 369 |
| 369 CPDF_Dictionary* pClassMap = m_pTree->m_pTreeRoot->GetDictBy("ClassMap"); | 370 CPDF_Dictionary* pClassMap = m_pTree->m_pTreeRoot->GetDictBy("ClassMap"); |
| 370 if (!pClassMap) | 371 if (!pClassMap) |
| 371 return nullptr; | 372 return nullptr; |
| 372 | 373 |
| 373 if (CPDF_Array* pArray = pC->AsArray()) { | 374 if (CPDF_Array* pArray = pC->AsArray()) { |
| 374 for (uint32_t i = 0; i < pArray->GetCount(); i++) { | 375 for (uint32_t i = 0; i < pArray->GetCount(); i++) { |
| 375 CFX_ByteString class_name = pArray->GetStringAt(i); | 376 CFX_ByteString class_name = pArray->GetStringAt(i); |
| 376 CPDF_Dictionary* pClassDict = pClassMap->GetDictBy(class_name); | 377 CPDF_Dictionary* pClassDict = |
| 378 pClassMap->GetDictBy(class_name.AsByteStringC()); |
| 377 if (pClassDict && pClassDict->GetStringBy("O") == owner) | 379 if (pClassDict && pClassDict->GetStringBy("O") == owner) |
| 378 return pClassDict->GetDirectObjectBy(name); | 380 return pClassDict->GetDirectObjectBy(name); |
| 379 } | 381 } |
| 380 return nullptr; | 382 return nullptr; |
| 381 } | 383 } |
| 382 CFX_ByteString class_name = pC->GetString(); | 384 CFX_ByteString class_name = pC->GetString(); |
| 383 CPDF_Dictionary* pClassDict = pClassMap->GetDictBy(class_name); | 385 CPDF_Dictionary* pClassDict = |
| 386 pClassMap->GetDictBy(class_name.AsByteStringC()); |
| 384 if (pClassDict && pClassDict->GetStringBy("O") == owner) | 387 if (pClassDict && pClassDict->GetStringBy("O") == owner) |
| 385 return pClassDict->GetDirectObjectBy(name); | 388 return pClassDict->GetDirectObjectBy(name); |
| 386 return nullptr; | 389 return nullptr; |
| 387 } | 390 } |
| 388 CPDF_Object* CPDF_StructElementImpl::GetAttr(const CFX_ByteStringC& owner, | 391 CPDF_Object* CPDF_StructElementImpl::GetAttr(const CFX_ByteStringC& owner, |
| 389 const CFX_ByteStringC& name, | 392 const CFX_ByteStringC& name, |
| 390 FX_BOOL bInheritable, | 393 FX_BOOL bInheritable, |
| 391 int subindex) { | 394 int subindex) { |
| 392 CPDF_Object* pAttr = GetAttr(owner, name, bInheritable); | 395 CPDF_Object* pAttr = GetAttr(owner, name, bInheritable); |
| 393 CPDF_Array* pArray = ToArray(pAttr); | 396 CPDF_Array* pArray = ToArray(pAttr); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 return ToNumber(pAttr) ? pAttr->GetNumber() : default_value; | 434 return ToNumber(pAttr) ? pAttr->GetNumber() : default_value; |
| 432 } | 435 } |
| 433 int CPDF_StructElementImpl::GetInteger(const CFX_ByteStringC& owner, | 436 int CPDF_StructElementImpl::GetInteger(const CFX_ByteStringC& owner, |
| 434 const CFX_ByteStringC& name, | 437 const CFX_ByteStringC& name, |
| 435 int default_value, | 438 int default_value, |
| 436 FX_BOOL bInheritable, | 439 FX_BOOL bInheritable, |
| 437 int subindex) { | 440 int subindex) { |
| 438 CPDF_Object* pAttr = GetAttr(owner, name, bInheritable, subindex); | 441 CPDF_Object* pAttr = GetAttr(owner, name, bInheritable, subindex); |
| 439 return ToNumber(pAttr) ? pAttr->GetInteger() : default_value; | 442 return ToNumber(pAttr) ? pAttr->GetInteger() : default_value; |
| 440 } | 443 } |
| OLD | NEW |