OLD | NEW |
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/fpdfapi/fpdf_font/include/cpdf_font.h" | 10 #include "core/fpdfapi/fpdf_font/include/cpdf_font.h" |
11 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" | 11 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" |
12 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" | 12 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" |
13 #include "core/fpdfapi/fpdf_parser/include/cpdf_simple_parser.h" | 13 #include "core/fpdfapi/fpdf_parser/include/cpdf_simple_parser.h" |
14 #include "core/fpdfdoc/doc_utils.h" | 14 #include "core/fpdfdoc/doc_utils.h" |
15 #include "core/fpdfdoc/include/fpdf_doc.h" | 15 #include "core/fpdfdoc/include/fpdf_doc.h" |
16 #include "core/fxge/include/fx_font.h" | 16 #include "core/fxge/include/fx_font.h" |
17 | 17 |
18 namespace { | 18 namespace { |
19 | 19 |
20 const int FPDFDOC_UTILS_MAXRECURSION = 32; | 20 const int FPDFDOC_UTILS_MAXRECURSION = 32; |
21 | 21 |
22 CPDF_Object* SearchNumberNode(const CPDF_Dictionary* pNode, int num) { | 22 CPDF_Object* SearchNumberNode(const CPDF_Dictionary* pNode, int num) { |
23 CPDF_Array* pLimits = pNode->GetArrayBy("Limits"); | 23 CPDF_Array* pLimits = pNode->GetArrayBy("Limits"); |
24 if (pLimits && | 24 if (pLimits && |
25 (num < pLimits->GetIntegerAt(0) || num > pLimits->GetIntegerAt(1))) { | 25 (num < pLimits->GetIntegerAt(0) || num > pLimits->GetIntegerAt(1))) { |
26 return NULL; | 26 return NULL; |
27 } | 27 } |
28 CPDF_Array* pNumbers = pNode->GetArrayBy("Nums"); | 28 CPDF_Array* pNumbers = pNode->GetArrayBy("Nums"); |
29 if (pNumbers) { | 29 if (pNumbers) { |
30 uint32_t dwCount = pNumbers->GetCount() / 2; | 30 for (size_t i = 0; i < pNumbers->GetCount() / 2; i++) { |
31 for (uint32_t i = 0; i < dwCount; i++) { | |
32 int index = pNumbers->GetIntegerAt(i * 2); | 31 int index = pNumbers->GetIntegerAt(i * 2); |
33 if (num == index) { | 32 if (num == index) { |
34 return pNumbers->GetDirectObjectAt(i * 2 + 1); | 33 return pNumbers->GetDirectObjectAt(i * 2 + 1); |
35 } | 34 } |
36 if (index > num) { | 35 if (index > num) { |
37 break; | 36 break; |
38 } | 37 } |
39 } | 38 } |
40 return NULL; | 39 return NULL; |
41 } | 40 } |
42 CPDF_Array* pKids = pNode->GetArrayBy("Kids"); | 41 CPDF_Array* pKids = pNode->GetArrayBy("Kids"); |
43 if (!pKids) { | 42 if (!pKids) { |
44 return NULL; | 43 return NULL; |
45 } | 44 } |
46 for (uint32_t i = 0; i < pKids->GetCount(); i++) { | 45 for (size_t i = 0; i < pKids->GetCount(); i++) { |
47 CPDF_Dictionary* pKid = pKids->GetDictAt(i); | 46 CPDF_Dictionary* pKid = pKids->GetDictAt(i); |
48 if (!pKid) { | 47 if (!pKid) { |
49 continue; | 48 continue; |
50 } | 49 } |
51 CPDF_Object* pFound = SearchNumberNode(pKid, num); | 50 CPDF_Object* pFound = SearchNumberNode(pKid, num); |
52 if (pFound) { | 51 if (pFound) { |
53 return pFound; | 52 return pFound; |
54 } | 53 } |
55 } | 54 } |
56 return NULL; | 55 return NULL; |
(...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
747 CPDF_Object* pAttr = pFieldDict->GetDirectObjectBy(name); | 746 CPDF_Object* pAttr = pFieldDict->GetDirectObjectBy(name); |
748 if (pAttr) { | 747 if (pAttr) { |
749 return pAttr; | 748 return pAttr; |
750 } | 749 } |
751 CPDF_Dictionary* pParent = pFieldDict->GetDictBy("Parent"); | 750 CPDF_Dictionary* pParent = pFieldDict->GetDictBy("Parent"); |
752 if (!pParent) { | 751 if (!pParent) { |
753 return NULL; | 752 return NULL; |
754 } | 753 } |
755 return FPDF_GetFieldAttr(pParent, name, nLevel + 1); | 754 return FPDF_GetFieldAttr(pParent, name, nLevel + 1); |
756 } | 755 } |
OLD | NEW |