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

Side by Side Diff: core/fpdfapi/page/fpdf_page_parser_old.cpp

Issue 2477443002: Remove FX_BOOL from core (Closed)
Patch Set: Created 4 years, 1 month 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/fpdfapi/page/fpdf_page_func.cpp ('k') | core/fpdfapi/page/pageint.h » ('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/fpdfapi/page/pageint.h" 7 #include "core/fpdfapi/page/pageint.h"
8 8
9 #include <limits.h> 9 #include <limits.h>
10 10
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 FPDFAPI_CreateFaxDecoder(src_buf, limit, width, height, pParam); 89 FPDFAPI_CreateFaxDecoder(src_buf, limit, width, height, pParam);
90 return DecodeAllScanlines(pDecoder, dest_buf, dest_size); 90 return DecodeAllScanlines(pDecoder, dest_buf, dest_size);
91 } 91 }
92 if (decoder == "ASCII85Decode" || decoder == "A85") { 92 if (decoder == "ASCII85Decode" || decoder == "A85") {
93 return A85Decode(src_buf, limit, dest_buf, dest_size); 93 return A85Decode(src_buf, limit, dest_buf, dest_size);
94 } 94 }
95 if (decoder == "ASCIIHexDecode" || decoder == "AHx") { 95 if (decoder == "ASCIIHexDecode" || decoder == "AHx") {
96 return HexDecode(src_buf, limit, dest_buf, dest_size); 96 return HexDecode(src_buf, limit, dest_buf, dest_size);
97 } 97 }
98 if (decoder == "FlateDecode" || decoder == "Fl") { 98 if (decoder == "FlateDecode" || decoder == "Fl") {
99 return FPDFAPI_FlateOrLZWDecode(FALSE, src_buf, limit, pParam, dest_size, 99 return FPDFAPI_FlateOrLZWDecode(false, src_buf, limit, pParam, dest_size,
100 dest_buf, dest_size); 100 dest_buf, dest_size);
101 } 101 }
102 if (decoder == "LZWDecode" || decoder == "LZW") { 102 if (decoder == "LZWDecode" || decoder == "LZW") {
103 return FPDFAPI_FlateOrLZWDecode(TRUE, src_buf, limit, pParam, 0, dest_buf, 103 return FPDFAPI_FlateOrLZWDecode(true, src_buf, limit, pParam, 0, dest_buf,
104 dest_size); 104 dest_size);
105 } 105 }
106 if (decoder == "DCTDecode" || decoder == "DCT") { 106 if (decoder == "DCTDecode" || decoder == "DCT") {
107 CCodec_ScanlineDecoder* pDecoder = 107 CCodec_ScanlineDecoder* pDecoder =
108 CPDF_ModuleMgr::Get()->GetJpegModule()->CreateDecoder( 108 CPDF_ModuleMgr::Get()->GetJpegModule()->CreateDecoder(
109 src_buf, limit, width, height, 0, 109 src_buf, limit, width, height, 0,
110 !pParam || pParam->GetIntegerFor("ColorTransform", 1)); 110 !pParam || pParam->GetIntegerFor("ColorTransform", 1));
111 return DecodeAllScanlines(pDecoder, dest_buf, dest_size); 111 return DecodeAllScanlines(pDecoder, dest_buf, dest_size);
112 } 112 }
113 if (decoder == "RunLengthDecode" || decoder == "RL") { 113 if (decoder == "RunLengthDecode" || decoder == "RL") {
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 310
311 m_WordBuffer[m_WordSize] = 0; 311 m_WordBuffer[m_WordSize] = 0;
312 if (bIsNumber) 312 if (bIsNumber)
313 return Number; 313 return Number;
314 314
315 if (m_WordBuffer[0] == '/') 315 if (m_WordBuffer[0] == '/')
316 return Name; 316 return Name;
317 317
318 if (m_WordSize == 4) { 318 if (m_WordSize == 4) {
319 if (memcmp(m_WordBuffer, "true", 4) == 0) { 319 if (memcmp(m_WordBuffer, "true", 4) == 0) {
320 m_pLastObj = new CPDF_Boolean(TRUE); 320 m_pLastObj = new CPDF_Boolean(true);
321 return Others; 321 return Others;
322 } 322 }
323 if (memcmp(m_WordBuffer, "null", 4) == 0) { 323 if (memcmp(m_WordBuffer, "null", 4) == 0) {
324 m_pLastObj = new CPDF_Null; 324 m_pLastObj = new CPDF_Null;
325 return Others; 325 return Others;
326 } 326 }
327 } else if (m_WordSize == 5) { 327 } else if (m_WordSize == 5) {
328 if (memcmp(m_WordBuffer, "false", 5) == 0) { 328 if (memcmp(m_WordBuffer, "false", 5) == 0) {
329 m_pLastObj = new CPDF_Boolean(FALSE); 329 m_pLastObj = new CPDF_Boolean(false);
330 return Others; 330 return Others;
331 } 331 }
332 } 332 }
333 return Keyword; 333 return Keyword;
334 } 334 }
335 335
336 CPDF_Object* CPDF_StreamParser::GetObject() { 336 CPDF_Object* CPDF_StreamParser::GetObject() {
337 CPDF_Object* pObj = m_pLastObj; 337 CPDF_Object* pObj = m_pLastObj;
338 m_pLastObj = nullptr; 338 m_pLastObj = nullptr;
339 return pObj; 339 return pObj;
(...skipping 13 matching lines...) Expand all
353 353
354 int first_char = m_WordBuffer[0]; 354 int first_char = m_WordBuffer[0];
355 if (first_char == '/') { 355 if (first_char == '/') {
356 CFX_ByteString name = 356 CFX_ByteString name =
357 PDF_NameDecode(CFX_ByteStringC(m_WordBuffer + 1, m_WordSize - 1)); 357 PDF_NameDecode(CFX_ByteStringC(m_WordBuffer + 1, m_WordSize - 1));
358 return new CPDF_Name(m_pPool ? m_pPool->Intern(name) : name); 358 return new CPDF_Name(m_pPool ? m_pPool->Intern(name) : name);
359 } 359 }
360 360
361 if (first_char == '(') { 361 if (first_char == '(') {
362 CFX_ByteString str = ReadString(); 362 CFX_ByteString str = ReadString();
363 return new CPDF_String(m_pPool ? m_pPool->Intern(str) : str, FALSE); 363 return new CPDF_String(m_pPool ? m_pPool->Intern(str) : str, false);
364 } 364 }
365 365
366 if (first_char == '<') { 366 if (first_char == '<') {
367 if (m_WordSize == 1) 367 if (m_WordSize == 1)
368 return new CPDF_String(ReadHexString(), TRUE); 368 return new CPDF_String(ReadHexString(), true);
369 369
370 CPDF_Dictionary* pDict = new CPDF_Dictionary(m_pPool); 370 CPDF_Dictionary* pDict = new CPDF_Dictionary(m_pPool);
371 while (1) { 371 while (1) {
372 GetNextWord(bIsNumber); 372 GetNextWord(bIsNumber);
373 if (m_WordSize == 2 && m_WordBuffer[0] == '>') 373 if (m_WordSize == 2 && m_WordBuffer[0] == '>')
374 break; 374 break;
375 375
376 if (!m_WordSize || m_WordBuffer[0] != '/') { 376 if (!m_WordSize || m_WordBuffer[0] != '/') {
377 pDict->Release(); 377 pDict->Release();
378 return nullptr; 378 return nullptr;
(...skipping 29 matching lines...) Expand all
408 continue; 408 continue;
409 } 409 }
410 410
411 if (!m_WordSize || m_WordBuffer[0] == ']') 411 if (!m_WordSize || m_WordBuffer[0] == ']')
412 break; 412 break;
413 } 413 }
414 return pArray; 414 return pArray;
415 } 415 }
416 416
417 if (m_WordSize == 5 && !memcmp(m_WordBuffer, "false", 5)) 417 if (m_WordSize == 5 && !memcmp(m_WordBuffer, "false", 5))
418 return new CPDF_Boolean(FALSE); 418 return new CPDF_Boolean(false);
419 419
420 if (m_WordSize == 4) { 420 if (m_WordSize == 4) {
421 if (memcmp(m_WordBuffer, "true", 4) == 0) 421 if (memcmp(m_WordBuffer, "true", 4) == 0)
422 return new CPDF_Boolean(TRUE); 422 return new CPDF_Boolean(true);
423 423
424 if (memcmp(m_WordBuffer, "null", 4) == 0) 424 if (memcmp(m_WordBuffer, "null", 4) == 0)
425 return new CPDF_Null; 425 return new CPDF_Null;
426 } 426 }
427 427
428 return nullptr; 428 return nullptr;
429 } 429 }
430 430
431 void CPDF_StreamParser::GetNextWord(bool& bIsNumber) { 431 void CPDF_StreamParser::GetNextWord(bool& bIsNumber) {
432 m_WordSize = 0; 432 m_WordSize = 0;
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
672 m_CurrentOffset = 0; 672 m_CurrentOffset = 0;
673 673
674 CPDF_Object* pContent = pPage->m_pFormDict->GetDirectObjectFor("Contents"); 674 CPDF_Object* pContent = pPage->m_pFormDict->GetDirectObjectFor("Contents");
675 if (!pContent) { 675 if (!pContent) {
676 m_Status = Done; 676 m_Status = Done;
677 return; 677 return;
678 } 678 }
679 if (CPDF_Stream* pStream = pContent->AsStream()) { 679 if (CPDF_Stream* pStream = pContent->AsStream()) {
680 m_nStreams = 0; 680 m_nStreams = 0;
681 m_pSingleStream.reset(new CPDF_StreamAcc); 681 m_pSingleStream.reset(new CPDF_StreamAcc);
682 m_pSingleStream->LoadAllData(pStream, FALSE); 682 m_pSingleStream->LoadAllData(pStream, false);
683 } else if (CPDF_Array* pArray = pContent->AsArray()) { 683 } else if (CPDF_Array* pArray = pContent->AsArray()) {
684 m_nStreams = pArray->GetCount(); 684 m_nStreams = pArray->GetCount();
685 if (m_nStreams) 685 if (m_nStreams)
686 m_StreamArray.resize(m_nStreams); 686 m_StreamArray.resize(m_nStreams);
687 else 687 else
688 m_Status = Done; 688 m_Status = Done;
689 } else { 689 } else {
690 m_Status = Done; 690 m_Status = Done;
691 } 691 }
692 } 692 }
(...skipping 28 matching lines...) Expand all
721 } 721 }
722 } 722 }
723 CPDF_Dictionary* pResources = pForm->m_pFormDict->GetDictFor("Resources"); 723 CPDF_Dictionary* pResources = pForm->m_pFormDict->GetDictFor("Resources");
724 m_pParser.reset(new CPDF_StreamContentParser( 724 m_pParser.reset(new CPDF_StreamContentParser(
725 pForm->m_pDocument, pForm->m_pPageResources, pForm->m_pResources, 725 pForm->m_pDocument, pForm->m_pPageResources, pForm->m_pResources,
726 pParentMatrix, pForm, pResources, &form_bbox, pGraphicStates, level)); 726 pParentMatrix, pForm, pResources, &form_bbox, pGraphicStates, level));
727 m_pParser->GetCurStates()->m_CTM = form_matrix; 727 m_pParser->GetCurStates()->m_CTM = form_matrix;
728 m_pParser->GetCurStates()->m_ParentMatrix = form_matrix; 728 m_pParser->GetCurStates()->m_ParentMatrix = form_matrix;
729 if (ClipPath) { 729 if (ClipPath) {
730 m_pParser->GetCurStates()->m_ClipPath.AppendPath(ClipPath, FXFILL_WINDING, 730 m_pParser->GetCurStates()->m_ClipPath.AppendPath(ClipPath, FXFILL_WINDING,
731 TRUE); 731 true);
732 } 732 }
733 if (pForm->m_Transparency & PDFTRANS_GROUP) { 733 if (pForm->m_Transparency & PDFTRANS_GROUP) {
734 CPDF_GeneralState* pState = &m_pParser->GetCurStates()->m_GeneralState; 734 CPDF_GeneralState* pState = &m_pParser->GetCurStates()->m_GeneralState;
735 pState->SetBlendType(FXDIB_BLEND_NORMAL); 735 pState->SetBlendType(FXDIB_BLEND_NORMAL);
736 pState->SetStrokeAlpha(1.0f); 736 pState->SetStrokeAlpha(1.0f);
737 pState->SetFillAlpha(1.0f); 737 pState->SetFillAlpha(1.0f);
738 pState->SetSoftMask(nullptr); 738 pState->SetSoftMask(nullptr);
739 } 739 }
740 m_nStreams = 0; 740 m_nStreams = 0;
741 m_pSingleStream.reset(new CPDF_StreamAcc); 741 m_pSingleStream.reset(new CPDF_StreamAcc);
742 m_pSingleStream->LoadAllData(pForm->m_pFormStream, FALSE); 742 m_pSingleStream->LoadAllData(pForm->m_pFormStream, false);
743 m_pData = (uint8_t*)m_pSingleStream->GetData(); 743 m_pData = (uint8_t*)m_pSingleStream->GetData();
744 m_Size = m_pSingleStream->GetSize(); 744 m_Size = m_pSingleStream->GetSize();
745 m_Status = ToBeContinued; 745 m_Status = ToBeContinued;
746 m_InternalStage = STAGE_PARSE; 746 m_InternalStage = STAGE_PARSE;
747 m_CurrentOffset = 0; 747 m_CurrentOffset = 0;
748 } 748 }
749 749
750 void CPDF_ContentParser::Continue(IFX_Pause* pPause) { 750 void CPDF_ContentParser::Continue(IFX_Pause* pPause) {
751 int steps = 0; 751 int steps = 0;
752 while (m_Status == ToBeContinued) { 752 while (m_Status == ToBeContinued) {
(...skipping 23 matching lines...) Expand all
776 m_Size = m_pSingleStream->GetSize(); 776 m_Size = m_pSingleStream->GetSize();
777 } 777 }
778 m_InternalStage = STAGE_PARSE; 778 m_InternalStage = STAGE_PARSE;
779 m_CurrentOffset = 0; 779 m_CurrentOffset = 0;
780 } else { 780 } else {
781 CPDF_Array* pContent = 781 CPDF_Array* pContent =
782 m_pObjectHolder->m_pFormDict->GetArrayFor("Contents"); 782 m_pObjectHolder->m_pFormDict->GetArrayFor("Contents");
783 m_StreamArray[m_CurrentOffset].reset(new CPDF_StreamAcc); 783 m_StreamArray[m_CurrentOffset].reset(new CPDF_StreamAcc);
784 CPDF_Stream* pStreamObj = ToStream( 784 CPDF_Stream* pStreamObj = ToStream(
785 pContent ? pContent->GetDirectObjectAt(m_CurrentOffset) : nullptr); 785 pContent ? pContent->GetDirectObjectAt(m_CurrentOffset) : nullptr);
786 m_StreamArray[m_CurrentOffset]->LoadAllData(pStreamObj, FALSE); 786 m_StreamArray[m_CurrentOffset]->LoadAllData(pStreamObj, false);
787 m_CurrentOffset++; 787 m_CurrentOffset++;
788 } 788 }
789 } 789 }
790 if (m_InternalStage == STAGE_PARSE) { 790 if (m_InternalStage == STAGE_PARSE) {
791 if (!m_pParser) { 791 if (!m_pParser) {
792 m_pParser.reset(new CPDF_StreamContentParser( 792 m_pParser.reset(new CPDF_StreamContentParser(
793 m_pObjectHolder->m_pDocument, m_pObjectHolder->m_pPageResources, 793 m_pObjectHolder->m_pDocument, m_pObjectHolder->m_pPageResources,
794 nullptr, nullptr, m_pObjectHolder, m_pObjectHolder->m_pResources, 794 nullptr, nullptr, m_pObjectHolder, m_pObjectHolder->m_pResources,
795 &m_pObjectHolder->m_BBox, nullptr, 0)); 795 &m_pObjectHolder->m_BBox, nullptr, 0));
796 m_pParser->GetCurStates()->m_ColorState.SetDefault(); 796 m_pParser->GetCurStates()->m_ColorState.SetDefault();
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
837 } 837 }
838 m_Status = Done; 838 m_Status = Done;
839 return; 839 return;
840 } 840 }
841 steps++; 841 steps++;
842 if (pPause && pPause->NeedToPauseNow()) { 842 if (pPause && pPause->NeedToPauseNow()) {
843 break; 843 break;
844 } 844 }
845 } 845 }
846 } 846 }
OLDNEW
« no previous file with comments | « core/fpdfapi/page/fpdf_page_func.cpp ('k') | core/fpdfapi/page/pageint.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698