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

Side by Side Diff: core/fpdfapi/fpdf_parser/cpdf_hint_tables.cpp

Issue 2334323005: Rename dictionary set and get methods (Closed)
Patch Set: Created 4 years, 3 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 2016 PDFium Authors. All rights reserved. 1 // Copyright 2016 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/fpdfapi/fpdf_parser/cpdf_hint_tables.h" 7 #include "core/fpdfapi/fpdf_parser/cpdf_hint_tables.h"
8 8
9 #include <limits> 9 #include <limits>
10 10
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 } 448 }
449 } 449 }
450 return CPDF_DataAvail::DataAvailable; 450 return CPDF_DataAvail::DataAvailable;
451 } 451 }
452 452
453 bool CPDF_HintTables::LoadHintStream(CPDF_Stream* pHintStream) { 453 bool CPDF_HintTables::LoadHintStream(CPDF_Stream* pHintStream) {
454 if (!pHintStream) 454 if (!pHintStream)
455 return false; 455 return false;
456 456
457 CPDF_Dictionary* pDict = pHintStream->GetDict(); 457 CPDF_Dictionary* pDict = pHintStream->GetDict();
458 CPDF_Object* pOffset = pDict ? pDict->GetObjectBy("S") : nullptr; 458 CPDF_Object* pOffset = pDict ? pDict->GetObjectFor("S") : nullptr;
459 if (!pOffset || !pOffset->IsNumber()) 459 if (!pOffset || !pOffset->IsNumber())
460 return false; 460 return false;
461 461
462 int shared_hint_table_offset = pOffset->GetInteger(); 462 int shared_hint_table_offset = pOffset->GetInteger();
463 if (shared_hint_table_offset <= 0) 463 if (shared_hint_table_offset <= 0)
464 return false; 464 return false;
465 465
466 CPDF_StreamAcc acc; 466 CPDF_StreamAcc acc;
467 acc.LoadAllData(pHintStream); 467 acc.LoadAllData(pHintStream);
468 468
(...skipping 11 matching lines...) Expand all
480 return false; 480 return false;
481 } 481 }
482 482
483 CFX_BitStream bs; 483 CFX_BitStream bs;
484 bs.Init(acc.GetData(), size); 484 bs.Init(acc.GetData(), size);
485 return ReadPageHintTable(&bs) && 485 return ReadPageHintTable(&bs) &&
486 ReadSharedObjHintTable(&bs, shared_hint_table_offset); 486 ReadSharedObjHintTable(&bs, shared_hint_table_offset);
487 } 487 }
488 488
489 int CPDF_HintTables::GetEndOfFirstPageOffset() const { 489 int CPDF_HintTables::GetEndOfFirstPageOffset() const {
490 CPDF_Object* pOffsetE = m_pLinearizedDict->GetDirectObjectBy("E"); 490 CPDF_Object* pOffsetE = m_pLinearizedDict->GetDirectObjectFor("E");
491 return pOffsetE ? pOffsetE->GetInteger() : -1; 491 return pOffsetE ? pOffsetE->GetInteger() : -1;
492 } 492 }
493 493
494 int CPDF_HintTables::GetNumberOfPages() const { 494 int CPDF_HintTables::GetNumberOfPages() const {
495 CPDF_Object* pPageNum = m_pLinearizedDict->GetDirectObjectBy("N"); 495 CPDF_Object* pPageNum = m_pLinearizedDict->GetDirectObjectFor("N");
496 return pPageNum ? pPageNum->GetInteger() : 0; 496 return pPageNum ? pPageNum->GetInteger() : 0;
497 } 497 }
498 498
499 int CPDF_HintTables::GetFirstPageObjectNumber() const { 499 int CPDF_HintTables::GetFirstPageObjectNumber() const {
500 CPDF_Object* pFirstPageObj = m_pLinearizedDict->GetDirectObjectBy("O"); 500 CPDF_Object* pFirstPageObj = m_pLinearizedDict->GetDirectObjectFor("O");
501 return pFirstPageObj ? pFirstPageObj->GetInteger() : -1; 501 return pFirstPageObj ? pFirstPageObj->GetInteger() : -1;
502 } 502 }
503 503
504 int CPDF_HintTables::GetFirstPageNumber() const { 504 int CPDF_HintTables::GetFirstPageNumber() const {
505 CPDF_Object* pFirstPageNum = m_pLinearizedDict->GetDirectObjectBy("P"); 505 CPDF_Object* pFirstPageNum = m_pLinearizedDict->GetDirectObjectFor("P");
506 return pFirstPageNum ? pFirstPageNum->GetInteger() : 0; 506 return pFirstPageNum ? pFirstPageNum->GetInteger() : 0;
507 } 507 }
508 508
509 int CPDF_HintTables::ReadPrimaryHintStreamOffset() const { 509 int CPDF_HintTables::ReadPrimaryHintStreamOffset() const {
510 return ReadPrimaryHintStream(0); 510 return ReadPrimaryHintStream(0);
511 } 511 }
512 512
513 int CPDF_HintTables::ReadPrimaryHintStreamLength() const { 513 int CPDF_HintTables::ReadPrimaryHintStreamLength() const {
514 return ReadPrimaryHintStream(1); 514 return ReadPrimaryHintStream(1);
515 } 515 }
516 516
517 int CPDF_HintTables::ReadPrimaryHintStream(int index) const { 517 int CPDF_HintTables::ReadPrimaryHintStream(int index) const {
518 CPDF_Array* pRange = m_pLinearizedDict->GetArrayBy("H"); 518 CPDF_Array* pRange = m_pLinearizedDict->GetArrayFor("H");
519 if (!pRange) 519 if (!pRange)
520 return -1; 520 return -1;
521 521
522 CPDF_Object* pStreamLen = pRange->GetDirectObjectAt(index); 522 CPDF_Object* pStreamLen = pRange->GetDirectObjectAt(index);
523 return pStreamLen ? pStreamLen->GetInteger() : -1; 523 return pStreamLen ? pStreamLen->GetInteger() : -1;
524 } 524 }
OLDNEW
« no previous file with comments | « core/fpdfapi/fpdf_parser/cpdf_document.cpp ('k') | core/fpdfapi/fpdf_parser/cpdf_object_unittest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698