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

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

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