| 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_pageview.h" | 7 #include "fpdfsdk/include/cpdfsdk_pageview.h" |
| 8 | 8 |
| 9 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" | 9 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" |
| 10 #include "core/fpdfapi/fpdf_render/include/cpdf_renderoptions.h" | 10 #include "core/fpdfapi/fpdf_render/include/cpdf_renderoptions.h" |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 | 310 |
| 311 for (CPDFSDK_Annot* pAnnot : m_fxAnnotArray) { | 311 for (CPDFSDK_Annot* pAnnot : m_fxAnnotArray) { |
| 312 if (pAnnot->GetXFAWidget() == hWidget) | 312 if (pAnnot->GetXFAWidget() == hWidget) |
| 313 return pAnnot; | 313 return pAnnot; |
| 314 } | 314 } |
| 315 return nullptr; | 315 return nullptr; |
| 316 } | 316 } |
| 317 #endif // PDF_ENABLE_XFA | 317 #endif // PDF_ENABLE_XFA |
| 318 | 318 |
| 319 FX_BOOL CPDFSDK_PageView::OnLButtonDown(const CFX_FloatPoint& point, | 319 FX_BOOL CPDFSDK_PageView::OnLButtonDown(const CFX_FloatPoint& point, |
| 320 FX_UINT nFlag) { | 320 uint32_t nFlag) { |
| 321 CPDFSDK_Environment* pEnv = m_pSDKDoc->GetEnv(); | 321 CPDFSDK_Environment* pEnv = m_pSDKDoc->GetEnv(); |
| 322 ASSERT(pEnv); | 322 ASSERT(pEnv); |
| 323 CPDFSDK_Annot* pFXAnnot = GetFXWidgetAtPoint(point.x, point.y); | 323 CPDFSDK_Annot* pFXAnnot = GetFXWidgetAtPoint(point.x, point.y); |
| 324 if (!pFXAnnot) { | 324 if (!pFXAnnot) { |
| 325 KillFocusAnnot(nFlag); | 325 KillFocusAnnot(nFlag); |
| 326 return FALSE; | 326 return FALSE; |
| 327 } | 327 } |
| 328 | 328 |
| 329 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); | 329 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); |
| 330 FX_BOOL bRet = | 330 FX_BOOL bRet = |
| 331 pAnnotHandlerMgr->Annot_OnLButtonDown(this, pFXAnnot, nFlag, point); | 331 pAnnotHandlerMgr->Annot_OnLButtonDown(this, pFXAnnot, nFlag, point); |
| 332 if (bRet) | 332 if (bRet) |
| 333 SetFocusAnnot(pFXAnnot); | 333 SetFocusAnnot(pFXAnnot); |
| 334 return bRet; | 334 return bRet; |
| 335 } | 335 } |
| 336 | 336 |
| 337 #ifdef PDF_ENABLE_XFA | 337 #ifdef PDF_ENABLE_XFA |
| 338 FX_BOOL CPDFSDK_PageView::OnRButtonDown(const CFX_FloatPoint& point, | 338 FX_BOOL CPDFSDK_PageView::OnRButtonDown(const CFX_FloatPoint& point, |
| 339 FX_UINT nFlag) { | 339 uint32_t nFlag) { |
| 340 CPDFSDK_Environment* pEnv = m_pSDKDoc->GetEnv(); | 340 CPDFSDK_Environment* pEnv = m_pSDKDoc->GetEnv(); |
| 341 ASSERT(pEnv); | 341 ASSERT(pEnv); |
| 342 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); | 342 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); |
| 343 ASSERT(pAnnotHandlerMgr); | 343 ASSERT(pAnnotHandlerMgr); |
| 344 | 344 |
| 345 CPDFSDK_Annot* pFXAnnot = GetFXWidgetAtPoint(point.x, point.y); | 345 CPDFSDK_Annot* pFXAnnot = GetFXWidgetAtPoint(point.x, point.y); |
| 346 | 346 |
| 347 if (!pFXAnnot) | 347 if (!pFXAnnot) |
| 348 return FALSE; | 348 return FALSE; |
| 349 | 349 |
| 350 if (pAnnotHandlerMgr->Annot_OnRButtonDown(this, pFXAnnot, nFlag, point)) | 350 if (pAnnotHandlerMgr->Annot_OnRButtonDown(this, pFXAnnot, nFlag, point)) |
| 351 SetFocusAnnot(pFXAnnot); | 351 SetFocusAnnot(pFXAnnot); |
| 352 | 352 |
| 353 return TRUE; | 353 return TRUE; |
| 354 } | 354 } |
| 355 | 355 |
| 356 FX_BOOL CPDFSDK_PageView::OnRButtonUp(const CFX_FloatPoint& point, | 356 FX_BOOL CPDFSDK_PageView::OnRButtonUp(const CFX_FloatPoint& point, |
| 357 FX_UINT nFlag) { | 357 uint32_t nFlag) { |
| 358 CPDFSDK_Environment* pEnv = m_pSDKDoc->GetEnv(); | 358 CPDFSDK_Environment* pEnv = m_pSDKDoc->GetEnv(); |
| 359 ASSERT(pEnv); | 359 ASSERT(pEnv); |
| 360 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); | 360 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); |
| 361 | 361 |
| 362 CPDFSDK_Annot* pFXAnnot = GetFXWidgetAtPoint(point.x, point.y); | 362 CPDFSDK_Annot* pFXAnnot = GetFXWidgetAtPoint(point.x, point.y); |
| 363 | 363 |
| 364 if (!pFXAnnot) | 364 if (!pFXAnnot) |
| 365 return FALSE; | 365 return FALSE; |
| 366 | 366 |
| 367 if (pAnnotHandlerMgr->Annot_OnRButtonUp(this, pFXAnnot, nFlag, point)) | 367 if (pAnnotHandlerMgr->Annot_OnRButtonUp(this, pFXAnnot, nFlag, point)) |
| 368 SetFocusAnnot(pFXAnnot); | 368 SetFocusAnnot(pFXAnnot); |
| 369 | 369 |
| 370 return TRUE; | 370 return TRUE; |
| 371 } | 371 } |
| 372 #endif // PDF_ENABLE_XFA | 372 #endif // PDF_ENABLE_XFA |
| 373 | 373 |
| 374 FX_BOOL CPDFSDK_PageView::OnLButtonUp(const CFX_FloatPoint& point, | 374 FX_BOOL CPDFSDK_PageView::OnLButtonUp(const CFX_FloatPoint& point, |
| 375 FX_UINT nFlag) { | 375 uint32_t nFlag) { |
| 376 CPDFSDK_Environment* pEnv = m_pSDKDoc->GetEnv(); | 376 CPDFSDK_Environment* pEnv = m_pSDKDoc->GetEnv(); |
| 377 ASSERT(pEnv); | 377 ASSERT(pEnv); |
| 378 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); | 378 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); |
| 379 CPDFSDK_Annot* pFXAnnot = GetFXWidgetAtPoint(point.x, point.y); | 379 CPDFSDK_Annot* pFXAnnot = GetFXWidgetAtPoint(point.x, point.y); |
| 380 CPDFSDK_Annot* pFocusAnnot = GetFocusAnnot(); | 380 CPDFSDK_Annot* pFocusAnnot = GetFocusAnnot(); |
| 381 FX_BOOL bRet = FALSE; | 381 FX_BOOL bRet = FALSE; |
| 382 if (pFocusAnnot && pFocusAnnot != pFXAnnot) { | 382 if (pFocusAnnot && pFocusAnnot != pFXAnnot) { |
| 383 // Last focus Annot gets a chance to handle the event. | 383 // Last focus Annot gets a chance to handle the event. |
| 384 bRet = pAnnotHandlerMgr->Annot_OnLButtonUp(this, pFocusAnnot, nFlag, point); | 384 bRet = pAnnotHandlerMgr->Annot_OnLButtonUp(this, pFocusAnnot, nFlag, point); |
| 385 } | 385 } |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 int nFlag) { | 425 int nFlag) { |
| 426 if (CPDFSDK_Annot* pAnnot = GetFXWidgetAtPoint(point.x, point.y)) { | 426 if (CPDFSDK_Annot* pAnnot = GetFXWidgetAtPoint(point.x, point.y)) { |
| 427 CPDFSDK_Environment* pEnv = m_pSDKDoc->GetEnv(); | 427 CPDFSDK_Environment* pEnv = m_pSDKDoc->GetEnv(); |
| 428 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); | 428 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); |
| 429 return pAnnotHandlerMgr->Annot_OnMouseWheel(this, pAnnot, nFlag, | 429 return pAnnotHandlerMgr->Annot_OnMouseWheel(this, pAnnot, nFlag, |
| 430 (int)deltaY, point); | 430 (int)deltaY, point); |
| 431 } | 431 } |
| 432 return FALSE; | 432 return FALSE; |
| 433 } | 433 } |
| 434 | 434 |
| 435 FX_BOOL CPDFSDK_PageView::OnChar(int nChar, FX_UINT nFlag) { | 435 FX_BOOL CPDFSDK_PageView::OnChar(int nChar, uint32_t nFlag) { |
| 436 if (CPDFSDK_Annot* pAnnot = GetFocusAnnot()) { | 436 if (CPDFSDK_Annot* pAnnot = GetFocusAnnot()) { |
| 437 CPDFSDK_Environment* pEnv = m_pSDKDoc->GetEnv(); | 437 CPDFSDK_Environment* pEnv = m_pSDKDoc->GetEnv(); |
| 438 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); | 438 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); |
| 439 return pAnnotHandlerMgr->Annot_OnChar(pAnnot, nChar, nFlag); | 439 return pAnnotHandlerMgr->Annot_OnChar(pAnnot, nChar, nFlag); |
| 440 } | 440 } |
| 441 | 441 |
| 442 return FALSE; | 442 return FALSE; |
| 443 } | 443 } |
| 444 | 444 |
| 445 FX_BOOL CPDFSDK_PageView::OnKeyDown(int nKeyCode, int nFlag) { | 445 FX_BOOL CPDFSDK_PageView::OnKeyDown(int nKeyCode, int nFlag) { |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 return pAnnot; | 578 return pAnnot; |
| 579 } | 579 } |
| 580 return nullptr; | 580 return nullptr; |
| 581 } | 581 } |
| 582 | 582 |
| 583 int CPDFSDK_PageView::GetPageIndexForStaticPDF() const { | 583 int CPDFSDK_PageView::GetPageIndexForStaticPDF() const { |
| 584 CPDF_Dictionary* pDict = GetPDFPage()->m_pFormDict; | 584 CPDF_Dictionary* pDict = GetPDFPage()->m_pFormDict; |
| 585 CPDF_Document* pDoc = m_pSDKDoc->GetPDFDocument(); | 585 CPDF_Document* pDoc = m_pSDKDoc->GetPDFDocument(); |
| 586 return (pDoc && pDict) ? pDoc->GetPageIndex(pDict->GetObjNum()) : -1; | 586 return (pDoc && pDict) ? pDoc->GetPageIndex(pDict->GetObjNum()) : -1; |
| 587 } | 587 } |
| OLD | NEW |