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

Side by Side Diff: core/fpdfdoc/doc_basic.cpp

Issue 1841173002: Rename GetElementValue() to GetDirectObject{By,At}(). (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Fix test name Created 4 years, 8 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
« no previous file with comments | « core/fpdfdoc/doc_ap.cpp ('k') | core/fpdfdoc/doc_bookmark.cpp » ('j') | 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 "core/fpdfapi/fpdf_parser/include/cpdf_array.h" 7 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h"
8 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" 8 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h"
9 #include "core/fpdfdoc/doc_utils.h" 9 #include "core/fpdfdoc/doc_utils.h"
10 #include "core/include/fpdfdoc/fpdf_doc.h" 10 #include "core/include/fpdfdoc/fpdf_doc.h"
11 11
12 namespace { 12 namespace {
13 13
14 const int nMaxRecursion = 32; 14 const int nMaxRecursion = 32;
15 const FX_CHAR* const g_sZoomModes[] = {"XYZ", "Fit", "FitH", "FitV", "FitR", 15 const FX_CHAR* const g_sZoomModes[] = {"XYZ", "Fit", "FitH", "FitV", "FitR",
16 "FitB", "FitBH", "FitBV", nullptr}; 16 "FitB", "FitBH", "FitBV", nullptr};
17 17
18 } // namespace 18 } // namespace
19 19
20 int CPDF_Dest::GetPageIndex(CPDF_Document* pDoc) { 20 int CPDF_Dest::GetPageIndex(CPDF_Document* pDoc) {
21 CPDF_Array* pArray = ToArray(m_pObj); 21 CPDF_Array* pArray = ToArray(m_pObj);
22 if (!pArray) 22 if (!pArray)
23 return 0; 23 return 0;
24 24
25 CPDF_Object* pPage = pArray->GetElementValue(0); 25 CPDF_Object* pPage = pArray->GetDirectObjectAt(0);
26 if (!pPage) 26 if (!pPage)
27 return 0; 27 return 0;
28 if (pPage->IsNumber()) 28 if (pPage->IsNumber())
29 return pPage->GetInteger(); 29 return pPage->GetInteger();
30 if (!pPage->IsDictionary()) 30 if (!pPage->IsDictionary())
31 return 0; 31 return 0;
32 return pDoc->GetPageIndex(pPage->GetObjNum()); 32 return pDoc->GetPageIndex(pPage->GetObjNum());
33 } 33 }
34 uint32_t CPDF_Dest::GetPageObjNum() { 34 uint32_t CPDF_Dest::GetPageObjNum() {
35 CPDF_Array* pArray = ToArray(m_pObj); 35 CPDF_Array* pArray = ToArray(m_pObj);
36 if (!pArray) 36 if (!pArray)
37 return 0; 37 return 0;
38 38
39 CPDF_Object* pPage = pArray->GetElementValue(0); 39 CPDF_Object* pPage = pArray->GetDirectObjectAt(0);
40 if (!pPage) 40 if (!pPage)
41 return 0; 41 return 0;
42 if (pPage->IsNumber()) 42 if (pPage->IsNumber())
43 return pPage->GetInteger(); 43 return pPage->GetInteger();
44 if (pPage->IsDictionary()) 44 if (pPage->IsDictionary())
45 return pPage->GetObjNum(); 45 return pPage->GetObjNum();
46 return 0; 46 return 0;
47 } 47 }
48 48
49 int CPDF_Dest::GetZoomMode() { 49 int CPDF_Dest::GetZoomMode() {
50 CPDF_Array* pArray = ToArray(m_pObj); 50 CPDF_Array* pArray = ToArray(m_pObj);
51 if (!pArray) 51 if (!pArray)
52 return 0; 52 return 0;
53 53
54 CPDF_Object* pObj = pArray->GetElementValue(1); 54 CPDF_Object* pObj = pArray->GetDirectObjectAt(1);
55 if (!pObj) 55 if (!pObj)
56 return 0; 56 return 0;
57 57
58 CFX_ByteString mode = pObj->GetString(); 58 CFX_ByteString mode = pObj->GetString();
59 for (int i = 0; g_sZoomModes[i]; ++i) { 59 for (int i = 0; g_sZoomModes[i]; ++i) {
60 if (mode == g_sZoomModes[i]) 60 if (mode == g_sZoomModes[i])
61 return i + 1; 61 return i + 1;
62 } 62 }
63 63
64 return 0; 64 return 0;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 if (ppFind) { 109 if (ppFind) {
110 *ppFind = pNames; 110 *ppFind = pNames;
111 } 111 }
112 if (iCompare < 0) { 112 if (iCompare < 0) {
113 continue; 113 continue;
114 } 114 }
115 } else { 115 } else {
116 break; 116 break;
117 } 117 }
118 nIndex += i; 118 nIndex += i;
119 return pNames->GetElementValue(i * 2 + 1); 119 return pNames->GetDirectObjectAt(i * 2 + 1);
120 } 120 }
121 nIndex += dwCount; 121 nIndex += dwCount;
122 return NULL; 122 return NULL;
123 } 123 }
124 CPDF_Array* pKids = pNode->GetArrayBy("Kids"); 124 CPDF_Array* pKids = pNode->GetArrayBy("Kids");
125 if (!pKids) { 125 if (!pKids) {
126 return NULL; 126 return NULL;
127 } 127 }
128 for (uint32_t i = 0; i < pKids->GetCount(); i++) { 128 for (uint32_t i = 0; i < pKids->GetCount(); i++) {
129 CPDF_Dictionary* pKid = pKids->GetDictAt(i); 129 CPDF_Dictionary* pKid = pKids->GetDictAt(i);
(...skipping 21 matching lines...) Expand all
151 if (pNames) { 151 if (pNames) {
152 int nCount = pNames->GetCount() / 2; 152 int nCount = pNames->GetCount() / 2;
153 if (nIndex >= nCurIndex + nCount) { 153 if (nIndex >= nCurIndex + nCount) {
154 nCurIndex += nCount; 154 nCurIndex += nCount;
155 return NULL; 155 return NULL;
156 } 156 }
157 if (ppFind) { 157 if (ppFind) {
158 *ppFind = pNames; 158 *ppFind = pNames;
159 } 159 }
160 csName = pNames->GetStringAt((nIndex - nCurIndex) * 2); 160 csName = pNames->GetStringAt((nIndex - nCurIndex) * 2);
161 return pNames->GetElementValue((nIndex - nCurIndex) * 2 + 1); 161 return pNames->GetDirectObjectAt((nIndex - nCurIndex) * 2 + 1);
162 } 162 }
163 CPDF_Array* pKids = pNode->GetArrayBy("Kids"); 163 CPDF_Array* pKids = pNode->GetArrayBy("Kids");
164 if (!pKids) { 164 if (!pKids) {
165 return NULL; 165 return NULL;
166 } 166 }
167 for (uint32_t i = 0; i < pKids->GetCount(); i++) { 167 for (uint32_t i = 0; i < pKids->GetCount(); i++) {
168 CPDF_Dictionary* pKid = pKids->GetDictAt(i); 168 CPDF_Dictionary* pKid = pKids->GetDictAt(i);
169 if (!pKid) { 169 if (!pKid) {
170 continue; 170 continue;
171 } 171 }
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 int nIndex = 0; 230 int nIndex = 0;
231 return SearchNameNode(m_pRoot, csName, nIndex, NULL); 231 return SearchNameNode(m_pRoot, csName, nIndex, NULL);
232 } 232 }
233 CPDF_Array* CPDF_NameTree::LookupNamedDest(CPDF_Document* pDoc, 233 CPDF_Array* CPDF_NameTree::LookupNamedDest(CPDF_Document* pDoc,
234 const CFX_ByteStringC& sName) { 234 const CFX_ByteStringC& sName) {
235 CPDF_Object* pValue = LookupValue(sName); 235 CPDF_Object* pValue = LookupValue(sName);
236 if (!pValue) { 236 if (!pValue) {
237 CPDF_Dictionary* pDests = pDoc->GetRoot()->GetDictBy("Dests"); 237 CPDF_Dictionary* pDests = pDoc->GetRoot()->GetDictBy("Dests");
238 if (!pDests) 238 if (!pDests)
239 return nullptr; 239 return nullptr;
240 pValue = pDests->GetElementValue(sName); 240 pValue = pDests->GetDirectObjectBy(sName);
241 } 241 }
242 if (!pValue) 242 if (!pValue)
243 return nullptr; 243 return nullptr;
244 if (CPDF_Array* pArray = pValue->AsArray()) 244 if (CPDF_Array* pArray = pValue->AsArray())
245 return pArray; 245 return pArray;
246 if (CPDF_Dictionary* pDict = pValue->AsDictionary()) 246 if (CPDF_Dictionary* pDict = pValue->AsDictionary())
247 return pDict->GetArrayBy("D"); 247 return pDict->GetArrayBy("D");
248 return nullptr; 248 return nullptr;
249 } 249 }
250 250
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 int nPage = FXSYS_atoi(bsLbl); 508 int nPage = FXSYS_atoi(bsLbl);
509 if (nPage > 0 && nPage <= nPages) { 509 if (nPage > 0 && nPage <= nPages) {
510 return nPage; 510 return nPage;
511 } 511 }
512 return -1; 512 return -1;
513 } 513 }
514 int32_t CPDF_PageLabel::GetPageByLabel(const CFX_WideStringC& wsLabel) const { 514 int32_t CPDF_PageLabel::GetPageByLabel(const CFX_WideStringC& wsLabel) const {
515 CFX_ByteString bsLabel = PDF_EncodeText(wsLabel.GetPtr()); 515 CFX_ByteString bsLabel = PDF_EncodeText(wsLabel.GetPtr());
516 return GetPageByLabel(bsLabel); 516 return GetPageByLabel(bsLabel);
517 } 517 }
OLDNEW
« no previous file with comments | « core/fpdfdoc/doc_ap.cpp ('k') | core/fpdfdoc/doc_bookmark.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698