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

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

Issue 1194933003: Make CPDF_Object::GetString() a virtual method. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: rebase Created 5 years, 5 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
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 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 FX_POSITION pos = pFonts->GetStartPos(); 291 FX_POSITION pos = pFonts->GetStartPos();
292 while (pos) { 292 while (pos) {
293 CPDF_Object* pObj = NULL; 293 CPDF_Object* pObj = NULL;
294 CFX_ByteString csKey; 294 CFX_ByteString csKey;
295 pObj = pFonts->GetNextElement(pos, csKey); 295 pObj = pFonts->GetNextElement(pos, csKey);
296 if (pObj == NULL) { 296 if (pObj == NULL) {
297 continue; 297 continue;
298 } 298 }
299 CPDF_Object* pDirect = pObj->GetDirect(); 299 CPDF_Object* pDirect = pObj->GetDirect();
300 if (pDirect != NULL && pDirect->GetType() == PDFOBJ_DICTIONARY) { 300 if (pDirect != NULL && pDirect->GetType() == PDFOBJ_DICTIONARY) {
301 if (((CPDF_Dictionary*)pDirect)->GetString("Type") == "Font") { 301 if (((CPDF_Dictionary*)pDirect)->GetStringAt("Type") == "Font") {
302 dwCount ++; 302 dwCount ++;
303 } 303 }
304 } 304 }
305 } 305 }
306 return dwCount; 306 return dwCount;
307 } 307 }
308 CPDF_Font* GetInterFormFont(CPDF_Dictionary* pFormDict, CPDF_Document* pDocument , FX_DWORD index, CFX_ByteString& csNameTag) 308 CPDF_Font* GetInterFormFont(CPDF_Dictionary* pFormDict, CPDF_Document* pDocument , FX_DWORD index, CFX_ByteString& csNameTag)
309 { 309 {
310 if (pFormDict == NULL) { 310 if (pFormDict == NULL) {
311 return NULL; 311 return NULL;
(...skipping 13 matching lines...) Expand all
325 CFX_ByteString csKey; 325 CFX_ByteString csKey;
326 pObj = pFonts->GetNextElement(pos, csKey); 326 pObj = pFonts->GetNextElement(pos, csKey);
327 if (pObj == NULL) { 327 if (pObj == NULL) {
328 continue; 328 continue;
329 } 329 }
330 CPDF_Object* pDirect = pObj->GetDirect(); 330 CPDF_Object* pDirect = pObj->GetDirect();
331 if (pDirect == NULL || pDirect->GetType() != PDFOBJ_DICTIONARY) { 331 if (pDirect == NULL || pDirect->GetType() != PDFOBJ_DICTIONARY) {
332 continue; 332 continue;
333 } 333 }
334 CPDF_Dictionary* pElement = (CPDF_Dictionary*)pDirect; 334 CPDF_Dictionary* pElement = (CPDF_Dictionary*)pDirect;
335 if (pElement->GetString("Type") != "Font") { 335 if (pElement->GetStringAt("Type") != "Font") {
336 continue; 336 continue;
337 } 337 }
338 if (dwCount == index) { 338 if (dwCount == index) {
339 csNameTag = csKey; 339 csNameTag = csKey;
340 return pDocument->LoadFont(pElement); 340 return pDocument->LoadFont(pElement);
341 } 341 }
342 dwCount ++; 342 dwCount ++;
343 } 343 }
344 return NULL; 344 return NULL;
345 } 345 }
346 CPDF_Font* GetInterFormFont(CPDF_Dictionary* pFormDict, CPDF_Document* pDocument , CFX_ByteString csNameTag) 346 CPDF_Font* GetInterFormFont(CPDF_Dictionary* pFormDict, CPDF_Document* pDocument , CFX_ByteString csNameTag)
347 { 347 {
348 CFX_ByteString csAlias = PDF_NameDecode(csNameTag); 348 CFX_ByteString csAlias = PDF_NameDecode(csNameTag);
349 if (pFormDict == NULL || csAlias.IsEmpty()) { 349 if (pFormDict == NULL || csAlias.IsEmpty()) {
350 return NULL; 350 return NULL;
351 } 351 }
352 CPDF_Dictionary* pDR = pFormDict->GetDict("DR"); 352 CPDF_Dictionary* pDR = pFormDict->GetDict("DR");
353 if (pDR == NULL) { 353 if (pDR == NULL) {
354 return NULL; 354 return NULL;
355 } 355 }
356 CPDF_Dictionary* pFonts = pDR->GetDict("Font"); 356 CPDF_Dictionary* pFonts = pDR->GetDict("Font");
357 if (pFonts == NULL) { 357 if (pFonts == NULL) {
358 return NULL; 358 return NULL;
359 } 359 }
360 CPDF_Dictionary* pElement = pFonts->GetDict(csAlias); 360 CPDF_Dictionary* pElement = pFonts->GetDict(csAlias);
361 if (pElement == NULL) { 361 if (pElement == NULL) {
362 return NULL; 362 return NULL;
363 } 363 }
364 if (pElement->GetString("Type") == "Font") { 364 if (pElement->GetStringAt("Type") == "Font") {
365 return pDocument->LoadFont(pElement); 365 return pDocument->LoadFont(pElement);
366 } 366 }
367 return NULL; 367 return NULL;
368 } 368 }
369 CPDF_Font* GetInterFormFont(CPDF_Dictionary* pFormDict, CPDF_Document* pDocument , CFX_ByteString csFontName, CFX_ByteString& csNameTag) 369 CPDF_Font* GetInterFormFont(CPDF_Dictionary* pFormDict, CPDF_Document* pDocument , CFX_ByteString csFontName, CFX_ByteString& csNameTag)
370 { 370 {
371 if (pFormDict == NULL || csFontName.IsEmpty()) { 371 if (pFormDict == NULL || csFontName.IsEmpty()) {
372 return NULL; 372 return NULL;
373 } 373 }
374 CPDF_Dictionary* pDR = pFormDict->GetDict("DR"); 374 CPDF_Dictionary* pDR = pFormDict->GetDict("DR");
(...skipping 10 matching lines...) Expand all
385 CFX_ByteString csKey; 385 CFX_ByteString csKey;
386 pObj = pFonts->GetNextElement(pos, csKey); 386 pObj = pFonts->GetNextElement(pos, csKey);
387 if (pObj == NULL) { 387 if (pObj == NULL) {
388 continue; 388 continue;
389 } 389 }
390 CPDF_Object* pDirect = pObj->GetDirect(); 390 CPDF_Object* pDirect = pObj->GetDirect();
391 if (pDirect == NULL || pDirect->GetType() != PDFOBJ_DICTIONARY) { 391 if (pDirect == NULL || pDirect->GetType() != PDFOBJ_DICTIONARY) {
392 continue; 392 continue;
393 } 393 }
394 CPDF_Dictionary* pElement = (CPDF_Dictionary*)pDirect; 394 CPDF_Dictionary* pElement = (CPDF_Dictionary*)pDirect;
395 if (pElement->GetString("Type") != "Font") { 395 if (pElement->GetStringAt("Type") != "Font") {
396 continue; 396 continue;
397 } 397 }
398 CPDF_Font* pFind = pDocument->LoadFont(pElement); 398 CPDF_Font* pFind = pDocument->LoadFont(pElement);
399 if (pFind == NULL) { 399 if (pFind == NULL) {
400 continue; 400 continue;
401 } 401 }
402 CFX_ByteString csBaseFont; 402 CFX_ByteString csBaseFont;
403 csBaseFont = pFind->GetBaseFont(); 403 csBaseFont = pFind->GetBaseFont();
404 csBaseFont.Remove(' '); 404 csBaseFont.Remove(' ');
405 if (csBaseFont == csFontName) { 405 if (csBaseFont == csFontName) {
(...skipping 22 matching lines...) Expand all
428 CFX_ByteString csKey; 428 CFX_ByteString csKey;
429 pObj = pFonts->GetNextElement(pos, csKey); 429 pObj = pFonts->GetNextElement(pos, csKey);
430 if (pObj == NULL) { 430 if (pObj == NULL) {
431 continue; 431 continue;
432 } 432 }
433 CPDF_Object* pDirect = pObj->GetDirect(); 433 CPDF_Object* pDirect = pObj->GetDirect();
434 if (pDirect == NULL || pDirect->GetType() != PDFOBJ_DICTIONARY) { 434 if (pDirect == NULL || pDirect->GetType() != PDFOBJ_DICTIONARY) {
435 continue; 435 continue;
436 } 436 }
437 CPDF_Dictionary* pElement = (CPDF_Dictionary*)pDirect; 437 CPDF_Dictionary* pElement = (CPDF_Dictionary*)pDirect;
438 if (pElement->GetString("Type") != "Font") { 438 if (pElement->GetStringAt("Type") != "Font") {
439 continue; 439 continue;
440 } 440 }
441 CPDF_Font* pFind = pDocument->LoadFont(pElement); 441 CPDF_Font* pFind = pDocument->LoadFont(pElement);
442 if (pFind == NULL) { 442 if (pFind == NULL) {
443 continue; 443 continue;
444 } 444 }
445 CFX_SubstFont* pSubst = (CFX_SubstFont*)pFind->GetSubstFont(); 445 CFX_SubstFont* pSubst = (CFX_SubstFont*)pFind->GetSubstFont();
446 if (pSubst == NULL) { 446 if (pSubst == NULL) {
447 continue; 447 continue;
448 } 448 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 CFX_ByteString csKey; 487 CFX_ByteString csKey;
488 pObj = pFonts->GetNextElement(pos, csKey); 488 pObj = pFonts->GetNextElement(pos, csKey);
489 if (pObj == NULL) { 489 if (pObj == NULL) {
490 continue; 490 continue;
491 } 491 }
492 CPDF_Object* pDirect = pObj->GetDirect(); 492 CPDF_Object* pDirect = pObj->GetDirect();
493 if (pDirect == NULL || pDirect->GetType() != PDFOBJ_DICTIONARY) { 493 if (pDirect == NULL || pDirect->GetType() != PDFOBJ_DICTIONARY) {
494 continue; 494 continue;
495 } 495 }
496 CPDF_Dictionary* pElement = (CPDF_Dictionary*)pDirect; 496 CPDF_Dictionary* pElement = (CPDF_Dictionary*)pDirect;
497 if (pElement->GetString("Type") != "Font") { 497 if (pElement->GetStringAt("Type") != "Font") {
498 continue; 498 continue;
499 } 499 }
500 if (pFont->GetFontDict() == pElement) { 500 if (pFont->GetFontDict() == pElement) {
501 csNameTag = csKey; 501 csNameTag = csKey;
502 return TRUE; 502 return TRUE;
503 } 503 }
504 } 504 }
505 return FALSE; 505 return FALSE;
506 } 506 }
507 FX_BOOL FindInterFormFont(CPDF_Dictionary* pFormDict, CPDF_Document* pDocument, CFX_ByteString csFontName, CPDF_Font*& pFont, CFX_ByteString& csNameTag) 507 FX_BOOL FindInterFormFont(CPDF_Dictionary* pFormDict, CPDF_Document* pDocument, CFX_ByteString csFontName, CPDF_Font*& pFont, CFX_ByteString& csNameTag)
(...skipping 18 matching lines...) Expand all
526 CFX_ByteString csKey, csTmp; 526 CFX_ByteString csKey, csTmp;
527 pObj = pFonts->GetNextElement(pos, csKey); 527 pObj = pFonts->GetNextElement(pos, csKey);
528 if (pObj == NULL) { 528 if (pObj == NULL) {
529 continue; 529 continue;
530 } 530 }
531 CPDF_Object* pDirect = pObj->GetDirect(); 531 CPDF_Object* pDirect = pObj->GetDirect();
532 if (pDirect == NULL || pDirect->GetType() != PDFOBJ_DICTIONARY) { 532 if (pDirect == NULL || pDirect->GetType() != PDFOBJ_DICTIONARY) {
533 continue; 533 continue;
534 } 534 }
535 CPDF_Dictionary* pElement = (CPDF_Dictionary*)pDirect; 535 CPDF_Dictionary* pElement = (CPDF_Dictionary*)pDirect;
536 if (pElement->GetString("Type") != "Font") { 536 if (pElement->GetStringAt("Type") != "Font") {
537 continue; 537 continue;
538 } 538 }
539 pFont = pDocument->LoadFont(pElement); 539 pFont = pDocument->LoadFont(pElement);
540 if (pFont == NULL) { 540 if (pFont == NULL) {
541 continue; 541 continue;
542 } 542 }
543 CFX_ByteString csBaseFont; 543 CFX_ByteString csBaseFont;
544 csBaseFont = pFont->GetBaseFont(); 544 csBaseFont = pFont->GetBaseFont();
545 csBaseFont.Remove(' '); 545 csBaseFont.Remove(' ');
546 if (csBaseFont == csFontName) { 546 if (csBaseFont == csFontName) {
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 if (pFonts == NULL) { 640 if (pFonts == NULL) {
641 return; 641 return;
642 } 642 }
643 pFonts->RemoveAt(csNameTag); 643 pFonts->RemoveAt(csNameTag);
644 } 644 }
645 CPDF_Font* GetDefaultInterFormFont(CPDF_Dictionary* pFormDict, CPDF_Document* pD ocument) 645 CPDF_Font* GetDefaultInterFormFont(CPDF_Dictionary* pFormDict, CPDF_Document* pD ocument)
646 { 646 {
647 if (pFormDict == NULL) { 647 if (pFormDict == NULL) {
648 return NULL; 648 return NULL;
649 } 649 }
650 CPDF_DefaultAppearance cDA = pFormDict->GetString("DA"); 650 CPDF_DefaultAppearance cDA = pFormDict->GetStringAt("DA");
651 CFX_ByteString csFontNameTag; 651 CFX_ByteString csFontNameTag;
652 FX_FLOAT fFontSize; 652 FX_FLOAT fFontSize;
653 cDA.GetFont(csFontNameTag, fFontSize); 653 cDA.GetFont(csFontNameTag, fFontSize);
654 return GetInterFormFont(pFormDict, pDocument, csFontNameTag); 654 return GetInterFormFont(pFormDict, pDocument, csFontNameTag);
655 } 655 }
656 CPDF_IconFit::ScaleMethod CPDF_IconFit::GetScaleMethod() 656 CPDF_IconFit::ScaleMethod CPDF_IconFit::GetScaleMethod()
657 { 657 {
658 if (m_pDict == NULL) { 658 if (m_pDict == NULL) {
659 return Always; 659 return Always;
660 } 660 }
661 CFX_ByteString csSW = m_pDict->GetString("SW", "A"); 661 CFX_ByteString csSW = m_pDict->GetStringAt("SW", "A");
662 if (csSW == "B") { 662 if (csSW == "B") {
663 return Bigger; 663 return Bigger;
664 } else if (csSW == "S") { 664 } else if (csSW == "S") {
665 return Smaller; 665 return Smaller;
666 } else if (csSW == "N") { 666 } else if (csSW == "N") {
667 return Never; 667 return Never;
668 } 668 }
669 return Always; 669 return Always;
670 } 670 }
671 FX_BOOL CPDF_IconFit::IsProportionalScale() 671 FX_BOOL CPDF_IconFit::IsProportionalScale()
672 { 672 {
673 if (m_pDict == NULL) { 673 if (m_pDict == NULL) {
674 return TRUE; 674 return TRUE;
675 } 675 }
676 return m_pDict->GetString("S", "P") != "A"; 676 return m_pDict->GetStringAt("S", "P") != "A";
677 } 677 }
678 void CPDF_IconFit::GetIconPosition(FX_FLOAT& fLeft, FX_FLOAT& fBottom) 678 void CPDF_IconFit::GetIconPosition(FX_FLOAT& fLeft, FX_FLOAT& fBottom)
679 { 679 {
680 fLeft = fBottom = 0.5; 680 fLeft = fBottom = 0.5;
681 if (m_pDict == NULL) { 681 if (m_pDict == NULL) {
682 return; 682 return;
683 } 683 }
684 CPDF_Array* pA = m_pDict->GetArray("A"); 684 CPDF_Array* pA = m_pDict->GetArray("A");
685 if (pA != NULL) { 685 if (pA != NULL) {
686 FX_DWORD dwCount = pA->GetCount(); 686 FX_DWORD dwCount = pA->GetCount();
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
721 CPDF_Object* pAttr = pFieldDict->GetElementValue(name); 721 CPDF_Object* pAttr = pFieldDict->GetElementValue(name);
722 if (pAttr) { 722 if (pAttr) {
723 return pAttr; 723 return pAttr;
724 } 724 }
725 CPDF_Dictionary* pParent = pFieldDict->GetDict("Parent"); 725 CPDF_Dictionary* pParent = pFieldDict->GetDict("Parent");
726 if (pParent == NULL) { 726 if (pParent == NULL) {
727 return NULL; 727 return NULL;
728 } 728 }
729 return FPDF_GetFieldAttr(pParent, name, nLevel + 1); 729 return FPDF_GetFieldAttr(pParent, name, nLevel + 1);
730 } 730 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698