OLD | NEW |
1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include "fpdfsdk/include/cpdfsdk_xfaannothandler.h" | 7 #include "fpdfsdk/include/cpdfsdk_xfawidgethandler.h" |
8 | 8 |
9 #include "core/fpdfdoc/include/cpdf_interform.h" | 9 #include "core/fpdfdoc/include/cpdf_interform.h" |
10 #include "fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h" | 10 #include "fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h" |
11 #include "fpdfsdk/include/cpdfsdk_annot.h" | 11 #include "fpdfsdk/include/cpdfsdk_annot.h" |
12 #include "fpdfsdk/include/cpdfsdk_interform.h" | 12 #include "fpdfsdk/include/cpdfsdk_interform.h" |
13 #include "fpdfsdk/include/cpdfsdk_xfawidget.h" | 13 #include "fpdfsdk/include/cpdfsdk_xfawidget.h" |
14 #include "fpdfsdk/include/fsdk_mgr.h" | 14 #include "fpdfsdk/include/fsdk_mgr.h" |
15 #include "xfa/fxfa/include/fxfa_basic.h" | 15 #include "xfa/fxfa/include/fxfa_basic.h" |
16 #include "xfa/fxfa/include/xfa_ffdocview.h" | 16 #include "xfa/fxfa/include/xfa_ffdocview.h" |
17 #include "xfa/fxfa/include/xfa_ffpageview.h" | 17 #include "xfa/fxfa/include/xfa_ffpageview.h" |
18 #include "xfa/fxfa/include/xfa_ffwidget.h" | 18 #include "xfa/fxfa/include/xfa_ffwidget.h" |
19 #include "xfa/fxfa/include/xfa_ffwidgethandler.h" | 19 #include "xfa/fxfa/include/xfa_ffwidgethandler.h" |
20 #include "xfa/fxgraphics/include/cfx_graphics.h" | 20 #include "xfa/fxgraphics/include/cfx_graphics.h" |
21 #include "xfa/fwl/core/include/fwl_widgethit.h" | 21 #include "xfa/fwl/core/include/fwl_widgethit.h" |
22 | 22 |
23 CPDFSDK_XFAAnnotHandler::CPDFSDK_XFAAnnotHandler(CPDFDoc_Environment* pApp) | 23 CPDFSDK_XFAWidgetHandler::CPDFSDK_XFAWidgetHandler(CPDFDoc_Environment* pApp) |
24 : m_pApp(pApp) {} | 24 : m_pApp(pApp) {} |
25 | 25 |
26 CPDFSDK_XFAAnnotHandler::~CPDFSDK_XFAAnnotHandler() {} | 26 CPDFSDK_XFAWidgetHandler::~CPDFSDK_XFAWidgetHandler() {} |
27 | 27 |
28 CFX_ByteString CPDFSDK_XFAAnnotHandler::GetType() { | 28 CFX_ByteString CPDFSDK_XFAWidgetHandler::GetType() { |
29 return FSDK_XFAWIDGET_TYPENAME; | 29 return FSDK_XFAWIDGET_TYPENAME; |
30 } | 30 } |
31 | 31 |
32 FX_BOOL CPDFSDK_XFAAnnotHandler::CanAnswer(CPDFSDK_Annot* pAnnot) { | 32 FX_BOOL CPDFSDK_XFAWidgetHandler::CanAnswer(CPDFSDK_Annot* pAnnot) { |
33 return !!pAnnot->GetXFAWidget(); | 33 return !!pAnnot->GetXFAWidget(); |
34 } | 34 } |
35 | 35 |
36 CPDFSDK_Annot* CPDFSDK_XFAAnnotHandler::NewAnnot(CPDF_Annot* pAnnot, | 36 CPDFSDK_Annot* CPDFSDK_XFAWidgetHandler::NewAnnot(CPDF_Annot* pAnnot, |
37 CPDFSDK_PageView* pPage) { | 37 CPDFSDK_PageView* pPage) { |
38 return nullptr; | 38 return nullptr; |
39 } | 39 } |
40 | 40 |
41 CPDFSDK_Annot* CPDFSDK_XFAAnnotHandler::NewAnnot(CXFA_FFWidget* pAnnot, | 41 CPDFSDK_Annot* CPDFSDK_XFAWidgetHandler::NewAnnot(CXFA_FFWidget* pAnnot, |
42 CPDFSDK_PageView* pPage) { | 42 CPDFSDK_PageView* pPage) { |
43 CPDFSDK_Document* pSDKDoc = m_pApp->GetSDKDocument(); | 43 CPDFSDK_Document* pSDKDoc = m_pApp->GetSDKDocument(); |
44 CPDFSDK_InterForm* pInterForm = pSDKDoc->GetInterForm(); | 44 CPDFSDK_InterForm* pInterForm = pSDKDoc->GetInterForm(); |
45 CPDFSDK_XFAWidget* pWidget = new CPDFSDK_XFAWidget(pAnnot, pPage, pInterForm); | 45 CPDFSDK_XFAWidget* pWidget = new CPDFSDK_XFAWidget(pAnnot, pPage, pInterForm); |
46 pInterForm->AddXFAMap(pAnnot, pWidget); | 46 pInterForm->AddXFAMap(pAnnot, pWidget); |
47 return pWidget; | 47 return pWidget; |
48 } | 48 } |
49 | 49 |
50 void CPDFSDK_XFAAnnotHandler::OnDraw(CPDFSDK_PageView* pPageView, | 50 void CPDFSDK_XFAWidgetHandler::OnDraw(CPDFSDK_PageView* pPageView, |
51 CPDFSDK_Annot* pAnnot, | 51 CPDFSDK_Annot* pAnnot, |
52 CFX_RenderDevice* pDevice, | 52 CFX_RenderDevice* pDevice, |
53 CFX_Matrix* pUser2Device, | 53 CFX_Matrix* pUser2Device, |
54 uint32_t dwFlags) { | 54 uint32_t dwFlags) { |
55 ASSERT(pPageView); | 55 ASSERT(pPageView); |
56 ASSERT(pAnnot); | 56 ASSERT(pAnnot); |
57 | 57 |
58 CPDFSDK_Document* pSDKDoc = pPageView->GetSDKDocument(); | 58 CPDFSDK_Document* pSDKDoc = pPageView->GetSDKDocument(); |
59 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot); | 59 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot); |
60 | 60 |
61 CFX_Graphics gs; | 61 CFX_Graphics gs; |
62 gs.Create(pDevice); | 62 gs.Create(pDevice); |
63 | 63 |
64 CFX_Matrix mt; | 64 CFX_Matrix mt; |
65 mt = *pUser2Device; | 65 mt = *pUser2Device; |
66 | 66 |
67 FX_BOOL bIsHighlight = FALSE; | 67 FX_BOOL bIsHighlight = FALSE; |
68 if (pSDKDoc->GetFocusAnnot() != pAnnot) | 68 if (pSDKDoc->GetFocusAnnot() != pAnnot) |
69 bIsHighlight = TRUE; | 69 bIsHighlight = TRUE; |
70 | 70 |
71 pWidgetHandler->RenderWidget(pAnnot->GetXFAWidget(), &gs, &mt, bIsHighlight); | 71 pWidgetHandler->RenderWidget(pAnnot->GetXFAWidget(), &gs, &mt, bIsHighlight); |
72 | 72 |
73 // to do highlight and shadow | 73 // to do highlight and shadow |
74 } | 74 } |
75 | 75 |
76 void CPDFSDK_XFAAnnotHandler::OnDrawSleep(CPDFSDK_PageView* pPageView, | 76 void CPDFSDK_XFAWidgetHandler::OnDrawSleep(CPDFSDK_PageView* pPageView, |
77 CPDFSDK_Annot* pAnnot, | 77 CPDFSDK_Annot* pAnnot, |
78 CFX_RenderDevice* pDevice, | 78 CFX_RenderDevice* pDevice, |
79 CFX_Matrix* pUser2Device, | 79 CFX_Matrix* pUser2Device, |
80 const CFX_FloatRect& rcWindow, | 80 const CFX_FloatRect& rcWindow, |
81 uint32_t dwFlags) {} | 81 uint32_t dwFlags) {} |
82 | 82 |
83 void CPDFSDK_XFAAnnotHandler::OnCreate(CPDFSDK_Annot* pAnnot) {} | 83 void CPDFSDK_XFAWidgetHandler::OnCreate(CPDFSDK_Annot* pAnnot) {} |
84 | 84 |
85 void CPDFSDK_XFAAnnotHandler::OnLoad(CPDFSDK_Annot* pAnnot) {} | 85 void CPDFSDK_XFAWidgetHandler::OnLoad(CPDFSDK_Annot* pAnnot) {} |
86 | 86 |
87 void CPDFSDK_XFAAnnotHandler::OnDelete(CPDFSDK_Annot* pAnnot) {} | 87 void CPDFSDK_XFAWidgetHandler::OnDelete(CPDFSDK_Annot* pAnnot) {} |
88 | 88 |
89 void CPDFSDK_XFAAnnotHandler::OnRelease(CPDFSDK_Annot* pAnnot) {} | 89 void CPDFSDK_XFAWidgetHandler::OnRelease(CPDFSDK_Annot* pAnnot) {} |
90 | 90 |
91 void CPDFSDK_XFAAnnotHandler::ReleaseAnnot(CPDFSDK_Annot* pAnnot) { | 91 void CPDFSDK_XFAWidgetHandler::ReleaseAnnot(CPDFSDK_Annot* pAnnot) { |
92 CPDFSDK_XFAWidget* pWidget = reinterpret_cast<CPDFSDK_XFAWidget*>(pAnnot); | 92 CPDFSDK_XFAWidget* pWidget = reinterpret_cast<CPDFSDK_XFAWidget*>(pAnnot); |
93 CPDFSDK_InterForm* pInterForm = pWidget->GetInterForm(); | 93 CPDFSDK_InterForm* pInterForm = pWidget->GetInterForm(); |
94 pInterForm->RemoveXFAMap(pWidget->GetXFAWidget()); | 94 pInterForm->RemoveXFAMap(pWidget->GetXFAWidget()); |
95 | 95 |
96 delete pWidget; | 96 delete pWidget; |
97 } | 97 } |
98 | 98 |
99 void CPDFSDK_XFAAnnotHandler::DeleteAnnot(CPDFSDK_Annot* pAnnot) {} | 99 void CPDFSDK_XFAWidgetHandler::DeleteAnnot(CPDFSDK_Annot* pAnnot) {} |
100 | 100 |
101 CFX_FloatRect CPDFSDK_XFAAnnotHandler::GetViewBBox(CPDFSDK_PageView* pPageView, | 101 CFX_FloatRect CPDFSDK_XFAWidgetHandler::GetViewBBox(CPDFSDK_PageView* pPageView, |
102 CPDFSDK_Annot* pAnnot) { | 102 CPDFSDK_Annot* pAnnot) { |
103 ASSERT(pAnnot); | 103 ASSERT(pAnnot); |
104 | 104 |
105 CFX_RectF rcBBox; | 105 CFX_RectF rcBBox; |
106 XFA_Element eType = pAnnot->GetXFAWidget()->GetDataAcc()->GetUIType(); | 106 XFA_Element eType = pAnnot->GetXFAWidget()->GetDataAcc()->GetUIType(); |
107 if (eType == XFA_Element::Signature) | 107 if (eType == XFA_Element::Signature) |
108 pAnnot->GetXFAWidget()->GetBBox(rcBBox, XFA_WidgetStatus_Visible, TRUE); | 108 pAnnot->GetXFAWidget()->GetBBox(rcBBox, XFA_WidgetStatus_Visible, TRUE); |
109 else | 109 else |
110 pAnnot->GetXFAWidget()->GetBBox(rcBBox, XFA_WidgetStatus_None); | 110 pAnnot->GetXFAWidget()->GetBBox(rcBBox, XFA_WidgetStatus_None); |
111 | 111 |
112 CFX_FloatRect rcWidget(rcBBox.left, rcBBox.top, rcBBox.left + rcBBox.width, | 112 CFX_FloatRect rcWidget(rcBBox.left, rcBBox.top, rcBBox.left + rcBBox.width, |
113 rcBBox.top + rcBBox.height); | 113 rcBBox.top + rcBBox.height); |
114 rcWidget.left -= 1.0f; | 114 rcWidget.left -= 1.0f; |
115 rcWidget.right += 1.0f; | 115 rcWidget.right += 1.0f; |
116 rcWidget.bottom -= 1.0f; | 116 rcWidget.bottom -= 1.0f; |
117 rcWidget.top += 1.0f; | 117 rcWidget.top += 1.0f; |
118 | 118 |
119 return rcWidget; | 119 return rcWidget; |
120 } | 120 } |
121 | 121 |
122 FX_BOOL CPDFSDK_XFAAnnotHandler::HitTest(CPDFSDK_PageView* pPageView, | 122 FX_BOOL CPDFSDK_XFAWidgetHandler::HitTest(CPDFSDK_PageView* pPageView, |
123 CPDFSDK_Annot* pAnnot, | 123 CPDFSDK_Annot* pAnnot, |
124 const CFX_FloatPoint& point) { | 124 const CFX_FloatPoint& point) { |
125 if (!pPageView || !pAnnot) | 125 if (!pPageView || !pAnnot) |
126 return FALSE; | 126 return FALSE; |
127 | 127 |
128 CPDFSDK_Document* pSDKDoc = pPageView->GetSDKDocument(); | 128 CPDFSDK_Document* pSDKDoc = pPageView->GetSDKDocument(); |
129 if (!pSDKDoc) | 129 if (!pSDKDoc) |
130 return FALSE; | 130 return FALSE; |
131 | 131 |
132 CPDFXFA_Document* pDoc = pSDKDoc->GetXFADocument(); | 132 CPDFXFA_Document* pDoc = pSDKDoc->GetXFADocument(); |
133 if (!pDoc) | 133 if (!pDoc) |
134 return FALSE; | 134 return FALSE; |
135 | 135 |
136 CXFA_FFDocView* pDocView = pDoc->GetXFADocView(); | 136 CXFA_FFDocView* pDocView = pDoc->GetXFADocView(); |
137 if (!pDocView) | 137 if (!pDocView) |
138 return FALSE; | 138 return FALSE; |
139 | 139 |
140 CXFA_FFWidgetHandler* pWidgetHandler = pDocView->GetWidgetHandler(); | 140 CXFA_FFWidgetHandler* pWidgetHandler = pDocView->GetWidgetHandler(); |
141 if (!pWidgetHandler) | 141 if (!pWidgetHandler) |
142 return FALSE; | 142 return FALSE; |
143 | 143 |
144 FWL_WidgetHit dwHitTest = | 144 FWL_WidgetHit dwHitTest = |
145 pWidgetHandler->OnHitTest(pAnnot->GetXFAWidget(), point.x, point.y); | 145 pWidgetHandler->OnHitTest(pAnnot->GetXFAWidget(), point.x, point.y); |
146 return dwHitTest != FWL_WidgetHit::Unknown; | 146 return dwHitTest != FWL_WidgetHit::Unknown; |
147 } | 147 } |
148 | 148 |
149 void CPDFSDK_XFAAnnotHandler::OnMouseEnter(CPDFSDK_PageView* pPageView, | 149 void CPDFSDK_XFAWidgetHandler::OnMouseEnter(CPDFSDK_PageView* pPageView, |
150 CPDFSDK_Annot* pAnnot, | 150 CPDFSDK_Annot* pAnnot, |
151 uint32_t nFlag) { | 151 uint32_t nFlag) { |
152 if (!pPageView || !pAnnot) | 152 if (!pPageView || !pAnnot) |
153 return; | 153 return; |
154 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot); | 154 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot); |
155 pWidgetHandler->OnMouseEnter(pAnnot->GetXFAWidget()); | 155 pWidgetHandler->OnMouseEnter(pAnnot->GetXFAWidget()); |
156 } | 156 } |
157 | 157 |
158 void CPDFSDK_XFAAnnotHandler::OnMouseExit(CPDFSDK_PageView* pPageView, | 158 void CPDFSDK_XFAWidgetHandler::OnMouseExit(CPDFSDK_PageView* pPageView, |
159 CPDFSDK_Annot* pAnnot, | 159 CPDFSDK_Annot* pAnnot, |
160 uint32_t nFlag) { | 160 uint32_t nFlag) { |
161 if (!pPageView || !pAnnot) | 161 if (!pPageView || !pAnnot) |
162 return; | 162 return; |
163 | 163 |
164 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot); | 164 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot); |
165 pWidgetHandler->OnMouseExit(pAnnot->GetXFAWidget()); | 165 pWidgetHandler->OnMouseExit(pAnnot->GetXFAWidget()); |
166 } | 166 } |
167 | 167 |
168 FX_BOOL CPDFSDK_XFAAnnotHandler::OnLButtonDown(CPDFSDK_PageView* pPageView, | 168 FX_BOOL CPDFSDK_XFAWidgetHandler::OnLButtonDown(CPDFSDK_PageView* pPageView, |
169 CPDFSDK_Annot* pAnnot, | 169 CPDFSDK_Annot* pAnnot, |
170 uint32_t nFlags, | 170 uint32_t nFlags, |
171 const CFX_FloatPoint& point) { | 171 const CFX_FloatPoint& point) { |
172 if (!pPageView || !pAnnot) | 172 if (!pPageView || !pAnnot) |
173 return FALSE; | 173 return FALSE; |
174 | 174 |
175 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot); | 175 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot); |
176 return pWidgetHandler->OnLButtonDown(pAnnot->GetXFAWidget(), | 176 return pWidgetHandler->OnLButtonDown(pAnnot->GetXFAWidget(), |
177 GetFWLFlags(nFlags), point.x, point.y); | 177 GetFWLFlags(nFlags), point.x, point.y); |
178 } | 178 } |
179 | 179 |
180 FX_BOOL CPDFSDK_XFAAnnotHandler::OnLButtonUp(CPDFSDK_PageView* pPageView, | 180 FX_BOOL CPDFSDK_XFAWidgetHandler::OnLButtonUp(CPDFSDK_PageView* pPageView, |
181 CPDFSDK_Annot* pAnnot, | 181 CPDFSDK_Annot* pAnnot, |
182 uint32_t nFlags, | 182 uint32_t nFlags, |
183 const CFX_FloatPoint& point) { | 183 const CFX_FloatPoint& point) { |
184 if (!pPageView || !pAnnot) | 184 if (!pPageView || !pAnnot) |
185 return FALSE; | 185 return FALSE; |
186 | 186 |
187 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot); | 187 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot); |
188 return pWidgetHandler->OnLButtonUp(pAnnot->GetXFAWidget(), | 188 return pWidgetHandler->OnLButtonUp(pAnnot->GetXFAWidget(), |
189 GetFWLFlags(nFlags), point.x, point.y); | 189 GetFWLFlags(nFlags), point.x, point.y); |
190 } | 190 } |
191 | 191 |
192 FX_BOOL CPDFSDK_XFAAnnotHandler::OnLButtonDblClk(CPDFSDK_PageView* pPageView, | 192 FX_BOOL CPDFSDK_XFAWidgetHandler::OnLButtonDblClk(CPDFSDK_PageView* pPageView, |
193 CPDFSDK_Annot* pAnnot, | 193 CPDFSDK_Annot* pAnnot, |
194 uint32_t nFlags, | 194 uint32_t nFlags, |
195 const CFX_FloatPoint& point) { | 195 const CFX_FloatPoint& point) { |
196 if (!pPageView || !pAnnot) | 196 if (!pPageView || !pAnnot) |
197 return FALSE; | 197 return FALSE; |
198 | 198 |
199 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot); | 199 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot); |
200 return pWidgetHandler->OnLButtonDblClk(pAnnot->GetXFAWidget(), | 200 return pWidgetHandler->OnLButtonDblClk(pAnnot->GetXFAWidget(), |
201 GetFWLFlags(nFlags), point.x, point.y); | 201 GetFWLFlags(nFlags), point.x, point.y); |
202 } | 202 } |
203 | 203 |
204 FX_BOOL CPDFSDK_XFAAnnotHandler::OnMouseMove(CPDFSDK_PageView* pPageView, | 204 FX_BOOL CPDFSDK_XFAWidgetHandler::OnMouseMove(CPDFSDK_PageView* pPageView, |
205 CPDFSDK_Annot* pAnnot, | 205 CPDFSDK_Annot* pAnnot, |
206 uint32_t nFlags, | 206 uint32_t nFlags, |
207 const CFX_FloatPoint& point) { | 207 const CFX_FloatPoint& point) { |
208 if (!pPageView || !pAnnot) | 208 if (!pPageView || !pAnnot) |
209 return FALSE; | 209 return FALSE; |
210 | 210 |
211 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot); | 211 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot); |
212 return pWidgetHandler->OnMouseMove(pAnnot->GetXFAWidget(), | 212 return pWidgetHandler->OnMouseMove(pAnnot->GetXFAWidget(), |
213 GetFWLFlags(nFlags), point.x, point.y); | 213 GetFWLFlags(nFlags), point.x, point.y); |
214 } | 214 } |
215 | 215 |
216 FX_BOOL CPDFSDK_XFAAnnotHandler::OnMouseWheel(CPDFSDK_PageView* pPageView, | 216 FX_BOOL CPDFSDK_XFAWidgetHandler::OnMouseWheel(CPDFSDK_PageView* pPageView, |
217 CPDFSDK_Annot* pAnnot, | 217 CPDFSDK_Annot* pAnnot, |
218 uint32_t nFlags, | 218 uint32_t nFlags, |
219 short zDelta, | 219 short zDelta, |
220 const CFX_FloatPoint& point) { | 220 const CFX_FloatPoint& point) { |
221 if (!pPageView || !pAnnot) | 221 if (!pPageView || !pAnnot) |
222 return FALSE; | 222 return FALSE; |
223 | 223 |
224 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot); | 224 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot); |
225 return pWidgetHandler->OnMouseWheel( | 225 return pWidgetHandler->OnMouseWheel( |
226 pAnnot->GetXFAWidget(), GetFWLFlags(nFlags), zDelta, point.x, point.y); | 226 pAnnot->GetXFAWidget(), GetFWLFlags(nFlags), zDelta, point.x, point.y); |
227 } | 227 } |
228 | 228 |
229 FX_BOOL CPDFSDK_XFAAnnotHandler::OnRButtonDown(CPDFSDK_PageView* pPageView, | 229 FX_BOOL CPDFSDK_XFAWidgetHandler::OnRButtonDown(CPDFSDK_PageView* pPageView, |
230 CPDFSDK_Annot* pAnnot, | 230 CPDFSDK_Annot* pAnnot, |
231 uint32_t nFlags, | 231 uint32_t nFlags, |
232 const CFX_FloatPoint& point) { | 232 const CFX_FloatPoint& point) { |
233 if (!pPageView || !pAnnot) | 233 if (!pPageView || !pAnnot) |
234 return FALSE; | 234 return FALSE; |
235 | 235 |
236 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot); | 236 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot); |
237 return pWidgetHandler->OnRButtonDown(pAnnot->GetXFAWidget(), | 237 return pWidgetHandler->OnRButtonDown(pAnnot->GetXFAWidget(), |
238 GetFWLFlags(nFlags), point.x, point.y); | 238 GetFWLFlags(nFlags), point.x, point.y); |
239 } | 239 } |
240 | 240 |
241 FX_BOOL CPDFSDK_XFAAnnotHandler::OnRButtonUp(CPDFSDK_PageView* pPageView, | 241 FX_BOOL CPDFSDK_XFAWidgetHandler::OnRButtonUp(CPDFSDK_PageView* pPageView, |
242 CPDFSDK_Annot* pAnnot, | 242 CPDFSDK_Annot* pAnnot, |
243 uint32_t nFlags, | 243 uint32_t nFlags, |
244 const CFX_FloatPoint& point) { | 244 const CFX_FloatPoint& point) { |
245 if (!pPageView || !pAnnot) | 245 if (!pPageView || !pAnnot) |
246 return FALSE; | 246 return FALSE; |
247 | 247 |
248 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot); | 248 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot); |
249 return pWidgetHandler->OnRButtonUp(pAnnot->GetXFAWidget(), | 249 return pWidgetHandler->OnRButtonUp(pAnnot->GetXFAWidget(), |
250 GetFWLFlags(nFlags), point.x, point.y); | 250 GetFWLFlags(nFlags), point.x, point.y); |
251 } | 251 } |
252 | 252 |
253 FX_BOOL CPDFSDK_XFAAnnotHandler::OnRButtonDblClk(CPDFSDK_PageView* pPageView, | 253 FX_BOOL CPDFSDK_XFAWidgetHandler::OnRButtonDblClk(CPDFSDK_PageView* pPageView, |
254 CPDFSDK_Annot* pAnnot, | 254 CPDFSDK_Annot* pAnnot, |
255 uint32_t nFlags, | 255 uint32_t nFlags, |
256 const CFX_FloatPoint& point) { | 256 const CFX_FloatPoint& point) { |
257 if (!pPageView || !pAnnot) | 257 if (!pPageView || !pAnnot) |
258 return FALSE; | 258 return FALSE; |
259 | 259 |
260 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot); | 260 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot); |
261 return pWidgetHandler->OnRButtonDblClk(pAnnot->GetXFAWidget(), | 261 return pWidgetHandler->OnRButtonDblClk(pAnnot->GetXFAWidget(), |
262 GetFWLFlags(nFlags), point.x, point.y); | 262 GetFWLFlags(nFlags), point.x, point.y); |
263 } | 263 } |
264 | 264 |
265 FX_BOOL CPDFSDK_XFAAnnotHandler::OnChar(CPDFSDK_Annot* pAnnot, | 265 FX_BOOL CPDFSDK_XFAWidgetHandler::OnChar(CPDFSDK_Annot* pAnnot, |
266 uint32_t nChar, | 266 uint32_t nChar, |
267 uint32_t nFlags) { | 267 uint32_t nFlags) { |
268 if (!pAnnot) | 268 if (!pAnnot) |
269 return FALSE; | 269 return FALSE; |
270 | 270 |
271 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot); | 271 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot); |
272 return pWidgetHandler->OnChar(pAnnot->GetXFAWidget(), nChar, | 272 return pWidgetHandler->OnChar(pAnnot->GetXFAWidget(), nChar, |
273 GetFWLFlags(nFlags)); | 273 GetFWLFlags(nFlags)); |
274 } | 274 } |
275 | 275 |
276 FX_BOOL CPDFSDK_XFAAnnotHandler::OnKeyDown(CPDFSDK_Annot* pAnnot, | 276 FX_BOOL CPDFSDK_XFAWidgetHandler::OnKeyDown(CPDFSDK_Annot* pAnnot, |
277 int nKeyCode, | 277 int nKeyCode, |
278 int nFlag) { | 278 int nFlag) { |
279 if (!pAnnot) | 279 if (!pAnnot) |
280 return FALSE; | 280 return FALSE; |
281 | 281 |
282 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot); | 282 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot); |
283 return pWidgetHandler->OnKeyDown(pAnnot->GetXFAWidget(), nKeyCode, | 283 return pWidgetHandler->OnKeyDown(pAnnot->GetXFAWidget(), nKeyCode, |
284 GetFWLFlags(nFlag)); | 284 GetFWLFlags(nFlag)); |
285 } | 285 } |
286 | 286 |
287 FX_BOOL CPDFSDK_XFAAnnotHandler::OnKeyUp(CPDFSDK_Annot* pAnnot, | 287 FX_BOOL CPDFSDK_XFAWidgetHandler::OnKeyUp(CPDFSDK_Annot* pAnnot, |
288 int nKeyCode, | 288 int nKeyCode, |
289 int nFlag) { | 289 int nFlag) { |
290 if (!pAnnot) | 290 if (!pAnnot) |
291 return FALSE; | 291 return FALSE; |
292 | 292 |
293 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot); | 293 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot); |
294 return pWidgetHandler->OnKeyUp(pAnnot->GetXFAWidget(), nKeyCode, | 294 return pWidgetHandler->OnKeyUp(pAnnot->GetXFAWidget(), nKeyCode, |
295 GetFWLFlags(nFlag)); | 295 GetFWLFlags(nFlag)); |
296 } | 296 } |
297 | 297 |
298 void CPDFSDK_XFAAnnotHandler::OnDeSelected(CPDFSDK_Annot* pAnnot) {} | 298 void CPDFSDK_XFAWidgetHandler::OnDeSelected(CPDFSDK_Annot* pAnnot) {} |
299 | 299 |
300 void CPDFSDK_XFAAnnotHandler::OnSelected(CPDFSDK_Annot* pAnnot) {} | 300 void CPDFSDK_XFAWidgetHandler::OnSelected(CPDFSDK_Annot* pAnnot) {} |
301 | 301 |
302 FX_BOOL CPDFSDK_XFAAnnotHandler::OnSetFocus(CPDFSDK_Annot* pAnnot, | 302 FX_BOOL CPDFSDK_XFAWidgetHandler::OnSetFocus(CPDFSDK_Annot* pAnnot, |
303 uint32_t nFlag) { | |
304 return TRUE; | |
305 } | |
306 | |
307 FX_BOOL CPDFSDK_XFAAnnotHandler::OnKillFocus(CPDFSDK_Annot* pAnnot, | |
308 uint32_t nFlag) { | 303 uint32_t nFlag) { |
309 return TRUE; | 304 return TRUE; |
310 } | 305 } |
311 | 306 |
312 FX_BOOL CPDFSDK_XFAAnnotHandler::OnXFAChangedFocus(CPDFSDK_Annot* pOldAnnot, | 307 FX_BOOL CPDFSDK_XFAWidgetHandler::OnKillFocus(CPDFSDK_Annot* pAnnot, |
313 CPDFSDK_Annot* pNewAnnot) { | 308 uint32_t nFlag) { |
| 309 return TRUE; |
| 310 } |
| 311 |
| 312 FX_BOOL CPDFSDK_XFAWidgetHandler::OnXFAChangedFocus(CPDFSDK_Annot* pOldAnnot, |
| 313 CPDFSDK_Annot* pNewAnnot) { |
314 CXFA_FFWidgetHandler* pWidgetHandler = nullptr; | 314 CXFA_FFWidgetHandler* pWidgetHandler = nullptr; |
315 | 315 |
316 if (pOldAnnot) | 316 if (pOldAnnot) |
317 pWidgetHandler = GetXFAWidgetHandler(pOldAnnot); | 317 pWidgetHandler = GetXFAWidgetHandler(pOldAnnot); |
318 else if (pNewAnnot) | 318 else if (pNewAnnot) |
319 pWidgetHandler = GetXFAWidgetHandler(pNewAnnot); | 319 pWidgetHandler = GetXFAWidgetHandler(pNewAnnot); |
320 | 320 |
321 if (pWidgetHandler) { | 321 if (pWidgetHandler) { |
322 FX_BOOL bRet = TRUE; | 322 FX_BOOL bRet = TRUE; |
323 CXFA_FFWidget* hWidget = pNewAnnot ? pNewAnnot->GetXFAWidget() : nullptr; | 323 CXFA_FFWidget* hWidget = pNewAnnot ? pNewAnnot->GetXFAWidget() : nullptr; |
324 if (hWidget) { | 324 if (hWidget) { |
325 CXFA_FFPageView* pXFAPageView = hWidget->GetPageView(); | 325 CXFA_FFPageView* pXFAPageView = hWidget->GetPageView(); |
326 if (pXFAPageView) { | 326 if (pXFAPageView) { |
327 bRet = pXFAPageView->GetDocView()->SetFocus(hWidget); | 327 bRet = pXFAPageView->GetDocView()->SetFocus(hWidget); |
328 if (pXFAPageView->GetDocView()->GetFocusWidget() == hWidget) | 328 if (pXFAPageView->GetDocView()->GetFocusWidget() == hWidget) |
329 bRet = TRUE; | 329 bRet = TRUE; |
330 } | 330 } |
331 } | 331 } |
332 return bRet; | 332 return bRet; |
333 } | 333 } |
334 | 334 |
335 return TRUE; | 335 return TRUE; |
336 } | 336 } |
337 | 337 |
338 CXFA_FFWidgetHandler* CPDFSDK_XFAAnnotHandler::GetXFAWidgetHandler( | 338 CXFA_FFWidgetHandler* CPDFSDK_XFAWidgetHandler::GetXFAWidgetHandler( |
339 CPDFSDK_Annot* pAnnot) { | 339 CPDFSDK_Annot* pAnnot) { |
340 if (!pAnnot) | 340 if (!pAnnot) |
341 return nullptr; | 341 return nullptr; |
342 | 342 |
343 CPDFSDK_PageView* pPageView = pAnnot->GetPageView(); | 343 CPDFSDK_PageView* pPageView = pAnnot->GetPageView(); |
344 if (!pPageView) | 344 if (!pPageView) |
345 return nullptr; | 345 return nullptr; |
346 | 346 |
347 CPDFSDK_Document* pSDKDoc = pPageView->GetSDKDocument(); | 347 CPDFSDK_Document* pSDKDoc = pPageView->GetSDKDocument(); |
348 if (!pSDKDoc) | 348 if (!pSDKDoc) |
(...skipping 10 matching lines...) Expand all Loading... |
359 return pDocView->GetWidgetHandler(); | 359 return pDocView->GetWidgetHandler(); |
360 } | 360 } |
361 | 361 |
362 const uint32_t FWL_KEYFLAG_Ctrl = (1 << 0); | 362 const uint32_t FWL_KEYFLAG_Ctrl = (1 << 0); |
363 const uint32_t FWL_KEYFLAG_Alt = (1 << 1); | 363 const uint32_t FWL_KEYFLAG_Alt = (1 << 1); |
364 const uint32_t FWL_KEYFLAG_Shift = (1 << 2); | 364 const uint32_t FWL_KEYFLAG_Shift = (1 << 2); |
365 const uint32_t FWL_KEYFLAG_LButton = (1 << 3); | 365 const uint32_t FWL_KEYFLAG_LButton = (1 << 3); |
366 const uint32_t FWL_KEYFLAG_RButton = (1 << 4); | 366 const uint32_t FWL_KEYFLAG_RButton = (1 << 4); |
367 const uint32_t FWL_KEYFLAG_MButton = (1 << 5); | 367 const uint32_t FWL_KEYFLAG_MButton = (1 << 5); |
368 | 368 |
369 uint32_t CPDFSDK_XFAAnnotHandler::GetFWLFlags(uint32_t dwFlag) { | 369 uint32_t CPDFSDK_XFAWidgetHandler::GetFWLFlags(uint32_t dwFlag) { |
370 uint32_t dwFWLFlag = 0; | 370 uint32_t dwFWLFlag = 0; |
371 | 371 |
372 if (dwFlag & FWL_EVENTFLAG_ControlKey) | 372 if (dwFlag & FWL_EVENTFLAG_ControlKey) |
373 dwFWLFlag |= FWL_KEYFLAG_Ctrl; | 373 dwFWLFlag |= FWL_KEYFLAG_Ctrl; |
374 if (dwFlag & FWL_EVENTFLAG_LeftButtonDown) | 374 if (dwFlag & FWL_EVENTFLAG_LeftButtonDown) |
375 dwFWLFlag |= FWL_KEYFLAG_LButton; | 375 dwFWLFlag |= FWL_KEYFLAG_LButton; |
376 if (dwFlag & FWL_EVENTFLAG_MiddleButtonDown) | 376 if (dwFlag & FWL_EVENTFLAG_MiddleButtonDown) |
377 dwFWLFlag |= FWL_KEYFLAG_MButton; | 377 dwFWLFlag |= FWL_KEYFLAG_MButton; |
378 if (dwFlag & FWL_EVENTFLAG_RightButtonDown) | 378 if (dwFlag & FWL_EVENTFLAG_RightButtonDown) |
379 dwFWLFlag |= FWL_KEYFLAG_RButton; | 379 dwFWLFlag |= FWL_KEYFLAG_RButton; |
380 if (dwFlag & FWL_EVENTFLAG_ShiftKey) | 380 if (dwFlag & FWL_EVENTFLAG_ShiftKey) |
381 dwFWLFlag |= FWL_KEYFLAG_Shift; | 381 dwFWLFlag |= FWL_KEYFLAG_Shift; |
382 if (dwFlag & FWL_EVENTFLAG_AltKey) | 382 if (dwFlag & FWL_EVENTFLAG_AltKey) |
383 dwFWLFlag |= FWL_KEYFLAG_Alt; | 383 dwFWLFlag |= FWL_KEYFLAG_Alt; |
384 | 384 |
385 return dwFWLFlag; | 385 return dwFWLFlag; |
386 } | 386 } |
OLD | NEW |