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

Side by Side Diff: fpdfsdk/fpdfppo.cpp

Issue 1885973002: Remove implicit cast from CFX_ByteString to (const char*). (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Typo 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/fpdfformfill.cpp ('k') | fpdfsdk/fpdfxfa/fpdfxfa_doc.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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 CPDF_Object* pType = pDict->GetObjectBy("Type")->GetDirect(); 184 CPDF_Object* pType = pDict->GetObjectBy("Type")->GetDirect();
185 if (!ToName(pType)) 185 if (!ToName(pType))
186 return nullptr; 186 return nullptr;
187 if (pType->GetString().Compare("Page")) 187 if (pType->GetString().Compare("Page"))
188 return nullptr; 188 return nullptr;
189 189
190 CPDF_Dictionary* pp = ToDictionary(pDict->GetObjectBy("Parent")->GetDirect()); 190 CPDF_Dictionary* pp = ToDictionary(pDict->GetObjectBy("Parent")->GetDirect());
191 if (!pp) 191 if (!pp)
192 return nullptr; 192 return nullptr;
193 193
194 if (pDict->KeyExist((const char*)nSrctag)) 194 CFX_ByteStringC sSrcTag = nSrctag.AsStringC();
195 return pDict->GetObjectBy((const char*)nSrctag); 195 if (pDict->KeyExist(sSrcTag))
196 return pDict->GetObjectBy(sSrcTag);
196 197
197 while (pp) { 198 while (pp) {
198 if (pp->KeyExist((const char*)nSrctag)) 199 if (pp->KeyExist(sSrcTag))
199 return pp->GetObjectBy((const char*)nSrctag); 200 return pp->GetObjectBy(sSrcTag);
200 if (!pp->KeyExist("Parent")) 201 if (!pp->KeyExist("Parent"))
201 break; 202 break;
202 pp = ToDictionary(pp->GetObjectBy("Parent")->GetDirect()); 203 pp = ToDictionary(pp->GetObjectBy("Parent")->GetDirect());
203 } 204 }
204 return nullptr; 205 return nullptr;
205 } 206 }
206 207
207 FX_BOOL CPDF_PageOrganizer::UpdateReference(CPDF_Object* pObj, 208 FX_BOOL CPDF_PageOrganizer::UpdateReference(CPDF_Object* pObj,
208 CPDF_Document* pDoc, 209 CPDF_Document* pDoc,
209 ObjectNumberMap* pObjNumberMap) { 210 ObjectNumberMap* pObjNumberMap) {
210 switch (pObj->GetType()) { 211 switch (pObj->GetType()) {
211 case CPDF_Object::REFERENCE: { 212 case CPDF_Object::REFERENCE: {
212 CPDF_Reference* pReference = pObj->AsReference(); 213 CPDF_Reference* pReference = pObj->AsReference();
213 uint32_t newobjnum = GetNewObjId(pDoc, pObjNumberMap, pReference); 214 uint32_t newobjnum = GetNewObjId(pDoc, pObjNumberMap, pReference);
214 if (newobjnum == 0) 215 if (newobjnum == 0)
215 return FALSE; 216 return FALSE;
216 pReference->SetRef(pDoc, newobjnum); 217 pReference->SetRef(pDoc, newobjnum);
217 break; 218 break;
218 } 219 }
219 case CPDF_Object::DICTIONARY: { 220 case CPDF_Object::DICTIONARY: {
220 CPDF_Dictionary* pDict = pObj->AsDictionary(); 221 CPDF_Dictionary* pDict = pObj->AsDictionary();
221 auto it = pDict->begin(); 222 auto it = pDict->begin();
222 while (it != pDict->end()) { 223 while (it != pDict->end()) {
223 const CFX_ByteString& key = it->first; 224 const CFX_ByteString& key = it->first;
224 CPDF_Object* pNextObj = it->second; 225 CPDF_Object* pNextObj = it->second;
225 ++it; 226 ++it;
226 if (!FXSYS_strcmp(key, "Parent") || !FXSYS_strcmp(key, "Prev") || 227 if (!FXSYS_strcmp(key.c_str(), "Parent") ||
227 !FXSYS_strcmp(key, "First")) { 228 !FXSYS_strcmp(key.c_str(), "Prev") ||
229 !FXSYS_strcmp(key.c_str(), "First")) {
228 continue; 230 continue;
229 } 231 }
230 if (pNextObj) { 232 if (pNextObj) {
231 if (!UpdateReference(pNextObj, pDoc, pObjNumberMap)) 233 if (!UpdateReference(pNextObj, pDoc, pObjNumberMap))
232 pDict->RemoveAt(key.AsStringC()); 234 pDict->RemoveAt(key.AsStringC());
233 } else { 235 } else {
234 return FALSE; 236 return FALSE;
235 } 237 }
236 } 238 }
237 break; 239 break;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 if (!pDirect) 285 if (!pDirect)
284 return 0; 286 return 0;
285 287
286 CPDF_Object* pClone = pDirect->Clone(); 288 CPDF_Object* pClone = pDirect->Clone();
287 if (!pClone) 289 if (!pClone)
288 return 0; 290 return 0;
289 291
290 if (CPDF_Dictionary* pDictClone = pClone->AsDictionary()) { 292 if (CPDF_Dictionary* pDictClone = pClone->AsDictionary()) {
291 if (pDictClone->KeyExist("Type")) { 293 if (pDictClone->KeyExist("Type")) {
292 CFX_ByteString strType = pDictClone->GetStringBy("Type"); 294 CFX_ByteString strType = pDictClone->GetStringBy("Type");
293 if (!FXSYS_stricmp(strType, "Pages")) { 295 if (!FXSYS_stricmp(strType.c_str(), "Pages")) {
294 pDictClone->Release(); 296 pDictClone->Release();
295 return 4; 297 return 4;
296 } 298 }
297 if (!FXSYS_stricmp(strType, "Page")) { 299 if (!FXSYS_stricmp(strType.c_str(), "Page")) {
298 pDictClone->Release(); 300 pDictClone->Release();
299 return 0; 301 return 0;
300 } 302 }
301 } 303 }
302 } 304 }
303 dwNewObjNum = pDoc->AddIndirectObject(pClone); 305 dwNewObjNum = pDoc->AddIndirectObject(pClone);
304 (*pObjNumberMap)[dwObjnum] = dwNewObjNum; 306 (*pObjNumberMap)[dwObjnum] = dwNewObjNum;
305 if (!UpdateReference(pClone, pDoc, pObjNumberMap)) { 307 if (!UpdateReference(pClone, pDoc, pObjNumberMap)) {
306 pClone->Release(); 308 pClone->Release();
307 return 0; 309 return 0;
(...skipping 15 matching lines...) Expand all
323 CFX_ByteString cbMidRange; 325 CFX_ByteString cbMidRange;
324 int nStringFrom = 0; 326 int nStringFrom = 0;
325 int nStringTo = 0; 327 int nStringTo = 0;
326 while (nStringTo < nLength) { 328 while (nStringTo < nLength) {
327 nStringTo = rangstring.Find(',', nStringFrom); 329 nStringTo = rangstring.Find(',', nStringFrom);
328 if (nStringTo == -1) 330 if (nStringTo == -1)
329 nStringTo = nLength; 331 nStringTo = nLength;
330 cbMidRange = rangstring.Mid(nStringFrom, nStringTo - nStringFrom); 332 cbMidRange = rangstring.Mid(nStringFrom, nStringTo - nStringFrom);
331 int nMid = cbMidRange.Find('-'); 333 int nMid = cbMidRange.Find('-');
332 if (nMid == -1) { 334 if (nMid == -1) {
333 long lPageNum = atol(cbMidRange); 335 long lPageNum = atol(cbMidRange.c_str());
334 if (lPageNum <= 0 || lPageNum > nCount) 336 if (lPageNum <= 0 || lPageNum > nCount)
335 return FALSE; 337 return FALSE;
336 pageArray->push_back((uint16_t)lPageNum); 338 pageArray->push_back((uint16_t)lPageNum);
337 } else { 339 } else {
338 int nStartPageNum = atol(cbMidRange.Mid(0, nMid)); 340 int nStartPageNum = atol(cbMidRange.Mid(0, nMid).c_str());
339 if (nStartPageNum == 0) 341 if (nStartPageNum == 0)
340 return FALSE; 342 return FALSE;
341 343
342 ++nMid; 344 ++nMid;
343 int nEnd = cbMidRange.GetLength() - nMid; 345 int nEnd = cbMidRange.GetLength() - nMid;
344 if (nEnd == 0) 346 if (nEnd == 0)
345 return FALSE; 347 return FALSE;
346 348
347 int nEndPageNum = atol(cbMidRange.Mid(nMid, nEnd)); 349 int nEndPageNum = atol(cbMidRange.Mid(nMid, nEnd).c_str());
348 if (nStartPageNum < 0 || nStartPageNum > nEndPageNum || 350 if (nStartPageNum < 0 || nStartPageNum > nEndPageNum ||
349 nEndPageNum > nCount) { 351 nEndPageNum > nCount) {
350 return FALSE; 352 return FALSE;
351 } 353 }
352 for (int i = nStartPageNum; i <= nEndPageNum; ++i) { 354 for (int i = nStartPageNum; i <= nEndPageNum; ++i) {
353 pageArray->push_back(i); 355 pageArray->push_back(i);
354 } 356 }
355 } 357 }
356 nStringFrom = nStringTo + 1; 358 nStringFrom = nStringTo + 1;
357 } 359 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 if (!pSrcDict) 404 if (!pSrcDict)
403 return FALSE; 405 return FALSE;
404 406
405 CPDF_Dictionary* pDstDict = pDstDoc->GetRoot(); 407 CPDF_Dictionary* pDstDict = pDstDoc->GetRoot();
406 if (!pDstDict) 408 if (!pDstDict)
407 return FALSE; 409 return FALSE;
408 410
409 pDstDict->SetAt("ViewerPreferences", pSrcDict->Clone(TRUE)); 411 pDstDict->SetAt("ViewerPreferences", pSrcDict->Clone(TRUE));
410 return TRUE; 412 return TRUE;
411 } 413 }
OLDNEW
« no previous file with comments | « fpdfsdk/fpdfformfill.cpp ('k') | fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698