| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 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/formfiller/FFL_CBA_Fontmap.h" | 7 #include "fpdfsdk/include/formfiller/FFL_CBA_Fontmap.h" |
| 8 #include "fpdfsdk/include/formfiller/FFL_FormFiller.h" | 8 #include "fpdfsdk/include/formfiller/FFL_FormFiller.h" |
| 9 | 9 |
| 10 #define GetRed(rgb) ((uint8_t)(rgb)) | 10 #define GetRed(rgb) ((uint8_t)(rgb)) |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 CPDF_Rect CFFL_FormFiller::GetWindowRect(CPDFSDK_PageView* pPageView) { | 42 CPDF_Rect CFFL_FormFiller::GetWindowRect(CPDFSDK_PageView* pPageView) { |
| 43 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) { | 43 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) { |
| 44 return pWnd->GetWindowRect(); | 44 return pWnd->GetWindowRect(); |
| 45 } | 45 } |
| 46 | 46 |
| 47 return CPDF_Rect(0, 0, 0, 0); | 47 return CPDF_Rect(0, 0, 0, 0); |
| 48 } | 48 } |
| 49 | 49 |
| 50 FX_RECT CFFL_FormFiller::GetViewBBox(CPDFSDK_PageView* pPageView, | 50 FX_RECT CFFL_FormFiller::GetViewBBox(CPDFSDK_PageView* pPageView, |
| 51 CPDFSDK_Annot* pAnnot) { | 51 CPDFSDK_Annot* pAnnot) { |
| 52 ASSERT(pPageView != NULL); | 52 ASSERT(pPageView); |
| 53 ASSERT(pAnnot != NULL); | 53 ASSERT(pAnnot); |
| 54 | 54 |
| 55 CPDF_Rect rcAnnot = m_pWidget->GetRect(); | 55 CPDF_Rect rcAnnot = m_pWidget->GetRect(); |
| 56 | 56 |
| 57 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) { | 57 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) { |
| 58 CPDF_Rect rcWindow = pWnd->GetWindowRect(); | 58 CPDF_Rect rcWindow = pWnd->GetWindowRect(); |
| 59 rcAnnot = PWLtoFFL(rcWindow); | 59 rcAnnot = PWLtoFFL(rcWindow); |
| 60 } | 60 } |
| 61 | 61 |
| 62 CPDF_Rect rcWin = rcAnnot; | 62 CPDF_Rect rcWin = rcAnnot; |
| 63 | 63 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 void CFFL_FormFiller::OnLoad(CPDFSDK_Annot* pAnnot) {} | 102 void CFFL_FormFiller::OnLoad(CPDFSDK_Annot* pAnnot) {} |
| 103 | 103 |
| 104 void CFFL_FormFiller::OnDelete(CPDFSDK_Annot* pAnnot) {} | 104 void CFFL_FormFiller::OnDelete(CPDFSDK_Annot* pAnnot) {} |
| 105 | 105 |
| 106 void CFFL_FormFiller::OnMouseEnter(CPDFSDK_PageView* pPageView, | 106 void CFFL_FormFiller::OnMouseEnter(CPDFSDK_PageView* pPageView, |
| 107 CPDFSDK_Annot* pAnnot) {} | 107 CPDFSDK_Annot* pAnnot) {} |
| 108 | 108 |
| 109 void CFFL_FormFiller::OnMouseExit(CPDFSDK_PageView* pPageView, | 109 void CFFL_FormFiller::OnMouseExit(CPDFSDK_PageView* pPageView, |
| 110 CPDFSDK_Annot* pAnnot) { | 110 CPDFSDK_Annot* pAnnot) { |
| 111 EndTimer(); | 111 EndTimer(); |
| 112 ASSERT(m_pWidget != NULL); | 112 ASSERT(m_pWidget); |
| 113 } | 113 } |
| 114 | 114 |
| 115 FX_BOOL CFFL_FormFiller::OnLButtonDown(CPDFSDK_PageView* pPageView, | 115 FX_BOOL CFFL_FormFiller::OnLButtonDown(CPDFSDK_PageView* pPageView, |
| 116 CPDFSDK_Annot* pAnnot, | 116 CPDFSDK_Annot* pAnnot, |
| 117 FX_UINT nFlags, | 117 FX_UINT nFlags, |
| 118 const CPDF_Point& point) { | 118 const CPDF_Point& point) { |
| 119 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, TRUE)) { | 119 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, TRUE)) { |
| 120 m_bValid = TRUE; | 120 m_bValid = TRUE; |
| 121 FX_RECT rect = GetViewBBox(pPageView, pAnnot); | 121 FX_RECT rect = GetViewBBox(pPageView, pAnnot); |
| 122 InvalidateRect(rect.left, rect.top, rect.right, rect.bottom); | 122 InvalidateRect(rect.left, rect.top, rect.right, rect.bottom); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 } | 209 } |
| 210 | 210 |
| 211 return FALSE; | 211 return FALSE; |
| 212 } | 212 } |
| 213 | 213 |
| 214 FX_BOOL CFFL_FormFiller::OnKeyDown(CPDFSDK_Annot* pAnnot, | 214 FX_BOOL CFFL_FormFiller::OnKeyDown(CPDFSDK_Annot* pAnnot, |
| 215 FX_UINT nKeyCode, | 215 FX_UINT nKeyCode, |
| 216 FX_UINT nFlags) { | 216 FX_UINT nFlags) { |
| 217 if (IsValid()) { | 217 if (IsValid()) { |
| 218 CPDFSDK_PageView* pPageView = GetCurPageView(); | 218 CPDFSDK_PageView* pPageView = GetCurPageView(); |
| 219 ASSERT(pPageView != NULL); | 219 ASSERT(pPageView); |
| 220 | 220 |
| 221 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) { | 221 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) { |
| 222 return pWnd->OnKeyDown(nKeyCode, nFlags); | 222 return pWnd->OnKeyDown(nKeyCode, nFlags); |
| 223 } | 223 } |
| 224 } | 224 } |
| 225 | 225 |
| 226 return FALSE; | 226 return FALSE; |
| 227 } | 227 } |
| 228 | 228 |
| 229 FX_BOOL CFFL_FormFiller::OnChar(CPDFSDK_Annot* pAnnot, | 229 FX_BOOL CFFL_FormFiller::OnChar(CPDFSDK_Annot* pAnnot, |
| 230 FX_UINT nChar, | 230 FX_UINT nChar, |
| 231 FX_UINT nFlags) { | 231 FX_UINT nFlags) { |
| 232 if (IsValid()) { | 232 if (IsValid()) { |
| 233 CPDFSDK_PageView* pPageView = GetCurPageView(); | 233 CPDFSDK_PageView* pPageView = GetCurPageView(); |
| 234 ASSERT(pPageView != NULL); | 234 ASSERT(pPageView); |
| 235 | 235 |
| 236 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) { | 236 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) { |
| 237 return pWnd->OnChar(nChar, nFlags); | 237 return pWnd->OnChar(nChar, nFlags); |
| 238 } | 238 } |
| 239 } | 239 } |
| 240 | 240 |
| 241 return FALSE; | 241 return FALSE; |
| 242 } | 242 } |
| 243 | 243 |
| 244 void CFFL_FormFiller::SetFocusForAnnot(CPDFSDK_Annot* pAnnot, FX_UINT nFlag) { | 244 void CFFL_FormFiller::SetFocusForAnnot(CPDFSDK_Annot* pAnnot, FX_UINT nFlag) { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 bDestroyPDFWindow = FALSE; | 277 bDestroyPDFWindow = FALSE; |
| 278 } | 278 } |
| 279 EscapeFiller(pPageView, bDestroyPDFWindow); | 279 EscapeFiller(pPageView, bDestroyPDFWindow); |
| 280 } | 280 } |
| 281 | 281 |
| 282 FX_BOOL CFFL_FormFiller::IsValid() const { | 282 FX_BOOL CFFL_FormFiller::IsValid() const { |
| 283 return m_bValid; | 283 return m_bValid; |
| 284 } | 284 } |
| 285 | 285 |
| 286 PWL_CREATEPARAM CFFL_FormFiller::GetCreateParam() { | 286 PWL_CREATEPARAM CFFL_FormFiller::GetCreateParam() { |
| 287 ASSERT(m_pApp != NULL); | 287 ASSERT(m_pApp); |
| 288 | 288 |
| 289 PWL_CREATEPARAM cp; | 289 PWL_CREATEPARAM cp; |
| 290 cp.pParentWnd = NULL; | 290 cp.pParentWnd = NULL; |
| 291 cp.pProvider = this; | 291 cp.pProvider = this; |
| 292 cp.rcRectWnd = GetPDFWindowRect(); | 292 cp.rcRectWnd = GetPDFWindowRect(); |
| 293 | 293 |
| 294 FX_DWORD dwCreateFlags = PWS_BORDER | PWS_BACKGROUND | PWS_VISIBLE; | 294 FX_DWORD dwCreateFlags = PWS_BORDER | PWS_BACKGROUND | PWS_VISIBLE; |
| 295 FX_DWORD dwFieldFlag = m_pWidget->GetFieldFlags(); | 295 FX_DWORD dwFieldFlag = m_pWidget->GetFieldFlags(); |
| 296 if (dwFieldFlag & FIELDFLAG_READONLY) { | 296 if (dwFieldFlag & FIELDFLAG_READONLY) { |
| 297 dwCreateFlags |= PWS_READONLY; | 297 dwCreateFlags |= PWS_READONLY; |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 | 408 |
| 409 return mt; | 409 return mt; |
| 410 } | 410 } |
| 411 } | 411 } |
| 412 return CFX_Matrix(1, 0, 0, 1, 0, 0); | 412 return CFX_Matrix(1, 0, 0, 1, 0, 0); |
| 413 } | 413 } |
| 414 | 414 |
| 415 CFX_Matrix CFFL_FormFiller::GetCurMatrix() { | 415 CFX_Matrix CFFL_FormFiller::GetCurMatrix() { |
| 416 CFX_Matrix mt; | 416 CFX_Matrix mt; |
| 417 | 417 |
| 418 ASSERT(m_pWidget != NULL); | |
| 419 | |
| 420 CPDF_Rect rcDA; | 418 CPDF_Rect rcDA; |
| 421 m_pWidget->GetPDFAnnot()->GetRect(rcDA); | 419 m_pWidget->GetPDFAnnot()->GetRect(rcDA); |
| 422 | 420 |
| 423 switch (m_pWidget->GetRotate()) { | 421 switch (m_pWidget->GetRotate()) { |
| 424 default: | 422 default: |
| 425 case 0: | 423 case 0: |
| 426 mt = CFX_Matrix(1, 0, 0, 1, 0, 0); | 424 mt = CFX_Matrix(1, 0, 0, 1, 0, 0); |
| 427 break; | 425 break; |
| 428 case 90: | 426 case 90: |
| 429 mt = CFX_Matrix(0, 1, -1, 0, rcDA.right - rcDA.left, 0); | 427 mt = CFX_Matrix(0, 1, -1, 0, rcDA.right - rcDA.left, 0); |
| 430 break; | 428 break; |
| 431 case 180: | 429 case 180: |
| 432 mt = CFX_Matrix(-1, 0, 0, -1, rcDA.right - rcDA.left, | 430 mt = CFX_Matrix(-1, 0, 0, -1, rcDA.right - rcDA.left, |
| 433 rcDA.top - rcDA.bottom); | 431 rcDA.top - rcDA.bottom); |
| 434 break; | 432 break; |
| 435 case 270: | 433 case 270: |
| 436 mt = CFX_Matrix(0, -1, 1, 0, 0, rcDA.top - rcDA.bottom); | 434 mt = CFX_Matrix(0, -1, 1, 0, 0, rcDA.top - rcDA.bottom); |
| 437 break; | 435 break; |
| 438 } | 436 } |
| 439 mt.e += rcDA.left; | 437 mt.e += rcDA.left; |
| 440 mt.f += rcDA.bottom; | 438 mt.f += rcDA.bottom; |
| 441 | 439 |
| 442 return mt; | 440 return mt; |
| 443 } | 441 } |
| 444 | 442 |
| 445 CFX_WideString CFFL_FormFiller::LoadPopupMenuString(int nIndex) { | 443 CFX_WideString CFFL_FormFiller::LoadPopupMenuString(int nIndex) { |
| 446 ASSERT(m_pApp != NULL); | 444 ASSERT(m_pApp); |
| 447 | 445 |
| 448 return L""; | 446 return L""; |
| 449 } | 447 } |
| 450 | 448 |
| 451 CPDF_Rect CFFL_FormFiller::GetPDFWindowRect() const { | 449 CPDF_Rect CFFL_FormFiller::GetPDFWindowRect() const { |
| 452 CPDF_Rect rectAnnot; | 450 CPDF_Rect rectAnnot; |
| 453 m_pWidget->GetPDFAnnot()->GetRect(rectAnnot); | 451 m_pWidget->GetPDFAnnot()->GetRect(rectAnnot); |
| 454 | 452 |
| 455 FX_FLOAT fWidth = rectAnnot.right - rectAnnot.left; | 453 FX_FLOAT fWidth = rectAnnot.right - rectAnnot.left; |
| 456 FX_FLOAT fHeight = rectAnnot.top - rectAnnot.bottom; | 454 FX_FLOAT fHeight = rectAnnot.top - rectAnnot.bottom; |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 636 InvalidateRect(rect.left, rect.top, rect.right, rect.bottom); | 634 InvalidateRect(rect.left, rect.top, rect.right, rect.bottom); |
| 637 } | 635 } |
| 638 | 636 |
| 639 void CFFL_Button::OnMouseExit(CPDFSDK_PageView* pPageView, | 637 void CFFL_Button::OnMouseExit(CPDFSDK_PageView* pPageView, |
| 640 CPDFSDK_Annot* pAnnot) { | 638 CPDFSDK_Annot* pAnnot) { |
| 641 m_bMouseIn = FALSE; | 639 m_bMouseIn = FALSE; |
| 642 | 640 |
| 643 FX_RECT rect = GetViewBBox(pPageView, pAnnot); | 641 FX_RECT rect = GetViewBBox(pPageView, pAnnot); |
| 644 InvalidateRect(rect.left, rect.top, rect.right, rect.bottom); | 642 InvalidateRect(rect.left, rect.top, rect.right, rect.bottom); |
| 645 EndTimer(); | 643 EndTimer(); |
| 646 ASSERT(m_pWidget != NULL); | 644 ASSERT(m_pWidget); |
| 647 } | 645 } |
| 648 | 646 |
| 649 FX_BOOL CFFL_Button::OnLButtonDown(CPDFSDK_PageView* pPageView, | 647 FX_BOOL CFFL_Button::OnLButtonDown(CPDFSDK_PageView* pPageView, |
| 650 CPDFSDK_Annot* pAnnot, | 648 CPDFSDK_Annot* pAnnot, |
| 651 FX_UINT nFlags, | 649 FX_UINT nFlags, |
| 652 const CPDF_Point& point) { | 650 const CPDF_Point& point) { |
| 653 CPDF_Rect rcAnnot = pAnnot->GetRect(); | 651 CPDF_Rect rcAnnot = pAnnot->GetRect(); |
| 654 if (!rcAnnot.Contains(point.x, point.y)) | 652 if (!rcAnnot.Contains(point.x, point.y)) |
| 655 return FALSE; | 653 return FALSE; |
| 656 | 654 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 674 | 672 |
| 675 FX_RECT rect = GetViewBBox(pPageView, pAnnot); | 673 FX_RECT rect = GetViewBBox(pPageView, pAnnot); |
| 676 InvalidateRect(rect.left, rect.top, rect.right, rect.bottom); | 674 InvalidateRect(rect.left, rect.top, rect.right, rect.bottom); |
| 677 return TRUE; | 675 return TRUE; |
| 678 } | 676 } |
| 679 | 677 |
| 680 FX_BOOL CFFL_Button::OnMouseMove(CPDFSDK_PageView* pPageView, | 678 FX_BOOL CFFL_Button::OnMouseMove(CPDFSDK_PageView* pPageView, |
| 681 CPDFSDK_Annot* pAnnot, | 679 CPDFSDK_Annot* pAnnot, |
| 682 FX_UINT nFlags, | 680 FX_UINT nFlags, |
| 683 const CPDF_Point& point) { | 681 const CPDF_Point& point) { |
| 684 ASSERT(m_pApp != NULL); | 682 ASSERT(m_pApp); |
| 685 | 683 |
| 686 return TRUE; | 684 return TRUE; |
| 687 } | 685 } |
| 688 | 686 |
| 689 void CFFL_Button::OnDraw(CPDFSDK_PageView* pPageView, | 687 void CFFL_Button::OnDraw(CPDFSDK_PageView* pPageView, |
| 690 CPDFSDK_Annot* pAnnot, | 688 CPDFSDK_Annot* pAnnot, |
| 691 CFX_RenderDevice* pDevice, | 689 CFX_RenderDevice* pDevice, |
| 692 CFX_Matrix* pUser2Device, | 690 CFX_Matrix* pUser2Device, |
| 693 FX_DWORD dwFlags) { | 691 FX_DWORD dwFlags) { |
| 694 ASSERT(pPageView != NULL); | 692 ASSERT(pPageView); |
| 695 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; | 693 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; |
| 696 CPDF_FormControl* pCtrl = pWidget->GetFormControl(); | 694 CPDF_FormControl* pCtrl = pWidget->GetFormControl(); |
| 697 CPDF_FormControl::HighlightingMode eHM = pCtrl->GetHighlightingMode(); | 695 CPDF_FormControl::HighlightingMode eHM = pCtrl->GetHighlightingMode(); |
| 698 | 696 |
| 699 if (eHM == CPDF_FormControl::Push) { | 697 if (eHM == CPDF_FormControl::Push) { |
| 700 if (m_bMouseDown) { | 698 if (m_bMouseDown) { |
| 701 if (pWidget->IsWidgetAppearanceValid(CPDF_Annot::Down)) | 699 if (pWidget->IsWidgetAppearanceValid(CPDF_Annot::Down)) |
| 702 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Down, NULL); | 700 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Down, NULL); |
| 703 else | 701 else |
| 704 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, | 702 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 717 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL); | 715 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL); |
| 718 } | 716 } |
| 719 | 717 |
| 720 void CFFL_Button::OnDrawDeactive(CPDFSDK_PageView* pPageView, | 718 void CFFL_Button::OnDrawDeactive(CPDFSDK_PageView* pPageView, |
| 721 CPDFSDK_Annot* pAnnot, | 719 CPDFSDK_Annot* pAnnot, |
| 722 CFX_RenderDevice* pDevice, | 720 CFX_RenderDevice* pDevice, |
| 723 CFX_Matrix* pUser2Device, | 721 CFX_Matrix* pUser2Device, |
| 724 FX_DWORD dwFlags) { | 722 FX_DWORD dwFlags) { |
| 725 OnDraw(pPageView, pAnnot, pDevice, pUser2Device, dwFlags); | 723 OnDraw(pPageView, pAnnot, pDevice, pUser2Device, dwFlags); |
| 726 } | 724 } |
| OLD | NEW |