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 <functional> | 10 #include <functional> |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 explicit CPDF_Document(std::unique_ptr<CPDF_Parser> pParser); | 44 explicit CPDF_Document(std::unique_ptr<CPDF_Parser> pParser); |
45 ~CPDF_Document() override; | 45 ~CPDF_Document() override; |
46 | 46 |
47 CPDF_Parser* GetParser() const { return m_pParser.get(); } | 47 CPDF_Parser* GetParser() const { return m_pParser.get(); } |
48 CPDF_Dictionary* GetRoot() const { return m_pRootDict; } | 48 CPDF_Dictionary* GetRoot() const { return m_pRootDict; } |
49 CPDF_Dictionary* GetInfo() const { return m_pInfoDict; } | 49 CPDF_Dictionary* GetInfo() const { return m_pInfoDict; } |
50 | 50 |
51 void DeletePage(int iPage); | 51 void DeletePage(int iPage); |
52 int GetPageCount() const; | 52 int GetPageCount() const; |
53 | 53 |
| 54 bool IsPageLoaded(int iPage) const; |
54 CPDF_Dictionary* GetPage(int iPage); | 55 CPDF_Dictionary* GetPage(int iPage); |
55 int GetPageIndex(uint32_t objnum); | 56 int GetPageIndex(uint32_t objnum); |
56 uint32_t GetUserPermissions() const; | 57 uint32_t GetUserPermissions() const; |
57 CPDF_DocPageData* GetPageData() const { return m_pDocPage; } | 58 CPDF_DocPageData* GetPageData() const { return m_pDocPage; } |
58 | 59 |
| 60 void SetPageObjNum(int iPage, uint32_t objNum); |
| 61 |
59 std::unique_ptr<JBig2_DocumentContext>* CodecContext() { | 62 std::unique_ptr<JBig2_DocumentContext>* CodecContext() { |
60 return &m_pCodecContext; | 63 return &m_pCodecContext; |
61 } | 64 } |
62 std::unique_ptr<CPDF_LinkList>* LinksContext() { return &m_pLinksContext; } | 65 std::unique_ptr<CPDF_LinkList>* LinksContext() { return &m_pLinksContext; } |
63 | 66 |
64 CPDF_DocRenderData* GetRenderData() const { return m_pDocRender.get(); } | 67 CPDF_DocRenderData* GetRenderData() const { return m_pDocRender.get(); } |
65 | 68 |
66 // |pFontDict| must not be null. | 69 // |pFontDict| must not be null. |
67 CPDF_Font* LoadFont(CPDF_Dictionary* pFontDict); | 70 CPDF_Font* LoadFont(CPDF_Dictionary* pFontDict); |
68 CPDF_ColorSpace* LoadColorSpace(CPDF_Object* pCSObj, | 71 CPDF_ColorSpace* LoadColorSpace(CPDF_Object* pCSObj, |
(...skipping 21 matching lines...) Expand all Loading... |
90 FX_BOOL bVert, | 93 FX_BOOL bVert, |
91 FX_BOOL bTranslateName = FALSE); | 94 FX_BOOL bTranslateName = FALSE); |
92 CPDF_Font* AddWindowsFont(LOGFONTW* pLogFont, | 95 CPDF_Font* AddWindowsFont(LOGFONTW* pLogFont, |
93 FX_BOOL bVert, | 96 FX_BOOL bVert, |
94 FX_BOOL bTranslateName = FALSE); | 97 FX_BOOL bTranslateName = FALSE); |
95 #endif | 98 #endif |
96 | 99 |
97 protected: | 100 protected: |
98 friend class CPDF_Creator; | 101 friend class CPDF_Creator; |
99 friend class CPDF_Parser; | 102 friend class CPDF_Parser; |
100 friend class CPDF_DataAvail; | |
101 friend class CPDF_OCContext; | 103 friend class CPDF_OCContext; |
102 | 104 |
103 // Retrieve page count information by getting count value from the tree nodes | 105 // Retrieve page count information by getting count value from the tree nodes |
104 int RetrievePageCount() const; | 106 int RetrievePageCount() const; |
105 CPDF_Dictionary* FindPDFPage(CPDF_Dictionary* pPages, | 107 CPDF_Dictionary* FindPDFPage(CPDF_Dictionary* pPages, |
106 int iPage, | 108 int iPage, |
107 int nPagesToGo, | 109 int nPagesToGo, |
108 int level); | 110 int level); |
109 int FindPageIndex(CPDF_Dictionary* pNode, | 111 int FindPageIndex(CPDF_Dictionary* pNode, |
110 uint32_t& skip_count, | 112 uint32_t& skip_count, |
111 uint32_t objnum, | 113 uint32_t objnum, |
112 int& index, | 114 int& index, |
113 int level = 0); | 115 int level = 0); |
114 CPDF_Object* ParseIndirectObject(uint32_t objnum) override; | 116 CPDF_Object* ParseIndirectObject(uint32_t objnum) override; |
115 | 117 |
116 std::unique_ptr<CPDF_Parser> m_pParser; | 118 std::unique_ptr<CPDF_Parser> m_pParser; |
117 CPDF_Dictionary* m_pRootDict; | 119 CPDF_Dictionary* m_pRootDict; |
118 CPDF_Dictionary* m_pInfoDict; | 120 CPDF_Dictionary* m_pInfoDict; |
119 bool m_bLinearized; | 121 bool m_bLinearized; |
120 int m_iFirstPageNo; | 122 int m_iFirstPageNo; |
121 uint32_t m_dwFirstPageObjNum; | 123 uint32_t m_dwFirstPageObjNum; |
122 CFX_ArrayTemplate<uint32_t> m_PageList; | |
123 // TODO(thestig): Figure out why this cannot be a std::unique_ptr. | 124 // TODO(thestig): Figure out why this cannot be a std::unique_ptr. |
124 CPDF_DocPageData* m_pDocPage; | 125 CPDF_DocPageData* m_pDocPage; |
125 std::unique_ptr<CPDF_DocRenderData> m_pDocRender; | 126 std::unique_ptr<CPDF_DocRenderData> m_pDocRender; |
126 std::unique_ptr<JBig2_DocumentContext> m_pCodecContext; | 127 std::unique_ptr<JBig2_DocumentContext> m_pCodecContext; |
127 std::unique_ptr<CPDF_LinkList> m_pLinksContext; | 128 std::unique_ptr<CPDF_LinkList> m_pLinksContext; |
128 | 129 |
129 private: | 130 private: |
130 void LoadDocInternal(); | 131 void LoadDocInternal(); |
131 size_t CalculateEncodingDict(int charset, CPDF_Dictionary* pBaseDict); | 132 size_t CalculateEncodingDict(int charset, CPDF_Dictionary* pBaseDict); |
132 CPDF_Dictionary* GetPagesDict() const; | 133 CPDF_Dictionary* GetPagesDict() const; |
133 CPDF_Dictionary* ProcessbCJK( | 134 CPDF_Dictionary* ProcessbCJK( |
134 CPDF_Dictionary* pBaseDict, | 135 CPDF_Dictionary* pBaseDict, |
135 int charset, | 136 int charset, |
136 FX_BOOL bVert, | 137 FX_BOOL bVert, |
137 CFX_ByteString basefont, | 138 CFX_ByteString basefont, |
138 std::function<void(FX_WCHAR, FX_WCHAR, CPDF_Array*)> Insert); | 139 std::function<void(FX_WCHAR, FX_WCHAR, CPDF_Array*)> Insert); |
| 140 |
| 141 CFX_ArrayTemplate<uint32_t> m_PageList; |
139 }; | 142 }; |
140 | 143 |
141 #endif // CORE_FPDFAPI_FPDF_PARSER_INCLUDE_CPDF_DOCUMENT_H_ | 144 #endif // CORE_FPDFAPI_FPDF_PARSER_INCLUDE_CPDF_DOCUMENT_H_ |
OLD | NEW |