• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "core/fxcrt/retain_ptr.h"
14 #include "core/fxcrt/unowned_ptr.h"
15 
16 class CFX_Matrix;
17 class CPDFXFA_Context;
18 class CPDF_Dictionary;
19 class CPDF_Page;
20 class CXFA_FFPageView;
21 
22 class CPDFXFA_Page : public Retainable {
23  public:
24   template <typename T, typename... Args>
25   friend RetainPtr<T> pdfium::MakeRetain(Args&&... args);
26 
27   bool LoadPage();
28   bool LoadPDFPage(CPDF_Dictionary* pageDict);
GetContext()29   CPDFXFA_Context* GetContext() const { return m_pContext.Get(); }
GetPageIndex()30   int GetPageIndex() const { return m_iPageIndex; }
GetPDFPage()31   CPDF_Page* GetPDFPage() const { return m_pPDFPage.get(); }
GetXFAPageView()32   CXFA_FFPageView* GetXFAPageView() const { return m_pXFAPageView; }
33 
SetXFAPageView(CXFA_FFPageView * pPageView)34   void SetXFAPageView(CXFA_FFPageView* pPageView) {
35     m_pXFAPageView = pPageView;
36   }
37 
38   float GetPageWidth() const;
39   float GetPageHeight() const;
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 
60   CFX_Matrix GetDisplayMatrix(int xPos,
61                               int yPos,
62                               int xSize,
63                               int ySize,
64                               int iRotate) const;
65 
66  protected:
67   // Refcounted class.
68   CPDFXFA_Page(CPDFXFA_Context* pContext, int page_index);
69   ~CPDFXFA_Page() override;
70 
71   bool LoadPDFPage();
72   bool LoadXFAPageView();
73 
74  private:
75   std::unique_ptr<CPDF_Page> m_pPDFPage;
76   CXFA_FFPageView* m_pXFAPageView;
77   UnownedPtr<CPDFXFA_Context> const m_pContext;
78   const int m_iPageIndex;
79 };
80 
81 #endif  // FPDFSDK_FPDFXFA_CPDFXFA_PAGE_H_
82