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 _FPDF_PAGE_ | 7 #ifndef _FPDF_PAGE_ |
8 #define _FPDF_PAGE_ | 8 #define _FPDF_PAGE_ |
9 #ifndef _FPDF_PARSER_ | 9 #ifndef _FPDF_PARSER_ |
10 #include "fpdf_parser.h" | 10 #include "fpdf_parser.h" |
11 #endif | 11 #endif |
12 #ifndef _FPDF_RESOURCE_ | 12 #ifndef _FPDF_RESOURCE_ |
13 #include "fpdf_resource.h" | 13 #include "fpdf_resource.h" |
14 #endif | 14 #endif |
15 #ifndef _FX_DIB_H_ | 15 #ifndef _FX_DIB_H_ |
16 #include "../fxge/fx_dib.h" | 16 #include "../fxge/fx_dib.h" |
17 #endif | 17 #endif |
18 class CPDF_PageObjects; | 18 class CPDF_PageObjects; |
19 class CPDF_Page; | 19 class CPDF_Page; |
20 class CPDF_Form; | 20 class CPDF_Form; |
21 class CPDF_ParseOptions; | 21 class CPDF_ParseOptions; |
22 class CPDF_PageObject; | 22 class CPDF_PageObject; |
23 class CPDF_PageRenderCache; | 23 class CPDF_PageRenderCache; |
24 class CPDF_StreamFilter; | 24 class CPDF_StreamFilter; |
25 class CPDF_AllStates; | 25 class CPDF_AllStates; |
26 class CPDF_ContentParser; | 26 class CPDF_ContentParser; |
27 class CPDF_StreamContentParser; | 27 class CPDF_StreamContentParser; |
28 class CPDF_ResourceNaming; | 28 class CPDF_ResourceNaming; |
29 #define PDFTRANS_GROUP» » » 0x0100 | 29 #define PDFTRANS_GROUP 0x0100 |
30 #define PDFTRANS_ISOLATED» » 0x0200 | 30 #define PDFTRANS_ISOLATED 0x0200 |
31 #define PDFTRANS_KNOCKOUT» » 0x0400 | 31 #define PDFTRANS_KNOCKOUT 0x0400 |
32 #define PDF_CONTENT_NOT_PARSED» 0 | 32 #define PDF_CONTENT_NOT_PARSED 0 |
33 #define PDF_CONTENT_PARSING» » 1 | 33 #define PDF_CONTENT_PARSING 1 |
34 #define PDF_CONTENT_PARSED» » 2 | 34 #define PDF_CONTENT_PARSED 2 |
35 class CPDF_PageObjects : public CFX_Object | 35 class CPDF_PageObjects : public CFX_Object { |
36 { | 36 public: |
37 public: | 37 CPDF_PageObjects(FX_BOOL bReleaseMembers = TRUE); |
38 | 38 |
39 CPDF_PageObjects(FX_BOOL bReleaseMembers = TRUE); | 39 ~CPDF_PageObjects(); |
40 | 40 |
41 ~CPDF_PageObjects(); | 41 void ContinueParse(IFX_Pause* pPause); |
42 | 42 |
| 43 int GetParseState() const { return m_ParseState; } |
43 | 44 |
| 45 FX_BOOL IsParsed() const { return m_ParseState == PDF_CONTENT_PARSED; } |
44 | 46 |
| 47 int EstimateParseProgress() const; |
45 | 48 |
46 void» » » » ContinueParse(IFX_Pause* pPause); | 49 FX_POSITION GetFirstObjectPosition() const { |
| 50 return m_ObjectList.GetHeadPosition(); |
| 51 } |
47 | 52 |
48 int»» » » » GetParseState() const | 53 FX_POSITION GetLastObjectPosition() const { |
49 { | 54 return m_ObjectList.GetTailPosition(); |
50 return m_ParseState; | 55 } |
51 } | |
52 | 56 |
53 FX_BOOL» » » » IsParsed() const | 57 CPDF_PageObject* GetNextObject(FX_POSITION& pos) const { |
54 { | 58 return (CPDF_PageObject*)m_ObjectList.GetNext(pos); |
55 return m_ParseState == PDF_CONTENT_PARSED; | 59 } |
56 } | |
57 | 60 |
58 int»» » » » EstimateParseProgress() const; | 61 CPDF_PageObject* GetPrevObject(FX_POSITION& pos) const { |
| 62 return (CPDF_PageObject*)m_ObjectList.GetPrev(pos); |
| 63 } |
59 | 64 |
| 65 CPDF_PageObject* GetObjectAt(FX_POSITION pos) const { |
| 66 return (CPDF_PageObject*)m_ObjectList.GetAt(pos); |
| 67 } |
60 | 68 |
| 69 FX_DWORD CountObjects() const { return m_ObjectList.GetCount(); } |
61 | 70 |
| 71 int GetObjectIndex(CPDF_PageObject* pObj) const; |
62 | 72 |
63 FX_POSITION»» » GetFirstObjectPosition() const | 73 CPDF_PageObject* GetObjectByIndex(int index) const; |
64 { | |
65 return m_ObjectList.GetHeadPosition(); | |
66 } | |
67 | 74 |
68 FX_POSITION»» » GetLastObjectPosition() const | 75 FX_POSITION InsertObject(FX_POSITION posInsertAfter, |
69 { | 76 CPDF_PageObject* pNewObject); |
70 return m_ObjectList.GetTailPosition(); | |
71 } | |
72 | 77 |
73 CPDF_PageObject*» GetNextObject(FX_POSITION& pos) const | 78 void Transform(const CFX_AffineMatrix& matrix); |
74 { | |
75 return (CPDF_PageObject*)m_ObjectList.GetNext(pos); | |
76 } | |
77 | 79 |
78 CPDF_PageObject*» GetPrevObject(FX_POSITION& pos) const | 80 FX_BOOL BackgroundAlphaNeeded() const { return m_bBackgroundAlphaNeeded; } |
79 { | |
80 return (CPDF_PageObject*)m_ObjectList.GetPrev(pos); | |
81 } | |
82 | 81 |
83 CPDF_PageObject*» GetObjectAt(FX_POSITION pos) const | 82 CFX_FloatRect CalcBoundingBox() const; |
84 { | |
85 return (CPDF_PageObject*)m_ObjectList.GetAt(pos); | |
86 } | |
87 | 83 |
88 FX_DWORD» » » CountObjects() const | 84 CPDF_Dictionary* m_pFormDict; |
89 { | |
90 return m_ObjectList.GetCount(); | |
91 } | |
92 | 85 |
93 int»» » » » GetObjectIndex(CPDF_PageObject* pObj) co
nst; | 86 CPDF_Stream* m_pFormStream; |
94 | 87 |
95 CPDF_PageObject*» GetObjectByIndex(int index) const; | 88 CPDF_Document* m_pDocument; |
96 | 89 |
| 90 CPDF_Dictionary* m_pPageResources; |
97 | 91 |
| 92 CPDF_Dictionary* m_pResources; |
98 | 93 |
| 94 CFX_FloatRect m_BBox; |
99 | 95 |
| 96 int m_Transparency; |
100 | 97 |
101 FX_POSITION»» » InsertObject(FX_POSITION posInsertAfter, CPDF_Pa
geObject* pNewObject); | 98 protected: |
| 99 friend class CPDF_ContentParser; |
| 100 friend class CPDF_StreamContentParser; |
| 101 friend class CPDF_AllStates; |
102 | 102 |
103 void» » » » Transform(const CFX_AffineMatrix& matrix
); | 103 CFX_PtrList m_ObjectList; |
104 | 104 |
105 FX_BOOL» » » » BackgroundAlphaNeeded() const | 105 FX_BOOL m_bBackgroundAlphaNeeded; |
106 { | |
107 return m_bBackgroundAlphaNeeded; | |
108 } | |
109 | 106 |
110 CFX_FloatRect» » CalcBoundingBox() const; | 107 FX_BOOL m_bReleaseMembers; |
| 108 void LoadTransInfo(); |
| 109 void ClearCacheObjects(); |
111 | 110 |
112 CPDF_Dictionary*» m_pFormDict; | 111 CPDF_ContentParser* m_pParser; |
113 | 112 |
114 CPDF_Stream*» » m_pFormStream; | 113 FX_BOOL m_ParseState; |
| 114 }; |
| 115 class CPDF_Page : public CPDF_PageObjects, public CFX_PrivateData { |
| 116 public: |
| 117 CPDF_Page(); |
115 | 118 |
116 CPDF_Document*» » m_pDocument; | 119 ~CPDF_Page(); |
117 | 120 |
118 CPDF_Dictionary*» m_pPageResources; | 121 void Load(CPDF_Document* pDocument, |
| 122 CPDF_Dictionary* pPageDict, |
| 123 FX_BOOL bPageCache = TRUE); |
119 | 124 |
120 CPDF_Dictionary*» m_pResources; | 125 void StartParse(CPDF_ParseOptions* pOptions = NULL, FX_BOOL bReParse = FALSE); |
121 | 126 |
122 CFX_FloatRect» » m_BBox; | 127 void ParseContent(CPDF_ParseOptions* pOptions = NULL, |
| 128 FX_BOOL bReParse = FALSE); |
123 | 129 |
124 int»» » » » m_Transparency; | 130 void GetDisplayMatrix(CFX_AffineMatrix& matrix, |
| 131 int xPos, |
| 132 int yPos, |
| 133 int xSize, |
| 134 int ySize, |
| 135 int iRotate) const; |
125 | 136 |
126 protected: | 137 FX_FLOAT GetPageWidth() const { return m_PageWidth; } |
127 friend class» » CPDF_ContentParser; | |
128 friend class» » CPDF_StreamContentParser; | |
129 friend class» » CPDF_AllStates; | |
130 | 138 |
131 CFX_PtrList»» » m_ObjectList; | 139 FX_FLOAT GetPageHeight() const { return m_PageHeight; } |
132 | 140 |
133 FX_BOOL» » » » m_bBackgroundAlphaNeeded; | 141 CFX_FloatRect GetPageBBox() const { return m_BBox; } |
134 | 142 |
135 FX_BOOL» » » » m_bReleaseMembers; | 143 const CFX_AffineMatrix& GetPageMatrix() const { return m_PageMatrix; } |
136 void» » » » LoadTransInfo(); | |
137 void ClearCacheObjects(); | |
138 | 144 |
139 CPDF_ContentParser*»m_pParser; | 145 CPDF_Object* GetPageAttr(FX_BSTR name) const; |
140 | 146 |
141 FX_BOOL» » » » m_ParseState; | 147 CPDF_PageRenderCache* GetRenderCache() const { return m_pPageRender; } |
| 148 |
| 149 void ClearRenderCache(); |
| 150 |
| 151 protected: |
| 152 friend class CPDF_ContentParser; |
| 153 |
| 154 FX_FLOAT m_PageWidth; |
| 155 |
| 156 FX_FLOAT m_PageHeight; |
| 157 |
| 158 CFX_AffineMatrix m_PageMatrix; |
| 159 |
| 160 CPDF_PageRenderCache* m_pPageRender; |
142 }; | 161 }; |
143 class CPDF_Page : public CPDF_PageObjects, public CFX_PrivateData | 162 class CPDF_ParseOptions : public CFX_Object { |
144 { | 163 public: |
145 public: | 164 CPDF_ParseOptions(); |
146 | 165 |
147 CPDF_Page(); | 166 FX_BOOL m_bTextOnly; |
148 | 167 |
149 ~CPDF_Page(); | 168 FX_BOOL m_bMarkedContent; |
150 | 169 |
151 void» » » » Load(CPDF_Document* pDocument, CPDF_Dict
ionary* pPageDict, FX_BOOL bPageCache = TRUE); | 170 FX_BOOL m_bSeparateForm; |
152 | 171 |
153 void» » » » StartParse(CPDF_ParseOptions* pOptions =
NULL, FX_BOOL bReParse = FALSE); | 172 FX_BOOL m_bDecodeInlineImage; |
| 173 }; |
| 174 class CPDF_Form : public CPDF_PageObjects { |
| 175 public: |
| 176 CPDF_Form(CPDF_Document* pDocument, |
| 177 CPDF_Dictionary* pPageResources, |
| 178 CPDF_Stream* pFormStream, |
| 179 CPDF_Dictionary* pParentResources = NULL); |
154 | 180 |
155 void» » » » ParseContent(CPDF_ParseOptions* pOptions
= NULL, FX_BOOL bReParse = FALSE); | 181 ~CPDF_Form(); |
156 | 182 |
157 void» » » » GetDisplayMatrix(CFX_AffineMatrix& matri
x, int xPos, int yPos, | 183 void StartParse(CPDF_AllStates* pGraphicStates, |
158 int xSize, int ySize, int iRotate) cons
t; | 184 CFX_AffineMatrix* pParentMatrix, |
| 185 CPDF_Type3Char* pType3Char, |
| 186 CPDF_ParseOptions* pOptions, |
| 187 int level = 0); |
159 | 188 |
160 FX_FLOAT» » » GetPageWidth() const | 189 void ParseContent(CPDF_AllStates* pGraphicStates, |
161 { | 190 CFX_AffineMatrix* pParentMatrix, |
162 return m_PageWidth; | 191 CPDF_Type3Char* pType3Char, |
163 } | 192 CPDF_ParseOptions* pOptions, |
| 193 int level = 0); |
164 | 194 |
165 FX_FLOAT» » » GetPageHeight() const | 195 CPDF_Form* Clone() const; |
166 { | 196 }; |
167 return m_PageHeight; | 197 class CPDF_PageContentGenerate : public CFX_Object { |
168 } | 198 public: |
| 199 CPDF_PageContentGenerate(CPDF_Page* pPage); |
| 200 ~CPDF_PageContentGenerate(); |
| 201 FX_BOOL InsertPageObject(CPDF_PageObject* pPageObject); |
| 202 void GenerateContent(); |
| 203 void TransformContent(CFX_Matrix& matrix); |
169 | 204 |
170 CFX_FloatRect» » GetPageBBox() const | 205 protected: |
171 { | 206 void ProcessImage(CFX_ByteTextBuf& buf, CPDF_ImageObject* pImageObj); |
172 return m_BBox; | 207 void ProcessForm(CFX_ByteTextBuf& buf, |
173 } | 208 FX_LPCBYTE data, |
| 209 FX_DWORD size, |
| 210 CFX_Matrix& matrix); |
| 211 CFX_ByteString RealizeResource(CPDF_Object* pResourceObj, |
| 212 const FX_CHAR* szType); |
174 | 213 |
175 const CFX_AffineMatrix&» GetPageMatrix() const | 214 private: |
176 { | 215 CPDF_Page* m_pPage; |
177 return m_PageMatrix; | 216 CPDF_Document* m_pDocument; |
178 } | 217 CFX_PtrArray m_pageObjects; |
179 | |
180 CPDF_Object*» » GetPageAttr(FX_BSTR name) const; | |
181 | |
182 | |
183 | |
184 CPDF_PageRenderCache*» GetRenderCache() const | |
185 { | |
186 return m_pPageRender; | |
187 } | |
188 | |
189 void» » » » ClearRenderCache(); | |
190 | |
191 protected: | |
192 friend class» » CPDF_ContentParser; | |
193 | |
194 FX_FLOAT» » » m_PageWidth; | |
195 | |
196 FX_FLOAT» » » m_PageHeight; | |
197 | |
198 CFX_AffineMatrix» m_PageMatrix; | |
199 | |
200 CPDF_PageRenderCache*» m_pPageRender; | |
201 }; | |
202 class CPDF_ParseOptions : public CFX_Object | |
203 { | |
204 public: | |
205 | |
206 CPDF_ParseOptions(); | |
207 | |
208 FX_BOOL» » » » m_bTextOnly; | |
209 | |
210 FX_BOOL» » » » m_bMarkedContent; | |
211 | |
212 FX_BOOL» » » » m_bSeparateForm; | |
213 | |
214 FX_BOOL» » » » m_bDecodeInlineImage; | |
215 }; | |
216 class CPDF_Form : public CPDF_PageObjects | |
217 { | |
218 public: | |
219 | |
220 CPDF_Form(CPDF_Document* pDocument, CPDF_Dictionary* pPageResources, CPDF_St
ream* pFormStream, CPDF_Dictionary* pParentResources = NULL); | |
221 | |
222 ~CPDF_Form(); | |
223 | |
224 void» » » » StartParse(CPDF_AllStates* pGraphicState
s, CFX_AffineMatrix* pParentMatrix, | |
225 CPDF_Type3Char* pType3Char, CPDF_ParseOptions
* pOptions, int level = 0); | |
226 | |
227 void» » » » ParseContent(CPDF_AllStates* pGraphicSta
tes, CFX_AffineMatrix* pParentMatrix, | |
228 CPDF_Type3Char* pType3Char, CPDF_ParseOptio
ns* pOptions, int level = 0); | |
229 | |
230 CPDF_Form*» » » Clone() const; | |
231 }; | |
232 class CPDF_PageContentGenerate : public CFX_Object | |
233 { | |
234 public: | |
235 CPDF_PageContentGenerate(CPDF_Page* pPage); | |
236 ~CPDF_PageContentGenerate(); | |
237 FX_BOOL InsertPageObject(CPDF_PageObject* pPageObject); | |
238 void GenerateContent(); | |
239 void TransformContent(CFX_Matrix& matrix); | |
240 protected: | |
241 void ProcessImage(CFX_ByteTextBuf& buf, CPDF_ImageObject* pImageO
bj); | |
242 void ProcessForm(CFX_ByteTextBuf& buf, FX_LPCBYTE data, FX_DWORD
size, CFX_Matrix& matrix); | |
243 CFX_ByteString RealizeResource(CPDF_Object* pResourceObj, const FX_CHAR* sz
Type); | |
244 private: | |
245 CPDF_Page* m_pPage; | |
246 CPDF_Document* m_pDocument; | |
247 CFX_PtrArray m_pageObjects; | |
248 }; | 218 }; |
249 #endif | 219 #endif |
OLD | NEW |