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