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_FPDFAPI_FPDF_PAGE_PAGEINT_H_ | 7 #ifndef CORE_FPDFAPI_FPDF_PAGE_PAGEINT_H_ |
8 #define CORE_FPDFAPI_FPDF_PAGE_PAGEINT_H_ | 8 #define CORE_FPDFAPI_FPDF_PAGE_PAGEINT_H_ |
9 | 9 |
10 #include <map> | 10 #include <map> |
(...skipping 21 matching lines...) Expand all Loading... |
32 class CPDF_StreamAcc; | 32 class CPDF_StreamAcc; |
33 class CPDF_TextObject; | 33 class CPDF_TextObject; |
34 class CPDF_Type3Char; | 34 class CPDF_Type3Char; |
35 | 35 |
36 #define PARSE_STEP_LIMIT 100 | 36 #define PARSE_STEP_LIMIT 100 |
37 | 37 |
38 class CPDF_StreamParser { | 38 class CPDF_StreamParser { |
39 public: | 39 public: |
40 enum SyntaxType { EndOfData, Number, Keyword, Name, Others }; | 40 enum SyntaxType { EndOfData, Number, Keyword, Name, Others }; |
41 | 41 |
42 CPDF_StreamParser(const uint8_t* pData, FX_DWORD dwSize); | 42 CPDF_StreamParser(const uint8_t* pData, uint32_t dwSize); |
43 ~CPDF_StreamParser(); | 43 ~CPDF_StreamParser(); |
44 | 44 |
45 CPDF_Stream* ReadInlineStream(CPDF_Document* pDoc, | 45 CPDF_Stream* ReadInlineStream(CPDF_Document* pDoc, |
46 CPDF_Dictionary* pDict, | 46 CPDF_Dictionary* pDict, |
47 CPDF_Object* pCSObj, | 47 CPDF_Object* pCSObj, |
48 FX_BOOL bDecode); | 48 FX_BOOL bDecode); |
49 SyntaxType ParseNextElement(); | 49 SyntaxType ParseNextElement(); |
50 uint8_t* GetWordBuf() { return m_WordBuffer; } | 50 uint8_t* GetWordBuf() { return m_WordBuffer; } |
51 FX_DWORD GetWordSize() const { return m_WordSize; } | 51 uint32_t GetWordSize() const { return m_WordSize; } |
52 CPDF_Object* GetObject() { | 52 CPDF_Object* GetObject() { |
53 CPDF_Object* pObj = m_pLastObj; | 53 CPDF_Object* pObj = m_pLastObj; |
54 m_pLastObj = NULL; | 54 m_pLastObj = NULL; |
55 return pObj; | 55 return pObj; |
56 } | 56 } |
57 FX_DWORD GetPos() const { return m_Pos; } | 57 uint32_t GetPos() const { return m_Pos; } |
58 void SetPos(FX_DWORD pos) { m_Pos = pos; } | 58 void SetPos(uint32_t pos) { m_Pos = pos; } |
59 CPDF_Object* ReadNextObject(FX_BOOL bAllowNestedArray = FALSE, | 59 CPDF_Object* ReadNextObject(FX_BOOL bAllowNestedArray = FALSE, |
60 FX_BOOL bInArray = FALSE); | 60 FX_BOOL bInArray = FALSE); |
61 void SkipPathObject(); | 61 void SkipPathObject(); |
62 | 62 |
63 protected: | 63 protected: |
64 friend class fpdf_page_parser_old_ReadHexString_Test; | 64 friend class fpdf_page_parser_old_ReadHexString_Test; |
65 | 65 |
66 void GetNextWord(FX_BOOL& bIsNumber); | 66 void GetNextWord(FX_BOOL& bIsNumber); |
67 CFX_ByteString ReadString(); | 67 CFX_ByteString ReadString(); |
68 CFX_ByteString ReadHexString(); | 68 CFX_ByteString ReadHexString(); |
69 const uint8_t* m_pBuf; | 69 const uint8_t* m_pBuf; |
70 | 70 |
71 // Length in bytes of m_pBuf. | 71 // Length in bytes of m_pBuf. |
72 FX_DWORD m_Size; | 72 uint32_t m_Size; |
73 | 73 |
74 // Current byte position within m_pBuf. | 74 // Current byte position within m_pBuf. |
75 FX_DWORD m_Pos; | 75 uint32_t m_Pos; |
76 | 76 |
77 uint8_t m_WordBuffer[256]; | 77 uint8_t m_WordBuffer[256]; |
78 FX_DWORD m_WordSize; | 78 uint32_t m_WordSize; |
79 CPDF_Object* m_pLastObj; | 79 CPDF_Object* m_pLastObj; |
80 | 80 |
81 private: | 81 private: |
82 bool PositionIsInBounds() const; | 82 bool PositionIsInBounds() const; |
83 }; | 83 }; |
84 | 84 |
85 #define PARAM_BUF_SIZE 16 | 85 #define PARAM_BUF_SIZE 16 |
86 struct ContentParam { | 86 struct ContentParam { |
87 enum Type { OBJECT = 0, NUMBER, NAME }; | 87 enum Type { OBJECT = 0, NUMBER, NAME }; |
88 Type m_Type; | 88 Type m_Type; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 CPDF_PageObjectHolder* GetPageObjectHolder() const { return m_pObjectHolder; } | 121 CPDF_PageObjectHolder* GetPageObjectHolder() const { return m_pObjectHolder; } |
122 CPDF_AllStates* GetCurStates() const { return m_pCurStates.get(); } | 122 CPDF_AllStates* GetCurStates() const { return m_pCurStates.get(); } |
123 FX_BOOL IsColored() const { return m_bColored; } | 123 FX_BOOL IsColored() const { return m_bColored; } |
124 const FX_FLOAT* GetType3Data() const { return m_Type3Data; } | 124 const FX_FLOAT* GetType3Data() const { return m_Type3Data; } |
125 | 125 |
126 void AddNumberParam(const FX_CHAR* str, int len); | 126 void AddNumberParam(const FX_CHAR* str, int len); |
127 void AddObjectParam(CPDF_Object* pObj); | 127 void AddObjectParam(CPDF_Object* pObj); |
128 void AddNameParam(const FX_CHAR* name, int size); | 128 void AddNameParam(const FX_CHAR* name, int size); |
129 int GetNextParamPos(); | 129 int GetNextParamPos(); |
130 void ClearAllParams(); | 130 void ClearAllParams(); |
131 CPDF_Object* GetObject(FX_DWORD index); | 131 CPDF_Object* GetObject(uint32_t index); |
132 CFX_ByteString GetString(FX_DWORD index); | 132 CFX_ByteString GetString(uint32_t index); |
133 FX_FLOAT GetNumber(FX_DWORD index); | 133 FX_FLOAT GetNumber(uint32_t index); |
134 FX_FLOAT GetNumber16(FX_DWORD index); | 134 FX_FLOAT GetNumber16(uint32_t index); |
135 int GetInteger(FX_DWORD index) { return (int32_t)(GetNumber(index)); } | 135 int GetInteger(uint32_t index) { return (int32_t)(GetNumber(index)); } |
136 void OnOperator(const FX_CHAR* op); | 136 void OnOperator(const FX_CHAR* op); |
137 void BigCaseCaller(int index); | 137 void BigCaseCaller(int index); |
138 FX_DWORD GetParsePos() { return m_pSyntax->GetPos(); } | 138 uint32_t GetParsePos() { return m_pSyntax->GetPos(); } |
139 void AddTextObject(CFX_ByteString* pText, | 139 void AddTextObject(CFX_ByteString* pText, |
140 FX_FLOAT fInitKerning, | 140 FX_FLOAT fInitKerning, |
141 FX_FLOAT* pKerning, | 141 FX_FLOAT* pKerning, |
142 int count); | 142 int count); |
143 | 143 |
144 void ConvertUserSpace(FX_FLOAT& x, FX_FLOAT& y); | 144 void ConvertUserSpace(FX_FLOAT& x, FX_FLOAT& y); |
145 void ConvertTextSpace(FX_FLOAT& x, FX_FLOAT& y); | 145 void ConvertTextSpace(FX_FLOAT& x, FX_FLOAT& y); |
146 void OnChangeTextMatrix(); | 146 void OnChangeTextMatrix(); |
147 FX_DWORD Parse(const uint8_t* pData, FX_DWORD dwSize, FX_DWORD max_cost); | 147 uint32_t Parse(const uint8_t* pData, uint32_t dwSize, uint32_t max_cost); |
148 void ParsePathObject(); | 148 void ParsePathObject(); |
149 void AddPathPoint(FX_FLOAT x, FX_FLOAT y, int flag); | 149 void AddPathPoint(FX_FLOAT x, FX_FLOAT y, int flag); |
150 void AddPathRect(FX_FLOAT x, FX_FLOAT y, FX_FLOAT w, FX_FLOAT h); | 150 void AddPathRect(FX_FLOAT x, FX_FLOAT y, FX_FLOAT w, FX_FLOAT h); |
151 void AddPathObject(int FillType, FX_BOOL bStroke); | 151 void AddPathObject(int FillType, FX_BOOL bStroke); |
152 CPDF_ImageObject* AddImage(CPDF_Stream* pStream, | 152 CPDF_ImageObject* AddImage(CPDF_Stream* pStream, |
153 CPDF_Image* pImage, | 153 CPDF_Image* pImage, |
154 FX_BOOL bInline); | 154 FX_BOOL bInline); |
155 void AddDuplicateImage(); | 155 void AddDuplicateImage(); |
156 void AddForm(CPDF_Stream* pStream); | 156 void AddForm(CPDF_Stream* pStream); |
157 void SetGraphicStates(CPDF_PageObject* pObj, | 157 void SetGraphicStates(CPDF_PageObject* pObj, |
158 FX_BOOL bColor, | 158 FX_BOOL bColor, |
159 FX_BOOL bText, | 159 FX_BOOL bText, |
160 FX_BOOL bGraph); | 160 FX_BOOL bGraph); |
161 void SaveStates(CPDF_AllStates* pState); | 161 void SaveStates(CPDF_AllStates* pState); |
162 void RestoreStates(CPDF_AllStates* pState); | 162 void RestoreStates(CPDF_AllStates* pState); |
163 CPDF_Font* FindFont(const CFX_ByteString& name); | 163 CPDF_Font* FindFont(const CFX_ByteString& name); |
164 CPDF_ColorSpace* FindColorSpace(const CFX_ByteString& name); | 164 CPDF_ColorSpace* FindColorSpace(const CFX_ByteString& name); |
165 CPDF_Pattern* FindPattern(const CFX_ByteString& name, FX_BOOL bShading); | 165 CPDF_Pattern* FindPattern(const CFX_ByteString& name, FX_BOOL bShading); |
166 CPDF_Object* FindResourceObj(const CFX_ByteStringC& type, | 166 CPDF_Object* FindResourceObj(const CFX_ByteStringC& type, |
167 const CFX_ByteString& name); | 167 const CFX_ByteString& name); |
168 | 168 |
169 protected: | 169 protected: |
170 using OpCodes = | 170 using OpCodes = |
171 std::unordered_map<FX_DWORD, void (CPDF_StreamContentParser::*)()>; | 171 std::unordered_map<uint32_t, void (CPDF_StreamContentParser::*)()>; |
172 static OpCodes InitializeOpCodes(); | 172 static OpCodes InitializeOpCodes(); |
173 | 173 |
174 void Handle_CloseFillStrokePath(); | 174 void Handle_CloseFillStrokePath(); |
175 void Handle_FillStrokePath(); | 175 void Handle_FillStrokePath(); |
176 void Handle_CloseEOFillStrokePath(); | 176 void Handle_CloseEOFillStrokePath(); |
177 void Handle_EOFillStrokePath(); | 177 void Handle_EOFillStrokePath(); |
178 void Handle_BeginMarkedContent_Dictionary(); | 178 void Handle_BeginMarkedContent_Dictionary(); |
179 void Handle_BeginImage(); | 179 void Handle_BeginImage(); |
180 void Handle_BeginMarkedContent(); | 180 void Handle_BeginMarkedContent(); |
181 void Handle_BeginText(); | 181 void Handle_BeginText(); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 CPDF_Document* const m_pDocument; | 247 CPDF_Document* const m_pDocument; |
248 CPDF_Dictionary* m_pPageResources; | 248 CPDF_Dictionary* m_pPageResources; |
249 CPDF_Dictionary* m_pParentResources; | 249 CPDF_Dictionary* m_pParentResources; |
250 CPDF_Dictionary* m_pResources; | 250 CPDF_Dictionary* m_pResources; |
251 CPDF_PageObjectHolder* m_pObjectHolder; | 251 CPDF_PageObjectHolder* m_pObjectHolder; |
252 int m_Level; | 252 int m_Level; |
253 CFX_Matrix m_mtContentToUser; | 253 CFX_Matrix m_mtContentToUser; |
254 CFX_FloatRect m_BBox; | 254 CFX_FloatRect m_BBox; |
255 CPDF_ParseOptions m_Options; | 255 CPDF_ParseOptions m_Options; |
256 ContentParam m_ParamBuf[PARAM_BUF_SIZE]; | 256 ContentParam m_ParamBuf[PARAM_BUF_SIZE]; |
257 FX_DWORD m_ParamStartPos; | 257 uint32_t m_ParamStartPos; |
258 FX_DWORD m_ParamCount; | 258 uint32_t m_ParamCount; |
259 CPDF_StreamParser* m_pSyntax; | 259 CPDF_StreamParser* m_pSyntax; |
260 std::unique_ptr<CPDF_AllStates> m_pCurStates; | 260 std::unique_ptr<CPDF_AllStates> m_pCurStates; |
261 CPDF_ContentMark m_CurContentMark; | 261 CPDF_ContentMark m_CurContentMark; |
262 CFX_ArrayTemplate<CPDF_TextObject*> m_ClipTextList; | 262 CFX_ArrayTemplate<CPDF_TextObject*> m_ClipTextList; |
263 CPDF_TextObject* m_pLastTextObject; | 263 CPDF_TextObject* m_pLastTextObject; |
264 FX_FLOAT m_DefFontSize; | 264 FX_FLOAT m_DefFontSize; |
265 FX_PATHPOINT* m_pPathPoints; | 265 FX_PATHPOINT* m_pPathPoints; |
266 int m_PathPointCount; | 266 int m_PathPointCount; |
267 int m_PathAllocSize; | 267 int m_PathAllocSize; |
268 FX_FLOAT m_PathStartX; | 268 FX_FLOAT m_PathStartX; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 STAGE_PARSE, | 306 STAGE_PARSE, |
307 STAGE_CHECKCLIP, | 307 STAGE_CHECKCLIP, |
308 }; | 308 }; |
309 | 309 |
310 ParseStatus m_Status; | 310 ParseStatus m_Status; |
311 InternalStage m_InternalStage; | 311 InternalStage m_InternalStage; |
312 CPDF_PageObjectHolder* m_pObjectHolder; | 312 CPDF_PageObjectHolder* m_pObjectHolder; |
313 FX_BOOL m_bForm; | 313 FX_BOOL m_bForm; |
314 CPDF_ParseOptions m_Options; | 314 CPDF_ParseOptions m_Options; |
315 CPDF_Type3Char* m_pType3Char; | 315 CPDF_Type3Char* m_pType3Char; |
316 FX_DWORD m_nStreams; | 316 uint32_t m_nStreams; |
317 std::unique_ptr<CPDF_StreamAcc> m_pSingleStream; | 317 std::unique_ptr<CPDF_StreamAcc> m_pSingleStream; |
318 std::vector<std::unique_ptr<CPDF_StreamAcc>> m_StreamArray; | 318 std::vector<std::unique_ptr<CPDF_StreamAcc>> m_StreamArray; |
319 uint8_t* m_pData; | 319 uint8_t* m_pData; |
320 FX_DWORD m_Size; | 320 uint32_t m_Size; |
321 FX_DWORD m_CurrentOffset; | 321 uint32_t m_CurrentOffset; |
322 std::unique_ptr<CPDF_StreamContentParser> m_pParser; | 322 std::unique_ptr<CPDF_StreamContentParser> m_pParser; |
323 }; | 323 }; |
324 | 324 |
325 class CPDF_DocPageData { | 325 class CPDF_DocPageData { |
326 public: | 326 public: |
327 explicit CPDF_DocPageData(CPDF_Document* pPDFDoc); | 327 explicit CPDF_DocPageData(CPDF_Document* pPDFDoc); |
328 ~CPDF_DocPageData(); | 328 ~CPDF_DocPageData(); |
329 | 329 |
330 void Clear(FX_BOOL bRelease = FALSE); | 330 void Clear(FX_BOOL bRelease = FALSE); |
331 CPDF_Font* GetFont(CPDF_Dictionary* pFontDict, FX_BOOL findOnly); | 331 CPDF_Font* GetFont(CPDF_Dictionary* pFontDict, FX_BOOL findOnly); |
(...skipping 22 matching lines...) Expand all Loading... |
354 private: | 354 private: |
355 using CPDF_CountedFont = CPDF_CountedObject<CPDF_Font>; | 355 using CPDF_CountedFont = CPDF_CountedObject<CPDF_Font>; |
356 using CPDF_CountedIccProfile = CPDF_CountedObject<CPDF_IccProfile>; | 356 using CPDF_CountedIccProfile = CPDF_CountedObject<CPDF_IccProfile>; |
357 using CPDF_CountedImage = CPDF_CountedObject<CPDF_Image>; | 357 using CPDF_CountedImage = CPDF_CountedObject<CPDF_Image>; |
358 using CPDF_CountedStreamAcc = CPDF_CountedObject<CPDF_StreamAcc>; | 358 using CPDF_CountedStreamAcc = CPDF_CountedObject<CPDF_StreamAcc>; |
359 | 359 |
360 using CPDF_ColorSpaceMap = std::map<CPDF_Object*, CPDF_CountedColorSpace*>; | 360 using CPDF_ColorSpaceMap = std::map<CPDF_Object*, CPDF_CountedColorSpace*>; |
361 using CPDF_FontFileMap = std::map<CPDF_Stream*, CPDF_CountedStreamAcc*>; | 361 using CPDF_FontFileMap = std::map<CPDF_Stream*, CPDF_CountedStreamAcc*>; |
362 using CPDF_FontMap = std::map<CPDF_Dictionary*, CPDF_CountedFont*>; | 362 using CPDF_FontMap = std::map<CPDF_Dictionary*, CPDF_CountedFont*>; |
363 using CPDF_IccProfileMap = std::map<CPDF_Stream*, CPDF_CountedIccProfile*>; | 363 using CPDF_IccProfileMap = std::map<CPDF_Stream*, CPDF_CountedIccProfile*>; |
364 using CPDF_ImageMap = std::map<FX_DWORD, CPDF_CountedImage*>; | 364 using CPDF_ImageMap = std::map<uint32_t, CPDF_CountedImage*>; |
365 using CPDF_PatternMap = std::map<CPDF_Object*, CPDF_CountedPattern*>; | 365 using CPDF_PatternMap = std::map<CPDF_Object*, CPDF_CountedPattern*>; |
366 | 366 |
367 CPDF_Document* const m_pPDFDoc; | 367 CPDF_Document* const m_pPDFDoc; |
368 FX_BOOL m_bForceClear; | 368 FX_BOOL m_bForceClear; |
369 std::map<CFX_ByteString, CPDF_Stream*> m_HashProfileMap; | 369 std::map<CFX_ByteString, CPDF_Stream*> m_HashProfileMap; |
370 CPDF_ColorSpaceMap m_ColorSpaceMap; | 370 CPDF_ColorSpaceMap m_ColorSpaceMap; |
371 CPDF_FontFileMap m_FontFileMap; | 371 CPDF_FontFileMap m_FontFileMap; |
372 CPDF_FontMap m_FontMap; | 372 CPDF_FontMap m_FontMap; |
373 CPDF_IccProfileMap m_IccProfileMap; | 373 CPDF_IccProfileMap m_IccProfileMap; |
374 CPDF_ImageMap m_ImageMap; | 374 CPDF_ImageMap m_ImageMap; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 | 434 |
435 std::vector<CPDF_Function*> m_pSubFunctions; | 435 std::vector<CPDF_Function*> m_pSubFunctions; |
436 FX_FLOAT* m_pBounds; | 436 FX_FLOAT* m_pBounds; |
437 FX_FLOAT* m_pEncode; | 437 FX_FLOAT* m_pEncode; |
438 | 438 |
439 static const int kRequiredNumInputs = 1; | 439 static const int kRequiredNumInputs = 1; |
440 }; | 440 }; |
441 | 441 |
442 class CPDF_IccProfile { | 442 class CPDF_IccProfile { |
443 public: | 443 public: |
444 CPDF_IccProfile(const uint8_t* pData, FX_DWORD dwSize); | 444 CPDF_IccProfile(const uint8_t* pData, uint32_t dwSize); |
445 ~CPDF_IccProfile(); | 445 ~CPDF_IccProfile(); |
446 FX_DWORD GetComponents() const { return m_nSrcComponents; } | 446 uint32_t GetComponents() const { return m_nSrcComponents; } |
447 FX_BOOL m_bsRGB; | 447 FX_BOOL m_bsRGB; |
448 void* m_pTransform; | 448 void* m_pTransform; |
449 | 449 |
450 private: | 450 private: |
451 FX_DWORD m_nSrcComponents; | 451 uint32_t m_nSrcComponents; |
452 }; | 452 }; |
453 | 453 |
454 class CPDF_DeviceCS : public CPDF_ColorSpace { | 454 class CPDF_DeviceCS : public CPDF_ColorSpace { |
455 public: | 455 public: |
456 CPDF_DeviceCS(CPDF_Document* pDoc, int family); | 456 CPDF_DeviceCS(CPDF_Document* pDoc, int family); |
457 | 457 |
458 FX_BOOL GetRGB(FX_FLOAT* pBuf, | 458 FX_BOOL GetRGB(FX_FLOAT* pBuf, |
459 FX_FLOAT& R, | 459 FX_FLOAT& R, |
460 FX_FLOAT& G, | 460 FX_FLOAT& G, |
461 FX_FLOAT& B) const override; | 461 FX_FLOAT& B) const override; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
502 CPDF_Pattern* m_pPattern; | 502 CPDF_Pattern* m_pPattern; |
503 CPDF_CountedPattern* m_pCountedPattern; | 503 CPDF_CountedPattern* m_pCountedPattern; |
504 int m_nComps; | 504 int m_nComps; |
505 FX_FLOAT m_Comps[MAX_PATTERN_COLORCOMPS]; | 505 FX_FLOAT m_Comps[MAX_PATTERN_COLORCOMPS]; |
506 }; | 506 }; |
507 | 507 |
508 void PDF_ReplaceAbbr(CPDF_Object* pObj); | 508 void PDF_ReplaceAbbr(CPDF_Object* pObj); |
509 bool IsPathOperator(const uint8_t* buf, size_t len); | 509 bool IsPathOperator(const uint8_t* buf, size_t len); |
510 | 510 |
511 #endif // CORE_FPDFAPI_FPDF_PAGE_PAGEINT_H_ | 511 #endif // CORE_FPDFAPI_FPDF_PAGE_PAGEINT_H_ |
OLD | NEW |