summaryrefslogtreecommitdiff
path: root/core/fpdfdoc/cpdf_structelement.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/fpdfdoc/cpdf_structelement.cpp')
-rw-r--r--core/fpdfdoc/cpdf_structelement.cpp134
1 files changed, 0 insertions, 134 deletions
diff --git a/core/fpdfdoc/cpdf_structelement.cpp b/core/fpdfdoc/cpdf_structelement.cpp
index 418f75b3a9..137d5b32e4 100644
--- a/core/fpdfdoc/cpdf_structelement.cpp
+++ b/core/fpdfdoc/cpdf_structelement.cpp
@@ -16,38 +16,6 @@
#include "core/fpdfdoc/cpdf_structtree.h"
#include "third_party/base/stl_util.h"
-namespace {
-
-const int nMaxRecursion = 32;
-
-CPDF_Dictionary* FindAttrDict(CPDF_Object* pAttrs,
- const CFX_ByteStringC& owner,
- float nLevel = 0.0F) {
- if (nLevel > nMaxRecursion)
- return nullptr;
- if (!pAttrs)
- return nullptr;
-
- CPDF_Dictionary* pDict = nullptr;
- if (pAttrs->IsDictionary()) {
- pDict = pAttrs->AsDictionary();
- } else if (CPDF_Stream* pStream = pAttrs->AsStream()) {
- pDict = pStream->GetDict();
- } else if (CPDF_Array* pArray = pAttrs->AsArray()) {
- for (uint32_t i = 0; i < pArray->GetCount(); i++) {
- CPDF_Object* pElement = pArray->GetDirectObjectAt(i);
- pDict = FindAttrDict(pElement, owner, nLevel + 1);
- if (pDict)
- return pDict;
- }
- }
- if (pDict && pDict->GetStringFor("O") == owner)
- return pDict;
- return nullptr;
-}
-
-} // namespace
-
CPDF_StructKid::CPDF_StructKid()
: m_Type(Invalid),
m_pDict(nullptr),
@@ -166,105 +134,3 @@ void CPDF_StructElement::LoadKid(uint32_t PageObjNum,
pKid->m_pElement =
pdfium::MakeRetain<CPDF_StructElement>(m_pTree, this, pKidDict);
}
-
-CPDF_Object* CPDF_StructElement::GetAttr(const CFX_ByteStringC& owner,
- const CFX_ByteStringC& name,
- bool bInheritable,
- float fLevel) {
- if (fLevel > nMaxRecursion)
- return nullptr;
-
- if (bInheritable) {
- if (CPDF_Object* pAttr = GetAttr(owner, name, false))
- return pAttr;
- if (!m_pParent)
- return nullptr;
- return m_pParent->GetAttr(owner, name, true, fLevel + 1);
- }
-
- if (CPDF_Object* pA = m_pDict->GetDirectObjectFor("A")) {
- if (CPDF_Dictionary* dict = FindAttrDict(pA, owner)) {
- if (CPDF_Object* attr = dict->GetDirectObjectFor(CFX_ByteString(name)))
- return attr;
- }
- }
-
- CPDF_Object* pC = m_pDict->GetDirectObjectFor("C");
- if (!pC)
- return nullptr;
-
- CPDF_Dictionary* pClassMap = m_pTree->GetTreeRoot()->GetDictFor("ClassMap");
- if (!pClassMap)
- return nullptr;
-
- if (CPDF_Array* pArray = pC->AsArray()) {
- for (uint32_t i = 0; i < pArray->GetCount(); i++) {
- CFX_ByteString class_name = pArray->GetStringAt(i);
- CPDF_Dictionary* pClassDict = pClassMap->GetDictFor(class_name);
- if (pClassDict && pClassDict->GetStringFor("O") == owner)
- return pClassDict->GetDirectObjectFor(CFX_ByteString(name));
- }
- return nullptr;
- }
-
- CFX_ByteString class_name = pC->GetString();
- CPDF_Dictionary* pClassDict = pClassMap->GetDictFor(class_name);
- if (pClassDict && pClassDict->GetStringFor("O") == owner)
- return pClassDict->GetDirectObjectFor(CFX_ByteString(name));
- return nullptr;
-}
-
-CPDF_Object* CPDF_StructElement::GetAttr(const CFX_ByteStringC& owner,
- const CFX_ByteStringC& name,
- bool bInheritable,
- int subindex) {
- CPDF_Object* pAttr = GetAttr(owner, name, bInheritable);
- CPDF_Array* pArray = ToArray(pAttr);
- if (!pArray || subindex == -1)
- return pAttr;
- if (subindex >= static_cast<int>(pArray->GetCount()))
- return pAttr;
- return pArray->GetDirectObjectAt(subindex);
-}
-
-CFX_ByteString CPDF_StructElement::GetName(const CFX_ByteStringC& owner,
- const CFX_ByteStringC& name,
- const CFX_ByteStringC& default_value,
- bool bInheritable,
- int subindex) {
- CPDF_Object* pAttr = GetAttr(owner, name, bInheritable, subindex);
- if (ToName(pAttr))
- return pAttr->GetString();
- return CFX_ByteString(default_value);
-}
-
-FX_ARGB CPDF_StructElement::GetColor(const CFX_ByteStringC& owner,
- const CFX_ByteStringC& name,
- FX_ARGB default_value,
- bool bInheritable,
- int subindex) {
- CPDF_Array* pArray = ToArray(GetAttr(owner, name, bInheritable, subindex));
- if (!pArray)
- return default_value;
- return 0xff000000 | (static_cast<int>(pArray->GetNumberAt(0) * 255) << 16) |
- (static_cast<int>(pArray->GetNumberAt(1) * 255) << 8) |
- static_cast<int>(pArray->GetNumberAt(2) * 255);
-}
-
-float CPDF_StructElement::GetNumber(const CFX_ByteStringC& owner,
- const CFX_ByteStringC& name,
- float default_value,
- bool bInheritable,
- int subindex) {
- CPDF_Object* pAttr = GetAttr(owner, name, bInheritable, subindex);
- return ToNumber(pAttr) ? pAttr->GetNumber() : default_value;
-}
-
-int CPDF_StructElement::GetInteger(const CFX_ByteStringC& owner,
- const CFX_ByteStringC& name,
- int default_value,
- bool bInheritable,
- int subindex) {
- CPDF_Object* pAttr = GetAttr(owner, name, bInheritable, subindex);
- return ToNumber(pAttr) ? pAttr->GetInteger() : default_value;
-}