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

Side by Side 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: 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 unified diff | Download patch
« core/src/fpdfdoc/doc_utils.h ('K') | « core/src/fpdfdoc/doc_utils.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "core/include/fpdfapi/cpdf_document.h" 10 #include "core/include/fpdfapi/cpdf_document.h"
11 #include "core/include/fpdfapi/cpdf_simple_parser.h" 11 #include "core/include/fpdfapi/cpdf_simple_parser.h"
12 #include "core/include/fpdfdoc/fpdf_doc.h" 12 #include "core/include/fpdfdoc/fpdf_doc.h"
13 #include "core/src/fpdfdoc/doc_utils.h" 13 #include "core/src/fpdfdoc/doc_utils.h"
14 14
15 static const int FPDFDOC_UTILS_MAXRECURSION = 32; 15 namespace {
16
17 const int FPDFDOC_UTILS_MAXRECURSION = 32;
18
19 CPDF_Object* SearchNumberNode(CPDF_Dictionary* pNode, int num) {
Oliver Chang 2016/03/10 00:45:45 can this be const CPDF_Dictionary* ?
Tom Sepez 2016/03/10 00:54:28 Done.
20 CPDF_Array* pLimits = pNode->GetArrayBy("Limits");
21 if (pLimits &&
22 (num < pLimits->GetIntegerAt(0) || num > pLimits->GetIntegerAt(1))) {
23 return NULL;
24 }
25 CPDF_Array* pNumbers = pNode->GetArrayBy("Nums");
26 if (pNumbers) {
27 FX_DWORD dwCount = pNumbers->GetCount() / 2;
28 for (FX_DWORD i = 0; i < dwCount; i++) {
29 int index = pNumbers->GetIntegerAt(i * 2);
30 if (num == index) {
31 return pNumbers->GetElementValue(i * 2 + 1);
32 }
33 if (index > num) {
34 break;
35 }
36 }
37 return NULL;
38 }
39 CPDF_Array* pKids = pNode->GetArrayBy("Kids");
40 if (!pKids) {
41 return NULL;
42 }
43 for (FX_DWORD i = 0; i < pKids->GetCount(); i++) {
44 CPDF_Dictionary* pKid = pKids->GetDictAt(i);
45 if (!pKid) {
46 continue;
47 }
48 CPDF_Object* pFound = SearchNumberNode(pKid, num);
49 if (pFound) {
50 return pFound;
51 }
52 }
53 return NULL;
54 }
55
56 } // namespace
57
58 CPDF_Object* CPDF_NumberTree::LookupValue(int num) {
59 return SearchNumberNode(m_pRoot, num);
60 }
16 61
17 CFX_WideString GetFullName(CPDF_Dictionary* pFieldDict) { 62 CFX_WideString GetFullName(CPDF_Dictionary* pFieldDict) {
18 CFX_WideString full_name; 63 CFX_WideString full_name;
19 CPDF_Dictionary* pLevel = pFieldDict; 64 CPDF_Dictionary* pLevel = pFieldDict;
20 while (pLevel) { 65 while (pLevel) {
21 CFX_WideString short_name = pLevel->GetUnicodeTextBy("T"); 66 CFX_WideString short_name = pLevel->GetUnicodeTextBy("T");
22 if (short_name != L"") { 67 if (short_name != L"") {
23 if (full_name == L"") { 68 if (full_name == L"") {
24 full_name = short_name; 69 full_name = short_name;
25 } else { 70 } else {
(...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after
698 CPDF_Object* pAttr = pFieldDict->GetElementValue(name); 743 CPDF_Object* pAttr = pFieldDict->GetElementValue(name);
699 if (pAttr) { 744 if (pAttr) {
700 return pAttr; 745 return pAttr;
701 } 746 }
702 CPDF_Dictionary* pParent = pFieldDict->GetDictBy("Parent"); 747 CPDF_Dictionary* pParent = pFieldDict->GetDictBy("Parent");
703 if (!pParent) { 748 if (!pParent) {
704 return NULL; 749 return NULL;
705 } 750 }
706 return FPDF_GetFieldAttr(pParent, name, nLevel + 1); 751 return FPDF_GetFieldAttr(pParent, name, nLevel + 1);
707 } 752 }
OLDNEW
« core/src/fpdfdoc/doc_utils.h ('K') | « core/src/fpdfdoc/doc_utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698