| OLD | NEW |
| (Empty) |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | |
| 6 | |
| 7 #ifndef CORE_INCLUDE_FPDFAPI_FPDF_PAGE_H_ | |
| 8 #define CORE_INCLUDE_FPDFAPI_FPDF_PAGE_H_ | |
| 9 | |
| 10 #include <deque> | |
| 11 #include <memory> | |
| 12 | |
| 13 #include "core/include/fpdfapi/fpdf_resource.h" | |
| 14 #include "core/include/fxge/fx_dib.h" | |
| 15 | |
| 16 class CPDF_Page; | |
| 17 class CPDF_Form; | |
| 18 class CPDF_ParseOptions; | |
| 19 class CPDF_PageObject; | |
| 20 class CPDF_PageRenderCache; | |
| 21 class CPDF_AllStates; | |
| 22 class CPDF_ContentParser; | |
| 23 class CPDF_ImageObject; | |
| 24 | |
| 25 #define PDFTRANS_GROUP 0x0100 | |
| 26 #define PDFTRANS_ISOLATED 0x0200 | |
| 27 #define PDFTRANS_KNOCKOUT 0x0400 | |
| 28 | |
| 29 class CPDF_PageObjectList | |
| 30 : public std::deque<std::unique_ptr<CPDF_PageObject>> { | |
| 31 public: | |
| 32 CPDF_PageObject* GetPageObjectByIndex(int index); | |
| 33 }; | |
| 34 | |
| 35 class CPDF_PageObjectHolder { | |
| 36 public: | |
| 37 CPDF_PageObjectHolder(); | |
| 38 | |
| 39 void ContinueParse(IFX_Pause* pPause); | |
| 40 bool IsParsed() const { return m_ParseState == CONTENT_PARSED; } | |
| 41 | |
| 42 CPDF_PageObjectList* GetPageObjectList() { return &m_PageObjectList; } | |
| 43 const CPDF_PageObjectList* GetPageObjectList() const { | |
| 44 return &m_PageObjectList; | |
| 45 } | |
| 46 | |
| 47 FX_BOOL BackgroundAlphaNeeded() const { return m_bBackgroundAlphaNeeded; } | |
| 48 void SetBackgroundAlphaNeeded(FX_BOOL needed) { | |
| 49 m_bBackgroundAlphaNeeded = needed; | |
| 50 } | |
| 51 | |
| 52 FX_BOOL HasImageMask() const { return m_bHasImageMask; } | |
| 53 void SetHasImageMask(FX_BOOL value) { m_bHasImageMask = value; } | |
| 54 | |
| 55 void Transform(const CFX_Matrix& matrix); | |
| 56 CFX_FloatRect CalcBoundingBox() const; | |
| 57 | |
| 58 CPDF_Dictionary* m_pFormDict; | |
| 59 CPDF_Stream* m_pFormStream; | |
| 60 CPDF_Document* m_pDocument; | |
| 61 CPDF_Dictionary* m_pPageResources; | |
| 62 CPDF_Dictionary* m_pResources; | |
| 63 CFX_FloatRect m_BBox; | |
| 64 int m_Transparency; | |
| 65 | |
| 66 protected: | |
| 67 enum ParseState { CONTENT_NOT_PARSED, CONTENT_PARSING, CONTENT_PARSED }; | |
| 68 | |
| 69 void LoadTransInfo(); | |
| 70 | |
| 71 FX_BOOL m_bBackgroundAlphaNeeded; | |
| 72 FX_BOOL m_bHasImageMask; | |
| 73 ParseState m_ParseState; | |
| 74 std::unique_ptr<CPDF_ContentParser> m_pParser; | |
| 75 CPDF_PageObjectList m_PageObjectList; | |
| 76 }; | |
| 77 | |
| 78 class CPDF_Page : public CPDF_PageObjectHolder, public CFX_PrivateData { | |
| 79 public: | |
| 80 CPDF_Page(); | |
| 81 ~CPDF_Page(); | |
| 82 | |
| 83 void Load(CPDF_Document* pDocument, | |
| 84 CPDF_Dictionary* pPageDict, | |
| 85 FX_BOOL bPageCache = TRUE); | |
| 86 | |
| 87 void ParseContent(CPDF_ParseOptions* pOptions); | |
| 88 | |
| 89 void GetDisplayMatrix(CFX_Matrix& matrix, | |
| 90 int xPos, | |
| 91 int yPos, | |
| 92 int xSize, | |
| 93 int ySize, | |
| 94 int iRotate) const; | |
| 95 | |
| 96 FX_FLOAT GetPageWidth() const { return m_PageWidth; } | |
| 97 FX_FLOAT GetPageHeight() const { return m_PageHeight; } | |
| 98 CFX_FloatRect GetPageBBox() const { return m_BBox; } | |
| 99 const CFX_Matrix& GetPageMatrix() const { return m_PageMatrix; } | |
| 100 CPDF_Object* GetPageAttr(const CFX_ByteStringC& name) const; | |
| 101 CPDF_PageRenderCache* GetRenderCache() const { return m_pPageRender; } | |
| 102 | |
| 103 protected: | |
| 104 friend class CPDF_ContentParser; | |
| 105 void StartParse(CPDF_ParseOptions* pOptions); | |
| 106 | |
| 107 FX_FLOAT m_PageWidth; | |
| 108 FX_FLOAT m_PageHeight; | |
| 109 CFX_Matrix m_PageMatrix; | |
| 110 CPDF_PageRenderCache* m_pPageRender; | |
| 111 }; | |
| 112 class CPDF_ParseOptions { | |
| 113 public: | |
| 114 CPDF_ParseOptions(); | |
| 115 | |
| 116 FX_BOOL m_bTextOnly; | |
| 117 | |
| 118 FX_BOOL m_bMarkedContent; | |
| 119 | |
| 120 FX_BOOL m_bSeparateForm; | |
| 121 | |
| 122 FX_BOOL m_bDecodeInlineImage; | |
| 123 }; | |
| 124 class CPDF_Form : public CPDF_PageObjectHolder { | |
| 125 public: | |
| 126 CPDF_Form(CPDF_Document* pDocument, | |
| 127 CPDF_Dictionary* pPageResources, | |
| 128 CPDF_Stream* pFormStream, | |
| 129 CPDF_Dictionary* pParentResources = NULL); | |
| 130 | |
| 131 ~CPDF_Form(); | |
| 132 | |
| 133 void StartParse(CPDF_AllStates* pGraphicStates, | |
| 134 CFX_Matrix* pParentMatrix, | |
| 135 CPDF_Type3Char* pType3Char, | |
| 136 CPDF_ParseOptions* pOptions, | |
| 137 int level = 0); | |
| 138 | |
| 139 void ParseContent(CPDF_AllStates* pGraphicStates, | |
| 140 CFX_Matrix* pParentMatrix, | |
| 141 CPDF_Type3Char* pType3Char, | |
| 142 CPDF_ParseOptions* pOptions, | |
| 143 int level = 0); | |
| 144 | |
| 145 CPDF_Form* Clone() const; | |
| 146 }; | |
| 147 class CPDF_PageContentGenerator { | |
| 148 public: | |
| 149 explicit CPDF_PageContentGenerator(CPDF_Page* pPage); | |
| 150 | |
| 151 FX_BOOL InsertPageObject(CPDF_PageObject* pPageObject); | |
| 152 void GenerateContent(); | |
| 153 void TransformContent(CFX_Matrix& matrix); | |
| 154 | |
| 155 private: | |
| 156 void ProcessImage(CFX_ByteTextBuf& buf, CPDF_ImageObject* pImageObj); | |
| 157 void ProcessForm(CFX_ByteTextBuf& buf, | |
| 158 const uint8_t* data, | |
| 159 FX_DWORD size, | |
| 160 CFX_Matrix& matrix); | |
| 161 CFX_ByteString RealizeResource(CPDF_Object* pResourceObj, | |
| 162 const FX_CHAR* szType); | |
| 163 | |
| 164 CPDF_Page* m_pPage; | |
| 165 CPDF_Document* m_pDocument; | |
| 166 CFX_ArrayTemplate<CPDF_PageObject*> m_pageObjects; | |
| 167 }; | |
| 168 | |
| 169 #endif // CORE_INCLUDE_FPDFAPI_FPDF_PAGE_H_ | |
| OLD | NEW |