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

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

Issue 884473003: Merge to XFA: Kill scattered extern _PDF_CharType declarations. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Created 5 years, 11 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_parser.h" 7 #include "../../../include/fpdfapi/fpdf_parser.h"
8 #include "../../../include/fpdfapi/fpdf_module.h" 8 #include "../../../include/fpdfapi/fpdf_module.h"
9 #include "../../../include/fpdfapi/fpdf_page.h" 9 #include "../../../include/fpdfapi/fpdf_page.h"
10 #include "../../../../third_party/numerics/safe_math.h" 10 #include "../../../../third_party/numerics/safe_math.h"
11 #include "../fpdf_page/pageint.h" 11 #include "../fpdf_page/pageint.h"
12 #include <utility> 12 #include <utility>
13 #include <vector> 13 #include <vector>
14 14
15 extern const FX_LPCSTR _PDF_CharType;
16 FX_BOOL IsSignatureDict(const CPDF_Dictionary* pDict) 15 FX_BOOL IsSignatureDict(const CPDF_Dictionary* pDict)
17 { 16 {
18 CPDF_Object* pType = pDict->GetElementValue(FX_BSTRC("Type")); 17 CPDF_Object* pType = pDict->GetElementValue(FX_BSTRC("Type"));
19 if (!pType) { 18 if (!pType) {
20 pType = pDict->GetElementValue(FX_BSTRC("FT")); 19 pType = pDict->GetElementValue(FX_BSTRC("FT"));
21 if (!pType) { 20 if (!pType) {
22 return FALSE; 21 return FALSE;
23 } 22 }
24 } 23 }
25 if (pType->GetString() == FX_BSTRC("Sig")) { 24 if (pType->GetString() == FX_BSTRC("Sig")) {
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after
645 if (size > 4096) { 644 if (size > 4096) {
646 size = 4096; 645 size = 4096;
647 } 646 }
648 if (!m_Syntax.m_pFileAccess->ReadBlock(buffer, pos, size)) { 647 if (!m_Syntax.m_pFileAccess->ReadBlock(buffer, pos, size)) {
649 break; 648 break;
650 } 649 }
651 for (FX_DWORD i = 0; i < size; i ++) { 650 for (FX_DWORD i = 0; i < size; i ++) {
652 FX_BYTE byte = buffer[i]; 651 FX_BYTE byte = buffer[i];
653 switch (status) { 652 switch (status) {
654 case 0: 653 case 0:
655 if (_PDF_CharType[byte] == 'W') { 654 if (PDF_CharType[byte] == 'W') {
656 status = 1; 655 status = 1;
657 } 656 }
658 if (byte <= '9' && byte >= '0') { 657 if (byte <= '9' && byte >= '0') {
659 --i; 658 --i;
660 status = 1; 659 status = 1;
661 } 660 }
662 if (byte == '%') { 661 if (byte == '%') {
663 inside_index = 0; 662 inside_index = 0;
664 status = 9; 663 status = 9;
665 } 664 }
666 if (byte == '(') { 665 if (byte == '(') {
667 status = 10; 666 status = 10;
668 depth = 1; 667 depth = 1;
669 } 668 }
670 if (byte == '<') { 669 if (byte == '<') {
671 inside_index = 1; 670 inside_index = 1;
672 status = 11; 671 status = 11;
673 } 672 }
674 if (byte == '\\') { 673 if (byte == '\\') {
675 status = 13; 674 status = 13;
676 } 675 }
677 if (byte == 't') { 676 if (byte == 't') {
678 status = 7; 677 status = 7;
679 inside_index = 1; 678 inside_index = 1;
680 } 679 }
681 break; 680 break;
682 case 1: 681 case 1:
683 if (_PDF_CharType[byte] == 'W') { 682 if (PDF_CharType[byte] == 'W') {
684 break; 683 break;
685 } else if (byte <= '9' && byte >= '0') { 684 } else if (byte <= '9' && byte >= '0') {
686 start_pos = pos + i; 685 start_pos = pos + i;
687 status = 2; 686 status = 2;
688 objnum = byte - '0'; 687 objnum = byte - '0';
689 } else if (byte == 't') { 688 } else if (byte == 't') {
690 status = 7; 689 status = 7;
691 inside_index = 1; 690 inside_index = 1;
692 } else if (byte == 'x') { 691 } else if (byte == 'x') {
693 status = 8; 692 status = 8;
694 inside_index = 1; 693 inside_index = 1;
695 } else { 694 } else {
696 --i; 695 --i;
697 status = 0; 696 status = 0;
698 } 697 }
699 break; 698 break;
700 case 2: 699 case 2:
701 if (byte <= '9' && byte >= '0') { 700 if (byte <= '9' && byte >= '0') {
702 objnum = objnum * 10 + byte - '0'; 701 objnum = objnum * 10 + byte - '0';
703 break; 702 break;
704 } else if (_PDF_CharType[byte] == 'W') { 703 } else if (PDF_CharType[byte] == 'W') {
705 status = 3; 704 status = 3;
706 } else { 705 } else {
707 --i; 706 --i;
708 status = 14; 707 status = 14;
709 inside_index = 0; 708 inside_index = 0;
710 } 709 }
711 break; 710 break;
712 case 3: 711 case 3:
713 if (byte <= '9' && byte >= '0') { 712 if (byte <= '9' && byte >= '0') {
714 start_pos1 = pos + i; 713 start_pos1 = pos + i;
715 status = 4; 714 status = 4;
716 gennum = byte - '0'; 715 gennum = byte - '0';
717 } else if (_PDF_CharType[byte] == 'W') { 716 } else if (PDF_CharType[byte] == 'W') {
718 break; 717 break;
719 } else if (byte == 't') { 718 } else if (byte == 't') {
720 status = 7; 719 status = 7;
721 inside_index = 1; 720 inside_index = 1;
722 } else { 721 } else {
723 --i; 722 --i;
724 status = 0; 723 status = 0;
725 } 724 }
726 break; 725 break;
727 case 4: 726 case 4:
728 if (byte <= '9' && byte >= '0') { 727 if (byte <= '9' && byte >= '0') {
729 gennum = gennum * 10 + byte - '0'; 728 gennum = gennum * 10 + byte - '0';
730 break; 729 break;
731 } else if (_PDF_CharType[byte] == 'W') { 730 } else if (PDF_CharType[byte] == 'W') {
732 status = 5; 731 status = 5;
733 } else { 732 } else {
734 --i; 733 --i;
735 status = 0; 734 status = 0;
736 } 735 }
737 break; 736 break;
738 case 5: 737 case 5:
739 if (byte == 'o') { 738 if (byte == 'o') {
740 status = 6; 739 status = 6;
741 inside_index = 1; 740 inside_index = 1;
742 } else if (_PDF_CharType[byte] == 'W') { 741 } else if (PDF_CharType[byte] == 'W') {
743 break; 742 break;
744 } else if (byte <= '9' && byte >= '0') { 743 } else if (byte <= '9' && byte >= '0') {
745 objnum = gennum; 744 objnum = gennum;
746 gennum = byte - '0'; 745 gennum = byte - '0';
747 start_pos = start_pos1; 746 start_pos = start_pos1;
748 start_pos1 = pos + i; 747 start_pos1 = pos + i;
749 status = 4; 748 status = 4;
750 } else if (byte == 't') { 749 } else if (byte == 't') {
751 status = 7; 750 status = 7;
752 inside_index = 1; 751 inside_index = 1;
(...skipping 14 matching lines...) Expand all
767 break; 766 break;
768 case 2: 767 case 2:
769 if (byte != 'j') { 768 if (byte != 'j') {
770 --i; 769 --i;
771 status = 0; 770 status = 0;
772 } else { 771 } else {
773 inside_index ++; 772 inside_index ++;
774 } 773 }
775 break; 774 break;
776 case 3: 775 case 3:
777 if (_PDF_CharType[byte] == 'W' || _PDF_CharType[byte ] == 'D') { 776 if (PDF_CharType[byte] == 'W' || PDF_CharType[byte] == 'D') {
778 if (objnum > 0x1000000) { 777 if (objnum > 0x1000000) {
779 status = 0; 778 status = 0;
780 break; 779 break;
781 } 780 }
782 FX_FILESIZE obj_pos = start_pos - m_Syntax.m_Hea derOffset; 781 FX_FILESIZE obj_pos = start_pos - m_Syntax.m_Hea derOffset;
783 last_obj = start_pos; 782 last_obj = start_pos;
784 FX_LPVOID pResult = FXSYS_bsearch(&obj_pos, m_So rtedOffset.GetData(), m_SortedOffset.GetSize(), sizeof(FX_FILESIZE), _CompareFil eSize); 783 FX_LPVOID pResult = FXSYS_bsearch(&obj_pos, m_So rtedOffset.GetData(), m_SortedOffset.GetSize(), sizeof(FX_FILESIZE), _CompareFil eSize);
785 if (pResult == NULL) { 784 if (pResult == NULL) {
786 m_SortedOffset.Add(obj_pos); 785 m_SortedOffset.Add(obj_pos);
787 } 786 }
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
841 pObject->Release(); 840 pObject->Release();
842 } 841 }
843 } 842 }
844 --i; 843 --i;
845 status = 0; 844 status = 0;
846 break; 845 break;
847 } 846 }
848 break; 847 break;
849 case 7: 848 case 7:
850 if (inside_index == 7) { 849 if (inside_index == 7) {
851 if (_PDF_CharType[byte] == 'W' || _PDF_CharType[byte] == 'D') { 850 if (PDF_CharType[byte] == 'W' || PDF_CharType[byte] == ' D') {
852 last_trailer = pos + i - 7; 851 last_trailer = pos + i - 7;
853 m_Syntax.RestorePos(pos + i - m_Syntax.m_HeaderOffse t); 852 m_Syntax.RestorePos(pos + i - m_Syntax.m_HeaderOffse t);
854 CPDF_Object* pObj = m_Syntax.GetObject(m_pDocument, 0, 0, 0); 853 CPDF_Object* pObj = m_Syntax.GetObject(m_pDocument, 0, 0, 0);
855 if (pObj) { 854 if (pObj) {
856 if (pObj->GetType() != PDFOBJ_DICTIONARY && pObj ->GetType() != PDFOBJ_STREAM) { 855 if (pObj->GetType() != PDFOBJ_DICTIONARY && pObj ->GetType() != PDFOBJ_STREAM) {
857 pObj->Release(); 856 pObj->Release();
858 } else { 857 } else {
859 CPDF_Dictionary* pTrailer = NULL; 858 CPDF_Dictionary* pTrailer = NULL;
860 if (pObj->GetType() == PDFOBJ_STREAM) { 859 if (pObj->GetType() == PDFOBJ_STREAM) {
861 pTrailer = ((CPDF_Stream*)pObj)->GetDict (); 860 pTrailer = ((CPDF_Stream*)pObj)->GetDict ();
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
946 } else if (byte == '>') { 945 } else if (byte == '>') {
947 status = 0; 946 status = 0;
948 } 947 }
949 inside_index = 0; 948 inside_index = 0;
950 break; 949 break;
951 case 12: 950 case 12:
952 --i; 951 --i;
953 status = 0; 952 status = 0;
954 break; 953 break;
955 case 13: 954 case 13:
956 if (_PDF_CharType[byte] == 'D' || _PDF_CharType[byte] == 'W' ) { 955 if (PDF_CharType[byte] == 'D' || PDF_CharType[byte] == 'W') {
957 --i; 956 --i;
958 status = 0; 957 status = 0;
959 } 958 }
960 break; 959 break;
961 case 14: 960 case 14:
962 if (_PDF_CharType[byte] == 'W') { 961 if (PDF_CharType[byte] == 'W') {
963 status = 0; 962 status = 0;
964 } else if (byte == '%' || byte == '(' || byte == '<' || byte == '\\') { 963 } else if (byte == '%' || byte == '(' || byte == '<' || byte == '\\') {
965 status = 0; 964 status = 0;
966 --i; 965 --i;
967 } else if (inside_index == 6) { 966 } else if (inside_index == 6) {
968 status = 0; 967 status = 0;
969 --i; 968 --i;
970 } else if (byte == "endobj"[inside_index]) { 969 } else if (byte == "endobj"[inside_index]) {
971 inside_index++; 970 inside_index++;
972 } 971 }
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after
1646 FX_DWORD dwSaveMetadataObjnum = m_Syntax.m_MetadataObjnum; 1645 FX_DWORD dwSaveMetadataObjnum = m_Syntax.m_MetadataObjnum;
1647 m_Syntax.m_MetadataObjnum = 0; 1646 m_Syntax.m_MetadataObjnum = 0;
1648 if (m_pTrailer) { 1647 if (m_pTrailer) {
1649 m_pTrailer->Release(); 1648 m_pTrailer->Release();
1650 m_pTrailer = NULL; 1649 m_pTrailer = NULL;
1651 } 1650 }
1652 m_Syntax.RestorePos(m_LastXRefOffset - m_Syntax.m_HeaderOffset); 1651 m_Syntax.RestorePos(m_LastXRefOffset - m_Syntax.m_HeaderOffset);
1653 FX_BYTE ch = 0; 1652 FX_BYTE ch = 0;
1654 FX_DWORD dwCount = 0; 1653 FX_DWORD dwCount = 0;
1655 m_Syntax.GetNextChar(ch); 1654 m_Syntax.GetNextChar(ch);
1656 FX_INT32 type = _PDF_CharType[ch]; 1655 FX_INT32 type = PDF_CharType[ch];
1657 while (type == 'W') { 1656 while (type == 'W') {
1658 ++dwCount; 1657 ++dwCount;
1659 if (m_Syntax.m_FileLen >= (FX_FILESIZE)(m_Syntax.SavePos() + m_Syntax.m_ HeaderOffset)) { 1658 if (m_Syntax.m_FileLen >= (FX_FILESIZE)(m_Syntax.SavePos() + m_Syntax.m_ HeaderOffset)) {
1660 break; 1659 break;
1661 } 1660 }
1662 m_Syntax.GetNextChar(ch); 1661 m_Syntax.GetNextChar(ch);
1663 type = _PDF_CharType[ch]; 1662 type = PDF_CharType[ch];
1664 } 1663 }
1665 m_LastXRefOffset += dwCount; 1664 m_LastXRefOffset += dwCount;
1666 FX_POSITION pos = m_ObjectStreamMap.GetStartPosition(); 1665 FX_POSITION pos = m_ObjectStreamMap.GetStartPosition();
1667 while (pos) { 1666 while (pos) {
1668 FX_LPVOID objnum; 1667 FX_LPVOID objnum;
1669 CPDF_StreamAcc* pStream; 1668 CPDF_StreamAcc* pStream;
1670 m_ObjectStreamMap.GetNextAssoc(pos, objnum, (void*&)pStream); 1669 m_ObjectStreamMap.GetNextAssoc(pos, objnum, (void*&)pStream);
1671 delete pStream; 1670 delete pStream;
1672 } 1671 }
1673 m_ObjectStreamMap.RemoveAll(); 1672 m_ObjectStreamMap.RemoveAll();
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
1778 } 1777 }
1779 #define MAX_WORD_BUFFER 256 1778 #define MAX_WORD_BUFFER 256
1780 void CPDF_SyntaxParser::GetNextWord() 1779 void CPDF_SyntaxParser::GetNextWord()
1781 { 1780 {
1782 m_WordSize = 0; 1781 m_WordSize = 0;
1783 m_bIsNumber = TRUE; 1782 m_bIsNumber = TRUE;
1784 FX_BYTE ch; 1783 FX_BYTE ch;
1785 if (!GetNextChar(ch)) { 1784 if (!GetNextChar(ch)) {
1786 return; 1785 return;
1787 } 1786 }
1788 FX_BYTE type = _PDF_CharType[ch]; 1787 FX_BYTE type = PDF_CharType[ch];
1789 while (1) { 1788 while (1) {
1790 while (type == 'W') { 1789 while (type == 'W') {
1791 if (!GetNextChar(ch)) { 1790 if (!GetNextChar(ch)) {
1792 return; 1791 return;
1793 } 1792 }
1794 type = _PDF_CharType[ch]; 1793 type = PDF_CharType[ch];
1795 } 1794 }
1796 if (ch != '%') { 1795 if (ch != '%') {
1797 break; 1796 break;
1798 } 1797 }
1799 while (1) { 1798 while (1) {
1800 if (!GetNextChar(ch)) { 1799 if (!GetNextChar(ch)) {
1801 return; 1800 return;
1802 } 1801 }
1803 if (ch == '\r' || ch == '\n') { 1802 if (ch == '\r' || ch == '\n') {
1804 break; 1803 break;
1805 } 1804 }
1806 } 1805 }
1807 type = _PDF_CharType[ch]; 1806 type = PDF_CharType[ch];
1808 } 1807 }
1809 if (type == 'D') { 1808 if (type == 'D') {
1810 m_bIsNumber = FALSE; 1809 m_bIsNumber = FALSE;
1811 m_WordBuffer[m_WordSize++] = ch; 1810 m_WordBuffer[m_WordSize++] = ch;
1812 if (ch == '/') { 1811 if (ch == '/') {
1813 while (1) { 1812 while (1) {
1814 if (!GetNextChar(ch)) { 1813 if (!GetNextChar(ch)) {
1815 return; 1814 return;
1816 } 1815 }
1817 type = _PDF_CharType[ch]; 1816 type = PDF_CharType[ch];
1818 if (type != 'R' && type != 'N') { 1817 if (type != 'R' && type != 'N') {
1819 m_Pos --; 1818 m_Pos --;
1820 return; 1819 return;
1821 } 1820 }
1822 if (m_WordSize < MAX_WORD_BUFFER) { 1821 if (m_WordSize < MAX_WORD_BUFFER) {
1823 m_WordBuffer[m_WordSize++] = ch; 1822 m_WordBuffer[m_WordSize++] = ch;
1824 } 1823 }
1825 } 1824 }
1826 } else if (ch == '<') { 1825 } else if (ch == '<') {
1827 if (!GetNextChar(ch)) { 1826 if (!GetNextChar(ch)) {
(...skipping 19 matching lines...) Expand all
1847 while (1) { 1846 while (1) {
1848 if (m_WordSize < MAX_WORD_BUFFER) { 1847 if (m_WordSize < MAX_WORD_BUFFER) {
1849 m_WordBuffer[m_WordSize++] = ch; 1848 m_WordBuffer[m_WordSize++] = ch;
1850 } 1849 }
1851 if (type != 'N') { 1850 if (type != 'N') {
1852 m_bIsNumber = FALSE; 1851 m_bIsNumber = FALSE;
1853 } 1852 }
1854 if (!GetNextChar(ch)) { 1853 if (!GetNextChar(ch)) {
1855 return; 1854 return;
1856 } 1855 }
1857 type = _PDF_CharType[ch]; 1856 type = PDF_CharType[ch];
1858 if (type == 'D' || type == 'W') { 1857 if (type == 'D' || type == 'W') {
1859 m_Pos --; 1858 m_Pos --;
1860 break; 1859 break;
1861 } 1860 }
1862 } 1861 }
1863 } 1862 }
1864 CFX_ByteString CPDF_SyntaxParser::ReadString() 1863 CFX_ByteString CPDF_SyntaxParser::ReadString()
1865 { 1864 {
1866 FX_BYTE ch; 1865 FX_BYTE ch;
1867 if (!GetNextChar(ch)) { 1866 if (!GetNextChar(ch)) {
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
2015 } 2014 }
2016 } 2015 }
2017 } 2016 }
2018 } 2017 }
2019 void CPDF_SyntaxParser::ToNextWord() 2018 void CPDF_SyntaxParser::ToNextWord()
2020 { 2019 {
2021 FX_BYTE ch; 2020 FX_BYTE ch;
2022 if (!GetNextChar(ch)) { 2021 if (!GetNextChar(ch)) {
2023 return; 2022 return;
2024 } 2023 }
2025 FX_BYTE type = _PDF_CharType[ch]; 2024 FX_BYTE type = PDF_CharType[ch];
2026 while (1) { 2025 while (1) {
2027 while (type == 'W') { 2026 while (type == 'W') {
2028 m_dwWordPos = m_Pos; 2027 m_dwWordPos = m_Pos;
2029 if (!GetNextChar(ch)) { 2028 if (!GetNextChar(ch)) {
2030 return; 2029 return;
2031 } 2030 }
2032 type = _PDF_CharType[ch]; 2031 type = PDF_CharType[ch];
2033 } 2032 }
2034 if (ch != '%') { 2033 if (ch != '%') {
2035 break; 2034 break;
2036 } 2035 }
2037 while (1) { 2036 while (1) {
2038 if (!GetNextChar(ch)) { 2037 if (!GetNextChar(ch)) {
2039 return; 2038 return;
2040 } 2039 }
2041 if (ch == '\r' || ch == '\n') { 2040 if (ch == '\r' || ch == '\n') {
2042 break; 2041 break;
2043 } 2042 }
2044 } 2043 }
2045 type = _PDF_CharType[ch]; 2044 type = PDF_CharType[ch];
2046 } 2045 }
2047 m_Pos --; 2046 m_Pos --;
2048 } 2047 }
2049 CFX_ByteString CPDF_SyntaxParser::GetNextWord(FX_BOOL& bIsNumber) 2048 CFX_ByteString CPDF_SyntaxParser::GetNextWord(FX_BOOL& bIsNumber)
2050 { 2049 {
2051 GetNextWord(); 2050 GetNextWord();
2052 bIsNumber = m_bIsNumber; 2051 bIsNumber = m_bIsNumber;
2053 return CFX_ByteString((FX_LPCSTR)m_WordBuffer, m_WordSize); 2052 return CFX_ByteString((FX_LPCSTR)m_WordBuffer, m_WordSize);
2054 } 2053 }
2055 CFX_ByteString CPDF_SyntaxParser::GetKeyword() 2054 CFX_ByteString CPDF_SyntaxParser::GetKeyword()
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
2527 { 2526 {
2528 GetNextWord(); 2527 GetNextWord();
2529 if (!m_bIsNumber) { 2528 if (!m_bIsNumber) {
2530 return 0; 2529 return 0;
2531 } 2530 }
2532 m_WordBuffer[m_WordSize] = 0; 2531 m_WordBuffer[m_WordSize] = 0;
2533 return FXSYS_atoi((FX_LPCSTR)m_WordBuffer); 2532 return FXSYS_atoi((FX_LPCSTR)m_WordBuffer);
2534 } 2533 }
2535 FX_BOOL CPDF_SyntaxParser::IsWholeWord(FX_FILESIZE startpos, FX_FILESIZE limit, FX_LPCBYTE tag, FX_DWORD taglen) 2534 FX_BOOL CPDF_SyntaxParser::IsWholeWord(FX_FILESIZE startpos, FX_FILESIZE limit, FX_LPCBYTE tag, FX_DWORD taglen)
2536 { 2535 {
2537 FX_BYTE type = _PDF_CharType[tag[0]]; 2536 FX_BYTE type = PDF_CharType[tag[0]];
2538 FX_BOOL bCheckLeft = type != 'D' && type != 'W'; 2537 FX_BOOL bCheckLeft = type != 'D' && type != 'W';
2539 type = _PDF_CharType[tag[taglen - 1]]; 2538 type = PDF_CharType[tag[taglen - 1]];
2540 FX_BOOL bCheckRight = type != 'D' && type != 'W'; 2539 FX_BOOL bCheckRight = type != 'D' && type != 'W';
2541 FX_BYTE ch; 2540 FX_BYTE ch;
2542 if (bCheckRight && startpos + (FX_INT32)taglen <= limit && GetCharAt(startpo s + (FX_INT32)taglen, ch)) { 2541 if (bCheckRight && startpos + (FX_INT32)taglen <= limit && GetCharAt(startpo s + (FX_INT32)taglen, ch)) {
2543 FX_BYTE type = _PDF_CharType[ch]; 2542 FX_BYTE type = PDF_CharType[ch];
2544 if (type == 'N' || type == 'R') { 2543 if (type == 'N' || type == 'R') {
2545 return FALSE; 2544 return FALSE;
2546 } 2545 }
2547 } 2546 }
2548 if (bCheckLeft && startpos > 0 && GetCharAt(startpos - 1, ch)) { 2547 if (bCheckLeft && startpos > 0 && GetCharAt(startpos - 1, ch)) {
2549 FX_BYTE type = _PDF_CharType[ch]; 2548 FX_BYTE type = PDF_CharType[ch];
2550 if (type == 'N' || type == 'R') { 2549 if (type == 'N' || type == 'R') {
2551 return FALSE; 2550 return FALSE;
2552 } 2551 }
2553 } 2552 }
2554 return TRUE; 2553 return TRUE;
2555 } 2554 }
2556 FX_BOOL CPDF_SyntaxParser::SearchWord(FX_BSTR tag, FX_BOOL bWholeWord, FX_BOOL b Forward, FX_FILESIZE limit) 2555 FX_BOOL CPDF_SyntaxParser::SearchWord(FX_BSTR tag, FX_BOOL bWholeWord, FX_BOOL b Forward, FX_FILESIZE limit)
2557 { 2556 {
2558 FX_INT32 taglen = tag.GetLength(); 2557 FX_INT32 taglen = tag.GetLength();
2559 if (taglen == 0) { 2558 if (taglen == 0) {
(...skipping 1265 matching lines...) Expand 10 before | Expand all | Expand 10 after
3825 m_Pos = dwOffset; 3824 m_Pos = dwOffset;
3826 } 3825 }
3827 #define MAX_WORD_BUFFER 256 3826 #define MAX_WORD_BUFFER 256
3828 FX_BOOL CPDF_DataAvail::GetNextToken(CFX_ByteString &token) 3827 FX_BOOL CPDF_DataAvail::GetNextToken(CFX_ByteString &token)
3829 { 3828 {
3830 m_WordSize = 0; 3829 m_WordSize = 0;
3831 FX_BYTE ch; 3830 FX_BYTE ch;
3832 if (!GetNextChar(ch)) { 3831 if (!GetNextChar(ch)) {
3833 return FALSE; 3832 return FALSE;
3834 } 3833 }
3835 FX_BYTE type = _PDF_CharType[ch]; 3834 FX_BYTE type = PDF_CharType[ch];
3836 while (1) { 3835 while (1) {
3837 while (type == 'W') { 3836 while (type == 'W') {
3838 if (!GetNextChar(ch)) { 3837 if (!GetNextChar(ch)) {
3839 return FALSE; 3838 return FALSE;
3840 } 3839 }
3841 type = _PDF_CharType[ch]; 3840 type = PDF_CharType[ch];
3842 } 3841 }
3843 if (ch != '%') { 3842 if (ch != '%') {
3844 break; 3843 break;
3845 } 3844 }
3846 while (1) { 3845 while (1) {
3847 if (!GetNextChar(ch)) { 3846 if (!GetNextChar(ch)) {
3848 return FALSE; 3847 return FALSE;
3849 } 3848 }
3850 if (ch == '\r' || ch == '\n') { 3849 if (ch == '\r' || ch == '\n') {
3851 break; 3850 break;
3852 } 3851 }
3853 } 3852 }
3854 type = _PDF_CharType[ch]; 3853 type = PDF_CharType[ch];
3855 } 3854 }
3856 if (type == 'D') { 3855 if (type == 'D') {
3857 m_WordBuffer[m_WordSize++] = ch; 3856 m_WordBuffer[m_WordSize++] = ch;
3858 if (ch == '/') { 3857 if (ch == '/') {
3859 while (1) { 3858 while (1) {
3860 if (!GetNextChar(ch)) { 3859 if (!GetNextChar(ch)) {
3861 return FALSE; 3860 return FALSE;
3862 } 3861 }
3863 type = _PDF_CharType[ch]; 3862 type = PDF_CharType[ch];
3864 if (type != 'R' && type != 'N') { 3863 if (type != 'R' && type != 'N') {
3865 m_Pos --; 3864 m_Pos --;
3866 CFX_ByteString ret(m_WordBuffer, m_WordSize); 3865 CFX_ByteString ret(m_WordBuffer, m_WordSize);
3867 token = ret; 3866 token = ret;
3868 return TRUE; 3867 return TRUE;
3869 } 3868 }
3870 if (m_WordSize < MAX_WORD_BUFFER) { 3869 if (m_WordSize < MAX_WORD_BUFFER) {
3871 m_WordBuffer[m_WordSize++] = ch; 3870 m_WordBuffer[m_WordSize++] = ch;
3872 } 3871 }
3873 } 3872 }
(...skipping 20 matching lines...) Expand all
3894 token = ret; 3893 token = ret;
3895 return TRUE; 3894 return TRUE;
3896 } 3895 }
3897 while (1) { 3896 while (1) {
3898 if (m_WordSize < MAX_WORD_BUFFER) { 3897 if (m_WordSize < MAX_WORD_BUFFER) {
3899 m_WordBuffer[m_WordSize++] = ch; 3898 m_WordBuffer[m_WordSize++] = ch;
3900 } 3899 }
3901 if (!GetNextChar(ch)) { 3900 if (!GetNextChar(ch)) {
3902 return FALSE; 3901 return FALSE;
3903 } 3902 }
3904 type = _PDF_CharType[ch]; 3903 type = PDF_CharType[ch];
3905 if (type == 'D' || type == 'W') { 3904 if (type == 'D' || type == 'W') {
3906 m_Pos --; 3905 m_Pos --;
3907 break; 3906 break;
3908 } 3907 }
3909 } 3908 }
3910 CFX_ByteString ret(m_WordBuffer, m_WordSize); 3909 CFX_ByteString ret(m_WordBuffer, m_WordSize);
3911 token = ret; 3910 token = ret;
3912 return TRUE; 3911 return TRUE;
3913 } 3912 }
3914 FX_BOOL CPDF_DataAvail::GetNextChar(FX_BYTE &ch) 3913 FX_BOOL CPDF_DataAvail::GetNextChar(FX_BYTE &ch)
(...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after
4633 { 4632 {
4634 FX_INT32 iSize = m_childNode.GetSize(); 4633 FX_INT32 iSize = m_childNode.GetSize();
4635 for (FX_INT32 i = 0; i < iSize; ++i) { 4634 for (FX_INT32 i = 0; i < iSize; ++i) {
4636 CPDF_PageNode *pNode = (CPDF_PageNode*)m_childNode[i]; 4635 CPDF_PageNode *pNode = (CPDF_PageNode*)m_childNode[i];
4637 if (pNode) { 4636 if (pNode) {
4638 delete pNode; 4637 delete pNode;
4639 } 4638 }
4640 } 4639 }
4641 m_childNode.RemoveAll(); 4640 m_childNode.RemoveAll();
4642 } 4641 }
OLDNEW
« no previous file with comments | « core/src/fpdfapi/fpdf_parser/fpdf_parser_filters.cpp ('k') | core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698