xref: /aosp_15_r20/external/pdfium/fpdfsdk/cpdfsdk_annot.cpp (revision 3ac0a46f773bac49fa9476ec2b1cf3f8da5ec3a4)
1 // Copyright 2016 The PDFium Authors
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 #include "fpdfsdk/cpdfsdk_annot.h"
8 
9 #include "fpdfsdk/cpdfsdk_pageview.h"
10 #include "third_party/base/check.h"
11 
CPDFSDK_Annot(CPDFSDK_PageView * pPageView)12 CPDFSDK_Annot::CPDFSDK_Annot(CPDFSDK_PageView* pPageView)
13     : m_pPageView(pPageView) {
14   DCHECK(m_pPageView);
15 }
16 
17 CPDFSDK_Annot::~CPDFSDK_Annot() = default;
18 
AsBAAnnot()19 CPDFSDK_BAAnnot* CPDFSDK_Annot::AsBAAnnot() {
20   return nullptr;
21 }
22 
AsXFAWidget()23 CPDFXFA_Widget* CPDFSDK_Annot::AsXFAWidget() {
24   return nullptr;
25 }
26 
27 // static
OnMouseEnter(ObservedPtr<CPDFSDK_Annot> & pAnnot,Mask<FWL_EVENTFLAG> nFlags)28 void CPDFSDK_Annot::OnMouseEnter(ObservedPtr<CPDFSDK_Annot>& pAnnot,
29                                  Mask<FWL_EVENTFLAG> nFlags) {
30   pAnnot->GetUnsafeInputHandlers()->OnMouseEnter(nFlags);
31 }
32 
33 // static
OnMouseExit(ObservedPtr<CPDFSDK_Annot> & pAnnot,Mask<FWL_EVENTFLAG> nFlags)34 void CPDFSDK_Annot::OnMouseExit(ObservedPtr<CPDFSDK_Annot>& pAnnot,
35                                 Mask<FWL_EVENTFLAG> nFlags) {
36   pAnnot->GetUnsafeInputHandlers()->OnMouseExit(nFlags);
37 }
38 
39 // static
OnLButtonDown(ObservedPtr<CPDFSDK_Annot> & pAnnot,Mask<FWL_EVENTFLAG> nFlags,const CFX_PointF & point)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
OnLButtonUp(ObservedPtr<CPDFSDK_Annot> & pAnnot,Mask<FWL_EVENTFLAG> nFlags,const CFX_PointF & point)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
OnLButtonDblClk(ObservedPtr<CPDFSDK_Annot> & pAnnot,Mask<FWL_EVENTFLAG> nFlags,const CFX_PointF & point)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
OnMouseMove(ObservedPtr<CPDFSDK_Annot> & pAnnot,Mask<FWL_EVENTFLAG> nFlags,const CFX_PointF & point)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
OnMouseWheel(ObservedPtr<CPDFSDK_Annot> & pAnnot,Mask<FWL_EVENTFLAG> nFlags,const CFX_PointF & point,const CFX_Vector & delta)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
OnRButtonDown(ObservedPtr<CPDFSDK_Annot> & pAnnot,Mask<FWL_EVENTFLAG> nFlags,const CFX_PointF & point)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
OnRButtonUp(ObservedPtr<CPDFSDK_Annot> & pAnnot,Mask<FWL_EVENTFLAG> nFlags,const CFX_PointF & point)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 
89 // static
OnChar(ObservedPtr<CPDFSDK_Annot> & pAnnot,uint32_t nChar,Mask<FWL_EVENTFLAG> nFlags)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
OnKeyDown(ObservedPtr<CPDFSDK_Annot> & pAnnot,FWL_VKEYCODE nKeyCode,Mask<FWL_EVENTFLAG> nFlags)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
OnSetFocus(ObservedPtr<CPDFSDK_Annot> & pAnnot,Mask<FWL_EVENTFLAG> nFlags)104 bool CPDFSDK_Annot::OnSetFocus(ObservedPtr<CPDFSDK_Annot>& pAnnot,
105                                Mask<FWL_EVENTFLAG> nFlags) {
106   return pAnnot->GetUnsafeInputHandlers()->OnSetFocus(nFlags);
107 }
108 
109 // static
OnKillFocus(ObservedPtr<CPDFSDK_Annot> & pAnnot,Mask<FWL_EVENTFLAG> nFlags)110 bool CPDFSDK_Annot::OnKillFocus(ObservedPtr<CPDFSDK_Annot>& pAnnot,
111                                 Mask<FWL_EVENTFLAG> nFlags) {
112   return pAnnot->GetUnsafeInputHandlers()->OnKillFocus(nFlags);
113 }
114 
GetXFAPage()115 IPDF_Page* CPDFSDK_Annot::GetXFAPage() {
116 #ifdef PDF_ENABLE_XFA
117   return m_pPageView->GetXFAPage();
118 #else
119   return nullptr;
120 #endif
121 }
122 
GetLayoutOrder() const123 int CPDFSDK_Annot::GetLayoutOrder() const {
124   return 5;
125 }
126 
GetPDFAnnot() const127 CPDF_Annot* CPDFSDK_Annot::GetPDFAnnot() const {
128   return nullptr;
129 }
130 
GetPage()131 IPDF_Page* CPDFSDK_Annot::GetPage() {
132 #ifdef PDF_ENABLE_XFA
133   IPDF_Page* pXFAPage = GetXFAPage();
134   if (pXFAPage)
135     return pXFAPage;
136 #endif  // PDF_ENABLE_XFA
137   return GetPDFPage();
138 }
139 
GetPDFPage()140 CPDF_Page* CPDFSDK_Annot::GetPDFPage() {
141   return m_pPageView->GetPDFPage();
142 }
143