Dan Sinclair | 455a419 | 2016-03-16 09:48:56 -0400 | [diff] [blame] | 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 | |
dsinclair | 41872fa | 2016-10-04 11:29:35 -0700 | [diff] [blame] | 7 | #ifndef CORE_FPDFAPI_PAGE_CPDF_PAGE_H_ |
| 8 | #define CORE_FPDFAPI_PAGE_CPDF_PAGE_H_ |
Dan Sinclair | 455a419 | 2016-03-16 09:48:56 -0400 | [diff] [blame] | 9 | |
thestig | 5cc2465 | 2016-04-26 11:46:02 -0700 | [diff] [blame] | 10 | #include <memory> |
| 11 | |
dsinclair | 41872fa | 2016-10-04 11:29:35 -0700 | [diff] [blame] | 12 | #include "core/fpdfapi/page/cpdf_pageobjectholder.h" |
dsinclair | a52ab74 | 2016-09-29 13:59:29 -0700 | [diff] [blame] | 13 | #include "core/fxcrt/fx_basic.h" |
| 14 | #include "core/fxcrt/fx_coordinates.h" |
| 15 | #include "core/fxcrt/fx_system.h" |
Dan Sinclair | 455a419 | 2016-03-16 09:48:56 -0400 | [diff] [blame] | 16 | |
Dan Sinclair | 455a419 | 2016-03-16 09:48:56 -0400 | [diff] [blame] | 17 | class CPDF_Dictionary; |
thestig | 5cc2465 | 2016-04-26 11:46:02 -0700 | [diff] [blame] | 18 | class CPDF_Document; |
Dan Sinclair | 455a419 | 2016-03-16 09:48:56 -0400 | [diff] [blame] | 19 | class CPDF_Object; |
| 20 | class CPDF_PageRenderCache; |
weili | 9f515bc | 2016-07-24 08:08:24 -0700 | [diff] [blame] | 21 | class CPDF_PageRenderContext; |
Dan Sinclair | 584b1e6 | 2016-03-21 09:15:45 -0400 | [diff] [blame] | 22 | |
tsepez | 1e2c557 | 2016-05-25 14:58:09 -0700 | [diff] [blame] | 23 | class CPDF_Page : public CPDF_PageObjectHolder { |
Dan Sinclair | 455a419 | 2016-03-16 09:48:56 -0400 | [diff] [blame] | 24 | public: |
tsepez | 1e2c557 | 2016-05-25 14:58:09 -0700 | [diff] [blame] | 25 | class View {}; // Caller implements as desired, empty here due to layering. |
| 26 | |
thestig | 5cc2465 | 2016-04-26 11:46:02 -0700 | [diff] [blame] | 27 | CPDF_Page(CPDF_Document* pDocument, |
| 28 | CPDF_Dictionary* pPageDict, |
| 29 | bool bPageCache); |
weili | 868150b | 2016-06-13 14:57:29 -0700 | [diff] [blame] | 30 | ~CPDF_Page() override; |
Dan Sinclair | 455a419 | 2016-03-16 09:48:56 -0400 | [diff] [blame] | 31 | |
Jane Liu | 22eb7ae | 2017-06-26 13:24:23 -0400 | [diff] [blame] | 32 | // CPDF_PageObjectHolder |
| 33 | bool IsPage() const override; |
| 34 | |
thestig | 5cc2465 | 2016-04-26 11:46:02 -0700 | [diff] [blame] | 35 | void ParseContent(); |
Dan Sinclair | 455a419 | 2016-03-16 09:48:56 -0400 | [diff] [blame] | 36 | |
Dan Sinclair | 1b08df1 | 2017-02-09 09:17:20 -0500 | [diff] [blame] | 37 | CFX_Matrix GetDisplayMatrix(int xPos, |
| 38 | int yPos, |
| 39 | int xSize, |
| 40 | int ySize, |
| 41 | int iRotate) const; |
Dan Sinclair | 455a419 | 2016-03-16 09:48:56 -0400 | [diff] [blame] | 42 | |
Dan Sinclair | 05df075 | 2017-03-14 14:43:42 -0400 | [diff] [blame] | 43 | float GetPageWidth() const { return m_PageWidth; } |
| 44 | float GetPageHeight() const { return m_PageHeight; } |
Dan Sinclair | 455a419 | 2016-03-16 09:48:56 -0400 | [diff] [blame] | 45 | CFX_FloatRect GetPageBBox() const { return m_BBox; } |
| 46 | const CFX_Matrix& GetPageMatrix() const { return m_PageMatrix; } |
rbpotter | ce8e51e | 2017-04-28 12:42:47 -0700 | [diff] [blame] | 47 | int GetPageRotation() const; |
thestig | 5cc2465 | 2016-04-26 11:46:02 -0700 | [diff] [blame] | 48 | CPDF_PageRenderCache* GetRenderCache() const { return m_pPageRender.get(); } |
Dan Sinclair | 455a419 | 2016-03-16 09:48:56 -0400 | [diff] [blame] | 49 | |
weili | 9f515bc | 2016-07-24 08:08:24 -0700 | [diff] [blame] | 50 | CPDF_PageRenderContext* GetRenderContext() const { |
| 51 | return m_pRenderContext.get(); |
tsepez | 1e2c557 | 2016-05-25 14:58:09 -0700 | [diff] [blame] | 52 | } |
weili | 9f515bc | 2016-07-24 08:08:24 -0700 | [diff] [blame] | 53 | void SetRenderContext(std::unique_ptr<CPDF_PageRenderContext> pContext); |
tsepez | 1e2c557 | 2016-05-25 14:58:09 -0700 | [diff] [blame] | 54 | |
| 55 | View* GetView() const { return m_pView; } |
| 56 | void SetView(View* pView) { m_pView = pView; } |
| 57 | |
Lei Zhang | d928181 | 2017-05-26 10:33:45 -0700 | [diff] [blame] | 58 | private: |
thestig | 5cc2465 | 2016-04-26 11:46:02 -0700 | [diff] [blame] | 59 | void StartParse(); |
Dan Sinclair | 455a419 | 2016-03-16 09:48:56 -0400 | [diff] [blame] | 60 | |
Lei Zhang | d928181 | 2017-05-26 10:33:45 -0700 | [diff] [blame] | 61 | CPDF_Object* GetPageAttr(const CFX_ByteString& name) const; |
| 62 | CFX_FloatRect GetBox(const CFX_ByteString& name) const; |
| 63 | |
Dan Sinclair | 05df075 | 2017-03-14 14:43:42 -0400 | [diff] [blame] | 64 | float m_PageWidth; |
| 65 | float m_PageHeight; |
Dan Sinclair | 455a419 | 2016-03-16 09:48:56 -0400 | [diff] [blame] | 66 | CFX_Matrix m_PageMatrix; |
tsepez | 1e2c557 | 2016-05-25 14:58:09 -0700 | [diff] [blame] | 67 | View* m_pView; |
thestig | 5cc2465 | 2016-04-26 11:46:02 -0700 | [diff] [blame] | 68 | std::unique_ptr<CPDF_PageRenderCache> m_pPageRender; |
weili | 9f515bc | 2016-07-24 08:08:24 -0700 | [diff] [blame] | 69 | std::unique_ptr<CPDF_PageRenderContext> m_pRenderContext; |
Dan Sinclair | 455a419 | 2016-03-16 09:48:56 -0400 | [diff] [blame] | 70 | }; |
| 71 | |
dsinclair | 41872fa | 2016-10-04 11:29:35 -0700 | [diff] [blame] | 72 | #endif // CORE_FPDFAPI_PAGE_CPDF_PAGE_H_ |