| dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 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 |  | 
| dsinclair | 114e46a | 2016-09-29 17:18:21 -0700 | [diff] [blame] | 7 | #ifndef FPDFSDK_CPDFSDK_PAGEVIEW_H_ | 
|  | 8 | #define FPDFSDK_CPDFSDK_PAGEVIEW_H_ | 
| dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 9 |  | 
|  | 10 | #include <memory> | 
|  | 11 | #include <vector> | 
|  | 12 |  | 
| dsinclair | 41872fa | 2016-10-04 11:29:35 -0700 | [diff] [blame] | 13 | #include "core/fpdfapi/page/cpdf_page.h" | 
| dsinclair | a52ab74 | 2016-09-29 13:59:29 -0700 | [diff] [blame] | 14 | #include "core/fxcrt/fx_system.h" | 
| Dan Sinclair | aee0db0 | 2017-09-21 16:53:58 -0400 | [diff] [blame] | 15 | #include "core/fxcrt/unowned_ptr.h" | 
| dsinclair | 114e46a | 2016-09-29 17:18:21 -0700 | [diff] [blame] | 16 | #include "fpdfsdk/cpdfsdk_annot.h" | 
| Henrique Nakashima | 4a65254 | 2017-08-22 10:59:49 -0400 | [diff] [blame] | 17 | #include "fpdfsdk/cpdfsdk_annothandlermgr.h" | 
| dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 18 |  | 
|  | 19 | class CFX_RenderDevice; | 
|  | 20 | class CPDF_AnnotList; | 
|  | 21 | class CPDF_RenderOptions; | 
|  | 22 |  | 
|  | 23 | class CPDFSDK_PageView final : public CPDF_Page::View { | 
|  | 24 | public: | 
| dsinclair | b402b17 | 2016-10-11 09:26:32 -0700 | [diff] [blame] | 25 | CPDFSDK_PageView(CPDFSDK_FormFillEnvironment* pFormFillEnv, | 
|  | 26 | UnderlyingPageType* page); | 
| dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 27 | ~CPDFSDK_PageView(); | 
|  | 28 |  | 
|  | 29 | #ifdef PDF_ENABLE_XFA | 
|  | 30 | void PageView_OnDraw(CFX_RenderDevice* pDevice, | 
|  | 31 | CFX_Matrix* pUser2Device, | 
|  | 32 | CPDF_RenderOptions* pOptions, | 
|  | 33 | const FX_RECT& pClip); | 
|  | 34 | #else   // PDF_ENABLE_XFA | 
|  | 35 | void PageView_OnDraw(CFX_RenderDevice* pDevice, | 
|  | 36 | CFX_Matrix* pUser2Device, | 
|  | 37 | CPDF_RenderOptions* pOptions); | 
|  | 38 | #endif  // PDF_ENABLE_XFA | 
|  | 39 |  | 
| dsinclair | 8afe15a | 2016-10-05 12:00:34 -0700 | [diff] [blame] | 40 | void LoadFXAnnots(); | 
| dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 41 | CPDFSDK_Annot* GetFocusAnnot(); | 
| dsinclair | 8afe15a | 2016-10-05 12:00:34 -0700 | [diff] [blame] | 42 | bool IsValidAnnot(const CPDF_Annot* p) const; | 
|  | 43 | bool IsValidSDKAnnot(const CPDFSDK_Annot* p) const; | 
| dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 44 |  | 
| dsinclair | 8afe15a | 2016-10-05 12:00:34 -0700 | [diff] [blame] | 45 | const std::vector<CPDFSDK_Annot*>& GetAnnotList() const { | 
|  | 46 | return m_SDKAnnotArray; | 
|  | 47 | } | 
| dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 48 | CPDFSDK_Annot* GetAnnotByDict(CPDF_Dictionary* pDict); | 
|  | 49 |  | 
|  | 50 | #ifdef PDF_ENABLE_XFA | 
| tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 51 | bool DeleteAnnot(CPDFSDK_Annot* pAnnot); | 
| dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 52 | CPDFSDK_Annot* AddAnnot(CXFA_FFWidget* pPDFAnnot); | 
|  | 53 | CPDFSDK_Annot* GetAnnotByXFAWidget(CXFA_FFWidget* hWidget); | 
| dsinclair | 8afe15a | 2016-10-05 12:00:34 -0700 | [diff] [blame] | 54 |  | 
| dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 55 | CPDFXFA_Page* GetPDFXFAPage() { return m_page; } | 
|  | 56 | #endif  // PDF_ENABLE_XFA | 
|  | 57 |  | 
|  | 58 | CPDF_Page* GetPDFPage() const; | 
|  | 59 | CPDF_Document* GetPDFDocument(); | 
| Tom Sepez | cc20513 | 2017-05-16 14:01:47 -0700 | [diff] [blame] | 60 | CPDFSDK_FormFillEnvironment* GetFormFillEnv() const { | 
|  | 61 | return m_pFormFillEnv.Get(); | 
|  | 62 | } | 
|  | 63 |  | 
| Lei Zhang | a4c7ac4 | 2018-04-17 15:12:58 +0000 | [diff] [blame^] | 64 | WideString GetFocusedFormText(); | 
| Ryan Harrison | 275e260 | 2017-09-18 14:23:18 -0400 | [diff] [blame] | 65 | WideString GetSelectedText(); | 
|  | 66 | void ReplaceSelection(const WideString& text); | 
| Diana Gage | dce2d72 | 2017-06-20 11:17:11 -0700 | [diff] [blame] | 67 |  | 
| Lei Zhang | 63b0126 | 2017-08-31 08:54:46 -0700 | [diff] [blame] | 68 | bool OnFocus(const CFX_PointF& point, uint32_t nFlag); | 
| Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame] | 69 | bool OnLButtonDown(const CFX_PointF& point, uint32_t nFlag); | 
|  | 70 | bool OnLButtonUp(const CFX_PointF& point, uint32_t nFlag); | 
| dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 71 | #ifdef PDF_ENABLE_XFA | 
| Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame] | 72 | bool OnRButtonDown(const CFX_PointF& point, uint32_t nFlag); | 
|  | 73 | bool OnRButtonUp(const CFX_PointF& point, uint32_t nFlag); | 
| dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 74 | #endif  // PDF_ENABLE_XFA | 
| tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 75 | bool OnChar(int nChar, uint32_t nFlag); | 
|  | 76 | bool OnKeyDown(int nKeyCode, int nFlag); | 
|  | 77 | bool OnKeyUp(int nKeyCode, int nFlag); | 
| dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 78 |  | 
| Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame] | 79 | bool OnMouseMove(const CFX_PointF& point, int nFlag); | 
| tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 80 | bool OnMouseWheel(double deltaX, | 
|  | 81 | double deltaY, | 
| Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame] | 82 | const CFX_PointF& point, | 
| tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 83 | int nFlag); | 
| dsinclair | 8afe15a | 2016-10-05 12:00:34 -0700 | [diff] [blame] | 84 |  | 
| dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 85 | void GetCurrentMatrix(CFX_Matrix& matrix) { matrix = m_curMatrix; } | 
|  | 86 | void UpdateRects(const std::vector<CFX_FloatRect>& rects); | 
|  | 87 | void UpdateView(CPDFSDK_Annot* pAnnot); | 
| dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 88 |  | 
|  | 89 | int GetPageIndex() const; | 
| dsinclair | e539358 | 2016-10-03 11:25:00 -0700 | [diff] [blame] | 90 |  | 
| tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 91 | void SetValid(bool bValid) { m_bValid = bValid; } | 
|  | 92 | bool IsValid() { return m_bValid; } | 
| dsinclair | e539358 | 2016-10-03 11:25:00 -0700 | [diff] [blame] | 93 |  | 
| tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 94 | bool IsLocked() { return m_bLocked; } | 
| dsinclair | bcf4623 | 2016-10-03 13:02:27 -0700 | [diff] [blame] | 95 |  | 
|  | 96 | void SetBeingDestroyed() { m_bBeingDestroyed = true; } | 
|  | 97 | bool IsBeingDestroyed() const { return m_bBeingDestroyed; } | 
|  | 98 |  | 
| dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 99 | #ifndef PDF_ENABLE_XFA | 
|  | 100 | bool OwnsPage() const { return m_bOwnsPage; } | 
|  | 101 | void TakePageOwnership() { m_bOwnsPage = true; } | 
|  | 102 | #endif  // PDF_ENABLE_XFA | 
|  | 103 |  | 
|  | 104 | private: | 
| Dan Sinclair | b45ea1f | 2017-02-21 14:27:59 -0500 | [diff] [blame] | 105 | CPDFSDK_Annot* GetFXAnnotAtPoint(const CFX_PointF& point); | 
|  | 106 | CPDFSDK_Annot* GetFXWidgetAtPoint(const CFX_PointF& point); | 
|  | 107 |  | 
| dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 108 | int GetPageIndexForStaticPDF() const; | 
|  | 109 |  | 
| Henrique Nakashima | 4a65254 | 2017-08-22 10:59:49 -0400 | [diff] [blame] | 110 | void EnterWidget(CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr, | 
|  | 111 | CPDFSDK_Annot::ObservedPtr* pAnnot, | 
|  | 112 | uint32_t nFlag); | 
|  | 113 | void ExitWidget(CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr, | 
|  | 114 | bool callExitCallback, | 
|  | 115 | uint32_t nFlag); | 
|  | 116 |  | 
| dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 117 | CFX_Matrix m_curMatrix; | 
|  | 118 | UnderlyingPageType* const m_page; | 
|  | 119 | std::unique_ptr<CPDF_AnnotList> m_pAnnotList; | 
| dsinclair | 8afe15a | 2016-10-05 12:00:34 -0700 | [diff] [blame] | 120 | std::vector<CPDFSDK_Annot*> m_SDKAnnotArray; | 
| Dan Sinclair | aee0db0 | 2017-09-21 16:53:58 -0400 | [diff] [blame] | 121 | UnownedPtr<CPDFSDK_FormFillEnvironment> const m_pFormFillEnv; | 
| tsepez | f8074ce | 2016-09-27 14:29:57 -0700 | [diff] [blame] | 122 | CPDFSDK_Annot::ObservedPtr m_pCaptureWidget; | 
| dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 123 | #ifndef PDF_ENABLE_XFA | 
|  | 124 | bool m_bOwnsPage; | 
|  | 125 | #endif  // PDF_ENABLE_XFA | 
| tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 126 | bool m_bOnWidget; | 
|  | 127 | bool m_bValid; | 
|  | 128 | bool m_bLocked; | 
| dsinclair | bcf4623 | 2016-10-03 13:02:27 -0700 | [diff] [blame] | 129 | bool m_bBeingDestroyed; | 
| dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 130 | }; | 
|  | 131 |  | 
| dsinclair | 114e46a | 2016-09-29 17:18:21 -0700 | [diff] [blame] | 132 | #endif  // FPDFSDK_CPDFSDK_PAGEVIEW_H_ |