OLD | NEW |
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 #ifndef CORE_INCLUDE_FPDFAPI_FPDF_PAGE_H_ | 7 #ifndef CORE_INCLUDE_FPDFAPI_FPDF_PAGE_H_ |
8 #define CORE_INCLUDE_FPDFAPI_FPDF_PAGE_H_ | 8 #define CORE_INCLUDE_FPDFAPI_FPDF_PAGE_H_ |
9 | 9 |
| 10 #include <memory> |
| 11 |
| 12 #include "core/include/fpdfapi/fpdf_parser.h" |
| 13 #include "core/include/fpdfapi/fpdf_resource.h" |
10 #include "core/include/fxge/fx_dib.h" | 14 #include "core/include/fxge/fx_dib.h" |
11 #include "fpdf_parser.h" | |
12 #include "fpdf_resource.h" | |
13 | 15 |
14 class CPDF_PageObjects; | |
15 class CPDF_Page; | 16 class CPDF_Page; |
16 class CPDF_Form; | 17 class CPDF_Form; |
17 class CPDF_ParseOptions; | 18 class CPDF_ParseOptions; |
18 class CPDF_PageObject; | 19 class CPDF_PageObject; |
19 class CPDF_PageRenderCache; | 20 class CPDF_PageRenderCache; |
20 class CPDF_StreamFilter; | 21 class CPDF_StreamFilter; |
21 class CPDF_AllStates; | 22 class CPDF_AllStates; |
22 class CPDF_ContentParser; | 23 class CPDF_ContentParser; |
23 class CPDF_StreamContentParser; | 24 class CPDF_StreamContentParser; |
24 #define PDFTRANS_GROUP 0x0100 | 25 #define PDFTRANS_GROUP 0x0100 |
25 #define PDFTRANS_ISOLATED 0x0200 | 26 #define PDFTRANS_ISOLATED 0x0200 |
26 #define PDFTRANS_KNOCKOUT 0x0400 | 27 #define PDFTRANS_KNOCKOUT 0x0400 |
27 | 28 |
28 class CPDF_PageObjects { | 29 class CPDF_PageObjects { |
29 public: | 30 public: |
30 CPDF_PageObjects(FX_BOOL bReleaseMembers = TRUE); | 31 CPDF_PageObjects(); |
31 ~CPDF_PageObjects(); | 32 ~CPDF_PageObjects(); |
32 | 33 |
33 void ContinueParse(IFX_Pause* pPause); | 34 void ContinueParse(IFX_Pause* pPause); |
34 | 35 |
35 FX_BOOL IsParsed() const { return m_ParseState == CONTENT_PARSED; } | 36 FX_BOOL IsParsed() const { return m_ParseState == CONTENT_PARSED; } |
36 | 37 |
37 FX_POSITION GetFirstObjectPosition() const { | 38 FX_POSITION GetFirstObjectPosition() const { |
38 return m_ObjectList.GetHeadPosition(); | 39 return m_ObjectList.GetHeadPosition(); |
39 } | 40 } |
40 | 41 |
41 FX_POSITION GetLastObjectPosition() const { | 42 FX_POSITION GetLastObjectPosition() const { |
42 return m_ObjectList.GetTailPosition(); | 43 return m_ObjectList.GetTailPosition(); |
43 } | 44 } |
44 | 45 |
45 CPDF_PageObject* GetNextObject(FX_POSITION& pos) const { | 46 CPDF_PageObject* GetNextObject(FX_POSITION& pos) const { |
46 return (CPDF_PageObject*)m_ObjectList.GetNext(pos); | 47 return (CPDF_PageObject*)m_ObjectList.GetNext(pos); |
47 } | 48 } |
48 | 49 |
49 CPDF_PageObject* GetPrevObject(FX_POSITION& pos) const { | 50 CPDF_PageObject* GetPrevObject(FX_POSITION& pos) const { |
50 return (CPDF_PageObject*)m_ObjectList.GetPrev(pos); | 51 return (CPDF_PageObject*)m_ObjectList.GetPrev(pos); |
51 } | 52 } |
52 | 53 |
53 CPDF_PageObject* GetObjectAt(FX_POSITION pos) const { | 54 CPDF_PageObject* GetObjectAt(FX_POSITION pos) const { |
54 return (CPDF_PageObject*)m_ObjectList.GetAt(pos); | 55 return (CPDF_PageObject*)m_ObjectList.GetAt(pos); |
55 } | 56 } |
56 | 57 |
| 58 void AddTail(CPDF_PageObject* obj) { m_ObjectList.AddTail(obj); } |
57 FX_DWORD CountObjects() const { return m_ObjectList.GetCount(); } | 59 FX_DWORD CountObjects() const { return m_ObjectList.GetCount(); } |
58 | 60 |
59 int GetObjectIndex(CPDF_PageObject* pObj) const; | 61 int GetObjectIndex(CPDF_PageObject* pObj) const; |
60 | 62 |
61 CPDF_PageObject* GetObjectByIndex(int index) const; | 63 CPDF_PageObject* GetObjectByIndex(int index) const; |
62 | 64 |
63 FX_POSITION InsertObject(FX_POSITION posInsertAfter, | 65 FX_POSITION InsertObject(FX_POSITION posInsertAfter, |
64 CPDF_PageObject* pNewObject); | 66 CPDF_PageObject* pNewObject); |
65 | 67 |
66 void Transform(const CFX_Matrix& matrix); | 68 void Transform(const CFX_Matrix& matrix); |
67 | 69 |
68 FX_BOOL BackgroundAlphaNeeded() const { return m_bBackgroundAlphaNeeded; } | 70 FX_BOOL BackgroundAlphaNeeded() const { return m_bBackgroundAlphaNeeded; } |
| 71 void SetBackgroundAlphaNeeded(FX_BOOL needed) { |
| 72 m_bBackgroundAlphaNeeded = needed; |
| 73 } |
69 | 74 |
70 FX_BOOL HasImageMask() const { return m_bHasImageMask; } | 75 FX_BOOL HasImageMask() const { return m_bHasImageMask; } |
71 | 76 void SetHasImageMask(FX_BOOL value) { m_bHasImageMask = value; } |
72 CFX_FloatRect CalcBoundingBox() const; | 77 CFX_FloatRect CalcBoundingBox() const; |
73 | 78 |
74 CPDF_Dictionary* m_pFormDict; | 79 CPDF_Dictionary* m_pFormDict; |
75 CPDF_Stream* m_pFormStream; | 80 CPDF_Stream* m_pFormStream; |
76 CPDF_Document* m_pDocument; | 81 CPDF_Document* m_pDocument; |
77 CPDF_Dictionary* m_pPageResources; | 82 CPDF_Dictionary* m_pPageResources; |
78 CPDF_Dictionary* m_pResources; | 83 CPDF_Dictionary* m_pResources; |
79 CFX_FloatRect m_BBox; | 84 CFX_FloatRect m_BBox; |
80 int m_Transparency; | 85 int m_Transparency; |
81 | 86 |
82 protected: | 87 protected: |
83 friend class CPDF_ContentParser; | |
84 friend class CPDF_StreamContentParser; | |
85 friend class CPDF_AllStates; | |
86 | |
87 enum ParseState { CONTENT_NOT_PARSED, CONTENT_PARSING, CONTENT_PARSED }; | 88 enum ParseState { CONTENT_NOT_PARSED, CONTENT_PARSING, CONTENT_PARSED }; |
88 | 89 |
89 void LoadTransInfo(); | 90 void LoadTransInfo(); |
90 void ClearCacheObjects(); | |
91 | 91 |
92 CFX_PtrList m_ObjectList; | |
93 FX_BOOL m_bBackgroundAlphaNeeded; | 92 FX_BOOL m_bBackgroundAlphaNeeded; |
94 FX_BOOL m_bHasImageMask; | 93 FX_BOOL m_bHasImageMask; |
95 FX_BOOL m_bReleaseMembers; | |
96 CPDF_ContentParser* m_pParser; | |
97 ParseState m_ParseState; | 94 ParseState m_ParseState; |
| 95 std::unique_ptr<CPDF_ContentParser> m_pParser; |
| 96 CFX_PtrList m_ObjectList; |
98 }; | 97 }; |
99 | 98 |
100 class CPDF_Page : public CPDF_PageObjects, public CFX_PrivateData { | 99 class CPDF_Page : public CPDF_PageObjects, public CFX_PrivateData { |
101 public: | 100 public: |
102 CPDF_Page(); | 101 CPDF_Page(); |
103 ~CPDF_Page(); | 102 ~CPDF_Page(); |
104 | 103 |
105 void Load(CPDF_Document* pDocument, | 104 void Load(CPDF_Document* pDocument, |
106 CPDF_Dictionary* pPageDict, | 105 CPDF_Dictionary* pPageDict, |
107 FX_BOOL bPageCache = TRUE); | 106 FX_BOOL bPageCache = TRUE); |
108 | 107 |
109 void StartParse(CPDF_ParseOptions* pOptions = NULL, FX_BOOL bReParse = FALSE); | 108 void ParseContent(CPDF_ParseOptions* pOptions); |
110 void ParseContent(CPDF_ParseOptions* pOptions = NULL, | |
111 FX_BOOL bReParse = FALSE); | |
112 | 109 |
113 void GetDisplayMatrix(CFX_Matrix& matrix, | 110 void GetDisplayMatrix(CFX_Matrix& matrix, |
114 int xPos, | 111 int xPos, |
115 int yPos, | 112 int yPos, |
116 int xSize, | 113 int xSize, |
117 int ySize, | 114 int ySize, |
118 int iRotate) const; | 115 int iRotate) const; |
119 | 116 |
120 FX_FLOAT GetPageWidth() const { return m_PageWidth; } | 117 FX_FLOAT GetPageWidth() const { return m_PageWidth; } |
121 FX_FLOAT GetPageHeight() const { return m_PageHeight; } | 118 FX_FLOAT GetPageHeight() const { return m_PageHeight; } |
122 CFX_FloatRect GetPageBBox() const { return m_BBox; } | 119 CFX_FloatRect GetPageBBox() const { return m_BBox; } |
123 const CFX_Matrix& GetPageMatrix() const { return m_PageMatrix; } | 120 const CFX_Matrix& GetPageMatrix() const { return m_PageMatrix; } |
124 CPDF_Object* GetPageAttr(const CFX_ByteStringC& name) const; | 121 CPDF_Object* GetPageAttr(const CFX_ByteStringC& name) const; |
125 CPDF_PageRenderCache* GetRenderCache() const { return m_pPageRender; } | 122 CPDF_PageRenderCache* GetRenderCache() const { return m_pPageRender; } |
126 | 123 |
127 protected: | 124 protected: |
128 friend class CPDF_ContentParser; | 125 friend class CPDF_ContentParser; |
| 126 void StartParse(CPDF_ParseOptions* pOptions); |
| 127 |
129 FX_FLOAT m_PageWidth; | 128 FX_FLOAT m_PageWidth; |
130 FX_FLOAT m_PageHeight; | 129 FX_FLOAT m_PageHeight; |
131 CFX_Matrix m_PageMatrix; | 130 CFX_Matrix m_PageMatrix; |
132 CPDF_PageRenderCache* m_pPageRender; | 131 CPDF_PageRenderCache* m_pPageRender; |
133 }; | 132 }; |
134 class CPDF_ParseOptions { | 133 class CPDF_ParseOptions { |
135 public: | 134 public: |
136 CPDF_ParseOptions(); | 135 CPDF_ParseOptions(); |
137 | 136 |
138 FX_BOOL m_bTextOnly; | 137 FX_BOOL m_bTextOnly; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 CFX_Matrix& matrix); | 181 CFX_Matrix& matrix); |
183 CFX_ByteString RealizeResource(CPDF_Object* pResourceObj, | 182 CFX_ByteString RealizeResource(CPDF_Object* pResourceObj, |
184 const FX_CHAR* szType); | 183 const FX_CHAR* szType); |
185 | 184 |
186 CPDF_Page* m_pPage; | 185 CPDF_Page* m_pPage; |
187 CPDF_Document* m_pDocument; | 186 CPDF_Document* m_pDocument; |
188 CFX_ArrayTemplate<CPDF_PageObject*> m_pageObjects; | 187 CFX_ArrayTemplate<CPDF_PageObject*> m_pageObjects; |
189 }; | 188 }; |
190 | 189 |
191 #endif // CORE_INCLUDE_FPDFAPI_FPDF_PAGE_H_ | 190 #endif // CORE_INCLUDE_FPDFAPI_FPDF_PAGE_H_ |
OLD | NEW |