| 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_PAGE_PAGEINT_H_ | 7 #ifndef CORE_FPDFAPI_PAGE_PAGEINT_H_ |
| 8 #define CORE_FPDFAPI_PAGE_PAGEINT_H_ | 8 #define CORE_FPDFAPI_PAGE_PAGEINT_H_ |
| 9 | 9 |
| 10 #include <map> | |
| 11 #include <memory> | 10 #include <memory> |
| 12 #include <set> | |
| 13 #include <unordered_map> | |
| 14 #include <utility> | |
| 15 #include <vector> | 11 #include <vector> |
| 16 | 12 |
| 17 #include "core/fpdfapi/page/cpdf_contentmark.h" | 13 #include "core/fpdfapi/page/cpdf_colorspace.h" |
| 18 #include "core/fpdfapi/page/cpdf_countedobject.h" | 14 #include "core/fpdfapi/page/cpdf_countedobject.h" |
| 19 #include "core/fpdfapi/page/cpdf_pageobjectholder.h" | |
| 20 #include "core/fpdfapi/page/cpdf_streamcontentparser.h" | |
| 21 #include "core/fpdfapi/parser/cpdf_stream.h" | |
| 22 #include "core/fxcrt/cfx_string_pool_template.h" | |
| 23 #include "core/fxcrt/cfx_weak_ptr.h" | |
| 24 #include "core/fxge/cfx_pathdata.h" | |
| 25 #include "core/fxge/cfx_renderdevice.h" | |
| 26 | 15 |
| 27 class CPDF_AllStates; | |
| 28 class CPDF_ColorSpace; | |
| 29 class CPDF_ExpIntFunc; | 16 class CPDF_ExpIntFunc; |
| 30 class CPDF_Font; | |
| 31 class CPDF_FontEncoding; | |
| 32 class CPDF_Form; | |
| 33 class CPDF_IccProfile; | |
| 34 class CPDF_Image; | |
| 35 class CPDF_ImageObject; | |
| 36 class CPDF_Page; | |
| 37 class CPDF_Pattern; | 17 class CPDF_Pattern; |
| 38 class CPDF_SampledFunc; | 18 class CPDF_SampledFunc; |
| 39 class CPDF_StitchFunc; | 19 class CPDF_StitchFunc; |
| 40 class CPDF_StreamAcc; | 20 class CPDF_StreamAcc; |
| 41 class CPDF_TextObject; | |
| 42 class CPDF_Type3Char; | |
| 43 | |
| 44 #define PARSE_STEP_LIMIT 100 | |
| 45 | |
| 46 class CPDF_StreamParser { | |
| 47 public: | |
| 48 enum SyntaxType { EndOfData, Number, Keyword, Name, Others }; | |
| 49 | |
| 50 CPDF_StreamParser(const uint8_t* pData, uint32_t dwSize); | |
| 51 CPDF_StreamParser(const uint8_t* pData, | |
| 52 uint32_t dwSize, | |
| 53 const CFX_WeakPtr<CFX_ByteStringPool>& pPool); | |
| 54 ~CPDF_StreamParser(); | |
| 55 | |
| 56 SyntaxType ParseNextElement(); | |
| 57 uint8_t* GetWordBuf() { return m_WordBuffer; } | |
| 58 uint32_t GetWordSize() const { return m_WordSize; } | |
| 59 uint32_t GetPos() const { return m_Pos; } | |
| 60 void SetPos(uint32_t pos) { m_Pos = pos; } | |
| 61 std::unique_ptr<CPDF_Object> GetObject() { return std::move(m_pLastObj); } | |
| 62 std::unique_ptr<CPDF_Object> ReadNextObject(bool bAllowNestedArray, | |
| 63 uint32_t dwInArrayLevel); | |
| 64 std::unique_ptr<CPDF_Stream> ReadInlineStream( | |
| 65 CPDF_Document* pDoc, | |
| 66 std::unique_ptr<CPDF_Dictionary> pDict, | |
| 67 CPDF_Object* pCSObj); | |
| 68 | |
| 69 private: | |
| 70 friend class cpdf_streamparser_ReadHexString_Test; | |
| 71 | |
| 72 void GetNextWord(bool& bIsNumber); | |
| 73 CFX_ByteString ReadString(); | |
| 74 CFX_ByteString ReadHexString(); | |
| 75 bool PositionIsInBounds() const; | |
| 76 | |
| 77 const uint8_t* m_pBuf; | |
| 78 uint32_t m_Size; // Length in bytes of m_pBuf. | |
| 79 uint32_t m_Pos; // Current byte position within m_pBuf. | |
| 80 uint8_t m_WordBuffer[256]; | |
| 81 uint32_t m_WordSize; | |
| 82 std::unique_ptr<CPDF_Object> m_pLastObj; | |
| 83 CFX_WeakPtr<CFX_ByteStringPool> m_pPool; | |
| 84 }; | |
| 85 | |
| 86 #define _FPDF_MAX_TYPE3_FORM_LEVEL_ 4 | |
| 87 | |
| 88 class CPDF_ContentParser { | |
| 89 public: | |
| 90 enum ParseStatus { Ready, ToBeContinued, Done }; | |
| 91 | |
| 92 CPDF_ContentParser(); | |
| 93 ~CPDF_ContentParser(); | |
| 94 | |
| 95 ParseStatus GetStatus() const { return m_Status; } | |
| 96 void Start(CPDF_Page* pPage); | |
| 97 void Start(CPDF_Form* pForm, | |
| 98 CPDF_AllStates* pGraphicStates, | |
| 99 const CFX_Matrix* pParentMatrix, | |
| 100 CPDF_Type3Char* pType3Char, | |
| 101 int level); | |
| 102 void Continue(IFX_Pause* pPause); | |
| 103 | |
| 104 private: | |
| 105 enum InternalStage { | |
| 106 STAGE_GETCONTENT = 1, | |
| 107 STAGE_PARSE, | |
| 108 STAGE_CHECKCLIP, | |
| 109 }; | |
| 110 | |
| 111 ParseStatus m_Status; | |
| 112 InternalStage m_InternalStage; | |
| 113 CPDF_PageObjectHolder* m_pObjectHolder; | |
| 114 bool m_bForm; | |
| 115 CPDF_Type3Char* m_pType3Char; | |
| 116 uint32_t m_nStreams; | |
| 117 std::unique_ptr<CPDF_StreamAcc> m_pSingleStream; | |
| 118 std::vector<std::unique_ptr<CPDF_StreamAcc>> m_StreamArray; | |
| 119 uint8_t* m_pData; | |
| 120 uint32_t m_Size; | |
| 121 uint32_t m_CurrentOffset; | |
| 122 std::unique_ptr<CPDF_StreamContentParser> m_pParser; | |
| 123 }; | |
| 124 | 21 |
| 125 class CPDF_Function { | 22 class CPDF_Function { |
| 126 public: | 23 public: |
| 127 enum class Type { | 24 enum class Type { |
| 128 kTypeInvalid = -1, | 25 kTypeInvalid = -1, |
| 129 kType0Sampled = 0, | 26 kType0Sampled = 0, |
| 130 kType2ExpotentialInterpolation = 2, | 27 kType2ExpotentialInterpolation = 2, |
| 131 kType3Stitching = 3, | 28 kType3Stitching = 3, |
| 132 kType4PostScript = 4, | 29 kType4PostScript = 4, |
| 133 }; | 30 }; |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 CPDF_CountedPattern* m_pCountedPattern; | 197 CPDF_CountedPattern* m_pCountedPattern; |
| 301 int m_nComps; | 198 int m_nComps; |
| 302 FX_FLOAT m_Comps[MAX_PATTERN_COLORCOMPS]; | 199 FX_FLOAT m_Comps[MAX_PATTERN_COLORCOMPS]; |
| 303 }; | 200 }; |
| 304 | 201 |
| 305 CFX_ByteStringC PDF_FindKeyAbbreviationForTesting(const CFX_ByteStringC& abbr); | 202 CFX_ByteStringC PDF_FindKeyAbbreviationForTesting(const CFX_ByteStringC& abbr); |
| 306 CFX_ByteStringC PDF_FindValueAbbreviationForTesting( | 203 CFX_ByteStringC PDF_FindValueAbbreviationForTesting( |
| 307 const CFX_ByteStringC& abbr); | 204 const CFX_ByteStringC& abbr); |
| 308 | 205 |
| 309 #endif // CORE_FPDFAPI_PAGE_PAGEINT_H_ | 206 #endif // CORE_FPDFAPI_PAGE_PAGEINT_H_ |
| OLD | NEW |