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

Side by Side Diff: core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp

Issue 1644633003: Member function name refactoring (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 10 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 "core/include/fpdfapi/fpdf_objects.h" 7 #include "core/include/fpdfapi/fpdf_objects.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 for (int i = 0; i < size; i++) { 394 for (int i = 0; i < size; i++) {
395 if (pList[i]) 395 if (pList[i])
396 pList[i]->Release(); 396 pList[i]->Release();
397 } 397 }
398 } 398 }
399 CFX_FloatRect CPDF_Array::GetRect() { 399 CFX_FloatRect CPDF_Array::GetRect() {
400 CFX_FloatRect rect; 400 CFX_FloatRect rect;
401 if (!IsArray() || m_Objects.GetSize() != 4) 401 if (!IsArray() || m_Objects.GetSize() != 4)
402 return rect; 402 return rect;
403 403
404 rect.left = GetNumber(0); 404 rect.left = GetNumberAt(0);
405 rect.bottom = GetNumber(1); 405 rect.bottom = GetNumberAt(1);
406 rect.right = GetNumber(2); 406 rect.right = GetNumberAt(2);
407 rect.top = GetNumber(3); 407 rect.top = GetNumberAt(3);
408 return rect; 408 return rect;
409 } 409 }
410 CFX_Matrix CPDF_Array::GetMatrix() { 410 CFX_Matrix CPDF_Array::GetMatrix() {
411 CFX_Matrix matrix; 411 CFX_Matrix matrix;
412 if (!IsArray() || m_Objects.GetSize() != 6) 412 if (!IsArray() || m_Objects.GetSize() != 6)
413 return matrix; 413 return matrix;
414 414
415 matrix.Set(GetNumber(0), GetNumber(1), GetNumber(2), GetNumber(3), 415 matrix.Set(GetNumberAt(0), GetNumberAt(1), GetNumberAt(2), GetNumberAt(3),
416 GetNumber(4), GetNumber(5)); 416 GetNumberAt(4), GetNumberAt(5));
417 return matrix; 417 return matrix;
418 } 418 }
419 CPDF_Object* CPDF_Array::GetElement(FX_DWORD i) const { 419 CPDF_Object* CPDF_Array::GetElement(FX_DWORD i) const {
420 if (i >= (FX_DWORD)m_Objects.GetSize()) 420 if (i >= (FX_DWORD)m_Objects.GetSize())
421 return nullptr; 421 return nullptr;
422 return m_Objects.GetAt(i); 422 return m_Objects.GetAt(i);
423 } 423 }
424 CPDF_Object* CPDF_Array::GetElementValue(FX_DWORD i) const { 424 CPDF_Object* CPDF_Array::GetElementValue(FX_DWORD i) const {
425 if (i >= (FX_DWORD)m_Objects.GetSize()) 425 if (i >= (FX_DWORD)m_Objects.GetSize())
426 return nullptr; 426 return nullptr;
427 return m_Objects.GetAt(i)->GetDirect(); 427 return m_Objects.GetAt(i)->GetDirect();
428 } 428 }
429 CFX_ByteString CPDF_Array::GetString(FX_DWORD i) const { 429 CFX_ByteString CPDF_Array::GetStringAt(FX_DWORD i) const {
430 if (i >= (FX_DWORD)m_Objects.GetSize()) 430 if (i >= (FX_DWORD)m_Objects.GetSize())
431 return CFX_ByteString(); 431 return CFX_ByteString();
432 return m_Objects.GetAt(i)->GetString(); 432 return m_Objects.GetAt(i)->GetString();
433 } 433 }
434 CFX_ByteStringC CPDF_Array::GetConstString(FX_DWORD i) const { 434 CFX_ByteStringC CPDF_Array::GetConstStringAt(FX_DWORD i) const {
435 if (i >= (FX_DWORD)m_Objects.GetSize()) 435 if (i >= (FX_DWORD)m_Objects.GetSize())
436 return CFX_ByteStringC(); 436 return CFX_ByteStringC();
437 return m_Objects.GetAt(i)->GetConstString(); 437 return m_Objects.GetAt(i)->GetConstString();
438 } 438 }
439 int CPDF_Array::GetInteger(FX_DWORD i) const { 439 int CPDF_Array::GetIntegerAt(FX_DWORD i) const {
440 if (i >= (FX_DWORD)m_Objects.GetSize()) 440 if (i >= (FX_DWORD)m_Objects.GetSize())
441 return 0; 441 return 0;
442 return m_Objects.GetAt(i)->GetInteger(); 442 return m_Objects.GetAt(i)->GetInteger();
443 } 443 }
444 FX_FLOAT CPDF_Array::GetNumber(FX_DWORD i) const { 444 FX_FLOAT CPDF_Array::GetNumberAt(FX_DWORD i) const {
445 if (i >= (FX_DWORD)m_Objects.GetSize()) 445 if (i >= (FX_DWORD)m_Objects.GetSize())
446 return 0; 446 return 0;
447 return m_Objects.GetAt(i)->GetNumber(); 447 return m_Objects.GetAt(i)->GetNumber();
448 } 448 }
449 CPDF_Dictionary* CPDF_Array::GetDict(FX_DWORD i) const { 449 CPDF_Dictionary* CPDF_Array::GetDictAt(FX_DWORD i) const {
450 CPDF_Object* p = GetElementValue(i); 450 CPDF_Object* p = GetElementValue(i);
451 if (!p) 451 if (!p)
452 return NULL; 452 return NULL;
453 if (CPDF_Dictionary* pDict = p->AsDictionary()) 453 if (CPDF_Dictionary* pDict = p->AsDictionary())
454 return pDict; 454 return pDict;
455 if (CPDF_Stream* pStream = p->AsStream()) 455 if (CPDF_Stream* pStream = p->AsStream())
456 return pStream->GetDict(); 456 return pStream->GetDict();
457 return NULL; 457 return NULL;
458 } 458 }
459 CPDF_Stream* CPDF_Array::GetStream(FX_DWORD i) const { 459 CPDF_Stream* CPDF_Array::GetStreamAt(FX_DWORD i) const {
460 return ToStream(GetElementValue(i)); 460 return ToStream(GetElementValue(i));
461 } 461 }
462 CPDF_Array* CPDF_Array::GetArray(FX_DWORD i) const { 462 CPDF_Array* CPDF_Array::GetArrayAt(FX_DWORD i) const {
463 return ToArray(GetElementValue(i)); 463 return ToArray(GetElementValue(i));
464 } 464 }
465 void CPDF_Array::RemoveAt(FX_DWORD i, int nCount) { 465 void CPDF_Array::RemoveAt(FX_DWORD i, int nCount) {
466 if (i >= (FX_DWORD)m_Objects.GetSize()) 466 if (i >= (FX_DWORD)m_Objects.GetSize())
467 return; 467 return;
468 468
469 if (nCount <= 0 || nCount > m_Objects.GetSize() - i) 469 if (nCount <= 0 || nCount > m_Objects.GetSize() - i)
470 return; 470 return;
471 471
472 for (int j = 0; j < nCount; ++j) { 472 for (int j = 0; j < nCount; ++j) {
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 auto it = m_Map.find(key); 548 auto it = m_Map.find(key);
549 if (it == m_Map.end()) 549 if (it == m_Map.end())
550 return nullptr; 550 return nullptr;
551 return it->second; 551 return it->second;
552 } 552 }
553 CPDF_Object* CPDF_Dictionary::GetElementValue( 553 CPDF_Object* CPDF_Dictionary::GetElementValue(
554 const CFX_ByteStringC& key) const { 554 const CFX_ByteStringC& key) const {
555 CPDF_Object* p = GetElement(key); 555 CPDF_Object* p = GetElement(key);
556 return p ? p->GetDirect() : nullptr; 556 return p ? p->GetDirect() : nullptr;
557 } 557 }
558 CFX_ByteString CPDF_Dictionary::GetString(const CFX_ByteStringC& key) const { 558 CFX_ByteString CPDF_Dictionary::GetStringBy(const CFX_ByteStringC& key) const {
559 CPDF_Object* p = GetElement(key); 559 CPDF_Object* p = GetElement(key);
560 if (p) { 560 if (p) {
561 return p->GetString(); 561 return p->GetString();
562 } 562 }
563 return CFX_ByteString(); 563 return CFX_ByteString();
564 } 564 }
565 CFX_ByteStringC CPDF_Dictionary::GetConstString( 565 CFX_ByteStringC CPDF_Dictionary::GetConstStringBy(
566 const CFX_ByteStringC& key) const { 566 const CFX_ByteStringC& key) const {
567 CPDF_Object* p = GetElement(key); 567 CPDF_Object* p = GetElement(key);
568 if (p) { 568 if (p) {
569 return p->GetConstString(); 569 return p->GetConstString();
570 } 570 }
571 return CFX_ByteStringC(); 571 return CFX_ByteStringC();
572 } 572 }
573 CFX_WideString CPDF_Dictionary::GetUnicodeText(const CFX_ByteStringC& key, 573 CFX_WideString CPDF_Dictionary::GetUnicodeTextBy(const CFX_ByteStringC& key,
574 CFX_CharMap* pCharMap) const { 574 CFX_CharMap* pCharMap) const {
575 CPDF_Object* p = GetElement(key); 575 CPDF_Object* p = GetElement(key);
576 if (CPDF_Reference* pRef = ToReference(p)) 576 if (CPDF_Reference* pRef = ToReference(p))
577 p = pRef->GetDirect(); 577 p = pRef->GetDirect();
578 return p ? p->GetUnicodeText(pCharMap) : CFX_WideString(); 578 return p ? p->GetUnicodeText(pCharMap) : CFX_WideString();
579 } 579 }
580 CFX_ByteString CPDF_Dictionary::GetString(const CFX_ByteStringC& key, 580 CFX_ByteString CPDF_Dictionary::GetStringBy(const CFX_ByteStringC& key,
581 const CFX_ByteStringC& def) const { 581 const CFX_ByteStringC& def) const {
582 CPDF_Object* p = GetElement(key); 582 CPDF_Object* p = GetElement(key);
583 if (p) { 583 if (p) {
584 return p->GetString(); 584 return p->GetString();
585 } 585 }
586 return CFX_ByteString(def); 586 return CFX_ByteString(def);
587 } 587 }
588 CFX_ByteStringC CPDF_Dictionary::GetConstString( 588 CFX_ByteStringC CPDF_Dictionary::GetConstStringBy(
589 const CFX_ByteStringC& key, 589 const CFX_ByteStringC& key,
590 const CFX_ByteStringC& def) const { 590 const CFX_ByteStringC& def) const {
591 CPDF_Object* p = GetElement(key); 591 CPDF_Object* p = GetElement(key);
592 if (p) { 592 if (p) {
593 return p->GetConstString(); 593 return p->GetConstString();
594 } 594 }
595 return CFX_ByteStringC(def); 595 return CFX_ByteStringC(def);
596 } 596 }
597 int CPDF_Dictionary::GetInteger(const CFX_ByteStringC& key) const { 597 int CPDF_Dictionary::GetIntegerBy(const CFX_ByteStringC& key) const {
598 CPDF_Object* p = GetElement(key); 598 CPDF_Object* p = GetElement(key);
599 if (p) { 599 if (p) {
600 return p->GetInteger(); 600 return p->GetInteger();
601 } 601 }
602 return 0; 602 return 0;
603 } 603 }
604 int CPDF_Dictionary::GetInteger(const CFX_ByteStringC& key, int def) const { 604 int CPDF_Dictionary::GetIntegerBy(const CFX_ByteStringC& key, int def) const {
605 CPDF_Object* p = GetElement(key); 605 CPDF_Object* p = GetElement(key);
606 if (p) { 606 if (p) {
607 return p->GetInteger(); 607 return p->GetInteger();
608 } 608 }
609 return def; 609 return def;
610 } 610 }
611 FX_FLOAT CPDF_Dictionary::GetNumber(const CFX_ByteStringC& key) const { 611 FX_FLOAT CPDF_Dictionary::GetNumberBy(const CFX_ByteStringC& key) const {
612 CPDF_Object* p = GetElement(key); 612 CPDF_Object* p = GetElement(key);
613 if (p) { 613 if (p) {
614 return p->GetNumber(); 614 return p->GetNumber();
615 } 615 }
616 return 0; 616 return 0;
617 } 617 }
618 FX_BOOL CPDF_Dictionary::GetBoolean(const CFX_ByteStringC& key, 618 FX_BOOL CPDF_Dictionary::GetBooleanBy(const CFX_ByteStringC& key,
619 FX_BOOL bDefault) const { 619 FX_BOOL bDefault) const {
620 CPDF_Object* p = GetElement(key); 620 CPDF_Object* p = GetElement(key);
621 if (ToBoolean(p)) 621 if (ToBoolean(p))
622 return p->GetInteger(); 622 return p->GetInteger();
623 return bDefault; 623 return bDefault;
624 } 624 }
625 CPDF_Dictionary* CPDF_Dictionary::GetDict(const CFX_ByteStringC& key) const { 625 CPDF_Dictionary* CPDF_Dictionary::GetDictBy(const CFX_ByteStringC& key) const {
626 CPDF_Object* p = GetElementValue(key); 626 CPDF_Object* p = GetElementValue(key);
627 if (!p) 627 if (!p)
628 return nullptr; 628 return nullptr;
629 if (CPDF_Dictionary* pDict = p->AsDictionary()) 629 if (CPDF_Dictionary* pDict = p->AsDictionary())
630 return pDict; 630 return pDict;
631 if (CPDF_Stream* pStream = p->AsStream()) 631 if (CPDF_Stream* pStream = p->AsStream())
632 return pStream->GetDict(); 632 return pStream->GetDict();
633 return nullptr; 633 return nullptr;
634 } 634 }
635 CPDF_Array* CPDF_Dictionary::GetArray(const CFX_ByteStringC& key) const { 635 CPDF_Array* CPDF_Dictionary::GetArrayBy(const CFX_ByteStringC& key) const {
636 return ToArray(GetElementValue(key)); 636 return ToArray(GetElementValue(key));
637 } 637 }
638 CPDF_Stream* CPDF_Dictionary::GetStream(const CFX_ByteStringC& key) const { 638 CPDF_Stream* CPDF_Dictionary::GetStreamBy(const CFX_ByteStringC& key) const {
639 return ToStream(GetElementValue(key)); 639 return ToStream(GetElementValue(key));
640 } 640 }
641 CFX_FloatRect CPDF_Dictionary::GetRect(const CFX_ByteStringC& key) const { 641 CFX_FloatRect CPDF_Dictionary::GetRectBy(const CFX_ByteStringC& key) const {
642 CFX_FloatRect rect; 642 CFX_FloatRect rect;
643 CPDF_Array* pArray = GetArray(key); 643 CPDF_Array* pArray = GetArrayBy(key);
644 if (pArray) 644 if (pArray)
645 rect = pArray->GetRect(); 645 rect = pArray->GetRect();
646 return rect; 646 return rect;
647 } 647 }
648 CFX_Matrix CPDF_Dictionary::GetMatrix(const CFX_ByteStringC& key) const { 648 CFX_Matrix CPDF_Dictionary::GetMatrixBy(const CFX_ByteStringC& key) const {
649 CFX_Matrix matrix; 649 CFX_Matrix matrix;
650 CPDF_Array* pArray = GetArray(key); 650 CPDF_Array* pArray = GetArrayBy(key);
651 if (pArray) 651 if (pArray)
652 matrix = pArray->GetMatrix(); 652 matrix = pArray->GetMatrix();
653 return matrix; 653 return matrix;
654 } 654 }
655 FX_BOOL CPDF_Dictionary::KeyExist(const CFX_ByteStringC& key) const { 655 FX_BOOL CPDF_Dictionary::KeyExist(const CFX_ByteStringC& key) const {
656 return pdfium::ContainsKey(m_Map, key); 656 return pdfium::ContainsKey(m_Map, key);
657 } 657 }
658 658
659 void CPDF_Dictionary::SetAt(const CFX_ByteStringC& key, CPDF_Object* pObj) { 659 void CPDF_Dictionary::SetAt(const CFX_ByteStringC& key, CPDF_Object* pObj) {
660 ASSERT(IsDictionary()); 660 ASSERT(IsDictionary());
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
1080 pObj->Destroy(); 1080 pObj->Destroy();
1081 return FALSE; 1081 return FALSE;
1082 } 1082 }
1083 it->second->Destroy(); 1083 it->second->Destroy();
1084 } 1084 }
1085 pObj->m_ObjNum = objnum; 1085 pObj->m_ObjNum = objnum;
1086 m_IndirectObjs[objnum] = pObj; 1086 m_IndirectObjs[objnum] = pObj;
1087 m_LastObjNum = std::max(m_LastObjNum, objnum); 1087 m_LastObjNum = std::max(m_LastObjNum, objnum);
1088 return TRUE; 1088 return TRUE;
1089 } 1089 }
OLDNEW
« no previous file with comments | « core/src/fpdfapi/fpdf_parser/fpdf_parser_fdf.cpp ('k') | core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698