| OLD | NEW |
| 1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef CORE_FPDFAPI_FPDF_PARSER_INCLUDE_CPDF_DOCUMENT_H_ | 7 #ifndef CORE_FPDFAPI_FPDF_PARSER_INCLUDE_CPDF_DOCUMENT_H_ |
| 8 #define CORE_FPDFAPI_FPDF_PARSER_INCLUDE_CPDF_DOCUMENT_H_ | 8 #define CORE_FPDFAPI_FPDF_PARSER_INCLUDE_CPDF_DOCUMENT_H_ |
| 9 | 9 |
| 10 #include <memory> |
| 11 |
| 10 #include "core/fpdfapi/fpdf_parser/include/cpdf_indirect_object_holder.h" | 12 #include "core/fpdfapi/fpdf_parser/include/cpdf_indirect_object_holder.h" |
| 11 #include "core/fpdfapi/fpdf_parser/include/cpdf_object.h" | 13 #include "core/fpdfapi/fpdf_parser/include/cpdf_object.h" |
| 12 #include "core/fxcrt/include/fx_basic.h" | 14 #include "core/fxcrt/include/fx_basic.h" |
| 13 | 15 |
| 14 class CFX_Font; | 16 class CFX_Font; |
| 15 class CFX_Matrix; | 17 class CFX_Matrix; |
| 16 class CPDF_ColorSpace; | 18 class CPDF_ColorSpace; |
| 17 class CPDF_DocPageData; | 19 class CPDF_DocPageData; |
| 18 class CPDF_DocRenderData; | 20 class CPDF_DocRenderData; |
| 19 class CPDF_Font; | 21 class CPDF_Font; |
| 20 class CPDF_FontEncoding; | 22 class CPDF_FontEncoding; |
| 21 class CPDF_IccProfile; | 23 class CPDF_IccProfile; |
| 22 class CPDF_Image; | 24 class CPDF_Image; |
| 23 class CPDF_Pattern; | 25 class CPDF_Pattern; |
| 24 class CPDF_StreamAcc; | 26 class CPDF_StreamAcc; |
| 25 | 27 |
| 26 #define FPDFPERM_PRINT 0x0004 | 28 #define FPDFPERM_PRINT 0x0004 |
| 27 #define FPDFPERM_MODIFY 0x0008 | 29 #define FPDFPERM_MODIFY 0x0008 |
| 28 #define FPDFPERM_EXTRACT 0x0010 | 30 #define FPDFPERM_EXTRACT 0x0010 |
| 29 #define FPDFPERM_ANNOT_FORM 0x0020 | 31 #define FPDFPERM_ANNOT_FORM 0x0020 |
| 30 #define FPDFPERM_FILL_FORM 0x0100 | 32 #define FPDFPERM_FILL_FORM 0x0100 |
| 31 #define FPDFPERM_EXTRACT_ACCESS 0x0200 | 33 #define FPDFPERM_EXTRACT_ACCESS 0x0200 |
| 32 #define FPDFPERM_ASSEMBLE 0x0400 | 34 #define FPDFPERM_ASSEMBLE 0x0400 |
| 33 #define FPDFPERM_PRINT_HIGH 0x0800 | 35 #define FPDFPERM_PRINT_HIGH 0x0800 |
| 34 #define FPDF_PAGE_MAX_NUM 0xFFFFF | 36 #define FPDF_PAGE_MAX_NUM 0xFFFFF |
| 35 | 37 |
| 36 class CPDF_Document : public CFX_PrivateData, public CPDF_IndirectObjectHolder { | 38 class CPDF_Document : public CFX_PrivateData, public CPDF_IndirectObjectHolder { |
| 37 public: | 39 public: |
| 38 CPDF_Document(); | |
| 39 explicit CPDF_Document(CPDF_Parser* pParser); | 40 explicit CPDF_Document(CPDF_Parser* pParser); |
| 40 ~CPDF_Document(); | 41 ~CPDF_Document(); |
| 41 | 42 |
| 42 CPDF_Parser* GetParser() const { return m_pParser; } | 43 CPDF_Parser* GetParser() const { return m_pParser; } |
| 43 CPDF_Dictionary* GetRoot() const { return m_pRootDict; } | 44 CPDF_Dictionary* GetRoot() const { return m_pRootDict; } |
| 44 CPDF_Dictionary* GetInfo() const { return m_pInfoDict; } | 45 CPDF_Dictionary* GetInfo() const { return m_pInfoDict; } |
| 45 | 46 |
| 46 void GetID(CFX_ByteString& id1, CFX_ByteString& id2) const { | 47 void GetID(CFX_ByteString& id1, CFX_ByteString& id2) const { |
| 47 id1 = m_ID1; | 48 id1 = m_ID1; |
| 48 id2 = m_ID2; | 49 id2 = m_ID2; |
| 49 } | 50 } |
| 50 | 51 |
| 51 int GetPageCount() const; | 52 int GetPageCount() const; |
| 52 CPDF_Dictionary* GetPage(int iPage); | 53 CPDF_Dictionary* GetPage(int iPage); |
| 53 int GetPageIndex(uint32_t objnum); | 54 int GetPageIndex(uint32_t objnum); |
| 54 uint32_t GetUserPermissions(FX_BOOL bCheckRevision = FALSE) const; | 55 uint32_t GetUserPermissions(FX_BOOL bCheckRevision = FALSE) const; |
| 55 CPDF_DocPageData* GetPageData() { return GetValidatePageData(); } | 56 CPDF_DocPageData* GetPageData() const { return m_pDocPage; } |
| 56 void ClearPageData(); | 57 void ClearPageData(); |
| 57 void RemoveColorSpaceFromPageData(CPDF_Object* pObject); | 58 void RemoveColorSpaceFromPageData(CPDF_Object* pObject); |
| 58 | 59 |
| 59 CPDF_DocRenderData* GetRenderData() { return GetValidateRenderData(); } | 60 CPDF_DocRenderData* GetRenderData() const { return m_pDocRender.get(); } |
| 60 void ClearRenderData(); | 61 void ClearRenderData(); |
| 61 void ClearRenderFont(); | 62 void ClearRenderFont(); |
| 62 | 63 |
| 63 FX_BOOL IsFormStream(uint32_t objnum, FX_BOOL& bForm) const; | 64 FX_BOOL IsFormStream(uint32_t objnum, FX_BOOL& bForm) const; |
| 64 | 65 |
| 65 // |pFontDict| must not be null. | 66 // |pFontDict| must not be null. |
| 66 CPDF_Font* LoadFont(CPDF_Dictionary* pFontDict); | 67 CPDF_Font* LoadFont(CPDF_Dictionary* pFontDict); |
| 67 CPDF_ColorSpace* LoadColorSpace(CPDF_Object* pCSObj, | 68 CPDF_ColorSpace* LoadColorSpace(CPDF_Object* pCSObj, |
| 68 CPDF_Dictionary* pResources = NULL); | 69 CPDF_Dictionary* pResources = NULL); |
| 69 | 70 |
| 70 CPDF_Pattern* LoadPattern(CPDF_Object* pObj, | 71 CPDF_Pattern* LoadPattern(CPDF_Object* pObj, |
| 71 FX_BOOL bShading, | 72 FX_BOOL bShading, |
| 72 const CFX_Matrix* matrix = NULL); | 73 const CFX_Matrix* matrix = NULL); |
| 73 | 74 |
| 74 CPDF_Image* LoadImageF(CPDF_Object* pObj); | 75 CPDF_Image* LoadImageF(CPDF_Object* pObj); |
| 75 CPDF_StreamAcc* LoadFontFile(CPDF_Stream* pStream); | 76 CPDF_StreamAcc* LoadFontFile(CPDF_Stream* pStream); |
| 76 CPDF_IccProfile* LoadIccProfile(CPDF_Stream* pStream); | 77 CPDF_IccProfile* LoadIccProfile(CPDF_Stream* pStream); |
| 77 | 78 |
| 79 void LoadDoc(); |
| 80 void LoadAsynDoc(CPDF_Dictionary* pLinearized); |
| 81 void LoadPages(); |
| 82 |
| 83 // Editing methods. |
| 84 void CreateNewDoc(); |
| 85 CPDF_Dictionary* CreateNewPage(int iPage); |
| 86 void DeletePage(int iPage); |
| 87 CPDF_Font* AddStandardFont(const FX_CHAR* font, CPDF_FontEncoding* pEncoding); |
| 88 CPDF_Font* AddFont(CFX_Font* pFont, int charset, FX_BOOL bVert); |
| 78 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 89 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
| 79 | |
| 80 CPDF_Font* AddWindowsFont(LOGFONTA* pLogFont, | 90 CPDF_Font* AddWindowsFont(LOGFONTA* pLogFont, |
| 81 FX_BOOL bVert, | 91 FX_BOOL bVert, |
| 82 FX_BOOL bTranslateName = FALSE); | 92 FX_BOOL bTranslateName = FALSE); |
| 83 CPDF_Font* AddWindowsFont(LOGFONTW* pLogFont, | 93 CPDF_Font* AddWindowsFont(LOGFONTW* pLogFont, |
| 84 FX_BOOL bVert, | 94 FX_BOOL bVert, |
| 85 FX_BOOL bTranslateName = FALSE); | 95 FX_BOOL bTranslateName = FALSE); |
| 86 #endif | 96 #endif |
| 87 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | 97 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
| 88 CPDF_Font* AddMacFont(CTFontRef pFont, | 98 CPDF_Font* AddMacFont(CTFontRef pFont, |
| 89 FX_BOOL bVert, | 99 FX_BOOL bVert, |
| 90 FX_BOOL bTranslateName = FALSE); | 100 FX_BOOL bTranslateName = FALSE); |
| 91 #endif | 101 #endif |
| 92 | 102 |
| 93 CPDF_Font* AddStandardFont(const FX_CHAR* font, CPDF_FontEncoding* pEncoding); | |
| 94 CPDF_Font* AddFont(CFX_Font* pFont, int charset, FX_BOOL bVert); | |
| 95 void CreateNewDoc(); | |
| 96 | |
| 97 CPDF_Dictionary* CreateNewPage(int iPage); | |
| 98 void DeletePage(int iPage); | |
| 99 | |
| 100 void LoadDoc(); | |
| 101 void LoadAsynDoc(CPDF_Dictionary* pLinearized); | |
| 102 void LoadPages(); | |
| 103 | |
| 104 protected: | 103 protected: |
| 105 // Retrieve page count information by getting count value from the tree nodes | |
| 106 // or walking through the tree nodes to calculate it. | |
| 107 int RetrievePageCount() const; | |
| 108 CPDF_Dictionary* _FindPDFPage(CPDF_Dictionary* pPages, | |
| 109 int iPage, | |
| 110 int nPagesToGo, | |
| 111 int level); | |
| 112 int _FindPageIndex(CPDF_Dictionary* pNode, | |
| 113 uint32_t& skip_count, | |
| 114 uint32_t objnum, | |
| 115 int& index, | |
| 116 int level = 0); | |
| 117 FX_BOOL CheckOCGVisible(CPDF_Dictionary* pOCG, FX_BOOL bPrinting); | |
| 118 CPDF_DocPageData* GetValidatePageData(); | |
| 119 CPDF_DocRenderData* GetValidateRenderData(); | |
| 120 friend class CPDF_Creator; | 104 friend class CPDF_Creator; |
| 121 friend class CPDF_Parser; | 105 friend class CPDF_Parser; |
| 122 friend class CPDF_DataAvail; | 106 friend class CPDF_DataAvail; |
| 123 friend class CPDF_OCContext; | 107 friend class CPDF_OCContext; |
| 124 | 108 |
| 109 // Retrieve page count information by getting count value from the tree nodes |
| 110 // or walking through the tree nodes to calculate it. |
| 111 int RetrievePageCount() const; |
| 112 CPDF_Dictionary* FindPDFPage(CPDF_Dictionary* pPages, |
| 113 int iPage, |
| 114 int nPagesToGo, |
| 115 int level); |
| 116 int FindPageIndex(CPDF_Dictionary* pNode, |
| 117 uint32_t& skip_count, |
| 118 uint32_t objnum, |
| 119 int& index, |
| 120 int level = 0); |
| 121 FX_BOOL CheckOCGVisible(CPDF_Dictionary* pOCG, FX_BOOL bPrinting); |
| 122 |
| 125 CPDF_Dictionary* m_pRootDict; | 123 CPDF_Dictionary* m_pRootDict; |
| 126 CPDF_Dictionary* m_pInfoDict; | 124 CPDF_Dictionary* m_pInfoDict; |
| 127 CFX_ByteString m_ID1; | 125 CFX_ByteString m_ID1; |
| 128 CFX_ByteString m_ID2; | 126 CFX_ByteString m_ID2; |
| 129 FX_BOOL m_bLinearized; | 127 bool m_bLinearized; |
| 130 uint32_t m_dwFirstPageNo; | 128 int m_iFirstPageNo; |
| 131 uint32_t m_dwFirstPageObjNum; | 129 uint32_t m_dwFirstPageObjNum; |
| 132 CFX_ArrayTemplate<uint32_t> m_PageList; | 130 CFX_ArrayTemplate<uint32_t> m_PageList; |
| 131 // TODO(thestig): Figure out why this cannot be a std::unique_ptr. |
| 133 CPDF_DocPageData* m_pDocPage; | 132 CPDF_DocPageData* m_pDocPage; |
| 134 CPDF_DocRenderData* m_pDocRender; | 133 std::unique_ptr<CPDF_DocRenderData> m_pDocRender; |
| 135 }; | 134 }; |
| 136 | 135 |
| 137 #endif // CORE_FPDFAPI_FPDF_PARSER_INCLUDE_CPDF_DOCUMENT_H_ | 136 #endif // CORE_FPDFAPI_FPDF_PARSER_INCLUDE_CPDF_DOCUMENT_H_ |
| OLD | NEW |