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

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

Issue 871773002: Merge to XFA: Use IPDF_DataAvail interface to hide CPDF_DataAvail. (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
« no previous file with comments | « core/include/fpdfapi/fpdf_parser.h ('k') | fpdfsdk/src/fpdf_dataavail.cpp » ('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 "../../../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"
(...skipping 2702 matching lines...) Expand 10 before | Expand all | Expand 10 after
2713 while (1) { 2713 while (1) {
2714 if (!GetNextChar(ch)) { 2714 if (!GetNextChar(ch)) {
2715 return; 2715 return;
2716 } 2716 }
2717 buffer[offset++] = ch; 2717 buffer[offset++] = ch;
2718 if (offset == size) { 2718 if (offset == size) {
2719 break; 2719 break;
2720 } 2720 }
2721 } 2721 }
2722 } 2722 }
2723
2724 class CPDF_DataAvail FX_FINAL : public CFX_Object, public IPDF_DataAvail
2725 {
2726 public:
2727 CPDF_DataAvail(IFX_FileAvail* pFileAvail, IFX_FileRead* pFileRead);
2728 ~CPDF_DataAvail();
2729
2730 virtual FX_BOOL IsDocAvail(IFX_DownloadHints* pHints) F X_OVERRIDE;
2731
2732 virtual void SetDocument(CPDF_Document* pDoc) FX_OVE RRIDE;
2733
2734 virtual FX_BOOL IsPageAvail(int iPage, IFX_DownloadHints * pHints) FX_OVERRIDE;
2735
2736 virtual FX_INT32 IsFormAvail(IFX_DownloadHints *pHints) FX_OVERRIDE;
2737
2738 virtual FX_INT32 IsLinearizedPDF() FX_OVERRIDE;
2739
2740 virtual FX_BOOL IsLinearized() FX_OVERRIDE
2741 {
2742 return m_bLinearized;
2743 }
2744
2745 virtual void GetLinearizedMainXRefInfo(FX_FILESIZE *p Pos, FX_DWORD *pSize) FX_OVERRIDE;
2746 protected:
2747 FX_DWORD GetObjectSize(FX_DWORD objnum, FX_FILESI ZE& offset);
2748 FX_BOOL IsObjectsAvail(CFX_PtrArray& obj_array, FX_BOOL bParsePage, IFX_DownloadHints* pHints, CFX_PtrArray &ret_array);
2749 FX_BOOL CheckDocStatus(IFX_DownloadHints *pHints );
2750 FX_BOOL CheckHeader(IFX_DownloadHints* pHints);
2751 FX_BOOL CheckFirstPage(IFX_DownloadHints *pHints );
2752 FX_BOOL CheckEnd(IFX_DownloadHints *pHints);
2753 FX_BOOL CheckCrossRef(IFX_DownloadHints* pHints) ;
2754 FX_BOOL CheckCrossRefItem(IFX_DownloadHints *pHi nts);
2755 FX_BOOL CheckTrailer(IFX_DownloadHints* pHints);
2756 FX_BOOL CheckRoot(IFX_DownloadHints* pHints);
2757 FX_BOOL CheckInfo(IFX_DownloadHints* pHints);
2758 FX_BOOL CheckPages(IFX_DownloadHints* pHints);
2759 FX_BOOL CheckPage(IFX_DownloadHints* pHints);
2760 FX_BOOL CheckResources(IFX_DownloadHints* pHints );
2761 FX_BOOL CheckAnnots(IFX_DownloadHints* pHints);
2762 FX_BOOL CheckAcroForm(IFX_DownloadHints* pHints) ;
2763 FX_BOOL CheckAcroFormSubObject(IFX_DownloadHints * pHints);
2764 FX_BOOL CheckTrailerAppend(IFX_DownloadHints* pH ints);
2765 FX_BOOL CheckPageStatus(IFX_DownloadHints* pHint s);
2766 FX_BOOL CheckAllCrossRefStream(IFX_DownloadHints *pHints);
2767
2768 FX_DWORD CheckCrossRefStream(IFX_DownloadHints *p Hints, FX_FILESIZE &xref_offset);
2769 FX_BOOL IsLinearizedFile(FX_LPBYTE pData, FX_DWO RD dwLen);
2770 void SetStartOffset(FX_FILESIZE dwOffset);
2771 FX_BOOL GetNextToken(CFX_ByteString &token);
2772 FX_BOOL GetNextChar(FX_BYTE &ch);
2773 CPDF_Object * ParseIndirectObjectAt(FX_FILESIZE pos, F X_DWORD objnum);
2774 CPDF_Object * GetObject(FX_DWORD objnum, IFX_DownloadH ints* pHints, FX_BOOL *pExistInFile);
2775 FX_BOOL GetPageKids(CPDF_Parser *pParser, CPDF_O bject *pPages);
2776 FX_BOOL PreparePageItem();
2777 FX_BOOL LoadPages(IFX_DownloadHints* pHints);
2778 FX_BOOL LoadAllXref(IFX_DownloadHints* pHints);
2779 FX_BOOL LoadAllFile(IFX_DownloadHints* pHints);
2780 FX_BOOL CheckLinearizedData(IFX_DownloadHints* p Hints);
2781 FX_BOOL CheckFileResources(IFX_DownloadHints* pH ints);
2782 FX_BOOL CheckPageAnnots(int iPage, IFX_DownloadH ints* pHints);
2783
2784 FX_BOOL CheckLinearizedFirstPage(int iPage, IFX_ DownloadHints* pHints);
2785 FX_BOOL HaveResourceAncestor(CPDF_Dictionary *pD ict);
2786 FX_BOOL CheckPage(FX_INT32 iPage, IFX_DownloadHi nts* pHints);
2787 FX_BOOL LoadDocPages(IFX_DownloadHints* pHints);
2788 FX_BOOL LoadDocPage(FX_INT32 iPage, IFX_Download Hints* pHints);
2789 FX_BOOL CheckPageNode(CPDF_PageNode &pageNodes, FX_INT32 iPage, FX_INT32 &iCount, IFX_DownloadHints* pHints);
2790 FX_BOOL CheckUnkownPageNode(FX_DWORD dwPageNo, C PDF_PageNode *pPageNode, IFX_DownloadHints* pHints);
2791 FX_BOOL CheckArrayPageNode(FX_DWORD dwPageNo, CP DF_PageNode *pPageNode, IFX_DownloadHints* pHints);
2792 FX_BOOL CheckPageCount(IFX_DownloadHints* pHints );
2793 FX_BOOL IsFirstCheck(int iPage);
2794 void ResetFirstCheck(int iPage);
2795
2796 CPDF_Parser m_parser;
2797
2798 CPDF_SyntaxParser m_syntaxParser;
2799
2800 CPDF_Object *m_pRoot;
2801
2802 FX_DWORD m_dwRootObjNum;
2803
2804 FX_DWORD m_dwInfoObjNum;
2805
2806 CPDF_Object *m_pLinearized;
2807
2808 CPDF_Object *m_pTrailer;
2809
2810 FX_BOOL m_bDocAvail;
2811
2812 FX_FILESIZE m_dwHeaderOffset;
2813
2814 FX_FILESIZE m_dwLastXRefOffset;
2815
2816 FX_FILESIZE m_dwXRefOffset;
2817
2818 FX_FILESIZE m_dwTrailerOffset;
2819
2820 FX_FILESIZE m_dwCurrentOffset;
2821
2822 PDF_DATAAVAIL_STATUS m_docStatus;
2823
2824 FX_FILESIZE m_dwFileLen;
2825
2826 CPDF_Document* m_pDocument;
2827
2828 CPDF_SortObjNumArray m_objnum_array;
2829
2830 CFX_PtrArray m_objs_array;
2831
2832 FX_FILESIZE m_Pos;
2833
2834 FX_FILESIZE m_bufferOffset;
2835
2836 FX_DWORD m_bufferSize;
2837
2838 CFX_ByteString m_WordBuf;
2839
2840 FX_BYTE m_WordBuffer[257];
2841
2842 FX_DWORD m_WordSize;
2843
2844 FX_BYTE m_bufferData[512];
2845
2846 CFX_FileSizeArray m_CrossOffset;
2847
2848 CFX_DWordArray m_XRefStreamList;
2849
2850 CFX_DWordArray m_PageObjList;
2851
2852 FX_DWORD m_PagesObjNum;
2853
2854 FX_BOOL m_bLinearized;
2855
2856 FX_DWORD m_dwFirstPageNo;
2857
2858 FX_BOOL m_bLinearedDataOK;
2859
2860 FX_BOOL m_bMainXRefLoadTried;
2861
2862 FX_BOOL m_bMainXRefLoadedOK;
2863
2864 FX_BOOL m_bPagesTreeLoad;
2865
2866 FX_BOOL m_bPagesLoad;
2867
2868 CPDF_Parser * m_pCurrentParser;
2869
2870 FX_FILESIZE m_dwCurrentXRefSteam;
2871
2872 FX_BOOL m_bAnnotsLoad;
2873
2874 FX_BOOL m_bHaveAcroForm;
2875
2876 FX_DWORD m_dwAcroFormObjNum;
2877
2878 FX_BOOL m_bAcroFormLoad;
2879
2880 CPDF_Object * m_pAcroForm;
2881
2882 CFX_PtrArray m_arrayAcroforms;
2883
2884 CPDF_Dictionary * m_pPageDict;
2885
2886 CPDF_Object * m_pPageResource;
2887
2888 FX_BOOL m_bNeedDownLoadResource;
2889
2890 FX_BOOL m_bPageLoadedOK;
2891
2892 FX_BOOL m_bLinearizedFormParamLoad;
2893
2894 CFX_PtrArray m_PagesArray;
2895
2896 FX_DWORD m_dwEncryptObjNum;
2897
2898 FX_FILESIZE m_dwPrevXRefOffset;
2899
2900 FX_BOOL m_bTotalLoadPageTree;
2901
2902 FX_BOOL m_bCurPageDictLoadOK;
2903
2904 CPDF_PageNode m_pageNodes;
2905
2906 CFX_CMapDWordToDWord * m_pageMapCheckState;
2907
2908 CFX_CMapDWordToDWord * m_pagesLoadState;
2909 };
2910
2911 IPDF_DataAvail::IPDF_DataAvail(IFX_FileAvail* pFileAvail, IFX_FileRead* pFileRea d) :
2912 m_pFileAvail(pFileAvail),
2913 m_pFileRead(pFileRead) {
2914 }
2915
2916 // static
2917 IPDF_DataAvail* IPDF_DataAvail::Create(IFX_FileAvail* pFileAvail, IFX_FileRead* pFileRead)
2918 {
2919 return FX_NEW CPDF_DataAvail(pFileAvail, pFileRead);
2920 }
2921
2723 CPDF_DataAvail::CPDF_DataAvail(IFX_FileAvail* pFileAvail, IFX_FileRead* pFileRea d) 2922 CPDF_DataAvail::CPDF_DataAvail(IFX_FileAvail* pFileAvail, IFX_FileRead* pFileRea d)
2923 : IPDF_DataAvail(pFileAvail, pFileRead)
2724 { 2924 {
2725 m_pFileAvail = pFileAvail;
2726 m_pFileRead = pFileRead;
2727 m_Pos = 0; 2925 m_Pos = 0;
2728 m_dwFileLen = 0; 2926 m_dwFileLen = 0;
2729 if (m_pFileRead) { 2927 if (m_pFileRead) {
2730 m_dwFileLen = (FX_DWORD)m_pFileRead->GetSize(); 2928 m_dwFileLen = (FX_DWORD)m_pFileRead->GetSize();
2731 } 2929 }
2732 m_dwCurrentOffset = 0; 2930 m_dwCurrentOffset = 0;
2733 m_WordSize = 0; 2931 m_WordSize = 0;
2734 m_dwXRefOffset = 0; 2932 m_dwXRefOffset = 0;
2735 m_bufferOffset = 0; 2933 m_bufferOffset = 0;
2736 m_dwFirstPageNo = 0; 2934 m_dwFirstPageNo = 0;
(...skipping 1693 matching lines...) Expand 10 before | Expand all | Expand 10 after
4430 { 4628 {
4431 FX_INT32 iSize = m_childNode.GetSize(); 4629 FX_INT32 iSize = m_childNode.GetSize();
4432 for (FX_INT32 i = 0; i < iSize; ++i) { 4630 for (FX_INT32 i = 0; i < iSize; ++i) {
4433 CPDF_PageNode *pNode = (CPDF_PageNode*)m_childNode[i]; 4631 CPDF_PageNode *pNode = (CPDF_PageNode*)m_childNode[i];
4434 if (pNode) { 4632 if (pNode) {
4435 delete pNode; 4633 delete pNode;
4436 } 4634 }
4437 } 4635 }
4438 m_childNode.RemoveAll(); 4636 m_childNode.RemoveAll();
4439 } 4637 }
OLDNEW
« no previous file with comments | « core/include/fpdfapi/fpdf_parser.h ('k') | fpdfsdk/src/fpdf_dataavail.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698