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

Side by Side Diff: fpdfsdk/src/fpdfppo.cpp

Issue 1636503006: Merge to XFA: War on #defines, part 1. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Dircet -> Direct typo. Created 4 years, 11 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/src/fpdfeditpage.cpp ('k') | fpdfsdk/src/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 <memory> 9 #include <memory>
10 10
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 break; 196 break;
197 pp = ToDictionary(pp->GetElement("Parent")->GetDirect()); 197 pp = ToDictionary(pp->GetElement("Parent")->GetDirect());
198 } 198 }
199 return nullptr; 199 return nullptr;
200 } 200 }
201 201
202 FX_BOOL CPDF_PageOrganizer::UpdateReference(CPDF_Object* pObj, 202 FX_BOOL CPDF_PageOrganizer::UpdateReference(CPDF_Object* pObj,
203 CPDF_Document* pDoc, 203 CPDF_Document* pDoc,
204 ObjectNumberMap* pObjNumberMap) { 204 ObjectNumberMap* pObjNumberMap) {
205 switch (pObj->GetType()) { 205 switch (pObj->GetType()) {
206 case PDFOBJ_REFERENCE: { 206 case CPDF_Object::REFERENCE: {
207 CPDF_Reference* pReference = pObj->AsReference(); 207 CPDF_Reference* pReference = pObj->AsReference();
208 FX_DWORD newobjnum = GetNewObjId(pDoc, pObjNumberMap, pReference); 208 FX_DWORD newobjnum = GetNewObjId(pDoc, pObjNumberMap, pReference);
209 if (newobjnum == 0) 209 if (newobjnum == 0)
210 return FALSE; 210 return FALSE;
211 pReference->SetRef(pDoc, newobjnum); 211 pReference->SetRef(pDoc, newobjnum);
212 break; 212 break;
213 } 213 }
214 case PDFOBJ_DICTIONARY: { 214 case CPDF_Object::DICTIONARY: {
215 CPDF_Dictionary* pDict = pObj->AsDictionary(); 215 CPDF_Dictionary* pDict = pObj->AsDictionary();
216 auto it = pDict->begin(); 216 auto it = pDict->begin();
217 while (it != pDict->end()) { 217 while (it != pDict->end()) {
218 const CFX_ByteString& key = it->first; 218 const CFX_ByteString& key = it->first;
219 CPDF_Object* pNextObj = it->second; 219 CPDF_Object* pNextObj = it->second;
220 ++it; 220 ++it;
221 if (!FXSYS_strcmp(key, "Parent") || !FXSYS_strcmp(key, "Prev") || 221 if (!FXSYS_strcmp(key, "Parent") || !FXSYS_strcmp(key, "Prev") ||
222 !FXSYS_strcmp(key, "First")) { 222 !FXSYS_strcmp(key, "First")) {
223 continue; 223 continue;
224 } 224 }
225 if (pNextObj) { 225 if (pNextObj) {
226 if (!UpdateReference(pNextObj, pDoc, pObjNumberMap)) 226 if (!UpdateReference(pNextObj, pDoc, pObjNumberMap))
227 pDict->RemoveAt(key); 227 pDict->RemoveAt(key);
228 } else { 228 } else {
229 return FALSE; 229 return FALSE;
230 } 230 }
231 } 231 }
232 break; 232 break;
233 } 233 }
234 case PDFOBJ_ARRAY: { 234 case CPDF_Object::ARRAY: {
235 CPDF_Array* pArray = pObj->AsArray(); 235 CPDF_Array* pArray = pObj->AsArray();
236 FX_DWORD count = pArray->GetCount(); 236 FX_DWORD count = pArray->GetCount();
237 for (FX_DWORD i = 0; i < count; ++i) { 237 for (FX_DWORD i = 0; i < count; ++i) {
238 CPDF_Object* pNextObj = pArray->GetElement(i); 238 CPDF_Object* pNextObj = pArray->GetElement(i);
239 if (!pNextObj) 239 if (!pNextObj)
240 return FALSE; 240 return FALSE;
241 if (!UpdateReference(pNextObj, pDoc, pObjNumberMap)) 241 if (!UpdateReference(pNextObj, pDoc, pObjNumberMap))
242 return FALSE; 242 return FALSE;
243 } 243 }
244 break; 244 break;
245 } 245 }
246 case PDFOBJ_STREAM: { 246 case CPDF_Object::STREAM: {
247 CPDF_Stream* pStream = pObj->AsStream(); 247 CPDF_Stream* pStream = pObj->AsStream();
248 CPDF_Dictionary* pDict = pStream->GetDict(); 248 CPDF_Dictionary* pDict = pStream->GetDict();
249 if (pDict) { 249 if (pDict) {
250 if (!UpdateReference(pDict, pDoc, pObjNumberMap)) 250 if (!UpdateReference(pDict, pDoc, pObjNumberMap))
251 return FALSE; 251 return FALSE;
252 } else { 252 } else {
253 return FALSE; 253 return FALSE;
254 } 254 }
255 break; 255 break;
256 } 256 }
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 if (!pSrcDict) 398 if (!pSrcDict)
399 return FALSE; 399 return FALSE;
400 400
401 CPDF_Dictionary* pDstDict = pDstDoc->GetRoot(); 401 CPDF_Dictionary* pDstDict = pDstDoc->GetRoot();
402 if (!pDstDict) 402 if (!pDstDict)
403 return FALSE; 403 return FALSE;
404 404
405 pDstDict->SetAt("ViewerPreferences", pSrcDict->Clone(TRUE)); 405 pDstDict->SetAt("ViewerPreferences", pSrcDict->Clone(TRUE));
406 return TRUE; 406 return TRUE;
407 } 407 }
OLDNEW
« no previous file with comments | « fpdfsdk/src/fpdfeditpage.cpp ('k') | fpdfsdk/src/fpdfsave.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698