blob: face5072c78ffe3f967e9a7998436d47702a5d33 [file] [log] [blame]
dsinclairf34518b2016-09-13 12:03:48 -07001// 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
dsinclair114e46a2016-09-29 17:18:21 -07007#ifndef FPDFSDK_CPDFSDK_PAGEVIEW_H_
8#define FPDFSDK_CPDFSDK_PAGEVIEW_H_
dsinclairf34518b2016-09-13 12:03:48 -07009
10#include <memory>
11#include <vector>
12
dsinclair41872fa2016-10-04 11:29:35 -070013#include "core/fpdfapi/page/cpdf_page.h"
Tom Sepezcc205132017-05-16 14:01:47 -070014#include "core/fxcrt/cfx_unowned_ptr.h"
dsinclaira52ab742016-09-29 13:59:29 -070015#include "core/fxcrt/fx_system.h"
dsinclair114e46a2016-09-29 17:18:21 -070016#include "fpdfsdk/cpdfsdk_annot.h"
dsinclairf34518b2016-09-13 12:03:48 -070017
18class CFX_RenderDevice;
19class CPDF_AnnotList;
20class CPDF_RenderOptions;
21
22class CPDFSDK_PageView final : public CPDF_Page::View {
23 public:
dsinclairb402b172016-10-11 09:26:32 -070024 CPDFSDK_PageView(CPDFSDK_FormFillEnvironment* pFormFillEnv,
25 UnderlyingPageType* page);
dsinclairf34518b2016-09-13 12:03:48 -070026 ~CPDFSDK_PageView();
27
28#ifdef PDF_ENABLE_XFA
29 void PageView_OnDraw(CFX_RenderDevice* pDevice,
30 CFX_Matrix* pUser2Device,
31 CPDF_RenderOptions* pOptions,
32 const FX_RECT& pClip);
33#else // PDF_ENABLE_XFA
34 void PageView_OnDraw(CFX_RenderDevice* pDevice,
35 CFX_Matrix* pUser2Device,
36 CPDF_RenderOptions* pOptions);
37#endif // PDF_ENABLE_XFA
38
dsinclair8afe15a2016-10-05 12:00:34 -070039 void LoadFXAnnots();
dsinclairf34518b2016-09-13 12:03:48 -070040 CPDFSDK_Annot* GetFocusAnnot();
dsinclair8afe15a2016-10-05 12:00:34 -070041 bool IsValidAnnot(const CPDF_Annot* p) const;
42 bool IsValidSDKAnnot(const CPDFSDK_Annot* p) const;
dsinclairf34518b2016-09-13 12:03:48 -070043
dsinclair8afe15a2016-10-05 12:00:34 -070044 const std::vector<CPDFSDK_Annot*>& GetAnnotList() const {
45 return m_SDKAnnotArray;
46 }
dsinclairf34518b2016-09-13 12:03:48 -070047 CPDFSDK_Annot* GetAnnotByDict(CPDF_Dictionary* pDict);
48
49#ifdef PDF_ENABLE_XFA
tsepez4cf55152016-11-02 14:37:54 -070050 bool DeleteAnnot(CPDFSDK_Annot* pAnnot);
dsinclairf34518b2016-09-13 12:03:48 -070051 CPDFSDK_Annot* AddAnnot(CXFA_FFWidget* pPDFAnnot);
52 CPDFSDK_Annot* GetAnnotByXFAWidget(CXFA_FFWidget* hWidget);
dsinclair8afe15a2016-10-05 12:00:34 -070053
dsinclairf34518b2016-09-13 12:03:48 -070054 CPDFXFA_Page* GetPDFXFAPage() { return m_page; }
55#endif // PDF_ENABLE_XFA
56
57 CPDF_Page* GetPDFPage() const;
58 CPDF_Document* GetPDFDocument();
Tom Sepezcc205132017-05-16 14:01:47 -070059 CPDFSDK_FormFillEnvironment* GetFormFillEnv() const {
60 return m_pFormFillEnv.Get();
61 }
62
Diana Gagedce2d722017-06-20 11:17:11 -070063 CFX_WideString GetSelectedText();
Diana Gageab390972017-07-28 17:07:39 -070064 void ReplaceSelection(const CFX_WideString& text);
Diana Gagedce2d722017-06-20 11:17:11 -070065
Dan Sinclairf528eee2017-02-14 11:52:07 -050066 bool OnLButtonDown(const CFX_PointF& point, uint32_t nFlag);
67 bool OnLButtonUp(const CFX_PointF& point, uint32_t nFlag);
dsinclairf34518b2016-09-13 12:03:48 -070068#ifdef PDF_ENABLE_XFA
Dan Sinclairf528eee2017-02-14 11:52:07 -050069 bool OnRButtonDown(const CFX_PointF& point, uint32_t nFlag);
70 bool OnRButtonUp(const CFX_PointF& point, uint32_t nFlag);
dsinclairf34518b2016-09-13 12:03:48 -070071#endif // PDF_ENABLE_XFA
tsepez4cf55152016-11-02 14:37:54 -070072 bool OnChar(int nChar, uint32_t nFlag);
73 bool OnKeyDown(int nKeyCode, int nFlag);
74 bool OnKeyUp(int nKeyCode, int nFlag);
dsinclairf34518b2016-09-13 12:03:48 -070075
Dan Sinclairf528eee2017-02-14 11:52:07 -050076 bool OnMouseMove(const CFX_PointF& point, int nFlag);
tsepez4cf55152016-11-02 14:37:54 -070077 bool OnMouseWheel(double deltaX,
78 double deltaY,
Dan Sinclairf528eee2017-02-14 11:52:07 -050079 const CFX_PointF& point,
tsepez4cf55152016-11-02 14:37:54 -070080 int nFlag);
dsinclair8afe15a2016-10-05 12:00:34 -070081
dsinclairf34518b2016-09-13 12:03:48 -070082 void GetCurrentMatrix(CFX_Matrix& matrix) { matrix = m_curMatrix; }
83 void UpdateRects(const std::vector<CFX_FloatRect>& rects);
84 void UpdateView(CPDFSDK_Annot* pAnnot);
dsinclairf34518b2016-09-13 12:03:48 -070085
86 int GetPageIndex() const;
dsinclaire5393582016-10-03 11:25:00 -070087
tsepez4cf55152016-11-02 14:37:54 -070088 void SetValid(bool bValid) { m_bValid = bValid; }
89 bool IsValid() { return m_bValid; }
dsinclaire5393582016-10-03 11:25:00 -070090
tsepez4cf55152016-11-02 14:37:54 -070091 bool IsLocked() { return m_bLocked; }
dsinclairbcf46232016-10-03 13:02:27 -070092
93 void SetBeingDestroyed() { m_bBeingDestroyed = true; }
94 bool IsBeingDestroyed() const { return m_bBeingDestroyed; }
95
dsinclairf34518b2016-09-13 12:03:48 -070096#ifndef PDF_ENABLE_XFA
97 bool OwnsPage() const { return m_bOwnsPage; }
98 void TakePageOwnership() { m_bOwnsPage = true; }
99#endif // PDF_ENABLE_XFA
100
101 private:
Dan Sinclairb45ea1f2017-02-21 14:27:59 -0500102 CPDFSDK_Annot* GetFXAnnotAtPoint(const CFX_PointF& point);
103 CPDFSDK_Annot* GetFXWidgetAtPoint(const CFX_PointF& point);
104
dsinclairf34518b2016-09-13 12:03:48 -0700105 int GetPageIndexForStaticPDF() const;
106
107 CFX_Matrix m_curMatrix;
108 UnderlyingPageType* const m_page;
109 std::unique_ptr<CPDF_AnnotList> m_pAnnotList;
dsinclair8afe15a2016-10-05 12:00:34 -0700110 std::vector<CPDFSDK_Annot*> m_SDKAnnotArray;
Tom Sepezcc205132017-05-16 14:01:47 -0700111 CFX_UnownedPtr<CPDFSDK_FormFillEnvironment> const m_pFormFillEnv;
tsepezf8074ce2016-09-27 14:29:57 -0700112 CPDFSDK_Annot::ObservedPtr m_pCaptureWidget;
dsinclairf34518b2016-09-13 12:03:48 -0700113#ifndef PDF_ENABLE_XFA
114 bool m_bOwnsPage;
115#endif // PDF_ENABLE_XFA
tsepez4cf55152016-11-02 14:37:54 -0700116 bool m_bEnterWidget;
tsepez4cf55152016-11-02 14:37:54 -0700117 bool m_bOnWidget;
118 bool m_bValid;
119 bool m_bLocked;
dsinclairbcf46232016-10-03 13:02:27 -0700120 bool m_bBeingDestroyed;
dsinclairf34518b2016-09-13 12:03:48 -0700121};
122
dsinclair114e46a2016-09-29 17:18:21 -0700123#endif // FPDFSDK_CPDFSDK_PAGEVIEW_H_