Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(17)

Side by Side Diff: fpdfsdk/src/formfiller/FFL_FormFiller.cpp

Issue 1512763013: Get rid of most instance of 'foo != NULL' (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: nits Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « fpdfsdk/src/formfiller/FFL_ComboBox.cpp ('k') | fpdfsdk/src/formfiller/FFL_IFormFiller.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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
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
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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 InvalidateRect(rect.left, rect.top, rect.right, rect.bottom); 628 InvalidateRect(rect.left, rect.top, rect.right, rect.bottom);
631 } 629 }
632 630
633 void CFFL_Button::OnMouseExit(CPDFSDK_PageView* pPageView, 631 void CFFL_Button::OnMouseExit(CPDFSDK_PageView* pPageView,
634 CPDFSDK_Annot* pAnnot) { 632 CPDFSDK_Annot* pAnnot) {
635 m_bMouseIn = FALSE; 633 m_bMouseIn = FALSE;
636 634
637 FX_RECT rect = GetViewBBox(pPageView, pAnnot); 635 FX_RECT rect = GetViewBBox(pPageView, pAnnot);
638 InvalidateRect(rect.left, rect.top, rect.right, rect.bottom); 636 InvalidateRect(rect.left, rect.top, rect.right, rect.bottom);
639 EndTimer(); 637 EndTimer();
640 ASSERT(m_pWidget != NULL); 638 ASSERT(m_pWidget);
641 } 639 }
642 640
643 FX_BOOL CFFL_Button::OnLButtonDown(CPDFSDK_PageView* pPageView, 641 FX_BOOL CFFL_Button::OnLButtonDown(CPDFSDK_PageView* pPageView,
644 CPDFSDK_Annot* pAnnot, 642 CPDFSDK_Annot* pAnnot,
645 FX_UINT nFlags, 643 FX_UINT nFlags,
646 const CPDF_Point& point) { 644 const CPDF_Point& point) {
647 CPDF_Rect rcAnnot = pAnnot->GetRect(); 645 CPDF_Rect rcAnnot = pAnnot->GetRect();
648 if (!rcAnnot.Contains(point.x, point.y)) 646 if (!rcAnnot.Contains(point.x, point.y))
649 return FALSE; 647 return FALSE;
650 648
(...skipping 17 matching lines...) Expand all
668 666
669 FX_RECT rect = GetViewBBox(pPageView, pAnnot); 667 FX_RECT rect = GetViewBBox(pPageView, pAnnot);
670 InvalidateRect(rect.left, rect.top, rect.right, rect.bottom); 668 InvalidateRect(rect.left, rect.top, rect.right, rect.bottom);
671 return TRUE; 669 return TRUE;
672 } 670 }
673 671
674 FX_BOOL CFFL_Button::OnMouseMove(CPDFSDK_PageView* pPageView, 672 FX_BOOL CFFL_Button::OnMouseMove(CPDFSDK_PageView* pPageView,
675 CPDFSDK_Annot* pAnnot, 673 CPDFSDK_Annot* pAnnot,
676 FX_UINT nFlags, 674 FX_UINT nFlags,
677 const CPDF_Point& point) { 675 const CPDF_Point& point) {
678 ASSERT(m_pApp != NULL); 676 ASSERT(m_pApp);
679 677
680 return TRUE; 678 return TRUE;
681 } 679 }
682 680
683 void CFFL_Button::OnDraw(CPDFSDK_PageView* pPageView, 681 void CFFL_Button::OnDraw(CPDFSDK_PageView* pPageView,
684 CPDFSDK_Annot* pAnnot, 682 CPDFSDK_Annot* pAnnot,
685 CFX_RenderDevice* pDevice, 683 CFX_RenderDevice* pDevice,
686 CFX_Matrix* pUser2Device, 684 CFX_Matrix* pUser2Device,
687 FX_DWORD dwFlags) { 685 FX_DWORD dwFlags) {
688 ASSERT(pPageView != NULL); 686 ASSERT(pPageView);
689 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; 687 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
690 CPDF_FormControl* pCtrl = pWidget->GetFormControl(); 688 CPDF_FormControl* pCtrl = pWidget->GetFormControl();
691 CPDF_FormControl::HighlightingMode eHM = pCtrl->GetHighlightingMode(); 689 CPDF_FormControl::HighlightingMode eHM = pCtrl->GetHighlightingMode();
692 690
693 if (eHM == CPDF_FormControl::Push) { 691 if (eHM == CPDF_FormControl::Push) {
694 if (m_bMouseDown) { 692 if (m_bMouseDown) {
695 if (pWidget->IsWidgetAppearanceValid(CPDF_Annot::Down)) 693 if (pWidget->IsWidgetAppearanceValid(CPDF_Annot::Down))
696 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Down, NULL); 694 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Down, NULL);
697 else 695 else
698 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, 696 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal,
(...skipping 12 matching lines...) Expand all
711 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL); 709 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL);
712 } 710 }
713 711
714 void CFFL_Button::OnDrawDeactive(CPDFSDK_PageView* pPageView, 712 void CFFL_Button::OnDrawDeactive(CPDFSDK_PageView* pPageView,
715 CPDFSDK_Annot* pAnnot, 713 CPDFSDK_Annot* pAnnot,
716 CFX_RenderDevice* pDevice, 714 CFX_RenderDevice* pDevice,
717 CFX_Matrix* pUser2Device, 715 CFX_Matrix* pUser2Device,
718 FX_DWORD dwFlags) { 716 FX_DWORD dwFlags) {
719 OnDraw(pPageView, pAnnot, pDevice, pUser2Device, dwFlags); 717 OnDraw(pPageView, pAnnot, pDevice, pUser2Device, dwFlags);
720 } 718 }
OLDNEW
« no previous file with comments | « fpdfsdk/src/formfiller/FFL_ComboBox.cpp ('k') | fpdfsdk/src/formfiller/FFL_IFormFiller.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698