Lei Zhang | 9429368 | 2016-01-27 18:27:56 -0800 | [diff] [blame] | 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 | |
dsinclair | 4d29e78 | 2016-10-04 14:02:47 -0700 | [diff] [blame] | 7 | #ifndef FPDFSDK_FPDFXFA_CPDFXFA_PAGE_H_ |
| 8 | #define FPDFSDK_FPDFXFA_CPDFXFA_PAGE_H_ |
Lei Zhang | 9429368 | 2016-01-27 18:27:56 -0800 | [diff] [blame] | 9 | |
thestig | 9f3dbbc | 2016-04-13 13:18:21 -0700 | [diff] [blame] | 10 | #include <memory> |
| 11 | |
Tom Sepez | 9792f16 | 2017-05-16 14:11:30 -0700 | [diff] [blame] | 12 | #include "core/fxcrt/cfx_retain_ptr.h" |
Tom Sepez | 797ca5c | 2017-05-25 12:03:18 -0700 | [diff] [blame] | 13 | #include "core/fxcrt/cfx_unowned_ptr.h" |
dsinclair | a52ab74 | 2016-09-29 13:59:29 -0700 | [diff] [blame] | 14 | #include "core/fxcrt/fx_system.h" |
Dan Sinclair | aa403d3 | 2016-03-15 14:57:22 -0400 | [diff] [blame] | 15 | |
weili | 625ad66 | 2016-06-15 11:21:33 -0700 | [diff] [blame] | 16 | class CFX_Matrix; |
dsinclair | 521b750 | 2016-11-02 13:02:28 -0700 | [diff] [blame] | 17 | class CPDFXFA_Context; |
weili | 625ad66 | 2016-06-15 11:21:33 -0700 | [diff] [blame] | 18 | class CPDF_Dictionary; |
dan sinclair | 06f49c8 | 2016-02-27 08:53:48 -0500 | [diff] [blame] | 19 | class CPDF_Page; |
dsinclair | df4bc59 | 2016-03-31 20:34:43 -0700 | [diff] [blame] | 20 | class CXFA_FFPageView; |
dan sinclair | 06f49c8 | 2016-02-27 08:53:48 -0500 | [diff] [blame] | 21 | |
Tom Sepez | 9792f16 | 2017-05-16 14:11:30 -0700 | [diff] [blame] | 22 | class CPDFXFA_Page : public CFX_Retainable { |
Lei Zhang | 9429368 | 2016-01-27 18:27:56 -0800 | [diff] [blame] | 23 | public: |
Tom Sepez | 9792f16 | 2017-05-16 14:11:30 -0700 | [diff] [blame] | 24 | template <typename T, typename... Args> |
| 25 | friend CFX_RetainPtr<T> pdfium::MakeRetain(Args&&... args); |
thestig | 9f3dbbc | 2016-04-13 13:18:21 -0700 | [diff] [blame] | 26 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 27 | bool LoadPage(); |
| 28 | bool LoadPDFPage(CPDF_Dictionary* pageDict); |
Tom Sepez | 797ca5c | 2017-05-25 12:03:18 -0700 | [diff] [blame] | 29 | CPDFXFA_Context* GetContext() const { return m_pContext.Get(); } |
thestig | 9f3dbbc | 2016-04-13 13:18:21 -0700 | [diff] [blame] | 30 | int GetPageIndex() const { return m_iPageIndex; } |
| 31 | CPDF_Page* GetPDFPage() const { return m_pPDFPage.get(); } |
| 32 | CXFA_FFPageView* GetXFAPageView() const { return m_pXFAPageView; } |
| 33 | |
dsinclair | df4bc59 | 2016-03-31 20:34:43 -0700 | [diff] [blame] | 34 | void SetXFAPageView(CXFA_FFPageView* pPageView) { |
| 35 | m_pXFAPageView = pPageView; |
| 36 | } |
Lei Zhang | 9429368 | 2016-01-27 18:27:56 -0800 | [diff] [blame] | 37 | |
Dan Sinclair | 05df075 | 2017-03-14 14:43:42 -0400 | [diff] [blame] | 38 | float GetPageWidth() const; |
| 39 | float GetPageHeight() const; |
Lei Zhang | 9429368 | 2016-01-27 18:27:56 -0800 | [diff] [blame] | 40 | |
| 41 | void DeviceToPage(int start_x, |
| 42 | int start_y, |
| 43 | int size_x, |
| 44 | int size_y, |
| 45 | int rotate, |
| 46 | int device_x, |
| 47 | int device_y, |
| 48 | double* page_x, |
| 49 | double* page_y); |
| 50 | void PageToDevice(int start_x, |
| 51 | int start_y, |
| 52 | int size_x, |
| 53 | int size_y, |
| 54 | int rotate, |
| 55 | double page_x, |
| 56 | double page_y, |
| 57 | int* device_x, |
| 58 | int* device_y); |
| 59 | |
Dan Sinclair | 1b08df1 | 2017-02-09 09:17:20 -0500 | [diff] [blame] | 60 | CFX_Matrix GetDisplayMatrix(int xPos, |
| 61 | int yPos, |
| 62 | int xSize, |
| 63 | int ySize, |
| 64 | int iRotate) const; |
Lei Zhang | 9429368 | 2016-01-27 18:27:56 -0800 | [diff] [blame] | 65 | |
| 66 | protected: |
thestig | 9f3dbbc | 2016-04-13 13:18:21 -0700 | [diff] [blame] | 67 | // Refcounted class. |
Tom Sepez | 9792f16 | 2017-05-16 14:11:30 -0700 | [diff] [blame] | 68 | CPDFXFA_Page(CPDFXFA_Context* pContext, int page_index); |
| 69 | ~CPDFXFA_Page() override; |
thestig | 9f3dbbc | 2016-04-13 13:18:21 -0700 | [diff] [blame] | 70 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 71 | bool LoadPDFPage(); |
| 72 | bool LoadXFAPageView(); |
Lei Zhang | 9429368 | 2016-01-27 18:27:56 -0800 | [diff] [blame] | 73 | |
| 74 | private: |
thestig | 9f3dbbc | 2016-04-13 13:18:21 -0700 | [diff] [blame] | 75 | std::unique_ptr<CPDF_Page> m_pPDFPage; |
dsinclair | df4bc59 | 2016-03-31 20:34:43 -0700 | [diff] [blame] | 76 | CXFA_FFPageView* m_pXFAPageView; |
Tom Sepez | 797ca5c | 2017-05-25 12:03:18 -0700 | [diff] [blame] | 77 | CFX_UnownedPtr<CPDFXFA_Context> const m_pContext; |
thestig | 9f3dbbc | 2016-04-13 13:18:21 -0700 | [diff] [blame] | 78 | const int m_iPageIndex; |
Lei Zhang | 9429368 | 2016-01-27 18:27:56 -0800 | [diff] [blame] | 79 | }; |
| 80 | |
dsinclair | 4d29e78 | 2016-10-04 14:02:47 -0700 | [diff] [blame] | 81 | #endif // FPDFSDK_FPDFXFA_CPDFXFA_PAGE_H_ |