diff options
author | Tom Sepez <tsepez@chromium.org> | 2016-03-09 17:00:09 -0800 |
---|---|---|
committer | Tom Sepez <tsepez@chromium.org> | 2016-03-09 17:00:09 -0800 |
commit | c7c2115d33c5e6cee5e3d5215e3357b859f5990e (patch) | |
tree | 3238db19814a04da55de12e66773bf966edc5aff /core/src/fpdfdoc/doc_utils.cpp | |
parent | 70d54be5ab45d26a7ec6b125ea09f8b6a89a3b6f (diff) | |
download | pdfium-c7c2115d33c5e6cee5e3d5215e3357b859f5990e.tar.xz |
Move CPDF_NumberTree to fpdfdoc.
It's not used anywhere in fpdfapi, and can become restricted
to fpdfoc/.
R=ochang@chromium.org
Review URL: https://codereview.chromium.org/1776713004 .
Diffstat (limited to 'core/src/fpdfdoc/doc_utils.cpp')
-rw-r--r-- | core/src/fpdfdoc/doc_utils.cpp | 47 |
1 files changed, 46 insertions, 1 deletions
diff --git a/core/src/fpdfdoc/doc_utils.cpp b/core/src/fpdfdoc/doc_utils.cpp index 81d72b6704..cccd49ada4 100644 --- a/core/src/fpdfdoc/doc_utils.cpp +++ b/core/src/fpdfdoc/doc_utils.cpp @@ -12,7 +12,52 @@ #include "core/include/fpdfdoc/fpdf_doc.h" #include "core/src/fpdfdoc/doc_utils.h" -static const int FPDFDOC_UTILS_MAXRECURSION = 32; +namespace { + +const int FPDFDOC_UTILS_MAXRECURSION = 32; + +CPDF_Object* SearchNumberNode(const CPDF_Dictionary* pNode, int num) { + CPDF_Array* pLimits = pNode->GetArrayBy("Limits"); + if (pLimits && + (num < pLimits->GetIntegerAt(0) || num > pLimits->GetIntegerAt(1))) { + return NULL; + } + CPDF_Array* pNumbers = pNode->GetArrayBy("Nums"); + if (pNumbers) { + FX_DWORD dwCount = pNumbers->GetCount() / 2; + for (FX_DWORD i = 0; i < dwCount; i++) { + int index = pNumbers->GetIntegerAt(i * 2); + if (num == index) { + return pNumbers->GetElementValue(i * 2 + 1); + } + if (index > num) { + break; + } + } + return NULL; + } + CPDF_Array* pKids = pNode->GetArrayBy("Kids"); + if (!pKids) { + return NULL; + } + for (FX_DWORD i = 0; i < pKids->GetCount(); i++) { + CPDF_Dictionary* pKid = pKids->GetDictAt(i); + if (!pKid) { + continue; + } + CPDF_Object* pFound = SearchNumberNode(pKid, num); + if (pFound) { + return pFound; + } + } + return NULL; +} + +} // namespace + +CPDF_Object* CPDF_NumberTree::LookupValue(int num) const { + return SearchNumberNode(m_pRoot, num); +} CFX_WideString GetFullName(CPDF_Dictionary* pFieldDict) { CFX_WideString full_name; |