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_SRC_FPDFAPI_FPDF_PAGE_PAGEINT_H_ | 7 #ifndef CORE_SRC_FPDFAPI_FPDF_PAGE_PAGEINT_H_ |
8 #define CORE_SRC_FPDFAPI_FPDF_PAGE_PAGEINT_H_ | 8 #define CORE_SRC_FPDFAPI_FPDF_PAGE_PAGEINT_H_ |
9 | 9 |
10 #include <map> | 10 #include <map> |
11 | 11 |
| 12 #include "../../../../third_party/base/nonstd_unique_ptr.h" |
12 #include "../../../include/fpdfapi/fpdf_pageobj.h" | 13 #include "../../../include/fpdfapi/fpdf_pageobj.h" |
13 | 14 |
14 #define PARSE_STEP_LIMIT 100 | 15 #define PARSE_STEP_LIMIT 100 |
15 | 16 |
16 class CPDF_StreamParser | 17 class CPDF_StreamParser |
17 { | 18 { |
18 public: | 19 public: |
19 | 20 |
20 CPDF_StreamParser(const uint8_t* pData, FX_DWORD dwSize); | 21 CPDF_StreamParser(const uint8_t* pData, FX_DWORD dwSize); |
21 ~CPDF_StreamParser(); | 22 ~CPDF_StreamParser(); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 char m_Buffer[32]; | 117 char m_Buffer[32]; |
117 } m_Name; | 118 } m_Name; |
118 }; | 119 }; |
119 } _ContentParam; | 120 } _ContentParam; |
120 #define _FPDF_MAX_FORM_LEVEL_ 30 | 121 #define _FPDF_MAX_FORM_LEVEL_ 30 |
121 #define _FPDF_MAX_TYPE3_FORM_LEVEL_ 4 | 122 #define _FPDF_MAX_TYPE3_FORM_LEVEL_ 4 |
122 #define _FPDF_MAX_OBJECT_STACK_SIZE_ 512 | 123 #define _FPDF_MAX_OBJECT_STACK_SIZE_ 512 |
123 class CPDF_StreamContentParser | 124 class CPDF_StreamContentParser |
124 { | 125 { |
125 public: | 126 public: |
126 CPDF_StreamContentParser(); | 127 CPDF_StreamContentParser( |
| 128 CPDF_Document* pDoc, |
| 129 CPDF_Dictionary* pPageResources, |
| 130 CPDF_Dictionary* pParentResources, |
| 131 CFX_AffineMatrix* pmtContentToUser, |
| 132 CPDF_PageObjects* pObjList, |
| 133 CPDF_Dictionary* pResources, |
| 134 CFX_FloatRect* pBBox, |
| 135 CPDF_ParseOptions* pOptions, |
| 136 CPDF_AllStates* pAllStates, |
| 137 int level); |
127 ~CPDF_StreamContentParser(); | 138 ~CPDF_StreamContentParser(); |
128 FX_BOOL Initialize(); | 139 |
129 void» PrepareParse(CPDF_Document* pDoc, CPDF_Dictionary* pPageResource
s, CPDF_Dictionary* pParentResources, | 140 FX_BOOL ShouldAbort() const { return m_bAbort; } |
130 CFX_AffineMatrix* pmtContentToUser, | 141 CPDF_PageObjects* GetObjectList() const { return m_pObjectList; } |
131 CPDF_PageObjects* pObjList, CPDF_Dictionary* pResources
, | 142 CPDF_AllStates* GetCurStates() const { return m_pCurStates.get(); } |
132 CFX_FloatRect* pBBox, CPDF_ParseOptions* pOptions, | 143 FX_BOOL IsColored() const { return m_bColored; } |
133 CPDF_AllStates* pAllStates, int level); | 144 const FX_FLOAT* GetType3Data() const { return m_Type3Data; } |
134 CPDF_Document*» » m_pDocument; | 145 |
135 CPDF_Dictionary*» m_pPageResources; | |
136 CPDF_Dictionary*» m_pParentResources; | |
137 CPDF_PageObjects*» m_pObjectList; | |
138 CPDF_Dictionary*» m_pResources; | |
139 int»» » » » m_Level; | |
140 CFX_AffineMatrix» m_mtContentToUser; | |
141 CFX_FloatRect» » m_BBox; | |
142 CPDF_ParseOptions» m_Options; | |
143 _ContentParam» » m_ParamBuf1[PARAM_BUF_SIZE]; | |
144 FX_DWORD» » » m_ParamStartPos; | |
145 FX_DWORD» » » m_ParamCount; | |
146 void AddNumberParam(const FX_CHAR* str, int l
en); | 146 void AddNumberParam(const FX_CHAR* str, int l
en); |
147 void AddObjectParam(CPDF_Object* pObj); | 147 void AddObjectParam(CPDF_Object* pObj); |
148 void AddNameParam(const FX_CHAR* name, int si
ze); | 148 void AddNameParam(const FX_CHAR* name, int si
ze); |
149 int GetNextParamPos(); | 149 int GetNextParamPos(); |
150 void ClearAllParams(); | 150 void ClearAllParams(); |
151 CPDF_Object* GetObject(FX_DWORD index); | 151 CPDF_Object* GetObject(FX_DWORD index); |
152 CFX_ByteString GetString(FX_DWORD index); | 152 CFX_ByteString GetString(FX_DWORD index); |
153 FX_FLOAT GetNumber(FX_DWORD index); | 153 FX_FLOAT GetNumber(FX_DWORD index); |
154 FX_FLOAT GetNumber16(FX_DWORD index); | 154 FX_FLOAT GetNumber16(FX_DWORD index); |
155 int GetInteger(FX_DWORD index) | 155 int GetInteger(FX_DWORD index) |
156 { | 156 { |
157 return (int32_t)(GetNumber(index)); | 157 return (int32_t)(GetNumber(index)); |
158 } | 158 } |
159 FX_BOOL OnOperator(const FX_CHAR* op); | 159 FX_BOOL OnOperator(const FX_CHAR* op); |
160 void BigCaseCaller(int index); | 160 void BigCaseCaller(int index); |
161 FX_BOOL m_bAbort; | |
162 CPDF_StreamParser* m_pSyntax; | |
163 FX_DWORD GetParsePos() | 161 FX_DWORD GetParsePos() |
164 { | 162 { |
165 return m_pSyntax->GetPos(); | 163 return m_pSyntax->GetPos(); |
166 } | 164 } |
167 CPDF_AllStates* m_pCurStates; | |
168 CPDF_ContentMark m_CurContentMark; | |
169 CFX_PtrArray m_ClipTextList; | |
170 CPDF_TextObject* m_pLastTextObject; | |
171 FX_FLOAT m_DefFontSize; | |
172 void AddTextObject(CFX_ByteString* pText, FX_
FLOAT fInitKerning, FX_FLOAT* pKerning, int count); | 165 void AddTextObject(CFX_ByteString* pText, FX_
FLOAT fInitKerning, FX_FLOAT* pKerning, int count); |
173 | 166 |
174 void ConvertUserSpace(FX_FLOAT& x, FX_FLOAT&
y); | 167 void ConvertUserSpace(FX_FLOAT& x, FX_FLOAT&
y); |
175 void ConvertTextSpace(FX_FLOAT& x, FX_FLOAT&
y); | 168 void ConvertTextSpace(FX_FLOAT& x, FX_FLOAT&
y); |
176 void OnChangeTextMatrix(); | 169 void OnChangeTextMatrix(); |
177 FX_DWORD Parse(const uint8_t* pData, FX_DWORD dwSize, FX_
DWORD max_cost); | 170 FX_DWORD Parse(const uint8_t* pData, FX_DWORD dwSize, FX_
DWORD max_cost); |
178 void ParsePathObject(); | 171 void ParsePathObject(); |
179 int m_CompatCount; | |
180 FX_PATHPOINT* m_pPathPoints; | |
181 int m_PathPointCount; | |
182 int m_PathAllocSize; | |
183 FX_FLOAT m_PathStartX, m_PathStartY; | |
184 FX_FLOAT m_PathCurrentX, m_PathCurrentY; | |
185 int m_PathClipType; | |
186 void AddPathPoint(FX_FLOAT x, FX_FLOAT y, int
flag); | 172 void AddPathPoint(FX_FLOAT x, FX_FLOAT y, int
flag); |
187 void AddPathRect(FX_FLOAT x, FX_FLOAT y, FX_F
LOAT w, FX_FLOAT h); | 173 void AddPathRect(FX_FLOAT x, FX_FLOAT y, FX_F
LOAT w, FX_FLOAT h); |
188 void AddPathObject(int FillType, FX_BOOL bStr
oke); | 174 void AddPathObject(int FillType, FX_BOOL bStr
oke); |
189 CPDF_ImageObject* AddImage(CPDF_Stream* pStream, CPDF_Image* pImage, FX_BO
OL bInline); | 175 CPDF_ImageObject* AddImage(CPDF_Stream* pStream, CPDF_Image* pImage, FX_BO
OL bInline); |
190 void AddDuplicateImage(); | 176 void AddDuplicateImage(); |
191 void AddForm(CPDF_Stream*); | 177 void AddForm(CPDF_Stream*); |
192 CFX_ByteString m_LastImageName; | |
193 CPDF_Image* m_pLastImage; | |
194 CFX_BinaryBuf m_LastImageDict, m_LastImageData; | |
195 CPDF_Dictionary* m_pLastImageDict; | |
196 CPDF_Dictionary* m_pLastCloneImageDict; | |
197 FX_BOOL m_bReleaseLastDict; | |
198 FX_BOOL m_bSameLastDict; | |
199 void SetGraphicStates(CPDF_PageObject* pObj,
FX_BOOL bColor, FX_BOOL bText, FX_BOOL bGraph); | 178 void SetGraphicStates(CPDF_PageObject* pObj,
FX_BOOL bColor, FX_BOOL bText, FX_BOOL bGraph); |
200 FX_BOOL m_bColored; | |
201 FX_FLOAT m_Type3Data[6]; | |
202 FX_BOOL m_bResourceMissing; | |
203 CFX_PtrArray m_StateStack; | |
204 void SaveStates(CPDF_AllStates*); | 179 void SaveStates(CPDF_AllStates*); |
205 void RestoreStates(CPDF_AllStates*); | 180 void RestoreStates(CPDF_AllStates*); |
206 CPDF_Font* FindFont(const CFX_ByteString& name); | 181 CPDF_Font* FindFont(const CFX_ByteString& name); |
207 CPDF_ColorSpace* FindColorSpace(const CFX_ByteString& name); | 182 CPDF_ColorSpace* FindColorSpace(const CFX_ByteString& name); |
208 CPDF_Pattern* FindPattern(const CFX_ByteString& name, FX_BOOL
bShading); | 183 CPDF_Pattern* FindPattern(const CFX_ByteString& name, FX_BOOL
bShading); |
209 CPDF_Object* FindResourceObj(const CFX_ByteStringC& type, con
st CFX_ByteString& name); | 184 CPDF_Object* FindResourceObj(const CFX_ByteStringC& type, con
st CFX_ByteString& name); |
| 185 |
| 186 protected: |
| 187 struct OpCode { |
| 188 FX_DWORD m_OpId; |
| 189 void (CPDF_StreamContentParser::*m_OpHandler)(); |
| 190 }; |
| 191 static const OpCode g_OpCodes[]; |
| 192 |
210 void Handle_CloseFillStrokePath(); | 193 void Handle_CloseFillStrokePath(); |
211 void Handle_FillStrokePath(); | 194 void Handle_FillStrokePath(); |
212 void Handle_CloseEOFillStrokePath(); | 195 void Handle_CloseEOFillStrokePath(); |
213 void Handle_EOFillStrokePath(); | 196 void Handle_EOFillStrokePath(); |
214 void Handle_BeginMarkedContent_Dictionary(); | 197 void Handle_BeginMarkedContent_Dictionary(); |
215 void Handle_BeginImage(); | 198 void Handle_BeginImage(); |
216 void Handle_BeginMarkedContent(); | 199 void Handle_BeginMarkedContent(); |
217 void Handle_BeginText(); | 200 void Handle_BeginText(); |
218 void Handle_BeginSectionUndefined(); | 201 void Handle_BeginSectionUndefined(); |
219 void Handle_CurveTo_123(); | 202 void Handle_CurveTo_123(); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 void Handle_SetHorzScale(); | 257 void Handle_SetHorzScale(); |
275 void Handle_MoveToNextLine(); | 258 void Handle_MoveToNextLine(); |
276 void Handle_CurveTo_23(); | 259 void Handle_CurveTo_23(); |
277 void Handle_SetLineWidth(); | 260 void Handle_SetLineWidth(); |
278 void Handle_Clip(); | 261 void Handle_Clip(); |
279 void Handle_EOClip(); | 262 void Handle_EOClip(); |
280 void Handle_CurveTo_13(); | 263 void Handle_CurveTo_13(); |
281 void Handle_NextLineShowText(); | 264 void Handle_NextLineShowText(); |
282 void Handle_NextLineShowText_Space(); | 265 void Handle_NextLineShowText_Space(); |
283 void Handle_Invalid(); | 266 void Handle_Invalid(); |
| 267 |
| 268 CPDF_Document* const m_pDocument; |
| 269 CPDF_Dictionary* m_pPageResources; |
| 270 CPDF_Dictionary* m_pParentResources; |
| 271 CPDF_Dictionary* m_pResources; |
| 272 CPDF_PageObjects* m_pObjectList; |
| 273 int m_Level; |
| 274 CFX_AffineMatrix m_mtContentToUser; |
| 275 CFX_FloatRect m_BBox; |
| 276 CPDF_ParseOptions m_Options; |
| 277 _ContentParam m_ParamBuf1[PARAM_BUF_SIZE]; |
| 278 FX_DWORD m_ParamStartPos; |
| 279 FX_DWORD m_ParamCount; |
| 280 FX_BOOL m_bAbort; |
| 281 CPDF_StreamParser* m_pSyntax; |
| 282 nonstd::unique_ptr<CPDF_AllStates> m_pCurStates; |
| 283 CPDF_ContentMark m_CurContentMark; |
| 284 CFX_PtrArray m_ClipTextList; |
| 285 CPDF_TextObject* m_pLastTextObject; |
| 286 FX_FLOAT m_DefFontSize; |
| 287 int m_CompatCount; |
| 288 FX_PATHPOINT* m_pPathPoints; |
| 289 int m_PathPointCount; |
| 290 int m_PathAllocSize; |
| 291 FX_FLOAT m_PathStartX; |
| 292 FX_FLOAT m_PathStartY; |
| 293 FX_FLOAT m_PathCurrentX; |
| 294 FX_FLOAT m_PathCurrentY; |
| 295 int m_PathClipType; |
| 296 CFX_ByteString m_LastImageName; |
| 297 CPDF_Image* m_pLastImage; |
| 298 CFX_BinaryBuf m_LastImageDict; |
| 299 CFX_BinaryBuf m_LastImageData; |
| 300 CPDF_Dictionary* m_pLastImageDict; |
| 301 CPDF_Dictionary* m_pLastCloneImageDict; |
| 302 FX_BOOL m_bReleaseLastDict; |
| 303 FX_BOOL m_bSameLastDict; |
| 304 FX_BOOL m_bColored; |
| 305 FX_FLOAT m_Type3Data[6]; |
| 306 FX_BOOL m_bResourceMissing; |
| 307 CFX_PtrArray m_StateStack; |
284 }; | 308 }; |
285 class CPDF_ContentParser | 309 class CPDF_ContentParser |
286 { | 310 { |
287 public: | 311 public: |
288 CPDF_ContentParser(); | 312 CPDF_ContentParser(); |
289 ~CPDF_ContentParser(); | 313 ~CPDF_ContentParser(); |
290 typedef enum { Ready, ToBeContinued, Done } ParseStatus; | 314 typedef enum { Ready, ToBeContinued, Done } ParseStatus; |
291 ParseStatus GetStatus() | 315 ParseStatus GetStatus() |
292 { | 316 { |
293 return m_Status; | 317 return m_Status; |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
458 FX_FLOAT& G, | 482 FX_FLOAT& G, |
459 FX_FLOAT& B) const override; | 483 FX_FLOAT& B) const override; |
460 CPDF_ColorSpace* GetBaseCS() const override; | 484 CPDF_ColorSpace* GetBaseCS() const override; |
461 | 485 |
462 private: | 486 private: |
463 CPDF_ColorSpace* m_pBaseCS; | 487 CPDF_ColorSpace* m_pBaseCS; |
464 CPDF_CountedColorSpace* m_pCountedBaseCS; | 488 CPDF_CountedColorSpace* m_pCountedBaseCS; |
465 }; | 489 }; |
466 | 490 |
467 #endif // CORE_SRC_FPDFAPI_FPDF_PAGE_PAGEINT_H_ | 491 #endif // CORE_SRC_FPDFAPI_FPDF_PAGE_PAGEINT_H_ |
OLD | NEW |