K. Moon | 832a694 | 2022-10-31 20:11:31 +0000 | [diff] [blame] | 1 | // Copyright 2016 The PDFium Authors |
jaepark | 2736276 | 2016-08-11 13:10:39 -0700 | [diff] [blame] | 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 | #include "fpdfsdk/cpdfsdk_annot.h" |
jaepark | 2736276 | 2016-08-11 13:10:39 -0700 | [diff] [blame] | 8 | |
dsinclair | 114e46a | 2016-09-29 17:18:21 -0700 | [diff] [blame] | 9 | #include "fpdfsdk/cpdfsdk_pageview.h" |
Tom Sepez | 9c78c0d | 2021-01-27 20:13:14 +0000 | [diff] [blame] | 10 | #include "third_party/base/check.h" |
jaepark | 2736276 | 2016-08-11 13:10:39 -0700 | [diff] [blame] | 11 | |
jaepark | 2736276 | 2016-08-11 13:10:39 -0700 | [diff] [blame] | 12 | CPDFSDK_Annot::CPDFSDK_Annot(CPDFSDK_PageView* pPageView) |
Lei Zhang | c2ad628 | 2020-02-13 20:50:57 +0000 | [diff] [blame] | 13 | : m_pPageView(pPageView) { |
Tom Sepez | 9c78c0d | 2021-01-27 20:13:14 +0000 | [diff] [blame] | 14 | DCHECK(m_pPageView); |
Lei Zhang | c2ad628 | 2020-02-13 20:50:57 +0000 | [diff] [blame] | 15 | } |
jaepark | 2736276 | 2016-08-11 13:10:39 -0700 | [diff] [blame] | 16 | |
Lei Zhang | c2ad628 | 2020-02-13 20:50:57 +0000 | [diff] [blame] | 17 | CPDFSDK_Annot::~CPDFSDK_Annot() = default; |
jaepark | 2736276 | 2016-08-11 13:10:39 -0700 | [diff] [blame] | 18 | |
Tom Sepez | 522d77d | 2018-07-28 00:00:25 +0000 | [diff] [blame] | 19 | CPDFSDK_BAAnnot* CPDFSDK_Annot::AsBAAnnot() { |
| 20 | return nullptr; |
| 21 | } |
| 22 | |
Tom Sepez | 451ed2d | 2019-08-19 22:55:31 +0000 | [diff] [blame] | 23 | CPDFXFA_Widget* CPDFSDK_Annot::AsXFAWidget() { |
jaepark | 2736276 | 2016-08-11 13:10:39 -0700 | [diff] [blame] | 24 | return nullptr; |
| 25 | } |
jaepark | 2736276 | 2016-08-11 13:10:39 -0700 | [diff] [blame] | 26 | |
Lei Zhang | 76ef4c9 | 2022-04-08 19:03:51 +0000 | [diff] [blame] | 27 | // static |
| 28 | void CPDFSDK_Annot::OnMouseEnter(ObservedPtr<CPDFSDK_Annot>& pAnnot, |
| 29 | Mask<FWL_EVENTFLAG> nFlags) { |
| 30 | pAnnot->GetUnsafeInputHandlers()->OnMouseEnter(nFlags); |
| 31 | } |
| 32 | |
| 33 | // static |
| 34 | void CPDFSDK_Annot::OnMouseExit(ObservedPtr<CPDFSDK_Annot>& pAnnot, |
| 35 | Mask<FWL_EVENTFLAG> nFlags) { |
| 36 | pAnnot->GetUnsafeInputHandlers()->OnMouseExit(nFlags); |
| 37 | } |
| 38 | |
| 39 | // static |
| 40 | bool CPDFSDK_Annot::OnLButtonDown(ObservedPtr<CPDFSDK_Annot>& pAnnot, |
| 41 | Mask<FWL_EVENTFLAG> nFlags, |
| 42 | const CFX_PointF& point) { |
| 43 | return pAnnot->GetUnsafeInputHandlers()->OnLButtonDown(nFlags, point); |
| 44 | } |
| 45 | |
| 46 | // static |
| 47 | bool CPDFSDK_Annot::OnLButtonUp(ObservedPtr<CPDFSDK_Annot>& pAnnot, |
| 48 | Mask<FWL_EVENTFLAG> nFlags, |
| 49 | const CFX_PointF& point) { |
| 50 | return pAnnot->GetUnsafeInputHandlers()->OnLButtonUp(nFlags, point); |
| 51 | } |
| 52 | |
| 53 | // static |
| 54 | bool CPDFSDK_Annot::OnLButtonDblClk(ObservedPtr<CPDFSDK_Annot>& pAnnot, |
| 55 | Mask<FWL_EVENTFLAG> nFlags, |
| 56 | const CFX_PointF& point) { |
| 57 | return pAnnot->GetUnsafeInputHandlers()->OnLButtonDblClk(nFlags, point); |
| 58 | } |
| 59 | |
| 60 | // static |
| 61 | bool CPDFSDK_Annot::OnMouseMove(ObservedPtr<CPDFSDK_Annot>& pAnnot, |
| 62 | Mask<FWL_EVENTFLAG> nFlags, |
| 63 | const CFX_PointF& point) { |
| 64 | return pAnnot->GetUnsafeInputHandlers()->OnMouseMove(nFlags, point); |
| 65 | } |
| 66 | |
| 67 | // static |
| 68 | bool CPDFSDK_Annot::OnMouseWheel(ObservedPtr<CPDFSDK_Annot>& pAnnot, |
| 69 | Mask<FWL_EVENTFLAG> nFlags, |
| 70 | const CFX_PointF& point, |
| 71 | const CFX_Vector& delta) { |
| 72 | return pAnnot->GetUnsafeInputHandlers()->OnMouseWheel(nFlags, point, delta); |
| 73 | } |
| 74 | |
| 75 | // static |
| 76 | bool CPDFSDK_Annot::OnRButtonDown(ObservedPtr<CPDFSDK_Annot>& pAnnot, |
| 77 | Mask<FWL_EVENTFLAG> nFlags, |
| 78 | const CFX_PointF& point) { |
| 79 | return pAnnot->GetUnsafeInputHandlers()->OnRButtonDown(nFlags, point); |
| 80 | } |
| 81 | |
| 82 | // static |
| 83 | bool CPDFSDK_Annot::OnRButtonUp(ObservedPtr<CPDFSDK_Annot>& pAnnot, |
| 84 | Mask<FWL_EVENTFLAG> nFlags, |
| 85 | const CFX_PointF& point) { |
| 86 | return pAnnot->GetUnsafeInputHandlers()->OnRButtonUp(nFlags, point); |
| 87 | } |
| 88 | |
Lei Zhang | 2ea512b | 2022-04-08 21:10:01 +0000 | [diff] [blame] | 89 | // static |
| 90 | bool CPDFSDK_Annot::OnChar(ObservedPtr<CPDFSDK_Annot>& pAnnot, |
| 91 | uint32_t nChar, |
| 92 | Mask<FWL_EVENTFLAG> nFlags) { |
| 93 | return pAnnot->GetUnsafeInputHandlers()->OnChar(nChar, nFlags); |
| 94 | } |
| 95 | |
| 96 | // static |
| 97 | bool CPDFSDK_Annot::OnKeyDown(ObservedPtr<CPDFSDK_Annot>& pAnnot, |
| 98 | FWL_VKEYCODE nKeyCode, |
| 99 | Mask<FWL_EVENTFLAG> nFlags) { |
| 100 | return pAnnot->GetUnsafeInputHandlers()->OnKeyDown(nKeyCode, nFlags); |
| 101 | } |
| 102 | |
| 103 | // static |
| 104 | bool CPDFSDK_Annot::OnSetFocus(ObservedPtr<CPDFSDK_Annot>& pAnnot, |
| 105 | Mask<FWL_EVENTFLAG> nFlags) { |
| 106 | return pAnnot->GetUnsafeInputHandlers()->OnSetFocus(nFlags); |
| 107 | } |
| 108 | |
| 109 | // static |
| 110 | bool CPDFSDK_Annot::OnKillFocus(ObservedPtr<CPDFSDK_Annot>& pAnnot, |
| 111 | Mask<FWL_EVENTFLAG> nFlags) { |
| 112 | return pAnnot->GetUnsafeInputHandlers()->OnKillFocus(nFlags); |
| 113 | } |
| 114 | |
Tom Sepez | 9bf0181 | 2019-08-19 18:59:27 +0000 | [diff] [blame] | 115 | IPDF_Page* CPDFSDK_Annot::GetXFAPage() { |
| 116 | #ifdef PDF_ENABLE_XFA |
Lei Zhang | c2ad628 | 2020-02-13 20:50:57 +0000 | [diff] [blame] | 117 | return m_pPageView->GetXFAPage(); |
| 118 | #else |
Tom Sepez | 9bf0181 | 2019-08-19 18:59:27 +0000 | [diff] [blame] | 119 | return nullptr; |
Lei Zhang | c2ad628 | 2020-02-13 20:50:57 +0000 | [diff] [blame] | 120 | #endif |
Tom Sepez | 9bf0181 | 2019-08-19 18:59:27 +0000 | [diff] [blame] | 121 | } |
| 122 | |
jaepark | 2736276 | 2016-08-11 13:10:39 -0700 | [diff] [blame] | 123 | int CPDFSDK_Annot::GetLayoutOrder() const { |
| 124 | return 5; |
| 125 | } |
| 126 | |
| 127 | CPDF_Annot* CPDFSDK_Annot::GetPDFAnnot() const { |
| 128 | return nullptr; |
| 129 | } |
| 130 | |
Tom Sepez | 101535f | 2018-06-12 13:36:05 +0000 | [diff] [blame] | 131 | IPDF_Page* CPDFSDK_Annot::GetPage() { |
jaepark | 2736276 | 2016-08-11 13:10:39 -0700 | [diff] [blame] | 132 | #ifdef PDF_ENABLE_XFA |
Tom Sepez | 9bf0181 | 2019-08-19 18:59:27 +0000 | [diff] [blame] | 133 | IPDF_Page* pXFAPage = GetXFAPage(); |
Tom Sepez | 8e63177 | 2018-06-13 21:26:56 +0000 | [diff] [blame] | 134 | if (pXFAPage) |
| 135 | return pXFAPage; |
jaepark | 2736276 | 2016-08-11 13:10:39 -0700 | [diff] [blame] | 136 | #endif // PDF_ENABLE_XFA |
Tom Sepez | 8e63177 | 2018-06-13 21:26:56 +0000 | [diff] [blame] | 137 | return GetPDFPage(); |
jaepark | 2736276 | 2016-08-11 13:10:39 -0700 | [diff] [blame] | 138 | } |
| 139 | |
| 140 | CPDF_Page* CPDFSDK_Annot::GetPDFPage() { |
Lei Zhang | c2ad628 | 2020-02-13 20:50:57 +0000 | [diff] [blame] | 141 | return m_pPageView->GetPDFPage(); |
jaepark | 2736276 | 2016-08-11 13:10:39 -0700 | [diff] [blame] | 142 | } |