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

Side by Side Diff: fpdfsdk/fsdk_annothandler.cpp

Issue 2051233002: Remove more casts, part 7. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: 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
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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 90
91 return nullptr; 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 pAnnot;
101 } 101 }
102 } 102 }
103 103
104 void CPDFSDK_AnnotHandlerMgr::Annot_OnCreate(CPDFSDK_Annot* pAnnot) { 104 void CPDFSDK_AnnotHandlerMgr::Annot_OnCreate(CPDFSDK_Annot* pAnnot) {
105 CPDF_Annot* pPDFAnnot = pAnnot->GetPDFAnnot(); 105 CPDF_Annot* pPDFAnnot = pAnnot->GetPDFAnnot();
106 106
107 CPDFSDK_DateTime curTime; 107 CPDFSDK_DateTime curTime;
108 pPDFAnnot->GetAnnotDict()->SetAtString("M", curTime.ToPDFDateTimeString()); 108 pPDFAnnot->GetAnnotDict()->SetAtString("M", curTime.ToPDFDateTimeString());
109 pPDFAnnot->GetAnnotDict()->SetAtNumber("F", 0); 109 pPDFAnnot->GetAnnotDict()->SetAtNumber("F", 0);
110 110
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 CBA_AnnotIterator ai(pSDKAnnot->GetPageView(), "Widget", ""); 395 CBA_AnnotIterator ai(pSDKAnnot->GetPageView(), "Widget", "");
396 return bNext ? ai.GetNextAnnot(pSDKAnnot) : ai.GetPrevAnnot(pSDKAnnot); 396 return bNext ? ai.GetNextAnnot(pSDKAnnot) : ai.GetPrevAnnot(pSDKAnnot);
397 #endif // PDF_ENABLE_XFA 397 #endif // PDF_ENABLE_XFA
398 } 398 }
399 399
400 FX_BOOL CPDFSDK_BFAnnotHandler::CanAnswer(CPDFSDK_Annot* pAnnot) { 400 FX_BOOL CPDFSDK_BFAnnotHandler::CanAnswer(CPDFSDK_Annot* pAnnot) {
401 ASSERT(pAnnot->GetType() == "Widget"); 401 ASSERT(pAnnot->GetType() == "Widget");
402 if (pAnnot->GetSubType() == BFFT_SIGNATURE) 402 if (pAnnot->GetSubType() == BFFT_SIGNATURE)
403 return FALSE; 403 return FALSE;
404 404
405 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; 405 CPDFSDK_Widget* pWidget = static_cast<CPDFSDK_Widget*>(pAnnot);
406 if (!pWidget->IsVisible()) 406 if (!pWidget->IsVisible())
407 return FALSE; 407 return FALSE;
408 408
409 int nFieldFlags = pWidget->GetFieldFlags(); 409 int nFieldFlags = pWidget->GetFieldFlags();
410 if ((nFieldFlags & FIELDFLAG_READONLY) == FIELDFLAG_READONLY) 410 if ((nFieldFlags & FIELDFLAG_READONLY) == FIELDFLAG_READONLY)
411 return FALSE; 411 return FALSE;
412 412
413 if (pWidget->GetFieldType() == FIELDTYPE_PUSHBUTTON) 413 if (pWidget->GetFieldType() == FIELDTYPE_PUSHBUTTON)
414 return TRUE; 414 return TRUE;
415 415
(...skipping 28 matching lines...) Expand all
444 return nullptr; 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 std::unique_ptr<CPDFSDK_Widget> pWidget(static_cast<CPDFSDK_Widget*>(pAnnot));
455 CPDFSDK_InterForm* pInterForm = pWidget->GetInterForm(); 455 CPDFSDK_InterForm* pInterForm = pWidget->GetInterForm();
456 CPDF_FormControl* pCtrol = pWidget->GetFormControl(); 456 CPDF_FormControl* pControl = pWidget->GetFormControl();
457 pInterForm->RemoveMap(pCtrol); 457 pInterForm->RemoveMap(pControl);
458
459 delete pWidget;
460 } 458 }
461 459
462 void CPDFSDK_BFAnnotHandler::OnDraw(CPDFSDK_PageView* pPageView, 460 void CPDFSDK_BFAnnotHandler::OnDraw(CPDFSDK_PageView* pPageView,
463 CPDFSDK_Annot* pAnnot, 461 CPDFSDK_Annot* pAnnot,
464 CFX_RenderDevice* pDevice, 462 CFX_RenderDevice* pDevice,
465 CFX_Matrix* pUser2Device, 463 CFX_Matrix* pUser2Device,
466 uint32_t dwFlags) { 464 uint32_t dwFlags) {
467 CFX_ByteString sSubType = pAnnot->GetSubType(); 465 CFX_ByteString sSubType = pAnnot->GetSubType();
468 466
469 if (sSubType == BFFT_SIGNATURE) { 467 if (sSubType == BFFT_SIGNATURE) {
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 } else { 642 } else {
645 if (m_pFormFiller) 643 if (m_pFormFiller)
646 m_pFormFiller->OnCreate(pAnnot); 644 m_pFormFiller->OnCreate(pAnnot);
647 } 645 }
648 } 646 }
649 647
650 void CPDFSDK_BFAnnotHandler::OnLoad(CPDFSDK_Annot* pAnnot) { 648 void CPDFSDK_BFAnnotHandler::OnLoad(CPDFSDK_Annot* pAnnot) {
651 if (pAnnot->GetSubType() == BFFT_SIGNATURE) 649 if (pAnnot->GetSubType() == BFFT_SIGNATURE)
652 return; 650 return;
653 651
654 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; 652 CPDFSDK_Widget* pWidget = static_cast<CPDFSDK_Widget*>(pAnnot);
655 if (!pWidget->IsAppearanceValid()) 653 if (!pWidget->IsAppearanceValid())
656 pWidget->ResetAppearance(nullptr, FALSE); 654 pWidget->ResetAppearance(nullptr, FALSE);
657 655
658 int nFieldType = pWidget->GetFieldType(); 656 int nFieldType = pWidget->GetFieldType();
659 if (nFieldType == FIELDTYPE_TEXTFIELD || nFieldType == FIELDTYPE_COMBOBOX) { 657 if (nFieldType == FIELDTYPE_TEXTFIELD || nFieldType == FIELDTYPE_COMBOBOX) {
660 FX_BOOL bFormated = FALSE; 658 FX_BOOL bFormated = FALSE;
661 CFX_WideString sValue = pWidget->OnFormat(bFormated); 659 CFX_WideString sValue = pWidget->OnFormat(bFormated);
662 if (bFormated && nFieldType == FIELDTYPE_COMBOBOX) { 660 if (bFormated && nFieldType == FIELDTYPE_COMBOBOX) {
663 pWidget->ResetAppearance(sValue.c_str(), FALSE); 661 pWidget->ResetAppearance(sValue.c_str(), FALSE);
664 } 662 }
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
1091 1089
1092 CPDFSDK_Annot* CPDFSDK_AnnotIterator::PrevAnnot() { 1090 CPDFSDK_Annot* CPDFSDK_AnnotIterator::PrevAnnot() {
1093 if (m_pos < m_iteratorAnnotList.size()) 1091 if (m_pos < m_iteratorAnnotList.size())
1094 return m_iteratorAnnotList[m_iteratorAnnotList.size() - ++m_pos]; 1092 return m_iteratorAnnotList[m_iteratorAnnotList.size() - ++m_pos];
1095 return nullptr; 1093 return nullptr;
1096 } 1094 }
1097 1095
1098 CPDFSDK_Annot* CPDFSDK_AnnotIterator::Next() { 1096 CPDFSDK_Annot* CPDFSDK_AnnotIterator::Next() {
1099 return m_bReverse ? PrevAnnot() : NextAnnot(); 1097 return m_bReverse ? PrevAnnot() : NextAnnot();
1100 } 1098 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698