• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2014 The PDFium Authors
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 "core/fpdfapi/page/cpdf_page.h"
11 #include "core/fpdfapi/page/ipdf_page.h"
12 #include "core/fxcrt/fx_coordinates.h"
13 #include "core/fxcrt/retain_ptr.h"
14 #include "core/fxcrt/unowned_ptr.h"
15 #include "third_party/abseil-cpp/absl/types/optional.h"
16 
17 class CFX_RenderDevice;
18 class CPDF_Dictionary;
19 class CPDF_Document;
20 class CPDFSDK_Annot;
21 class CPDFSDK_PageView;
22 class CXFA_FFPageView;
23 
24 class CPDFXFA_Page final : public IPDF_Page {
25  public:
26   CONSTRUCT_VIA_MAKE_RETAIN;
27 
28   // IPDF_Page:
29   CPDF_Page* AsPDFPage() override;
30   CPDFXFA_Page* AsXFAPage() override;
31   CPDF_Document* GetDocument() const override;
32   float GetPageWidth() const override;
33   float GetPageHeight() const override;
34   CFX_Matrix GetDisplayMatrix(const FX_RECT& rect, int iRotate) const override;
35   absl::optional<CFX_PointF> DeviceToPage(
36       const FX_RECT& rect,
37       int rotate,
38       const CFX_PointF& device_point) const override;
39   absl::optional<CFX_PointF> PageToDevice(
40       const FX_RECT& rect,
41       int rotate,
42       const CFX_PointF& page_point) const override;
43 
44   bool LoadPage();
45   void LoadPDFPageFromDict(RetainPtr<CPDF_Dictionary> pPageDict);
GetPageIndex()46   int GetPageIndex() const { return m_iPageIndex; }
SetXFAPageViewIndex(int index)47   void SetXFAPageViewIndex(int index) { m_iPageIndex = index; }
48   CXFA_FFPageView* GetXFAPageView() const;
49   CPDFSDK_Annot* GetNextXFAAnnot(CPDFSDK_Annot* pSDKAnnot) const;
50   CPDFSDK_Annot* GetPrevXFAAnnot(CPDFSDK_Annot* pSDKAnnot) const;
51   CPDFSDK_Annot* GetFirstXFAAnnot(CPDFSDK_PageView* page_view) const;
52   CPDFSDK_Annot* GetLastXFAAnnot(CPDFSDK_PageView* page_view) const;
53   int HasFormFieldAtPoint(const CFX_PointF& point) const;
54   void DrawFocusAnnot(CFX_RenderDevice* pDevice,
55                       CPDFSDK_Annot* pAnnot,
56                       const CFX_Matrix& mtUser2Device,
57                       const FX_RECT& rtClip);
58 
59  private:
60   // Refcounted class.
61   CPDFXFA_Page(CPDF_Document* pDocument, int page_index);
62   ~CPDFXFA_Page() override;
63 
64   bool LoadPDFPage();
65 
66   RetainPtr<CPDF_Page> m_pPDFPage;  // Backing page, if any.
67   UnownedPtr<CPDF_Document> const m_pDocument;
68   int m_iPageIndex;
69 };
70 
71 #endif  // FPDFSDK_FPDFXFA_CPDFXFA_PAGE_H_
72