summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2016-03-09 17:00:09 -0800
committerTom Sepez <tsepez@chromium.org>2016-03-09 17:00:09 -0800
commitc7c2115d33c5e6cee5e3d5215e3357b859f5990e (patch)
tree3238db19814a04da55de12e66773bf966edc5aff
parent70d54be5ab45d26a7ec6b125ea09f8b6a89a3b6f (diff)
downloadpdfium-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 .
-rw-r--r--core/include/fpdfapi/fpdf_parser.h10
-rw-r--r--core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp41
-rw-r--r--core/src/fpdfdoc/doc_basic.cpp1
-rw-r--r--core/src/fpdfdoc/doc_tagged.cpp1
-rw-r--r--core/src/fpdfdoc/doc_utils.cpp47
-rw-r--r--core/src/fpdfdoc/doc_utils.h12
6 files changed, 60 insertions, 52 deletions
diff --git a/core/include/fpdfapi/fpdf_parser.h b/core/include/fpdfapi/fpdf_parser.h
index 2134d0159b..7d7243c90f 100644
--- a/core/include/fpdfapi/fpdf_parser.h
+++ b/core/include/fpdfapi/fpdf_parser.h
@@ -201,16 +201,6 @@ FX_DWORD RunLengthDecode(const uint8_t* src_buf,
FX_DWORD& dest_size);
bool IsSignatureDict(const CPDF_Dictionary* pDict);
-class CPDF_NumberTree {
- public:
- CPDF_NumberTree(CPDF_Dictionary* pRoot) { m_pRoot = pRoot; }
-
- CPDF_Object* LookupValue(int num);
-
- protected:
- CPDF_Dictionary* m_pRoot;
-};
-
class IFX_FileAvail {
public:
virtual ~IFX_FileAvail() {}
diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp
index a08cf7d466..3bf3f58432 100644
--- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp
+++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp
@@ -220,44 +220,3 @@ CFX_ByteTextBuf& operator<<(CFX_ByteTextBuf& buf, const CPDF_Object* pObj) {
}
return buf;
}
-
-static CPDF_Object* SearchNumberNode(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;
-}
-
-CPDF_Object* CPDF_NumberTree::LookupValue(int num) {
- return SearchNumberNode(m_pRoot, num);
-}
diff --git a/core/src/fpdfdoc/doc_basic.cpp b/core/src/fpdfdoc/doc_basic.cpp
index 09d74f546a..72f8ea42f6 100644
--- a/core/src/fpdfdoc/doc_basic.cpp
+++ b/core/src/fpdfdoc/doc_basic.cpp
@@ -6,6 +6,7 @@
#include "core/include/fpdfapi/cpdf_document.h"
#include "core/include/fpdfdoc/fpdf_doc.h"
+#include "core/src/fpdfdoc/doc_utils.h"
const int nMaxRecursion = 32;
int CPDF_Dest::GetPageIndex(CPDF_Document* pDoc) {
diff --git a/core/src/fpdfdoc/doc_tagged.cpp b/core/src/fpdfdoc/doc_tagged.cpp
index 6eb1c98592..2d0677efa4 100644
--- a/core/src/fpdfdoc/doc_tagged.cpp
+++ b/core/src/fpdfdoc/doc_tagged.cpp
@@ -10,6 +10,7 @@
#include "core/include/fpdfapi/fpdf_page.h"
#include "core/include/fpdfapi/fpdf_parser.h"
#include "core/include/fpdfdoc/fpdf_tagged.h"
+#include "core/src/fpdfdoc/doc_utils.h"
#include "core/src/fpdfdoc/tagged_int.h"
const int nMaxRecursion = 32;
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;
diff --git a/core/src/fpdfdoc/doc_utils.h b/core/src/fpdfdoc/doc_utils.h
index 58eee84380..d69652fedc 100644
--- a/core/src/fpdfdoc/doc_utils.h
+++ b/core/src/fpdfdoc/doc_utils.h
@@ -9,6 +9,18 @@
#include <vector>
+class CPDF_Dictionary;
+class CPDF_FormField;
+
+class CPDF_NumberTree {
+ public:
+ CPDF_NumberTree(CPDF_Dictionary* pRoot) : m_pRoot(pRoot) {}
+ CPDF_Object* LookupValue(int num) const;
+
+ protected:
+ CPDF_Dictionary* const m_pRoot;
+};
+
CFX_WideString GetFullName(CPDF_Dictionary* pFieldDict);
void InitInterFormDict(CPDF_Dictionary*& pFormDict, CPDF_Document* pDocument);
FX_DWORD CountInterFormFonts(CPDF_Dictionary* pFormDict);