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

Side by Side Diff: fpdfsdk/fsdk_annothandler.cpp

Issue 2031653003: Get rid of NULLs in fpdfsdk/ (Closed) Base URL: https://pdfium.googlesource.com/pdfium@nullptr_core
Patch Set: rebase Created 4 years, 6 months 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/fsdk_actionhandler.cpp ('k') | fpdfsdk/fsdk_baseannot.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/fsdk_annothandler.h" 7 #include "fpdfsdk/include/fsdk_annothandler.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <vector> 10 #include <vector>
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 CPDFSDK_Annot* CPDFSDK_AnnotHandlerMgr::NewAnnot(CXFA_FFWidget* pAnnot, 81 CPDFSDK_Annot* CPDFSDK_AnnotHandlerMgr::NewAnnot(CXFA_FFWidget* pAnnot,
82 CPDFSDK_PageView* pPageView) { 82 CPDFSDK_PageView* pPageView) {
83 ASSERT(pAnnot); 83 ASSERT(pAnnot);
84 ASSERT(pPageView); 84 ASSERT(pPageView);
85 85
86 if (IPDFSDK_AnnotHandler* pAnnotHandler = 86 if (IPDFSDK_AnnotHandler* pAnnotHandler =
87 GetAnnotHandler(FSDK_XFAWIDGET_TYPENAME)) { 87 GetAnnotHandler(FSDK_XFAWIDGET_TYPENAME)) {
88 return pAnnotHandler->NewAnnot(pAnnot, pPageView); 88 return pAnnotHandler->NewAnnot(pAnnot, pPageView);
89 } 89 }
90 90
91 return NULL; 91 return nullptr;
92 } 92 }
93 #endif // PDF_ENABLE_XFA 93 #endif // PDF_ENABLE_XFA
94 94
95 void CPDFSDK_AnnotHandlerMgr::ReleaseAnnot(CPDFSDK_Annot* pAnnot) { 95 void CPDFSDK_AnnotHandlerMgr::ReleaseAnnot(CPDFSDK_Annot* pAnnot) {
96 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) { 96 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) {
97 pAnnotHandler->OnRelease(pAnnot); 97 pAnnotHandler->OnRelease(pAnnot);
98 pAnnotHandler->ReleaseAnnot(pAnnot); 98 pAnnotHandler->ReleaseAnnot(pAnnot);
99 } else { 99 } else {
100 delete (CPDFSDK_Annot*)pAnnot; 100 delete (CPDFSDK_Annot*)pAnnot;
101 } 101 }
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 return pAnnotHandler->HitTest(pPageView, pAnnot, point); 360 return pAnnotHandler->HitTest(pPageView, pAnnot, point);
361 } 361 }
362 return FALSE; 362 return FALSE;
363 } 363 }
364 364
365 CPDFSDK_Annot* CPDFSDK_AnnotHandlerMgr::GetNextAnnot(CPDFSDK_Annot* pSDKAnnot, 365 CPDFSDK_Annot* CPDFSDK_AnnotHandlerMgr::GetNextAnnot(CPDFSDK_Annot* pSDKAnnot,
366 FX_BOOL bNext) { 366 FX_BOOL bNext) {
367 #ifdef PDF_ENABLE_XFA 367 #ifdef PDF_ENABLE_XFA
368 CPDFSDK_PageView* pPageView = pSDKAnnot->GetPageView(); 368 CPDFSDK_PageView* pPageView = pSDKAnnot->GetPageView();
369 CPDFXFA_Page* pPage = pPageView->GetPDFXFAPage(); 369 CPDFXFA_Page* pPage = pPageView->GetPDFXFAPage();
370 if (pPage == NULL) 370 if (!pPage)
371 return NULL; 371 return nullptr;
372 if (pPage->GetPDFPage()) { // for pdf annots. 372 if (pPage->GetPDFPage()) { // for pdf annots.
373 CBA_AnnotIterator ai(pSDKAnnot->GetPageView(), pSDKAnnot->GetType(), ""); 373 CBA_AnnotIterator ai(pSDKAnnot->GetPageView(), pSDKAnnot->GetType(), "");
374 CPDFSDK_Annot* pNext = 374 CPDFSDK_Annot* pNext =
375 bNext ? ai.GetNextAnnot(pSDKAnnot) : ai.GetPrevAnnot(pSDKAnnot); 375 bNext ? ai.GetNextAnnot(pSDKAnnot) : ai.GetPrevAnnot(pSDKAnnot);
376 return pNext; 376 return pNext;
377 } 377 }
378 // for xfa annots 378 // for xfa annots
379 std::unique_ptr<IXFA_WidgetIterator> pWidgetIterator( 379 std::unique_ptr<IXFA_WidgetIterator> pWidgetIterator(
380 pPage->GetXFAPageView()->CreateWidgetIterator( 380 pPage->GetXFAPageView()->CreateWidgetIterator(
381 XFA_TRAVERSEWAY_Tranvalse, XFA_WidgetStatus_Visible | 381 XFA_TRAVERSEWAY_Tranvalse, XFA_WidgetStatus_Visible |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm(); 434 CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm();
435 if (pPDFInterForm && pPDFInterForm->NeedConstructAP()) 435 if (pPDFInterForm && pPDFInterForm->NeedConstructAP())
436 pWidget->ResetAppearance(nullptr, FALSE); 436 pWidget->ResetAppearance(nullptr, FALSE);
437 437
438 return pWidget; 438 return pWidget;
439 } 439 }
440 440
441 #ifdef PDF_ENABLE_XFA 441 #ifdef PDF_ENABLE_XFA
442 CPDFSDK_Annot* CPDFSDK_BFAnnotHandler::NewAnnot(CXFA_FFWidget* hWidget, 442 CPDFSDK_Annot* CPDFSDK_BFAnnotHandler::NewAnnot(CXFA_FFWidget* hWidget,
443 CPDFSDK_PageView* pPage) { 443 CPDFSDK_PageView* pPage) {
444 return NULL; 444 return nullptr;
445 } 445 }
446 #endif // PDF_ENABLE_XFA 446 #endif // PDF_ENABLE_XFA
447 447
448 void CPDFSDK_BFAnnotHandler::ReleaseAnnot(CPDFSDK_Annot* pAnnot) { 448 void CPDFSDK_BFAnnotHandler::ReleaseAnnot(CPDFSDK_Annot* pAnnot) {
449 ASSERT(pAnnot); 449 ASSERT(pAnnot);
450 450
451 if (m_pFormFiller) 451 if (m_pFormFiller)
452 m_pFormFiller->OnDelete(pAnnot); 452 m_pFormFiller->OnDelete(pAnnot);
453 453
454 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; 454 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 m_pFormFiller->OnCreate(pAnnot); 646 m_pFormFiller->OnCreate(pAnnot);
647 } 647 }
648 } 648 }
649 649
650 void CPDFSDK_BFAnnotHandler::OnLoad(CPDFSDK_Annot* pAnnot) { 650 void CPDFSDK_BFAnnotHandler::OnLoad(CPDFSDK_Annot* pAnnot) {
651 if (pAnnot->GetSubType() == BFFT_SIGNATURE) 651 if (pAnnot->GetSubType() == BFFT_SIGNATURE)
652 return; 652 return;
653 653
654 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; 654 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
655 if (!pWidget->IsAppearanceValid()) 655 if (!pWidget->IsAppearanceValid())
656 pWidget->ResetAppearance(NULL, FALSE); 656 pWidget->ResetAppearance(nullptr, FALSE);
657 657
658 int nFieldType = pWidget->GetFieldType(); 658 int nFieldType = pWidget->GetFieldType();
659 if (nFieldType == FIELDTYPE_TEXTFIELD || nFieldType == FIELDTYPE_COMBOBOX) { 659 if (nFieldType == FIELDTYPE_TEXTFIELD || nFieldType == FIELDTYPE_COMBOBOX) {
660 FX_BOOL bFormated = FALSE; 660 FX_BOOL bFormated = FALSE;
661 CFX_WideString sValue = pWidget->OnFormat(bFormated); 661 CFX_WideString sValue = pWidget->OnFormat(bFormated);
662 if (bFormated && nFieldType == FIELDTYPE_COMBOBOX) { 662 if (bFormated && nFieldType == FIELDTYPE_COMBOBOX) {
663 pWidget->ResetAppearance(sValue.c_str(), FALSE); 663 pWidget->ResetAppearance(sValue.c_str(), FALSE);
664 } 664 }
665 } 665 }
666 666
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 CPDFSDK_Annot* CPDFSDK_XFAAnnotHandler::NewAnnot(CXFA_FFWidget* pAnnot, 729 CPDFSDK_Annot* CPDFSDK_XFAAnnotHandler::NewAnnot(CXFA_FFWidget* pAnnot,
730 CPDFSDK_PageView* pPage) { 730 CPDFSDK_PageView* pPage) {
731 CPDFSDK_Document* pSDKDoc = m_pApp->GetSDKDocument(); 731 CPDFSDK_Document* pSDKDoc = m_pApp->GetSDKDocument();
732 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pSDKDoc->GetInterForm(); 732 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pSDKDoc->GetInterForm();
733 CPDFSDK_XFAWidget* pWidget = new CPDFSDK_XFAWidget(pAnnot, pPage, pInterForm); 733 CPDFSDK_XFAWidget* pWidget = new CPDFSDK_XFAWidget(pAnnot, pPage, pInterForm);
734 pInterForm->AddXFAMap(pAnnot, pWidget); 734 pInterForm->AddXFAMap(pAnnot, pWidget);
735 return pWidget; 735 return pWidget;
736 } 736 }
737 737
738 FX_BOOL CPDFSDK_XFAAnnotHandler::CanAnswer(CPDFSDK_Annot* pAnnot) { 738 FX_BOOL CPDFSDK_XFAAnnotHandler::CanAnswer(CPDFSDK_Annot* pAnnot) {
739 return pAnnot->GetXFAWidget() != NULL; 739 return !!pAnnot->GetXFAWidget();
740 } 740 }
741 741
742 void CPDFSDK_XFAAnnotHandler::OnDraw(CPDFSDK_PageView* pPageView, 742 void CPDFSDK_XFAAnnotHandler::OnDraw(CPDFSDK_PageView* pPageView,
743 CPDFSDK_Annot* pAnnot, 743 CPDFSDK_Annot* pAnnot,
744 CFX_RenderDevice* pDevice, 744 CFX_RenderDevice* pDevice,
745 CFX_Matrix* pUser2Device, 745 CFX_Matrix* pUser2Device,
746 uint32_t dwFlags) { 746 uint32_t dwFlags) {
747 ASSERT(pPageView != NULL); 747 ASSERT(pPageView);
748 ASSERT(pAnnot != NULL); 748 ASSERT(pAnnot);
749 749
750 CPDFSDK_Document* pSDKDoc = pPageView->GetSDKDocument(); 750 CPDFSDK_Document* pSDKDoc = pPageView->GetSDKDocument();
751 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot); 751 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot);
752 752
753 CFX_Graphics gs; 753 CFX_Graphics gs;
754 gs.Create(pDevice); 754 gs.Create(pDevice);
755 755
756 CFX_Matrix mt; 756 CFX_Matrix mt;
757 mt = *(CFX_Matrix*)pUser2Device; 757 mt = *(CFX_Matrix*)pUser2Device;
758 758
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
975 return TRUE; 975 return TRUE;
976 } 976 }
977 977
978 FX_BOOL CPDFSDK_XFAAnnotHandler::OnKillFocus(CPDFSDK_Annot* pAnnot, 978 FX_BOOL CPDFSDK_XFAAnnotHandler::OnKillFocus(CPDFSDK_Annot* pAnnot,
979 uint32_t nFlag) { 979 uint32_t nFlag) {
980 return TRUE; 980 return TRUE;
981 } 981 }
982 982
983 FX_BOOL CPDFSDK_XFAAnnotHandler::OnXFAChangedFocus(CPDFSDK_Annot* pOldAnnot, 983 FX_BOOL CPDFSDK_XFAAnnotHandler::OnXFAChangedFocus(CPDFSDK_Annot* pOldAnnot,
984 CPDFSDK_Annot* pNewAnnot) { 984 CPDFSDK_Annot* pNewAnnot) {
985 CXFA_FFWidgetHandler* pWidgetHandler = NULL; 985 CXFA_FFWidgetHandler* pWidgetHandler = nullptr;
986 986
987 if (pOldAnnot) 987 if (pOldAnnot)
988 pWidgetHandler = GetXFAWidgetHandler(pOldAnnot); 988 pWidgetHandler = GetXFAWidgetHandler(pOldAnnot);
989 else if (pNewAnnot) 989 else if (pNewAnnot)
990 pWidgetHandler = GetXFAWidgetHandler(pNewAnnot); 990 pWidgetHandler = GetXFAWidgetHandler(pNewAnnot);
991 991
992 if (pWidgetHandler) { 992 if (pWidgetHandler) {
993 FX_BOOL bRet = TRUE; 993 FX_BOOL bRet = TRUE;
994 CXFA_FFWidget* hWidget = pNewAnnot ? pNewAnnot->GetXFAWidget() : NULL; 994 CXFA_FFWidget* hWidget = pNewAnnot ? pNewAnnot->GetXFAWidget() : nullptr;
995 if (hWidget) { 995 if (hWidget) {
996 CXFA_FFPageView* pXFAPageView = hWidget->GetPageView(); 996 CXFA_FFPageView* pXFAPageView = hWidget->GetPageView();
997 if (pXFAPageView) { 997 if (pXFAPageView) {
998 bRet = pXFAPageView->GetDocView()->SetFocus(hWidget); 998 bRet = pXFAPageView->GetDocView()->SetFocus(hWidget);
999 if (pXFAPageView->GetDocView()->GetFocusWidget() == hWidget) 999 if (pXFAPageView->GetDocView()->GetFocusWidget() == hWidget)
1000 bRet = TRUE; 1000 bRet = TRUE;
1001 } 1001 }
1002 } 1002 }
1003 return bRet; 1003 return bRet;
1004 } 1004 }
1005 1005
1006 return TRUE; 1006 return TRUE;
1007 } 1007 }
1008 1008
1009 CXFA_FFWidgetHandler* CPDFSDK_XFAAnnotHandler::GetXFAWidgetHandler( 1009 CXFA_FFWidgetHandler* CPDFSDK_XFAAnnotHandler::GetXFAWidgetHandler(
1010 CPDFSDK_Annot* pAnnot) { 1010 CPDFSDK_Annot* pAnnot) {
1011 if (!pAnnot) 1011 if (!pAnnot)
1012 return NULL; 1012 return nullptr;
1013 1013
1014 CPDFSDK_PageView* pPageView = pAnnot->GetPageView(); 1014 CPDFSDK_PageView* pPageView = pAnnot->GetPageView();
1015 if (!pPageView) 1015 if (!pPageView)
1016 return NULL; 1016 return nullptr;
1017 1017
1018 CPDFSDK_Document* pSDKDoc = pPageView->GetSDKDocument(); 1018 CPDFSDK_Document* pSDKDoc = pPageView->GetSDKDocument();
1019 if (!pSDKDoc) 1019 if (!pSDKDoc)
1020 return NULL; 1020 return nullptr;
1021 1021
1022 CPDFXFA_Document* pDoc = pSDKDoc->GetXFADocument(); 1022 CPDFXFA_Document* pDoc = pSDKDoc->GetXFADocument();
1023 if (!pDoc) 1023 if (!pDoc)
1024 return NULL; 1024 return nullptr;
1025 1025
1026 CXFA_FFDocView* pDocView = pDoc->GetXFADocView(); 1026 CXFA_FFDocView* pDocView = pDoc->GetXFADocView();
1027 if (!pDocView) 1027 if (!pDocView)
1028 return NULL; 1028 return nullptr;
1029 1029
1030 return pDocView->GetWidgetHandler(); 1030 return pDocView->GetWidgetHandler();
1031 } 1031 }
1032 1032
1033 #define FWL_KEYFLAG_Ctrl (1 << 0) 1033 #define FWL_KEYFLAG_Ctrl (1 << 0)
1034 #define FWL_KEYFLAG_Alt (1 << 1) 1034 #define FWL_KEYFLAG_Alt (1 << 1)
1035 #define FWL_KEYFLAG_Shift (1 << 2) 1035 #define FWL_KEYFLAG_Shift (1 << 2)
1036 #define FWL_KEYFLAG_LButton (1 << 3) 1036 #define FWL_KEYFLAG_LButton (1 << 3)
1037 #define FWL_KEYFLAG_RButton (1 << 4) 1037 #define FWL_KEYFLAG_RButton (1 << 4)
1038 #define FWL_KEYFLAG_MButton (1 << 5) 1038 #define FWL_KEYFLAG_MButton (1 << 5)
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1091 1091
1092 CPDFSDK_Annot* CPDFSDK_AnnotIterator::PrevAnnot() { 1092 CPDFSDK_Annot* CPDFSDK_AnnotIterator::PrevAnnot() {
1093 if (m_pos < m_iteratorAnnotList.size()) 1093 if (m_pos < m_iteratorAnnotList.size())
1094 return m_iteratorAnnotList[m_iteratorAnnotList.size() - ++m_pos]; 1094 return m_iteratorAnnotList[m_iteratorAnnotList.size() - ++m_pos];
1095 return nullptr; 1095 return nullptr;
1096 } 1096 }
1097 1097
1098 CPDFSDK_Annot* CPDFSDK_AnnotIterator::Next() { 1098 CPDFSDK_Annot* CPDFSDK_AnnotIterator::Next() {
1099 return m_bReverse ? PrevAnnot() : NextAnnot(); 1099 return m_bReverse ? PrevAnnot() : NextAnnot();
1100 } 1100 }
OLDNEW
« no previous file with comments | « fpdfsdk/fsdk_actionhandler.cpp ('k') | fpdfsdk/fsdk_baseannot.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698