Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(229)

Unified Diff: core/src/fpdfdoc/doc_utils.cpp

Issue 1776713004: Move CPDF_NumberTree to fpdfdoc. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: One more const. Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « core/src/fpdfdoc/doc_utils.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/src/fpdfdoc/doc_utils.cpp
diff --git a/core/src/fpdfdoc/doc_utils.cpp b/core/src/fpdfdoc/doc_utils.cpp
index 81d72b6704e8d4f5c9f7a20ef288ff52c498ca87..cccd49ada4b0fd7cccc45fe399ff30bd9df74550 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;
« no previous file with comments | « core/src/fpdfdoc/doc_utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698