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 #include <memory> | 11 #include <memory> |
12 | 12 |
13 #include "core/include/fpdfapi/fpdf_page.h" | 13 #include "core/include/fpdfapi/fpdf_page.h" |
14 #include "core/include/fpdfapi/fpdf_pageobj.h" | 14 #include "core/include/fpdfapi/fpdf_pageobj.h" |
15 | 15 |
16 class CPDF_AllStates; | 16 class CPDF_AllStates; |
17 class CPDF_ParseOptions; | 17 class CPDF_ParseOptions; |
18 | 18 |
19 #define PARSE_STEP_LIMIT 100 | 19 #define PARSE_STEP_LIMIT 100 |
20 | 20 |
21 class CPDF_StreamParser { | 21 class CPDF_StreamParser { |
22 public: | 22 public: |
| 23 enum SyntaxType { EndOfData, Number, Keyword, Name, Others }; |
| 24 |
23 CPDF_StreamParser(const uint8_t* pData, FX_DWORD dwSize); | 25 CPDF_StreamParser(const uint8_t* pData, FX_DWORD dwSize); |
24 ~CPDF_StreamParser(); | 26 ~CPDF_StreamParser(); |
25 | 27 |
26 CPDF_Stream* ReadInlineStream(CPDF_Document* pDoc, | 28 CPDF_Stream* ReadInlineStream(CPDF_Document* pDoc, |
27 CPDF_Dictionary* pDict, | 29 CPDF_Dictionary* pDict, |
28 CPDF_Object* pCSObj, | 30 CPDF_Object* pCSObj, |
29 FX_BOOL bDecode); | 31 FX_BOOL bDecode); |
30 typedef enum { EndOfData, Number, Keyword, Name, Others } SyntaxType; | |
31 | |
32 SyntaxType ParseNextElement(); | 32 SyntaxType ParseNextElement(); |
33 uint8_t* GetWordBuf() { return m_WordBuffer; } | 33 uint8_t* GetWordBuf() { return m_WordBuffer; } |
34 FX_DWORD GetWordSize() { return m_WordSize; } | 34 FX_DWORD GetWordSize() const { return m_WordSize; } |
35 CPDF_Object* GetObject() { | 35 CPDF_Object* GetObject() { |
36 CPDF_Object* pObj = m_pLastObj; | 36 CPDF_Object* pObj = m_pLastObj; |
37 m_pLastObj = NULL; | 37 m_pLastObj = NULL; |
38 return pObj; | 38 return pObj; |
39 } | 39 } |
40 FX_DWORD GetPos() { return m_Pos; } | 40 FX_DWORD GetPos() const { return m_Pos; } |
41 void SetPos(FX_DWORD pos) { m_Pos = pos; } | 41 void SetPos(FX_DWORD pos) { m_Pos = pos; } |
42 | |
43 CPDF_Object* ReadNextObject(FX_BOOL bAllowNestedArray = FALSE, | 42 CPDF_Object* ReadNextObject(FX_BOOL bAllowNestedArray = FALSE, |
44 FX_BOOL bInArray = FALSE); | 43 FX_BOOL bInArray = FALSE); |
45 void SkipPathObject(); | 44 void SkipPathObject(); |
46 | 45 |
47 protected: | 46 protected: |
48 friend class fpdf_page_parser_old_ReadHexString_Test; | 47 friend class fpdf_page_parser_old_ReadHexString_Test; |
49 | 48 |
50 void GetNextWord(FX_BOOL& bIsNumber); | 49 void GetNextWord(FX_BOOL& bIsNumber); |
51 CFX_ByteString ReadString(); | 50 CFX_ByteString ReadString(); |
52 CFX_ByteString ReadHexString(); | 51 CFX_ByteString ReadHexString(); |
53 const uint8_t* m_pBuf; | 52 const uint8_t* m_pBuf; |
54 | 53 |
55 // Length in bytes of m_pBuf. | 54 // Length in bytes of m_pBuf. |
56 FX_DWORD m_Size; | 55 FX_DWORD m_Size; |
57 | 56 |
58 // Current byte position within m_pBuf. | 57 // Current byte position within m_pBuf. |
59 FX_DWORD m_Pos; | 58 FX_DWORD m_Pos; |
60 | 59 |
61 uint8_t m_WordBuffer[256]; | 60 uint8_t m_WordBuffer[256]; |
62 FX_DWORD m_WordSize; | 61 FX_DWORD m_WordSize; |
63 CPDF_Object* m_pLastObj; | 62 CPDF_Object* m_pLastObj; |
64 | 63 |
65 private: | 64 private: |
66 bool PositionIsInBounds() const; | 65 bool PositionIsInBounds() const; |
67 }; | 66 }; |
68 typedef enum { | 67 |
69 PDFOP_CloseFillStrokePath = 0, | |
70 PDFOP_FillStrokePath, | |
71 PDFOP_CloseEOFillStrokePath, | |
72 PDFOP_EOFillStrokePath, | |
73 PDFOP_BeginMarkedContent_Dictionary, | |
74 PDFOP_BeginImage, | |
75 PDFOP_BeginMarkedContent, | |
76 PDFOP_BeginText, | |
77 PDFOP_BeginSectionUndefined, | |
78 PDFOP_CurveTo_123, | |
79 PDFOP_ConcatMatrix, | |
80 PDFOP_SetColorSpace_Fill, | |
81 PDFOP_SetColorSpace_Stroke, | |
82 PDFOP_SetDash, | |
83 PDFOP_SetCharWidth, | |
84 PDFOP_SetCachedDevice, | |
85 PDFOP_ExecuteXObject, | |
86 PDFOP_MarkPlace_Dictionary, | |
87 PDFOP_EndImage, | |
88 PDFOP_EndMarkedContent, | |
89 PDFOP_EndText, | |
90 PDFOP_EndSectionUndefined, | |
91 PDFOP_FillPath, | |
92 PDFOP_FillPathOld, | |
93 PDFOP_EOFillPath, | |
94 PDFOP_SetGray_Fill, | |
95 PDFOP_SetGray_Stroke, | |
96 PDFOP_SetExtendGraphState, | |
97 PDFOP_ClosePath, | |
98 PDFOP_SetFlat, | |
99 PDFOP_BeginImageData, | |
100 PDFOP_SetLineJoin, | |
101 PDFOP_SetLineCap, | |
102 PDFOP_SetCMYKColor_Fill, | |
103 PDFOP_SetCMYKColor_Stroke, | |
104 PDFOP_LineTo, | |
105 PDFOP_MoveTo, | |
106 PDFOP_SetMiterLimit, | |
107 PDFOP_MarkPlace, | |
108 PDFOP_EndPath, | |
109 PDFOP_SaveGraphState, | |
110 PDFOP_RestoreGraphState, | |
111 PDFOP_Rectangle, | |
112 PDFOP_SetRGBColor_Fill, | |
113 PDFOP_SetRGBColor_Stroke, | |
114 PDFOP_SetRenderIntent, | |
115 PDFOP_CloseStrokePath, | |
116 PDFOP_StrokePath, | |
117 PDFOP_SetColor_Fill, | |
118 PDFOP_SetColor_Stroke, | |
119 PDFOP_SetColorPS_Fill, | |
120 PDFOP_SetColorPS_Stroke, | |
121 PDFOP_ShadeFill, | |
122 PDFOP_SetCharSpace, | |
123 PDFOP_MoveTextPoint, | |
124 PDFOP_MoveTextPoint_SetLeading, | |
125 PDFOP_SetFont, | |
126 PDFOP_ShowText, | |
127 PDFOP_ShowText_Positioning, | |
128 PDFOP_SetTextLeading, | |
129 PDFOP_SetTextMatrix, | |
130 PDFOP_SetTextRenderMode, | |
131 PDFOP_SetTextRise, | |
132 PDFOP_SetWordSpace, | |
133 PDFOP_SetHorzScale, | |
134 PDFOP_MoveToNextLine, | |
135 PDFOP_CurveTo_23, | |
136 PDFOP_SetLineWidth, | |
137 PDFOP_Clip, | |
138 PDFOP_EOClip, | |
139 PDFOP_CurveTo_13, | |
140 PDFOP_NextLineShowText, | |
141 PDFOP_NextLineShowText_Space, | |
142 PDFOP_Invalid | |
143 } PDFOP; | |
144 #define PARAM_BUF_SIZE 16 | 68 #define PARAM_BUF_SIZE 16 |
145 typedef struct { | 69 struct ContentParam { |
146 int m_Type; | 70 int m_Type; |
147 union { | 71 union { |
148 struct { | 72 struct { |
149 FX_BOOL m_bInteger; | 73 FX_BOOL m_bInteger; |
150 union { | 74 union { |
151 int m_Integer; | 75 int m_Integer; |
152 FX_FLOAT m_Float; | 76 FX_FLOAT m_Float; |
153 }; | 77 }; |
154 } m_Number; | 78 } m_Number; |
155 CPDF_Object* m_pObject; | 79 CPDF_Object* m_pObject; |
156 struct { | 80 struct { |
157 int m_Len; | 81 int m_Len; |
158 char m_Buffer[32]; | 82 char m_Buffer[32]; |
159 } m_Name; | 83 } m_Name; |
160 }; | 84 }; |
161 } _ContentParam; | 85 }; |
162 #define _FPDF_MAX_FORM_LEVEL_ 30 | 86 #define _FPDF_MAX_FORM_LEVEL_ 30 |
163 #define _FPDF_MAX_TYPE3_FORM_LEVEL_ 4 | 87 #define _FPDF_MAX_TYPE3_FORM_LEVEL_ 4 |
164 #define _FPDF_MAX_OBJECT_STACK_SIZE_ 512 | 88 #define _FPDF_MAX_OBJECT_STACK_SIZE_ 512 |
165 class CPDF_StreamContentParser { | 89 class CPDF_StreamContentParser { |
166 public: | 90 public: |
167 CPDF_StreamContentParser(CPDF_Document* pDoc, | 91 CPDF_StreamContentParser(CPDF_Document* pDoc, |
168 CPDF_Dictionary* pPageResources, | 92 CPDF_Dictionary* pPageResources, |
169 CPDF_Dictionary* pParentResources, | 93 CPDF_Dictionary* pParentResources, |
170 CFX_Matrix* pmtContentToUser, | 94 CFX_Matrix* pmtContentToUser, |
171 CPDF_PageObjects* pObjList, | 95 CPDF_PageObjects* pObjList, |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 | 232 |
309 CPDF_Document* const m_pDocument; | 233 CPDF_Document* const m_pDocument; |
310 CPDF_Dictionary* m_pPageResources; | 234 CPDF_Dictionary* m_pPageResources; |
311 CPDF_Dictionary* m_pParentResources; | 235 CPDF_Dictionary* m_pParentResources; |
312 CPDF_Dictionary* m_pResources; | 236 CPDF_Dictionary* m_pResources; |
313 CPDF_PageObjects* m_pObjectList; | 237 CPDF_PageObjects* m_pObjectList; |
314 int m_Level; | 238 int m_Level; |
315 CFX_Matrix m_mtContentToUser; | 239 CFX_Matrix m_mtContentToUser; |
316 CFX_FloatRect m_BBox; | 240 CFX_FloatRect m_BBox; |
317 CPDF_ParseOptions m_Options; | 241 CPDF_ParseOptions m_Options; |
318 _ContentParam m_ParamBuf1[PARAM_BUF_SIZE]; | 242 ContentParam m_ParamBuf1[PARAM_BUF_SIZE]; |
319 FX_DWORD m_ParamStartPos; | 243 FX_DWORD m_ParamStartPos; |
320 FX_DWORD m_ParamCount; | 244 FX_DWORD m_ParamCount; |
321 CPDF_StreamParser* m_pSyntax; | 245 CPDF_StreamParser* m_pSyntax; |
322 std::unique_ptr<CPDF_AllStates> m_pCurStates; | 246 std::unique_ptr<CPDF_AllStates> m_pCurStates; |
323 CPDF_ContentMark m_CurContentMark; | 247 CPDF_ContentMark m_CurContentMark; |
324 CFX_ArrayTemplate<CPDF_TextObject*> m_ClipTextList; | 248 CFX_ArrayTemplate<CPDF_TextObject*> m_ClipTextList; |
325 CPDF_TextObject* m_pLastTextObject; | 249 CPDF_TextObject* m_pLastTextObject; |
326 FX_FLOAT m_DefFontSize; | 250 FX_FLOAT m_DefFontSize; |
327 int m_CompatCount; | 251 int m_CompatCount; |
328 FX_PATHPOINT* m_pPathPoints; | 252 FX_PATHPOINT* m_pPathPoints; |
(...skipping 17 matching lines...) Expand all Loading... |
346 FX_BOOL m_bResourceMissing; | 270 FX_BOOL m_bResourceMissing; |
347 CFX_ArrayTemplate<CPDF_AllStates*> m_StateStack; | 271 CFX_ArrayTemplate<CPDF_AllStates*> m_StateStack; |
348 }; | 272 }; |
349 class CPDF_ContentParser { | 273 class CPDF_ContentParser { |
350 public: | 274 public: |
351 enum ParseStatus { Ready, ToBeContinued, Done }; | 275 enum ParseStatus { Ready, ToBeContinued, Done }; |
352 | 276 |
353 CPDF_ContentParser(); | 277 CPDF_ContentParser(); |
354 ~CPDF_ContentParser(); | 278 ~CPDF_ContentParser(); |
355 | 279 |
356 ParseStatus GetStatus() { return m_Status; } | 280 ParseStatus GetStatus() const { return m_Status; } |
357 void Start(CPDF_Page* pPage, CPDF_ParseOptions* pOptions); | 281 void Start(CPDF_Page* pPage, CPDF_ParseOptions* pOptions); |
358 void Start(CPDF_Form* pForm, | 282 void Start(CPDF_Form* pForm, |
359 CPDF_AllStates* pGraphicStates, | 283 CPDF_AllStates* pGraphicStates, |
360 CFX_Matrix* pParentMatrix, | 284 CFX_Matrix* pParentMatrix, |
361 CPDF_Type3Char* pType3Char, | 285 CPDF_Type3Char* pType3Char, |
362 CPDF_ParseOptions* pOptions, | 286 CPDF_ParseOptions* pOptions, |
363 int level); | 287 int level); |
364 void Continue(IFX_Pause* pPause); | 288 void Continue(IFX_Pause* pPause); |
365 | 289 |
366 protected: | 290 protected: |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 FX_FLOAT& G, | 443 FX_FLOAT& G, |
520 FX_FLOAT& B) const override; | 444 FX_FLOAT& B) const override; |
521 CPDF_ColorSpace* GetBaseCS() const override; | 445 CPDF_ColorSpace* GetBaseCS() const override; |
522 | 446 |
523 private: | 447 private: |
524 CPDF_ColorSpace* m_pBaseCS; | 448 CPDF_ColorSpace* m_pBaseCS; |
525 CPDF_CountedColorSpace* m_pCountedBaseCS; | 449 CPDF_CountedColorSpace* m_pCountedBaseCS; |
526 }; | 450 }; |
527 | 451 |
528 #endif // CORE_SRC_FPDFAPI_FPDF_PAGE_PAGEINT_H_ | 452 #endif // CORE_SRC_FPDFAPI_FPDF_PAGE_PAGEINT_H_ |
OLD | NEW |