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 FPDFSDK_FPDFXFA_CPDFXFA_PAGE_H_ 8 #define FPDFSDK_FPDFXFA_CPDFXFA_PAGE_H_ 9 10 #include <memory> 11 12 #include "core/fxcrt/fx_system.h" 13 14 class CFX_Matrix; 15 class CPDFXFA_Context; 16 class CPDF_Dictionary; 17 class CPDF_Page; 18 class CXFA_FFPageView; 19 20 class CPDFXFA_Page { 21 public: 22 CPDFXFA_Page(CPDFXFA_Context* pContext, int page_index); 23 Retain()24 void Retain() { m_iRef++; } Release()25 void Release() { 26 if (--m_iRef <= 0) 27 delete this; 28 } 29 30 bool LoadPage(); 31 bool LoadPDFPage(CPDF_Dictionary* pageDict); GetContext()32 CPDFXFA_Context* GetContext() const { return m_pContext; } GetPageIndex()33 int GetPageIndex() const { return m_iPageIndex; } GetPDFPage()34 CPDF_Page* GetPDFPage() const { return m_pPDFPage.get(); } GetXFAPageView()35 CXFA_FFPageView* GetXFAPageView() const { return m_pXFAPageView; } 36 SetXFAPageView(CXFA_FFPageView * pPageView)37 void SetXFAPageView(CXFA_FFPageView* pPageView) { 38 m_pXFAPageView = pPageView; 39 } 40 41 FX_FLOAT GetPageWidth() const; 42 FX_FLOAT GetPageHeight() const; 43 44 void DeviceToPage(int start_x, 45 int start_y, 46 int size_x, 47 int size_y, 48 int rotate, 49 int device_x, 50 int device_y, 51 double* page_x, 52 double* page_y); 53 void PageToDevice(int start_x, 54 int start_y, 55 int size_x, 56 int size_y, 57 int rotate, 58 double page_x, 59 double page_y, 60 int* device_x, 61 int* device_y); 62 63 CFX_Matrix GetDisplayMatrix(int xPos, 64 int yPos, 65 int xSize, 66 int ySize, 67 int iRotate) const; 68 69 protected: 70 // Refcounted class. 71 ~CPDFXFA_Page(); 72 73 bool LoadPDFPage(); 74 bool LoadXFAPageView(); 75 76 private: 77 std::unique_ptr<CPDF_Page> m_pPDFPage; 78 CXFA_FFPageView* m_pXFAPageView; 79 CPDFXFA_Context* const m_pContext; 80 const int m_iPageIndex; 81 int m_iRef; 82 }; 83 84 #endif // FPDFSDK_FPDFXFA_CPDFXFA_PAGE_H_ 85