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_PARSER_CPDF_DOCUMENT_H_ | 7 #ifndef CORE_FPDFAPI_PARSER_CPDF_DOCUMENT_H_ |
8 #define CORE_FPDFAPI_PARSER_CPDF_DOCUMENT_H_ | 8 #define CORE_FPDFAPI_PARSER_CPDF_DOCUMENT_H_ |
9 | 9 |
10 #include <functional> | 10 #include <functional> |
11 #include <memory> | 11 #include <memory> |
| 12 #include <stack> |
12 | 13 |
13 #include "core/fpdfapi/parser/cpdf_indirect_object_holder.h" | 14 #include "core/fpdfapi/parser/cpdf_indirect_object_holder.h" |
14 #include "core/fpdfapi/parser/cpdf_object.h" | 15 #include "core/fpdfapi/parser/cpdf_object.h" |
15 #include "core/fpdfdoc/cpdf_linklist.h" | 16 #include "core/fpdfdoc/cpdf_linklist.h" |
16 #include "core/fxcrt/cfx_string_pool_template.h" | 17 #include "core/fxcrt/cfx_string_pool_template.h" |
17 #include "core/fxcrt/cfx_weak_ptr.h" | 18 #include "core/fxcrt/cfx_weak_ptr.h" |
18 #include "core/fxcrt/fx_basic.h" | 19 #include "core/fxcrt/fx_basic.h" |
19 | 20 |
20 class CFX_Font; | 21 class CFX_Font; |
21 class CFX_Matrix; | 22 class CFX_Matrix; |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 CPDF_Font* AddWindowsFont(LOGFONTW* pLogFont, | 101 CPDF_Font* AddWindowsFont(LOGFONTW* pLogFont, |
101 FX_BOOL bVert, | 102 FX_BOOL bVert, |
102 FX_BOOL bTranslateName = FALSE); | 103 FX_BOOL bTranslateName = FALSE); |
103 #endif | 104 #endif |
104 | 105 |
105 private: | 106 private: |
106 friend class CPDF_TestDocument; | 107 friend class CPDF_TestDocument; |
107 | 108 |
108 // Retrieve page count information by getting count value from the tree nodes | 109 // Retrieve page count information by getting count value from the tree nodes |
109 int RetrievePageCount() const; | 110 int RetrievePageCount() const; |
110 CPDF_Dictionary* FindPDFPage(CPDF_Dictionary* pPages, | 111 CPDF_Dictionary* TraversePDFPages(int iPage, int nPagesToGo); |
111 int iPage, | |
112 int nPagesToGo, | |
113 int level); | |
114 int FindPageIndex(CPDF_Dictionary* pNode, | 112 int FindPageIndex(CPDF_Dictionary* pNode, |
115 uint32_t& skip_count, | 113 uint32_t& skip_count, |
116 uint32_t objnum, | 114 uint32_t objnum, |
117 int& index, | 115 int& index, |
118 int level = 0); | 116 int level = 0); |
119 CPDF_Object* ParseIndirectObject(uint32_t objnum) override; | 117 CPDF_Object* ParseIndirectObject(uint32_t objnum) override; |
120 void LoadDocInternal(); | 118 void LoadDocInternal(); |
121 size_t CalculateEncodingDict(int charset, CPDF_Dictionary* pBaseDict); | 119 size_t CalculateEncodingDict(int charset, CPDF_Dictionary* pBaseDict); |
122 CPDF_Dictionary* GetPagesDict() const; | 120 CPDF_Dictionary* GetPagesDict() const; |
123 CPDF_Dictionary* ProcessbCJK( | 121 CPDF_Dictionary* ProcessbCJK( |
124 CPDF_Dictionary* pBaseDict, | 122 CPDF_Dictionary* pBaseDict, |
125 int charset, | 123 int charset, |
126 FX_BOOL bVert, | 124 FX_BOOL bVert, |
127 CFX_ByteString basefont, | 125 CFX_ByteString basefont, |
128 std::function<void(FX_WCHAR, FX_WCHAR, CPDF_Array*)> Insert); | 126 std::function<void(FX_WCHAR, FX_WCHAR, CPDF_Array*)> Insert); |
129 | 127 int InsertDeletePDFPage(CPDF_Dictionary* pPages, |
| 128 int nPagesToGo, |
| 129 CPDF_Dictionary* pPage, |
| 130 FX_BOOL bInsert, |
| 131 std::set<CPDF_Dictionary*>* pVisited); |
| 132 int InsertNewPage(int iPage, |
| 133 CPDF_Dictionary* pPageDict, |
| 134 CFX_ArrayTemplate<uint32_t>& pageList); |
130 std::unique_ptr<CPDF_Parser> m_pParser; | 135 std::unique_ptr<CPDF_Parser> m_pParser; |
131 CPDF_Dictionary* m_pRootDict; | 136 CPDF_Dictionary* m_pRootDict; |
132 CPDF_Dictionary* m_pInfoDict; | 137 CPDF_Dictionary* m_pInfoDict; |
| 138 std::stack<std::pair<CPDF_Dictionary*, int>> m_pTreeTraversal; |
| 139 int m_iLastPageTraversed; |
133 bool m_bLinearized; | 140 bool m_bLinearized; |
134 int m_iFirstPageNo; | 141 int m_iFirstPageNo; |
135 uint32_t m_dwFirstPageObjNum; | 142 uint32_t m_dwFirstPageObjNum; |
136 // TODO(thestig): Figure out why this cannot be a std::unique_ptr. | 143 // TODO(thestig): Figure out why this cannot be a std::unique_ptr. |
137 CPDF_DocPageData* m_pDocPage; | 144 CPDF_DocPageData* m_pDocPage; |
138 std::unique_ptr<CPDF_DocRenderData> m_pDocRender; | 145 std::unique_ptr<CPDF_DocRenderData> m_pDocRender; |
139 std::unique_ptr<JBig2_DocumentContext> m_pCodecContext; | 146 std::unique_ptr<JBig2_DocumentContext> m_pCodecContext; |
140 std::unique_ptr<CPDF_LinkList> m_pLinksContext; | 147 std::unique_ptr<CPDF_LinkList> m_pLinksContext; |
141 CFX_ArrayTemplate<uint32_t> m_PageList; | 148 CFX_ArrayTemplate<uint32_t> m_PageList; |
142 CFX_WeakPtr<CFX_ByteStringPool> m_pByteStringPool; | 149 CFX_WeakPtr<CFX_ByteStringPool> m_pByteStringPool; |
143 }; | 150 }; |
144 | 151 |
145 #endif // CORE_FPDFAPI_PARSER_CPDF_DOCUMENT_H_ | 152 #endif // CORE_FPDFAPI_PARSER_CPDF_DOCUMENT_H_ |
OLD | NEW |