OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 |
| 7 #ifndef CORE_INCLUDE_FPDFAPI_CPDF_DOCUMENT_H_ |
| 8 #define CORE_INCLUDE_FPDFAPI_CPDF_DOCUMENT_H_ |
| 9 |
| 10 #include "core/include/fpdfapi/fpdf_objects.h" |
| 11 #include "core/include/fxcrt/fx_basic.h" |
| 12 |
| 13 class CFX_Font; |
| 14 class CPDF_ColorSpace; |
| 15 class CPDF_DocPageData; |
| 16 class CPDF_DocRenderData; |
| 17 class CPDF_Font; |
| 18 class CPDF_FontEncoding; |
| 19 class CPDF_IccProfile; |
| 20 class CPDF_Image; |
| 21 class CPDF_Pattern; |
| 22 |
| 23 class CPDF_Document : public CFX_PrivateData, public CPDF_IndirectObjectHolder { |
| 24 public: |
| 25 CPDF_Document(); |
| 26 explicit CPDF_Document(CPDF_Parser* pParser); |
| 27 ~CPDF_Document(); |
| 28 |
| 29 CPDF_Parser* GetParser() const { return m_pParser; } |
| 30 CPDF_Dictionary* GetRoot() const { return m_pRootDict; } |
| 31 CPDF_Dictionary* GetInfo() const { return m_pInfoDict; } |
| 32 |
| 33 void GetID(CFX_ByteString& id1, CFX_ByteString& id2) const { |
| 34 id1 = m_ID1; |
| 35 id2 = m_ID2; |
| 36 } |
| 37 |
| 38 int GetPageCount() const; |
| 39 |
| 40 CPDF_Dictionary* GetPage(int iPage); |
| 41 |
| 42 int GetPageIndex(FX_DWORD objnum); |
| 43 |
| 44 FX_DWORD GetUserPermissions(FX_BOOL bCheckRevision = FALSE) const; |
| 45 |
| 46 CPDF_DocPageData* GetPageData() { return GetValidatePageData(); } |
| 47 |
| 48 void ClearPageData(); |
| 49 |
| 50 void RemoveColorSpaceFromPageData(CPDF_Object* pObject); |
| 51 |
| 52 CPDF_DocRenderData* GetRenderData() { return GetValidateRenderData(); } |
| 53 |
| 54 void ClearRenderData(); |
| 55 |
| 56 void ClearRenderFont(); |
| 57 |
| 58 FX_BOOL IsFormStream(FX_DWORD objnum, FX_BOOL& bForm) const; |
| 59 |
| 60 // |pFontDict| must not be null. |
| 61 CPDF_Font* LoadFont(CPDF_Dictionary* pFontDict); |
| 62 |
| 63 CPDF_ColorSpace* LoadColorSpace(CPDF_Object* pCSObj, |
| 64 CPDF_Dictionary* pResources = NULL); |
| 65 |
| 66 CPDF_Pattern* LoadPattern(CPDF_Object* pObj, |
| 67 FX_BOOL bShading, |
| 68 const CFX_Matrix* matrix = NULL); |
| 69 |
| 70 CPDF_Image* LoadImageF(CPDF_Object* pObj); |
| 71 |
| 72 CPDF_StreamAcc* LoadFontFile(CPDF_Stream* pStream); |
| 73 |
| 74 CPDF_IccProfile* LoadIccProfile(CPDF_Stream* pStream); |
| 75 |
| 76 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
| 77 |
| 78 CPDF_Font* AddWindowsFont(LOGFONTA* pLogFont, |
| 79 FX_BOOL bVert, |
| 80 FX_BOOL bTranslateName = FALSE); |
| 81 CPDF_Font* AddWindowsFont(LOGFONTW* pLogFont, |
| 82 FX_BOOL bVert, |
| 83 FX_BOOL bTranslateName = FALSE); |
| 84 #endif |
| 85 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
| 86 CPDF_Font* AddMacFont(CTFontRef pFont, |
| 87 FX_BOOL bVert, |
| 88 FX_BOOL bTranslateName = FALSE); |
| 89 #endif |
| 90 |
| 91 CPDF_Font* AddStandardFont(const FX_CHAR* font, CPDF_FontEncoding* pEncoding); |
| 92 |
| 93 CPDF_Font* AddFont(CFX_Font* pFont, int charset, FX_BOOL bVert); |
| 94 |
| 95 void CreateNewDoc(); |
| 96 |
| 97 CPDF_Dictionary* CreateNewPage(int iPage); |
| 98 |
| 99 void DeletePage(int iPage); |
| 100 |
| 101 void LoadDoc(); |
| 102 void LoadAsynDoc(CPDF_Dictionary* pLinearized); |
| 103 void LoadPages(); |
| 104 |
| 105 protected: |
| 106 CPDF_Dictionary* m_pRootDict; |
| 107 |
| 108 CPDF_Dictionary* m_pInfoDict; |
| 109 |
| 110 CFX_ByteString m_ID1; |
| 111 |
| 112 CFX_ByteString m_ID2; |
| 113 |
| 114 FX_BOOL m_bLinearized; |
| 115 |
| 116 FX_DWORD m_dwFirstPageNo; |
| 117 |
| 118 FX_DWORD m_dwFirstPageObjNum; |
| 119 |
| 120 CFX_DWordArray m_PageList; |
| 121 |
| 122 // Retrieve page count information by getting count value from the tree nodes |
| 123 // or walking through the tree nodes to calculate it. |
| 124 int RetrievePageCount() const; |
| 125 CPDF_Dictionary* _FindPDFPage(CPDF_Dictionary* pPages, |
| 126 int iPage, |
| 127 int nPagesToGo, |
| 128 int level); |
| 129 int _FindPageIndex(CPDF_Dictionary* pNode, |
| 130 FX_DWORD& skip_count, |
| 131 FX_DWORD objnum, |
| 132 int& index, |
| 133 int level = 0); |
| 134 FX_BOOL CheckOCGVisible(CPDF_Dictionary* pOCG, FX_BOOL bPrinting); |
| 135 CPDF_DocPageData* GetValidatePageData(); |
| 136 CPDF_DocRenderData* GetValidateRenderData(); |
| 137 friend class CPDF_Creator; |
| 138 friend class CPDF_Parser; |
| 139 friend class CPDF_DataAvail; |
| 140 friend class CPDF_OCContext; |
| 141 |
| 142 CPDF_DocPageData* m_pDocPage; |
| 143 CPDF_DocRenderData* m_pDocRender; |
| 144 }; |
| 145 |
| 146 #endif // CORE_INCLUDE_FPDFAPI_CPDF_DOCUMENT_H_ |
OLD | NEW |