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

Side by Side Diff: fpdfsdk/fpdfppo.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 | « fpdfsdk/fpdfeditpage.cpp ('k') | fpdfsdk/fpdfsave.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 "public/fpdf_ppo.h" 7 #include "public/fpdf_ppo.h"
8 8
9 #include <map> 9 #include <map>
10 #include <memory> 10 #include <memory>
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 CFX_ByteString producerstr; 62 CFX_ByteString producerstr;
63 producerstr.Format("PDFium"); 63 producerstr.Format("PDFium");
64 DInfoDict->SetAt("Producer", new CPDF_String(producerstr, FALSE)); 64 DInfoDict->SetAt("Producer", new CPDF_String(producerstr, FALSE));
65 65
66 // Set type 66 // Set type
67 CFX_ByteString cbRootType = pNewRoot->GetStringBy("Type", ""); 67 CFX_ByteString cbRootType = pNewRoot->GetStringBy("Type", "");
68 if (cbRootType.Equal("")) { 68 if (cbRootType.Equal("")) {
69 pNewRoot->SetAt("Type", new CPDF_Name("Catalog")); 69 pNewRoot->SetAt("Type", new CPDF_Name("Catalog"));
70 } 70 }
71 71
72 CPDF_Object* pElement = pNewRoot->GetElement("Pages"); 72 CPDF_Object* pElement = pNewRoot->GetObjectBy("Pages");
73 CPDF_Dictionary* pNewPages = 73 CPDF_Dictionary* pNewPages =
74 pElement ? ToDictionary(pElement->GetDirect()) : nullptr; 74 pElement ? ToDictionary(pElement->GetDirect()) : nullptr;
75 if (!pNewPages) { 75 if (!pNewPages) {
76 pNewPages = new CPDF_Dictionary; 76 pNewPages = new CPDF_Dictionary;
77 uint32_t NewPagesON = pDestPDFDoc->AddIndirectObject(pNewPages); 77 uint32_t NewPagesON = pDestPDFDoc->AddIndirectObject(pNewPages);
78 pNewRoot->SetAt("Pages", new CPDF_Reference(pDestPDFDoc, NewPagesON)); 78 pNewRoot->SetAt("Pages", new CPDF_Reference(pDestPDFDoc, NewPagesON));
79 } 79 }
80 80
81 CFX_ByteString cbPageType = pNewPages->GetStringBy("Type", ""); 81 CFX_ByteString cbPageType = pNewPages->GetStringBy("Type", "");
82 if (cbPageType.Equal("")) { 82 if (cbPageType.Equal("")) {
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 } 177 }
178 178
179 CPDF_Object* CPDF_PageOrganizer::PageDictGetInheritableTag( 179 CPDF_Object* CPDF_PageOrganizer::PageDictGetInheritableTag(
180 CPDF_Dictionary* pDict, 180 CPDF_Dictionary* pDict,
181 CFX_ByteString nSrctag) { 181 CFX_ByteString nSrctag) {
182 if (!pDict || nSrctag.IsEmpty()) 182 if (!pDict || nSrctag.IsEmpty())
183 return nullptr; 183 return nullptr;
184 if (!pDict->KeyExist("Parent") || !pDict->KeyExist("Type")) 184 if (!pDict->KeyExist("Parent") || !pDict->KeyExist("Type"))
185 return nullptr; 185 return nullptr;
186 186
187 CPDF_Object* pType = pDict->GetElement("Type")->GetDirect(); 187 CPDF_Object* pType = pDict->GetObjectBy("Type")->GetDirect();
188 if (!ToName(pType)) 188 if (!ToName(pType))
189 return nullptr; 189 return nullptr;
190 if (pType->GetString().Compare("Page")) 190 if (pType->GetString().Compare("Page"))
191 return nullptr; 191 return nullptr;
192 192
193 CPDF_Dictionary* pp = ToDictionary(pDict->GetElement("Parent")->GetDirect()); 193 CPDF_Dictionary* pp = ToDictionary(pDict->GetObjectBy("Parent")->GetDirect());
194 if (!pp) 194 if (!pp)
195 return nullptr; 195 return nullptr;
196 196
197 if (pDict->KeyExist((const char*)nSrctag)) 197 if (pDict->KeyExist((const char*)nSrctag))
198 return pDict->GetElement((const char*)nSrctag); 198 return pDict->GetObjectBy((const char*)nSrctag);
199 199
200 while (pp) { 200 while (pp) {
201 if (pp->KeyExist((const char*)nSrctag)) 201 if (pp->KeyExist((const char*)nSrctag))
202 return pp->GetElement((const char*)nSrctag); 202 return pp->GetObjectBy((const char*)nSrctag);
203 if (!pp->KeyExist("Parent")) 203 if (!pp->KeyExist("Parent"))
204 break; 204 break;
205 pp = ToDictionary(pp->GetElement("Parent")->GetDirect()); 205 pp = ToDictionary(pp->GetObjectBy("Parent")->GetDirect());
206 } 206 }
207 return nullptr; 207 return nullptr;
208 } 208 }
209 209
210 FX_BOOL CPDF_PageOrganizer::UpdateReference(CPDF_Object* pObj, 210 FX_BOOL CPDF_PageOrganizer::UpdateReference(CPDF_Object* pObj,
211 CPDF_Document* pDoc, 211 CPDF_Document* pDoc,
212 ObjectNumberMap* pObjNumberMap) { 212 ObjectNumberMap* pObjNumberMap) {
213 switch (pObj->GetType()) { 213 switch (pObj->GetType()) {
214 case CPDF_Object::REFERENCE: { 214 case CPDF_Object::REFERENCE: {
215 CPDF_Reference* pReference = pObj->AsReference(); 215 CPDF_Reference* pReference = pObj->AsReference();
(...skipping 20 matching lines...) Expand all
236 } else { 236 } else {
237 return FALSE; 237 return FALSE;
238 } 238 }
239 } 239 }
240 break; 240 break;
241 } 241 }
242 case CPDF_Object::ARRAY: { 242 case CPDF_Object::ARRAY: {
243 CPDF_Array* pArray = pObj->AsArray(); 243 CPDF_Array* pArray = pObj->AsArray();
244 uint32_t count = pArray->GetCount(); 244 uint32_t count = pArray->GetCount();
245 for (uint32_t i = 0; i < count; ++i) { 245 for (uint32_t i = 0; i < count; ++i) {
246 CPDF_Object* pNextObj = pArray->GetElement(i); 246 CPDF_Object* pNextObj = pArray->GetObjectAt(i);
247 if (!pNextObj) 247 if (!pNextObj)
248 return FALSE; 248 return FALSE;
249 if (!UpdateReference(pNextObj, pDoc, pObjNumberMap)) 249 if (!UpdateReference(pNextObj, pDoc, pObjNumberMap))
250 return FALSE; 250 return FALSE;
251 } 251 }
252 break; 252 break;
253 } 253 }
254 case CPDF_Object::STREAM: { 254 case CPDF_Object::STREAM: {
255 CPDF_Stream* pStream = pObj->AsStream(); 255 CPDF_Stream* pStream = pObj->AsStream();
256 CPDF_Dictionary* pDict = pStream->GetDict(); 256 CPDF_Dictionary* pDict = pStream->GetDict();
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 if (!pSrcDict) 406 if (!pSrcDict)
407 return FALSE; 407 return FALSE;
408 408
409 CPDF_Dictionary* pDstDict = pDstDoc->GetRoot(); 409 CPDF_Dictionary* pDstDict = pDstDoc->GetRoot();
410 if (!pDstDict) 410 if (!pDstDict)
411 return FALSE; 411 return FALSE;
412 412
413 pDstDict->SetAt("ViewerPreferences", pSrcDict->Clone(TRUE)); 413 pDstDict->SetAt("ViewerPreferences", pSrcDict->Clone(TRUE));
414 return TRUE; 414 return TRUE;
415 } 415 }
OLDNEW
« no previous file with comments | « fpdfsdk/fpdfeditpage.cpp ('k') | fpdfsdk/fpdfsave.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698