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

Side by Side Diff: core/src/fpdfdoc/doc_utils.cpp

Issue 1541703003: Use std::map as CPDF_Dictionary's underlying store. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: address comments, rebase, fix embedder test 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 | « core/src/fpdfdoc/doc_formcontrol.cpp ('k') | fpdfsdk/src/formfiller/FFL_CBA_Fontmap.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/include/fpdfdoc/fpdf_doc.h" 7 #include "core/include/fpdfdoc/fpdf_doc.h"
8 #include "doc_utils.h" 8 #include "doc_utils.h"
9 9
10 static const int FPDFDOC_UTILS_MAXRECURSION = 32; 10 static const int FPDFDOC_UTILS_MAXRECURSION = 32;
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 } 272 }
273 CPDF_Dictionary* pDR = pFormDict->GetDict("DR"); 273 CPDF_Dictionary* pDR = pFormDict->GetDict("DR");
274 if (!pDR) { 274 if (!pDR) {
275 return 0; 275 return 0;
276 } 276 }
277 CPDF_Dictionary* pFonts = pDR->GetDict("Font"); 277 CPDF_Dictionary* pFonts = pDR->GetDict("Font");
278 if (!pFonts) { 278 if (!pFonts) {
279 return 0; 279 return 0;
280 } 280 }
281 FX_DWORD dwCount = 0; 281 FX_DWORD dwCount = 0;
282 FX_POSITION pos = pFonts->GetStartPos(); 282 for (const auto& it : *pFonts) {
283 while (pos) { 283 CPDF_Object* pObj = it.second;
284 CPDF_Object* pObj = NULL;
285 CFX_ByteString csKey;
286 pObj = pFonts->GetNextElement(pos, csKey);
287 if (!pObj) { 284 if (!pObj) {
288 continue; 285 continue;
289 } 286 }
290 if (CPDF_Dictionary* pDirect = ToDictionary(pObj->GetDirect())) { 287 if (CPDF_Dictionary* pDirect = ToDictionary(pObj->GetDirect())) {
291 if (pDirect->GetString("Type") == "Font") { 288 if (pDirect->GetString("Type") == "Font") {
292 dwCount++; 289 dwCount++;
293 } 290 }
294 } 291 }
295 } 292 }
296 return dwCount; 293 return dwCount;
297 } 294 }
298 CPDF_Font* GetInterFormFont(CPDF_Dictionary* pFormDict, 295 CPDF_Font* GetInterFormFont(CPDF_Dictionary* pFormDict,
299 CPDF_Document* pDocument, 296 CPDF_Document* pDocument,
300 FX_DWORD index, 297 FX_DWORD index,
301 CFX_ByteString& csNameTag) { 298 CFX_ByteString& csNameTag) {
302 if (!pFormDict) { 299 if (!pFormDict) {
303 return NULL; 300 return NULL;
304 } 301 }
305 CPDF_Dictionary* pDR = pFormDict->GetDict("DR"); 302 CPDF_Dictionary* pDR = pFormDict->GetDict("DR");
306 if (!pDR) { 303 if (!pDR) {
307 return NULL; 304 return NULL;
308 } 305 }
309 CPDF_Dictionary* pFonts = pDR->GetDict("Font"); 306 CPDF_Dictionary* pFonts = pDR->GetDict("Font");
310 if (!pFonts) { 307 if (!pFonts) {
311 return NULL; 308 return NULL;
312 } 309 }
313 FX_DWORD dwCount = 0; 310 FX_DWORD dwCount = 0;
314 FX_POSITION pos = pFonts->GetStartPos(); 311 for (const auto& it : *pFonts) {
315 while (pos) { 312 const CFX_ByteString& csKey = it.first;
316 CPDF_Object* pObj = NULL; 313 CPDF_Object* pObj = it.second;
317 CFX_ByteString csKey;
318 pObj = pFonts->GetNextElement(pos, csKey);
319 if (!pObj) { 314 if (!pObj) {
320 continue; 315 continue;
321 } 316 }
322 CPDF_Dictionary* pElement = ToDictionary(pObj->GetDirect()); 317 CPDF_Dictionary* pElement = ToDictionary(pObj->GetDirect());
323 if (!pElement) 318 if (!pElement)
324 continue; 319 continue;
325 if (pElement->GetString("Type") != "Font") 320 if (pElement->GetString("Type") != "Font")
326 continue; 321 continue;
327 if (dwCount == index) { 322 if (dwCount == index) {
328 csNameTag = csKey; 323 csNameTag = csKey;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 return NULL; 359 return NULL;
365 } 360 }
366 CPDF_Dictionary* pDR = pFormDict->GetDict("DR"); 361 CPDF_Dictionary* pDR = pFormDict->GetDict("DR");
367 if (!pDR) { 362 if (!pDR) {
368 return NULL; 363 return NULL;
369 } 364 }
370 CPDF_Dictionary* pFonts = pDR->GetDict("Font"); 365 CPDF_Dictionary* pFonts = pDR->GetDict("Font");
371 if (!pFonts) { 366 if (!pFonts) {
372 return NULL; 367 return NULL;
373 } 368 }
374 FX_POSITION pos = pFonts->GetStartPos(); 369 for (const auto& it : *pFonts) {
375 while (pos) { 370 const CFX_ByteString& csKey = it.first;
376 CPDF_Object* pObj = NULL; 371 CPDF_Object* pObj = it.second;
377 CFX_ByteString csKey;
378 pObj = pFonts->GetNextElement(pos, csKey);
379 if (!pObj) { 372 if (!pObj) {
380 continue; 373 continue;
381 } 374 }
382 CPDF_Dictionary* pElement = ToDictionary(pObj->GetDirect()); 375 CPDF_Dictionary* pElement = ToDictionary(pObj->GetDirect());
383 if (!pElement) 376 if (!pElement)
384 continue; 377 continue;
385 if (pElement->GetString("Type") != "Font") 378 if (pElement->GetString("Type") != "Font")
386 continue; 379 continue;
387 380
388 CPDF_Font* pFind = pDocument->LoadFont(pElement); 381 CPDF_Font* pFind = pDocument->LoadFont(pElement);
(...skipping 18 matching lines...) Expand all
407 return NULL; 400 return NULL;
408 } 401 }
409 CPDF_Dictionary* pDR = pFormDict->GetDict("DR"); 402 CPDF_Dictionary* pDR = pFormDict->GetDict("DR");
410 if (!pDR) { 403 if (!pDR) {
411 return NULL; 404 return NULL;
412 } 405 }
413 CPDF_Dictionary* pFonts = pDR->GetDict("Font"); 406 CPDF_Dictionary* pFonts = pDR->GetDict("Font");
414 if (!pFonts) { 407 if (!pFonts) {
415 return NULL; 408 return NULL;
416 } 409 }
417 FX_POSITION pos = pFonts->GetStartPos(); 410 for (const auto& it : *pFonts) {
418 while (pos) { 411 const CFX_ByteString& csKey = it.first;
419 CPDF_Object* pObj = NULL; 412 CPDF_Object* pObj = it.second;
420 CFX_ByteString csKey;
421 pObj = pFonts->GetNextElement(pos, csKey);
422 if (!pObj) { 413 if (!pObj) {
423 continue; 414 continue;
424 } 415 }
425 CPDF_Dictionary* pElement = ToDictionary(pObj->GetDirect()); 416 CPDF_Dictionary* pElement = ToDictionary(pObj->GetDirect());
426 if (!pElement) 417 if (!pElement)
427 continue; 418 continue;
428 if (pElement->GetString("Type") != "Font") 419 if (pElement->GetString("Type") != "Font")
429 continue; 420 continue;
430 CPDF_Font* pFind = pDocument->LoadFont(pElement); 421 CPDF_Font* pFind = pDocument->LoadFont(pElement);
431 if (!pFind) { 422 if (!pFind) {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 return FALSE; 456 return FALSE;
466 } 457 }
467 CPDF_Dictionary* pDR = pFormDict->GetDict("DR"); 458 CPDF_Dictionary* pDR = pFormDict->GetDict("DR");
468 if (!pDR) { 459 if (!pDR) {
469 return FALSE; 460 return FALSE;
470 } 461 }
471 CPDF_Dictionary* pFonts = pDR->GetDict("Font"); 462 CPDF_Dictionary* pFonts = pDR->GetDict("Font");
472 if (!pFonts) { 463 if (!pFonts) {
473 return FALSE; 464 return FALSE;
474 } 465 }
475 FX_POSITION pos = pFonts->GetStartPos(); 466 for (const auto& it : *pFonts) {
476 while (pos) { 467 const CFX_ByteString& csKey = it.first;
477 CPDF_Object* pObj = NULL; 468 CPDF_Object* pObj = it.second;
478 CFX_ByteString csKey;
479 pObj = pFonts->GetNextElement(pos, csKey);
480 if (!pObj) { 469 if (!pObj) {
481 continue; 470 continue;
482 } 471 }
483 CPDF_Dictionary* pElement = ToDictionary(pObj->GetDirect()); 472 CPDF_Dictionary* pElement = ToDictionary(pObj->GetDirect());
484 if (!pElement) 473 if (!pElement)
485 continue; 474 continue;
486 if (pElement->GetString("Type") != "Font") { 475 if (pElement->GetString("Type") != "Font") {
487 continue; 476 continue;
488 } 477 }
489 if (pFont->GetFontDict() == pElement) { 478 if (pFont->GetFontDict() == pElement) {
(...skipping 15 matching lines...) Expand all
505 if (!pDR) { 494 if (!pDR) {
506 return FALSE; 495 return FALSE;
507 } 496 }
508 CPDF_Dictionary* pFonts = pDR->GetDict("Font"); 497 CPDF_Dictionary* pFonts = pDR->GetDict("Font");
509 if (!pFonts) { 498 if (!pFonts) {
510 return FALSE; 499 return FALSE;
511 } 500 }
512 if (csFontName.GetLength() > 0) { 501 if (csFontName.GetLength() > 0) {
513 csFontName.Remove(' '); 502 csFontName.Remove(' ');
514 } 503 }
515 FX_POSITION pos = pFonts->GetStartPos(); 504 for (const auto& it : *pFonts) {
516 while (pos) { 505 const CFX_ByteString& csKey = it.first;
517 CPDF_Object* pObj = NULL; 506 CPDF_Object* pObj = it.second;
518 CFX_ByteString csKey, csTmp;
519 pObj = pFonts->GetNextElement(pos, csKey);
520 if (!pObj) { 507 if (!pObj) {
521 continue; 508 continue;
522 } 509 }
523 CPDF_Dictionary* pElement = ToDictionary(pObj->GetDirect()); 510 CPDF_Dictionary* pElement = ToDictionary(pObj->GetDirect());
524 if (!pElement) 511 if (!pElement)
525 continue; 512 continue;
526 if (pElement->GetString("Type") != "Font") { 513 if (pElement->GetString("Type") != "Font") {
527 continue; 514 continue;
528 } 515 }
529 pFont = pDocument->LoadFont(pElement); 516 pFont = pDocument->LoadFont(pElement);
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 CPDF_Object* pAttr = pFieldDict->GetElementValue(name); 699 CPDF_Object* pAttr = pFieldDict->GetElementValue(name);
713 if (pAttr) { 700 if (pAttr) {
714 return pAttr; 701 return pAttr;
715 } 702 }
716 CPDF_Dictionary* pParent = pFieldDict->GetDict("Parent"); 703 CPDF_Dictionary* pParent = pFieldDict->GetDict("Parent");
717 if (!pParent) { 704 if (!pParent) {
718 return NULL; 705 return NULL;
719 } 706 }
720 return FPDF_GetFieldAttr(pParent, name, nLevel + 1); 707 return FPDF_GetFieldAttr(pParent, name, nLevel + 1);
721 } 708 }
OLDNEW
« no previous file with comments | « core/src/fpdfdoc/doc_formcontrol.cpp ('k') | fpdfsdk/src/formfiller/FFL_CBA_Fontmap.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698