• 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 "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/fx_system.h"
14 #include "core/fxcrt/retain_ptr.h"
15 #include "core/fxcrt/unowned_ptr.h"
16 #include "third_party/base/optional.h"
17 
18 class CFX_RenderDevice;
19 class CPDF_Dictionary;
20 class CPDF_Document;
21 class CPDFSDK_Annot;
22 class CXFA_FFPageView;
23 
24 class CPDFXFA_Page final : public IPDF_Page {
25  public:
26   template <typename T, typename... Args>
27   friend RetainPtr<T> pdfium::MakeRetain(Args&&... args);
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   Optional<CFX_PointF> DeviceToPage(
37       const FX_RECT& rect,
38       int rotate,
39       const CFX_PointF& device_point) const override;
40   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(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, bool bNext);
51   int HasFormFieldAtPoint(const CFX_PointF& point) const;
52   void DrawFocusAnnot(CFX_RenderDevice* pDevice,
53                       CPDFSDK_Annot* pAnnot,
54                       const CFX_Matrix& mtUser2Device,
55                       const FX_RECT& rtClip);
56 
57  private:
58   // Refcounted class.
59   CPDFXFA_Page(CPDF_Document* pDocument, int page_index);
60   ~CPDFXFA_Page() override;
61 
62   bool LoadPDFPage();
63 
64   RetainPtr<CPDF_Page> m_pPDFPage;  // Backing page, if any.
65   UnownedPtr<CPDF_Document> const m_pDocument;
66   int m_iPageIndex;
67 };
68 
69 #endif  // FPDFSDK_FPDFXFA_CPDFXFA_PAGE_H_
70