1 // Copyright 2016 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_FPDFAPI_PAGE_CPDF_PAGE_H_ 8 #define CORE_FPDFAPI_PAGE_CPDF_PAGE_H_ 9 10 #include <map> 11 #include <memory> 12 13 #include "core/fpdfapi/page/cpdf_pageobjectholder.h" 14 #include "core/fxcrt/fx_basic.h" 15 #include "core/fxcrt/fx_coordinates.h" 16 #include "core/fxcrt/fx_system.h" 17 18 class CPDF_Dictionary; 19 class CPDF_Document; 20 class CPDF_Object; 21 class CPDF_PageRenderCache; 22 class CPDF_PageRenderContext; 23 24 // These structs are used to keep track of resources that have already been 25 // generated in the page. 26 struct GraphicsData { 27 FX_FLOAT fillAlpha; 28 FX_FLOAT strokeAlpha; 29 bool operator<(const GraphicsData& other) const; 30 }; 31 32 struct FontData { 33 CFX_ByteString baseFont; 34 bool operator<(const FontData& other) const; 35 }; 36 37 class CPDF_Page : public CPDF_PageObjectHolder { 38 public: 39 class View {}; // Caller implements as desired, empty here due to layering. 40 41 CPDF_Page(CPDF_Document* pDocument, 42 CPDF_Dictionary* pPageDict, 43 bool bPageCache); 44 ~CPDF_Page() override; 45 46 void ParseContent(); 47 48 CFX_Matrix GetDisplayMatrix(int xPos, 49 int yPos, 50 int xSize, 51 int ySize, 52 int iRotate) const; 53 54 FX_FLOAT GetPageWidth() const { return m_PageWidth; } 55 FX_FLOAT GetPageHeight() const { return m_PageHeight; } 56 CFX_FloatRect GetPageBBox() const { return m_BBox; } 57 const CFX_Matrix& GetPageMatrix() const { return m_PageMatrix; } 58 CPDF_Object* GetPageAttr(const CFX_ByteString& name) const; 59 CPDF_PageRenderCache* GetRenderCache() const { return m_pPageRender.get(); } 60 61 CPDF_PageRenderContext* GetRenderContext() const { 62 return m_pRenderContext.get(); 63 } 64 void SetRenderContext(std::unique_ptr<CPDF_PageRenderContext> pContext); 65 66 View* GetView() const { return m_pView; } 67 void SetView(View* pView) { m_pView = pView; } 68 69 std::map<GraphicsData, CFX_ByteString> m_GraphicsMap; 70 std::map<FontData, CFX_ByteString> m_FontsMap; 71 72 protected: 73 void StartParse(); 74 75 FX_FLOAT m_PageWidth; 76 FX_FLOAT m_PageHeight; 77 CFX_Matrix m_PageMatrix; 78 View* m_pView; 79 std::unique_ptr<CPDF_PageRenderCache> m_pPageRender; 80 std::unique_ptr<CPDF_PageRenderContext> m_pRenderContext; 81 }; 82 83 #endif // CORE_FPDFAPI_PAGE_CPDF_PAGE_H_ 84