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