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" |
dsinclair | 114e46a | 2016-09-29 17:18:21 -0700 | [diff] [blame] | 15 | #include "fpdfsdk/cpdfsdk_annot.h" |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 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: |
dsinclair | b402b17 | 2016-10-11 09:26:32 -0700 | [diff] [blame] | 23 | CPDFSDK_PageView(CPDFSDK_FormFillEnvironment* pFormFillEnv, |
| 24 | UnderlyingPageType* page); |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 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 | |
dsinclair | 8afe15a | 2016-10-05 12:00:34 -0700 | [diff] [blame] | 38 | void LoadFXAnnots(); |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 39 | CPDFSDK_Annot* GetFocusAnnot(); |
dsinclair | 8afe15a | 2016-10-05 12:00:34 -0700 | [diff] [blame] | 40 | bool IsValidAnnot(const CPDF_Annot* p) const; |
| 41 | bool IsValidSDKAnnot(const CPDFSDK_Annot* p) const; |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 42 | |
dsinclair | 8afe15a | 2016-10-05 12:00:34 -0700 | [diff] [blame] | 43 | const std::vector<CPDFSDK_Annot*>& GetAnnotList() const { |
| 44 | return m_SDKAnnotArray; |
| 45 | } |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 46 | CPDFSDK_Annot* GetAnnotByDict(CPDF_Dictionary* pDict); |
| 47 | |
| 48 | #ifdef PDF_ENABLE_XFA |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 49 | bool DeleteAnnot(CPDFSDK_Annot* pAnnot); |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 50 | CPDFSDK_Annot* AddAnnot(CXFA_FFWidget* pPDFAnnot); |
| 51 | CPDFSDK_Annot* GetAnnotByXFAWidget(CXFA_FFWidget* hWidget); |
dsinclair | 8afe15a | 2016-10-05 12:00:34 -0700 | [diff] [blame] | 52 | |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 53 | CPDFXFA_Page* GetPDFXFAPage() { return m_page; } |
| 54 | #endif // PDF_ENABLE_XFA |
| 55 | |
| 56 | CPDF_Page* GetPDFPage() const; |
| 57 | CPDF_Document* GetPDFDocument(); |
dsinclair | b402b17 | 2016-10-11 09:26:32 -0700 | [diff] [blame] | 58 | CPDFSDK_FormFillEnvironment* GetFormFillEnv() const { return m_pFormFillEnv; } |
Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame] | 59 | bool OnLButtonDown(const CFX_PointF& point, uint32_t nFlag); |
| 60 | bool OnLButtonUp(const CFX_PointF& point, uint32_t nFlag); |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 61 | #ifdef PDF_ENABLE_XFA |
Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame] | 62 | bool OnRButtonDown(const CFX_PointF& point, uint32_t nFlag); |
| 63 | bool OnRButtonUp(const CFX_PointF& point, uint32_t nFlag); |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 64 | #endif // PDF_ENABLE_XFA |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 65 | bool OnChar(int nChar, uint32_t nFlag); |
| 66 | bool OnKeyDown(int nKeyCode, int nFlag); |
| 67 | bool OnKeyUp(int nKeyCode, int nFlag); |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 68 | |
Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame] | 69 | bool OnMouseMove(const CFX_PointF& point, int nFlag); |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 70 | bool OnMouseWheel(double deltaX, |
| 71 | double deltaY, |
Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame] | 72 | const CFX_PointF& point, |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 73 | int nFlag); |
dsinclair | 8afe15a | 2016-10-05 12:00:34 -0700 | [diff] [blame] | 74 | |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 75 | void GetCurrentMatrix(CFX_Matrix& matrix) { matrix = m_curMatrix; } |
| 76 | void UpdateRects(const std::vector<CFX_FloatRect>& rects); |
| 77 | void UpdateView(CPDFSDK_Annot* pAnnot); |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 78 | |
| 79 | int GetPageIndex() const; |
dsinclair | e539358 | 2016-10-03 11:25:00 -0700 | [diff] [blame] | 80 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 81 | void SetValid(bool bValid) { m_bValid = bValid; } |
| 82 | bool IsValid() { return m_bValid; } |
dsinclair | e539358 | 2016-10-03 11:25:00 -0700 | [diff] [blame] | 83 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 84 | void SetLock(bool bLocked) { m_bLocked = bLocked; } |
| 85 | bool IsLocked() { return m_bLocked; } |
dsinclair | bcf4623 | 2016-10-03 13:02:27 -0700 | [diff] [blame] | 86 | |
| 87 | void SetBeingDestroyed() { m_bBeingDestroyed = true; } |
| 88 | bool IsBeingDestroyed() const { return m_bBeingDestroyed; } |
| 89 | |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 90 | #ifndef PDF_ENABLE_XFA |
| 91 | bool OwnsPage() const { return m_bOwnsPage; } |
| 92 | void TakePageOwnership() { m_bOwnsPage = true; } |
| 93 | #endif // PDF_ENABLE_XFA |
| 94 | |
| 95 | private: |
Dan Sinclair | b45ea1f | 2017-02-21 14:27:59 -0500 | [diff] [blame] | 96 | CPDFSDK_Annot* GetFXAnnotAtPoint(const CFX_PointF& point); |
| 97 | CPDFSDK_Annot* GetFXWidgetAtPoint(const CFX_PointF& point); |
| 98 | |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 99 | int GetPageIndexForStaticPDF() const; |
| 100 | |
| 101 | CFX_Matrix m_curMatrix; |
| 102 | UnderlyingPageType* const m_page; |
| 103 | std::unique_ptr<CPDF_AnnotList> m_pAnnotList; |
dsinclair | 8afe15a | 2016-10-05 12:00:34 -0700 | [diff] [blame] | 104 | std::vector<CPDFSDK_Annot*> m_SDKAnnotArray; |
dsinclair | b402b17 | 2016-10-11 09:26:32 -0700 | [diff] [blame] | 105 | CPDFSDK_FormFillEnvironment* const m_pFormFillEnv; // Not owned. |
tsepez | f8074ce | 2016-09-27 14:29:57 -0700 | [diff] [blame] | 106 | CPDFSDK_Annot::ObservedPtr m_pCaptureWidget; |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 107 | #ifndef PDF_ENABLE_XFA |
| 108 | bool m_bOwnsPage; |
| 109 | #endif // PDF_ENABLE_XFA |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 110 | bool m_bEnterWidget; |
| 111 | bool m_bExitWidget; |
| 112 | bool m_bOnWidget; |
| 113 | bool m_bValid; |
| 114 | bool m_bLocked; |
dsinclair | bcf4623 | 2016-10-03 13:02:27 -0700 | [diff] [blame] | 115 | bool m_bBeingDestroyed; |
dsinclair | f34518b | 2016-09-13 12:03:48 -0700 | [diff] [blame] | 116 | }; |
| 117 | |
dsinclair | 114e46a | 2016-09-29 17:18:21 -0700 | [diff] [blame] | 118 | #endif // FPDFSDK_CPDFSDK_PAGEVIEW_H_ |