• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2016 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_CPDFSDK_PAGEVIEW_H_
8 #define FPDFSDK_CPDFSDK_PAGEVIEW_H_
9 
10 #include <memory>
11 #include <vector>
12 
13 #include "core/fpdfapi/page/cpdf_page.h"
14 #include "core/fxcrt/fx_system.h"
15 #include "fpdfsdk/cpdfsdk_annot.h"
16 
17 class CFX_RenderDevice;
18 class CPDF_AnnotList;
19 class CPDF_RenderOptions;
20 
21 class CPDFSDK_PageView final : public CPDF_Page::View {
22  public:
23   CPDFSDK_PageView(CPDFSDK_FormFillEnvironment* pFormFillEnv,
24                    UnderlyingPageType* page);
25   ~CPDFSDK_PageView();
26 
27 #ifdef PDF_ENABLE_XFA
28   void PageView_OnDraw(CFX_RenderDevice* pDevice,
29                        CFX_Matrix* pUser2Device,
30                        CPDF_RenderOptions* pOptions,
31                        const FX_RECT& pClip);
32 #else   // PDF_ENABLE_XFA
33   void PageView_OnDraw(CFX_RenderDevice* pDevice,
34                        CFX_Matrix* pUser2Device,
35                        CPDF_RenderOptions* pOptions);
36 #endif  // PDF_ENABLE_XFA
37 
38   void LoadFXAnnots();
39   CPDFSDK_Annot* GetFocusAnnot();
40   bool IsValidAnnot(const CPDF_Annot* p) const;
41   bool IsValidSDKAnnot(const CPDFSDK_Annot* p) const;
42 
GetAnnotList()43   const std::vector<CPDFSDK_Annot*>& GetAnnotList() const {
44     return m_SDKAnnotArray;
45   }
46   CPDFSDK_Annot* GetAnnotByDict(CPDF_Dictionary* pDict);
47 
48 #ifdef PDF_ENABLE_XFA
49   bool DeleteAnnot(CPDFSDK_Annot* pAnnot);
50   CPDFSDK_Annot* AddAnnot(CXFA_FFWidget* pPDFAnnot);
51   CPDFSDK_Annot* GetAnnotByXFAWidget(CXFA_FFWidget* hWidget);
52 
GetPDFXFAPage()53   CPDFXFA_Page* GetPDFXFAPage() { return m_page; }
54 #endif  // PDF_ENABLE_XFA
55 
56   CPDF_Page* GetPDFPage() const;
57   CPDF_Document* GetPDFDocument();
GetFormFillEnv()58   CPDFSDK_FormFillEnvironment* GetFormFillEnv() const { return m_pFormFillEnv; }
59   bool OnLButtonDown(const CFX_PointF& point, uint32_t nFlag);
60   bool OnLButtonUp(const CFX_PointF& point, uint32_t nFlag);
61 #ifdef PDF_ENABLE_XFA
62   bool OnRButtonDown(const CFX_PointF& point, uint32_t nFlag);
63   bool OnRButtonUp(const CFX_PointF& point, uint32_t nFlag);
64 #endif  // PDF_ENABLE_XFA
65   bool OnChar(int nChar, uint32_t nFlag);
66   bool OnKeyDown(int nKeyCode, int nFlag);
67   bool OnKeyUp(int nKeyCode, int nFlag);
68 
69   bool OnMouseMove(const CFX_PointF& point, int nFlag);
70   bool OnMouseWheel(double deltaX,
71                     double deltaY,
72                     const CFX_PointF& point,
73                     int nFlag);
74 
GetCurrentMatrix(CFX_Matrix & matrix)75   void GetCurrentMatrix(CFX_Matrix& matrix) { matrix = m_curMatrix; }
76   void UpdateRects(const std::vector<CFX_FloatRect>& rects);
77   void UpdateView(CPDFSDK_Annot* pAnnot);
78 
79   int GetPageIndex() const;
80 
SetValid(bool bValid)81   void SetValid(bool bValid) { m_bValid = bValid; }
IsValid()82   bool IsValid() { return m_bValid; }
83 
SetLock(bool bLocked)84   void SetLock(bool bLocked) { m_bLocked = bLocked; }
IsLocked()85   bool IsLocked() { return m_bLocked; }
86 
SetBeingDestroyed()87   void SetBeingDestroyed() { m_bBeingDestroyed = true; }
IsBeingDestroyed()88   bool IsBeingDestroyed() const { return m_bBeingDestroyed; }
89 
90 #ifndef PDF_ENABLE_XFA
OwnsPage()91   bool OwnsPage() const { return m_bOwnsPage; }
TakePageOwnership()92   void TakePageOwnership() { m_bOwnsPage = true; }
93 #endif  // PDF_ENABLE_XFA
94 
95  private:
96   CPDFSDK_Annot* GetFXAnnotAtPoint(const CFX_PointF& point);
97   CPDFSDK_Annot* GetFXWidgetAtPoint(const CFX_PointF& point);
98 
99   int GetPageIndexForStaticPDF() const;
100 
101   CFX_Matrix m_curMatrix;
102   UnderlyingPageType* const m_page;
103   std::unique_ptr<CPDF_AnnotList> m_pAnnotList;
104   std::vector<CPDFSDK_Annot*> m_SDKAnnotArray;
105   CPDFSDK_FormFillEnvironment* const m_pFormFillEnv;  // Not owned.
106   CPDFSDK_Annot::ObservedPtr m_pCaptureWidget;
107 #ifndef PDF_ENABLE_XFA
108   bool m_bOwnsPage;
109 #endif  // PDF_ENABLE_XFA
110   bool m_bEnterWidget;
111   bool m_bExitWidget;
112   bool m_bOnWidget;
113   bool m_bValid;
114   bool m_bLocked;
115   bool m_bBeingDestroyed;
116 };
117 
118 #endif  // FPDFSDK_CPDFSDK_PAGEVIEW_H_
119