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/cpdfsdk_pageview.h" | 7 #include "fpdfsdk/cpdfsdk_pageview.h" |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <vector> | 10 #include <vector> |
(...skipping 18 matching lines...) Expand all Loading... |
29 #include "xfa/fxgraphics/cfx_graphics.h" | 29 #include "xfa/fxgraphics/cfx_graphics.h" |
30 #endif // PDF_ENABLE_XFA | 30 #endif // PDF_ENABLE_XFA |
31 | 31 |
32 CPDFSDK_PageView::CPDFSDK_PageView(CPDFSDK_FormFillEnvironment* pFormFillEnv, | 32 CPDFSDK_PageView::CPDFSDK_PageView(CPDFSDK_FormFillEnvironment* pFormFillEnv, |
33 UnderlyingPageType* page) | 33 UnderlyingPageType* page) |
34 : m_page(page), | 34 : m_page(page), |
35 m_pFormFillEnv(pFormFillEnv), | 35 m_pFormFillEnv(pFormFillEnv), |
36 #ifndef PDF_ENABLE_XFA | 36 #ifndef PDF_ENABLE_XFA |
37 m_bOwnsPage(false), | 37 m_bOwnsPage(false), |
38 #endif // PDF_ENABLE_XFA | 38 #endif // PDF_ENABLE_XFA |
39 m_bEnterWidget(FALSE), | 39 m_bEnterWidget(false), |
40 m_bExitWidget(FALSE), | 40 m_bExitWidget(false), |
41 m_bOnWidget(FALSE), | 41 m_bOnWidget(false), |
42 m_bValid(FALSE), | 42 m_bValid(false), |
43 m_bLocked(FALSE), | 43 m_bLocked(false), |
44 m_bBeingDestroyed(false) { | 44 m_bBeingDestroyed(false) { |
45 CPDFSDK_InterForm* pInterForm = pFormFillEnv->GetInterForm(); | 45 CPDFSDK_InterForm* pInterForm = pFormFillEnv->GetInterForm(); |
46 if (pInterForm) { | 46 if (pInterForm) { |
47 CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm(); | 47 CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm(); |
48 #ifdef PDF_ENABLE_XFA | 48 #ifdef PDF_ENABLE_XFA |
49 if (page->GetPDFPage()) | 49 if (page->GetPDFPage()) |
50 pPDFInterForm->FixPageFields(page->GetPDFPage()); | 50 pPDFInterForm->FixPageFields(page->GetPDFPage()); |
51 #else // PDF_ENABLE_XFA | 51 #else // PDF_ENABLE_XFA |
52 pPDFInterForm->FixPageFields(page); | 52 pPDFInterForm->FixPageFields(page); |
53 #endif // PDF_ENABLE_XFA | 53 #endif // PDF_ENABLE_XFA |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 CFX_Graphics gs; | 98 CFX_Graphics gs; |
99 gs.Create(pDevice); | 99 gs.Create(pDevice); |
100 CFX_RectF rectClip; | 100 CFX_RectF rectClip; |
101 rectClip.Set(static_cast<FX_FLOAT>(pClip.left), | 101 rectClip.Set(static_cast<FX_FLOAT>(pClip.left), |
102 static_cast<FX_FLOAT>(pClip.top), | 102 static_cast<FX_FLOAT>(pClip.top), |
103 static_cast<FX_FLOAT>(pClip.Width()), | 103 static_cast<FX_FLOAT>(pClip.Width()), |
104 static_cast<FX_FLOAT>(pClip.Height())); | 104 static_cast<FX_FLOAT>(pClip.Height())); |
105 gs.SetClipRect(rectClip); | 105 gs.SetClipRect(rectClip); |
106 std::unique_ptr<CXFA_RenderContext> pRenderContext(new CXFA_RenderContext); | 106 std::unique_ptr<CXFA_RenderContext> pRenderContext(new CXFA_RenderContext); |
107 CXFA_RenderOptions renderOptions; | 107 CXFA_RenderOptions renderOptions; |
108 renderOptions.m_bHighlight = TRUE; | 108 renderOptions.m_bHighlight = true; |
109 CXFA_FFPageView* xfaView = pPage->GetXFAPageView(); | 109 CXFA_FFPageView* xfaView = pPage->GetXFAPageView(); |
110 pRenderContext->StartRender(xfaView, &gs, *pUser2Device, renderOptions); | 110 pRenderContext->StartRender(xfaView, &gs, *pUser2Device, renderOptions); |
111 pRenderContext->DoRender(); | 111 pRenderContext->DoRender(); |
112 pRenderContext->StopRender(); | 112 pRenderContext->StopRender(); |
113 CXFA_FFDocView* docView = xfaView->GetDocView(); | 113 CXFA_FFDocView* docView = xfaView->GetDocView(); |
114 if (!docView) | 114 if (!docView) |
115 return; | 115 return; |
116 CPDFSDK_Annot* annot = GetFocusAnnot(); | 116 CPDFSDK_Annot* annot = GetFocusAnnot(); |
117 if (!annot) | 117 if (!annot) |
118 return; | 118 return; |
119 // Render the focus widget | 119 // Render the focus widget |
120 docView->GetWidgetHandler()->RenderWidget(annot->GetXFAWidget(), &gs, | 120 docView->GetWidgetHandler()->RenderWidget(annot->GetXFAWidget(), &gs, |
121 pUser2Device, FALSE); | 121 pUser2Device, false); |
122 return; | 122 return; |
123 } | 123 } |
124 #endif // PDF_ENABLE_XFA | 124 #endif // PDF_ENABLE_XFA |
125 | 125 |
126 // for pdf/static xfa. | 126 // for pdf/static xfa. |
127 CPDFSDK_AnnotIterator annotIterator(this, true); | 127 CPDFSDK_AnnotIterator annotIterator(this, true); |
128 while (CPDFSDK_Annot* pSDKAnnot = annotIterator.Next()) { | 128 while (CPDFSDK_Annot* pSDKAnnot = annotIterator.Next()) { |
129 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = | 129 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = |
130 m_pFormFillEnv->GetAnnotHandlerMgr(); | 130 m_pFormFillEnv->GetAnnotHandlerMgr(); |
131 pAnnotHandlerMgr->Annot_OnDraw(this, pSDKAnnot, pDevice, pUser2Device, | 131 pAnnotHandlerMgr->Annot_OnDraw(this, pSDKAnnot, pDevice, pUser2Device, |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 | 180 |
181 CPDFSDK_AnnotHandlerMgr* pAnnotHandler = m_pFormFillEnv->GetAnnotHandlerMgr(); | 181 CPDFSDK_AnnotHandlerMgr* pAnnotHandler = m_pFormFillEnv->GetAnnotHandlerMgr(); |
182 pSDKAnnot = pAnnotHandler->NewAnnot(pPDFAnnot, this); | 182 pSDKAnnot = pAnnotHandler->NewAnnot(pPDFAnnot, this); |
183 if (!pSDKAnnot) | 183 if (!pSDKAnnot) |
184 return nullptr; | 184 return nullptr; |
185 | 185 |
186 m_SDKAnnotArray.push_back(pSDKAnnot); | 186 m_SDKAnnotArray.push_back(pSDKAnnot); |
187 return pSDKAnnot; | 187 return pSDKAnnot; |
188 } | 188 } |
189 | 189 |
190 FX_BOOL CPDFSDK_PageView::DeleteAnnot(CPDFSDK_Annot* pAnnot) { | 190 bool CPDFSDK_PageView::DeleteAnnot(CPDFSDK_Annot* pAnnot) { |
191 if (!pAnnot) | 191 if (!pAnnot) |
192 return FALSE; | 192 return false; |
193 CPDFXFA_Page* pPage = pAnnot->GetPDFXFAPage(); | 193 CPDFXFA_Page* pPage = pAnnot->GetPDFXFAPage(); |
194 if (!pPage || (pPage->GetContext()->GetDocType() != DOCTYPE_STATIC_XFA && | 194 if (!pPage || (pPage->GetContext()->GetDocType() != DOCTYPE_STATIC_XFA && |
195 pPage->GetContext()->GetDocType() != DOCTYPE_DYNAMIC_XFA)) | 195 pPage->GetContext()->GetDocType() != DOCTYPE_DYNAMIC_XFA)) |
196 return FALSE; | 196 return false; |
197 | 197 |
198 if (GetFocusAnnot() == pAnnot) | 198 if (GetFocusAnnot() == pAnnot) |
199 m_pFormFillEnv->KillFocusAnnot(0); | 199 m_pFormFillEnv->KillFocusAnnot(0); |
200 CPDFSDK_AnnotHandlerMgr* pAnnotHandler = m_pFormFillEnv->GetAnnotHandlerMgr(); | 200 CPDFSDK_AnnotHandlerMgr* pAnnotHandler = m_pFormFillEnv->GetAnnotHandlerMgr(); |
201 if (pAnnotHandler) | 201 if (pAnnotHandler) |
202 pAnnotHandler->ReleaseAnnot(pAnnot); | 202 pAnnotHandler->ReleaseAnnot(pAnnot); |
203 | 203 |
204 auto it = std::find(m_SDKAnnotArray.begin(), m_SDKAnnotArray.end(), pAnnot); | 204 auto it = std::find(m_SDKAnnotArray.begin(), m_SDKAnnotArray.end(), pAnnot); |
205 if (it != m_SDKAnnotArray.end()) | 205 if (it != m_SDKAnnotArray.end()) |
206 m_SDKAnnotArray.erase(it); | 206 m_SDKAnnotArray.erase(it); |
207 if (m_pCaptureWidget.Get() == pAnnot) | 207 if (m_pCaptureWidget.Get() == pAnnot) |
208 m_pCaptureWidget.Reset(); | 208 m_pCaptureWidget.Reset(); |
209 | 209 |
210 return TRUE; | 210 return true; |
211 } | 211 } |
212 #endif // PDF_ENABLE_XFA | 212 #endif // PDF_ENABLE_XFA |
213 | 213 |
214 CPDF_Document* CPDFSDK_PageView::GetPDFDocument() { | 214 CPDF_Document* CPDFSDK_PageView::GetPDFDocument() { |
215 if (m_page) { | 215 if (m_page) { |
216 #ifdef PDF_ENABLE_XFA | 216 #ifdef PDF_ENABLE_XFA |
217 return m_page->GetContext()->GetPDFDoc(); | 217 return m_page->GetContext()->GetPDFDoc(); |
218 #else // PDF_ENABLE_XFA | 218 #else // PDF_ENABLE_XFA |
219 return m_page->m_pDocument; | 219 return m_page->m_pDocument; |
220 #endif // PDF_ENABLE_XFA | 220 #endif // PDF_ENABLE_XFA |
(...skipping 23 matching lines...) Expand all Loading... |
244 return nullptr; | 244 return nullptr; |
245 | 245 |
246 for (CPDFSDK_Annot* pAnnot : m_SDKAnnotArray) { | 246 for (CPDFSDK_Annot* pAnnot : m_SDKAnnotArray) { |
247 if (pAnnot->GetXFAWidget() == hWidget) | 247 if (pAnnot->GetXFAWidget() == hWidget) |
248 return pAnnot; | 248 return pAnnot; |
249 } | 249 } |
250 return nullptr; | 250 return nullptr; |
251 } | 251 } |
252 #endif // PDF_ENABLE_XFA | 252 #endif // PDF_ENABLE_XFA |
253 | 253 |
254 FX_BOOL CPDFSDK_PageView::OnLButtonDown(const CFX_FloatPoint& point, | 254 bool CPDFSDK_PageView::OnLButtonDown(const CFX_FloatPoint& point, |
255 uint32_t nFlag) { | 255 uint32_t nFlag) { |
256 CPDFSDK_Annot::ObservedPtr pAnnot(GetFXWidgetAtPoint(point.x, point.y)); | 256 CPDFSDK_Annot::ObservedPtr pAnnot(GetFXWidgetAtPoint(point.x, point.y)); |
257 if (!pAnnot) { | 257 if (!pAnnot) { |
258 m_pFormFillEnv->KillFocusAnnot(nFlag); | 258 m_pFormFillEnv->KillFocusAnnot(nFlag); |
259 return FALSE; | 259 return false; |
260 } | 260 } |
261 | 261 |
262 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = | 262 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = |
263 m_pFormFillEnv->GetAnnotHandlerMgr(); | 263 m_pFormFillEnv->GetAnnotHandlerMgr(); |
264 if (!pAnnotHandlerMgr->Annot_OnLButtonDown(this, &pAnnot, nFlag, point)) | 264 if (!pAnnotHandlerMgr->Annot_OnLButtonDown(this, &pAnnot, nFlag, point)) |
265 return FALSE; | 265 return false; |
266 | 266 |
267 if (!pAnnot) | 267 if (!pAnnot) |
268 return FALSE; | 268 return false; |
269 | 269 |
270 m_pFormFillEnv->SetFocusAnnot(&pAnnot); | 270 m_pFormFillEnv->SetFocusAnnot(&pAnnot); |
271 return TRUE; | 271 return true; |
272 } | 272 } |
273 | 273 |
274 #ifdef PDF_ENABLE_XFA | 274 #ifdef PDF_ENABLE_XFA |
275 FX_BOOL CPDFSDK_PageView::OnRButtonDown(const CFX_FloatPoint& point, | 275 bool CPDFSDK_PageView::OnRButtonDown(const CFX_FloatPoint& point, |
276 uint32_t nFlag) { | 276 uint32_t nFlag) { |
277 CPDFSDK_Annot::ObservedPtr pAnnot(GetFXWidgetAtPoint(point.x, point.y)); | 277 CPDFSDK_Annot::ObservedPtr pAnnot(GetFXWidgetAtPoint(point.x, point.y)); |
278 if (!pAnnot) | 278 if (!pAnnot) |
279 return FALSE; | 279 return false; |
280 | 280 |
281 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = | 281 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = |
282 m_pFormFillEnv->GetAnnotHandlerMgr(); | 282 m_pFormFillEnv->GetAnnotHandlerMgr(); |
283 FX_BOOL ok = | 283 bool ok = pAnnotHandlerMgr->Annot_OnRButtonDown(this, &pAnnot, nFlag, point); |
284 pAnnotHandlerMgr->Annot_OnRButtonDown(this, &pAnnot, nFlag, point); | |
285 if (!pAnnot) | 284 if (!pAnnot) |
286 return FALSE; | 285 return false; |
287 | 286 |
288 if (ok) | 287 if (ok) |
289 m_pFormFillEnv->SetFocusAnnot(&pAnnot); | 288 m_pFormFillEnv->SetFocusAnnot(&pAnnot); |
290 | 289 |
291 return TRUE; | 290 return true; |
292 } | 291 } |
293 | 292 |
294 FX_BOOL CPDFSDK_PageView::OnRButtonUp(const CFX_FloatPoint& point, | 293 bool CPDFSDK_PageView::OnRButtonUp(const CFX_FloatPoint& point, |
295 uint32_t nFlag) { | 294 uint32_t nFlag) { |
296 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = | 295 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = |
297 m_pFormFillEnv->GetAnnotHandlerMgr(); | 296 m_pFormFillEnv->GetAnnotHandlerMgr(); |
298 CPDFSDK_Annot::ObservedPtr pFXAnnot(GetFXWidgetAtPoint(point.x, point.y)); | 297 CPDFSDK_Annot::ObservedPtr pFXAnnot(GetFXWidgetAtPoint(point.x, point.y)); |
299 if (!pFXAnnot) | 298 if (!pFXAnnot) |
300 return FALSE; | 299 return false; |
301 | 300 |
302 if (pAnnotHandlerMgr->Annot_OnRButtonUp(this, &pFXAnnot, nFlag, point)) | 301 if (pAnnotHandlerMgr->Annot_OnRButtonUp(this, &pFXAnnot, nFlag, point)) |
303 m_pFormFillEnv->SetFocusAnnot(&pFXAnnot); | 302 m_pFormFillEnv->SetFocusAnnot(&pFXAnnot); |
304 | 303 |
305 return TRUE; | 304 return true; |
306 } | 305 } |
307 #endif // PDF_ENABLE_XFA | 306 #endif // PDF_ENABLE_XFA |
308 | 307 |
309 FX_BOOL CPDFSDK_PageView::OnLButtonUp(const CFX_FloatPoint& point, | 308 bool CPDFSDK_PageView::OnLButtonUp(const CFX_FloatPoint& point, |
310 uint32_t nFlag) { | 309 uint32_t nFlag) { |
311 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = | 310 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = |
312 m_pFormFillEnv->GetAnnotHandlerMgr(); | 311 m_pFormFillEnv->GetAnnotHandlerMgr(); |
313 CPDFSDK_Annot::ObservedPtr pFXAnnot(GetFXWidgetAtPoint(point.x, point.y)); | 312 CPDFSDK_Annot::ObservedPtr pFXAnnot(GetFXWidgetAtPoint(point.x, point.y)); |
314 CPDFSDK_Annot::ObservedPtr pFocusAnnot(GetFocusAnnot()); | 313 CPDFSDK_Annot::ObservedPtr pFocusAnnot(GetFocusAnnot()); |
315 if (pFocusAnnot && pFocusAnnot != pFXAnnot) { | 314 if (pFocusAnnot && pFocusAnnot != pFXAnnot) { |
316 // Last focus Annot gets a chance to handle the event. | 315 // Last focus Annot gets a chance to handle the event. |
317 if (pAnnotHandlerMgr->Annot_OnLButtonUp(this, &pFocusAnnot, nFlag, point)) | 316 if (pAnnotHandlerMgr->Annot_OnLButtonUp(this, &pFocusAnnot, nFlag, point)) |
318 return TRUE; | 317 return true; |
319 } | 318 } |
320 return pFXAnnot && | 319 return pFXAnnot && |
321 pAnnotHandlerMgr->Annot_OnLButtonUp(this, &pFXAnnot, nFlag, point); | 320 pAnnotHandlerMgr->Annot_OnLButtonUp(this, &pFXAnnot, nFlag, point); |
322 } | 321 } |
323 | 322 |
324 FX_BOOL CPDFSDK_PageView::OnMouseMove(const CFX_FloatPoint& point, int nFlag) { | 323 bool CPDFSDK_PageView::OnMouseMove(const CFX_FloatPoint& point, int nFlag) { |
325 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = | 324 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = |
326 m_pFormFillEnv->GetAnnotHandlerMgr(); | 325 m_pFormFillEnv->GetAnnotHandlerMgr(); |
327 CPDFSDK_Annot::ObservedPtr pFXAnnot(GetFXAnnotAtPoint(point.x, point.y)); | 326 CPDFSDK_Annot::ObservedPtr pFXAnnot(GetFXAnnotAtPoint(point.x, point.y)); |
328 if (pFXAnnot) { | 327 if (pFXAnnot) { |
329 if (m_pCaptureWidget && m_pCaptureWidget != pFXAnnot) { | 328 if (m_pCaptureWidget && m_pCaptureWidget != pFXAnnot) { |
330 m_bExitWidget = TRUE; | 329 m_bExitWidget = true; |
331 m_bEnterWidget = FALSE; | 330 m_bEnterWidget = false; |
332 pAnnotHandlerMgr->Annot_OnMouseExit(this, &m_pCaptureWidget, nFlag); | 331 pAnnotHandlerMgr->Annot_OnMouseExit(this, &m_pCaptureWidget, nFlag); |
333 } | 332 } |
334 m_pCaptureWidget.Reset(pFXAnnot.Get()); | 333 m_pCaptureWidget.Reset(pFXAnnot.Get()); |
335 m_bOnWidget = TRUE; | 334 m_bOnWidget = true; |
336 if (!m_bEnterWidget) { | 335 if (!m_bEnterWidget) { |
337 m_bEnterWidget = TRUE; | 336 m_bEnterWidget = true; |
338 m_bExitWidget = FALSE; | 337 m_bExitWidget = false; |
339 pAnnotHandlerMgr->Annot_OnMouseEnter(this, &pFXAnnot, nFlag); | 338 pAnnotHandlerMgr->Annot_OnMouseEnter(this, &pFXAnnot, nFlag); |
340 } | 339 } |
341 pAnnotHandlerMgr->Annot_OnMouseMove(this, &pFXAnnot, nFlag, point); | 340 pAnnotHandlerMgr->Annot_OnMouseMove(this, &pFXAnnot, nFlag, point); |
342 return TRUE; | 341 return true; |
343 } | 342 } |
344 if (m_bOnWidget) { | 343 if (m_bOnWidget) { |
345 m_bOnWidget = FALSE; | 344 m_bOnWidget = false; |
346 m_bExitWidget = TRUE; | 345 m_bExitWidget = true; |
347 m_bEnterWidget = FALSE; | 346 m_bEnterWidget = false; |
348 if (m_pCaptureWidget) { | 347 if (m_pCaptureWidget) { |
349 pAnnotHandlerMgr->Annot_OnMouseExit(this, &m_pCaptureWidget, nFlag); | 348 pAnnotHandlerMgr->Annot_OnMouseExit(this, &m_pCaptureWidget, nFlag); |
350 m_pCaptureWidget.Reset(); | 349 m_pCaptureWidget.Reset(); |
351 } | 350 } |
352 } | 351 } |
353 return FALSE; | 352 return false; |
354 } | 353 } |
355 | 354 |
356 FX_BOOL CPDFSDK_PageView::OnMouseWheel(double deltaX, | 355 bool CPDFSDK_PageView::OnMouseWheel(double deltaX, |
357 double deltaY, | 356 double deltaY, |
358 const CFX_FloatPoint& point, | 357 const CFX_FloatPoint& point, |
359 int nFlag) { | 358 int nFlag) { |
360 CPDFSDK_Annot::ObservedPtr pAnnot(GetFXWidgetAtPoint(point.x, point.y)); | 359 CPDFSDK_Annot::ObservedPtr pAnnot(GetFXWidgetAtPoint(point.x, point.y)); |
361 if (!pAnnot) | 360 if (!pAnnot) |
362 return FALSE; | 361 return false; |
363 | 362 |
364 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = | 363 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = |
365 m_pFormFillEnv->GetAnnotHandlerMgr(); | 364 m_pFormFillEnv->GetAnnotHandlerMgr(); |
366 return pAnnotHandlerMgr->Annot_OnMouseWheel(this, &pAnnot, nFlag, (int)deltaY, | 365 return pAnnotHandlerMgr->Annot_OnMouseWheel(this, &pAnnot, nFlag, (int)deltaY, |
367 point); | 366 point); |
368 } | 367 } |
369 | 368 |
370 FX_BOOL CPDFSDK_PageView::OnChar(int nChar, uint32_t nFlag) { | 369 bool CPDFSDK_PageView::OnChar(int nChar, uint32_t nFlag) { |
371 if (CPDFSDK_Annot* pAnnot = GetFocusAnnot()) { | 370 if (CPDFSDK_Annot* pAnnot = GetFocusAnnot()) { |
372 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = | 371 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = |
373 m_pFormFillEnv->GetAnnotHandlerMgr(); | 372 m_pFormFillEnv->GetAnnotHandlerMgr(); |
374 return pAnnotHandlerMgr->Annot_OnChar(pAnnot, nChar, nFlag); | 373 return pAnnotHandlerMgr->Annot_OnChar(pAnnot, nChar, nFlag); |
375 } | 374 } |
376 | 375 |
377 return FALSE; | 376 return false; |
378 } | 377 } |
379 | 378 |
380 FX_BOOL CPDFSDK_PageView::OnKeyDown(int nKeyCode, int nFlag) { | 379 bool CPDFSDK_PageView::OnKeyDown(int nKeyCode, int nFlag) { |
381 if (CPDFSDK_Annot* pAnnot = GetFocusAnnot()) { | 380 if (CPDFSDK_Annot* pAnnot = GetFocusAnnot()) { |
382 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = | 381 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = |
383 m_pFormFillEnv->GetAnnotHandlerMgr(); | 382 m_pFormFillEnv->GetAnnotHandlerMgr(); |
384 return pAnnotHandlerMgr->Annot_OnKeyDown(pAnnot, nKeyCode, nFlag); | 383 return pAnnotHandlerMgr->Annot_OnKeyDown(pAnnot, nKeyCode, nFlag); |
385 } | 384 } |
386 return FALSE; | 385 return false; |
387 } | 386 } |
388 | 387 |
389 FX_BOOL CPDFSDK_PageView::OnKeyUp(int nKeyCode, int nFlag) { | 388 bool CPDFSDK_PageView::OnKeyUp(int nKeyCode, int nFlag) { |
390 return FALSE; | 389 return false; |
391 } | 390 } |
392 | 391 |
393 void CPDFSDK_PageView::LoadFXAnnots() { | 392 void CPDFSDK_PageView::LoadFXAnnots() { |
394 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = | 393 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = |
395 m_pFormFillEnv->GetAnnotHandlerMgr(); | 394 m_pFormFillEnv->GetAnnotHandlerMgr(); |
396 | 395 |
397 SetLock(TRUE); | 396 SetLock(true); |
398 | 397 |
399 #ifdef PDF_ENABLE_XFA | 398 #ifdef PDF_ENABLE_XFA |
400 CFX_RetainPtr<CPDFXFA_Page> protector(m_page); | 399 CFX_RetainPtr<CPDFXFA_Page> protector(m_page); |
401 if (m_pFormFillEnv->GetXFAContext()->GetDocType() == DOCTYPE_DYNAMIC_XFA) { | 400 if (m_pFormFillEnv->GetXFAContext()->GetDocType() == DOCTYPE_DYNAMIC_XFA) { |
402 CXFA_FFPageView* pageView = m_page->GetXFAPageView(); | 401 CXFA_FFPageView* pageView = m_page->GetXFAPageView(); |
403 std::unique_ptr<IXFA_WidgetIterator> pWidgetHander( | 402 std::unique_ptr<IXFA_WidgetIterator> pWidgetHander( |
404 pageView->CreateWidgetIterator( | 403 pageView->CreateWidgetIterator( |
405 XFA_TRAVERSEWAY_Form, | 404 XFA_TRAVERSEWAY_Form, |
406 XFA_WidgetStatus_Visible | XFA_WidgetStatus_Viewable)); | 405 XFA_WidgetStatus_Visible | XFA_WidgetStatus_Viewable)); |
407 if (!pWidgetHander) { | 406 if (!pWidgetHander) { |
408 SetLock(FALSE); | 407 SetLock(false); |
409 return; | 408 return; |
410 } | 409 } |
411 | 410 |
412 while (CXFA_FFWidget* pXFAAnnot = pWidgetHander->MoveToNext()) { | 411 while (CXFA_FFWidget* pXFAAnnot = pWidgetHander->MoveToNext()) { |
413 CPDFSDK_Annot* pAnnot = pAnnotHandlerMgr->NewAnnot(pXFAAnnot, this); | 412 CPDFSDK_Annot* pAnnot = pAnnotHandlerMgr->NewAnnot(pXFAAnnot, this); |
414 if (!pAnnot) | 413 if (!pAnnot) |
415 continue; | 414 continue; |
416 m_SDKAnnotArray.push_back(pAnnot); | 415 m_SDKAnnotArray.push_back(pAnnot); |
417 pAnnotHandlerMgr->Annot_OnLoad(pAnnot); | 416 pAnnotHandlerMgr->Annot_OnLoad(pAnnot); |
418 } | 417 } |
419 | 418 |
420 SetLock(FALSE); | 419 SetLock(false); |
421 return; | 420 return; |
422 } | 421 } |
423 #endif // PDF_ENABLE_XFA | 422 #endif // PDF_ENABLE_XFA |
424 | 423 |
425 CPDF_Page* pPage = GetPDFPage(); | 424 CPDF_Page* pPage = GetPDFPage(); |
426 ASSERT(pPage); | 425 ASSERT(pPage); |
427 bool bUpdateAP = CPDF_InterForm::IsUpdateAPEnabled(); | 426 bool bUpdateAP = CPDF_InterForm::IsUpdateAPEnabled(); |
428 // Disable the default AP construction. | 427 // Disable the default AP construction. |
429 CPDF_InterForm::SetUpdateAP(false); | 428 CPDF_InterForm::SetUpdateAP(false); |
430 m_pAnnotList = pdfium::MakeUnique<CPDF_AnnotList>(pPage); | 429 m_pAnnotList = pdfium::MakeUnique<CPDF_AnnotList>(pPage); |
431 CPDF_InterForm::SetUpdateAP(bUpdateAP); | 430 CPDF_InterForm::SetUpdateAP(bUpdateAP); |
432 | 431 |
433 const size_t nCount = m_pAnnotList->Count(); | 432 const size_t nCount = m_pAnnotList->Count(); |
434 for (size_t i = 0; i < nCount; ++i) { | 433 for (size_t i = 0; i < nCount; ++i) { |
435 CPDF_Annot* pPDFAnnot = m_pAnnotList->GetAt(i); | 434 CPDF_Annot* pPDFAnnot = m_pAnnotList->GetAt(i); |
436 CheckUnSupportAnnot(GetPDFDocument(), pPDFAnnot); | 435 CheckUnSupportAnnot(GetPDFDocument(), pPDFAnnot); |
437 CPDFSDK_Annot* pAnnot = pAnnotHandlerMgr->NewAnnot(pPDFAnnot, this); | 436 CPDFSDK_Annot* pAnnot = pAnnotHandlerMgr->NewAnnot(pPDFAnnot, this); |
438 if (!pAnnot) | 437 if (!pAnnot) |
439 continue; | 438 continue; |
440 m_SDKAnnotArray.push_back(pAnnot); | 439 m_SDKAnnotArray.push_back(pAnnot); |
441 pAnnotHandlerMgr->Annot_OnLoad(pAnnot); | 440 pAnnotHandlerMgr->Annot_OnLoad(pAnnot); |
442 } | 441 } |
443 | 442 |
444 SetLock(FALSE); | 443 SetLock(false); |
445 } | 444 } |
446 | 445 |
447 void CPDFSDK_PageView::UpdateRects(const std::vector<CFX_FloatRect>& rects) { | 446 void CPDFSDK_PageView::UpdateRects(const std::vector<CFX_FloatRect>& rects) { |
448 for (const auto& rc : rects) | 447 for (const auto& rc : rects) |
449 m_pFormFillEnv->Invalidate(m_page, rc.left, rc.top, rc.right, rc.bottom); | 448 m_pFormFillEnv->Invalidate(m_page, rc.left, rc.top, rc.right, rc.bottom); |
450 } | 449 } |
451 | 450 |
452 void CPDFSDK_PageView::UpdateView(CPDFSDK_Annot* pAnnot) { | 451 void CPDFSDK_PageView::UpdateView(CPDFSDK_Annot* pAnnot) { |
453 CFX_FloatRect rcWindow = pAnnot->GetRect(); | 452 CFX_FloatRect rcWindow = pAnnot->GetRect(); |
454 m_pFormFillEnv->Invalidate(m_page, rcWindow.left, rcWindow.top, | 453 m_pFormFillEnv->Invalidate(m_page, rcWindow.left, rcWindow.top, |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
498 CPDFSDK_Annot* CPDFSDK_PageView::GetFocusAnnot() { | 497 CPDFSDK_Annot* CPDFSDK_PageView::GetFocusAnnot() { |
499 CPDFSDK_Annot* pFocusAnnot = m_pFormFillEnv->GetFocusAnnot(); | 498 CPDFSDK_Annot* pFocusAnnot = m_pFormFillEnv->GetFocusAnnot(); |
500 return IsValidSDKAnnot(pFocusAnnot) ? pFocusAnnot : nullptr; | 499 return IsValidSDKAnnot(pFocusAnnot) ? pFocusAnnot : nullptr; |
501 } | 500 } |
502 | 501 |
503 int CPDFSDK_PageView::GetPageIndexForStaticPDF() const { | 502 int CPDFSDK_PageView::GetPageIndexForStaticPDF() const { |
504 CPDF_Dictionary* pDict = GetPDFPage()->m_pFormDict; | 503 CPDF_Dictionary* pDict = GetPDFPage()->m_pFormDict; |
505 CPDF_Document* pDoc = m_pFormFillEnv->GetPDFDocument(); | 504 CPDF_Document* pDoc = m_pFormFillEnv->GetPDFDocument(); |
506 return (pDoc && pDict) ? pDoc->GetPageIndex(pDict->GetObjNum()) : -1; | 505 return (pDoc && pDict) ? pDoc->GetPageIndex(pDict->GetObjNum()) : -1; |
507 } | 506 } |
OLD | NEW |