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

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

Issue 1410343003: [Merge to XFA] Revert "Revert "Add type cast definitions for CPDF_Dictionary."" (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Rebase to origin/xfa Created 5 years, 2 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_tagged.cpp ('k') | core/src/fpdftext/fpdf_text_int.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 "../../include/fpdfdoc/fpdf_doc.h" 7 #include "../../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 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 } 283 }
284 FX_DWORD dwCount = 0; 284 FX_DWORD dwCount = 0;
285 FX_POSITION pos = pFonts->GetStartPos(); 285 FX_POSITION pos = pFonts->GetStartPos();
286 while (pos) { 286 while (pos) {
287 CPDF_Object* pObj = NULL; 287 CPDF_Object* pObj = NULL;
288 CFX_ByteString csKey; 288 CFX_ByteString csKey;
289 pObj = pFonts->GetNextElement(pos, csKey); 289 pObj = pFonts->GetNextElement(pos, csKey);
290 if (pObj == NULL) { 290 if (pObj == NULL) {
291 continue; 291 continue;
292 } 292 }
293 CPDF_Object* pDirect = pObj->GetDirect(); 293 if (CPDF_Dictionary* pDirect = ToDictionary(pObj->GetDirect())) {
294 if (pDirect != NULL && pDirect->GetType() == PDFOBJ_DICTIONARY) { 294 if (pDirect->GetString("Type") == "Font") {
295 if (((CPDF_Dictionary*)pDirect)->GetString("Type") == "Font") {
296 dwCount++; 295 dwCount++;
297 } 296 }
298 } 297 }
299 } 298 }
300 return dwCount; 299 return dwCount;
301 } 300 }
302 CPDF_Font* GetInterFormFont(CPDF_Dictionary* pFormDict, 301 CPDF_Font* GetInterFormFont(CPDF_Dictionary* pFormDict,
303 CPDF_Document* pDocument, 302 CPDF_Document* pDocument,
304 FX_DWORD index, 303 FX_DWORD index,
305 CFX_ByteString& csNameTag) { 304 CFX_ByteString& csNameTag) {
(...skipping 10 matching lines...) Expand all
316 } 315 }
317 FX_DWORD dwCount = 0; 316 FX_DWORD dwCount = 0;
318 FX_POSITION pos = pFonts->GetStartPos(); 317 FX_POSITION pos = pFonts->GetStartPos();
319 while (pos) { 318 while (pos) {
320 CPDF_Object* pObj = NULL; 319 CPDF_Object* pObj = NULL;
321 CFX_ByteString csKey; 320 CFX_ByteString csKey;
322 pObj = pFonts->GetNextElement(pos, csKey); 321 pObj = pFonts->GetNextElement(pos, csKey);
323 if (pObj == NULL) { 322 if (pObj == NULL) {
324 continue; 323 continue;
325 } 324 }
326 CPDF_Object* pDirect = pObj->GetDirect(); 325 CPDF_Dictionary* pElement = ToDictionary(pObj->GetDirect());
327 if (pDirect == NULL || pDirect->GetType() != PDFOBJ_DICTIONARY) { 326 if (!pElement)
328 continue; 327 continue;
329 } 328 if (pElement->GetString("Type") != "Font")
330 CPDF_Dictionary* pElement = (CPDF_Dictionary*)pDirect;
331 if (pElement->GetString("Type") != "Font") {
332 continue; 329 continue;
333 }
334 if (dwCount == index) { 330 if (dwCount == index) {
335 csNameTag = csKey; 331 csNameTag = csKey;
336 return pDocument->LoadFont(pElement); 332 return pDocument->LoadFont(pElement);
337 } 333 }
338 dwCount++; 334 dwCount++;
339 } 335 }
340 return NULL; 336 return NULL;
341 } 337 }
342 CPDF_Font* GetInterFormFont(CPDF_Dictionary* pFormDict, 338 CPDF_Font* GetInterFormFont(CPDF_Dictionary* pFormDict,
343 CPDF_Document* pDocument, 339 CPDF_Document* pDocument,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 return NULL; 375 return NULL;
380 } 376 }
381 FX_POSITION pos = pFonts->GetStartPos(); 377 FX_POSITION pos = pFonts->GetStartPos();
382 while (pos) { 378 while (pos) {
383 CPDF_Object* pObj = NULL; 379 CPDF_Object* pObj = NULL;
384 CFX_ByteString csKey; 380 CFX_ByteString csKey;
385 pObj = pFonts->GetNextElement(pos, csKey); 381 pObj = pFonts->GetNextElement(pos, csKey);
386 if (pObj == NULL) { 382 if (pObj == NULL) {
387 continue; 383 continue;
388 } 384 }
389 CPDF_Object* pDirect = pObj->GetDirect(); 385 CPDF_Dictionary* pElement = ToDictionary(pObj->GetDirect());
390 if (pDirect == NULL || pDirect->GetType() != PDFOBJ_DICTIONARY) { 386 if (!pElement)
391 continue; 387 continue;
392 } 388 if (pElement->GetString("Type") != "Font")
393 CPDF_Dictionary* pElement = (CPDF_Dictionary*)pDirect;
394 if (pElement->GetString("Type") != "Font") {
395 continue; 389 continue;
396 } 390
397 CPDF_Font* pFind = pDocument->LoadFont(pElement); 391 CPDF_Font* pFind = pDocument->LoadFont(pElement);
398 if (pFind == NULL) { 392 if (!pFind)
399 continue; 393 continue;
400 } 394
401 CFX_ByteString csBaseFont; 395 CFX_ByteString csBaseFont;
402 csBaseFont = pFind->GetBaseFont(); 396 csBaseFont = pFind->GetBaseFont();
403 csBaseFont.Remove(' '); 397 csBaseFont.Remove(' ');
404 if (csBaseFont == csFontName) { 398 if (csBaseFont == csFontName) {
405 csNameTag = csKey; 399 csNameTag = csKey;
406 return pFind; 400 return pFind;
407 } 401 }
408 } 402 }
409 return NULL; 403 return NULL;
410 } 404 }
(...skipping 13 matching lines...) Expand all
424 return NULL; 418 return NULL;
425 } 419 }
426 FX_POSITION pos = pFonts->GetStartPos(); 420 FX_POSITION pos = pFonts->GetStartPos();
427 while (pos) { 421 while (pos) {
428 CPDF_Object* pObj = NULL; 422 CPDF_Object* pObj = NULL;
429 CFX_ByteString csKey; 423 CFX_ByteString csKey;
430 pObj = pFonts->GetNextElement(pos, csKey); 424 pObj = pFonts->GetNextElement(pos, csKey);
431 if (pObj == NULL) { 425 if (pObj == NULL) {
432 continue; 426 continue;
433 } 427 }
434 CPDF_Object* pDirect = pObj->GetDirect(); 428 CPDF_Dictionary* pElement = ToDictionary(pObj->GetDirect());
435 if (pDirect == NULL || pDirect->GetType() != PDFOBJ_DICTIONARY) { 429 if (!pElement)
436 continue; 430 continue;
437 } 431 if (pElement->GetString("Type") != "Font")
438 CPDF_Dictionary* pElement = (CPDF_Dictionary*)pDirect;
439 if (pElement->GetString("Type") != "Font") {
440 continue; 432 continue;
441 }
442 CPDF_Font* pFind = pDocument->LoadFont(pElement); 433 CPDF_Font* pFind = pDocument->LoadFont(pElement);
443 if (pFind == NULL) { 434 if (pFind == NULL) {
444 continue; 435 continue;
445 } 436 }
446 CFX_SubstFont* pSubst = (CFX_SubstFont*)pFind->GetSubstFont(); 437 CFX_SubstFont* pSubst = (CFX_SubstFont*)pFind->GetSubstFont();
447 if (pSubst == NULL) { 438 if (pSubst == NULL) {
448 continue; 439 continue;
449 } 440 }
450 if (pSubst->m_Charset == (int)charSet) { 441 if (pSubst->m_Charset == (int)charSet) {
451 csNameTag = csKey; 442 csNameTag = csKey;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 return FALSE; 476 return FALSE;
486 } 477 }
487 FX_POSITION pos = pFonts->GetStartPos(); 478 FX_POSITION pos = pFonts->GetStartPos();
488 while (pos) { 479 while (pos) {
489 CPDF_Object* pObj = NULL; 480 CPDF_Object* pObj = NULL;
490 CFX_ByteString csKey; 481 CFX_ByteString csKey;
491 pObj = pFonts->GetNextElement(pos, csKey); 482 pObj = pFonts->GetNextElement(pos, csKey);
492 if (pObj == NULL) { 483 if (pObj == NULL) {
493 continue; 484 continue;
494 } 485 }
495 CPDF_Object* pDirect = pObj->GetDirect(); 486 CPDF_Dictionary* pElement = ToDictionary(pObj->GetDirect());
496 if (pDirect == NULL || pDirect->GetType() != PDFOBJ_DICTIONARY) { 487 if (!pElement)
497 continue; 488 continue;
498 }
499 CPDF_Dictionary* pElement = (CPDF_Dictionary*)pDirect;
500 if (pElement->GetString("Type") != "Font") { 489 if (pElement->GetString("Type") != "Font") {
501 continue; 490 continue;
502 } 491 }
503 if (pFont->GetFontDict() == pElement) { 492 if (pFont->GetFontDict() == pElement) {
504 csNameTag = csKey; 493 csNameTag = csKey;
505 return TRUE; 494 return TRUE;
506 } 495 }
507 } 496 }
508 return FALSE; 497 return FALSE;
509 } 498 }
(...skipping 17 matching lines...) Expand all
527 csFontName.Remove(' '); 516 csFontName.Remove(' ');
528 } 517 }
529 FX_POSITION pos = pFonts->GetStartPos(); 518 FX_POSITION pos = pFonts->GetStartPos();
530 while (pos) { 519 while (pos) {
531 CPDF_Object* pObj = NULL; 520 CPDF_Object* pObj = NULL;
532 CFX_ByteString csKey, csTmp; 521 CFX_ByteString csKey, csTmp;
533 pObj = pFonts->GetNextElement(pos, csKey); 522 pObj = pFonts->GetNextElement(pos, csKey);
534 if (pObj == NULL) { 523 if (pObj == NULL) {
535 continue; 524 continue;
536 } 525 }
537 CPDF_Object* pDirect = pObj->GetDirect(); 526 CPDF_Dictionary* pElement = ToDictionary(pObj->GetDirect());
538 if (pDirect == NULL || pDirect->GetType() != PDFOBJ_DICTIONARY) { 527 if (!pElement)
539 continue; 528 continue;
540 }
541 CPDF_Dictionary* pElement = (CPDF_Dictionary*)pDirect;
542 if (pElement->GetString("Type") != "Font") { 529 if (pElement->GetString("Type") != "Font") {
543 continue; 530 continue;
544 } 531 }
545 pFont = pDocument->LoadFont(pElement); 532 pFont = pDocument->LoadFont(pElement);
546 if (pFont == NULL) { 533 if (pFont == NULL) {
547 continue; 534 continue;
548 } 535 }
549 CFX_ByteString csBaseFont; 536 CFX_ByteString csBaseFont;
550 csBaseFont = pFont->GetBaseFont(); 537 csBaseFont = pFont->GetBaseFont();
551 csBaseFont.Remove(' '); 538 csBaseFont.Remove(' ');
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 CPDF_Object* pAttr = pFieldDict->GetElementValue(name); 718 CPDF_Object* pAttr = pFieldDict->GetElementValue(name);
732 if (pAttr) { 719 if (pAttr) {
733 return pAttr; 720 return pAttr;
734 } 721 }
735 CPDF_Dictionary* pParent = pFieldDict->GetDict("Parent"); 722 CPDF_Dictionary* pParent = pFieldDict->GetDict("Parent");
736 if (pParent == NULL) { 723 if (pParent == NULL) {
737 return NULL; 724 return NULL;
738 } 725 }
739 return FPDF_GetFieldAttr(pParent, name, nLevel + 1); 726 return FPDF_GetFieldAttr(pParent, name, nLevel + 1);
740 } 727 }
OLDNEW
« no previous file with comments | « core/src/fpdfdoc/doc_tagged.cpp ('k') | core/src/fpdftext/fpdf_text_int.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698