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

Side by Side Diff: core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp

Issue 880663003: Kill scattered extern _PDF_CharType declarations. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Fix typo in 'N' in fpdf_parser.h comment. Created 5 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 "../../../include/fpdfapi/fpdf_page.h" 7 #include "../../../include/fpdfapi/fpdf_page.h"
8 #include "../../../include/fpdfapi/fpdf_module.h" 8 #include "../../../include/fpdfapi/fpdf_module.h"
9 #include "../../../include/fxcodec/fx_codec.h" 9 #include "../../../include/fxcodec/fx_codec.h"
10 #include "pageint.h" 10 #include "pageint.h"
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 ICodec_ScanlineDecoder* pDecoder = CPDF_ModuleMgr::Get()->GetJpegModule( )->CreateDecoder( 300 ICodec_ScanlineDecoder* pDecoder = CPDF_ModuleMgr::Get()->GetJpegModule( )->CreateDecoder(
301 src_buf, limit, width, height, 0, pParam ? pParam->GetInteger(FX_BSTRC("ColorTransform"), 1) : 1); 301 src_buf, limit, width, height, 0, pParam ? pParam->GetInteger(FX_BSTRC("ColorTransform"), 1) : 1);
302 return _DecodeAllScanlines(pDecoder, dest_buf, dest_size); 302 return _DecodeAllScanlines(pDecoder, dest_buf, dest_size);
303 } else if (decoder == FX_BSTRC("RunLengthDecode") || decoder == FX_BSTRC("RL ")) { 303 } else if (decoder == FX_BSTRC("RunLengthDecode") || decoder == FX_BSTRC("RL ")) {
304 return RunLengthDecode(src_buf, limit, dest_buf, dest_size); 304 return RunLengthDecode(src_buf, limit, dest_buf, dest_size);
305 } 305 }
306 dest_size = 0; 306 dest_size = 0;
307 dest_buf = 0; 307 dest_buf = 0;
308 return (FX_DWORD) - 1; 308 return (FX_DWORD) - 1;
309 } 309 }
310 extern const FX_LPCSTR _PDF_CharType;
311 CPDF_Stream* CPDF_StreamParser::ReadInlineStream(CPDF_Document* pDoc, CPDF_Dicti onary* pDict, CPDF_Object* pCSObj, FX_BOOL bDecode) 310 CPDF_Stream* CPDF_StreamParser::ReadInlineStream(CPDF_Document* pDoc, CPDF_Dicti onary* pDict, CPDF_Object* pCSObj, FX_BOOL bDecode)
312 { 311 {
313 if (m_Pos == m_Size) { 312 if (m_Pos == m_Size) {
314 return NULL; 313 return NULL;
315 } 314 }
316 if (_PDF_CharType[m_pBuf[m_Pos]] == 'W') { 315 if (PDF_CharType[m_pBuf[m_Pos]] == 'W') {
317 m_Pos ++; 316 m_Pos ++;
318 } 317 }
319 CFX_ByteString Decoder; 318 CFX_ByteString Decoder;
320 CPDF_Dictionary* pParam = NULL; 319 CPDF_Dictionary* pParam = NULL;
321 CPDF_Object* pFilter = pDict->GetElementValue(FX_BSTRC("Filter")); 320 CPDF_Object* pFilter = pDict->GetElementValue(FX_BSTRC("Filter"));
322 if (pFilter == NULL) { 321 if (pFilter == NULL) {
323 } else if (pFilter->GetType() == PDFOBJ_ARRAY) { 322 } else if (pFilter->GetType() == PDFOBJ_ARRAY) {
324 Decoder = ((CPDF_Array*)pFilter)->GetString(0); 323 Decoder = ((CPDF_Array*)pFilter)->GetString(0);
325 CPDF_Array* pParams = pDict->GetArray(FX_BSTRC("DecodeParms")); 324 CPDF_Array* pParams = pDict->GetArray(FX_BSTRC("DecodeParms"));
326 if (pParams) { 325 if (pParams) {
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 if (m_pLastObj) { 439 if (m_pLastObj) {
441 m_pLastObj->Release(); 440 m_pLastObj->Release();
442 m_pLastObj = NULL; 441 m_pLastObj = NULL;
443 } 442 }
444 m_WordSize = 0; 443 m_WordSize = 0;
445 FX_BOOL bIsNumber = TRUE; 444 FX_BOOL bIsNumber = TRUE;
446 if (m_Pos >= m_Size) { 445 if (m_Pos >= m_Size) {
447 return EndOfData; 446 return EndOfData;
448 } 447 }
449 int ch = m_pBuf[m_Pos++]; 448 int ch = m_pBuf[m_Pos++];
450 int type = _PDF_CharType[ch]; 449 int type = PDF_CharType[ch];
451 while (1) { 450 while (1) {
452 while (type == 'W') { 451 while (type == 'W') {
453 if (m_Size <= m_Pos) { 452 if (m_Size <= m_Pos) {
454 return EndOfData; 453 return EndOfData;
455 } 454 }
456 ch = m_pBuf[m_Pos++]; 455 ch = m_pBuf[m_Pos++];
457 type = _PDF_CharType[ch]; 456 type = PDF_CharType[ch];
458 } 457 }
459 if (ch != '%') { 458 if (ch != '%') {
460 break; 459 break;
461 } 460 }
462 while (1) { 461 while (1) {
463 if (m_Size <= m_Pos) { 462 if (m_Size <= m_Pos) {
464 return EndOfData; 463 return EndOfData;
465 } 464 }
466 ch = m_pBuf[m_Pos++]; 465 ch = m_pBuf[m_Pos++];
467 if (ch == '\r' || ch == '\n') { 466 if (ch == '\r' || ch == '\n') {
468 break; 467 break;
469 } 468 }
470 } 469 }
471 type = _PDF_CharType[ch]; 470 type = PDF_CharType[ch];
472 } 471 }
473 if (type == 'D' && ch != '/') { 472 if (type == 'D' && ch != '/') {
474 m_Pos --; 473 m_Pos --;
475 m_pLastObj = ReadNextObject(); 474 m_pLastObj = ReadNextObject();
476 return Others; 475 return Others;
477 } 476 }
478 while (1) { 477 while (1) {
479 if (m_WordSize < MAX_WORD_BUFFER) { 478 if (m_WordSize < MAX_WORD_BUFFER) {
480 m_WordBuffer[m_WordSize++] = ch; 479 m_WordBuffer[m_WordSize++] = ch;
481 } 480 }
482 if (type != 'N') { 481 if (type != 'N') {
483 bIsNumber = FALSE; 482 bIsNumber = FALSE;
484 } 483 }
485 if (m_Size <= m_Pos) { 484 if (m_Size <= m_Pos) {
486 break; 485 break;
487 } 486 }
488 ch = m_pBuf[m_Pos++]; 487 ch = m_pBuf[m_Pos++];
489 type = _PDF_CharType[ch]; 488 type = PDF_CharType[ch];
490 if (type == 'D' || type == 'W') { 489 if (type == 'D' || type == 'W') {
491 m_Pos --; 490 m_Pos --;
492 break; 491 break;
493 } 492 }
494 } 493 }
495 m_WordBuffer[m_WordSize] = 0; 494 m_WordBuffer[m_WordSize] = 0;
496 if (bIsNumber) { 495 if (bIsNumber) {
497 return Number; 496 return Number;
498 } 497 }
499 if (m_WordBuffer[0] == '/') { 498 if (m_WordBuffer[0] == '/') {
(...skipping 16 matching lines...) Expand all
516 } 515 }
517 return Keyword; 516 return Keyword;
518 } 517 }
519 void CPDF_StreamParser::SkipPathObject() 518 void CPDF_StreamParser::SkipPathObject()
520 { 519 {
521 FX_DWORD command_startpos = m_Pos; 520 FX_DWORD command_startpos = m_Pos;
522 if (m_Pos >= m_Size) { 521 if (m_Pos >= m_Size) {
523 return; 522 return;
524 } 523 }
525 int ch = m_pBuf[m_Pos++]; 524 int ch = m_pBuf[m_Pos++];
526 int type = _PDF_CharType[ch]; 525 int type = PDF_CharType[ch];
527 while (1) { 526 while (1) {
528 while (type == 'W') { 527 while (type == 'W') {
529 if (m_Pos >= m_Size) { 528 if (m_Pos >= m_Size) {
530 return; 529 return;
531 } 530 }
532 ch = m_pBuf[m_Pos++]; 531 ch = m_pBuf[m_Pos++];
533 type = _PDF_CharType[ch]; 532 type = PDF_CharType[ch];
534 } 533 }
535 if (type != 'N') { 534 if (type != 'N') {
536 m_Pos = command_startpos; 535 m_Pos = command_startpos;
537 return; 536 return;
538 } 537 }
539 while (1) { 538 while (1) {
540 while (type != 'W') { 539 while (type != 'W') {
541 if (m_Pos >= m_Size) { 540 if (m_Pos >= m_Size) {
542 return; 541 return;
543 } 542 }
544 ch = m_pBuf[m_Pos++]; 543 ch = m_pBuf[m_Pos++];
545 type = _PDF_CharType[ch]; 544 type = PDF_CharType[ch];
546 } 545 }
547 while (type == 'W') { 546 while (type == 'W') {
548 if (m_Pos >= m_Size) { 547 if (m_Pos >= m_Size) {
549 return; 548 return;
550 } 549 }
551 ch = m_pBuf[m_Pos++]; 550 ch = m_pBuf[m_Pos++];
552 type = _PDF_CharType[ch]; 551 type = PDF_CharType[ch];
553 } 552 }
554 if (type == 'N') { 553 if (type == 'N') {
555 continue; 554 continue;
556 } 555 }
557 FX_DWORD op_startpos = m_Pos - 1; 556 FX_DWORD op_startpos = m_Pos - 1;
558 while (type != 'W' && type != 'D') { 557 while (type != 'W' && type != 'D') {
559 if (m_Pos >= m_Size) { 558 if (m_Pos >= m_Size) {
560 return; 559 return;
561 } 560 }
562 ch = m_pBuf[m_Pos++]; 561 ch = m_pBuf[m_Pos++];
563 type = _PDF_CharType[ch]; 562 type = PDF_CharType[ch];
564 } 563 }
565 if (m_Pos - op_startpos == 2) { 564 if (m_Pos - op_startpos == 2) {
566 int op = m_pBuf[op_startpos]; 565 int op = m_pBuf[op_startpos];
567 if (op == 'm' || op == 'l' || op == 'c' || op == 'v' || op == 'y ') { 566 if (op == 'm' || op == 'l' || op == 'c' || op == 'v' || op == 'y ') {
568 command_startpos = m_Pos; 567 command_startpos = m_Pos;
569 break; 568 break;
570 } 569 }
571 } else if (m_Pos - op_startpos == 3) { 570 } else if (m_Pos - op_startpos == 3) {
572 if (m_pBuf[op_startpos] == 'r' && m_pBuf[op_startpos + 1] == 'e' ) { 571 if (m_pBuf[op_startpos] == 'r' && m_pBuf[op_startpos + 1] == 'e' ) {
573 command_startpos = m_Pos; 572 command_startpos = m_Pos;
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
665 return NULL; 664 return NULL;
666 } 665 }
667 void CPDF_StreamParser::GetNextWord(FX_BOOL& bIsNumber) 666 void CPDF_StreamParser::GetNextWord(FX_BOOL& bIsNumber)
668 { 667 {
669 m_WordSize = 0; 668 m_WordSize = 0;
670 bIsNumber = TRUE; 669 bIsNumber = TRUE;
671 if (m_Size <= m_Pos) { 670 if (m_Size <= m_Pos) {
672 return; 671 return;
673 } 672 }
674 int ch = m_pBuf[m_Pos++]; 673 int ch = m_pBuf[m_Pos++];
675 int type = _PDF_CharType[ch]; 674 int type = PDF_CharType[ch];
676 while (1) { 675 while (1) {
677 while (type == 'W') { 676 while (type == 'W') {
678 if (m_Size <= m_Pos) { 677 if (m_Size <= m_Pos) {
679 return; 678 return;
680 } 679 }
681 ch = m_pBuf[m_Pos++]; 680 ch = m_pBuf[m_Pos++];
682 type = _PDF_CharType[ch]; 681 type = PDF_CharType[ch];
683 } 682 }
684 if (ch != '%') { 683 if (ch != '%') {
685 break; 684 break;
686 } 685 }
687 while (1) { 686 while (1) {
688 if (m_Size <= m_Pos) { 687 if (m_Size <= m_Pos) {
689 return; 688 return;
690 } 689 }
691 ch = m_pBuf[m_Pos++]; 690 ch = m_pBuf[m_Pos++];
692 if (ch == '\r' || ch == '\n') { 691 if (ch == '\r' || ch == '\n') {
693 break; 692 break;
694 } 693 }
695 } 694 }
696 type = _PDF_CharType[ch]; 695 type = PDF_CharType[ch];
697 } 696 }
698 if (type == 'D') { 697 if (type == 'D') {
699 bIsNumber = FALSE; 698 bIsNumber = FALSE;
700 m_WordBuffer[m_WordSize++] = ch; 699 m_WordBuffer[m_WordSize++] = ch;
701 if (ch == '/') { 700 if (ch == '/') {
702 while (1) { 701 while (1) {
703 if (m_Size <= m_Pos) { 702 if (m_Size <= m_Pos) {
704 return; 703 return;
705 } 704 }
706 ch = m_pBuf[m_Pos++]; 705 ch = m_pBuf[m_Pos++];
707 type = _PDF_CharType[ch]; 706 type = PDF_CharType[ch];
708 if (type != 'R' && type != 'N') { 707 if (type != 'R' && type != 'N') {
709 m_Pos --; 708 m_Pos --;
710 return; 709 return;
711 } 710 }
712 if (m_WordSize < MAX_WORD_BUFFER) { 711 if (m_WordSize < MAX_WORD_BUFFER) {
713 m_WordBuffer[m_WordSize++] = ch; 712 m_WordBuffer[m_WordSize++] = ch;
714 } 713 }
715 } 714 }
716 } else if (ch == '<') { 715 } else if (ch == '<') {
717 if (m_Size <= m_Pos) { 716 if (m_Size <= m_Pos) {
(...skipping 22 matching lines...) Expand all
740 if (m_WordSize < MAX_WORD_BUFFER) { 739 if (m_WordSize < MAX_WORD_BUFFER) {
741 m_WordBuffer[m_WordSize++] = ch; 740 m_WordBuffer[m_WordSize++] = ch;
742 } 741 }
743 if (type != 'N') { 742 if (type != 'N') {
744 bIsNumber = FALSE; 743 bIsNumber = FALSE;
745 } 744 }
746 if (m_Size <= m_Pos) { 745 if (m_Size <= m_Pos) {
747 return; 746 return;
748 } 747 }
749 ch = m_pBuf[m_Pos++]; 748 ch = m_pBuf[m_Pos++];
750 type = _PDF_CharType[ch]; 749 type = PDF_CharType[ch];
751 if (type == 'D' || type == 'W') { 750 if (type == 'D' || type == 'W') {
752 m_Pos --; 751 m_Pos --;
753 break; 752 break;
754 } 753 }
755 } 754 }
756 } 755 }
757 CFX_ByteString CPDF_StreamParser::ReadString() 756 CFX_ByteString CPDF_StreamParser::ReadString()
758 { 757 {
759 if (m_Size <= m_Pos) { 758 if (m_Size <= m_Pos) {
760 return CFX_ByteString(); 759 return CFX_ByteString();
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
1146 return 100; 1145 return 100;
1147 } 1146 }
1148 if (m_InternalStage == PAGEPARSE_STAGE_GETCONTENT) { 1147 if (m_InternalStage == PAGEPARSE_STAGE_GETCONTENT) {
1149 return 10; 1148 return 10;
1150 } 1149 }
1151 if (m_InternalStage == PAGEPARSE_STAGE_CHECKCLIP) { 1150 if (m_InternalStage == PAGEPARSE_STAGE_CHECKCLIP) {
1152 return 90; 1151 return 90;
1153 } 1152 }
1154 return 10 + 80 * m_CurrentOffset / m_Size; 1153 return 10 + 80 * m_CurrentOffset / m_Size;
1155 } 1154 }
OLDNEW
« no previous file with comments | « core/include/fpdfapi/fpdf_parser.h ('k') | core/src/fpdfapi/fpdf_parser/fpdf_parser_filters.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698